Example usage for android.graphics Typeface DEFAULT

List of usage examples for android.graphics Typeface DEFAULT

Introduction

In this page you can find the example usage for android.graphics Typeface DEFAULT.

Prototype

Typeface DEFAULT

To view the source code for android.graphics Typeface DEFAULT.

Click Source Link

Document

The default NORMAL typeface object

Usage

From source file:cn.bingoogolapple.androidcommon.adapter.BGAViewHolderHelper.java

/**
 * ?//from w  ww . j av a 2s  .  c om
 *
 * @param viewId
 * @param isBold
 * @return
 */
public BGAViewHolderHelper setBold(@IdRes int viewId, boolean isBold) {
    getTextView(viewId).getPaint().setTypeface(isBold ? Typeface.DEFAULT_BOLD : Typeface.DEFAULT);
    return this;
}

From source file:xyz.yhsj.helper.ViewHolderHelper.java

/**
 * ?/*from   ww w.j a  v  a  2s  .c  o m*/
 *
 * @param viewId
 * @param isBold
 * @return
 */
public ViewHolderHelper setBold(@IdRes int viewId, boolean isBold) {
    getTextView(viewId).getPaint().setTypeface(isBold ? Typeface.DEFAULT_BOLD : Typeface.DEFAULT);
    return this;
}

From source file:com.hao.common.adapter.BaseViewHolderHelper.java

/**
 * ?//from  w  w  w .  j a  va2s .c  o m
 *
 * @param viewId
 * @param isBold
 * @return
 */
public BaseViewHolderHelper setBold(@IdRes int viewId, boolean isBold) {
    getTextView(viewId).getPaint().setTypeface(isBold ? Typeface.DEFAULT_BOLD : Typeface.DEFAULT);
    return this;
}

From source file:com.einzig.ipst2.activities.MainActivity.java

/**
 * This method fixes formatting when radio boxes are changed
 *//* w  ww .ja va2s .c o m*/
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
    buttonView.setTypeface(isChecked ? Typeface.DEFAULT_BOLD : Typeface.DEFAULT);
    Logger.d("Check Changed : " + buttonView.getText().toString() + " - " + isChecked);
    ThemeHelper.styleRadioButton(buttonView, this, isChecked);
}

From source file:org.ciasaboark.tacere.manager.NotificationManagerWrapper.java

private Bitmap createMarkerIcon(Drawable backgroundImage, String text, int width, int height) {

    Bitmap canvasBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    // Create a canvas, that will draw on to canvasBitmap.
    Canvas imageCanvas = new Canvas(canvasBitmap);

    // Draw the image to our canvas
    backgroundImage.draw(imageCanvas);/*from  w  ww . j a  v  a 2s .co  m*/

    // Set up the paint for use with our Canvas
    TextPaint textPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG | TextPaint.LINEAR_TEXT_FLAG);
    textPaint.setTextAlign(TextPaint.Align.CENTER);
    textPaint.setTypeface(Typeface.DEFAULT);
    textPaint.setTextSize(100f);
    textPaint.setColor(context.getResources().getColor(android.R.color.white));

    int xPos = (imageCanvas.getWidth() / 2);
    int yPos = (int) ((imageCanvas.getHeight() / 2) - ((textPaint.descent() + textPaint.ascent()) / 2));
    Rect r = new Rect();
    textPaint.getTextBounds(text, 0, text.length(), r);
    //        yPos += (Math.abs(r.height()))/2;

    // Draw the text on top of our image
    imageCanvas.drawText(text, xPos, yPos, textPaint);

    // Combine background and text to a LayerDrawable
    LayerDrawable layerDrawable = new LayerDrawable(
            new Drawable[] { backgroundImage, new BitmapDrawable(canvasBitmap) });
    Bitmap newBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    layerDrawable.setBounds(0, 0, width, height);
    layerDrawable.draw(new Canvas(newBitmap));
    return newBitmap;
}

From source file:ch.gianulli.flashcards.ui.Flashcard.java

public void deactivateCard(boolean correctAnswer) {
    // Show button bar
    mButtonBarShowing = true;/*from   w  w  w. j  a  v  a  2s .  c o m*/
    mButtonBar.setVisibility(View.VISIBLE);
    mButtonBar.setAlpha(1.0f);

    // Set correct text color
    mQuestionColor = sDeactivatedTextColor;
    mAnswerColor = sDeactivatedTextColor;
    setQuestion(mQuestionText);
    setAnswer(mAnswerText);

    // Deactivate buttons
    mCorrectButton.setEnabled(false);
    mCorrectButton.setTypeface((correctAnswer) ? Typeface.DEFAULT_BOLD : Typeface.DEFAULT);
    mWrongButton.setEnabled(false);
    mWrongButton.setTypeface((correctAnswer) ? Typeface.DEFAULT : Typeface.DEFAULT_BOLD);
}

From source file:com.near.chimerarevo.fragments.PostFragment.java

private void parseBulletedLists(Elements itms) {
    String bld = "";
    for (Element itm : itms) {
        Elements str = itm.getElementsByTag("li");
        for (Element itm2 : str) {
            if (itm2.children().size() >= 1) {
                Elements ch = itm2.getElementsByTag("a");
                for (Element c : ch) {
                    if (c.attr("href").contains("#"))
                        c.removeAttr("href");
                }/*  w  ww .j  ava2 s .  c  o  m*/
            }
            bld += ("\u2022 " + itm2.outerHtml() + "<br />");
        }
    }
    addText(bld, true, Typeface.DEFAULT);
}

From source file:talex.zsw.baselibrary.widget.NavigationTabBar.java

public void setTypeface(final String typeface) {
    Typeface tempTypeface;// ww w.ja va  2s.  c  om
    //      try
    //      {
    //         tempTypeface = Typeface.createFromAsset(getContext().getAssets(), typeface);
    //      } catch (Exception e)
    //      {
    tempTypeface = Typeface.create(Typeface.DEFAULT, Typeface.NORMAL);
    //         e.printStackTrace();
    //      }

    setTypeface(tempTypeface);
}

From source file:com.near.chimerarevo.fragments.PostFragment.java

private void parseOrderedLists(Elements itms) {
    String bld = "";
    for (Element itm : itms) {
        Elements str = itm.getElementsByTag("li");
        for (int j = 0; j < str.size(); j++) {
            Element itm2 = str.get(j);
            bld += ("<b>" + (j + 1) + ")</b> <i>" + itm2.outerHtml() + "</i><br />");
        }// ww w.j  av  a2 s  .c  om
    }
    addText(bld, true, Typeface.DEFAULT);
}

From source file:com.hughes.android.dictionary.DictionaryActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    // This needs to be before super.onCreate, otherwise ActionbarSherlock
    // doesn't makes the background of the actionbar white when you're
    // in the dark theme.
    setTheme(((DictionaryApplication) getApplication()).getSelectedTheme().themeId);

    Log.d(LOG, "onCreate:" + this);
    super.onCreate(savedInstanceState);

    final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);

    // Don't auto-launch if this fails.
    prefs.edit().remove(C.DICT_FILE).commit();

    setContentView(R.layout.dictionary_activity);

    application = (DictionaryApplication) getApplication();
    theme = application.getSelectedTheme();
    textColorFg = getResources().getColor(theme.tokenRowFgColor);

    final Intent intent = getIntent();
    String intentAction = intent.getAction();
    /**/*from   www  .ja v  a  2s .  c om*/
     * @author Dominik Kppl Querying the Intent
     *         com.hughes.action.ACTION_SEARCH_DICT is the advanced query
     *         Arguments: SearchManager.QUERY -> the phrase to search from
     *         -> language in which the phrase is written to -> to which
     *         language shall be translated
     */
    if (intentAction != null && intentAction.equals("com.hughes.action.ACTION_SEARCH_DICT")) {
        String query = intent.getStringExtra(SearchManager.QUERY);
        String from = intent.getStringExtra("from");
        if (from != null)
            from = from.toLowerCase(Locale.US);
        String to = intent.getStringExtra("to");
        if (to != null)
            to = to.toLowerCase(Locale.US);
        if (query != null) {
            getIntent().putExtra(C.SEARCH_TOKEN, query);
        }
        if (intent.getStringExtra(C.DICT_FILE) == null && (from != null || to != null)) {
            Log.d(LOG, "DictSearch: from: " + from + " to " + to);
            List<DictionaryInfo> dicts = application.getDictionariesOnDevice(null);
            for (DictionaryInfo info : dicts) {
                boolean hasFrom = from == null;
                boolean hasTo = to == null;
                for (IndexInfo index : info.indexInfos) {
                    if (!hasFrom && index.shortName.toLowerCase(Locale.US).equals(from))
                        hasFrom = true;
                    if (!hasTo && index.shortName.toLowerCase(Locale.US).equals(to))
                        hasTo = true;
                }
                if (hasFrom && hasTo) {
                    if (from != null) {
                        int which_index = 0;
                        for (; which_index < info.indexInfos.size(); ++which_index) {
                            if (info.indexInfos.get(which_index).shortName.toLowerCase(Locale.US).equals(from))
                                break;
                        }
                        intent.putExtra(C.INDEX_SHORT_NAME, info.indexInfos.get(which_index).shortName);

                    }
                    intent.putExtra(C.DICT_FILE, application.getPath(info.uncompressedFilename).toString());
                    break;
                }
            }

        }
    }
    /**
     * @author Dominik Kppl Querying the Intent Intent.ACTION_SEARCH is a
     *         simple query Arguments follow from android standard (see
     *         documentation)
     */
    if (intentAction != null && intentAction.equals(Intent.ACTION_SEARCH)) {
        String query = intent.getStringExtra(SearchManager.QUERY);
        if (query != null)
            getIntent().putExtra(C.SEARCH_TOKEN, query);
    }
    /**
     * @author Dominik Kppl If no dictionary is chosen, use the default
     *         dictionary specified in the preferences If this step does
     *         fail (no default directory specified), show a toast and
     *         abort.
     */
    if (intent.getStringExtra(C.DICT_FILE) == null) {
        String dictfile = prefs.getString(getString(R.string.defaultDicKey), null);
        if (dictfile != null)
            intent.putExtra(C.DICT_FILE, application.getPath(dictfile).toString());
    }
    String dictFilename = intent.getStringExtra(C.DICT_FILE);

    if (dictFilename == null) {
        Toast.makeText(this, getString(R.string.no_dict_file), Toast.LENGTH_LONG).show();
        startActivity(DictionaryManagerActivity.getLaunchIntent(getApplicationContext()));
        finish();
        return;
    }
    if (dictFilename != null)
        dictFile = new File(dictFilename);

    ttsReady = false;
    textToSpeech = new TextToSpeech(getApplicationContext(), new OnInitListener() {
        @Override
        public void onInit(int status) {
            ttsReady = true;
            updateTTSLanguage(indexIndex);
        }
    });

    try {
        final String name = application.getDictionaryName(dictFile.getName());
        this.setTitle("QuickDic: " + name);
        dictRaf = new RandomAccessFile(dictFile, "r");
        dictionary = new Dictionary(dictRaf);
    } catch (Exception e) {
        Log.e(LOG, "Unable to load dictionary.", e);
        if (dictRaf != null) {
            try {
                dictRaf.close();
            } catch (IOException e1) {
                Log.e(LOG, "Unable to close dictRaf.", e1);
            }
            dictRaf = null;
        }
        Toast.makeText(this, getString(R.string.invalidDictionary, "", e.getMessage()), Toast.LENGTH_LONG)
                .show();
        startActivity(DictionaryManagerActivity.getLaunchIntent(getApplicationContext()));
        finish();
        return;
    }
    String targetIndex = intent.getStringExtra(C.INDEX_SHORT_NAME);
    if (savedInstanceState != null && savedInstanceState.getString(C.INDEX_SHORT_NAME) != null) {
        targetIndex = savedInstanceState.getString(C.INDEX_SHORT_NAME);
    }
    indexIndex = 0;
    for (int i = 0; i < dictionary.indices.size(); ++i) {
        if (dictionary.indices.get(i).shortName.equals(targetIndex)) {
            indexIndex = i;
            break;
        }
    }
    Log.d(LOG, "Loading index " + indexIndex);
    index = dictionary.indices.get(indexIndex);
    setListAdapter(new IndexAdapter(index));

    // Pre-load the collators.
    new Thread(new Runnable() {
        public void run() {
            android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_BACKGROUND);
            final long startMillis = System.currentTimeMillis();
            try {
                TransliteratorManager.init(new TransliteratorManager.Callback() {
                    @Override
                    public void onTransliteratorReady() {
                        uiHandler.post(new Runnable() {
                            @Override
                            public void run() {
                                onSearchTextChange(searchView.getQuery().toString());
                            }
                        });
                    }
                });

                for (final Index index : dictionary.indices) {
                    final String searchToken = index.sortedIndexEntries.get(0).token;
                    final IndexEntry entry = index.findExact(searchToken);
                    if (entry == null || !searchToken.equals(entry.token)) {
                        Log.e(LOG, "Couldn't find token: " + searchToken + ", "
                                + (entry == null ? "null" : entry.token));
                    }
                }
                indexPrepFinished = true;
            } catch (Exception e) {
                Log.w(LOG,
                        "Exception while prepping.  This can happen if dictionary is closed while search is happening.");
            }
            Log.d(LOG, "Prepping indices took:" + (System.currentTimeMillis() - startMillis));
        }
    }).start();

    String fontName = prefs.getString(getString(R.string.fontKey), "FreeSerif.otf.jpg");
    if ("SYSTEM".equals(fontName)) {
        typeface = Typeface.DEFAULT;
    } else if ("SERIF".equals(fontName)) {
        typeface = Typeface.SERIF;
    } else if ("SANS_SERIF".equals(fontName)) {
        typeface = Typeface.SANS_SERIF;
    } else if ("MONOSPACE".equals(fontName)) {
        typeface = Typeface.MONOSPACE;
    } else {
        if ("FreeSerif.ttf.jpg".equals(fontName)) {
            fontName = "FreeSerif.otf.jpg";
        }
        try {
            typeface = Typeface.createFromAsset(getAssets(), fontName);
        } catch (Exception e) {
            Log.w(LOG, "Exception trying to use typeface, using default.", e);
            Toast.makeText(this, getString(R.string.fontFailure, e.getLocalizedMessage()), Toast.LENGTH_LONG)
                    .show();
        }
    }
    if (typeface == null) {
        Log.w(LOG, "Unable to create typeface, using default.");
        typeface = Typeface.DEFAULT;
    }
    final String fontSize = prefs.getString(getString(R.string.fontSizeKey), "14");
    try {
        fontSizeSp = Integer.parseInt(fontSize.trim());
    } catch (NumberFormatException e) {
        fontSizeSp = 14;
    }

    // ContextMenu.
    registerForContextMenu(getListView());

    // Cache some prefs.
    wordList = application.getWordListFile();
    saveOnlyFirstSubentry = prefs.getBoolean(getString(R.string.saveOnlyFirstSubentryKey), false);
    clickOpensContextMenu = prefs.getBoolean(getString(R.string.clickOpensContextMenuKey), false);
    Log.d(LOG, "wordList=" + wordList + ", saveOnlyFirstSubentry=" + saveOnlyFirstSubentry);

    onCreateSetupActionBarAndSearchView();

    // Set the search text from the intent, then the saved state.
    String text = getIntent().getStringExtra(C.SEARCH_TOKEN);
    if (savedInstanceState != null) {
        text = savedInstanceState.getString(C.SEARCH_TOKEN);
    }
    if (text == null) {
        text = "";
    }
    setSearchText(text, true);
    Log.d(LOG, "Trying to restore searchText=" + text);

    setDictionaryPrefs(this, dictFile, index.shortName, searchView.getQuery().toString());

    updateLangButton();
    searchView.requestFocus();

    // http://stackoverflow.com/questions/2833057/background-listview-becomes-black-when-scrolling
    //        getListView().setCacheColorHint(0);
}