diff options
author | jandegr <jandegr@users.noreply.github.com> | 2018-05-29 13:45:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-29 13:45:44 +0200 |
commit | 22e3bf374767a1df3d1415d19fd48ea21ebe37a0 (patch) | |
tree | 2715910ad32211b53affdb79914fd7dfed077ae5 | |
parent | dd72b006bb249cfe391ff936609466bd89bb4ff1 (diff) | |
download | navit-22e3bf374767a1df3d1415d19fd48ea21ebe37a0.tar.gz |
cleanup
-rw-r--r-- | navit/android/src/org/navitproject/navit/NavitBackupTask.java | 14 | ||||
-rw-r--r-- | navit/android/src/org/navitproject/navit/NavitWatch.java | 145 |
2 files changed, 78 insertions, 81 deletions
diff --git a/navit/android/src/org/navitproject/navit/NavitBackupTask.java b/navit/android/src/org/navitproject/navit/NavitBackupTask.java index de495cc91..5780da382 100644 --- a/navit/android/src/org/navitproject/navit/NavitBackupTask.java +++ b/navit/android/src/org/navitproject/navit/NavitBackupTask.java @@ -85,16 +85,14 @@ public class NavitBackupTask extends AsyncTask<Void, Void, String> { + "/gui_internal.txt"); /* Backup Shared Preferences */ - preferencesOOs = new ObjectOutputStream(new FileOutputStream - (backupDir.getPath() + "/preferences.bak")); - preferencesOOs.writeObject(mActivity.getSharedPreferences - (Navit.NAVIT_PREFS, Context.MODE_PRIVATE).getAll()); - } - catch (IOException e) { + preferencesOOs = new ObjectOutputStream(new FileOutputStream( + backupDir.getPath() + "/preferences.bak")); + preferencesOOs.writeObject(mActivity.getSharedPreferences( + Navit.NAVIT_PREFS, Context.MODE_PRIVATE).getAll()); + } catch (IOException e) { e.printStackTrace(); return mActivity.getString(R.string.backup_failed); - } - finally { + } finally { /* Close Stream to prevent Resource Leaks */ try { if (preferencesOOs != null) { diff --git a/navit/android/src/org/navitproject/navit/NavitWatch.java b/navit/android/src/org/navitproject/navit/NavitWatch.java index e23ac1f08..d21ca64e3 100644 --- a/navit/android/src/org/navitproject/navit/NavitWatch.java +++ b/navit/android/src/org/navitproject/navit/NavitWatch.java @@ -19,86 +19,85 @@ package org.navitproject.navit; -import java.lang.Thread; import android.os.Handler; import android.os.Message; import android.util.Log; class NavitWatch implements Runnable { - private Thread thread; - private static Handler handler = new Handler() { - public void handleMessage(Message m) { - Log.e("NavitWatch","Handler received message"); - } - }; - private boolean removed; - private int watch_func; - private int watch_fd; - private int watch_cond; - private int watch_callbackid; - private boolean callback_pending; - private Runnable callback_runnable; - public native void poll(int func, int fd, int cond); - public native void watchCallback(int id); + private Thread thread; + private static Handler handler = new Handler() { + public void handleMessage(Message m) { + Log.e("NavitWatch","Handler received message"); + } + }; + private boolean removed; + private int watch_func; + private int watch_fd; + private int watch_cond; + private int watch_callbackid; + private boolean callback_pending; + private Runnable callback_runnable; + public native void poll(int func, int fd, int cond); + public native void watchCallback(int id); - NavitWatch(int func, int fd, int cond, int callbackid) - { - // Log.e("NavitWatch","Creating new thread for "+fd+" "+cond+" from current thread " + NavitWatch(int func, int fd, int cond, int callbackid) + { + // Log.e("NavitWatch","Creating new thread for "+fd+" "+cond+" from current thread " // + java.lang.Thread.currentThread().getName()); - watch_func = func; - watch_fd = fd; - watch_cond = cond; - watch_callbackid = callbackid; - final NavitWatch navitwatch = this; - callback_runnable = new Runnable() { - public void run() - { - navitwatch.callback(); - } - }; - thread = new Thread(this, "poll thread"); - thread.start(); - } - public void run() - { - for (;;) { - // Log.e("NavitWatch","Polling "+watch_fd+" "+watch_cond + " from " + watch_func = func; + watch_fd = fd; + watch_cond = cond; + watch_callbackid = callbackid; + final NavitWatch navitwatch = this; + callback_runnable = new Runnable() { + public void run() + { + navitwatch.callback(); + } + }; + thread = new Thread(this, "poll thread"); + thread.start(); + } + public void run() + { + for (;;) { + // Log.e("NavitWatch","Polling "+watch_fd+" "+watch_cond + " from " // + java.lang.Thread.currentThread().getName()); - poll(watch_func, watch_fd, watch_cond); - // Log.e("NavitWatch","poll returned"); - if (removed) - break; - callback_pending = true; - handler.post(callback_runnable); - try { - // Log.e("NavitWatch","wait"); - synchronized(this) { - if (callback_pending) - this.wait(); - } - // Log.e("NavitWatch","wait returned"); - } catch (Exception e) { - Log.e("NavitWatch","Exception "+e.getMessage()); - } - if (removed) - break; - } - } - public void callback() - { - // Log.e("NavitWatch","Calling Callback"); - if (!removed) - watchCallback(watch_callbackid); - synchronized(this) { - callback_pending = false; - // Log.e("NavitWatch","Waking up"); - this.notify(); - } - } - public void remove() - { - removed=true; - thread.interrupt(); - } + poll(watch_func, watch_fd, watch_cond); + // Log.e("NavitWatch","poll returned"); + if (removed) + break; + callback_pending = true; + handler.post(callback_runnable); + try { + // Log.e("NavitWatch","wait"); + synchronized(this) { + if (callback_pending) + this.wait(); + } + // Log.e("NavitWatch","wait returned"); + } catch (Exception e) { + Log.e("NavitWatch","Exception "+e.getMessage()); + } + if (removed) + break; + } + } + public void callback() + { + // Log.e("NavitWatch","Calling Callback"); + if (!removed) + watchCallback(watch_callbackid); + synchronized(this) { + callback_pending = false; + // Log.e("NavitWatch","Waking up"); + this.notify(); + } + } + public void remove() + { + removed=true; + thread.interrupt(); + } } |