Skip to content

Commit

Permalink
Minor optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
Pygmalion69 committed Jul 21, 2019
1 parent c085c3c commit 2ea6973
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 30 deletions.
4 changes: 2 additions & 2 deletions app/src/main/java/org/nitri/opentopo/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
}

@Override
protected void onSaveInstanceState(Bundle outState) {
protected void onSaveInstanceState(@NonNull Bundle outState) {
if (!TextUtils.isEmpty(mGpxUriString)) {
outState.putString(GPX_URI_STATE, mGpxUriString);
}
Expand All @@ -205,7 +205,7 @@ protected void onSaveInstanceState(Bundle outState) {

@Override
public void setUpNavigation(boolean upNavigation) {
if (getSupportFragmentManager() != null && getSupportActionBar() != null) {
if (getSupportActionBar() != null) {
if (upNavigation) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
Expand Down
25 changes: 6 additions & 19 deletions app/src/main/java/org/nitri/opentopo/MapFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,17 @@ public boolean onZoom(ZoomEvent event) {

private OnFragmentInteractionListener mListener;

final static String PARAM_LATITUDE = "latitude";
final static String PARAM_LONGITUDE = "longitude";
final static String PARAM_NEARBY_PLACE = "nearby_place";
private final static String PARAM_LATITUDE = "latitude";
private final static String PARAM_LONGITUDE = "longitude";

private SharedPreferences mPrefs;
private static final String MAP_PREFS = "map_prefs";

final static String PREF_BASE_MAP = "base_map";
final static String PREF_OVERLAY = "overlay";
private final static String PREF_BASE_MAP = "base_map";
private final static String PREF_OVERLAY = "overlay";

final static int BASE_MAP_OTM = 1;
final static int BASE_MAP_OSM = 2;
private final static int BASE_MAP_OTM = 1;
private final static int BASE_MAP_OSM = 2;


private int mBaseMap = BASE_MAP_OTM;
Expand All @@ -133,14 +132,6 @@ public static MapFragment newInstance(double lat, double lon) {
return mapFragment;
}

public static MapFragment newInstance(boolean showNearbyPlace) {
MapFragment mapFragment = new MapFragment();
Bundle arguments = new Bundle();
arguments.putBoolean(PARAM_NEARBY_PLACE, showNearbyPlace);
mapFragment.setArguments(arguments);
return mapFragment;
}

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand Down Expand Up @@ -225,9 +216,6 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
final double lon = arguments.getDouble(PARAM_LONGITUDE);
animateToLatLon(lat, lon);
}
if (arguments.containsKey(PARAM_NEARBY_PLACE) && arguments.getBoolean(PARAM_NEARBY_PLACE)) {
mListener.getSelectedNearbyPlace();
}
}
if (mListener.getSelectedNearbyPlace() != null) {
showNearbyPlace(mListener.getSelectedNearbyPlace());
Expand Down Expand Up @@ -419,7 +407,6 @@ public void setNearbyPlace() {
}

private void showNearbyPlace(NearbyItem nearbyPlace) {
//TODO: set overlay item
mOverlayHelper.setNearby(nearbyPlace);
animateToLatLon(nearbyPlace.getLat(), nearbyPlace.getLon());
}
Expand Down
10 changes: 4 additions & 6 deletions app/src/main/java/org/nitri/opentopo/NearbyFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,11 @@ public class NearbyFragment extends Fragment implements NearbyAdapter.OnItemClic
private double mLatitude;
private double mLongitude;

private String wikiBaseUrl;
private Gson gson = new GsonBuilder().setLenient().create();

Gson gson = new GsonBuilder().setLenient().create();
private Retrofit retrofit;

Retrofit retrofit;

List<NearbyItem> mNearbyItems = new ArrayList<>();
private List<NearbyItem> mNearbyItems = new ArrayList<>();
private NearbyAdapter mNearbyAdapter;


Expand Down Expand Up @@ -86,7 +84,7 @@ public void onCreate(Bundle savedInstanceState) {
mLongitude = getArguments().getDouble(PARAM_LONGITUDE);
}

wikiBaseUrl = requireContext().getString(R.string.wiki_base_url);
String wikiBaseUrl = requireContext().getString(R.string.wiki_base_url);
retrofit = new Retrofit.Builder()
.baseUrl(wikiBaseUrl)
.addConverterFactory(GsonConverterFactory.create(gson))
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.1'
classpath 'com.android.tools.build:gradle:3.4.2'
}
}

Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sun Mar 03 08:18:01 CET 2019
#Fri Jul 19 16:12:37 CEST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip

0 comments on commit 2ea6973

Please sign in to comment.