Java Code Examples for com.gianlu.commonutils.CommonUtils#setText()

The following examples show how to use com.gianlu.commonutils.CommonUtils#setText() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AuthenticationFragment.java    From Aria2App with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onRestoreInstanceState(@NonNull Bundle bundle) {
    authMethod.check(bundle.getInt("authMethod", R.id.editProfile_authMethod_none));
    CommonUtils.setText(token, bundle.getString("token"));
    CommonUtils.setText(username, bundle.getString("username"));
    CommonUtils.setText(password, bundle.getString("password"));
}
 
Example 2
Source File: DirectDownloadFragment.java    From Aria2App with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onRestoreInstanceState(@NonNull Bundle bundle) {
    enableDirectDownload.setChecked(bundle.getBoolean("enabled", false));

    CommonUtils.setText(address, bundle.getString("address"));
    auth.setChecked(bundle.getBoolean("auth", false));
    CommonUtils.setText(username, bundle.getString("username"));
    CommonUtils.setText(password, bundle.getString("password"));

    encryption.setChecked(bundle.getBoolean("encryption", false));
    certificate.restore(bundle.getBundle("certificate"), encryption.isChecked());
}
 
Example 3
Source File: ConnectionFragment.java    From Aria2App with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onRestoreInstanceState(@NonNull Bundle bundle) {
    connectionMethod.check(bundle.getInt("connectionMethod", R.id.editProfile_connectionMethod_http));

    CommonUtils.setText(address, bundle.getString("address"));
    CommonUtils.setText(port, bundle.getString("port"));
    CommonUtils.setText(endpoint, bundle.getString("endpoint", "/jsonrpc"));
    encryption.setChecked(bundle.getBoolean("encryption", false));
    certificate.restore(bundle.getBundle("certificate"), encryption.isChecked());
}
 
Example 4
Source File: LoadingActivity.java    From PretendYoureXyzzyAndroid with GNU General Public License v3.0 4 votes vote down vote up
private void showRegisterUI(final FirstLoadedPyx pyx) {
    loading.setVisibility(View.GONE);
    register.setVisibility(View.VISIBLE);
    registerNickname.setErrorEnabled(false);
    registerIdCode.setErrorEnabled(false);

    String lastNickname = Prefs.getString(PK.LAST_NICKNAME, null);
    if (lastNickname != null) CommonUtils.setText(registerNickname, lastNickname);

    String lastIdCode = Prefs.getString(PK.LAST_ID_CODE, null);
    if (lastIdCode != null) CommonUtils.setText(registerIdCode, lastIdCode);

    if (!pyx.isServerSecure() && !pyx.config().insecureIdAllowed())
        registerIdCode.setEnabled(false);
    else
        registerIdCode.setEnabled(true);

    registerSubmit.setOnClickListener(v -> {
        loading.setVisibility(View.VISIBLE);
        register.setVisibility(View.GONE);

        String idCode = getIdCode();
        String nick = CommonUtils.getText(registerNickname);
        pyx.register(nick, idCode, this, new Pyx.OnResult<RegisteredPyx>() {
            @Override
            public void onDone(@NonNull RegisteredPyx result) {
                Prefs.putString(PK.LAST_NICKNAME, result.user().nickname);
                Prefs.putString(PK.LAST_ID_CODE, idCode);
                goToMain();
            }

            @Override
            public void onException(@NonNull Exception ex) {
                Log.e(TAG, "Failed registering on server.", ex);

                loading.setVisibility(View.GONE);
                register.setVisibility(View.VISIBLE);

                if (ex instanceof PyxException) {
                    switch (((PyxException) ex).errorCode) {
                        case "rn":
                            registerNickname.setError(getString(R.string.reservedNickname));
                            return;
                        case "in":
                            registerNickname.setError(getString(R.string.invalidNickname));
                            return;
                        case "niu":
                            registerNickname.setError(getString(R.string.alreadyUsedNickname));
                            return;
                        case "tmu":
                            registerNickname.setError(getString(R.string.tooManyUsers));
                            return;
                        case "iid":
                            registerIdCode.setError(getString(R.string.invalidIdCode));
                            return;
                    }
                }

                Log.e(TAG, "Failed registering user on server.", ex);
                Toaster.with(LoadingActivity.this).message(R.string.failedLoading).show();
            }
        });
    });
}
 
Example 5
Source File: EditGameOptionsDialog.java    From PretendYoureXyzzyAndroid with GNU General Public License v3.0 4 votes vote down vote up
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    layout = (LinearLayout) inflater.inflate(R.layout.dialog_edit_game_options, container, false);

    Bundle args = getArguments();
    Game.Options options;
    if (args == null || (options = (Game.Options) args.getSerializable("options")) == null
            || (gid = args.getInt("gid", -1)) == -1 || getContext() == null) {
        dismissAllowingStateLoss();
        return layout;
    }


    try {
        pyx = RegisteredPyx.get();
    } catch (LevelMismatchException ex) {
        DialogUtils.showToast(getContext(), Toaster.build().message(R.string.failedLoading));
        dismissAllowingStateLoss();
        return layout;
    }

    scoreLimit = layout.findViewById(R.id.editGameOptions_scoreLimit);
    CommonUtils.setText(scoreLimit, String.valueOf(options.scoreLimit));

    playerLimit = layout.findViewById(R.id.editGameOptions_playerLimit);
    CommonUtils.setText(playerLimit, String.valueOf(options.playersLimit));

    spectatorLimit = layout.findViewById(R.id.editGameOptions_spectatorLimit);
    CommonUtils.setText(spectatorLimit, String.valueOf(options.spectatorsLimit));

    timerMultiplier = layout.findViewById(R.id.editGameOptions_timerMultiplier);
    AutoCompleteTextView timerMultiplierEditText = (AutoCompleteTextView) CommonUtils.getEditText(timerMultiplier);
    timerMultiplierEditText.setAdapter(new ArrayAdapter<>(getContext(), android.R.layout.simple_spinner_dropdown_item, Game.Options.VALID_TIMER_MULTIPLIERS));
    timerMultiplierEditText.setText(options.timerMultiplier, false);
    timerMultiplierEditText.setValidator(new AutoCompleteTextView.Validator() {
        @Override
        public boolean isValid(CharSequence text) {
            return Game.Options.timerMultiplierIndex(String.valueOf(text)) != -1;
        }

        @Override
        public CharSequence fixText(CharSequence invalidText) {
            return null;
        }
    });

    blankCards = layout.findViewById(R.id.editGameOptions_blankCards);
    CommonUtils.setText(blankCards, String.valueOf(options.blanksLimit));
    if (pyx.config().blankCardsEnabled()) blankCards.setVisibility(View.VISIBLE);
    else blankCards.setVisibility(View.GONE);

    password = layout.findViewById(R.id.editGameOptions_password);
    CommonUtils.setText(password, options.password);

    decksTitle = layout.findViewById(R.id.editGameOptions_decksTitle);

    decks = layout.findViewById(R.id.editGameOptions_decks);
    decks.removeAllViews();
    for (Deck set : pyx.firstLoad().decks) {
        MaterialCheckBox item = new MaterialCheckBox(getContext());
        item.setTag(set);
        item.setText(set.name);
        item.setChecked(options.cardSets.contains(set.id));
        item.setOnCheckedChangeListener((buttonView, isChecked) -> updateDecksCount());

        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        lp.topMargin = lp.bottomMargin = (int) -TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics());
        decks.addView(item, lp);
    }

    updateDecksCount();

    Button cancel = layout.findViewById(R.id.editGameOptions_cancel);
    cancel.setOnClickListener(v -> dismissAllowingStateLoss());

    Button apply = layout.findViewById(R.id.editGameOptions_apply);
    apply.setOnClickListener(v -> done());

    return layout;
}