Example usage for android.text Spanned SPAN_EXCLUSIVE_EXCLUSIVE

List of usage examples for android.text Spanned SPAN_EXCLUSIVE_EXCLUSIVE

Introduction

In this page you can find the example usage for android.text Spanned SPAN_EXCLUSIVE_EXCLUSIVE.

Prototype

int SPAN_EXCLUSIVE_EXCLUSIVE

To view the source code for android.text Spanned SPAN_EXCLUSIVE_EXCLUSIVE.

Click Source Link

Document

Spans of type SPAN_EXCLUSIVE_EXCLUSIVE do not expand to include text inserted at either their starting or ending point.

Usage

From source file:com.github.guwenk.smuradio.SignInDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    builder = new AlertDialog.Builder(getActivity());
    View signInDialogView = getActivity().getLayoutInflater().inflate(R.layout.dialog_sign_in, null);
    builder.setView(signInDialogView);//from  www. j a  v  a  2 s .com
    builder.setMessage(R.string.upload_your_song);

    checkBox = (CheckBox) signInDialogView.findViewById(R.id.checkBox2);

    int currentOrientation = getResources().getConfiguration().orientation;
    if (currentOrientation == Configuration.ORIENTATION_LANDSCAPE) {
        getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
    } else {
        getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
    }

    check1 = false;
    check2 = false;
    check3 = false;
    // Log.d(AuthTag, "onCreateDialog " + check1 + " " + check2 + " " + check3);

    this.mGoogleApiClient = OrderActivity.getmGoogleApiClient();
    mAuth = FirebaseAuth.getInstance();

    selectFileButton = (Button) signInDialogView.findViewById(R.id.selectFileButton);
    selectFileButton.setOnClickListener(new customButtonClickListener());

    signInButton = (SignInButton) signInDialogView.findViewById(R.id.sign_in_button);
    signInButton.setStyle(SignInButton.SIZE_WIDE, SignInButton.COLOR_AUTO);
    signInButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            signIn();
        }
    });

    builder.setPositiveButton(getString(R.string.next), new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            // TODO upload song
        }
    });

    builder.setNegativeButton(R.string.close, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {

        }
    });

    SpannableString ss = new SpannableString(getString(R.string.you_accepting_license_agreement));
    ClickableSpan clickableSpan = new ClickableSpan() {
        @Override
        public void onClick(View textView) {
            Log.d(AuthTag, "click");
            LicenseDialog licenseDialog = new LicenseDialog();
            licenseDialog.show(getFragmentManager(), "Sing in dialog");
        }

        @Override
        public void updateDrawState(TextPaint ds) {
            super.updateDrawState(ds);
            ds.setUnderlineText(true);
        }
    };
    ss.setSpan(clickableSpan, 14, ss.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    TextView textView = (TextView) signInDialogView.findViewById(R.id.textView);
    textView.setText(ss);
    textView.setMovementMethod(LinkMovementMethod.getInstance());
    textView.setHighlightColor(Color.TRANSPARENT);

    checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            check2 = isChecked;
            Log.d(AuthTag, "Checked: " + isChecked);
            buttonStatus();
        }
    });

    mStorageRef = FirebaseStorage.getInstance().getReference();

    alert = builder.create();
    return alert;
}

From source file:net.idlesoft.android.apps.github.activities.Repository.java

public void loadRepoInfo() {
    try {//from w  w w .j a v  a 2  s  . co m
        // TextView title =
        // (TextView)findViewById(R.id.tv_top_bar_title);
        // title.setText(m_jsonData.getString("name"));
        final TextView repo_name = (TextView) findViewById(R.id.tv_repository_info_name);
        repo_name.setText(mJson.getString("name"));
        repo_name.requestFocus();
        final TextView repo_desc = (TextView) findViewById(R.id.tv_repository_info_description);
        repo_desc.setText(mJson.getString("description"));
        final TextView repo_owner = (TextView) findViewById(R.id.tv_repository_info_owner);
        repo_owner.setText(mJson.getString("owner"));
        final TextView repo_watcher_count = (TextView) findViewById(R.id.tv_repository_info_watchers);
        if (mJson.getInt("watchers") == 1) {
            repo_watcher_count.setText(mJson.getInt("watchers") + " watcher");
        } else {
            repo_watcher_count.setText(mJson.getInt("watchers") + " watchers");
        }
        final TextView repo_fork_count = (TextView) findViewById(R.id.tv_repository_info_forks);
        if (mJson.getInt("forks") == 1) {
            repo_fork_count.setText(mJson.getInt("forks") + " fork");
        } else {
            repo_fork_count.setText(mJson.getInt("forks") + " forks");
        }
        final TextView repo_website = (TextView) findViewById(R.id.tv_repository_info_website);
        if (mJson.getString("homepage") != "") {
            repo_website.setText(mJson.getString("homepage"));
        } else {
            repo_website.setText("N/A");
        }

        /* Make the repository owner text link to his/her profile */
        repo_owner.setMovementMethod(LinkMovementMethod.getInstance());
        final Spannable spans = (Spannable) repo_owner.getText();
        final ClickableSpan clickSpan = new ClickableSpan() {
            @Override
            public void onClick(final View widget) {
                final Intent i = new Intent(Repository.this, Profile.class);
                try {
                    i.putExtra("username", mJson.getString("owner"));
                } catch (final JSONException e) {
                    e.printStackTrace();
                }
                startActivity(i);
            }
        };
        spans.setSpan(clickSpan, 0, spans.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    } catch (final JSONException e) {
        e.printStackTrace();
    }

    ((Button) findViewById(R.id.btn_repository_info_branches)).setOnClickListener(new OnClickListener() {
        public void onClick(final View v) {
            final Intent intent = new Intent(Repository.this, BranchesList.class);
            intent.putExtra("repo_name", mRepositoryName);
            intent.putExtra("repo_owner", mRepositoryOwner);
            startActivity(intent);
        }
    });
    ((Button) findViewById(R.id.btn_repository_info_issues)).setOnClickListener(new OnClickListener() {
        public void onClick(final View v) {
            final Intent intent = new Intent(Repository.this, Issues.class);
            intent.putExtra("repo_name", mRepositoryName);
            intent.putExtra("repo_owner", mRepositoryOwner);
            startActivity(intent);
        }
    });
    ((Button) findViewById(R.id.btn_repository_info_network)).setOnClickListener(new OnClickListener() {
        public void onClick(final View v) {
            final Intent intent = new Intent(Repository.this, NetworkList.class);
            intent.putExtra("repo_name", mRepositoryName);
            intent.putExtra("username", mRepositoryOwner);
            startActivity(intent);
        }
    });
}

From source file:com.github.michalbednarski.intentslab.providerlab.proxy.LogViewerFragment.java

@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
    setListAdapter(new CursorAdapter(getActivity(), data, false) {
        @Override//from ww  w . j a v a2s  .com
        public View newView(Context context, Cursor cursor, ViewGroup parent) {
            return ((LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE))
                    .inflate(android.R.layout.simple_list_item_2, parent, false);
        }

        @Override
        public void bindView(View view, Context context, Cursor cursor) {
            // First row: method and app name
            final String appName = getActivity().getPackageManager().getNameForUid(cursor.getInt(3));
            final String methodName = methodIdToName(cursor.getInt(1));
            ((TextView) view.findViewById(android.R.id.text1)).setText(methodName + "() by " + appName);

            // Second row: uri and exception
            final String uri = cursor.getString(2);
            String exception = cursor.getString(4);
            SpannableStringBuilder text2 = new SpannableStringBuilder(uri);
            if (exception != null) {
                text2.append("\n");
                final int start = text2.length();
                text2.append(exception);
                final int end = text2.length();
                text2.setSpan(new ForegroundColorSpan(Color.RED), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            } else {
                // TODO: result / empty result warning
            }
            ((TextView) view.findViewById(android.R.id.text2)).setText(text2);
        }
    });
}

From source file:com.abcs.haiwaigou.yyg.view.ReadMoreTextView.java

private CharSequence addClickableSpan(SpannableStringBuilder s, CharSequence trimText) {
    s.setSpan(viewMoreSpan, s.length() - trimText.length(), s.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    return s;/*from   w ww  . ja  v  a2 s . c om*/
}

From source file:org.eyeseetea.malariacare.network.CustomParser.java

/** Modified from {@link android.text.Html} */
private static void end(Editable text, Class<?> kind, Object... replaces) {
    int len = text.length();
    Object obj = getLast(text, kind);
    int where = text.getSpanStart(obj);
    text.removeSpan(obj);//w w w  .  java  2  s .c  o  m
    if (where != len) {
        for (Object replace : replaces) {
            text.setSpan(replace, where, len, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        }
    }
    return;
}

From source file:com.softminds.matrixcalculator.base_activities.FillingMatrix.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
    boolean isDark = preferences.getBoolean("DARK_THEME_KEY", false);
    boolean SmartFit = preferences.getBoolean("SMART_FIT_KEY", false);

    if (isDark)/*from  ww w  .j a  v a  2  s. c  o m*/
        setTheme(R.style.AppThemeDark_NoActionBar);
    else
        setTheme(R.style.AppTheme_NoActionBar);
    super.onCreate(savedInstanceState);

    Bundle bundle = getIntent().getExtras();
    if (bundle == null) {
        Log.wtf("FillingMatrix", "How the heck, it got called ??");
        Toast.makeText(getApplication(), R.string.unexpected_error, Toast.LENGTH_SHORT).show();
        finish();
    } else {
        col = bundle.getInt("COL");
        row = bundle.getInt("ROW");
    }
    setContentView(R.layout.filler);
    adCard = findViewById(R.id.AddCardFiller);

    if (!((GlobalValues) getApplication()).DonationKeyFound()) {
        AdView adView = findViewById(R.id.adViewFiller);
        AdRequest adRequest = new AdRequest.Builder().build();
        adView.setAdListener(new AdLoadListener(adCard));
        adView.loadAd(adRequest);
        if (getResources()
                .getConfiguration().orientation == android.content.res.Configuration.ORIENTATION_LANDSCAPE)
            adCard.setVisibility(View.INVISIBLE);
        else
            adCard.setVisibility(View.VISIBLE);
    } else
        ((ViewGroup) adCard.getParent()).removeView(adCard);

    Toolbar toolbar = findViewById(R.id.toolbarFill);
    setSupportActionBar(toolbar);

    CardView cardView = findViewById(R.id.DynamicCard);

    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    String string = sharedPreferences.getString("ELEVATE_AMOUNT", "4");
    String string2 = sharedPreferences.getString("CARD_CHANGE_KEY", "#bdbdbd");

    cardView.setCardElevation(Integer.parseInt(string));

    CardView.LayoutParams params1 = new CardView.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);

    GridLayout gridLayout = new GridLayout(getApplicationContext());
    gridLayout.setRowCount(row);
    gridLayout.setColumnCount(col);
    for (int i = 0; i < row; i++) {
        for (int j = 0; j < col; j++) {
            EditText editText = new EditText(getApplication());
            editText.setBackgroundColor(Color.parseColor(string2));
            editText.setId(i * 10 + j);
            if (isDark)
                editText.setTextColor(ContextCompat.getColor(this, R.color.white));
            editText.setGravity(Gravity.CENTER);
            SpannableStringBuilder stringBuilder = new SpannableStringBuilder(
                    "a" + String.valueOf(i + 1) + String.valueOf(j + 1));
            stringBuilder.setSpan(new SubscriptSpan(), 1, 3, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            stringBuilder.setSpan(new RelativeSizeSpan(0.75f), 1, 3, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            editText.setHint(stringBuilder);
            if (!PreferenceManager.getDefaultSharedPreferences(this).getBoolean("DECIMAL_USE", true)) {
                editText.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED);
            } else {
                editText.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL
                        | InputType.TYPE_NUMBER_FLAG_SIGNED);
            }
            editText.setFilters(new InputFilter[] { new InputFilter.LengthFilter(getLength()) });
            if (SmartFit) {
                editText.setWidth(ConvertTopx(CalculatedWidth(col)));
                editText.setTextSize(SizeReturner(row, col,
                        PreferenceManager.getDefaultSharedPreferences(getApplicationContext())
                                .getBoolean("EXTRA_SMALL_FONT", false)));
            } else {
                editText.setWidth(ConvertTopx(62));
                editText.setTextSize(SizeReturner(3, 3,
                        PreferenceManager.getDefaultSharedPreferences(getApplicationContext())
                                .getBoolean("EXTRA_SMALL_FONT", false)));
            }
            editText.setSingleLine();
            GridLayout.Spec Row = GridLayout.spec(i, 1);
            GridLayout.Spec Col = GridLayout.spec(j, 1);
            GridLayout.LayoutParams params = new GridLayout.LayoutParams(Row, Col);
            params.leftMargin = params.topMargin = params.bottomMargin = params.rightMargin = getResources()
                    .getDimensionPixelOffset(R.dimen.border_width);
            gridLayout.addView(editText, params);
        }
    }
    gridLayout.setLayoutParams(params1);
    cardView.addView(gridLayout);
    MakeType((Type) (getIntent().getExtras().getSerializable("TYPE")));
    if (GetMaximum() < GetMinimum()) {
        final Snackbar snackbar;
        snackbar = Snackbar.make(findViewById(R.id.filling_matrix), R.string.Warning3,
                Snackbar.LENGTH_INDEFINITE);
        snackbar.show();
        snackbar.setAction(getString(R.string.action_settings), new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                snackbar.dismiss();
                Intent intent = new Intent(getApplicationContext(), SettingsTab.class);
                startActivity(intent);
                finish();
            }
        });
    }

}

From source file:com.ntsync.android.sync.activities.KeyPasswordActivity.java

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    SystemHelper.initSystem(this);

    Log.i(TAG, "loading data from Intent");
    final Intent intent = getIntent();
    mUsername = intent.getStringExtra(PARAM_USERNAME);
    pwdSalt = intent.getByteArrayExtra(PARAM_SALT);
    pwdCheck = intent.getByteArrayExtra(PARAM_CHECK);

    requestWindowFeature(Window.FEATURE_LEFT_ICON);
    setContentView(R.layout.keypassword_activity);
    getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, R.drawable.key);
    mMessage = (TextView) findViewById(R.id.message_bottom);

    mPasswordEdit = new AutoCompleteTextView[5];
    mPasswordEdit[0] = (AutoCompleteTextView) findViewById(R.id.pwd1_edit);
    mPasswordEdit[1] = (AutoCompleteTextView) findViewById(R.id.pwd2_edit);
    mPasswordEdit[2] = (AutoCompleteTextView) findViewById(R.id.pwd3_edit);
    mPasswordEdit[3] = (AutoCompleteTextView) findViewById(R.id.pwd4_edit);
    mPasswordEdit[4] = (AutoCompleteTextView) findViewById(R.id.pwd5_edit);
    for (AutoCompleteTextView textView : mPasswordEdit) {
        textView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE
                | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | InputType.TYPE_TEXT_VARIATION_PASSWORD);
    }//from ww w. j  av a2  s.c om

    if (pwdSalt == null || pwdSalt.length != ClientKeyHelper.SALT_LENGHT || pwdCheck == null) {
        // disable password input
        for (AutoCompleteTextView textView : mPasswordEdit) {
            if (textView != null) {
                textView.setEnabled(false);
            }
        }
    }
    msgNewKey = (TextView) findViewById(R.id.message_newkey);
    SpannableString newKeyText = SpannableString.valueOf(getText(R.string.keypwd_activity_newkey_label));

    newKeyText.setSpan(new InternalURLSpan(this), 0, newKeyText.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    msgNewKey.setText(newKeyText, BufferType.SPANNABLE);
    msgNewKey.setMovementMethod(LinkMovementMethod.getInstance());
}

From source file:io.github.marktony.espresso.mvp.companydetails.CompanyDetailFragment.java

@Override
public void setCompanyWebsite(String website) {
    this.website = website;
    String ws = getString(R.string.official_website) + "\n" + website;
    Spannable spannable = new SpannableStringBuilder(ws);
    spannable.setSpan(new StyleSpan(Typeface.BOLD), 0, ws.length() - website.length() - 1,
            Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    spannable.setSpan(new URLSpan(website), ws.length() - website.length(), ws.length(),
            Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    textViewWebsite.setText(spannable);/*from   ww w  .  j  av  a2  s.c o  m*/
}

From source file:com.microsoft.azure.engagement.ProductDiscountActivity.java

/**
 * Method that adds or removes a strike from a TextView object
 *
 * @param textView The textView to manage
 *///from   ww w. j av a  2s .  c om
private final void addOrRemoveStrikeTextView(TextView textView, boolean toAdd) {
    textView.setText(textView.getText().toString(), TextView.BufferType.SPANNABLE);
    final Spannable spannable = (Spannable) textView.getText();

    if (toAdd == true) {
        // Add a StrikethroughSpan style
        final StrikethroughSpan strikethroughSpan = new StrikethroughSpan();
        spannable.setSpan(strikethroughSpan, 0, textView.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    } else {
        // Remove only StrikethroughSpan style
        final Object spans[] = spannable.getSpans(0, textView.length(), Object.class);
        for (final Object span : spans) {
            if (span instanceof StrikethroughSpan == true) {
                spannable.removeSpan(span);
                return;
            }
        }
    }
}

From source file:com.pax.pay.trans.action.activity.InputTransData2Activity.java

private void setEditText_date(EditText editText) {
    SpannableString ss = new SpannableString(getString(R.string.prompt_date_default2));
    AbsoluteSizeSpan ass = new AbsoluteSizeSpan(getResources().getDimensionPixelOffset(R.dimen.font_size_large),
            false);//from w w w  .j  av  a  2 s. co  m
    ss.setSpan(ass, 0, ss.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    editText.setHint(new SpannedString(ss)); // ??,?
    editText.setHintTextColor(getResources().getColor(R.color.textEdit_hint));
    editText.setInputType(InputType.TYPE_CLASS_NUMBER);
    editText.setFilters(new InputFilter[] { new InputFilter.LengthFilter(4) });
}