Beispiel #1
0
  public void showUpdateDialog() {
    final Dialog dialog = new Dialog(getActivity());
    dialog.setContentView(R.layout.edit_user_info);
    dialog.setCancelable(true);

    updateProfileTV = (TextView) dialog.findViewById(R.id.udpateProfileTV);
    phoneNumberUpd = (TextView) dialog.findViewById(R.id.phoneNumberUpd);
    errorTxtUpt = (TextView) dialog.findViewById(R.id.errorTxtUpt);
    nameUpd = (EditText) dialog.findViewById(R.id.nameUpd);
    eMailUpd = (EditText) dialog.findViewById(R.id.eMailUpd);
    addressETUpd = (EditText) dialog.findViewById(R.id.addressETUpd);
    save = (Button) dialog.findViewById(R.id.saveUpt);

    phoneNumberUpd.setText(databaseHandler.getUser(1).getMsisdn());
    nameUpd.setText(databaseHandler.getUser(1).getName());
    eMailUpd.setText(databaseHandler.getUser(1).getEmail());
    addressETUpd.setText(databaseHandler.getRegister(1).getAddress());
    save.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Hit here to update
            if (carFunctions.isConnectingToInternet()) {
              new UpdateProfile(
                      databaseHandler.getUser(1).getMsisdn(),
                      eMailUpd.getText().toString(),
                      nameUpd.getText().toString(),
                      addressETUpd.getText().toString())
                  .execute();
              // getActivity().finish();
              // Intent intent = new Intent(getActivity(), getActivity()
              // .getClass());
              // intent.putExtra("fragNum", "0");
              // getActivity().startActivity(intent);
            } else {
              Toast.makeText(getActivity(), "Check your internet connection", Toast.LENGTH_LONG)
                  .show();
            }
            dialog.dismiss();
          }
        });

    if (setting.getDuration() == 1) {
      dialog.setTitle(getResources().getString(R.string.update_profile_ar));
      updateProfileTV.setText(getResources().getString(R.string.update_profile_ar));
      save.setText(getResources().getString(R.string.save_ar));
    } else {
      dialog.setTitle(getResources().getString(R.string.update_profile_en));
      updateProfileTV.setText(getResources().getString(R.string.update_profile_en));
    }

    dialog.show();
  }
Beispiel #2
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    databaseHandler = new DataBaseHandler(getActivity());
    setting = databaseHandler.getSetting();
    carFunctions = new CarFunctions(getActivity());

    View view = inflater.inflate(R.layout.settings, container, false);
    settingsTV = (TextView) view.findViewById(R.id.settingsTV);
    logOut = (Button) view.findViewById(R.id.logOut);
    updateUserInfo = (Button) view.findViewById(R.id.updateInfo);

    if (setting.getDuration() == 1) {
      settingsTV.setText(getResources().getString(R.string.settings_ar));
      updateUserInfo.setText(getResources().getString(R.string.update_user_info_ar));
      logOut.setText(getResources().getString(R.string.log_out_ar));
    } else {
      settingsTV.setText(getResources().getString(R.string.settings_en));
      updateUserInfo.setText(getResources().getString(R.string.update_user_info_en));
      logOut.setText(getResources().getString(R.string.log_out_en));
    }

    logOut.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            showAlertDialog();
          }
        });
    updateUserInfo.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            showUpdateDialog();
          }
        });
    return view;
  }