|
@@ -1,23 +1,33 @@
|
|
|
package com.usai.redant.photo;
|
|
package com.usai.redant.photo;
|
|
|
|
|
|
|
|
import java.io.File;
|
|
import java.io.File;
|
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
|
|
+import java.util.Date;
|
|
|
import java.util.Timer;
|
|
import java.util.Timer;
|
|
|
import java.util.TimerTask;
|
|
import java.util.TimerTask;
|
|
|
|
|
|
|
|
import com.usai.util.Network;
|
|
import com.usai.util.Network;
|
|
|
import com.usai.util.dbUtil;
|
|
import com.usai.util.dbUtil;
|
|
|
|
|
+import com.usai.util.dbgUtil;
|
|
|
|
|
|
|
|
|
|
+import android.app.AlertDialog;
|
|
|
import android.app.ListActivity;
|
|
import android.app.ListActivity;
|
|
|
import android.content.BroadcastReceiver;
|
|
import android.content.BroadcastReceiver;
|
|
|
|
|
+import android.content.ContentValues;
|
|
|
import android.content.Context;
|
|
import android.content.Context;
|
|
|
|
|
+import android.content.DialogInterface;
|
|
|
import android.content.Intent;
|
|
import android.content.Intent;
|
|
|
import android.content.IntentFilter;
|
|
import android.content.IntentFilter;
|
|
|
import android.database.Cursor;
|
|
import android.database.Cursor;
|
|
|
import android.database.sqlite.SQLiteDatabase;
|
|
import android.database.sqlite.SQLiteDatabase;
|
|
|
import android.graphics.Color;
|
|
import android.graphics.Color;
|
|
|
import android.os.Bundle;
|
|
import android.os.Bundle;
|
|
|
|
|
+import android.os.Environment;
|
|
|
import android.util.Log;
|
|
import android.util.Log;
|
|
|
|
|
+import android.view.Menu;
|
|
|
|
|
+import android.view.MenuItem;
|
|
|
import android.view.View;
|
|
import android.view.View;
|
|
|
|
|
+import android.widget.EditText;
|
|
|
import android.widget.SimpleCursorAdapter;
|
|
import android.widget.SimpleCursorAdapter;
|
|
|
import android.widget.TextView;
|
|
import android.widget.TextView;
|
|
|
|
|
|
|
@@ -119,7 +129,104 @@ public class UploadQueueActivity extends ListActivity
|
|
|
dbUtil.CloseDB(m_db);
|
|
dbUtil.CloseDB(m_db);
|
|
|
super.onDestroy();
|
|
super.onDestroy();
|
|
|
}
|
|
}
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public boolean onCreateOptionsMenu(Menu menu)
|
|
|
|
|
+ {
|
|
|
|
|
+ // Inflate the menu; this adds items to the action bar if it is present.
|
|
|
|
|
+ getMenuInflater().inflate(R.menu.uploadqueue, menu);
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public boolean onOptionsItemSelected(MenuItem item)
|
|
|
|
|
+ {
|
|
|
|
|
+ // TODO Auto-generated method stub
|
|
|
|
|
+ switch (item.getItemId())
|
|
|
|
|
+ {
|
|
|
|
|
+ case R.id.action_clearfailed:
|
|
|
|
|
+ dbgUtil.fileLog("menu item clear click , clear...");
|
|
|
|
|
+ // clear();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ new AlertDialog.Builder(
|
|
|
|
|
+ UploadQueueActivity.this)
|
|
|
|
|
+ .setIconAttribute(
|
|
|
|
|
+ android.R.attr.alertDialogIcon)
|
|
|
|
|
+ .setTitle(
|
|
|
|
|
+ R.string.confirm_to_delete)
|
|
|
|
|
+ .setMessage(
|
|
|
|
|
+ "Are you sure to clear error records?")
|
|
|
|
|
+ .setPositiveButton(
|
|
|
|
|
+ android.R.string.ok,
|
|
|
|
|
+ new DialogInterface.OnClickListener()
|
|
|
|
|
+ {
|
|
|
|
|
+ public void onClick(
|
|
|
|
|
+ DialogInterface dialog,
|
|
|
|
|
+ int whichButton)
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ SQLiteDatabase dbr = dbUtil.OpenDB(UploadQueueActivity.this, null, false);
|
|
|
|
|
+ Cursor cursor = dbr.query("pics", new String[] { "_id",
|
|
|
|
|
+ "local_path" }, "try_count>=3", null, null, null, "_id", null);
|
|
|
|
|
+ while (cursor.moveToNext())
|
|
|
|
|
+ {
|
|
|
|
|
+ int _id = cursor.getInt(0);
|
|
|
|
|
+ String path = cursor.getString(1);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ RedAntApplication.writeLock.lock();
|
|
|
|
|
|
|
|
|
|
+ // write sql process
|
|
|
|
|
+ SQLiteDatabase dbw = dbUtil.OpenDB(UploadQueueActivity.this,
|
|
|
|
|
+ null, true);
|
|
|
|
|
+ dbw.execSQL("delete from pics where _id= "+_id);
|
|
|
|
|
+
|
|
|
|
|
+ String timeStamp = new SimpleDateFormat("yyyy_MM_dd")
|
|
|
|
|
+ .format(new Date());
|
|
|
|
|
+
|
|
|
|
|
+ File storageDir = new File(Environment
|
|
|
|
|
+ .getExternalStorageDirectory().getPath()
|
|
|
|
|
+ + "/redant/pop/done/" + timeStamp);
|
|
|
|
|
+
|
|
|
|
|
+ if (!storageDir.exists())
|
|
|
|
|
+ storageDir.mkdirs();
|
|
|
|
|
+
|
|
|
|
|
+ File pic = new File(path);
|
|
|
|
|
+
|
|
|
|
|
+ pic.delete();
|
|
|
|
|
+ dbUtil.CloseDB(dbw);
|
|
|
|
|
+ RedAntApplication.writeLock.unlock();
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ dbUtil.CloseCursor(cursor);
|
|
|
|
|
+ dbUtil.CloseDB(dbr);
|
|
|
|
|
+
|
|
|
|
|
+ sendBroadcast(new Intent("REDANT.POP.UPDATE_QUEUE_VIEW"));
|
|
|
|
|
+ sendBroadcast(new Intent("REDANT.POP.CLEAR_UPLOAD_QUEUE"));
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ .setNegativeButton(
|
|
|
|
|
+ android.R.string.cancel,
|
|
|
|
|
+ new DialogInterface.OnClickListener()
|
|
|
|
|
+ {
|
|
|
|
|
+ public void onClick(
|
|
|
|
|
+ DialogInterface dialog,
|
|
|
|
|
+ int whichButton)
|
|
|
|
|
+ {
|
|
|
|
|
+ // debug
|
|
|
|
|
+ // update_location();
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ .create()
|
|
|
|
|
+ .show();
|
|
|
|
|
+ break;
|
|
|
|
|
+
|
|
|
|
|
+ default:
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ return super.onOptionsItemSelected(item);
|
|
|
|
|
+ }
|
|
|
@Override
|
|
@Override
|
|
|
protected void onCreate(Bundle savedInstanceState)
|
|
protected void onCreate(Bundle savedInstanceState)
|
|
|
{
|
|
{
|