From 7daf29e5f1496c5a664a8982eeac54466868655a Mon Sep 17 00:00:00 2001 From: Georg Lukas Date: Wed, 13 Apr 2011 00:42:12 +0200 Subject: [PATCH] clear log in background --- src/APRSdroid.scala | 8 +------- src/UIHelper.scala | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/APRSdroid.scala b/src/APRSdroid.scala index 02d3d41..c2619be 100644 --- a/src/APRSdroid.scala +++ b/src/APRSdroid.scala @@ -103,13 +103,7 @@ class APRSdroid extends Activity with OnClickListener { } override def onOptionsItemSelected(mi : MenuItem) : Boolean = { - mi.getItemId match { - case R.id.clear => - storage.trimPosts(System.currentTimeMillis) - postcursor.requery() - true - case _ => uihelper.optionsItemAction(mi) - } + uihelper.optionsItemAction(mi) } override def onClick(view : View) { diff --git a/src/UIHelper.scala b/src/UIHelper.scala index ae86e7c..e9b87dc 100644 --- a/src/UIHelper.scala +++ b/src/UIHelper.scala @@ -5,6 +5,7 @@ import _root_.android.app.Activity import _root_.android.app.AlertDialog import _root_.android.content.{BroadcastReceiver, Context, DialogInterface, Intent, IntentFilter} import _root_.android.net.Uri +import _root_.android.util.Log import _root_.android.view.{LayoutInflater, Menu, MenuItem, View} import _root_.android.widget.{EditText, Toast} @@ -136,8 +137,7 @@ class UIHelper(ctx : Activity, menu_id : Int, prefs : PrefsWrapper) ctx.startActivity(new Intent(ctx, classOf[PrefsAct])); true case R.id.clear => - //storage.trimPosts(System.currentTimeMillis) - //postcursor.requery() + new StorageCleaner(StorageDatabase.open(ctx)).execute() true case R.id.about => aboutDialog() @@ -176,6 +176,16 @@ class UIHelper(ctx : Activity, menu_id : Int, prefs : PrefsWrapper) } } + class StorageCleaner(storage : StorageDatabase) extends MyAsyncTask[Unit, Unit] { + override def doInBackground1(params : Array[String]) { + Log.d("StorageCleaner", "trimming...") + storage.trimPosts(System.currentTimeMillis) + } + override def onPostExecute(x : Unit) { + Log.d("StorageCleaner", "broadcasting...") + ctx.sendBroadcast(new Intent(AprsService.UPDATE)) + } + } } class UrlOpener(ctx : Context, url : String) extends DialogInterface.OnClickListener {