private void fillData() {
   newName.setText(intent.getStringExtra(NutrientsDBAdapter.KEY_NAME));
   newProteins.setText(String.valueOf(intent.getFloatExtra(NutrientsDBAdapter.KEY_PROTEINS, 0)));
   newFats.setText(String.valueOf(intent.getFloatExtra(NutrientsDBAdapter.KEY_FATS, 0)));
   newCarbs.setText(String.valueOf(intent.getFloatExtra(NutrientsDBAdapter.KEY_CARBOHYDRATES, 0)));
   newCalories.setText(String.valueOf(intent.getFloatExtra(NutrientsDBAdapter.KEY_CALORIES, 0)));
 }
  public void addRow(View view) {

    EditText editText = (EditText) _popPopupWindow.getContentView().findViewById(R.id.skillInput);

    if (!_newsTopics.contains(editText.getText().toString())) {
      LinearLayout linear = (LinearLayout) findViewById(R.id.LinearLayout1);

      LayoutInflater inflater =
          (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      View rowView = (View) inflater.inflate(R.layout.row, null, false);

      TextView skillName = (TextView) rowView.findViewById(R.id.skillName);
      skillName.setText(editText.getText().toString());
      final Context mainActivity = this;

      rowView.setOnClickListener(
          new OnClickListener() {

            @Override
            public void onClick(View v) {
              Intent intent = new Intent(mainActivity, NewsActivity.class);

              TextView skillName = (TextView) v.findViewById(R.id.skillName);
              intent.putExtra(SKILL_NAME, skillName.getText().toString());
              startActivity(intent);
            }
          });

      linear.addView(rowView);
      linear.addView(getHorSep());
    }

    _popPopupWindow.dismiss();
    _popPopupWindow = null;
  }
  public void attemptLogin() {
    String loginName = mNameView.getText().toString();
    String mPassword = mPasswordView.getText().toString();
    boolean cancel = false;
    View focusView = null;

    if (TextUtils.isEmpty(mPassword)) {
      Toast.makeText(this, getString(R.string.error_pwd_required), Toast.LENGTH_SHORT).show();
      focusView = mPasswordView;
      cancel = true;
    }

    if (TextUtils.isEmpty(loginName)) {
      Toast.makeText(this, getString(R.string.error_name_required), Toast.LENGTH_SHORT).show();
      focusView = mNameView;
      cancel = true;
    }

    if (cancel) {
      focusView.requestFocus();
    } else {
      showProgress(true);
      if (imService != null) {
        //				boolean userNameChanged = true;
        //				boolean pwdChanged = true;
        loginName = loginName.trim();
        mPassword = mPassword.trim();
        imService.getLoginManager().login(loginName, mPassword);
      }
    }
  }
 private void saveItem() {
   mItem.setTitle(mTitle.getText().toString());
   mItem.setDetails(mDetails.getText().toString());
   // date is already set
   mItem.setAutodelete(mAutoDelete.isChecked());
   ItemManager.get(getActivity()).saveItem(mItem);
 }
 private void setViewsAsNotAuthenticated() {
   this.findViewById(R.id.login_state_message).setVisibility(View.GONE);
   this.findViewById(R.id.sign_in_button).setVisibility(View.VISIBLE);
   this.findViewById(R.id.profileImageAdd).setVisibility(View.GONE);
   mEmailView.setEnabled(true);
   mPasswordView.setVisibility(View.VISIBLE);
 }
Exemple #6
0
  /**
   * Adding new task
   *
   * @param view
   */
  @SuppressLint("SimpleDateFormat")
  public void onClick(View view) {

    switch (view.getId()) {
      case R.id.button_add:
        Task task = new Task();
        EditText text = (EditText) findViewById(R.id.edit_text_task);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss");
        task.setText(text.getText().toString());
        task.setCreatedDate(sdf.format(new Date()));
        task.setUpdatedDate(sdf.format(new Date()));
        task.setArchived(false);
        task.setChecked(false);
        System.out.println(user.getName());
        task.setUsername(user.getName());

        long id = table.tasks.create(task);
        task.setId(id);

        this.tasks.add(task);
        text.setText("");
        text.clearFocus();
        InputMethodManager inputManager =
            (InputMethodManager) this.getSystemService(Context.INPUT_METHOD_SERVICE);
        inputManager.hideSoftInputFromWindow(
            this.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);

        break;
    }
  }
  private View createAlarmTitleStep() {
    // This step view is generated programmatically
    titleEditText = new EditText(this);
    titleEditText.setHint("Alarm title (mandatory)");
    titleEditText.setSingleLine(true);
    titleEditText.addTextChangedListener(
        new TextWatcher() {
          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {
            checkTitleStep(s.toString());
          }

          @Override
          public void afterTextChanged(Editable s) {}
        });
    titleEditText.setOnEditorActionListener(
        new TextView.OnEditorActionListener() {
          @Override
          public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (checkTitleStep(v.getText().toString())) {
              verticalStepperForm.goToNextStep();
            }
            return false;
          }
        });
    return titleEditText;
  }
 private void insertEmote(String emote) {
   selectionStart = mMessage.getSelectionStart();
   mMessage.getEditableText().insert(selectionStart, emote);
   mMessage.setSelection(selectionStart + emote.length());
   selectionStart = -1; // reset them for next time
   selectionEnd = -1;
 }
Exemple #9
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    overridePendingTransition(R.anim.pull_in_from_left, R.anim.pull_out_to_left);
    setContentView(R.layout.pass);

    close = (Button) findViewById(R.id.pass_cl);
    login = (Button) findViewById(R.id.pass_yes);
    forget = (Button) findViewById(R.id.pass_no);
    uName = (EditText) findViewById(R.id.pass_username);
    pass = (EditText) findViewById(R.id.pass_pwd);
    tView = (TextView) findViewById(R.id.pass_title);

    close.setOnClickListener(this);
    login.setOnClickListener(this);
    forget.setOnClickListener(this);

    db.open();
    Cursor mCursor = db.getAllRecords();
    mCursor.moveToFirst();
    rName = mCursor.getString(1);
    if (mCursor.getCount() > 0) {
      uName.setClickable(false);
      uName.setBackgroundResource(R.drawable.keypad1);
    }
    db.close();
    tView.setText(rName + " @ MoneyMan");
    uName.setText(rName);
  } // end onCreate()
  private void getAccountInfo() {
    if (api.isAuthenticated()) {
      // If we're already authenticated, we don't need to get the login info

      dialog.show();
      LoginAsyncTask login = new LoginAsyncTask(this, null, null, getConfig(), dialog);
      login.execute();
    } else {

      String email = mLoginEmail.getText().toString();

      if (email.length() < 5 || email.indexOf("@") < 0 || email.indexOf(".") < 0) {
        showToast("Error, invalid e-mail");
        return;
      }

      String password = mLoginPassword.getText().toString();

      if (password.length() < 6) {
        showToast("Error, password too short");
        return;
      }

      // It's good to do Dropbox API (and any web API) calls in a separate thread,
      // so we don't get a force-close due to the UI thread stalling.

      dialog.show();
      LoginAsyncTask login = new LoginAsyncTask(this, email, password, getConfig(), dialog);
      login.execute();
    }
  }
  @SuppressLint("InflateParams")
  private void quickEdit(
      final String previousValue, final OnValueEdited callback, boolean password) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    View view = getLayoutInflater().inflate(R.layout.quickedit, null);
    final EditText editor = (EditText) view.findViewById(R.id.editor);
    OnClickListener mClickListener =
        new OnClickListener() {

          @Override
          public void onClick(DialogInterface dialog, int which) {
            String value = editor.getText().toString();
            if (!previousValue.equals(value) && value.trim().length() > 0) {
              callback.onValueEdited(value);
            }
          }
        };
    if (password) {
      editor.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
      editor.setHint(R.string.password);
      builder.setPositiveButton(R.string.accept, mClickListener);
    } else {
      builder.setPositiveButton(R.string.edit, mClickListener);
    }
    editor.requestFocus();
    editor.setText(previousValue);
    builder.setView(view);
    builder.setNegativeButton(R.string.cancel, null);
    builder.create().show();
  }
 private void init() {
   it = getIntent();
   order_id = it.getStringExtra("order_id");
   rec_id = it.getStringExtra("rec_id");
   goods_num = it.getStringExtra("goods_num");
   goods_pay_price = it.getStringExtra("goods_pay_price");
   goods_price = it.getStringExtra("goods_price");
   goods_name = it.getStringExtra("goods_name");
   tv_goods_pay_price = (TextView) findViewById(R.id.tv_goods_pay_price);
   tv_goods_pay_price.setText(goods_pay_price);
   tv_pay_price = (TextView) findViewById(R.id.tv_pay_price);
   tv_pay_price.setText(goods_pay_price);
   tv_goods_name = (TextView) findViewById(R.id.tv_goods_name);
   tv_goods_name.setText(goods_name);
   tv_goods_price = (TextView) findViewById(R.id.tv_goods_price);
   tv_goods_price.setText(goods_price);
   tv_goods_num = (TextView) findViewById(R.id.tv_goods_num);
   tv_goods_num.setText(goods_num);
   btn_sub = (Button) findViewById(R.id.btn_sub);
   btn_sub.setOnClickListener(this);
   check_1 = (CheckBox) findViewById(R.id.check_1);
   check_2 = (CheckBox) findViewById(R.id.check_2);
   ll_check_1 = (LinearLayout) findViewById(R.id.ll_check_1);
   ll_check_2 = (LinearLayout) findViewById(R.id.ll_check_2);
   ll_check_1.setOnClickListener(this);
   ll_check_2.setOnClickListener(this);
   et_pay_price = (EditText) findViewById(R.id.et_pay_price);
   et_pay_price.setText(goods_pay_price);
   et_goos_nnum = (EditText) findViewById(R.id.et_goos_nnum);
   et_goos_nnum.setText(goods_num);
   et_extend_msg = (EditText) findViewById(R.id.et_extend_msg);
 }
Exemple #13
0
  public void onClick(View v) {
    int id = v.getId();
    DBStorage dbStorage;
    switch (id) {
      case R.id.dialog_delete:
        dbStorage = new DBStorage(context);
        dbStorage.deleteChannel(channel.id);
        dbStorage.destroy();
        listener.onDialogDismissed();
        break;
      case R.id.dialog_change:
        dbStorage = new DBStorage(context);
        channel.name = etName.getText().toString();
        channel.link = etLink.getText().toString();
        channel.encoding = etEncoding.getText().toString();
        dbStorage.changeChannel(channel);
        dbStorage.destroy();
        listener.onDialogDismissed();
        break;

      case R.id.dialog_cancel:
        break;
    }
    dismiss();
  }
 @Override
 public void onClick(View v) {
   switch (v.getId()) {
     case R.id.btn_sub:
       String extend_msg = et_extend_msg.getText().toString();
       String refund_amount = et_pay_price.getText().toString();
       if (Double.valueOf(refund_amount) > Double.valueOf(goods_pay_price)) {
         Toast.makeText(E3_Activity_Returns.this, "金额输入错误", Toast.LENGTH_LONG).show();
       } else {
         loadingPDialog.show();
         HttpUtils.refund(
             res, order_id, rec_id, refund_type, refund_amount, goods_num, extend_msg);
       }
       break;
     case R.id.ll_check_1:
       check_1.setChecked(true);
       check_2.setChecked(false);
       refund_type = "1";
       break;
     case R.id.ll_check_2:
       check_2.setChecked(true);
       check_1.setChecked(false);
       refund_type = "2";
       break;
     case R.id.iv_back:
       this.finish();
       break;
     default:
       break;
   }
 }
  public void showEditDialog(
      Context context, String hintText, String OKText, final DialogCallBack callBack) {
    final EditText et_search;
    AlertDialog.Builder dialog = new AlertDialog.Builder(context);
    LayoutInflater inflater =
        (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.dialog_view, null);
    dialog.setView(layout);
    et_search = (EditText) layout.findViewById(R.id.searchC);
    et_search.setHint(hintText);
    dialog.setPositiveButton(
        OKText,
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
            String s = et_search.getText().toString().trim();
            callBack.exectEditEvent(s);
          }
        });

    dialog.setNegativeButton(
        R.string.cancel,
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {}
        });
    dialog.show();
  }
  @Override
  public void onSaveInstanceState(Bundle savedInstanceState) {

    // Saving title field
    if (titleEditText != null) {
      savedInstanceState.putString(STATE_TITLE, titleEditText.getText().toString());
    }

    // Saving description field
    if (descriptionEditText != null) {
      savedInstanceState.putString(STATE_DESCRIPTION, descriptionEditText.getText().toString());
    }

    // Saving time field
    if (time != null) {
      savedInstanceState.putInt(STATE_TIME_HOUR, time.first);
      savedInstanceState.putInt(STATE_TIME_MINUTES, time.second);
    }

    // Saving week days field
    if (weekDays != null) {
      savedInstanceState.putBooleanArray(STATE_WEEK_DAYS, weekDays);
    }

    // The call to super method must be at the end here
    super.onSaveInstanceState(savedInstanceState);
  }
  public void apply(View v) {
    // read raw values from the input widgets
    master_switch = switch_master_switch.isChecked();
    left_margin = Integer.parseInt(ET_left_margin.getText().toString());
    right_margin = Integer.parseInt(ET_right_margin.getText().toString());
    top_margin = Integer.parseInt(ET_top_margin.getText().toString());
    bottom_margin = Integer.parseInt(ET_bottom_margin.getText().toString());

    // save the values
    Editor editor = pref.edit();
    editor.putBoolean(Keys.MASTER_SWITCH, master_switch);
    editor.putInt(Keys.LEFT_MARGIN, left_margin);
    editor.putInt(Keys.RIGHT_MARGIN, right_margin);
    editor.putInt(Keys.TOP_MARGIN, top_margin);
    editor.putInt(Keys.BOTTOM_MARGIN, bottom_margin);
    editor.apply();

    int viewH = (screen_height - top_margin - bottom_margin);
    Log.d("VIEW H", Integer.toString(viewH));

    int viewW = screen_width - left_margin - right_margin;
    Log.d("VIEW W", Integer.toString(viewW));

    Toast.makeText(this, "Changes applied!", Toast.LENGTH_SHORT).show();
    if (viewW < screen_width * 0.5 || viewH < screen_height * 0.5)
      Toast.makeText(this, "Warning, the view area may be too small!", Toast.LENGTH_LONG).show();
    if (left_margin > screen_width
        || top_margin > screen_height
        || right_margin < 0
        || bottom_margin < 0)
      Toast.makeText(this, "Your view area goes off the screen!", Toast.LENGTH_LONG).show();

    finish();
  }
Exemple #18
0
  /**
   * Configure search field
   *
   * @param search
   * @param beerListItemAdapter
   * @param searchBtn
   */
  private void setUpSearchView(
      final EditText search,
      final BeerListItemAdapter beerListItemAdapter,
      final ImageView searchBtn) {
    search.addTextChangedListener(beerListItemAdapter);
    searchBtn.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            if (search.getText().length() > 0) {
              search.setText("");
            } else {
              search.requestFocus();
            }
          }
        });
    search.addTextChangedListener(
        new TextWatcher() {

          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {
            if (s.length() > 0) {
              searchBtn.setImageResource(R.drawable.ic_clear_white_24dp);
            } else {
              searchBtn.setImageResource(R.drawable.ic_search_white_24dp);
            }
          }

          @Override
          public void afterTextChanged(Editable s) {}
        });
  }
  @Override
  public void onClick(View v) {
    switch (v.getId()) {
      case R.id.reset_btn:
        if (reset_password1.getText().toString().trim().length() < 8) {
          Toast.makeText(this, "密码须大于8位", Toast.LENGTH_SHORT).show();
        } else if (!reset_password1
            .getText()
            .toString()
            .equals(reset_password2.getText().toString())) {
          Toast.makeText(this, "输入的两次密码不相等", Toast.LENGTH_SHORT).show();
        } else {
          HttpUtils.resetPassword(
              res,
              phone.replaceAll(" ", ""),
              reset_password2.getText().toString().replaceAll(" ", ""));
        }
        break;
      case R.id.register_back:
        super.finish();
        overridePendingTransition(R.anim.push_left_in, R.anim.push_left_out);
        break;
      case R.id.policy:
        Intent intent = new Intent(E8_ResetPwdActivity.this, E13_User_policy_Activity.class);
        startActivity(intent);
        this.overridePendingTransition(R.anim.push_right_in, R.anim.push_right_out);
        break;

      default:
        break;
    }
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);
    btnLogin = (Button) findViewById(R.id.btnLogin);
    txtUsername = (EditText) findViewById(R.id.txtUsername);

    intentFilter.addAction(WifiP2pManager.WIFI_P2P_STATE_CHANGED_ACTION);
    intentFilter.addAction(WifiP2pManager.WIFI_P2P_PEERS_CHANGED_ACTION);
    intentFilter.addAction(WifiP2pManager.WIFI_P2P_CONNECTION_CHANGED_ACTION);
    intentFilter.addAction(WifiP2pManager.WIFI_P2P_THIS_DEVICE_CHANGED_ACTION);

    manager = (WifiP2pManager) getSystemService(Context.WIFI_P2P_SERVICE);
    channel = manager.initialize(this, getMainLooper(), null);

    txtUsername.setOnEditorActionListener(
        new TextView.OnEditorActionListener() {
          @Override
          public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            login();
            return true;
          }
        });

    // Restore preferences
    SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
    String username = settings.getString("username", "");
    txtUsername.setText(username);
    btnLogin.setOnClickListener(this);
  }
  private void updateTextDataUI() {

    if (!mIsTimestampDisplayMode) {
      if (mDataBufferLastSize != mDataBuffer.size()) {

        final int bufferSize = mDataBuffer.size();
        if (bufferSize > maxPacketsToPaintAsText) {
          mDataBufferLastSize = bufferSize - maxPacketsToPaintAsText;
          mTextSpanBuffer.clear();
          addTextToSpanBuffer(
              mTextSpanBuffer, getString(R.string.uart_text_dataomitted) + "\n", mInfoColor);
        }

        // Log.d(TAG, "update packets: "+(bufferSize-mDataBufferLastSize));
        for (int i = mDataBufferLastSize; i < bufferSize; i++) {
          final UartDataChunk dataChunk = mDataBuffer.get(i);
          final boolean isRX = dataChunk.getMode() == UartDataChunk.TRANSFERMODE_RX;
          final String data = dataChunk.getData();
          final String formattedData = mShowDataInHexFormat ? asciiToHex(data) : data;
          addTextToSpanBuffer(mTextSpanBuffer, formattedData, isRX ? mRxColor : mTxColor);
        }

        mDataBufferLastSize = mDataBuffer.size();
        mBufferTextView.setText(mTextSpanBuffer);
        mBufferTextView.setSelection(
            0, mTextSpanBuffer.length()); // to automatically scroll to the end
      }
    }
  }
  @Override
  public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
      Log.i(AnkiDroidApp.TAG, "CardBrowser - onBackPressed()");
      if (mSearchEditText.getText().length() == 0
          && !mShowOnlyMarSus
          && mSelectedTags.size() == 0) {
        setResult(RESULT_OK);
        finish();
        if (Integer.valueOf(android.os.Build.VERSION.SDK) > 4) {
          ActivityTransitionAnimation.slide(CardBrowser.this, ActivityTransitionAnimation.RIGHT);
        }
      } else {
        mSearchEditText.setText("");
        mSearchEditText.setHint(R.string.downloaddeck_search);
        mSelectedTags.clear();
        mCards.clear();
        mCards.addAll(mAllCards);
        updateList();
      }
      return true;
    }

    return super.onKeyDown(keyCode, event);
  }
  /**
   * Inicializa las vistas de este Fragment
   *
   * @param layout el layout de este Fragment que contiene las vistas
   */
  private void initViews(View layout) {
    createButton = (Button) layout.findViewById(R.id.create_tokenly_fan_identity);
    mFanExternalUserName = (EditText) layout.findViewById(R.id.external_username);
    mFanExternalPassword = (EditText) layout.findViewById(R.id.tokenly_access_password);
    fanImage = (ImageView) layout.findViewById(R.id.tokenly_fan_image);
    mFanExternalPlatform = (Spinner) layout.findViewById(R.id.external_platform);
    relativeLayout = (RelativeLayout) layout.findViewById(R.id.user_image);
    createButton.setText((!isUpdate) ? "Create" : "Update");
    mFanExternalUserName.requestFocus();
    List<String> arraySpinner = ExternalPlatform.getArrayItems();
    ArrayAdapter<String> adapter =
        new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item, arraySpinner);
    mFanExternalPlatform.setAdapter(adapter);
    mFanExternalUserName.requestFocus();
    registerForContextMenu(fanImage);
    fanImage.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            CommonLogger.debug(TAG, "Entrando en fanImage.setOnClickListener");
            getActivity().openContextMenu(fanImage);
          }
        });

    createButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            CommonLogger.debug(TAG, "Entrando en createButton.setOnClickListener");

            int resultKey = createNewIdentity();
            switch (resultKey) {
              case CREATE_IDENTITY_SUCCESS:
                //
                // changeActivity(Activities.CCP_SUB_APP_INTRA_USER_IDENTITY.getCode(),
                // appSession.getAppPublicKey());
                if (!isUpdate) {
                  Toast.makeText(getActivity(), "Identity created", Toast.LENGTH_SHORT).show();
                } else {
                  Toast.makeText(getActivity(), "Changes saved", Toast.LENGTH_SHORT).show();
                }
                break;
              case CREATE_IDENTITY_FAIL_MODULE_EXCEPTION:
                Toast.makeText(getActivity(), "Error al crear la identidad", Toast.LENGTH_LONG)
                    .show();
                break;
              case CREATE_IDENTITY_FAIL_NO_VALID_DATA:
                Toast.makeText(getActivity(), "La data no es valida", Toast.LENGTH_LONG).show();
                break;
              case CREATE_IDENTITY_FAIL_MODULE_IS_NULL:
                Toast.makeText(
                        getActivity(),
                        "No se pudo acceder al module manager, es null",
                        Toast.LENGTH_LONG)
                    .show();
                break;
            }
          }
        });
  }
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
      return true;
    }

    if (id == R.id.confirm_create_group) {
      if (groupNameText.getText().toString().length() > 0
          && cityText.getText().toString().length() > 0) {
        nome = groupNameText.getText().toString();
        city = cityText.getText().toString();
        int selectedId = groupType.getCheckedRadioButtonId();
        if (selectedId == R.id.group_closed_radio) aperto = false;

        InfoGruppoBean gruppoBean = new InfoGruppoBean();
        gruppoBean.setNome(nome);
        gruppoBean.setCitta(city);
        gruppoBean.setAperto(aperto);
        if (checkNetwork())
          new CreaGruppoAT(getApplicationContext(), this, this, idSessione, gruppoBean).execute();

      } else {
        Toast.makeText(getApplicationContext(), "Compilare tutti i campi!", Toast.LENGTH_LONG)
            .show();
      }
    }

    return super.onOptionsItemSelected(item);
  }
  public void register(View view) {
    EditText nameText = (EditText) findViewById(R.id.name);
    name = nameText.getText().toString().toLowerCase();
    EditText passText = (EditText) findViewById(R.id.pass);
    password = passText.getText().toString().toLowerCase();

    usersFirebase.addValueEventListener(
        new ValueEventListener() {

          @Override
          public void onDataChange(DataSnapshot snapshot) {
            userExists = false;
            for (DataSnapshot postSnapshot : snapshot.getChildren()) {
              User user = postSnapshot.getValue(User.class);
              if (user.getName().equals(name)) {
                userExists = true;
                break;
              }
            }
            // remove eventlistener to ignore redundant callbacks
            usersFirebase.removeEventListener(this);
            if (userExists) {
              Log.i("PvCProject", "User Exists");
            } else {
              User user = new User(name, password, null, null);
              usersFirebase.push().setValue(user);
              Log.i("PvCProject", "User Created");
            }
          }

          @Override
          public void onCancelled(FirebaseError firebaseError) {}
        });
  }
Exemple #26
0
 public static void showInputDialog(
     Activity context, int title, int hint, String prefillInput, final InputCallback callback) {
   @SuppressLint("InflateParams")
   final View view = context.getLayoutInflater().inflate(R.layout.dialog_input, null);
   MaterialDialog.Builder dialog =
       new MaterialDialog.Builder(context)
           .title(title)
           .positiveText(android.R.string.ok)
           .negativeText(android.R.string.cancel)
           .callback(
               new MaterialDialog.ButtonCallback() {
                 @Override
                 public void onPositive(MaterialDialog dialog) {
                   if (callback != null) {
                     EditText input = (EditText) view.findViewById(R.id.input);
                     callback.onInput(input.getText().toString().trim());
                   }
                 }
               })
           .customView(view, true);
   final EditText input = (EditText) view.findViewById(R.id.input);
   if (hint != 0) input.setHint(hint);
   if (prefillInput != null) input.append(prefillInput);
   MaterialDialog alert = dialog.build();
   alert.setOnDismissListener(
       new DialogInterface.OnDismissListener() {
         @Override
         public void onDismiss(DialogInterface dialog) {
           if (callback instanceof InputCancelCallback)
             ((InputCancelCallback) callback).onCancel();
         }
       });
   alert.show();
 }
 public GoToPageDialog(
     final Context context, final DocumentView documentView, final DecodeService decodeService) {
   super(context);
   this.documentView = documentView;
   this.decodeService = decodeService;
   setTitle("Go to page");
   setContentView(R.layout.gotopage);
   final Button button = (Button) findViewById(R.id.goToButton);
   button.setOnClickListener(
       new View.OnClickListener() {
         public void onClick(View view) {
           goToPageAndDismiss();
         }
       });
   final EditText editText = (EditText) findViewById(R.id.pageNumberTextEdit);
   editText.setOnEditorActionListener(
       new TextView.OnEditorActionListener() {
         public boolean onEditorAction(TextView textView, int actionId, KeyEvent keyEvent) {
           if (actionId == EditorInfo.IME_NULL || actionId == EditorInfo.IME_ACTION_DONE) {
             goToPageAndDismiss();
             return true;
           }
           return false;
         }
       });
 }
  @Override
  public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
      Log.i(AnkiDroidApp.TAG, "CardBrowser - onBackPressed()");
      if (mSearchEditText.getText().length() == 0
          && !mShowOnlyMarSus
          && mSelectedTags.size() == 0) {
        // if (mPrefCacheCardBrowser) {
        // sCachedDeckPath = mDeck.getDeckPath();
        // sAllCardsCache = new ArrayList<HashMap<String, String>>();
        // sAllCardsCache.addAll(mAllCards);
        // }
        closeCardBrowser();
      } else {
        mSearchEditText.setText("");
        mSearchEditText.setHint(R.string.downloaddeck_search);
        mSelectedTags.clear();
        mCards.clear();
        mCards.addAll(mAllCards);
        updateList();
      }
      return true;
    }

    return super.onKeyDown(keyCode, event);
  }
  private void processLogin() {

    final ProgressDialog pd =
        ProgressDialog.show(LoginScreen.this, "Please wait", "Fetching user data", false);
    String push =
        String.format("%s/%s", edName.getText().toString(), edPassword.getText().toString());
    new CallWebService(Constants.API_LOGIN + push, CallWebService.TYPE_JSONOBJECT) {
      @Override
      public void response(String response) {

        pd.dismiss();
        Functions.logD("Response Login", response);
        User currentUser = new GsonBuilder().create().fromJson(response, User.class);

        if (currentUser.loginState.success.equalsIgnoreCase("1")) {

          Functions.displayMessage(LoginScreen.this, "Login Successfull");
          PrefUtils.setUser(LoginScreen.this, currentUser);
          Functions.fireIntent(LoginScreen.this, AddArtWorkScreen.class);
          PrefUtils.setLogin(LoginScreen.this, true);
          finish();

        } else {
          Functions.displayMessage(LoginScreen.this, "Login Failed");
        }
      }

      @Override
      public void error(VolleyError error) {
        pd.dismiss();
        Functions.displayMessage(LoginScreen.this, error.getMessage());
      }
    }.start();
  }
 private boolean isMatching(EditText etText1, EditText etText2) {
   if (etText1.getText().toString().equals(etText2.getText().toString())) {
     return true;
   } else {
     return false;
   }
 }