aboutsummaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
Diffstat (limited to 'main')
-rw-r--r--main/src/cgeo/geocaching/LogTrackableActivity.java4
-rw-r--r--main/src/cgeo/geocaching/TrackableActivity.java20
-rw-r--r--main/src/cgeo/geocaching/ui/logs/TrackableLogsViewCreator.java7
3 files changed, 17 insertions, 14 deletions
diff --git a/main/src/cgeo/geocaching/LogTrackableActivity.java b/main/src/cgeo/geocaching/LogTrackableActivity.java
index 5f0b8c5..fa77458 100644
--- a/main/src/cgeo/geocaching/LogTrackableActivity.java
+++ b/main/src/cgeo/geocaching/LogTrackableActivity.java
@@ -65,6 +65,8 @@ public class LogTrackableActivity extends AbstractLoggingActivity implements Dat
private int attempts = 0;
private Trackable trackable;
+ final public static int LOG_TRACKABLE = 1;
+
private final Handler showProgressHandler = new Handler() {
@Override
public void handleMessage(final Message msg) {
@@ -110,6 +112,7 @@ public class LogTrackableActivity extends AbstractLoggingActivity implements Dat
final StatusCode error = (StatusCode) msg.obj;
if (error == StatusCode.NO_ERROR) {
showToast(res.getString(R.string.info_log_posted));
+ setResult(RESULT_OK);
finish();
} else {
showToast(error.getErrorString(res));
@@ -138,6 +141,7 @@ public class LogTrackableActivity extends AbstractLoggingActivity implements Dat
if (trackable == null) {
Log.e("LogTrackableActivity.onCreate: cannot load trackable " + geocode);
+ setResult(RESULT_CANCELED);
finish();
return;
}
diff --git a/main/src/cgeo/geocaching/TrackableActivity.java b/main/src/cgeo/geocaching/TrackableActivity.java
index e04fe9f..653eb17 100644
--- a/main/src/cgeo/geocaching/TrackableActivity.java
+++ b/main/src/cgeo/geocaching/TrackableActivity.java
@@ -172,6 +172,10 @@ public class TrackableActivity extends AbstractViewPagerActivity<TrackableActivi
}
}
});
+ refreshTrackable(message);
+ }
+
+ private void refreshTrackable(final String message) {
waitDialog = ProgressDialog.show(this, message, res.getString(R.string.trackable_details_loading), true, true);
createSubscriptions.add(AppObservable.bindActivity(this, loadTrackable(geocode, guid, id)).singleOrDefault(null).subscribe(new Action1<Trackable>() {
@Override
@@ -198,7 +202,7 @@ public class TrackableActivity extends AbstractViewPagerActivity<TrackableActivi
public boolean onOptionsItemSelected(final MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_log_touch:
- startActivity(LogTrackableActivity.getIntent(this, trackable));
+ startActivityForResult(LogTrackableActivity.getIntent(this, trackable), LogTrackableActivity.LOG_TRACKABLE);
return true;
case R.id.menu_browser_trackable:
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(trackable.getUrl())));
@@ -598,16 +602,10 @@ public class TrackableActivity extends AbstractViewPagerActivity<TrackableActivi
}
@Override
- protected void onResume() {
- super.onResume();
- // refresh the logs view after coming back from logging a trackable
- if (trackable != null) {
- final Trackable updatedTrackable = DataStore.loadTrackable(trackable.getGeocode());
- // if this activity is resumed after a long time, the trackable might be gone due to regular cleanup
- if (updatedTrackable != null) {
- trackable.setLogs(updatedTrackable.getLogs());
- reinitializeViewPager();
- }
+ protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
+ // Refresh the logs view after coming back from logging a trackable
+ if (requestCode == LogTrackableActivity.LOG_TRACKABLE && resultCode == RESULT_OK) {
+ refreshTrackable(StringUtils.defaultIfBlank(trackable.getName(), trackable.getGeocode()));
}
}
diff --git a/main/src/cgeo/geocaching/ui/logs/TrackableLogsViewCreator.java b/main/src/cgeo/geocaching/ui/logs/TrackableLogsViewCreator.java
index c120286..ef8f5cc 100644
--- a/main/src/cgeo/geocaching/ui/logs/TrackableLogsViewCreator.java
+++ b/main/src/cgeo/geocaching/ui/logs/TrackableLogsViewCreator.java
@@ -44,10 +44,9 @@ public class TrackableLogsViewCreator extends LogsViewCreator {
@Override
protected void fillCountOrLocation(final LogViewHolder holder, final LogEntry log) {
- if (StringUtils.isBlank(log.cacheName)) {
- holder.countOrLocation.setVisibility(View.GONE);
- } else {
+ if (StringUtils.isNotBlank(log.cacheName)) {
holder.countOrLocation.setText(Html.fromHtml(log.cacheName));
+ holder.countOrLocation.setVisibility(View.VISIBLE);
final String cacheGuid = log.cacheGuid;
final String cacheName = log.cacheName;
holder.countOrLocation.setOnClickListener(new View.OnClickListener() {
@@ -56,6 +55,8 @@ public class TrackableLogsViewCreator extends LogsViewCreator {
CacheDetailActivity.startActivityGuid(activity, cacheGuid, Html.fromHtml(cacheName).toString());
}
});
+ } else {
+ holder.countOrLocation.setVisibility(View.GONE);
}
}