Update to fix of null pointer

This commit is contained in:
Denis 2014-10-03 15:37:46 +03:00
parent b55c729d31
commit c9b2aa844c
2 changed files with 18 additions and 15 deletions

View file

@ -12,6 +12,8 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import android.os.*;
import android.view.View;
import net.osmand.IndexConstants; import net.osmand.IndexConstants;
import net.osmand.PlatformUtil; import net.osmand.PlatformUtil;
import net.osmand.access.AccessibilityPlugin; import net.osmand.access.AccessibilityPlugin;
@ -54,9 +56,6 @@ import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.graphics.Shader.TileMode; import android.graphics.Shader.TileMode;
import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.BitmapDrawable;
import android.os.Build;
import android.os.Handler;
import android.os.Message;
import android.text.format.DateFormat; import android.text.format.DateFormat;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.accessibility.AccessibilityManager; import android.view.accessibility.AccessibilityManager;
@ -127,7 +126,7 @@ public class OsmandApplication extends Application {
} }
} }
super.onCreate(); super.onCreate();
new Toast(this); // activate in UI thread to avoid further exceptions createInUiThread();
sqliteAPI = new SQLiteAPIImpl(this); sqliteAPI = new SQLiteAPIImpl(this);
try { try {
bRouterServiceConnection = BRouterServiceConnection.connect(this); bRouterServiceConnection = BRouterServiceConnection.connect(this);
@ -184,6 +183,19 @@ public class OsmandApplication extends Application {
} }
private void createInUiThread() {
new Toast(this); // activate in UI thread to avoid further exceptions
new AsyncTask<View, Void, Void>() {
@Override
protected Void doInBackground(View... params) {
return null;
}
protected void onPostExecute(Void result) {
}
}.execute();
}
@Override @Override
public void onTerminate() { public void onTerminate() {
super.onTerminate(); super.onTerminate();

View file

@ -186,17 +186,8 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
} }
protected void onPostExecute(Void result) { protected void onPostExecute(Void result) {
if (isCancelled() || mapActivity == null){
return;
}
if (height > 0 && OVERLAP_LAYOUT) { if (height > 0 && OVERLAP_LAYOUT) {
mapActivity.runOnUiThread(new Runnable() { shiftButtons(height);
@Override
public void run() {
shiftButtons(height);
}
});
} }
} }
}.execute(reachedView); }.execute(reachedView);