Skip to content

Commit 2ea6973

Browse files
committed
Minor optimizations
1 parent c085c3c commit 2ea6973

File tree

5 files changed

+15
-30
lines changed

5 files changed

+15
-30
lines changed

app/src/main/java/org/nitri/opentopo/MainActivity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
196196
}
197197

198198
@Override
199-
protected void onSaveInstanceState(Bundle outState) {
199+
protected void onSaveInstanceState(@NonNull Bundle outState) {
200200
if (!TextUtils.isEmpty(mGpxUriString)) {
201201
outState.putString(GPX_URI_STATE, mGpxUriString);
202202
}
@@ -205,7 +205,7 @@ protected void onSaveInstanceState(Bundle outState) {
205205

206206
@Override
207207
public void setUpNavigation(boolean upNavigation) {
208-
if (getSupportFragmentManager() != null && getSupportActionBar() != null) {
208+
if (getSupportActionBar() != null) {
209209
if (upNavigation) {
210210
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
211211
getSupportActionBar().setDisplayShowHomeEnabled(true);

app/src/main/java/org/nitri/opentopo/MapFragment.java

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -96,18 +96,17 @@ public boolean onZoom(ZoomEvent event) {
9696

9797
private OnFragmentInteractionListener mListener;
9898

99-
final static String PARAM_LATITUDE = "latitude";
100-
final static String PARAM_LONGITUDE = "longitude";
101-
final static String PARAM_NEARBY_PLACE = "nearby_place";
99+
private final static String PARAM_LATITUDE = "latitude";
100+
private final static String PARAM_LONGITUDE = "longitude";
102101

103102
private SharedPreferences mPrefs;
104103
private static final String MAP_PREFS = "map_prefs";
105104

106-
final static String PREF_BASE_MAP = "base_map";
107-
final static String PREF_OVERLAY = "overlay";
105+
private final static String PREF_BASE_MAP = "base_map";
106+
private final static String PREF_OVERLAY = "overlay";
108107

109-
final static int BASE_MAP_OTM = 1;
110-
final static int BASE_MAP_OSM = 2;
108+
private final static int BASE_MAP_OTM = 1;
109+
private final static int BASE_MAP_OSM = 2;
111110

112111

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

136-
public static MapFragment newInstance(boolean showNearbyPlace) {
137-
MapFragment mapFragment = new MapFragment();
138-
Bundle arguments = new Bundle();
139-
arguments.putBoolean(PARAM_NEARBY_PLACE, showNearbyPlace);
140-
mapFragment.setArguments(arguments);
141-
return mapFragment;
142-
}
143-
144135
@Override
145136
public void onCreate(Bundle savedInstanceState) {
146137
super.onCreate(savedInstanceState);
@@ -225,9 +216,6 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
225216
final double lon = arguments.getDouble(PARAM_LONGITUDE);
226217
animateToLatLon(lat, lon);
227218
}
228-
if (arguments.containsKey(PARAM_NEARBY_PLACE) && arguments.getBoolean(PARAM_NEARBY_PLACE)) {
229-
mListener.getSelectedNearbyPlace();
230-
}
231219
}
232220
if (mListener.getSelectedNearbyPlace() != null) {
233221
showNearbyPlace(mListener.getSelectedNearbyPlace());
@@ -419,7 +407,6 @@ public void setNearbyPlace() {
419407
}
420408

421409
private void showNearbyPlace(NearbyItem nearbyPlace) {
422-
//TODO: set overlay item
423410
mOverlayHelper.setNearby(nearbyPlace);
424411
animateToLatLon(nearbyPlace.getLat(), nearbyPlace.getLon());
425412
}

app/src/main/java/org/nitri/opentopo/NearbyFragment.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,11 @@ public class NearbyFragment extends Fragment implements NearbyAdapter.OnItemClic
4545
private double mLatitude;
4646
private double mLongitude;
4747

48-
private String wikiBaseUrl;
48+
private Gson gson = new GsonBuilder().setLenient().create();
4949

50-
Gson gson = new GsonBuilder().setLenient().create();
50+
private Retrofit retrofit;
5151

52-
Retrofit retrofit;
53-
54-
List<NearbyItem> mNearbyItems = new ArrayList<>();
52+
private List<NearbyItem> mNearbyItems = new ArrayList<>();
5553
private NearbyAdapter mNearbyAdapter;
5654

5755

@@ -86,7 +84,7 @@ public void onCreate(Bundle savedInstanceState) {
8684
mLongitude = getArguments().getDouble(PARAM_LONGITUDE);
8785
}
8886

89-
wikiBaseUrl = requireContext().getString(R.string.wiki_base_url);
87+
String wikiBaseUrl = requireContext().getString(R.string.wiki_base_url);
9088
retrofit = new Retrofit.Builder()
9189
.baseUrl(wikiBaseUrl)
9290
.addConverterFactory(GsonConverterFactory.create(gson))

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ buildscript {
77
jcenter()
88
}
99
dependencies {
10-
classpath 'com.android.tools.build:gradle:3.3.1'
10+
classpath 'com.android.tools.build:gradle:3.4.2'
1111
}
1212
}
1313

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Sun Mar 03 08:18:01 CET 2019
1+
#Fri Jul 19 16:12:37 CEST 2019
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip

0 commit comments

Comments
 (0)