diff options
| author | Bananeweizen <bananeweizen@gmx.de> | 2011-08-29 07:28:37 +0200 |
|---|---|---|
| committer | Bananeweizen <bananeweizen@gmx.de> | 2011-08-29 07:28:37 +0200 |
| commit | 7ae6891d307f33f0eb2b3a842e086eee30ff3d0b (patch) | |
| tree | e905a01ce379c42ffbf3fdacc28823d5bbf6bbb1 /src | |
| parent | 0494869b02ae0cd6e8734c6667b4c64c4217b974 (diff) | |
| download | cgeo-7ae6891d307f33f0eb2b3a842e086eee30ff3d0b.zip cgeo-7ae6891d307f33f0eb2b3a842e086eee30ff3d0b.tar.gz cgeo-7ae6891d307f33f0eb2b3a842e086eee30ff3d0b.tar.bz2 | |
return to cache list after import, fixes #313
Diffstat (limited to 'src')
| -rw-r--r-- | src/cgeo/geocaching/cgeocaches.java | 27 | ||||
| -rw-r--r-- | src/cgeo/geocaching/cgeogpxes.java | 23 |
2 files changed, 31 insertions, 19 deletions
diff --git a/src/cgeo/geocaching/cgeocaches.java b/src/cgeo/geocaching/cgeocaches.java index fa763e7..4d07740 100644 --- a/src/cgeo/geocaching/cgeocaches.java +++ b/src/cgeo/geocaching/cgeocaches.java @@ -401,8 +401,7 @@ public class cgeocaches extends AbstractListActivity { waitDialog.setMessage(res.getString(R.string.web_downloading)+" "+(String)msg.obj+"..."); } else if (msg.what == 2) { //Cache downloaded waitDialog.setMessage(res.getString(R.string.web_downloaded)+" "+(String)msg.obj+"."); - //Once a cache is downloaded I used switchList to refresh it. - switchListById(listId); + refreshCurrentList(); } else if (msg.what == -2) { if (waitDialog != null) { waitDialog.dismiss(); @@ -448,7 +447,7 @@ public class cgeocaches extends AbstractListActivity { adapter.setSelectMode(false, true); } - switchListById(listId); + refreshCurrentList(); cacheList.clear(); @@ -1232,7 +1231,7 @@ public class cgeocaches extends AbstractListActivity { cgBase.dropCache(app, this, cache, new Handler() { @Override public void handleMessage(Message msg) { - switchListById(listId); // refresh + refreshCurrentList(); } }); return true; @@ -1243,8 +1242,7 @@ public class cgeocaches extends AbstractListActivity { } adapter.resetChecks(); - // refresh list by switching to the current list - switchListById(listId); + refreshCurrentList(); return true; } else if (id >= MENU_MOVE_SELECTED_OR_ALL_TO_LIST && id < MENU_MOVE_SELECTED_OR_ALL_TO_LIST + 100) { int newListId = id - MENU_MOVE_SELECTED_OR_ALL_TO_LIST; @@ -1257,8 +1255,7 @@ public class cgeocaches extends AbstractListActivity { } adapter.resetChecks(); - // refresh list by switching to the current list - switchListById(listId); + refreshCurrentList(); return true; } @@ -1421,11 +1418,13 @@ public class cgeocaches extends AbstractListActivity { } private void importGpx() { - final Intent intent = new Intent(this, cgeogpxes.class); - intent.putExtra("list", listId); - startActivity(intent); + cgeogpxes.startSubActivity(this, listId); + } - finish(); + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + super.onActivityResult(requestCode, resultCode, data); + refreshCurrentList(); } public void refreshStored() { @@ -2539,6 +2538,10 @@ public class cgeocaches extends AbstractListActivity { } } + private void refreshCurrentList() { + switchListById(listId); + } + public static void startActivityOffline(final Context context) { final Intent cachesIntent = new Intent(context, cgeocaches.class); cachesIntent.putExtra(EXTRAS_LIST_TYPE, "offline"); diff --git a/src/cgeo/geocaching/cgeogpxes.java b/src/cgeo/geocaching/cgeogpxes.java index 64d5bf8..db26a1f 100644 --- a/src/cgeo/geocaching/cgeogpxes.java +++ b/src/cgeo/geocaching/cgeogpxes.java @@ -3,21 +3,24 @@ package cgeo.geocaching; import java.io.File; import java.util.ArrayList; -import cgeo.geocaching.files.FileList; -import cgeo.geocaching.files.GPXParser; -import cgeo.geocaching.files.LocParser; - +import android.app.Activity; import android.app.ProgressDialog; +import android.content.Intent; import android.os.Bundle; import android.os.Environment; import android.os.Handler; import android.os.Message; +import cgeo.geocaching.files.FileList; +import cgeo.geocaching.files.GPXParser; +import cgeo.geocaching.files.LocParser; public class cgeogpxes extends FileList<cgGPXListAdapter> { + private static final String EXTRAS_LIST_ID = "list"; + public cgeogpxes() { super(new String[] {"gpx" - // TODO , "loc" + // TODO , "loc" }); } @@ -70,14 +73,14 @@ public class cgeogpxes extends FileList<cgGPXListAdapter> { Bundle extras = getIntent().getExtras(); if (extras != null) { - listId = extras.getInt("list"); + listId = extras.getInt(EXTRAS_LIST_ID); } if (listId <= 0) { listId = 1; } } - + @Override protected void setTitle() { setTitle(res.getString(R.string.gpx_import_title)); @@ -118,4 +121,10 @@ public class cgeogpxes extends FileList<cgGPXListAdapter> { loadCachesHandler.sendMessage(new Message()); } } + + public static void startSubActivity(Activity fromActivity, int listId) { + final Intent intent = new Intent(fromActivity, cgeogpxes.class); + intent.putExtra(EXTRAS_LIST_ID, listId); + fromActivity.startActivityForResult(intent, 0); + } } |
