|
@@ -126,64 +126,112 @@ public class SearchResultActivity extends AppCompatActivity implements AbsListVi
|
|
|
outState.putBundle("query_params",mParams);
|
|
outState.putBundle("query_params",mParams);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // 动态修改Menu
|
|
|
@Override
|
|
@Override
|
|
|
- public boolean onCreateOptionsMenu(Menu menu) {
|
|
|
|
|
- getMenuInflater().inflate(R.menu.result_menu,menu);
|
|
|
|
|
- return true;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- public boolean onOptionsItemSelected(MenuItem item) {
|
|
|
|
|
|
|
+ public boolean onPrepareOptionsMenu(Menu menu) {
|
|
|
|
|
+ super.onPrepareOptionsMenu(menu);
|
|
|
|
|
+ menu.clear();
|
|
|
|
|
|
|
|
- if (item.getItemId() == R.id.result_menu) {
|
|
|
|
|
|
|
|
|
|
|
|
+ if (resultData != null) {
|
|
|
try {
|
|
try {
|
|
|
|
|
+ JSONArray menu_json = resultData.getJSONArray("menu");
|
|
|
|
|
|
|
|
- JSONArray menu = resultData.getJSONArray("menu");
|
|
|
|
|
|
|
+ if (menu_json != null && menu_json.length() > 0) {
|
|
|
|
|
|
|
|
- if (menu.length() > 0) {
|
|
|
|
|
- ArrayList<String> titleList = new ArrayList<>();
|
|
|
|
|
-
|
|
|
|
|
- for (int i = 0; i < menu.length(); i++) {
|
|
|
|
|
- JSONObject json = menu.getJSONObject(i);
|
|
|
|
|
|
|
+ for (int i = 0; i < menu_json.length(); i++) {
|
|
|
|
|
+ JSONObject json = menu_json.getJSONObject(i);
|
|
|
String title = json.getString("title");
|
|
String title = json.getString("title");
|
|
|
- titleList.add(title);
|
|
|
|
|
|
|
+ menu.add(0, i, 0, title);
|
|
|
}
|
|
}
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (JSONException e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- new AlertDialog.Builder(mContext)
|
|
|
|
|
- .setSingleChoiceItems((String[])titleList.toArray(new String[titleList.size()]), -1, new DialogInterface.OnClickListener() {
|
|
|
|
|
- @Override
|
|
|
|
|
- public void onClick(DialogInterface dialog, int which) {
|
|
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- try {
|
|
|
|
|
- JSONArray menu = resultData.getJSONArray("menu");
|
|
|
|
|
- JSONObject json = menu.getJSONObject(which);
|
|
|
|
|
|
|
+// @Override
|
|
|
|
|
+// public boolean onCreateOptionsMenu(Menu menu) {
|
|
|
|
|
+// getMenuInflater().inflate(R.menu.result_menu,menu);
|
|
|
|
|
+// return true;
|
|
|
|
|
+// }
|
|
|
|
|
|
|
|
- String actionType = json.getString("action");
|
|
|
|
|
- String url = json.optString("url");
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public boolean onOptionsItemSelected(MenuItem item) {
|
|
|
|
|
|
|
|
- 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");
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+// 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");
|
|
|
|
|
+//
|
|
|
|
|
+// 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);
|
|
|
|
|
+// }
|
|
|
|
|
+// dialog.dismiss();
|
|
|
|
|
+// }
|
|
|
|
|
+// })
|
|
|
|
|
+// .show();
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// } catch (JSONException e) {
|
|
|
|
|
+// Log.e("Result", "onOptionsItemSelected: ", e);
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// }
|
|
|
|
|
|
|
|
- } catch (JSONException exception) {
|
|
|
|
|
- Log.d("Result", "onClick: ",exception);
|
|
|
|
|
- }
|
|
|
|
|
- dialog.dismiss();
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
- .show();
|
|
|
|
|
|
|
+ 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 e) {
|
|
|
|
|
- Log.e("Result", "onOptionsItemSelected: ", e);
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ } catch (JSONException exception) {
|
|
|
|
|
+ Log.d("Result", "onClick: ",exception);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
return true;
|
|
@@ -1017,7 +1065,7 @@ public class SearchResultActivity extends AppCompatActivity implements AbsListVi
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public void showOrderDetail() {
|
|
public void showOrderDetail() {
|
|
|
- Intent intent = OrderDetailActivity.build(mContext,OrderDetailActivity.class,URL_REMOTE,null,new Bundle());
|
|
|
|
|
|
|
+ Intent intent = OrderDetailActivity.build(mContext,OrderDetailActivity.class,null,URL_REMOTE,null,new Bundle());
|
|
|
|
|
|
|
|
startActivity(intent);
|
|
startActivity(intent);
|
|
|
}
|
|
}
|