|
|
@@ -7,6 +7,7 @@ import android.database.sqlite.SQLiteDatabase;
|
|
|
import android.graphics.Color;
|
|
|
import android.graphics.drawable.ColorDrawable;
|
|
|
import android.os.Bundle;
|
|
|
+import android.text.TextUtils;
|
|
|
import android.text.format.DateFormat;
|
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
|
@@ -28,6 +29,8 @@ import android.widget.TextView;
|
|
|
//import com.usai.util.dbUtil;
|
|
|
|
|
|
import com.usai.ratradefiling.R;
|
|
|
+import com.usai.ratradefiling.dataprovider.RADataProvider;
|
|
|
+import com.usai.ratradefiling.detail.NewDetailActivity;
|
|
|
import com.usai.ratradefiling.swipemenulistview.BaseSwipListAdapter;
|
|
|
import com.usai.ratradefiling.swipemenulistview.SwipeMenu;
|
|
|
import com.usai.ratradefiling.swipemenulistview.SwipeMenuCreator;
|
|
|
@@ -35,6 +38,10 @@ import com.usai.ratradefiling.swipemenulistview.SwipeMenuItem;
|
|
|
import com.usai.ratradefiling.swipemenulistview.SwipeMenuListView;
|
|
|
import com.usai.redant.rautils.utils.RAUtil;
|
|
|
|
|
|
+import org.json.JSONArray;
|
|
|
+import org.json.JSONException;
|
|
|
+import org.json.JSONObject;
|
|
|
+
|
|
|
import java.net.URISyntaxException;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
@@ -149,28 +156,30 @@ public class SavedDetailFragment extends TFListFragment
|
|
|
public void onListItemClick(ListView l, View v, int position, long id)
|
|
|
{
|
|
|
|
|
|
- Intent intent = new Intent();
|
|
|
- // SQLiteDatabase db = dbUtil.OpenDB(getActivity(), null, false);
|
|
|
- // Cursor c = db.query("favorites", new String[]
|
|
|
- // {"params"},"_id="+searchresult.getData().get(position).get("_id"),null,
|
|
|
- // null, null, null);
|
|
|
- // if(c.moveToNext())
|
|
|
- // {
|
|
|
- String uri = (String) searchresult.getData().get(position)
|
|
|
- .get("params");
|
|
|
- try
|
|
|
- {
|
|
|
- intent = Intent.parseUri(uri, 0);
|
|
|
-
|
|
|
- startActivity(intent);
|
|
|
- }
|
|
|
- catch (URISyntaxException e)
|
|
|
- {
|
|
|
- // TODO Auto-generated catch block
|
|
|
- e.printStackTrace();
|
|
|
+ JSONArray actions = sectionModel.actions;
|
|
|
+ if (actions == null) {
|
|
|
+ actions = new JSONArray();
|
|
|
}
|
|
|
|
|
|
+ Intent intent = new Intent(mCtx, NewDetailActivity.class);
|
|
|
+ intent.putExtra("sub_type", params.getString("sub_type"));
|
|
|
+ intent.putExtra("actions_count", actions.length());
|
|
|
+
|
|
|
+ intent.putExtra("bundle_params",params);
|
|
|
+// intent.putExtra("_id",detail_id);
|
|
|
+// if(_schema!=null)
|
|
|
+// intent.putExtra("_schema",_schema);
|
|
|
+
|
|
|
+ for (int i = 0; i < actions.length(); i++) {
|
|
|
+ try {
|
|
|
+ String name = actions.getString(i);
|
|
|
+ intent.putExtra("action" + i, name);
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ startActivity(intent);
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -197,16 +206,12 @@ public class SavedDetailFragment extends TFListFragment
|
|
|
public FavoritesAdapter(SearchResult result, Context context)
|
|
|
{
|
|
|
|
|
|
-// this.mInflater = LayoutInflater.from(context);
|
|
|
-// SQLiteDatabase db = dbUtil.OpenDB(getActivity(), null, false);
|
|
|
-// Cursor cursor = db.query("favorites", new String[] { "_id",
|
|
|
-// "create_time", "name", "params","module_name" }, "user='"
|
|
|
-// + ApexTrackingApplication.get_user() + "'", null, null,
|
|
|
-// null, "_id desc", null);
|
|
|
-//
|
|
|
-// result.add_records(cursor);
|
|
|
-// dbUtil.CloseCursor(cursor);
|
|
|
-// dbUtil.CloseDB(db);
|
|
|
+
|
|
|
+ this.mInflater = LayoutInflater.from(context);
|
|
|
+ JSONArray array = RADataProvider.loadSavedDetail();
|
|
|
+
|
|
|
+
|
|
|
+ result.add_records(array);
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -228,10 +233,12 @@ public class SavedDetailFragment extends TFListFragment
|
|
|
|
|
|
holder.message.setText(searchresult.getData().get(position).get("name")
|
|
|
.toString());// 给该控件设置数据(数据从集合类中来)
|
|
|
- holder.time.setText(DateFormat.format(
|
|
|
- getString(R.string.time_format),
|
|
|
- (Long) searchresult.getData().get(position)
|
|
|
- .get("create_time")));
|
|
|
+ String time =(String) searchresult.getData().get(position).get("create_time");
|
|
|
+ if(TextUtils.isEmpty(time))
|
|
|
+ {
|
|
|
+ time = "";
|
|
|
+ }
|
|
|
+ holder.time.setText(time );
|
|
|
holder.icon.setImageResource(rid);
|
|
|
|
|
|
|
|
|
@@ -273,27 +280,25 @@ public class SavedDetailFragment extends TFListFragment
|
|
|
return datalist.size();
|
|
|
}
|
|
|
|
|
|
- public void add_records(Cursor c)
|
|
|
+ public void add_records(JSONArray array)
|
|
|
{
|
|
|
- while (c.moveToNext())
|
|
|
+
|
|
|
+ for(int i=0;i<array.length();i++)
|
|
|
{
|
|
|
- long _id = c.getInt(0);
|
|
|
- long create_time = c.getLong(1);
|
|
|
- String name = c.getString(2);
|
|
|
- String params = c.getString(3);
|
|
|
- String module_name = c.getString(4);
|
|
|
+ JSONObject item = array.optJSONObject(i);
|
|
|
Map<String, Object> map = new HashMap<String, Object>();
|
|
|
- map.put("_id", _id);
|
|
|
-
|
|
|
- map.put("create_time", create_time);
|
|
|
- map.put("name", name);
|
|
|
-
|
|
|
- map.put("params", params);
|
|
|
- map.put("module_name", module_name);
|
|
|
+ map.put("_id", i);
|
|
|
|
|
|
+ map.put("create_time", item.optString("current_date"));
|
|
|
+ map.put("name", item.optString("name"));
|
|
|
+ map.put("company_name", item.optString("company_name"));
|
|
|
+ map.put("params", item.optJSONObject("param"));
|
|
|
+ map.put("module_name", item.optString("module"));
|
|
|
datalist.add(map);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
public List<Map<String, Object>> getData()
|