Merge pull request #381 from nextLane/nextLane/refreshNearBy

Adding refresh option for Nearby
This commit is contained in:
Vivek Maskara 2017-03-16 10:41:12 +05:30 committed by GitHub
commit 76027025f5
5 changed files with 41 additions and 3 deletions

View file

@ -9,6 +9,9 @@ import android.os.Bundle;
import android.support.v4.app.FragmentTransaction; import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.util.Log; import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import fr.free.nrw.commons.R; import fr.free.nrw.commons.R;
@ -40,12 +43,33 @@ public class NearbyActivity extends AppCompatActivity {
ft.add(R.id.container, fragment); ft.add(R.id.container, fragment);
ft.commit(); ft.commit();
} }
@Override
public boolean onCreateOptionsMenu (Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu_nearby, menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle item selection
switch (item.getItemId()) {
case R.id.action_refresh:
refreshView();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
@Override @Override
protected void onResume(){ protected void onResume(){
super.onResume(); super.onResume();
} }
protected void refreshView()
{
getSupportFragmentManager().beginTransaction()
.replace(R.id.container, new NearbyListFragment()).commit();
}
protected LatLng getmLatestLocation() { protected LatLng getmLatestLocation() {
return mLatestLocation; return mLatestLocation;
} }
@ -117,4 +141,4 @@ public class NearbyActivity extends AppCompatActivity {
unregisterLocationManager(); unregisterLocationManager();
} }
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 856 B

View file

@ -0,0 +1,13 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" tools:context=".MainActivity">
<item
android:id="@+id/action_refresh"
android:title="@string/refresh_button"
android:icon="@drawable/ic_action_refresh"
android:orderInCategory="1"
app:showAsAction="ifRoom"
/>
</menu>

View file

@ -49,6 +49,7 @@
<string name="menu_upload_single">Upload</string> <string name="menu_upload_single">Upload</string>
<string name="categories_search_text_hint">Search categories</string> <string name="categories_search_text_hint">Search categories</string>
<string name="menu_save_categories">Save</string> <string name="menu_save_categories">Save</string>
<string name="refresh_button">Refresh</string>
<plurals name="contributions_subtitle"> <plurals name="contributions_subtitle">
<item quantity="zero">No uploads yet</item> <item quantity="zero">No uploads yet</item>
<item quantity="one">1 upload</item> <item quantity="one">1 upload</item>

View file

@ -1,4 +1,4 @@
#Wed Mar 08 18:04:14 GMT 2017
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME