@Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    final Bundle extras = getIntent().getExtras();

    prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());

    if (prefs.getString("list_errorreporting", "ask").equalsIgnoreCase("always")) {
      Toast.makeText(this, getString(R.string.bugreport_dialogheader), Toast.LENGTH_LONG).show();
      CustomExceptionHandler.sendEmail(extras.getString("bugReport"), this);
      finish();
    } else if (prefs.getString("list_errorreporting", "ask").equalsIgnoreCase("ask")) {
      AlertDialog ad =
          new AlertDialog.Builder(this)
              .setTitle(getString(R.string.bugreport_dialogheader))
              .setMessage(getString(R.string.options_bugreport_question))
              .setPositiveButton(
                  getString(R.string.options_bugreport_send),
                  new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                      CustomExceptionHandler.sendEmail(
                          extras.getString("bugReport"), ExceptionActivity.this);
                      finish();
                    }
                  })
              .setNegativeButton(
                  getString(R.string.options_bugreport_dontsend),
                  new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                      finish();
                      return;
                    }
                  })
              .create();

      ad.setCancelable(false);
      ad.show();
    } else {
      AlertDialog ad =
          new AlertDialog.Builder(this)
              .setTitle(getString(R.string.bugreport_dialogheader))
              .setMessage(getString(R.string.options_bugreport_neversendmessage))
              .setPositiveButton(
                  getString(R.string.options_bugreport_ok),
                  new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                      finish();
                      return;
                    }
                  })
              .create();

      ad.setCancelable(false);
      ad.show();
    }
  }
예제 #2
0
  private void popdialogue() {
    final AlertDialog builder = new AlertDialog.Builder(EditPage.this).create();

    LayoutInflater inflater = LayoutInflater.from(this);
    View selectView =
        inflater.inflate(R.layout.picture_dialog, (ViewGroup) findViewById(R.id.layout_root));
    gridView = (GridView) selectView.findViewById(R.id.gridview);

    PictureAdapter adapter =
        new PictureAdapter(ImageUtil.imageMoodTitles, ImageUtil.imageMoodFiles, this);
    gridView.setAdapter(adapter);
    gridView.setOnItemClickListener(
        new OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
            mMoodIndex = position;

            ImageButton mMoodButton = (ImageButton) findViewById(R.id.emotion_sticker);
            mMoodButton.setImageResource(ImageUtil.imageMoodFiles[position]);

            if (builder != null) builder.dismiss();
          }
        });

    builder.setCancelable(false);
    builder.setTitle(R.string.stringHowAboutYourMood);
    builder.setView(selectView);
    builder.setCancelable(true);
    builder.show();
  }
예제 #3
0
  @Override
  protected Dialog onCreateDialog(int id) {
    switch (id) {
      case DIALOG_PROMPT:
        {
          AlertDialog dialog = (new AlertDialog.Builder(this)).create();
          dialog.setTitle("Ushahidi Setup");
          dialog.setMessage("Setup an ushahidi instance.");
          dialog.setButton2(
              "Ok",
              new Dialog.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                  Intent launchPreferencesIntent =
                      new Intent().setClass(Ushahidi.this, Settings.class);

                  // Make it a subactivity so we know when it returns
                  startActivityForResult(launchPreferencesIntent, REQUEST_CODE_SETTINGS);
                  dialog.dismiss();
                }
              });
          dialog.setCancelable(false);
          return dialog;
        }

      case DIALOG_ERROR:
        {
          AlertDialog dialog = (new AlertDialog.Builder(this)).create();
          dialog.setTitle(R.string.alert_dialog_error_title);
          dialog.setMessage(dialogErrorMsg);
          dialog.setButton2(
              "Ok",
              new Dialog.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {

                  Intent launchPreferencesIntent = new Intent(Ushahidi.this, Settings.class);

                  // Make it a subactivity so we know when it returns
                  startActivityForResult(launchPreferencesIntent, REQUEST_CODE_SETTINGS);

                  dialog.dismiss();
                }
              });
          dialog.setCancelable(false);
          return dialog;
        }
    }
    return null;
  }
  /** Creates and displays dialog with the given errorMsg. */
  private void createErrorDialog(String errorMsg) {
    Collect.getInstance().getActivityLogger().logInstanceAction(this, "createErrorDialog", "show.");

    AlertDialog alertDialog = new AlertDialog.Builder(this).create();

    alertDialog.setIcon(android.R.drawable.ic_dialog_info);
    alertDialog.setTitle(getString(R.string.error_occured));
    alertDialog.setMessage(errorMsg);
    DialogInterface.OnClickListener errorListener =
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int i) {
            switch (i) {
              case DialogInterface.BUTTON_POSITIVE:
                Collect.getInstance()
                    .getActivityLogger()
                    .logInstanceAction(this, "createErrorDialog", "OK");
                FormController formController = Collect.getInstance().getFormController();
                formController.jumpToIndex(currentIndex);
                break;
            }
          }
        };
    alertDialog.setCancelable(false);
    alertDialog.setButton(getString(R.string.ok), errorListener);
    alertDialog.show();
  }
 private void showExitApplicationNotification() {
   AlertDialog alertDialog = new AlertDialog.Builder(this).create();
   alertDialog.setTitle("Stop application?");
   // prevents the user from escaping the dialog by hitting the Back button
   alertDialog.setCancelable(false);
   alertDialog.setMessage(
       "Stop this application and exit?  You'll need to relaunch "
           + "the application to use it again.");
   alertDialog.setButton(
       AlertDialog.BUTTON_POSITIVE,
       "Stop and exit",
       new DialogInterface.OnClickListener() {
         public void onClick(DialogInterface dialog, int which) {
           finishApplication();
         }
       });
   alertDialog.setButton(
       AlertDialog.BUTTON_NEGATIVE,
       "Don't stop",
       new DialogInterface.OnClickListener() {
         public void onClick(DialogInterface dialog, int which) {
           // nothing to do here
         }
       });
   alertDialog.show();
 }
예제 #6
0
  private void verifySuccess() {
    AlertDialog dialog = new AlertDialog.Builder(getActivity()).create();
    dialog.setTitle(getResources().getString(R.string.txt_verify_dialog_title));
    dialog.setMessage(getResources().getString(R.string.txt_verify_dialog_message));
    dialog.setCancelable(false);
    dialog.setButton(
        DialogInterface.BUTTON_POSITIVE,
        getResources().getString(R.string.txt_verify),
        new DialogInterface.OnClickListener() {

          @Override
          public void onClick(DialogInterface dialog, int which) {
            Intent intent = new Intent("com.google.zxing.client.android.SCAN");
            intent.putExtra("SCAN_MODE", "QR_CODE_MODE");
            startActivityForResult(intent, 0);
          }
        });
    dialog.setButton(
        DialogInterface.BUTTON_NEGATIVE,
        getResources().getString(R.string.txt_cancel),
        new DialogInterface.OnClickListener() {

          @Override
          public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
          }
        });
    dialog.show();
  }
예제 #7
0
  private void dialogie(String s) {
    if (s == null || s.length() == 0) return;

    AlertDialog ad = new AlertDialog.Builder(me).create();
    ad.setCancelable(true);
    ad.setCanceledOnTouchOutside(true);
    ad.setTitle("Linkification view");

    LinearLayout rl = new LinearLayout(me);
    rl.setBackgroundColor(Color.WHITE);
    rl.setPadding(scalemex(5), scalemex(25), scalemex(5), scalemex(25));

    TextView tv;

    tv = new TextView(me);
    rl.addView(tv);
    tv.setBackgroundColor(Color.WHITE);
    tv.setTextColor(Color.BLACK);
    tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 19f);
    tv.setText(s);
    Linkify.addLinks(tv, Linkify.ALL);

    ScrollView ho = new ScrollView(me);
    ho.addView(rl);

    ad.setView(ho);
    ad.show();
  }
  public void showSuccessDialog(String title, String msg) {
    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(CollageEditorActivity.this);

    // set title
    alertDialogBuilder.setTitle(title);

    // set dialog message
    alertDialogBuilder
        .setMessage(msg)
        .setCancelable(true)
        .setNegativeButton(
            getString(R.string.action_share),
            new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int id) {
                Intent share = new Intent(Intent.ACTION_SEND);
                share.setType("image/jpeg");
                share.putExtra(Intent.EXTRA_STREAM, Uri.parse(fullScreenImageURL));
                startActivity(Intent.createChooser(share, getString(R.string.action_share)));
                finish();
              }
            })
        .setPositiveButton(
            getString(R.string.action_done),
            new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int id) {
                finish();
              }
            });

    // create alert dialog
    AlertDialog alertDialog = alertDialogBuilder.create();
    alertDialog.setCancelable(false);
    // show it
    alertDialog.show();
  }
  /** This function is called when result returned is null. Some connection problem. */
  public void resultIsNull() {
    // Dialog for no internet connection :
    final AlertDialog alertDialog = new AlertDialog.Builder(context).create();
    alertDialog.setTitle(context.getString(R.string.unable_to_reach_hollywood));
    alertDialog.setMessage(context.getString(R.string.check_internet_connection));
    alertDialog.setCancelable(false);
    alertDialog.setButton2(
        "Settings",
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
            Intent intent = new Intent(Settings.ACTION_WIFI_SETTINGS);
            context.startActivity(intent);
            HighestRatedMoviesGridActivity.loadedOnce = true;
            alertDialog.hide();
          }
        });
    alertDialog.setButton(
        "Retry",
        new DialogInterface.OnClickListener() {

          @Override
          public void onClick(DialogInterface dialog, int which) {
            retryRequired();
            alertDialog.hide();
          }
        });

    // TODO : SET ICON FOR DIALOG :

    // alertDialog.setIcon(R.drawable.ic_radio_white_36dp);

    alertDialog.show();
  }
예제 #10
0
  protected void showErrorDialog(View view, boolean cancelable) {
    if (getActivity().isFinishing()) return;

    if (mErrorDialog == null) {
      mErrorDialog = new AlertDialog.Builder(mContext, R.style.error_dialog).create();
      mErrorDialog.setCancelable(cancelable);
      mErrorDialog.setCanceledOnTouchOutside(cancelable);
    }
    mErrorDialog.show();
    Window window = mErrorDialog.getWindow();
    window.setGravity(Gravity.CENTER | Gravity.BOTTOM);
    window.setContentView(view);
    window.setWindowAnimations(R.style.animation_error_dialog);
    int width = (int) (ScreenUtils.getScreenW(mContext) * 5 / 6f);
    WindowManager.LayoutParams wmlp = window.getAttributes();
    wmlp.gravity = Gravity.CENTER | Gravity.BOTTOM;
    wmlp.y = 200;
    window.setLayout(width, ViewGroup.LayoutParams.WRAP_CONTENT);

    executor.schedule(
        new Runnable() {
          @Override
          public void run() {
            dismissErrorDialog();
          }
        },
        5,
        TimeUnit.SECONDS);
  }
예제 #11
0
  private void createAlertDialog(String message) {
    Collect.getInstance().getActivityLogger().logAction(this, "createAlertDialog", "show");

    mAlertDialog = new AlertDialog.Builder(this).create();
    mAlertDialog.setTitle(getString(R.string.upload_results));
    mAlertDialog.setMessage(message);
    DialogInterface.OnClickListener quitListener =
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int i) {
            switch (i) {
              case DialogInterface.BUTTON_POSITIVE: // ok
                Collect.getInstance()
                    .getActivityLogger()
                    .logAction(this, "createAlertDialog", "OK");
                // always exit this activity since it has no interface
                mAlertShowing = false;
                finish();
                break;
            }
          }
        };
    mAlertDialog.setCancelable(false);
    mAlertDialog.setButton(getString(R.string.ok), quitListener);
    mAlertDialog.setIcon(android.R.drawable.ic_dialog_info);
    mAlertShowing = true;
    mAlertMsg = message;
    mAlertDialog.show();
  }
예제 #12
0
 private void showWarmingDialog() {
   AlertDialog warmingDialog =
       new AlertDialog.Builder(this)
           .setTitle(R.string.dialog_warming_title)
           .setMessage(R.string.dialog_warming_message)
           .setPositiveButton(
               R.string.dialog_warming_positive_button,
               new DialogInterface.OnClickListener() {
                 @Override
                 public void onClick(DialogInterface dialog, int which) {
                   SharedPreferences.Editor edit = preferences.edit();
                   edit.putBoolean(IS_AGREE, true);
                   edit.apply();
                 }
               })
           .setNegativeButton(
               R.string.dialog_warming_negative_button,
               new DialogInterface.OnClickListener() {
                 @Override
                 public void onClick(DialogInterface dialog, int which) {
                   SharedPreferences.Editor edit = preferences.edit();
                   edit.putBoolean(IS_AGREE, false);
                   edit.apply();
                   MainActivity.this.finish();
                 }
               })
           .create();
   warmingDialog.setCanceledOnTouchOutside(false);
   warmingDialog.setCancelable(false);
   warmingDialog.show();
 }
예제 #13
0
  public void alerta(String menssage) {

    AlertDialog alertDialog = new AlertDialog.Builder(Body.this).create();

    // Setting Dialog Title
    alertDialog.setTitle("¿ Sabias que ?");

    // Setting Dialog Message
    alertDialog.setMessage(menssage);

    // Setting Icon to Dialog
    alertDialog.setIcon(R.drawable.orgcorazon1);
    alertDialog.setCancelable(false);

    // Setting OK Button
    alertDialog.setButton(
        "OK",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
            // Write your code here to execute after dialog closed
            mp.stop();
          }
        });

    // Showing Alert Message
    alertDialog.show();
  }
  public void root() {
    AlertDialog alertDialog = new AlertDialog.Builder(this).create();
    alertDialog.setTitle("Now What?");
    alertDialog.setCancelable(false);
    alertDialog.setMessage("What do you want to do?");
    alertDialog.setButton(
        "Root",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
            try {
              sendBroadcast(
                  new Intent("com.amazon.internal.E_COMMAND").putExtra("cmd", "adbd_start"));
              post();
            } catch (Exception e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            }
          }
        });

    alertDialog.setButton3(
        "Exit",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
            System.exit(0);
          }
        });
    alertDialog.show();
  }
  /**
   * The Wall Of Shame
   *
   * <p>Organizations and persons listed below have violated the copyright and/or licensing of
   * BurritoRoot and have had their rights to use any part or derivative of BurritoRoot revoked.
   *
   * <p>You are scum, you steal the hard work of our developers. You even stole my non working
   * unroot code you f*cking bum.
   *
   * <p>Author of unlockroot http://www(dot)unlockroot(dot)com Liang Bing [email protected]
   * [email protected] HongKong
   */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    AlertDialog alertDialog1 = new AlertDialog.Builder(this).create();
    alertDialog1.setTitle("Disclaimer");
    alertDialog1.setCancelable(false);
    alertDialog1.setMessage(
        "Copyright 2011 TeamAndIRC. Using this application may void your warranty. General advice is not to root you device, however if you want to, if you understand"
            + " what you are doing, and acknowledge you will hold no one responsible for any loss or damages caused by this app, or the rooting of your device click Agree. This application is"
            + "opensource, and licensed under the GPLv3. Source is available at https://github.com/CunningLogic/BurritoRoot");
    alertDialog1.setButton(
        "Agree",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
            credit();
          }
        });

    alertDialog1.setButton2(
        "Disagree!",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
            System.exit(0);
          }
        });

    alertDialog1.show();
  }
  private void update_password(String email, String password) {
    //        final LoadingDialog loadingDialog = new LoadingDialog();
    //        Bundle args = new Bundle();
    //        args.putString(LoadingDialog.DIALOG_TEXT_KEY, getString(R.string.submitting));
    //        loadingDialog.setArguments(args);
    //        loadingDialog.setCancelable(false);
    //        loadingDialog.show(getFragmentManager(), "submitting");
    dialog =
        new SpotsDialog(
            ForgetPassword.this, getString(R.string.submitting), R.style.SpotsDialogCustom);
    dialog.setCancelable(false);
    dialog.show();

    WebServiceFunctions.forget_password(
        this,
        email,
        password,
        password,
        new OnForgetPasswordListener() {

          @Override
          public void success(String message) {
            dialog.dismiss();
            Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG).show();
            onBackPressed();
          }

          @Override
          public void fail(String cause) {
            dialog.dismiss();
            Crouton.cancelAllCroutons();
            AppSnackBar.showTopSnackbar(ForgetPassword.this, cause, Color.RED, Color.WHITE);
          }
        });
  }
예제 #17
0
  /**
   * Creates a dialog with the given message. Will exit the activity when the user preses "ok" if
   * shouldExit is set to true.
   *
   * @param errorMsg
   * @param shouldExit
   */
  private void createErrorDialog(String errorMsg, final boolean shouldExit) {

    Collect.getInstance().getActivityLogger().logAction(this, "createErrorDialog", "show");

    mAlertDialog = new AlertDialog.Builder(this).create();
    mAlertDialog.setIcon(android.R.drawable.ic_dialog_info);
    mAlertDialog.setMessage(errorMsg);
    DialogInterface.OnClickListener errorListener =
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int i) {
            switch (i) {
              case DialogInterface.BUTTON_POSITIVE:
                Collect.getInstance()
                    .getActivityLogger()
                    .logAction(this, "createErrorDialog", shouldExit ? "exitApplication" : "OK");
                if (shouldExit) {
                  finish();
                }
                break;
            }
          }
        };
    mAlertDialog.setCancelable(false);
    mAlertDialog.setButton(getString(R.string.ok), errorListener);
    mAlertDialog.show();
  }
  public void credit() {
    AlertDialog alertDialog2 = new AlertDialog.Builder(this).create();
    alertDialog2.setTitle("Credit");
    alertDialog2.setCancelable(false);
    alertDialog2.setMessage(
        "Justin Case (jcase) :Theory, Exploit and Code.\n\n"
            + "Vashypooh :Bugging the shit out of jcase and testing\n\n"
            + "Trevor Eckhart :Testing\n\n"
            + "IOMoster :Pointing out my stupid mistake that kept this from working.\n\n"
            + "AndroidPolice.com for support all my efforts, no matter how drunk I am.\n\n"
            + "RootzWiki.com for giving me support and a home on the net.");
    alertDialog2.setButton(
        "You Rock",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
            root();
          }
        });

    alertDialog2.setButton2(
        "You Suck!",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
            System.exit(0);
          }
        });

    alertDialog2.show();
  }
 /**
  * Show a dialog to confirm exit download.
  *
  * @param message
  */
 private void pushToDialogOptions(String message) {
   alertDialog = new AlertDialog.Builder(DaisyReaderDownloadBooks.this).create();
   // Setting Dialog Title
   alertDialog.setTitle(R.string.error_title);
   // Setting Dialog Message
   alertDialog.setMessage(message);
   alertDialog.setCanceledOnTouchOutside(false);
   alertDialog.setCancelable(false);
   // Setting Icon to Dialog
   alertDialog.setIcon(R.raw.error);
   alertDialog.setButton(
       AlertDialog.BUTTON_NEGATIVE,
       DaisyReaderDownloadBooks.this.getString(R.string.no),
       new DialogInterface.OnClickListener() {
         public void onClick(DialogInterface dialog, int id) {
           mProgressDialog.show();
         }
       });
   alertDialog.setButton(
       AlertDialog.BUTTON_POSITIVE,
       DaisyReaderDownloadBooks.this.getString(R.string.yes),
       new DialogInterface.OnClickListener() {
         public void onClick(DialogInterface dialog, int id) {
           mTask.cancel(true);
         }
       });
   alertDialog.show();
 }
  public void getOrders(final Context mContext, final ListView orderList) {
    AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
    builder.setTitle("当前状态:");
    builder.setMessage("正在获取订单列表······");
    final AlertDialog dialog = builder.create();
    dialog.setCancelable(false);
    NetWorkManager.SuccessCallback successCallback =
        new NetWorkManager.SuccessCallback() {
          @Override
          public void onSuccess(String result) {
            // TODO Auto-generated method stub
            dialog.cancel();
            try {
              dialog.cancel();
              JSONArray mJsonArray = new JSONArray(result);
              List<Order> orders = new ArrayList<Order>();
              for (int i = 0; i < mJsonArray.length(); i++) {
                Order order = new Order();
                JSONObject order_JsonObject = mJsonArray.getJSONObject(i);
                order.setSeller_name(order_JsonObject.getString("sname"));
                JSONObject timeObject = order_JsonObject.getJSONObject("time");

                order.setApplyTime(timeObject.getInt("hour"));
                order.setApplyDate(
                    timeObject.getInt("year")
                        + "-"
                        + timeObject.getInt("month")
                        + "-"
                        + timeObject.getInt("day"));
                ArrayList<Integer> positionList = new ArrayList<Integer>();
                JSONArray positionList_JsonArray = order_JsonObject.getJSONArray("position");
                for (int j = 0; j < positionList_JsonArray.length(); j++) {
                  positionList.add(positionList_JsonArray.getInt(j));
                }
                order.setPositionList(positionList);
                orders.add(order);
              }
              OrderAdapter orderAdapter = new OrderAdapter(mContext, orders);
              orderList.setAdapter(orderAdapter);
            } catch (JSONException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            }
          }
        };
    NetWorkManager.FailCallback failCallback =
        new NetWorkManager.FailCallback() {
          @Override
          public void onFail() {
            dialog.cancel();
            Toast.makeText(mContext, "通过网络获取信息时出现异常!!", Toast.LENGTH_SHORT).show();
          }
        };
    final String url = ip + "/booking/";
    NetWorkManager manager = NetWorkManager.getInstance();
    NetWorkManager.HttpMethod httpMethod = NetWorkManager.HttpMethod.GET;
    dialog.show();
    manager.NetConnection(successCallback, failCallback, url, httpMethod);
  }
 public void getUser(final Context mContext, final View mView) {
   /*
   //测试用例
   final EditText username_et = (EditText)mView.findViewById(R.id.username_et);
   final EditText name_et = (EditText)mView.findViewById(R.id.name_et);
   final EditText phone_et = (EditText)mView.findViewById(R.id.phone_et);
   String result = "{username:chenbojun,realname:chenbojun,phonenumber:123}";
   JSONObject mJson;
   try {
   	mJson = new JSONObject(result);
   	username_et.setText(mJson.getString("username"));
   	name_et.setText(mJson.getString("realname"));
   	phone_et.setText(mJson.getString("phonenumber"));
   } catch (JSONException e) {
   	// TODO Auto-generated catch block
   	e.printStackTrace();
   }
   */
   AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
   builder.setTitle("当前状态:");
   builder.setMessage("正在获取个人信息······");
   final AlertDialog dialog = builder.create();
   dialog.setCancelable(false);
   final EditText username_et = (EditText) mView.findViewById(R.id.username_et);
   final EditText name_et = (EditText) mView.findViewById(R.id.name_et);
   final EditText phone_et = (EditText) mView.findViewById(R.id.phone_et);
   NetWorkManager.SuccessCallback successCallback =
       new NetWorkManager.SuccessCallback() {
         @Override
         public void onSuccess(String result) {
           // TODO Auto-generated method stub
           try {
             dialog.cancel();
             JSONObject mJson = new JSONObject(result);
             username_et.setText(mJson.getString("username"));
             name_et.setText(mJson.getString("realname"));
             phone_et.setText(mJson.getString("phonenumber"));
           } catch (JSONException e) {
             // TODO Auto-generated catch block
             e.printStackTrace();
           }
         }
       };
   NetWorkManager.FailCallback failCallback =
       new NetWorkManager.FailCallback() {
         @Override
         public void onFail() {
           dialog.cancel();
           Toast.makeText(mContext, "通过网络获取信息时出现异常!!", Toast.LENGTH_SHORT).show();
         }
       };
   final String url = ip + "/modifyinfo/ordinary/";
   NetWorkManager manager = NetWorkManager.getInstance();
   NetWorkManager.HttpMethod httpMethod = NetWorkManager.HttpMethod.GET;
   dialog.show();
   manager.NetConnection(successCallback, failCallback, url, httpMethod);
 }
예제 #22
0
  public static void buildPaper(final Context context, final String name, final String reContext) {
    final int appWidgetID = SharedPreferencesUtil.getSharedInt(context, "appWidgetId");
    Log.w("na", appWidgetID + "");
    if (appWidgetID == 0) {
      Toast.makeText(context, "请添加桌面小控件,才能使用该功能", Toast.LENGTH_SHORT).show();
    } else {
      final RemoteViews views =
          new RemoteViews(context.getPackageName(), R.layout.note_desk_widget);

      AlertDialog.Builder builder = new AlertDialog.Builder(context);
      final View dialog_build_paper = View.inflate(context, R.layout.dialog_build_paper, null);
      builder.setView(dialog_build_paper);
      final AlertDialog dialog = builder.create();
      dialog.setCancelable(false);
      dialog.show();

      ButtonFlat btn_dialog_cancel =
          (ButtonFlat) dialog_build_paper.findViewById(R.id.btn_dialog_cancel);
      ButtonFlat btn_dialog_secondart =
          (ButtonFlat) dialog_build_paper.findViewById(R.id.btn_dialog_secondart);
      ButtonFlat btn_dialog_import =
          (ButtonFlat) dialog_build_paper.findViewById(R.id.btn_dialog_import);

      btn_dialog_cancel.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              ((ViewGroup) (dialog_build_paper.getParent())).removeView(dialog_build_paper);
              dialog.dismiss();
            }
          });
      btn_dialog_import.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              views.setTextViewText(R.id.tv_desk_1, reContext + "");
              views.setTextViewText(R.id.tv_desk_name, name + "");
              AppWidgetManager manager = AppWidgetManager.getInstance(context);
              manager.updateAppWidget(appWidgetID, views);
              ((ViewGroup) (dialog_build_paper.getParent())).removeView(dialog_build_paper);
              dialog.dismiss();
            }
          });
      btn_dialog_secondart.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              views.setTextViewText(R.id.tv_desk_2, reContext + "");
              views.setTextViewText(R.id.tv_desk_name, name + "");
              AppWidgetManager manager = AppWidgetManager.getInstance(context);
              manager.updateAppWidget(appWidgetID, views);
              ((ViewGroup) (dialog_build_paper.getParent())).removeView(dialog_build_paper);
              dialog.dismiss();
            }
          });
    }
  }
예제 #23
0
  /** 第一次进入手机防盗界面 */
  private void showFirstEntryDialog() {
    AlertDialog.Builder builder = new Builder(this);
    final AlertDialog d = builder.create();
    d.setTitle("输入密码");
    View view = inflater.inflate(R.layout.first_entry_dialog, null);
    final EditText first_pwd_et = (EditText) view.findViewById(R.id.first_password_et);
    final EditText second_pwd_et = (EditText) view.findViewById(R.id.second_password_et);
    // d.addContentView(view, new LayoutParams(90, 100));
    d.setView(view);

    // 不允许用户通过 后退键  取消对话框
    d.setCancelable(false);
    d.show();

    Button confirm_bt = (Button) view.findViewById(R.id.lostProtectedConfirmbt);
    Button cancle_bt = (Button) view.findViewById(R.id.lostProtectedCanclebt);

    confirm_bt.setOnClickListener(
        new OnClickListener() {
          String endcodedpwd;

          public void onClick(View v) {
            // TODO Auto-generated method stub
            String first_pwd = first_pwd_et.getText().toString();
            String second_pwd = second_pwd_et.getText().toString();

            try {
              endcodedpwd = MD5Encoder.getMD5code(first_pwd);
            } catch (Exception e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            }
            if ("".equals(first_pwd) || "".equals(second_pwd)) {
              Toast.makeText(getApplicationContext(), "密码不能为空", 1).show();
            } else if (first_pwd.equals(second_pwd)) {
              Editor editer = sp.edit();
              editer.putString("password", endcodedpwd);
              editer.commit();
              d.dismiss();
              // setContentView(R.layout.lostprotect);
              LoadMainUI();
            } else {
              Toast.makeText(getApplicationContext(), "两次密码输入不一样", 1).show();
            }
          }
        });
    cancle_bt.setOnClickListener(
        new OnClickListener() {

          public void onClick(View v) {
            // TODO Auto-generated method stub
            d.dismiss();
            finish();
          }
        });
  }
  public SystemWebView(Context context, AttributeSet attrs) {
    super(context, attrs);
    this.context = context;
    progressBar = new ProgressBar(context);
    progressBar.setIndeterminate(true);
    progressBar.setLayoutParams(
        new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 100));
    builder = new AlertDialog.Builder(context).setTitle("加载中...").setView(progressBar);

    dialog = builder.create();
    dialog.setCancelable(false);
  }
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    if (Constants.IS_LOGGABLE) {
      Log.i(Constants.LOG_TAG, "Selected menu item id: " + String.valueOf(item.getItemId()));
    }
    switch (item.getItemId()) {
      case R.id.btnUncheckAll:
        AlertDialog dialog = new AlertDialog.Builder(this).create();
        dialog.setTitle("Confirmation");
        dialog.setMessage("Are you sure you want to uncheck all of the boxes below?");
        dialog.setCancelable(false);
        dialog.setButton(
            DialogInterface.BUTTON_POSITIVE,
            "Yes",
            new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int buttonId) {
                if (lvPackages == null
                    || lvPackages.getAdapter() == null
                    || ((packageAdapter) lvPackages.getAdapter()).selected == null) {
                  // something went wrong
                  return;
                }
                ((packageAdapter) lvPackages.getAdapter()).selected.clear();
                lvPackages.invalidateViews();
              }
            });
        dialog.setButton(
            DialogInterface.BUTTON_NEGATIVE,
            "No",
            new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int buttonId) {
                // do nothing!
              }
            });
        dialog.setIcon(android.R.drawable.ic_dialog_alert);
        dialog.show();

        return true;
      case R.id.btnSave:
        finish();
        return true;
      case R.id.btnDonate:
        Intent i = new Intent(Intent.ACTION_VIEW);
        i.setData(Uri.parse(Constants.DONATION_URL));
        startActivity(i);
        return true;
      case R.id.btnSettings:
        Intent settings = new Intent(this, SettingsActivity.class);
        startActivity(settings);
        return true;
    }
    return super.onOptionsItemSelected(item);
  }
 public void login(final Context mContext, final String username, final String password) {
   AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
   builder.setTitle("当前状态:");
   builder.setMessage("正在登录······");
   final AlertDialog mDialog = builder.create();
   mDialog.setCancelable(false);
   NetWorkManager.SuccessCallback successCallback =
       new NetWorkManager.SuccessCallback() {
         @Override
         public void onSuccess(String result) {
           // TODO Auto-generated method stub
           mDialog.cancel();
           if (!result.equals("login falied!!")) {
             SharedPreferences sp = mContext.getSharedPreferences("userIfo", Context.MODE_PRIVATE);
             if (sp.getBoolean("ISCHECK", true)) {
               Editor editor = sp.edit();
               editor.putString("USER_NAME", username);
               editor.putString("PASSWORD", password);
               editor.commit();
             } else {
               Editor editor = sp.edit();
               editor.putString("USER_NAME", "");
               editor.putString("PASSWORD", "");
               editor.commit();
             }
             Toast.makeText(mContext, "登陆成功", Toast.LENGTH_SHORT).show();
             Intent intent = new Intent();
             // 根据登录的用户类型来进入相应的个人中心,后期加
             intent.setClass(mContext, MainActivity.class);
             mContext.startActivity(intent);
             ((Activity) mContext).finish();
           } else {
             // 输出错误信息
             Toast.makeText(mContext, "用户名或者密码错误", Toast.LENGTH_SHORT).show();
           }
         }
       };
   NetWorkManager.FailCallback failCallback =
       new NetWorkManager.FailCallback() {
         @Override
         public void onFail() {
           mDialog.cancel();
           Toast.makeText(mContext, "通过网络获取信息时出现异常!!", Toast.LENGTH_LONG).show();
         }
       };
   final String url = ip + "/login/";
   NetWorkManager manager = NetWorkManager.getInstance();
   NetWorkManager.HttpMethod httpMethod = NetWorkManager.HttpMethod.POST;
   mDialog.show();
   manager.NetConnection(
       successCallback, failCallback, url, httpMethod, "username", username, "password", password);
 }
 public void getSellers(final Context mContext, final ListView sellerList) {
   // 测试用例
   AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
   builder.setTitle("当前状态:");
   builder.setMessage("正在获取商家列表······");
   final AlertDialog dialog = builder.create();
   dialog.setCancelable(false);
   NetWorkManager.SuccessCallback successCallback =
       new NetWorkManager.SuccessCallback() {
         @Override
         public void onSuccess(String result) {
           // TODO Auto-generated method stub
           dialog.cancel();
           try {
             dialog.cancel();
             JSONArray mJsonArray = new JSONArray(result);
             List<Seller> sellers = new ArrayList<Seller>();
             for (int i = 0; i < mJsonArray.length(); i++) {
               // sellers.add(new Seller(mJsonArray.getJSONObject(i).getString()))
               Seller seller = new Seller();
               JSONObject seller_JsonObject = mJsonArray.getJSONObject(i);
               seller.setId(seller_JsonObject.getString("id"));
               seller.setName(seller_JsonObject.getString("sname"));
               seller.setPhone(seller_JsonObject.getString("phonenumber"));
               seller.setAddress(seller_JsonObject.getString("address"));
               seller.setNumber(Integer.parseInt(seller_JsonObject.getString("counter")));
               seller.setIntroduction(seller_JsonObject.getString("description"));
               sellers.add(seller);
             }
             SellerAdapter sellerAdapter = new SellerAdapter(mContext, sellers);
             sellerList.setAdapter(sellerAdapter);
           } catch (JSONException e) {
             // TODO Auto-generated catch block
             e.printStackTrace();
           }
         }
       };
   NetWorkManager.FailCallback failCallback =
       new NetWorkManager.FailCallback() {
         @Override
         public void onFail() {
           dialog.cancel();
           Toast.makeText(mContext, "通过网络获取信息时出现异常!!", Toast.LENGTH_SHORT).show();
         }
       };
   final String url = ip + "/booked/";
   NetWorkManager manager = NetWorkManager.getInstance();
   NetWorkManager.HttpMethod httpMethod = NetWorkManager.HttpMethod.GET;
   dialog.show();
   manager.NetConnection(successCallback, failCallback, url, httpMethod);
 }
예제 #28
0
  /** 设置密码后进入手机防盗界面 */
  private void showNormalEntryDialog() {
    // TODO Auto-generated method stub
    AlertDialog.Builder builder = new Builder(this);
    final AlertDialog d = builder.create();
    View view = inflater.inflate(R.layout.normal_entry_dialog, null);
    // 不允许用户通过 后退键  取消对话框
    d.setCancelable(false);
    d.setTitle("请输入密码 ");
    // RelativeLayout.LayoutParams
    // FrameLayout.LayoutParams
    d.setView(view);
    d.show();
    final EditText normal_et = (EditText) view.findViewById(R.id.normal_password_et);

    Button confirm_bt = (Button) view.findViewById(R.id.secondConfirmbt);
    Button cancle_bt = (Button) view.findViewById(R.id.secondCanclebt);
    confirm_bt.setOnClickListener(
        new OnClickListener() {

          public void onClick(View v) {
            // TODO Auto-generated method stub
            String password = normal_et.getText().toString();
            String endcodepwd = null;
            try {
              endcodepwd = MD5Encoder.getMD5code(password);
            } catch (Exception e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            }

            String realpwd = sp.getString("password", null);
            if (endcodepwd != null && realpwd != null && endcodepwd.equals(realpwd)) {
              Logger.i(TAG, "密码正确,进入lostprotectedactivity");
              d.dismiss();
              // setContentView(R.layout.lostprotect);
              LoadMainUI();
            } else {
              Toast.makeText(getApplicationContext(), "密码不正确", 1).show();
            }
          }
        });
    cancle_bt.setOnClickListener(
        new OnClickListener() {

          public void onClick(View v) {
            // TODO Auto-generated method stub
            d.dismiss();
            finish();
          }
        });
  }
예제 #29
0
  // The return value is sent elsewhere. TODO in java, in SendMessage in C++.
  public void inputBox(String title, String defaultText, String defaultAction) {
    final FrameLayout fl = new FrameLayout(this);
    final EditText input = new EditText(this);
    input.setGravity(Gravity.CENTER);

    FrameLayout.LayoutParams editBoxLayout =
        new FrameLayout.LayoutParams(
            FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT);
    editBoxLayout.setMargins(2, 20, 2, 20);
    fl.addView(input, editBoxLayout);

    input.setInputType(InputType.TYPE_CLASS_TEXT);
    input.setText(defaultText);
    input.selectAll();

    // Lovely!
    AlertDialog.Builder bld = null;
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) bld = new AlertDialog.Builder(this);
    else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH)
      bld = createDialogBuilderWithTheme();
    else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M)
      bld = createDialogBuilderWithDeviceTheme();
    else bld = createDialogBuilderNew();

    AlertDialog dlg =
        bld.setView(fl)
            .setTitle(title)
            .setPositiveButton(
                defaultAction,
                new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface d, int which) {
                    NativeApp.sendMessage("inputbox_completed", input.getText().toString());
                    d.dismiss();
                  }
                })
            .setNegativeButton(
                "Cancel",
                new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface d, int which) {
                    NativeApp.sendMessage("inputbox_failed", "");
                    d.cancel();
                  }
                })
            .create();

    dlg.setCancelable(true);
    dlg.show();
  }
 public void sendOrder(final Context mContext, String id, int time, String position) {
   AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
   builder.setTitle("当前状态:");
   builder.setMessage("正在提交订单······");
   final AlertDialog mDialog = builder.create();
   mDialog.setCancelable(false);
   NetWorkManager.SuccessCallback successCallback =
       new NetWorkManager.SuccessCallback() {
         @Override
         public void onSuccess(String result) {
           // TODO Auto-generated method stub
           mDialog.cancel();
           Toast.makeText(mContext, NetWorkManager.session, Toast.LENGTH_LONG).show();
           if (result.equals("order accepted")) {
             Toast.makeText(mContext, "订单提交成功!!", Toast.LENGTH_SHORT).show();
             Intent intent = new Intent();
             // 根据登录的用户类型来进入相应的个人中心,后期加
             intent.setClass(mContext, MainActivity.class);
             mContext.startActivity(intent);
             ((Activity) mContext).finish();
           } else {
             // 输出错误信息
             Toast.makeText(mContext, "订单提交失败!!", Toast.LENGTH_SHORT).show();
           }
         }
       };
   NetWorkManager.FailCallback failCallback =
       new NetWorkManager.FailCallback() {
         @Override
         public void onFail() {
           mDialog.cancel();
           Toast.makeText(mContext, "通过网络获取信息时出现异常!!", Toast.LENGTH_LONG).show();
         }
       };
   final String url = ip + "/booking/";
   NetWorkManager manager = NetWorkManager.getInstance();
   NetWorkManager.HttpMethod httpMethod = NetWorkManager.HttpMethod.POST;
   mDialog.show();
   manager.NetConnection(
       successCallback,
       failCallback,
       url,
       httpMethod,
       "stadium_id",
       id,
       "time",
       "" + time,
       "position",
       position);
 }