|
|
@@ -13,6 +13,7 @@ import org.json.JSONObject;
|
|
|
import java.io.ByteArrayInputStream;
|
|
|
import java.io.ByteArrayOutputStream;
|
|
|
import java.io.File;
|
|
|
+import java.io.IOException;
|
|
|
import java.io.ObjectInputStream;
|
|
|
import java.io.ObjectOutputStream;
|
|
|
import java.util.ArrayList;
|
|
|
@@ -247,8 +248,70 @@ public class RAUploadManager {
|
|
|
{
|
|
|
stopAllTasks();
|
|
|
arr_queue = new ArrayList<Bundle>();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ Log.d("_RAIMAGE", "saveTasks: RAUploadManager");
|
|
|
+
|
|
|
+ SharedPreferences pref = RedAntApplication.getInstance()
|
|
|
+ .getSharedPreferences("RA Image", 0);
|
|
|
+ try {
|
|
|
+ String tasksBase64 = pref.getString("task_list", "");
|
|
|
+
|
|
|
+
|
|
|
+// ArrayList<String> wrap_arr = new ArrayList<String>();
|
|
|
+// for( Bundle b:arr_queue)
|
|
|
+// {
|
|
|
+// String sjson=RAUtil.Bundle2Json(b).toString();
|
|
|
+// Log.d("_RAIMAGE", "saveTasks: "+sjson);
|
|
|
+// wrap_arr.add(sjson);
|
|
|
+// }
|
|
|
+//
|
|
|
+// ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
|
|
+// ObjectOutputStream oos = new ObjectOutputStream(baos);
|
|
|
+// oos.writeObject(wrap_arr);
|
|
|
+//
|
|
|
+// String tasksBase64 = android.util.Base64.encodeToString(baos.toByteArray(), android.util.Base64.DEFAULT);//new String(Base64.encodeBase64(baos.toByteArray()));
|
|
|
+//
|
|
|
+//
|
|
|
+// editor.putString("task_list", tasksBase64);
|
|
|
+//
|
|
|
+//
|
|
|
+// editor.commit();
|
|
|
+
|
|
|
+ byte[] decode=Base64.decode(tasksBase64,Base64.DEFAULT);
|
|
|
+ ByteArrayInputStream bais= new ByteArrayInputStream(decode);
|
|
|
+
|
|
|
+ ObjectInputStream ois = null;
|
|
|
+
|
|
|
+ ois = new ObjectInputStream(bais);
|
|
|
+
|
|
|
+ ArrayList<String> arr_load=(ArrayList<String>)ois.readObject();
|
|
|
+ for(String s:arr_load)
|
|
|
+ {
|
|
|
+ Log.d("_RAIMAGE", "loadTask: "+s);
|
|
|
+ JSONObject jsobj = new JSONObject(s);
|
|
|
+ Bundle b=RAUtil.Json2Bundle(jsobj);
|
|
|
+ arr_queue.add(b);
|
|
|
+// String sjson=RAUtil.Bundle2Json(b).toString();
|
|
|
+
|
|
|
+// wrap_arr.add(sjson);
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } catch (ClassNotFoundException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ for(Bundle b:arr_queue)
|
|
|
+ {
|
|
|
+ startTask(b);
|
|
|
+ }
|
|
|
+// int a = 0;
|
|
|
// 此处缺少读取持久话保存任务队列的实现。
|
|
|
- };
|
|
|
+ }
|
|
|
|
|
|
public void addTask(Bundle task)
|
|
|
{
|
|
|
@@ -339,6 +402,8 @@ public class RAUploadManager {
|
|
|
public void saveTasks()
|
|
|
{
|
|
|
|
|
|
+ Log.d("_RAIMAGE", "saveTasks: RAUploadManager");
|
|
|
+
|
|
|
SharedPreferences pref = RedAntApplication.getInstance()
|
|
|
.getSharedPreferences("RA Image", 0);
|
|
|
SharedPreferences.Editor editor = pref.edit();
|
|
|
@@ -348,22 +413,29 @@ public class RAUploadManager {
|
|
|
ArrayList<String> wrap_arr = new ArrayList<String>();
|
|
|
for( Bundle b:arr_queue)
|
|
|
{
|
|
|
- wrap_arr.add(RAUtil.Bundle2Json(b).toString());
|
|
|
+ String sjson=RAUtil.Bundle2Json(b).toString();
|
|
|
+ Log.d("_RAIMAGE", "saveTasks: "+sjson);
|
|
|
+ wrap_arr.add(sjson);
|
|
|
}
|
|
|
|
|
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
|
|
ObjectOutputStream oos = new ObjectOutputStream(baos);
|
|
|
oos.writeObject(wrap_arr);
|
|
|
|
|
|
- String personBase64 = android.util.Base64.encodeToString(baos.toByteArray(), android.util.Base64.DEFAULT);//new String(Base64.encodeBase64(baos.toByteArray()));
|
|
|
+ String tasksBase64 = android.util.Base64.encodeToString(baos.toByteArray(), android.util.Base64.DEFAULT);//new String(Base64.encodeBase64(baos.toByteArray()));
|
|
|
|
|
|
|
|
|
- byte[] decode=Base64.decode(personBase64,Base64.DEFAULT);
|
|
|
- ByteArrayInputStream bais= new ByteArrayInputStream(decode);
|
|
|
+ editor.putString("task_list", tasksBase64);
|
|
|
+
|
|
|
|
|
|
- ObjectInputStream ois = new ObjectInputStream(bais);
|
|
|
- ArrayList<String> arr_load=(ArrayList<String>)ois.readObject();
|
|
|
- int a = 0;
|
|
|
+ editor.commit();
|
|
|
+
|
|
|
+// byte[] decode=Base64.decode(personBase64,Base64.DEFAULT);
|
|
|
+// ByteArrayInputStream bais= new ByteArrayInputStream(decode);
|
|
|
+//
|
|
|
+// ObjectInputStream ois = new ObjectInputStream(bais);
|
|
|
+// ArrayList<String> arr_load=(ArrayList<String>)ois.readObject();
|
|
|
+// int a = 0;
|
|
|
|
|
|
}
|
|
|
catch (Exception e)
|