Example usage for android.widget TextView getContext

List of usage examples for android.widget TextView getContext

Introduction

In this page you can find the example usage for android.widget TextView getContext.

Prototype

@ViewDebug.CapturedViewProperty
public final Context getContext() 

Source Link

Document

Returns the context the view is running in, through which it can access the current theme, resources, etc.

Usage

From source file:org.appcelerator.titanium.util.TiUIHelper.java

public static void styleText(TextView tv, String fontFamily, String fontSize, String fontWeight,
        String fontStyle) {/*from  w w w . jav  a  2 s  .  co m*/
    Typeface tf = tv.getTypeface();
    tf = toTypeface(tv.getContext(), fontFamily);
    tv.setTypeface(tf, toTypefaceStyle(fontWeight, fontStyle));
    tv.setTextSize(getSizeUnits(fontSize), getSize(fontSize));
}

From source file:com.ruesga.rview.misc.Formatter.java

@BindingAdapter("userMessage")
public static void toUserMessage(TextView view, String msg) {
    if (msg == null) {
        view.setText(null);// w w  w.ja v  a  2  s  .  co  m
        return;
    }

    String message = EmojiHelper.createEmoji(msg);

    // This process mimics the Gerrit formatting process done in class
    // ./gerrit-gwtexpui/src/main/java/com/google/gwtexpui/safehtml/client/SafeHtml.java

    // Split message into paragraphs
    String[] paragraphs = StringHelper.obtainParagraphs(message);
    StringBuilder sb = new StringBuilder();
    boolean formattedMessage = false;
    for (String p : paragraphs) {
        if (StringHelper.isQuote(p)) {
            sb.append(StringHelper.obtainQuote(StringHelper.removeLineBreaks(p)));
            formattedMessage = true;
        } else if (StringHelper.isList(p)) {
            sb.append(p);
            formattedMessage = true;
        } else if (StringHelper.isPreFormat(p)) {
            sb.append(StringHelper.obtainPreFormatMessage(p));
            formattedMessage = true;
        } else {
            sb.append(p);
        }
        sb.append("\n\n");
    }

    String userMessage = StringHelper.removeExtraLines(sb.toString());
    if (!formattedMessage) {
        view.setText(userMessage);
        return;
    }

    if (sQuoteColor == -1) {
        sQuoteColor = ContextCompat.getColor(view.getContext(), R.color.quote);
        sQuoteWidth = (int) view.getContext().getResources().getDimension(R.dimen.quote_width);
        sQuoteMargin = (int) view.getContext().getResources().getDimension(R.dimen.quote_margin);
    }

    String[] lines = userMessage.split("\n");
    SpannableStringBuilder spannable = new SpannableStringBuilder(userMessage
            .replaceAll(StringHelper.NON_PRINTABLE_CHAR, "").replaceAll(StringHelper.NON_PRINTABLE_CHAR2, ""));

    // Pre-Format
    int start = 0;
    int spans = 0;
    while ((start = userMessage.indexOf(StringHelper.NON_PRINTABLE_CHAR2, start)) != -1) {
        int end = userMessage.indexOf(StringHelper.NON_PRINTABLE_CHAR2, start + 1);
        if (end == -1) {
            //? This is supposed to be formatted by us. Skip it
            break;
        }

        // Find quote token occurrences
        int offset = StringHelper.countOccurrences(StringHelper.NON_PRINTABLE_CHAR, userMessage, 0, start);
        start -= offset;
        end -= offset;

        // Ensure bounds
        int spanStart = start - spans;
        int spanEnd = Math.min(end - spans - 1, spannable.length());
        if (spanStart < 0 || spanEnd < 0) {
            //Something was wrong. Skip it
            break;
        }
        spannable.setSpan(new RelativeSizeSpan(0.8f), spanStart, spanEnd, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        spannable.setSpan(new TypefaceSpan("monospace"), spanStart, spanEnd, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        start = end;
        spans++;
    }

    start = 0;
    for (String line : lines) {
        // Quotes
        int maxIndent = StringHelper.countOccurrences(StringHelper.NON_PRINTABLE_CHAR, line);
        for (int i = 0; i < maxIndent; i++) {
            QuotedSpan span = new QuotedSpan(sQuoteColor, sQuoteWidth, sQuoteMargin);
            spannable.setSpan(span, start, Math.min(start + line.length() - maxIndent, spannable.length()),
                    Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        }

        // List
        if (StringHelper.isList(line)) {
            spannable.replace(start, start + 1, "\u2022");
            spannable.setSpan(new LeadingMarginSpan.Standard(sQuoteMargin), start,
                    Math.min(start + line.length(), spannable.length()), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        }

        start += line.length() - maxIndent + 1;
    }

    view.setText(spannable);
}

From source file:com.lillicoder.newsblurry.login.LoginFragment.java

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

    this._passwordInput.setOnEditorActionListener(new OnEditorActionListener() {
        @Override//from  w ww . j ava 2  s . com
        public boolean onEditorAction(TextView view, int actionId, KeyEvent event) {
            // When the 'done' key is pressed, attempt login via
            // submit button.
            if (actionId == EditorInfo.IME_ACTION_DONE) {
                LoginFragment.this._signInButton.performClick();
                return true;
            }

            return false;
        }
    });

    this._signInButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            // Gather user credentials and attempt login.
            String userName = LoginFragment.this._userNameInput.getText().toString();
            String password = LoginFragment.this._passwordInput.getText().toString();

            // If the password is null (which it shouldn't be), replace it with
            // an empty string for the login task.
            if (password == null)
                password = "";

            if (!TextUtils.isEmpty(userName)) {
                LoginTask login = new LoginTask(view.getContext(), LoginFragment.this._loginTaskListener);
                login.execute(userName, password);
            } else {
                // The user provided no user name, show user name requirement error.
                LoginFragment.this.showUserNameRequiredError();
            }
        }
    });
}

From source file:com.google.android.apps.forscience.whistlepunk.review.RunReviewFragment.java

private void hookUpExperimentDetailsArea(ExperimentRun run, View rootView) {
    setArchivedUi(rootView, run.isArchived());

    final TextView runTitle = (TextView) rootView.findViewById(R.id.run_title_text);
    runTitle.setText(run.getRunTitle(rootView.getContext()));

    final TextView runDetailsText = (TextView) rootView.findViewById(R.id.run_details_text);
    runDetailsText.setText(run.getDisplayTime(runDetailsText.getContext()));

    final TextView durationText = (TextView) rootView.findViewById(R.id.run_review_duration);
    ElapsedTimeFormatter formatter = ElapsedTimeFormatter.getInstance(durationText.getContext());
    durationText.setText(formatter.format(run.elapsedSeconds()));
    durationText.setContentDescription(formatter.formatForAccessibility(run.elapsedSeconds()));
}

From source file:com.github.fountaingeyser.typefacecompat.FactoryTypefaceCompat.java

@Override
public View onCreateView(View parent, String name, Context context, AttributeSet attrs) {
    View result = null;/*from   ww w .  j ava 2 s.  c o  m*/
    // Allow base factory to try and create a view first
    if (mBaseFactory != null) {
        result = mBaseFactory.onCreateView(parent, name, context, attrs);
    }
    if (result instanceof TextView) {
        TextView textView = (TextView) result;
        String fontFamily = null;
        int style = 0;
        Resources.Theme theme = context.getTheme();
        TypedArray a = theme.obtainStyledAttributes(attrs, R.styleable.TextViewAppearance, 0, 0);
        TypedArray appearance = null;
        int ap = a.getResourceId(R.styleable.TextViewAppearance_android_textAppearance, -1);
        a.recycle();
        if (ap != -1) {
            appearance = theme.obtainStyledAttributes(ap, R.styleable.TextAppearance);
        }
        if (appearance != null) {
            fontFamily = appearance.getString(R.styleable.TextAppearance_android_fontFamily);
            style = appearance.getInt(R.styleable.TextAppearance_android_textStyle, 0);
            appearance.recycle();
        }
        a = theme.obtainStyledAttributes(attrs, R.styleable.TextAppearance, 0, 0);
        if (a.hasValue(R.styleable.TextAppearance_android_fontFamily)) {
            fontFamily = a.getString(R.styleable.TextAppearance_android_fontFamily);
            style = a.getInt(R.styleable.TextAppearance_android_textStyle, 0);
        }
        a.recycle();
        if (fontFamily != null && TypefaceCompat.isSupported(fontFamily)) {
            Typeface tf = TypefaceCompat.create(textView.getContext(), fontFamily, style);
            if (tf != null) {
                textView.setTypeface(tf);
            }
        }
    }
    return result;
}

From source file:com.tr4android.support.extension.typeface.TypefaceCompatFactory.java

/**
 * This method is responsible for creating the correct subclass of View given the xml element name
 * via AppCompat's layout inflater and afterwards sets the correct typeface if needed.
 *
 * @param parent  The future parent of the returned view. Note that this may be null.
 * @param name    The fully qualified class name of the View to be create.
 * @param context The context the view is being created in.
 * @param attrs   An AttributeSet of attributes to apply to the View.
 * @return The newly created view.//  ww  w  .  j  av  a2 s.com
 * @since 0.1.1
 * @deprecated
 */
@Deprecated
@Override
public View onCreateView(View parent, String name, Context context, AttributeSet attrs) {
    View result = null;
    // Allow base factory to try and create a view first
    if (mBaseFactory != null) {
        result = mBaseFactory.onCreateView(parent, name, context, attrs);
    }
    if (result instanceof TextView) {
        TextView textView = (TextView) result;
        String fontFamily = null;
        int style = 0;
        Resources.Theme theme = context.getTheme();
        TypedArray a = theme.obtainStyledAttributes(attrs, R.styleable.TextViewAppearance, 0, 0);
        TypedArray appearance = null;
        int ap = a.getResourceId(R.styleable.TextViewAppearance_android_textAppearance, -1);
        a.recycle();
        if (ap != -1) {
            appearance = theme.obtainStyledAttributes(ap, R.styleable.TextAppearance);
        }
        if (appearance != null) {
            fontFamily = appearance.getString(R.styleable.TextAppearance_android_fontFamily);
            style = appearance.getInt(R.styleable.TextAppearance_android_textStyle, 0);
            appearance.recycle();
        }
        a = theme.obtainStyledAttributes(attrs, R.styleable.TextAppearance, 0, 0);
        if (a.hasValue(R.styleable.TextAppearance_android_fontFamily)) {
            fontFamily = a.getString(R.styleable.TextAppearance_android_fontFamily);
            style = a.getInt(R.styleable.TextAppearance_android_textStyle, 0);
        }
        a.recycle();
        if (fontFamily != null && TypefaceCompat.isSupported(fontFamily)) {
            Typeface tf = TypefaceCompat.create(textView.getContext(), fontFamily, style);
            if (tf != null) {
                textView.setTypeface(tf);
            }
        }
    }
    return result;
}

From source file:kiv.janecekz.ma.ToneFragment.java

@Override
public void onClick(View arg0) {
    TextView v = (TextView) arg0;

    if (v.getId() == R.id.sharp) {
        sharp = !sharp;//from   w  w w.ja  va  2 s.c om
        int pos = 9;
        if (actualFreqView != null && !sharp) {
            pos = getTone(actualFreqView.getId()).getTonePos();
            v.setTextColor(getView().getResources().getColor(R.color.blue));
        } else if (actualFreqView != null && sharp) {
            // FIXME: Use only one method to get pos.

            pos = (getTone(actualFreqView.getId()).getTonePos() + 1) % 12;
            v.setTextColor(Color.RED);
        } else if (actualFreqView == null && sharp) {
            v.setTextColor(Color.RED);
        } else if (actualFreqView == null && !sharp) {
            v.setTextColor(getView().getResources().getColor(R.color.blue));
        }

        int baseFreq = SharedPref.getBaseFreq(getActivity());
        float freq = baseFreq * Tones.freqCoefs[pos];
        input.setText(String.format("%.2f", freq));

        pl.setFreq(freq);
    } else {
        if (actualFreqView != null) {
            actualFreqView.setTextColor(getView().getResources().getColor(R.color.blue));
        }

        actualFreqView = v;

        // Set frequency coefficient accordingly.
        int freqCoefPosition = getTone(v.getId()).getTonePos();
        freqCoefPosition = sharp ? (freqCoefPosition + 1) % 12 : freqCoefPosition;

        int baseFreq = SharedPref.getBaseFreq(getActivity());
        float freq = baseFreq * Tones.freqCoefs[freqCoefPosition];

        input.setText(String.format("%.2f", freq));
        pl.setFreq(freq);
        if (!pl.isPlay()) {
            pl.togglePlay();
        }

        v.setTextColor(Color.RED);
    }

    AnimationSet push = (AnimationSet) AnimationUtils.loadAnimation(v.getContext(), R.anim.push);
    v.startAnimation(push);
}

From source file:com.landenlabs.all_devtool.PackageFragment.java

@Override
public void onClick(View v) {

    int id = v.getId();
    switch (id) {
    case R.id.pkgLoadBtn:
        m_pkgLoadBtn.setVisibility(View.GONE);
        updateList();/*from  www. ja  va 2 s. c  o m*/
        break;
    case R.id.package_uninstall:
        if (m_uninstallResId == R.string.package_del_cache)
            deleteCaches();
        else
            uninstallPackages();
        break;
    case R.id.pkg_plus_minus_toggle:
        if (m_expand_collapse_toggle.isChecked())
            expandAll();
        else
            collapseAll();
        break;
    case R.id.pkg_title:
        if (TextUtils.isEmpty(m_title.getHint())) {
            // m_title.setTag(m_title.getText());
            m_title.setText("");
            m_title.setHint("Filter");
            if (m_list.size() > m_beforeFilter.size()) {
                m_beforeFilter.clear();
                m_beforeFilter.addAll(m_list);
            }

            m_title.setOnEditorActionListener(new TextView.OnEditorActionListener() {
                @Override
                public boolean onEditorAction(TextView edView, int actionId, KeyEvent event) {
                    if (actionId == EditorInfo.IME_ACTION_DONE) {
                        String filter = edView.getText().toString();
                        filterPackages(filter);
                        // hideKeyboard
                        InputMethodManager imm = (InputMethodManager) edView.getContext()
                                .getSystemService(Context.INPUT_METHOD_SERVICE);
                        imm.hideSoftInputFromWindow(edView.getWindowToken(), 0);
                        return true; // consume.
                    }
                    return false; // pass on to other listeners.
                }
            });
        }
        break;
    }
}

From source file:ca.ualberta.cs.drivr.MainActivity.java

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

    userManager.setConnectivityManager((ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE));

    /**//from ww w . j av a2 s.co m
     * This calls the login activity a the beginning if there is no local user stored
     */
    if (userManager.getUser().getUsername().isEmpty()) {
        Intent intent = new Intent(MainActivity.this, LoginActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(intent);
    }

    this.requestWindowFeature(Window.FEATURE_NO_TITLE);

    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);

    context = getApplicationContext();
    PreferenceManager.setDefaultValues(this, R.xml.pref_driver_mode, false);

    setSupportActionBar(toolbar);

    // Create an instance of GoogleAPIClient.
    if (mGoogleApiClient == null) {
        mGoogleApiClient = new GoogleApiClient.Builder(this).addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this).addApi(LocationServices.API).build();
    }

    mFragment = (SupportMapFragment) this.getSupportFragmentManager().findFragmentById(R.id.main_map);
    mFragment.getMapAsync(this);

    autocompleteFragment = (PlaceAutocompleteFragment) getFragmentManager()
            .findFragmentById(R.id.place_autocomplete_fragment);

    autocompleteFragment.setOnPlaceSelectedListener(new PlaceSelectionListener() {
        @Override
        public void onPlaceSelected(Place place) {
            ConcretePlace concretePlace = new ConcretePlace(place);
            Gson gson = new GsonBuilder().registerTypeAdapter(Uri.class, new UriSerializer()).create();
            if (userManager.getUserMode().equals(UserMode.RIDER)) {
                Intent intent = new Intent(MainActivity.this, NewRequestActivity.class);
                String concretePlaceJson = gson.toJson(concretePlace);
                intent.putExtra(NewRequestActivity.EXTRA_PLACE, concretePlaceJson);
                Log.i(TAG, "Place: " + place.getName() + ", :" + place.getLatLng());
                startActivity(intent);

            } else if (userManager.getUserMode().equals(UserMode.DRIVER)) {
                Intent intent = new Intent(MainActivity.this, SearchRequestActivity.class);
                String concretePlaceJson = gson.toJson(concretePlace);
                intent.putExtra(SearchRequestActivity.EXTRA_PLACE, concretePlaceJson);
                intent.putExtra(SearchRequestActivity.EXTRA_KEYWORD, "");
                Log.i(TAG, "Place: " + place.getName() + ", :" + place.getLatLng());
                startActivity(intent);
            }
        }

        @Override
        public void onError(Status status) {
            // Do nothing
        }
    });

    // Using the floating action button menu system
    final FloatingActionMenu fabMenu = (FloatingActionMenu) findViewById(R.id.main_fab_menu);
    FloatingActionButton fabSettings = (FloatingActionButton) findViewById(R.id.fabSettings);
    FloatingActionButton fabRequests = (FloatingActionButton) findViewById(R.id.main_fab_requests);
    FloatingActionButton fabProfile = (FloatingActionButton) findViewById(R.id.main_fab_profile);
    FloatingActionButton fabHistory = (FloatingActionButton) findViewById(R.id.main_fah_history);
    FloatingActionButton fabLogin = (FloatingActionButton) findViewById(R.id.main_fab_login);
    final FloatingActionButton fabDriver = (FloatingActionButton) findViewById(R.id.main_driver_mode);
    final FloatingActionButton fabRider = (FloatingActionButton) findViewById(R.id.main_rider_mode);

    // Hide the settings FAB
    fabSettings.setVisibility(View.GONE);

    /*
    Change between user and driver mode. Will probably be replaced with an option in settings.
    For now the visibility of this is set to gone because we should not have too many FABs.
    Having too many FABs may cause confusion and rendering issues on small screens.
    */
    keywordEditText = (EditText) findViewById(R.id.main_keyword_edit_text);
    FloatingActionButton fabMode = (FloatingActionButton) findViewById(R.id.main_fab_mode);
    fabMode.setVisibility(View.GONE);
    if (userManager.getUserMode().equals(UserMode.RIDER)) {
        fabRider.setVisibility(View.GONE);
        keywordEditText.setVisibility(View.GONE);
    } else {
        fabDriver.setVisibility(View.GONE);
        keywordEditText.setVisibility(View.VISIBLE);
    }

    keywordEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE) {
                Intent intent = new Intent(MainActivity.this, SearchRequestActivity.class);
                intent.putExtra(SearchRequestActivity.EXTRA_PLACE, "");
                intent.putExtra(SearchRequestActivity.EXTRA_KEYWORD, keywordEditText.getText().toString());
                keywordEditText.setText("");
                keywordEditText.clearFocus();
                startActivity(intent);
            }
            return true;
        }
    });

    fabMode.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Log.i(TAG, "clicked mode fab");
            /*
            Will be able to implement code below once elasticSearch is up and running
            UserManager userManager = null; // Once elasticSearch is working will replace with finding a User
            if (userManager.getUserMode() == UserMode.DRIVER) {
            userManager.setUserMode(UserMode.RIDER);
            }
            else if (userManager.getUserMode() == UserMode.RIDER) {
            userManager.setUserMode(UserMode.DRIVER);
            //Will have to implement a method "FindNearbyRequests" to get requests whose source
            // is nearby and display it on the map
            //Intent intent = new Intent((MainActivity.this, FindNearbyRequests.class);)
            //startActivity(intent);
            }*/
        }
    });

    fabDriver.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (userManager.getUser().getVehicleDescription().isEmpty()) {
                /*
                * From: http://stackoverflow.com/a/29048271
                * Author: Syeda Zunairah
                * Accessed: November 29, 2016
                * Creates a dialog box with an edit text to get the vehicle description.
                */
                AlertDialog.Builder alert = new AlertDialog.Builder(v.getContext());
                final EditText edittext = new EditText(v.getContext());
                edittext.setText("Vechicle Make");
                edittext.clearComposingText();
                alert.setTitle("Become a Driver!");
                alert.setMessage(
                        "Drivers are require to enter vehicle information!\n\nPlease enter your vehicle's make");

                alert.setView(edittext);

                alert.setPositiveButton("Save Description", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {
                        String vehicleDescription = edittext.getText().toString();
                        if (!vehicleDescription.isEmpty()) {
                            userManager.getUser().setVehicleDescription(vehicleDescription);
                            userManager.notifyObservers();
                            userManager.setUserMode(UserMode.DRIVER);
                            ElasticSearch elasticSearch = new ElasticSearch(
                                    userManager.getConnectivityManager());
                            elasticSearch.updateUser(userManager.getUser());
                            keywordEditText.setVisibility(View.VISIBLE);
                            fabDriver.setVisibility(View.GONE);
                            fabRider.setVisibility(View.VISIBLE);
                            fabMenu.close(true);
                        }
                        dialog.dismiss();
                    }
                });

                alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {
                        dialog.dismiss();
                    }
                });

                AlertDialog newAlert = alert.create();
                newAlert.show();
            }
            if (!userManager.getUser().getVehicleDescription().isEmpty()) {
                userManager.setUserMode(UserMode.DRIVER);
                keywordEditText.setVisibility(View.VISIBLE);
                fabDriver.setVisibility(View.GONE);
                fabRider.setVisibility(View.VISIBLE);
                fabMenu.close(true);
            }
        }
    });

    fabRider.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            userManager.setUserMode(UserMode.RIDER);
            keywordEditText.setVisibility(View.GONE);
            fabRider.setVisibility(View.GONE);
            fabDriver.setVisibility(View.VISIBLE);
            fabMenu.close(true);
        }
    });

    fabLogin.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(MainActivity.this, LoginActivity.class);
            fabMenu.close(true);
            startActivity(intent);
        }
    });

    fabSettings.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Log.i(TAG, "clicked settings fab");
            Intent intent = new Intent(MainActivity.this, SettingsActivity.class);
            fabMenu.close(true);
            startActivity(intent);
        }
    });

    fabProfile.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Log.i(TAG, "clicked profile fab");
            Intent intent = new Intent(MainActivity.this, ProfileActivity.class);
            fabMenu.close(true);
            startActivity(intent);
        }
    });
    fabHistory.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Log.i(TAG, "clicked history fab");
            Intent intent = new Intent(MainActivity.this, RequestHistoryActivity.class);
            fabMenu.close(true);
            startActivity(intent);
        }
    });

    fabRequests.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Log.i(TAG, "clicked requests fab");
            Intent intent = new Intent(MainActivity.this, RequestsListActivity.class);
            fabMenu.close(true);
            startActivity(intent);
        }
    });
    setNotificationAlarm(context);
}

From source file:com.github.irshulx.Components.InputExtensions.java

public void UpdateTextStyle(EditorTextStyle style, TextView editText) {
    /// String type = getControlType(getActiveView());
    try {/* w ww . ja v a  2 s .  c o  m*/
        if (editText == null) {
            editText = (EditText) editorCore.getActiveView();
        }
        EditorControl tag = editorCore.getControlTag(editText);

        int pBottom = editText.getPaddingBottom();
        int pRight = editText.getPaddingRight();
        int pTop = editText.getPaddingTop();

        if (isEditorTextStyleHeaders(style)) {
            updateTextStyle(editText, style);
            return;
        }
        if (isEditorTextStyleContentStyles(style)) {
            boolean containsHeadertextStyle = containsHeaderTextStyle(tag);
            if (style == EditorTextStyle.BOLD) {
                boldifyText(tag, editText, containsHeadertextStyle ? HEADING : CONTENT);
            } else if (style == EditorTextStyle.ITALIC) {
                italicizeText(tag, editText, containsHeadertextStyle ? HEADING : CONTENT);
            }
            return;
        }
        if (style == EditorTextStyle.INDENT) {
            if (editorCore.containsStyle(tag.editorTextStyles, EditorTextStyle.INDENT)) {
                tag = editorCore.updateTagStyle(tag, EditorTextStyle.INDENT, Op.Delete);
                editText.setPadding(0, pTop, pRight, pBottom);
                editText.setTag(tag);
            } else {
                tag = editorCore.updateTagStyle(tag, EditorTextStyle.INDENT, Op.Insert);
                editText.setPadding(30, pTop, pRight, pBottom);
                editText.setTag(tag);
            }
        } else if (style == EditorTextStyle.OUTDENT) {
            if (editorCore.containsStyle(tag.editorTextStyles, EditorTextStyle.INDENT)) {
                tag = editorCore.updateTagStyle(tag, EditorTextStyle.INDENT, Op.Delete);
                editText.setPadding(0, pTop, pRight, pBottom);
                editText.setTag(tag);
            }
        } else if (style == EditorTextStyle.BLOCKQUOTE) {
            LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) editText.getLayoutParams();
            if (editorCore.containsStyle(tag.editorTextStyles, EditorTextStyle.BLOCKQUOTE)) {
                tag = editorCore.updateTagStyle(tag, EditorTextStyle.BLOCKQUOTE, Op.Delete);
                editText.setPadding(0, pTop, pRight, pBottom);
                editText.setBackgroundDrawable(ContextCompat.getDrawable(this.editorCore.getContext(),
                        R.drawable.invisible_edit_text));
                params.setMargins(0, 0, 0, (int) editorCore.getContext().getResources()
                        .getDimension(R.dimen.edittext_margin_bottom));
            } else {
                float marginExtra = editorCore.getContext().getResources()
                        .getDimension(R.dimen.edittext_margin_bottom) * 1.5f;
                tag = editorCore.updateTagStyle(tag, EditorTextStyle.BLOCKQUOTE, Op.Insert);
                editText.setPadding(30, pTop, 30, pBottom);
                editText.setBackgroundDrawable(
                        editText.getContext().getResources().getDrawable(R.drawable.block_quote_background));
                params.setMargins(0, (int) marginExtra, 0, (int) marginExtra);
            }
            editText.setTag(tag);
        }
    } catch (Exception e) {

    }
}