瀏覽代碼

1.修改Android Apex Mobile,完成Result。

Pen Li 8 年之前
父節點
當前提交
e713aa690e

+ 0 - 10
Apex Mobile/app/app.iml

@@ -84,30 +84,20 @@
       <sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
       <sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
       <sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
-      <excludeFolder url="file://$MODULE_DIR$/build/.DS_Store" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
-      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/check-manifest" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaPrecompile" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
-      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
-      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/merged-not-compiled-resources" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/multi-dex" />
-      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/prebuild" />
-      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/proguard-rules" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
-      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/res_stripped" />
-      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/shaders" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/splits-support" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
-      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/tmp" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
       <excludeFolder url="file://$MODULE_DIR$/build/outputs" />
-      <excludeFolder url="file://$MODULE_DIR$/build/reports" />
       <excludeFolder url="file://$MODULE_DIR$/build/tmp" />
     </content>
     <orderEntry type="jdk" jdkName="Android API 26 Platform" jdkType="Android SDK" />

+ 12 - 0
Apex Mobile/app/src/main/AndroidManifest.xml

@@ -278,6 +278,18 @@
             android:label="Apex Mobile Background Service"></service>
 
         <activity android:name=".saved.CheckSavedActivity"></activity>
+
+        <activity android:name=".Result.AMResultActivity"
+                  android:screenOrientation="portrait"
+                  >
+
+        </activity>
+        <activity android:name=".Result.SearchResultActivity"
+                  android:screenOrientation="portrait"
+                  >
+
+        </activity>
+
     </application>
 
 </manifest>

+ 401 - 0
Apex Mobile/app/src/main/java/com/usai/apex/Result/AMResultActivity.java

@@ -0,0 +1,401 @@
+package com.usai.apex.Result;
+
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.database.Cursor;
+import android.database.sqlite.SQLiteDatabase;
+import android.os.Bundle;
+import android.support.v7.app.AlertDialog;
+import android.util.Log;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+import com.usai.apex.ApexTrackingApplication;
+import com.usai.apex.BuildConfig;
+import com.usai.apex.CustomizeFieldsActivity;
+import com.usai.apex.DetailActivity;
+import com.usai.apex.R;
+import com.usai.util.Network;
+import com.usai.util.dbUtil;
+
+import org.bouncycastle.util.Arrays;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Created by macmini1 on 2018/2/23.
+ */
+
+public class AMResultActivity extends SearchResultActivity {
+
+    private Boolean isDirty = false;
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+    }
+
+    @Override
+    protected void loadData() {
+        if (mParams.getString("columns") == null) {
+            ArrayList<String> header_name = new ArrayList<String>();
+            ArrayList<String> header_aname = new ArrayList<String>();
+            getHeader(header_name, header_aname);
+            String fields = "";
+            Iterator<String> iterator = header_name.iterator();
+            while (iterator.hasNext()) {
+                String name = iterator.next();
+                fields = fields + name + ",";
+            }
+            fields = fields.substring(0, fields.length() - 1);
+            mParams.putString("columns", fields);
+        }
+        super.loadData();
+    }
+
+    @Override
+    protected void onStart() {
+        super.onStart();
+
+       if (isDirty) {
+
+           ArrayList<String> header_name = new ArrayList<String>();
+           ArrayList<String> header_aname = new ArrayList<String>();
+           getHeader(header_name,header_aname);
+           String fields = "";
+           Iterator<String> iterator = header_name.iterator();
+           while (iterator.hasNext()) {
+               String name = iterator.next();
+               fields = fields + name + ",";
+           }
+           fields = fields.substring(0,fields.length() - 1);
+           mParams.putString("columns",fields);
+
+           loadData();
+           isDirty = false;
+       }
+    }
+
+    // 动态修改Menu
+    @Override
+    public boolean onPrepareOptionsMenu(Menu menu) {
+        super.onPrepareOptionsMenu(menu);
+        menu.clear();
+
+
+        if (resultData != null) {
+            try {
+                JSONArray menu_json = resultData.getJSONArray("menu");
+
+                if (menu_json != null && menu_json.length() > 0) {
+
+                    for (int i = 0; i < menu_json.length(); i++) {
+                        JSONObject json = menu_json.getJSONObject(i);
+                        String title = json.getString("title");
+                        menu.add(0, i, 0, title);
+                    }
+                }
+            } catch (JSONException e) {
+                e.printStackTrace();
+            }
+        }
+
+        return true;
+    }
+
+
+    @Override
+    public boolean onOptionsItemSelected(MenuItem item) {
+
+
+        int which = item.getItemId();
+        try {
+            JSONArray menu = resultData.getJSONArray("menu");
+            JSONObject json = menu.getJSONObject(which);
+
+            String actionType = json.getString("action");
+            String url = json.optString("url");
+
+            if (actionType.equals("field_setting")) {
+
+                fieldSetting();
+            } else if (actionType.equals("save")) {
+
+                save();
+            } else if (actionType.equals("download")) {
+
+                export(url);
+            }
+
+        } catch (JSONException exception) {
+            Log.d("Result", "onClick: ",exception);
+        }
+
+        return true;
+    }
+
+
+    @Override
+    public void cellDoubleTapAction(final int position) {
+
+        final JSONArray content_action = contentAction();
+        if (content_action != null) {
+
+            try {
+                if (content_action.length() == 1) {
+
+                    JSONObject action = content_action.getJSONObject(0);
+                    String module = action.getString("module");
+
+                    if (module.equals("quick_look")) {
+
+                        showQuickLookForPosition(position,action);
+
+                    } else if (module.equals("detail")) {
+
+                        showDetailForPosition(position);
+                    }
+
+
+                } else if (content_action.length() > 1) {
+
+                    ArrayList<String> titleList = new ArrayList<>();
+
+                    for (int i = 0; i < content_action.length(); i++) {
+                        JSONObject json = content_action.getJSONObject(i);
+                        String title = json.getString("title");
+                        titleList.add(title);
+                    }
+
+                    new AlertDialog.Builder(mContext)
+                            .setSingleChoiceItems((String[])titleList.toArray(new String[titleList.size()]), -1, new DialogInterface.OnClickListener() {
+                                @Override
+                                public void onClick(DialogInterface dialog, int which) {
+
+                                    try {
+
+                                        JSONObject json = content_action.getJSONObject(which);
+                                        String module = json.getString("module");
+
+                                        if (module.equals("quick_look")) {
+
+                                            showQuickLookForPosition(position,json);
+                                        } else if (module.equals("detail")) {
+
+                                            showDetailForPosition(position);
+                                        }
+
+
+                                    } catch (JSONException exception) {
+                                        Log.d("Result", "onClick: ",exception);
+                                    }
+                                    dialog.dismiss();
+
+                                }
+                            })
+                            .show();
+                }
+
+            } catch (JSONException e) {
+                e.printStackTrace();
+            }
+
+        }
+
+    }
+
+    public void showDetailForPosition(final int position) {
+
+        ArrayList<String> actions = getActions();
+        if (actions.size() < 1) {
+            return;
+        }
+
+        try {
+            JSONArray arr_col = contentLayout().getJSONObject("header").getJSONArray("col");
+            JSONArray item = contentData().getJSONArray("item_" + position);
+
+            String module_name = mParams.getString("module_name");
+            String detail_id = item.getString(arr_col.length());
+
+            Intent intent = new Intent(mContext, DetailActivity.class);
+            intent.putExtra("function_name", module_name);
+            intent.putExtra("actions_count", actions.size());
+            intent.putExtra("_id",detail_id);
+
+            Iterator<String> iterator = actions.iterator();
+            int i = 0;
+            while (iterator.hasNext()) {
+                String name = iterator.next();
+                intent.putExtra("action" + i++, name);
+            }
+            startActivity(intent);
+
+        } catch (JSONException e) {
+            e.printStackTrace();
+        }
+
+    }
+
+    public void showQuickLookForPosition(final int position,JSONObject action) {
+
+        try {
+
+            JSONObject params = new JSONObject();
+            Iterator<String> iterator = action.getJSONObject("params").keys();
+            while (iterator.hasNext()) {
+                String key = iterator.next();
+                JSONArray item = contentData().getJSONArray("item_" + position);
+                int idx = action.getJSONObject("params").getInt(key);
+                params.put(key,idx);
+            }
+
+            String url = action.getString("url");
+//            String module_name = mParams.getString("module_name");
+
+            showQuickLook(params,url);
+
+        } catch (JSONException e) {
+            e.printStackTrace();
+        }
+
+    }
+
+    public void getHeader(ArrayList<String> header_name, ArrayList<String> header_aname) {
+
+        String module_name = mParams.getString("module_name");
+        String user = ApexTrackingApplication.get_user();
+
+        SQLiteDatabase db = dbUtil.OpenDB(this, null, false);
+        Cursor cursor = db.query("fields_info", new String[] { "aname", "name",
+                "_id" }, "function_name='" + module_name + "' and user='"
+                + user + "' and behavior=" + Network.BEHAVIOR_RESULT
+                + " and show = 1", null, null, null, "priority , aname", null);
+        while (cursor.moveToNext())
+        {
+            String aname = cursor.getString(0);
+            String name = cursor.getString(1);
+
+            header_name.add(name);
+            header_aname.add(aname);
+        }
+        dbUtil.CloseCursor(cursor);
+        dbUtil.CloseDB(db);
+    }
+
+    public ArrayList<String> getActions() {
+
+        String module_name = mParams.getString("module_name");
+
+        SQLiteDatabase db = dbUtil.OpenDB(this, null, false);
+        Cursor cursor = db.query("actions_info",
+                new String[] { "name" }, "function_name='"
+                        + module_name + "' and user='" + ApexTrackingApplication.get_user() + "'", null,
+                null, null, "priority", null);
+
+        ArrayList<String> actions = new ArrayList<>();
+
+        while (cursor.moveToNext())
+        {
+            String name = cursor.getString(0);
+            actions.add(name);
+        }
+        dbUtil.CloseCursor(cursor);
+        dbUtil.CloseDB(db);
+
+        return actions;
+
+    }
+
+    public void save() {
+
+        final View edit = new EditText(this);
+        new android.app.AlertDialog.Builder(this)
+                .setIconAttribute(android.R.attr.alertDialogIcon)
+                .setTitle(R.string.str_createname)
+                .setView(edit)
+                .setPositiveButton(android.R.string.ok,
+                        new DialogInterface.OnClickListener()
+                        {
+                            public void onClick(DialogInterface dialog,
+                                                int whichButton)
+                            {
+                                String name = ((EditText) edit)
+                                        .getText().toString();
+                                String param = getIntent().toUri(0);
+
+                                JSONObject obj = new JSONObject();
+                                Set<String> keys = mParams.keySet();
+                                for (String key : keys)
+                                {
+
+
+                                    try
+                                    {
+                                        obj.put(key, mParams.get(key).toString());
+
+                                    }
+                                    catch (JSONException e)
+                                    {
+                                        // TODO Auto-generated catch block
+                                        e.printStackTrace();
+                                    }
+
+                                }
+                                obj.toString();
+
+                                SQLiteDatabase db = dbUtil.OpenDB(
+                                        ApexTrackingApplication.get_instance(), null, true);
+                                db.execSQL("insert into history(params,name,criterion,module_name,user,create_time) values('"
+
+                                        + param
+                                        + "','"
+                                        + name
+                                        + "','"
+                                        + obj.toString()
+                                        + "','"
+                                        + mParams.getString("module_name")
+                                        + "','"
+                                        + ApexTrackingApplication.get_user()
+                                        + "',"
+                                        + System.currentTimeMillis() + ")");
+                                dbUtil.CloseDB(db);
+
+										/* User clicked OK so do some stuff */
+                            }
+                        })
+                .setNegativeButton(android.R.string.cancel,
+                        new DialogInterface.OnClickListener()
+                        {
+                            public void onClick(DialogInterface dialog,
+                                                int whichButton)
+                            {
+
+										/* User clicked cancel so do some stuff */
+                            }
+                        }).create().show();
+    }
+
+    public void fieldSetting() {
+
+        isDirty = true;
+        Intent intent = new Intent();
+        intent.setClass(this, CustomizeFieldsActivity.class);
+        intent.putExtra("user", ApexTrackingApplication.get_user());
+        intent.putExtra("function_name", mParams.getString("module_name"));
+        intent.putExtra("behavior", Network.BEHAVIOR_RESULT);
+        startActivity(intent);
+
+    }
+
+}

+ 225 - 201
Apex Mobile/app/src/main/java/com/usai/apex/Result/SearchResultActivity.java

@@ -54,22 +54,117 @@ import java.util.Iterator;
 
 public class SearchResultActivity extends AppCompatActivity implements AbsListView.OnScrollListener {
 
-    private Bundle mParams;
-    private JSONObject resultData;
+    protected Bundle mParams;
+    protected JSONObject resultData;
 
-    private Context mContext;
-    private ListView resultListView;
-    private ResultAdapter adapter;
+    protected Context mContext;
+    protected ListView resultListView;
+    protected ResultAdapter adapter;
 
     private View clickedView;
     private View.OnTouchListener resultRowClickListener;
     private GestureDetector detector;
 
-    private TextView footer;
-    private int footer_height = 60;
+    protected TextView footer;
+    protected int footer_height = 60;
 
     ProgressDialog progressDialog;
 
+    public void cellDoubleTapAction(int position) {
+
+//        try {
+//
+//            JSONArray row_action = resultData.optJSONArray("row_action");
+//            if (row_action != null) {
+//
+//                if (row_action.length() == 1) {
+//
+//                    JSONObject action = row_action.getJSONObject(0);
+//                    String module = action.getString("module");
+//
+//                    if (module.equals("quick_look")) {
+//                        JSONObject param = action.getJSONObject("params");
+//                        String url = action.getString("url");
+//                        showQuickLook(param,url);
+//                    } else if (module.equals("kv_detail")) {
+//                        JSONObject params = new JSONObject();
+//                        params.put("query_id",mParams.get("query_id"));
+//
+//                        JSONObject criteria = new JSONObject();
+//                        JSONObject action_params = action.getJSONObject("params");
+//                        Iterator<String> iterator = action_params.keys();
+//                        while (iterator.hasNext()) {
+//                            String key = iterator.next();
+//                            JSONArray item = contentData().getJSONArray("item_" + position);
+//                            int idx = action_params.getInt(key);
+//                            criteria.put(key,item.get(idx));
+//                        }
+//
+//                        params.put("criteria",criteria.toString());
+//                        showKVDetail(params);
+//
+//                    } else if (module.equals("order_detail")) {
+//
+//                        showOrderDetail();
+//
+//                    }
+//
+//
+//                } else if (row_action.length() > 1) {
+//
+//                    ArrayList<String> titleList = new ArrayList<>();
+//
+//                    for (int i = 0; i < row_action.length(); i++) {
+//                        JSONObject json = row_action.getJSONObject(i);
+//                        String title = json.getString("title");
+//                        titleList.add(title);
+//                    }
+//
+//                    new AlertDialog.Builder(mContext)
+//                            .setSingleChoiceItems((String[])titleList.toArray(new String[titleList.size()]), -1, new DialogInterface.OnClickListener() {
+//                                @Override
+//                                public void onClick(DialogInterface dialog, int which) {
+//
+//                                    try {
+//                                        JSONArray content_action = resultData.getJSONArray("row_action");
+//                                        JSONObject json = content_action.getJSONObject(which);
+//                                        String module = json.getString("module");
+//                                        JSONObject add_params = json.getJSONObject("params");
+//
+//                                        if (module.equals("quick_look")) {
+//                                            JSONObject param = json.getJSONObject("params");
+//                                            String url = json.getString("url");
+//                                            showQuickLook(param,url);
+//                                        } else if (module.equals("kv_detail")) {
+//
+//                                            JSONObject params = json.getJSONObject("params");
+//                                            showKVDetail(params);
+//
+//                                        } else if (module.equals("order_detail")) {
+//
+//                                            showOrderDetail();
+//
+//                                        }
+//
+//
+//                                    } catch (JSONException exception) {
+//                                        Log.d("Result", "onClick: ",exception);
+//                                    }
+//                                    dialog.dismiss();
+//
+//                                }
+//                            })
+//                            .show();
+//
+//                }
+//
+//            }
+//
+//        } catch (JSONException exception) {
+//            Log.e("Result", "onDoubleTapEvent: ",exception);
+//        }
+    }
+
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
@@ -134,107 +229,52 @@ public class SearchResultActivity extends AppCompatActivity implements AbsListVi
         menu.clear();
 
 
-        if (resultData != null) {
-            try {
-                JSONArray menu_json = resultData.getJSONArray("menu");
-
-                if (menu_json != null && menu_json.length() > 0) {
-
-                    for (int i = 0; i < menu_json.length(); i++) {
-                        JSONObject json = menu_json.getJSONObject(i);
-                        String title = json.getString("title");
-                        menu.add(0, i, 0, title);
-                    }
-                }
-            } catch (JSONException e) {
-                e.printStackTrace();
-            }
-        }
+//        if (resultData != null) {
+//            try {
+//                JSONArray menu_json = resultData.getJSONArray("menu");
+//
+//                if (menu_json != null && menu_json.length() > 0) {
+//
+//                    for (int i = 0; i < menu_json.length(); i++) {
+//                        JSONObject json = menu_json.getJSONObject(i);
+//                        String title = json.getString("title");
+//                        menu.add(0, i, 0, title);
+//                    }
+//                }
+//            } catch (JSONException e) {
+//                e.printStackTrace();
+//            }
+//        }
 
         return true;
     }
 
-//    @Override
-//    public boolean onCreateOptionsMenu(Menu menu) {
-//        getMenuInflater().inflate(R.menu.result_menu,menu);
-//        return true;
-//    }
 
     @Override
     public boolean onOptionsItemSelected(MenuItem item) {
 
-//        if (item.getItemId() == R.id.result_menu) {
-//
-//            try {
-//
-//                JSONArray menu = resultData.getJSONArray("menu");
-//
-//                if (menu.length() > 0) {
-//                    ArrayList<String> titleList = new ArrayList<>();
-//
-//                    for (int i = 0; i < menu.length(); i++) {
-//                        JSONObject json = menu.getJSONObject(i);
-//                        String title = json.getString("title");
-//                        titleList.add(title);
-//                    }
-//
-//                    new AlertDialog.Builder(mContext)
-//                            .setSingleChoiceItems((String[])titleList.toArray(new String[titleList.size()]), -1, new DialogInterface.OnClickListener() {
-//                                @Override
-//                                public void onClick(DialogInterface dialog, int which) {
-//
-//                                    try {
-//                                        JSONArray menu = resultData.getJSONArray("menu");
-//                                        JSONObject json = menu.getJSONObject(which);
-//
-//                                        String actionType = json.getString("action");
-//                                        String url = json.optString("url");
+
+//        int which = item.getItemId();
+//        try {
+//            JSONArray menu = resultData.getJSONArray("menu");
+//            JSONObject json = menu.getJSONObject(which);
 //
-//                                        if (actionType.equals("download")) {
-//                                            export(url);
-//                                        } else if (actionType.equals("save")) {
-//                                            if(BuildConfig.DEBUG && true){
-//                                                //do something for assert aim
-//                                                Log.e("Result", "onOptionsItemSelected DialogClick: not implement");
-//                                            }
-//                                        }
+//            String actionType = json.getString("action");
+//            String url = json.optString("url");
 //
-//                                    } catch (JSONException exception) {
-//                                        Log.d("Result", "onClick: ",exception);
-//                                    }
-//                                    dialog.dismiss();
-//                                }
-//                            })
-//                            .show();
+//            if (actionType.equals("download")) {
+//                export(url);
+//            } else if (actionType.equals("save")) {
+//                if(BuildConfig.DEBUG && true){
+//                    //do something for assert aim
+//                    Log.e("Result", "onOptionsItemSelected DialogClick: not implement");
 //                }
-//
-//            } catch (JSONException e) {
-//                Log.e("Result", "onOptionsItemSelected: ", e);
 //            }
 //
+//        } catch (JSONException exception) {
+//            Log.d("Result", "onClick: ",exception);
 //        }
 
-        int which = item.getItemId();
-        try {
-            JSONArray menu = resultData.getJSONArray("menu");
-            JSONObject json = menu.getJSONObject(which);
-
-            String actionType = json.getString("action");
-            String url = json.optString("url");
-
-            if (actionType.equals("download")) {
-                export(url);
-            } else if (actionType.equals("save")) {
-                if(BuildConfig.DEBUG && true){
-                    //do something for assert aim
-                    Log.e("Result", "onOptionsItemSelected DialogClick: not implement");
-                }
-            }
-
-        } catch (JSONException exception) {
-            Log.d("Result", "onClick: ",exception);
-        }
-
         return true;
     }
 
@@ -262,7 +302,7 @@ public class SearchResultActivity extends AppCompatActivity implements AbsListVi
         }
     }
 
-    private void setupUI() {
+    protected void setupUI() {
         try {
             if (resultData == null) {
                 return;
@@ -302,13 +342,14 @@ public class SearchResultActivity extends AppCompatActivity implements AbsListVi
         invalidateOptionsMenu();
 
         String title = resultData.optString("table_title");
+        setTitleColor(Color.BLACK);
         setTitle(title);
 
         progressDialog.dismiss();
     }
 
 
-    private void showProgressDialog(String title, String msg) {
+    protected void showProgressDialog(String title, String msg) {
         progressDialog.setTitle(title);
         progressDialog.setMessage(msg);
         progressDialog.show();
@@ -349,13 +390,17 @@ public class SearchResultActivity extends AppCompatActivity implements AbsListVi
         return null;
     }
 
-    private void loadData() {
+    protected void loadData() {
 
 //        resultData = readRawFile(R.raw.predef_query);
 //        if (1 == 1) {
 //            return;
 //        }
 
+        if (isLoading) {
+            return;
+        }
+
         isLoading = true;
 
         showProgressDialog(null,"Loading");
@@ -409,7 +454,11 @@ public class SearchResultActivity extends AppCompatActivity implements AbsListVi
 
     }
 
-    private void loadMore() {
+    protected void loadMore() {
+
+        if (isLoading) {
+            return;
+        }
 
         isLoading = true;
         showProgressDialog(null,"Loading");
@@ -486,7 +535,7 @@ public class SearchResultActivity extends AppCompatActivity implements AbsListVi
         }).start();
     }
 
-    private JSONObject contentData() {
+    protected JSONObject contentData() {
         try {
             return resultData.getJSONObject("data");
         } catch (JSONException e) {
@@ -495,6 +544,44 @@ public class SearchResultActivity extends AppCompatActivity implements AbsListVi
         return null;
     }
 
+    protected JSONArray contentMenu() {
+        if (resultData != null) {
+            try {
+                JSONArray menu_json = resultData.getJSONArray("menu");
+                return menu_json;
+            } catch (JSONException e) {
+                e.printStackTrace();
+            }
+        }
+        return null;
+    }
+
+    protected JSONArray contentAction() {
+        if (resultData != null) {
+            try {
+                JSONArray action_json = resultData.getJSONArray("row_action");
+                return action_json;
+            } catch (JSONException e) {
+                e.printStackTrace();
+            }
+        }
+        return null;
+    }
+
+    protected JSONObject contentLayout() {
+        if (resultData != null) {
+            try {
+                JSONObject layout = resultData.getJSONObject("layout");
+                return layout;
+            } catch (JSONException e) {
+                e.printStackTrace();
+            }
+        }
+        return null;
+
+    }
+
+
     private class GestureListener extends GestureDetector.SimpleOnGestureListener {
 
         @Override
@@ -513,97 +600,7 @@ public class SearchResultActivity extends AppCompatActivity implements AbsListVi
                     return false;
                 }
 
-                try {
-
-                    JSONArray row_action = resultData.optJSONArray("row_action");
-                    if (row_action != null) {
-
-                        if (row_action.length() == 1) {
-
-                            JSONObject action = row_action.getJSONObject(0);
-                            String module = action.getString("module");
-
-                            if (module.equals("quick_look")) {
-                                JSONObject param = action.getJSONObject("params");
-                                String url = action.getString("url");
-                                showQuickLook(param,url);
-                            } else if (module.equals("kv_detail")) {
-                                JSONObject params = new JSONObject();
-                                params.put("query_id",mParams.get("query_id"));
-
-                                JSONObject criteria = new JSONObject();
-                                JSONObject action_params = action.getJSONObject("params");
-                                Iterator<String> iterator = action_params.keys();
-                                while (iterator.hasNext()) {
-                                    String key = iterator.next();
-                                    JSONArray item = contentData().getJSONArray("item_" + position);
-                                    int idx = action_params.getInt(key);
-                                    criteria.put(key,item.get(idx));
-                                }
-
-                                params.put("criteria",criteria.toString());
-                                showKVDetail(params);
-
-                            } else if (module.equals("order_detail")) {
-
-                                showOrderDetail();
-
-                            }
-
-
-                        } else if (row_action.length() > 1) {
-
-                            ArrayList<String> titleList = new ArrayList<>();
-
-                            for (int i = 0; i < row_action.length(); i++) {
-                                JSONObject json = row_action.getJSONObject(i);
-                                String title = json.getString("title");
-                                titleList.add(title);
-                            }
-
-                            new AlertDialog.Builder(mContext)
-                                    .setSingleChoiceItems((String[])titleList.toArray(new String[titleList.size()]), -1, new DialogInterface.OnClickListener() {
-                                        @Override
-                                        public void onClick(DialogInterface dialog, int which) {
-
-                                            try {
-                                                JSONArray content_action = resultData.getJSONArray("row_action");
-                                                JSONObject json = content_action.getJSONObject(which);
-                                                String module = json.getString("module");
-                                                JSONObject add_params = json.getJSONObject("params");
-
-                                                if (module.equals("quick_look")) {
-                                                    JSONObject param = json.getJSONObject("params");
-                                                    String url = json.getString("url");
-                                                    showQuickLook(param,url);
-                                                } else if (module.equals("kv_detail")) {
-
-                                                    JSONObject params = json.getJSONObject("params");
-                                                    showKVDetail(params);
-
-                                                } else if (module.equals("order_detail")) {
-
-                                                    showOrderDetail();
-
-                                                }
-
-
-                                            } catch (JSONException exception) {
-                                                Log.d("Result", "onClick: ",exception);
-                                            }
-                                            dialog.dismiss();
-
-                                        }
-                                    })
-                                    .show();
-
-                        }
-
-                    }
-
-                } catch (JSONException exception) {
-                    Log.e("Result", "onDoubleTapEvent: ",exception);
-                }
+                cellDoubleTapAction(position);
 
             }
 
@@ -644,7 +641,7 @@ public class SearchResultActivity extends AppCompatActivity implements AbsListVi
 
 
 
-    private class ResultAdapter extends BaseAdapter {
+    protected class ResultAdapter extends BaseAdapter {
 
         @Override
         public boolean areAllItemsEnabled() {
@@ -758,6 +755,7 @@ public class SearchResultActivity extends AppCompatActivity implements AbsListVi
 
 //            cell.setOnTouchListener(resultRowClickListener);
 
+            holder.row.setBackgroundColor(Color.WHITE);
             // setup
            try {
 
@@ -783,12 +781,20 @@ public class SearchResultActivity extends AppCompatActivity implements AbsListVi
                resultListView.setLayoutParams(listViewLayoutParams);
 
                JSONArray obj = (JSONArray)getItem(position);
+               JSONArray arr_col = header.getJSONArray("col");
+
                if (position == 0) {
 
                    // header
                    String bg_color = header.getString("bg_color");
                    String f_color = header.getString("f_color");
 
+                   if (!bg_color.contains("0x")) {
+                       bg_color = "0x" + bg_color;
+                   }
+                   if (!f_color.contains("0x")) {
+                       f_color = "0x" + f_color;
+                   }
                    bg_color = bg_color.replace("0x","#");
                    f_color = f_color.replace("0x","#");
 
@@ -797,7 +803,7 @@ public class SearchResultActivity extends AppCompatActivity implements AbsListVi
                    holder.row.setLayoutParams(layoutParams);
 
                    // col
-                   for (int i = 0; i < obj.length(); i++) {
+                   for (int i = 0; i < arr_col.length(); i++) {
 
                        JSONObject value = obj.getJSONObject(i);
                        int col_w = value.getInt("width");
@@ -809,6 +815,7 @@ public class SearchResultActivity extends AppCompatActivity implements AbsListVi
                        String col_f_color = value.getString("f_color");
                        String name = value.getString("name");
 
+
                        bg_color = bg_color.replace("0x","#");
                        f_color = f_color.replace("0x","#");
 
@@ -819,7 +826,7 @@ public class SearchResultActivity extends AppCompatActivity implements AbsListVi
                            tv.setHeight(height);
                            tv.setGravity(convertGravity("h_align",h_align) | convertGravity("v_center",v_center));
 
-                           tv.setTextColor(Color.parseColor(f_color));
+
 
                            tv.setSingleLine();
                            tv.setEllipsize(TextUtils.TruncateAt.END);
@@ -836,6 +843,8 @@ public class SearchResultActivity extends AppCompatActivity implements AbsListVi
                            tv.setOnTouchListener(resultRowClickListener);
                        }
 
+                       tv.setTextColor(Color.parseColor(f_color));
+
 
                        if (name.contains("</")) {
                            tv.setText(Html.fromHtml(name));
@@ -853,6 +862,18 @@ public class SearchResultActivity extends AppCompatActivity implements AbsListVi
                    String f_color = row.getString("f_color");
                    String color_0 = row.getString("color_0");
                    String color_1 = row.getString("color_1");
+
+                   if (!f_color.contains("0x")) {
+                       f_color = "0x" + f_color;
+                   }
+                   if (!color_0.contains("0x")) {
+                       color_0 = "0x" + color_0;
+                   }
+                   if (!color_1.contains("0x")) {
+                       color_1 = "0x" + color_1;
+                   }
+
+
                    f_color = f_color.replace("0x","#");
                    color_0 = color_0.replace("0x","#");
                    color_1 = color_1.replace("0x","#");
@@ -865,7 +886,7 @@ public class SearchResultActivity extends AppCompatActivity implements AbsListVi
                    holder.row.setLayoutParams(layoutParams);
 
                    // col
-                   for (int i = 0; i < obj.length(); i++) {
+                   for (int i = 0; i < arr_col.length(); i++) {
 
                        JSONArray col_layout = row.getJSONArray("val");
                        JSONObject layout_val = col_layout.getJSONObject(i);
@@ -895,7 +916,7 @@ public class SearchResultActivity extends AppCompatActivity implements AbsListVi
                            tv.setWidth(col_w);
                            tv.setHeight(col_h);
                            tv.setGravity(convertGravity("h_align",h_align) | convertGravity("v_center",v_center));
-                           tv.setTextColor(Color.parseColor(col_f_color));
+
 
                            tv.setSingleLine();
                            tv.setEllipsize(TextUtils.TruncateAt.END);
@@ -911,6 +932,7 @@ public class SearchResultActivity extends AppCompatActivity implements AbsListVi
                            tv.setBackgroundDrawable(getResources().getDrawable(R.drawable.result_black_border));
                        }
 
+                       tv.setTextColor(Color.parseColor(col_f_color));
 
                        if (value.contains("</")) {
                            tv.setText(Html.fromHtml(value));
@@ -1018,9 +1040,9 @@ public class SearchResultActivity extends AppCompatActivity implements AbsListVi
     }
 
 
-    private String documentPath;
-    private String download_query;
-    private void export(final String download_url) {
+    protected String documentPath;
+    protected String download_query;
+    protected void export(final String download_url) {
 
         if (download_query != null) {
             documentPath = download_query;
@@ -1075,8 +1097,8 @@ public class SearchResultActivity extends AppCompatActivity implements AbsListVi
     }
 
     public void showKVDetail(final JSONObject param) {
-        showProgressDialog("Please wait","Loading...");
-
+//        showProgressDialog("Please wait","Loading...");
+//
 //        new Thread(new Runnable() {
 //            @Override
 //            public void run() {
@@ -1133,6 +1155,8 @@ public class SearchResultActivity extends AppCompatActivity implements AbsListVi
                         if (path != null && !path.isEmpty()) {
                             Uri uri= Uri.parse(path);
                             openFileAtPath(uri,type);
+                        } else {
+                            showAlert("Sorry,there is a wrong.");
                         }
                     }
                 });
@@ -1143,7 +1167,7 @@ public class SearchResultActivity extends AppCompatActivity implements AbsListVi
 
     }
 
-    private void openFileAtPath(Uri uri, String type) {
+    protected void openFileAtPath(Uri uri, String type) {
         // type "application/pdf"
         Intent intent = new Intent(Intent.ACTION_VIEW);
         intent.setDataAndType(uri, type);
@@ -1167,7 +1191,7 @@ public class SearchResultActivity extends AppCompatActivity implements AbsListVi
 
     }
 
-    private void shareFile(Uri uri, String type) {
+    protected void shareFile(Uri uri, String type) {
 
         Intent shareIntent = new Intent();
         shareIntent.setAction(Intent.ACTION_SEND);

+ 11 - 7
Apex Mobile/app/src/main/java/com/usai/apex/SearchListActivity.java

@@ -9,6 +9,7 @@ import org.json.JSONArray;
 import org.json.JSONException;
 import org.json.JSONObject;
 
+import com.usai.apex.Result.AMResultActivity;
 import com.usai.util.Network;
 import com.usai.util.dbUtil;
 
@@ -392,11 +393,11 @@ public class SearchListActivity extends Activity implements OnClickListener
 		{
 			case R.id.btnok:
 			{
-				Intent intent = new Intent();
-				intent.setClass(this, ResultActivity.class);
-				// intent.putExtra("user", user);
-				// intent.putExtra("password", password);
-				intent.putExtra("function_name", function_name);
+//				Intent intent = new Intent();
+//				intent.setClass(this, ResultActivity.class);
+//				// intent.putExtra("user", user);
+//				// intent.putExtra("password", password);
+//				intent.putExtra("function_name", function_name);
 				Bundle parms = new Bundle();
 
 				boolean hascriterion = false;
@@ -475,10 +476,13 @@ public class SearchListActivity extends Activity implements OnClickListener
 				// Field field = (Field) hashMap.get(aname);
 				// parms.putString(field.name, field.value);
 				// }
-				intent.putExtra("searchParms", parms);
+//				intent.putExtra("searchParms", parms);
 
-				startActivity(intent);
+//				startActivity(intent);
 
+				Intent intent = new Intent(this, AMResultActivity.class);
+				intent.putExtra("query_params",parms);
+				startActivity(intent);
 				break;
 			}
 			case R.id.btncancel:

+ 36 - 1
Apex Mobile/app/src/main/java/com/usai/util/Network.java

@@ -104,7 +104,7 @@ public class Network
 	public static final int		RESULT_VER_LOW					= -15;
 
 	public static String		URL_UPDATE_AUTH					= "https://ra.apexshipping.com/login.php";
-	public static String		URL_REQUEST_COUNT				= "https://ra.apexshipping.com/main.php";
+	public static String		URL_REQUEST_COUNT				= "https://ra.apexshipping.com/main_new.php";
 	public static String		URL_REQUEST_RECORDS				= "https://ra.apexshipping.com/main.php";
 	public static String		URL_RETRIEVE_PASS				= "https://ra.apexshipping.com/main.php";
 	public static String		URL_ANNOUNCEMENTS				= "https://ra.apexshipping.com/mobile_news.php";
@@ -113,6 +113,7 @@ public class Network
 	public static String		URL_PUSH						= "https://ra.apexshipping.com/main.php";
 	public static String		URL_LOG						= "https://ra.apexshipping.com/mobile_news.php";
 
+
 	private static HttpClient getNewHttpClient()
 	{
 		try
@@ -343,11 +344,29 @@ public class Network
 		return RESULT_NET_ERROR;
 	}
 
+	public static void prepare_addtional_params(Bundle params) {
+		if (params == null) {
+			params = new Bundle();
+		}
+
+		String user = ApexTrackingApplication.get_user();
+		if (user != null && params.getString("user") == null) {
+			params.putString("user",user);
+		}
+
+		String pwd = ApexTrackingApplication.get_pass();
+		if (pwd != null && params.getString("pwd") == null) {
+			params.putString("pwd",pwd);
+		}
+
+	}
+
 	public static String getJson(String url, Bundle parms)
 	{
 		String TAG = "net_dbg@GetJson";
 		Log.d(TAG, "entry");
 
+		prepare_addtional_params(parms);
 		parms.putString("sessionid", ApexTrackingApplication.get_sessionid());
 
 		// if (true)
@@ -1497,6 +1516,7 @@ public class Network
 				URL url=new URL(download_url);
 				// 创建一个HTTP链接
 				connection=(HttpURLConnection)url.openConnection();
+				connection.setRequestMethod("POST");
 
 				// 拼参数
 				if (params != null && params.keySet().size() > 0) {
@@ -1549,6 +1569,21 @@ public class Network
 	}
 
 	public  static JSONObject query(Bundle params) {
+
+		params.putString("action","handset_search");
+
+		String jstr = getJson(Network.URL_REQUEST_COUNT, params);
+		if (jstr == null || jstr.length() <= 0)
+		{
+			return null;
+		}
+
+		try {
+			JSONObject jsobj = new JSONObject(jstr);
+			return jsobj;
+		} catch (JSONException e) {
+			e.printStackTrace();
+		}
 		return null;
 	}
 }

+ 1 - 1
Apex Mobile/app/src/main/java/com/usai/util/dbUtil.java

@@ -253,7 +253,7 @@ public class dbUtil
 				.getApplicationContext(), null, false);
 		Cursor cursor = db.query("fields_info", new String[] { "name" },
 				"function_name='" + module + "' and user='" + user
-						+ "' and behavior=" + Network.BEHAVIOR_RESULT, null,
+						+ "' and behavior=" + Network.BEHAVIOR_RESULT + " and show=1", null,
 				null, null, null, null);
 		String ret = "";
 		while (cursor.moveToNext())