|
|
@@ -35,6 +35,7 @@ import org.json.JSONArray;
|
|
|
import org.json.JSONException;
|
|
|
import org.json.JSONObject;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Iterator;
|
|
|
|
|
|
|
|
|
@@ -314,31 +315,53 @@ public class ApexResultActivity extends AppCompatActivity implements ApexResultP
|
|
|
|
|
|
private void menuItemClick() {
|
|
|
|
|
|
- ActionSheet actionSheet = new ActionSheet(mCtx);
|
|
|
+ ArrayList<ApexResultMenuItem> menuItems = mPresenter.getMenuItems();
|
|
|
+ if (menuItems != null && menuItems.size() > 0) {
|
|
|
|
|
|
- actionSheet.addAction("Setting", ActionSheet.ActionType.ActionTypeDefault, new View.OnClickListener() {
|
|
|
- @Override
|
|
|
- public void onClick(View v) {
|
|
|
- showFieldsSetting();
|
|
|
- }
|
|
|
- });
|
|
|
+ ActionSheet actionSheet = new ActionSheet(mCtx);
|
|
|
|
|
|
- actionSheet.addAction("Save", ActionSheet.ActionType.ActionTypeDefault, new View.OnClickListener() {
|
|
|
- @Override
|
|
|
- public void onClick(View v) {
|
|
|
- saveSearchParameters();
|
|
|
- }
|
|
|
- });
|
|
|
+ int len = menuItems.size();
|
|
|
+ for (int i = 0; i < len; i++) {
|
|
|
|
|
|
- actionSheet.addAction("Cancel", ActionSheet.ActionType.ACtionTypeCancel, new View.OnClickListener() {
|
|
|
- @Override
|
|
|
- public void onClick(View v) {
|
|
|
+ final ApexResultMenuItem menuItem = menuItems.get(i);
|
|
|
+ actionSheet.addAction(menuItem.title, ActionSheet.ActionType.ActionTypeDefault, new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ if (menuItem.action != null) {
|
|
|
|
|
|
+ if (menuItem.action.equals("save")) {
|
|
|
+
|
|
|
+ saveSearchParameters();
|
|
|
+ } else if (menuItem.action.equals("field_setting")) {
|
|
|
+ showFieldsSetting();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
- });
|
|
|
|
|
|
- actionSheet.show();
|
|
|
+ actionSheet.addAction("Cancel", ActionSheet.ActionType.ACtionTypeCancel, new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ actionSheet.show();
|
|
|
|
|
|
+ } else {
|
|
|
+
|
|
|
+ new AlertDialog.Builder(mCtx)
|
|
|
+ .setTitle("Warning")
|
|
|
+ .setMessage("there is no menu field to response")
|
|
|
+ .setPositiveButton("OK", new DialogInterface.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(DialogInterface dialog, int which) {
|
|
|
+
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .show();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void saveSearchParameters() {
|