From 927f226c2d9f8b92250b580cbd3587017b6046a7 Mon Sep 17 00:00:00 2001 From: frolovmo Date: Thu, 6 May 2010 15:45:17 +0000 Subject: [PATCH] change UI menu git-svn-id: https://osmand.googlecode.com/svn/trunk@38 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8 --- OsmAnd/res/drawable/exit.png | Bin 0 -> 4269 bytes OsmAnd/res/layout/menu.xml | 22 +++---- OsmAnd/res/values/strings.xml | 2 + .../osmand/activities/MainMenuActivity.java | 52 +++++++++++---- .../services/LongRunningActionCallback.java | 5 ++ .../services/LongRunningActionDispatcher.java | 61 ++++++++++++++++++ 6 files changed, 119 insertions(+), 23 deletions(-) create mode 100644 OsmAnd/res/drawable/exit.png create mode 100644 OsmAnd/src/com/osmand/services/LongRunningActionCallback.java create mode 100644 OsmAnd/src/com/osmand/services/LongRunningActionDispatcher.java diff --git a/OsmAnd/res/drawable/exit.png b/OsmAnd/res/drawable/exit.png new file mode 100644 index 0000000000000000000000000000000000000000..e0ae1d94ede4ed4d9298e061aa86253f2066e329 GIT binary patch literal 4269 zcmXX~dmvQX_dheoobfn}5Hpe)SD}zWp)MIx;gU&WD&-ij>hkr-ElOsN#~`Xn(#UJ- zc1xvedVEV#j>bE$N}9@zxs{}c5iwpfzp3B%kG>DxntR;qL(eHEqs>V;@y#O7ccl^0xTs}QGiEeJUfc! z6Biy66&MvBnVQ%hzflnSwI zY%YX1W*6p=R)6HIwCnmVc-k&>QR>XQjj!S%-fH3I6TtVo;J8zg2~L+$AQ{EseR9EE zYwr1SQqXc*#HCiDu3jfiI@*F=sOrG5j&4jw6p*<(G4dIGw1Ja3WLHT}cR$i8`}`=C zSK7LTK2VpCEqy)a&f(s;0~pY-suT}jJ-j+C(2WKLxq&0Aofa57IAA(QzR7ASm zjI$Jri2>*=c@^lNM_i|HyuaysZXP90gx-z-7xA5G3Vi)-%oP_}#>Y)yDK zl*r>KDSLpplZ3+v$^M5K_5^ns^Akk79zoXc6ux}cgV9#y^9ek9+c=V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zJF*0cV8>KW<6tsJ;8PJN9|(fl0zhPZRinCvl+ zNebUdBZi1~YD|G=^Cw7^lsAfnxg~<+M`T*&K3M+41Fuxz)#iiHVKznNrFYBec}#EM zc0emVWtK1f^5-0^Le_r_kptdj@<>{zP_tNzb>J5Ir*7Zhvyk6N_8teSQq~YGTACR2Z?8F01a`^VM* zUIf+MF;vZBDKiB)?XTB+^}EE^B=+a@Pn2Szbi6fHS3zB_N6IE-EBjG>LVp~ zSb_Hb*RFWpR2-r&edeCikV`ChpA-JCsd=me=HZO;f23AciOTI8>`ImmOYA|r= vJ8S&oC!o?2QWu(yslZ_TO%=cYS3y9>i0#>UfvKVTZvcEYZt?ot6Uq2L4ZoMS literal 0 HcmV?d00001 diff --git a/OsmAnd/res/layout/menu.xml b/OsmAnd/res/layout/menu.xml index ad2286ea74..c1cfcc719c 100644 --- a/OsmAnd/res/layout/menu.xml +++ b/OsmAnd/res/layout/menu.xml @@ -2,29 +2,27 @@ - - + android:layout_height="fill_parent" android:background="@color/menu_background"> + + - + android:text="@string/map_Button" android:layout_width="200px" android:layout_marginTop="5px"> + + android:text="@string/settings_Button" android:layout_width="200px" android:layout_marginTop="15px"> - + android:id="@+id/ExitButton" android:background="@drawable/exit"> + diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index a5a09e18fb..46c07b5858 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -17,4 +17,6 @@ Exit Map Settings +Search +#CFFACD diff --git a/OsmAnd/src/com/osmand/activities/MainMenuActivity.java b/OsmAnd/src/com/osmand/activities/MainMenuActivity.java index 453083d69a..7543f5fbe7 100644 --- a/OsmAnd/src/com/osmand/activities/MainMenuActivity.java +++ b/OsmAnd/src/com/osmand/activities/MainMenuActivity.java @@ -1,5 +1,7 @@ package com.osmand.activities; +import java.util.concurrent.Callable; + import android.app.Activity; import android.content.Intent; import android.os.Bundle; @@ -7,28 +9,36 @@ 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 { +public class MainMenuActivity extends Activity implements + LongRunningActionCallback { private Button showMap; private Button exitButton; private Button settingsButton; - + private ProgressBar loadProgress; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - - requestWindowFeature(Window.FEATURE_NO_TITLE); + + 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); } @@ -37,7 +47,8 @@ public class MainMenuActivity extends Activity { 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); } }); @@ -48,12 +59,31 @@ public class MainMenuActivity extends Activity { MainMenuActivity.this.finish(); } }); - - ResourceManager.getResourceManager().indexingPoi(); + + 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; + } + }, "Dialog Title", "Dialog message"); + } + @Override - protected void onSaveInstanceState(Bundle outState) { - super.onSaveInstanceState(outState); + public void onLongRunningActionFinished(Exception error) { + // TODO Auto-generated method stub + } + } diff --git a/OsmAnd/src/com/osmand/services/LongRunningActionCallback.java b/OsmAnd/src/com/osmand/services/LongRunningActionCallback.java new file mode 100644 index 0000000000..71e5a38268 --- /dev/null +++ b/OsmAnd/src/com/osmand/services/LongRunningActionCallback.java @@ -0,0 +1,5 @@ +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 new file mode 100644 index 0000000000..c64790b878 --- /dev/null +++ b/OsmAnd/src/com/osmand/services/LongRunningActionDispatcher.java @@ -0,0 +1,61 @@ +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); + } + +}