diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/cgeo/geocaching/StaticMapsProvider.java | 2 | ||||
| -rw-r--r-- | src/cgeo/geocaching/cgBase.java | 56 | ||||
| -rw-r--r-- | src/cgeo/geocaching/cgCacheListAdapter.java | 3 | ||||
| -rw-r--r-- | src/cgeo/geocaching/cgeo.java | 105 | ||||
| -rw-r--r-- | src/cgeo/geocaching/cgeoapplication.java | 16 | ||||
| -rw-r--r-- | src/cgeo/geocaching/cgeoauth.java | 2 | ||||
| -rw-r--r-- | src/cgeo/geocaching/cgeodetail.java | 4 | ||||
| -rw-r--r-- | src/cgeo/geocaching/cgeotouch.java | 9 | ||||
| -rw-r--r-- | src/cgeo/geocaching/cgeovisit.java | 9 | ||||
| -rw-r--r-- | src/cgeo/geocaching/cgeowaypointadd.java | 4 | ||||
| -rw-r--r-- | src/cgeo/geocaching/files/LocParser.java | 1 | ||||
| -rw-r--r-- | src/cgeo/geocaching/mapcommon/cgMapOverlay.java | 2 |
12 files changed, 117 insertions, 96 deletions
diff --git a/src/cgeo/geocaching/StaticMapsProvider.java b/src/cgeo/geocaching/StaticMapsProvider.java index 97e9bd1..ae1962c 100644 --- a/src/cgeo/geocaching/StaticMapsProvider.java +++ b/src/cgeo/geocaching/StaticMapsProvider.java @@ -123,7 +123,7 @@ public class StaticMapsProvider { } public static void downloadMaps(cgCache cache, cgSettings settings, Activity activity) { - if (settings.storeOfflineMaps != 1 || cache.coords == null || StringUtils.isNotBlank(cache.geocode)) { + if (settings.storeOfflineMaps != 1 || cache.coords == null || StringUtils.isBlank(cache.geocode)) { return; } diff --git a/src/cgeo/geocaching/cgBase.java b/src/cgeo/geocaching/cgBase.java index f06ac03..56c4856 100644 --- a/src/cgeo/geocaching/cgBase.java +++ b/src/cgeo/geocaching/cgBase.java @@ -485,6 +485,23 @@ public class cgBase { setViewstates(getViewstates(page), params); } + /** + * checks if an Array of Strings is empty or not. Empty means: + * - Array is null + * - or all elements are null or empty strings + */ + public static boolean isEmpty(String[] a) { + if (a == null) + return true; + + for (String s: a) { + if (StringUtils.isNotEmpty(s)) { + return false; + } + } + return true; + } + public class loginThread extends Thread { @@ -521,7 +538,7 @@ public class cgBase { viewstates = getViewstates(loginData); - if (ArrayUtils.isEmpty(viewstates)) { + if (isEmpty(viewstates)) { Log.e(cgSettings.tag, "cgeoBase.login: Failed to find viewstates"); return -1; // no viewstates } @@ -1022,7 +1039,7 @@ public class cgBase { final JSONObject dataJSON = new JSONObject(json); final JSONObject extra = dataJSON.getJSONObject("cs"); - if ( StringUtils.isNotBlank(data)) { + if (extra != null && extra.length() > 0) { int count = extra.getInt("count"); if (count > 0 && extra.has("cc")) { @@ -1765,13 +1782,13 @@ public class cgBase { } private static void checkFields(cgCache cache) { - if (StringUtils.isEmpty(cache.geocode)) { + if (StringUtils.isBlank(cache.geocode)) { Log.w(cgSettings.tag, "geo code not parsed correctly"); } - if (StringUtils.isEmpty(cache.name)) { + if (StringUtils.isBlank(cache.name)) { Log.w(cgSettings.tag, "name not parsed correctly"); } - if (StringUtils.isEmpty(cache.guid)) { + if (StringUtils.isBlank(cache.guid)) { Log.w(cgSettings.tag, "guid not parsed correctly"); } if (cache.terrain == null || cache.terrain == 0.0) { @@ -1780,10 +1797,10 @@ public class cgBase { if (cache.difficulty == null || cache.difficulty == 0.0) { Log.w(cgSettings.tag, "difficulty not parsed correctly"); } - if (StringUtils.isEmpty(cache.owner)) { + if (StringUtils.isBlank(cache.owner)) { Log.w(cgSettings.tag, "owner not parsed correctly"); } - if (StringUtils.isEmpty(cache.ownerReal)) { + if (StringUtils.isBlank(cache.ownerReal)) { Log.w(cgSettings.tag, "owner real not parsed correctly"); } if (cache.hidden == null) { @@ -1792,16 +1809,16 @@ public class cgBase { if (cache.favouriteCnt == null) { Log.w(cgSettings.tag, "favoriteCount not parsed correctly"); } - if (StringUtils.isEmpty(cache.size)) { + if (StringUtils.isBlank(cache.size)) { Log.w(cgSettings.tag, "size not parsed correctly"); } - if (StringUtils.isNotBlank(cache.type)) { + if (StringUtils.isBlank(cache.type)) { Log.w(cgSettings.tag, "type not parsed correctly"); } if (cache.coords == null) { Log.w(cgSettings.tag, "coordinates not parsed correctly"); } - if (StringUtils.isEmpty(cache.location)) { + if (StringUtils.isBlank(cache.location)) { Log.w(cgSettings.tag, "location not parsed correctly"); } } @@ -2668,7 +2685,7 @@ public class cgBase { return searchId; } - if (ArrayUtils.isEmpty(viewstates)) { + if (isEmpty(viewstates)) { Log.e(cgSettings.tag, "cgeoBase.searchByNextPage: No viewstate given"); return searchId; } @@ -2754,7 +2771,7 @@ public class cgBase { } if (forceReload == false && reason == 0 && (app.isOffline(geocode, guid) || app.isThere(geocode, guid, true, true))) { - if (StringUtils.isBlank(geocode) && StringUtils.isBlank(guid)) { + if (StringUtils.isBlank(geocode) && StringUtils.isNotBlank(guid)) { geocode = app.getGeocode(guid); } @@ -2787,7 +2804,7 @@ public class cgBase { if (StringUtils.isEmpty(page)) { if (app.isThere(geocode, guid, true, false)) { - if (StringUtils.isBlank(geocode) && StringUtils.isBlank(guid)) { + if (StringUtils.isBlank(geocode) && StringUtils.isNotBlank(guid)) { Log.i(cgSettings.tag, "Loading old cache from cache."); geocode = app.getGeocode(guid); @@ -2904,7 +2921,7 @@ public class cgBase { return null; } - if (StringUtils.isBlank(latitude)) { + if (StringUtils.isBlank(cacheType)) { cacheType = null; } @@ -3288,7 +3305,7 @@ public class cgBase { public int postLog(cgeoapplication app, String geocode, String cacheid, String[] viewstates, int logType, int year, int month, int day, String log, List<cgTrackableLog> trackables) { - if (ArrayUtils.isEmpty(viewstates)) { + if (isEmpty(viewstates)) { Log.e(cgSettings.tag, "cgeoBase.postLog: No viewstate given"); return 1000; } @@ -3385,7 +3402,7 @@ public class cgBase { if (matcher.find() && matcher.groupCount() > 0) { final String[] viewstatesConfirm = getViewstates(page); - if (ArrayUtils.isEmpty(viewstatesConfirm)) { + if (isEmpty(viewstatesConfirm)) { Log.e(cgSettings.tag, "cgeoBase.postLog: No viewstate for confirm log"); return 1000; } @@ -3450,7 +3467,7 @@ public class cgBase { public int postLogTrackable(String tbid, String trackingCode, String[] viewstates, int logType, int year, int month, int day, String log) { - if (ArrayUtils.isEmpty(viewstates)) { + if (isEmpty(viewstates)) { Log.e(cgSettings.tag, "cgeoBase.postLogTrackable: No viewstate given"); return 1000; } @@ -3643,7 +3660,7 @@ public class cgBase { if (app == null) { return; } - if (settings == null || StringUtils.isBlank(settings.tokenPublic) || StringUtils.isNotBlank(settings.tokenSecret)) { + if (settings == null || StringUtils.isBlank(settings.tokenPublic) || StringUtils.isBlank(settings.tokenSecret)) { return; } @@ -4028,7 +4045,7 @@ public class cgBase { response = request(secureRedir, newLocation.getHost(), newLocation.getPath(), "GET", new HashMap<String, String>(), requestId, false, false, false); } } else { - if (StringUtils.isNotBlank(buffer)) { + if (StringUtils.isNotEmpty(buffer)) { replaceWhitespace(buffer); String data = buffer.toString(); buffer = null; @@ -4877,7 +4894,6 @@ public class cgBase { gcIcons.put("mystery-disabled", R.drawable.marker_cache_mystery_disabled); gcIcons.put("gchq-disabled", R.drawable.marker_cache_gchq_disabled); } - } public static boolean runNavigation(Activity activity, Resources res, cgSettings settings, Double latitude, Double longitude) { diff --git a/src/cgeo/geocaching/cgCacheListAdapter.java b/src/cgeo/geocaching/cgCacheListAdapter.java index 66ca5a3..dec5bef 100644 --- a/src/cgeo/geocaching/cgCacheListAdapter.java +++ b/src/cgeo/geocaching/cgCacheListAdapter.java @@ -445,10 +445,13 @@ public class cgCacheListAdapter extends ArrayAdapter<cgCache> { if (cache.found && cache.logOffline) { holder.logStatusMark.setImageResource(R.drawable.mark_green_red); + holder.logStatusMark.setVisibility(View.VISIBLE); } else if (cache.found) { holder.logStatusMark.setImageResource(R.drawable.mark_green); + holder.logStatusMark.setVisibility(View.VISIBLE); } else if (cache.logOffline) { holder.logStatusMark.setImageResource(R.drawable.mark_red); + holder.logStatusMark.setVisibility(View.VISIBLE); } else { holder.logStatusMark.setVisibility(View.GONE); } diff --git a/src/cgeo/geocaching/cgeo.java b/src/cgeo/geocaching/cgeo.java index 5fe411d..1c7a4c4 100644 --- a/src/cgeo/geocaching/cgeo.java +++ b/src/cgeo/geocaching/cgeo.java @@ -27,6 +27,7 @@ import android.view.ContextMenu; import android.view.Menu; import android.view.MenuItem; import android.view.View; +import android.view.View.OnClickListener; import android.widget.RelativeLayout; import android.widget.TextView; import cgeo.geocaching.activity.AbstractActivity; @@ -451,32 +452,47 @@ public class cgeo extends AbstractActivity { final View findOnMap = findViewById(R.id.map); findOnMap.setClickable(true); - findOnMap.setOnClickListener(new cgeoFindOnMapListener()); + findOnMap.setOnClickListener(new OnClickListener() { + public void onClick(View v) { + cgeoFindOnMap(v); + } + }); final View findByOffline = findViewById(R.id.search_offline); findByOffline.setClickable(true); - findByOffline.setOnClickListener(new cgeoFindByOfflineListener()); + findByOffline.setOnClickListener(new OnClickListener() { + public void onClick(View v) { + cgeoFindByOffline(v); + } + }); registerForContextMenu(findByOffline); (new countBubbleUpdate()).start(); final View advanced = findViewById(R.id.advanced_button); advanced.setClickable(true); - advanced.setOnClickListener(new cgeoSearchListener()); + advanced.setOnClickListener(new OnClickListener() { + public void onClick(View v) { + cgeoSearch(v); + } + }); final View any = findViewById(R.id.any_button); any.setClickable(true); - any.setOnClickListener(new cgeoPointListener()); + any.setOnClickListener(new OnClickListener() { + public void onClick(View v) { + cgeoPoint(v); + } + }); final View filter = findViewById(R.id.filter_button); + filter.setClickable(true); registerForContextMenu(filter); filter.setOnClickListener(new View.OnClickListener() { - - public void onClick(View view) { - openContextMenu(view); + public void onClick(View v) { + openContextMenu(v); } }); - filter.setClickable(true); setFilterTitle(); } @@ -500,7 +516,11 @@ public class cgeo extends AbstractActivity { if (geo.coordsNow != null) { View findNearest = findViewById(R.id.nearest); findNearest.setClickable(true); - findNearest.setOnClickListener(new cgeoFindNearestListener()); + findNearest.setOnClickListener(new OnClickListener() { + public void onClick(View v) { + cgeoFindNearest(v); + } + }); findNearest.setBackgroundResource(R.drawable.main_nearby); String satellites = null; @@ -568,50 +588,45 @@ public class cgeo extends AbstractActivity { } } - private class cgeoFindNearestListener implements View.OnClickListener { - - public void onClick(View arg0) { - if (geo == null) { - return; - } - - final Intent cachesIntent = new Intent(context, cgeocaches.class); - cachesIntent.putExtra("type", "nearest"); - cachesIntent.putExtra("latitude", geo.coordsNow.getLatitude()); - cachesIntent.putExtra("longitude", geo.coordsNow.getLongitude()); - cachesIntent.putExtra("cachetype", settings.cacheType); - context.startActivity(cachesIntent); - } + public void cgeoFindOnMap(View v) { + findViewById(R.id.map).setPressed(true); + context.startActivity(new Intent(context, settings.getMapFactory().getMapClass())); } - - private class cgeoFindOnMapListener implements View.OnClickListener { - - public void onClick(View arg0) { - context.startActivity(new Intent(context, settings.getMapFactory().getMapClass())); + + public void cgeoFindNearest(View v) { + if (geo == null) { + return; } - } - - private class cgeoFindByOfflineListener implements View.OnClickListener { - public void onClick(View arg0) { - final Intent cachesIntent = new Intent(context, cgeocaches.class); - cachesIntent.putExtra("type", "offline"); - context.startActivity(cachesIntent); - } + findViewById(R.id.nearest).setPressed(true); + final Intent cachesIntent = new Intent(context, cgeocaches.class); + cachesIntent.putExtra("type", "nearest"); + cachesIntent.putExtra("latitude", geo.coordsNow.getLatitude()); + cachesIntent.putExtra("longitude", geo.coordsNow.getLongitude()); + cachesIntent.putExtra("cachetype", settings.cacheType); + context.startActivity(cachesIntent); } - private class cgeoSearchListener implements View.OnClickListener { - - public void onClick(View arg0) { - context.startActivity(new Intent(context, cgeoadvsearch.class)); - } + public void cgeoFindByOffline(View v) { + findViewById(R.id.search_offline).setPressed(true); + final Intent cachesIntent = new Intent(context, cgeocaches.class); + cachesIntent.putExtra("type", "offline"); + context.startActivity(cachesIntent); } - private class cgeoPointListener implements View.OnClickListener { + public void cgeoSearch(View v) { + findViewById(R.id.advanced_button).setPressed(true); + context.startActivity(new Intent(context, cgeoadvsearch.class)); + } - public void onClick(View arg0) { - context.startActivity(new Intent(context, cgeopoint.class)); - } + public void cgeoPoint(View v) { + findViewById(R.id.any_button).setPressed(true); + context.startActivity(new Intent(context, cgeopoint.class)); + } + + public void cgeoFilter(View v) { + findViewById(R.id.filter_button).setPressed(true); + findViewById(R.id.filter_button).performClick(); } private class countBubbleUpdate extends Thread { diff --git a/src/cgeo/geocaching/cgeoapplication.java b/src/cgeo/geocaching/cgeoapplication.java index bb49973..595db9e 100644 --- a/src/cgeo/geocaching/cgeoapplication.java +++ b/src/cgeo/geocaching/cgeoapplication.java @@ -8,7 +8,6 @@ import java.util.List; import java.util.Map; import java.util.UUID; -import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.StringUtils; import android.app.Application; @@ -271,7 +270,7 @@ public class cgeoapplication extends Application { } public boolean setViewstates(final UUID searchId, String[] viewstates) { - if (ArrayUtils.isEmpty(viewstates)) { + if (cgBase.isEmpty(viewstates)) { return false; } if (searchId == null || searches.containsKey(searchId) == false) { @@ -693,12 +692,8 @@ public class cgeoapplication extends Application { if (newItem) { // save only newly downloaded data for (cgCache cache : cacheList) { - String geocode = cache.geocode.toUpperCase(); - String guid = cache.guid.toLowerCase(); - cache.reason = reason; - - boolean status = storeWithMerge(cache, false); + storeWithMerge(cache, false); } } @@ -716,12 +711,7 @@ public class cgeoapplication extends Application { searches.put(searchId, search); } - String geocode = cache.geocode.toUpperCase(); - String guid = cache.guid.toLowerCase(); - - boolean status = false; - - status = storeWithMerge(cache, cache.reason >= 1); + final boolean status = storeWithMerge(cache, cache.reason >= 1); if (status) { search.addGeocode(cache.geocode); diff --git a/src/cgeo/geocaching/cgeoauth.java b/src/cgeo/geocaching/cgeoauth.java index 0554a24..c20c13c 100644 --- a/src/cgeo/geocaching/cgeoauth.java +++ b/src/cgeo/geocaching/cgeoauth.java @@ -122,7 +122,7 @@ public class cgeoauth extends AbstractActivity { startButton.setEnabled(true); startButton.setOnClickListener(new startListener()); - if (StringUtils.isNotBlank(OAtoken) && StringUtils.isNotBlank(OAtokenSecret)) { + if (StringUtils.isBlank(OAtoken) && StringUtils.isBlank(OAtokenSecret)) { // start authorization process startButton.setText(res.getString(R.string.auth_start)); } else { diff --git a/src/cgeo/geocaching/cgeodetail.java b/src/cgeo/geocaching/cgeodetail.java index 9cbecb9..053ded1 100644 --- a/src/cgeo/geocaching/cgeodetail.java +++ b/src/cgeo/geocaching/cgeodetail.java @@ -613,11 +613,11 @@ public class cgeodetail extends AbstractActivity { try { - if (StringUtils.isBlank(geocode)) { + if (geocode == null && StringUtils.isNotBlank(cache.geocode)) { geocode = cache.geocode; } - if (StringUtils.isBlank(guid)) { + if (guid == null && StringUtils.isNotBlank(cache.guid)) { guid = cache.guid; } diff --git a/src/cgeo/geocaching/cgeotouch.java b/src/cgeo/geocaching/cgeotouch.java index 60c066c..8386018 100644 --- a/src/cgeo/geocaching/cgeotouch.java +++ b/src/cgeo/geocaching/cgeotouch.java @@ -6,7 +6,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.StringUtils; import android.app.Dialog; @@ -51,7 +50,7 @@ public class cgeotouch extends cgLogForm { private Handler loadDataHandler = new Handler() { @Override public void handleMessage(Message msg) { - if (ArrayUtils.isEmpty(viewstates) && attempts < 2) { + if (cgBase.isEmpty(viewstates) && attempts < 2) { showToast(res.getString(R.string.err_log_load_data_again)); loadData thread; @@ -59,7 +58,7 @@ public class cgeotouch extends cgLogForm { thread.start(); return; - } else if (ArrayUtils.isEmpty(viewstates) && attempts >= 2) { + } else if (cgBase.isEmpty(viewstates) && attempts >= 2) { showToast(res.getString(R.string.err_log_load_data)); showProgress(false); @@ -290,7 +289,7 @@ public class cgeotouch extends cgLogForm { tweetCheck.setChecked(true); Button buttonPost = (Button)findViewById(R.id.post); - if (ArrayUtils.isEmpty(viewstates)) { + if (cgBase.isEmpty(viewstates)) { buttonPost.setEnabled(false); buttonPost.setOnTouchListener(null); buttonPost.setOnClickListener(null); @@ -446,4 +445,4 @@ public class cgeotouch extends cgLogForm { return 1000; } -}
\ No newline at end of file +} diff --git a/src/cgeo/geocaching/cgeovisit.java b/src/cgeo/geocaching/cgeovisit.java index 65a09c7..da696ec 100644 --- a/src/cgeo/geocaching/cgeovisit.java +++ b/src/cgeo/geocaching/cgeovisit.java @@ -8,7 +8,6 @@ import java.util.List; import java.util.Locale; import java.util.Map; -import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.StringUtils; import android.app.Dialog; @@ -85,7 +84,7 @@ public class cgeovisit extends cgLogForm { showToast(res.getString(R.string.info_log_type_changed)); } - if (ArrayUtils.isEmpty(viewstates) && attempts < 2) { + if (cgBase.isEmpty(viewstates) && attempts < 2) { showToast(res.getString(R.string.err_log_load_data_again)); loadData thread; @@ -93,7 +92,7 @@ public class cgeovisit extends cgLogForm { thread.start(); return; - } else if (ArrayUtils.isEmpty(viewstates) && attempts >= 2) { + } else if (cgBase.isEmpty(viewstates) && attempts >= 2) { showToast(res.getString(R.string.err_log_load_data)); showProgress(false); @@ -243,7 +242,7 @@ public class cgeovisit extends cgLogForm { if ((StringUtils.isBlank(cacheid)) && StringUtils.isNotBlank(geocode)) { cacheid = app.getCacheid(geocode); } - if ((StringUtils.isBlank(geocode)) && StringUtils.isNotBlank(cacheid)) { + if (StringUtils.isBlank(geocode) && StringUtils.isNotBlank(cacheid)) { geocode = app.getGeocode(cacheid); } @@ -550,7 +549,7 @@ public class cgeovisit extends cgLogForm { if (post == null) { post = (Button) findViewById(R.id.post); } - if (ArrayUtils.isEmpty(viewstates)) { + if (cgBase.isEmpty(viewstates)) { post.setEnabled(false); post.setOnTouchListener(null); post.setOnClickListener(null); diff --git a/src/cgeo/geocaching/cgeowaypointadd.java b/src/cgeo/geocaching/cgeowaypointadd.java index 1d641d7..3a4901b 100644 --- a/src/cgeo/geocaching/cgeowaypointadd.java +++ b/src/cgeo/geocaching/cgeowaypointadd.java @@ -248,8 +248,8 @@ public class cgeowaypointadd extends AbstractActivity { final String latText = ((Button) findViewById(R.id.buttonLatitude)).getText().toString(); final String lonText = ((Button) findViewById(R.id.buttonLongitude)).getText().toString(); - if (StringUtils.isNotBlank(bearingText) && StringUtils.isNotBlank(distanceText) - && StringUtils.isNotBlank(latText) && StringUtils.isNotBlank(lonText)) { + if (StringUtils.isBlank(bearingText) && StringUtils.isBlank(distanceText) + && StringUtils.isBlank(latText) && StringUtils.isBlank(lonText)) { helpDialog(res.getString(R.string.err_point_no_position_given_title), res.getString(R.string.err_point_no_position_given)); return; } diff --git a/src/cgeo/geocaching/files/LocParser.java b/src/cgeo/geocaching/files/LocParser.java index 47d46d4..076005d 100644 --- a/src/cgeo/geocaching/files/LocParser.java +++ b/src/cgeo/geocaching/files/LocParser.java @@ -75,7 +75,6 @@ public final class LocParser extends FileParser { // parse coordinates
for (String pointString : points) {
final cgCoord pointCoord = new cgCoord();
- Map<String, Object> tmp = null;
final Matcher matcherGeocode = patternGeocode.matcher(pointString);
if (matcherGeocode.find()) {
diff --git a/src/cgeo/geocaching/mapcommon/cgMapOverlay.java b/src/cgeo/geocaching/mapcommon/cgMapOverlay.java index de8a6ed..8f86c80 100644 --- a/src/cgeo/geocaching/mapcommon/cgMapOverlay.java +++ b/src/cgeo/geocaching/mapcommon/cgMapOverlay.java @@ -207,7 +207,7 @@ public class cgMapOverlay extends ItemizedOverlayBase implements OverlayBase { cgCoord coordinate = item.getCoord(); - if (coordinate.type != null && coordinate.type.equalsIgnoreCase("cache") && StringUtils.isNotBlank(coordinate.geocode)) { + if (StringUtils.isNotBlank(coordinate.type) && coordinate.type.equalsIgnoreCase("cache") && StringUtils.isNotBlank(coordinate.geocode)) { Intent popupIntent = new Intent(context, cgeopopup.class); popupIntent.putExtra("fromdetail", fromDetail); |
