From 92a6ef78ba9d7bd013b4a6e200316946086e3893 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Thu, 6 May 2010 20:46:06 +0000 Subject: [PATCH] changing layout git-svn-id: https://osmand.googlecode.com/svn/trunk@41 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8 --- OsmAnd/res/layout-port/menu.xml | 28 +++++++++ OsmAnd/res/layout/menu.xml | 22 +++---- OsmAnd/src/com/osmand/ResourceManager.java | 8 ++- .../osmand/activities/MainMenuActivity.java | 52 +++++----------- .../services/LongRunningActionCallback.java | 5 -- .../services/LongRunningActionDispatcher.java | 61 ------------------- 6 files changed, 61 insertions(+), 115 deletions(-) create mode 100644 OsmAnd/res/layout-port/menu.xml delete mode 100644 OsmAnd/src/com/osmand/services/LongRunningActionCallback.java delete mode 100644 OsmAnd/src/com/osmand/services/LongRunningActionDispatcher.java diff --git a/OsmAnd/res/layout-port/menu.xml b/OsmAnd/res/layout-port/menu.xml new file mode 100644 index 0000000000..a290e64d39 --- /dev/null +++ b/OsmAnd/res/layout-port/menu.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + diff --git a/OsmAnd/res/layout/menu.xml b/OsmAnd/res/layout/menu.xml index c1cfcc719c..9314de4f92 100644 --- a/OsmAnd/res/layout/menu.xml +++ b/OsmAnd/res/layout/menu.xml @@ -3,21 +3,21 @@ - - + - + + - - - + - diff --git a/OsmAnd/src/com/osmand/ResourceManager.java b/OsmAnd/src/com/osmand/ResourceManager.java index cccd266aeb..0d1902c063 100644 --- a/OsmAnd/src/com/osmand/ResourceManager.java +++ b/OsmAnd/src/com/osmand/ResourceManager.java @@ -14,6 +14,7 @@ import org.apache.commons.logging.Log; import org.apache.tools.bzip2.CBZip2InputStream; import org.xml.sax.SAXException; +import android.app.ProgressDialog; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.os.Environment; @@ -191,7 +192,7 @@ public class ResourceManager { // POI INDEX // - public void indexingPoi(){ + public void indexingPoi(ProgressDialog dlg){ if (poiIndex == null) { File file = new File(Environment.getExternalStorageDirectory(), POI_PATH); poiIndex = new DataTileManager(); @@ -201,6 +202,9 @@ public class ResourceManager { if (log.isDebugEnabled()) { log.debug("Starting index POI " + f.getAbsolutePath()); } + if(dlg != null){ + dlg.setMessage("Indexing poi " + f.getName()); + } boolean zipped = f.getName().endsWith(".bz2"); InputStream stream = null; try { @@ -240,7 +244,7 @@ public class ResourceManager { public DataTileManager getPoiIndex() { if(poiIndex == null){ - indexingPoi(); + indexingPoi(null); } return poiIndex; } diff --git a/OsmAnd/src/com/osmand/activities/MainMenuActivity.java b/OsmAnd/src/com/osmand/activities/MainMenuActivity.java index 7543f5fbe7..968772a042 100644 --- a/OsmAnd/src/com/osmand/activities/MainMenuActivity.java +++ b/OsmAnd/src/com/osmand/activities/MainMenuActivity.java @@ -1,28 +1,22 @@ package com.osmand.activities; -import java.util.concurrent.Callable; - import android.app.Activity; +import android.app.ProgressDialog; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.Window; import android.view.View.OnClickListener; import android.widget.Button; -import android.widget.ProgressBar; import com.osmand.R; import com.osmand.ResourceManager; -import com.osmand.services.LongRunningActionCallback; -import com.osmand.services.LongRunningActionDispatcher; -public class MainMenuActivity extends Activity implements - LongRunningActionCallback { +public class MainMenuActivity extends Activity { private Button showMap; private Button exitButton; private Button settingsButton; - private ProgressBar loadProgress; @Override protected void onCreate(Bundle savedInstanceState) { @@ -30,15 +24,12 @@ public class MainMenuActivity extends Activity implements requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.menu); - - showMap = (Button) findViewById(R.id.MapButton); showMap.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { - final Intent mapIndent = new Intent(MainMenuActivity.this, - MapActivity.class); + final Intent mapIndent = new Intent(MainMenuActivity.this, MapActivity.class); startActivityForResult(mapIndent, 0); } @@ -47,8 +38,7 @@ public class MainMenuActivity extends Activity implements settingsButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { - final Intent settings = new Intent(MainMenuActivity.this, - SettingsActivity.class); + final Intent settings = new Intent(MainMenuActivity.this, SettingsActivity.class); startActivity(settings); } }); @@ -60,30 +50,20 @@ public class MainMenuActivity extends Activity implements } }); - loadProgress = (ProgressBar) findViewById(R.id.LoadProgressBar); - loadProgress.setHorizontalScrollBarEnabled(true); - -// startLongRunningOperation(); - - } - - private LongRunningActionDispatcher dispatcher; - - @SuppressWarnings("unchecked") - private void startLongRunningOperation() { - this.dispatcher = new LongRunningActionDispatcher(this, this); - dispatcher.startLongRunningAction(new Callable() { - public Void call() throws Exception { - ResourceManager.getResourceManager().indexingPoi(); - return null; + final ProgressDialog dlg = ProgressDialog.show(this, "Loading data", "Reading indices..."); + new Thread(){ + @Override + public void run() { + try { + dlg.setMessage("Indexing poi..."); + ResourceManager.getResourceManager().indexingPoi(dlg); + } finally { + dlg.dismiss(); + } } - }, "Dialog Title", "Dialog message"); - } - - @Override - public void onLongRunningActionFinished(Exception error) { - // TODO Auto-generated method stub + }.start(); } + } diff --git a/OsmAnd/src/com/osmand/services/LongRunningActionCallback.java b/OsmAnd/src/com/osmand/services/LongRunningActionCallback.java deleted file mode 100644 index 71e5a38268..0000000000 --- a/OsmAnd/src/com/osmand/services/LongRunningActionCallback.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.osmand.services; - -public interface LongRunningActionCallback { - void onLongRunningActionFinished(Exception error); -} diff --git a/OsmAnd/src/com/osmand/services/LongRunningActionDispatcher.java b/OsmAnd/src/com/osmand/services/LongRunningActionDispatcher.java deleted file mode 100644 index c64790b878..0000000000 --- a/OsmAnd/src/com/osmand/services/LongRunningActionDispatcher.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.osmand.services; - -import java.util.concurrent.Callable; - -import android.app.ProgressDialog; -import android.content.Context; -import android.os.Handler; - -public class LongRunningActionDispatcher { - - private Context context; - - private LongRunningActionCallback callback; - - private ProgressDialog progressDialog; - - private Handler finishedHandler = new Handler(); - - public LongRunningActionDispatcher(Context context, - - LongRunningActionCallback callback) { - this.context = context; - this.callback = callback; - } - - @SuppressWarnings("unchecked") - public void startLongRunningAction(final Callable callable, - - String progressDialogTitle, String progressDialogMessage) { - - progressDialog = ProgressDialog.show(context, progressDialogTitle, - progressDialogMessage, true, false); - - new Thread(new Runnable() { - - public void run() { - Exception error = null; - try { - callable.call(); - } catch (Exception e) { - error = e; - } - - final Exception finalError = error; - finishedHandler.post(new Runnable() { - public void run() { - onLongRunningActionFinished(finalError); - } - }); - } - - }).start(); - - } - - private void onLongRunningActionFinished(Exception error) { - progressDialog.dismiss(); - callback.onLongRunningActionFinished(error); - } - -}