change UI menu

git-svn-id: https://osmand.googlecode.com/svn/trunk@38 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8
This commit is contained in:
frolovmo 2010-05-06 15:45:17 +00:00
parent 2fa9036f12
commit 927f226c2d
6 changed files with 119 additions and 23 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

View file

@ -2,29 +2,27 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:orientation="vertical" android:layout_width="fill_parent" android:orientation="vertical"
android:layout_height="fill_parent"> android:layout_height="fill_parent" android:background="@color/menu_background">
<ProgressBar android:id="@+id/ProgressBar01" <ProgressBar android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="top|right" android:id="@+id/LoadProgressBar" ></ProgressBar>
android:layout_gravity="top|right"></ProgressBar>
<TextView android:id="@+id/EmptyLable01" android:layout_width="wrap_content"
android:layout_height="wrap_content"></TextView>
<Button android:layout_height="wrap_content" <Button android:layout_height="wrap_content"
android:layout_gravity="center" android:id="@+id/MapButton" android:layout_gravity="center" android:id="@+id/MapButton"
android:text="@string/map_Button" android:layout_width="fill_parent"></Button> android:text="@string/map_Button" android:layout_width="200px" android:layout_marginTop="5px"></Button>
<TextView android:id="@+id/EmptyLable02" android:layout_width="wrap_content"
android:layout_height="wrap_content"></TextView>
<Button android:layout_height="wrap_content" <Button android:layout_height="wrap_content"
android:layout_gravity="center" android:id="@+id/SettingsButton" android:layout_gravity="center" android:id="@+id/SettingsButton"
android:text="@string/settings_Button" android:layout_width="fill_parent"></Button> android:text="@string/settings_Button" android:layout_width="200px" android:layout_marginTop="15px"></Button>
<FrameLayout android:id="@+id/FrameLayout01" <Button android:layout_height="wrap_content" android:id="@+id/SearchButton" android:text="@string/search_button" android:layout_width="200px" android:layout_gravity="center_horizontal" android:layout_marginTop="15px"></Button><FrameLayout android:id="@+id/FrameLayout01"
android:layout_height="fill_parent" android:layout_width="fill_parent"> android:layout_height="fill_parent" android:layout_width="fill_parent">
<Button android:layout_width="wrap_content" <Button android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_gravity="bottom|left" android:layout_height="wrap_content" android:layout_gravity="bottom|left"
android:text="@string/exit_Button" android:id="@+id/ExitButton"></Button> android:id="@+id/ExitButton" android:background="@drawable/exit"></Button>
</FrameLayout> </FrameLayout>
</LinearLayout> </LinearLayout>

View file

@ -17,4 +17,6 @@
<string name="exit_Button">Exit</string> <string name="exit_Button">Exit</string>
<string name="map_Button">Map</string> <string name="map_Button">Map</string>
<string name="settings_Button">Settings</string> <string name="settings_Button">Settings</string>
<string name="search_button">Search</string>
<color name="menu_background">#CFFACD</color>
</resources> </resources>

View file

@ -1,5 +1,7 @@
package com.osmand.activities; package com.osmand.activities;
import java.util.concurrent.Callable;
import android.app.Activity; import android.app.Activity;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
@ -7,15 +9,20 @@ import android.view.View;
import android.view.Window; import android.view.Window;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.widget.Button; import android.widget.Button;
import android.widget.ProgressBar;
import com.osmand.R; import com.osmand.R;
import com.osmand.ResourceManager; 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 showMap;
private Button exitButton; private Button exitButton;
private Button settingsButton; private Button settingsButton;
private ProgressBar loadProgress;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -24,11 +31,14 @@ public class MainMenuActivity extends Activity {
requestWindowFeature(Window.FEATURE_NO_TITLE); requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.menu); setContentView(R.layout.menu);
showMap = (Button) findViewById(R.id.MapButton); showMap = (Button) findViewById(R.id.MapButton);
showMap.setOnClickListener(new OnClickListener() { showMap.setOnClickListener(new OnClickListener() {
@Override @Override
public void onClick(View v) { 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); startActivityForResult(mapIndent, 0);
} }
@ -37,7 +47,8 @@ public class MainMenuActivity extends Activity {
settingsButton.setOnClickListener(new OnClickListener() { settingsButton.setOnClickListener(new OnClickListener() {
@Override @Override
public void onClick(View v) { 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); startActivity(settings);
} }
}); });
@ -49,11 +60,30 @@ public class MainMenuActivity extends Activity {
} }
}); });
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 @Override
protected void onSaveInstanceState(Bundle outState) { public void onLongRunningActionFinished(Exception error) {
super.onSaveInstanceState(outState); // TODO Auto-generated method stub
} }
} }

View file

@ -0,0 +1,5 @@
package com.osmand.services;
public interface LongRunningActionCallback {
void onLongRunningActionFinished(Exception error);
}

View file

@ -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);
}
}