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:com.mobisci_lab.virtualkeyboard.softkeyboard.LatinKeyboardView.java

@Override
public void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    TextPaint paint = new TextPaint();
    paint.setAntiAlias(true);//from   w w  w .  j  a  va 2s.  c  om
    paint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.BOLD));
    paint.setTextSize(11 * getResources().getDisplayMetrics().density);
    paint.setColor(ContextCompat.getColor(this.getContext(), R.color.candidate_other));

    List<Key> keys = getKeyboard().getKeys();
    for (Key key : keys) {
        float x = key.x + key.width / 2 + key.width / 5;
        float y = key.y + key.width / 2;
        String text = "";
        switch (key.codes[0]) {
        case 113:
            text = "1";
            break;
        case 119:
            text = "2";
            break;
        case 101:
            text = "3";
            break;
        case 114:
            text = "4";
            break;
        case 116:
            text = "5";
            break;
        case 121:
            text = "6";
            break;
        case 117:
            text = "7";
            break;
        case 105:
            text = "8";
            break;
        case 111:
            text = "9";
            break;
        case 112:
            text = "0";
            break;

        }
        canvas.drawText(text, x, y, paint);
    }
}

From source file:com.module.candychat.net.wouclass.SimpleAssetFontLoader.java

@Override
public Typeface getTypeFace(String typefaceName) {
    Typeface typeface = sTypefaceCache.get(typefaceName);

    if (typeface == null) {
        String fontFile = mFolderForPath + typefaceName + "." + mExtension;

        try {/*from w  w  w.j  av a 2  s  . c  om*/
            typeface = Typeface.createFromAsset(mAssetManager, fontFile);
            sTypefaceCache.put(typefaceName, typeface);
        } catch (java.lang.RuntimeException e) {
            return android.graphics.Typeface.DEFAULT;
        }
    }
    return typeface;
}

From source file:com.allmycode.flags.other.MyActivityOther.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);/*from w  ww  . ja  va2s. c  o  m*/
    targetActivity = (EditText) findViewById(R.id.editText1);
    flags = (EditText) findViewById(R.id.editText2);
    cheatSheet = (EditText) findViewById(R.id.editText3);
    for (String item : flagsList) {
        cheatSheet.append(item);
        cheatSheet.append("\n");
    }
    Intent whoCalled = getIntent();
    helloView = ((TextView) findViewById(R.id.textView3));
    helloView.setTextColor(android.graphics.Color.WHITE);
    helloView.setTypeface(Typeface.DEFAULT, Typeface.NORMAL);
    helloView.setText("Flags: 0x" + Integer.toHexString(whoCalled.getFlags()));
    if (whoCalled.getExtras() != null) {
        boolean areErrors = whoCalled.getExtras().getBoolean("existErrors", false);
        if (areErrors) {
            helloView.append(" There were errors!");
            helloView.setTextColor(android.graphics.Color.RED);
            helloView.setTypeface(Typeface.DEFAULT, Typeface.BOLD);
        }
    }
    ActivityManager am = (ActivityManager) getSystemService(Service.ACTIVITY_SERVICE);
    List<ActivityManager.RunningAppProcessInfo> processes;
    processes = am.getRunningAppProcesses();
    for (ActivityManager.RunningAppProcessInfo info : processes) {
        Log.i("Process:", info.processName);
    }
}

From source file:com.android.tabletcustomui.views.LeftCircleContainer.java

private void init(Context context, int width) {

    LinearLayoutCompat.LayoutParams layoutParams = new LinearLayoutCompat.LayoutParams((int) (width),
            (int) (width));
    layoutParams.gravity = Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL;
    this.setLayoutParams(layoutParams);

    LeftOuterCircleView leftOuterCircleView1 = new LeftOuterCircleView(context, width, false);
    LeftOuterCircleView leftOuterCircleView2 = new LeftOuterCircleView(context, (width - 40), true);

    circleTitleView = new CircleTitleView(context, (int) (width));
    circleTitleView.setTextColor(getContext().getResources().getColor(android.R.color.white));
    circleTitleView.setTextSize(20);/*from ww w  . ja v  a 2  s . c  o m*/
    circleTitleView.setTypeface(Typeface.DEFAULT, Typeface.BOLD_ITALIC);
    circleTitleView.setText("App Name");

    this.addView(leftOuterCircleView1);
    this.addView(leftOuterCircleView2);
    addCircle(1, width - 78, (float) 0.0, 0.85);
    addCircle(2, width - 150, (float) 0.0, 0.97);
    addCircle(3, width - 170, (float) 0.0, 0.97);
    addCircle(4, width - 190, (float) 0.0, 0.98);
    addCircle(5, width - 210, (float) 0.0, 0.98);
    addCircle(6, width - 230, (float) 0.0, 0.85);
    addCircle(7, width - 280, (float) 0.0, 0.85);
    addCircle(0, width - 35, (float) 0.0, 0.9);
    addCircle(0, width - 92, (float) 0.1, 0.9);

    this.addView(circleTitleView);

    animateClockWise(leftOuterCircleView1);

    animateAntiClockWise(leftOuterCircleView2);

}

From source file:Main.java

private static Typeface getTextTypeface(final CharSequence text) {
    if (!(text instanceof SpannableString)) {
        return Typeface.DEFAULT;
    }/*from   w  ww.  ja va2  s . c o m*/

    final SpannableString ss = (SpannableString) text;
    final StyleSpan[] styles = ss.getSpans(0, text.length(), StyleSpan.class);
    if (styles.length == 0) {
        return Typeface.DEFAULT;
    }

    if (styles[0].getStyle() == Typeface.BOLD) {
        return Typeface.DEFAULT_BOLD;
    }
    // TODO: BOLD_ITALIC, ITALIC case?
    return Typeface.DEFAULT;
}

From source file:com.miz.mizuu.AddNetworkFilesourceDialog.java

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

    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

    setContentView(R.layout.addnetwork);

    server = (EditText) findViewById(R.id.server);
    domain = (EditText) findViewById(R.id.domain);
    username = (EditText) findViewById(R.id.username);
    password = (EditText) findViewById(R.id.password);
    password.setTypeface(Typeface.DEFAULT);
    password.setTransformationMethod(new PasswordTransformationMethod());
    anonymous = (CheckBox) findViewById(R.id.checkBox);
    guest = (CheckBox) findViewById(R.id.checkBox2);

    guest.setOnCheckedChangeListener(changeListener);
    anonymous.setOnCheckedChangeListener(changeListener);

    isMovie = getIntent().getExtras().getString("type").equals("movie");

    LocalBroadcastManager.getInstance(this).registerReceiver(mMessageReceiver,
            new IntentFilter("mizuu-network-search"));
}

From source file:com.module.candychat.net.view.custom.CaseInsensitiveAssetFontLoader.java

@Override
public Typeface getTypeFace(String typefaceName) {
    String lowerTypefaceName = typefaceName.toLowerCase();
    Typeface typeface = sTypefaceCache.get(lowerTypefaceName);

    if (typeface == null) {
        String fontFile = mTypefacenameMapping.get(lowerTypefaceName);

        try {//  w  w w.j  a v a 2  s . c  o  m
            typeface = Typeface.createFromAsset(mAssetManager, fontFile);
            sTypefaceCache.put(lowerTypefaceName, typeface);
        } catch (RuntimeException e) {
            return Typeface.DEFAULT;
        }
    }
    return typeface;
}

From source file:com.code.android.vibevault.FeaturedShowsScreen.java

@Override
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.featured_shows_screen);

    getMoreShowsButton = new Button(this);
    getMoreShowsButton.setText("More Featured Shows");
    getMoreShowsButton.setTextColor(Color.rgb(18, 125, 212));
    getMoreShowsButton.setTypeface(Typeface.DEFAULT, Typeface.BOLD);
    getMoreShowsButton.setPadding(0, 6, 0, 6);

    getMoreShowsButton.setOnClickListener(new OnClickListener() {
        @Override/*from  www .j a v a 2  s  .c om*/
        public void onClick(View v) {
            if (VibeVault.moreFeaturedShows.size() != 0) {
                fetchSelectedShows(VibeVault.moreFeaturedShows.get(0));
            } else {
                Toast.makeText(getBaseContext(), "More featured shows weekly...", Toast.LENGTH_SHORT).show();
            }
        }
    });

    this.featuredShowsList = (ListView) this.findViewById(R.id.SelectedShowsListView);
    featuredShowsList.addFooterView(getMoreShowsButton);
    if (VibeVault.featuredShows.size() == 0) {
        getMoreShowsButton.setVisibility(View.GONE);
    } else {
        getMoreShowsButton.setVisibility(View.VISIBLE);
    }
    featuredShowsList.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> a, View v, int position, long id) {
            ArchiveShowObj show = (ArchiveShowObj) featuredShowsList.getItemAtPosition(position);
            Intent i = new Intent(FeaturedShowsScreen.this, ShowDetailsScreen.class);
            i.putExtra("Show", show);
            startActivity(i);
        }
    });
    featuredShowsList.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {
        @Override
        public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
            menu.add(Menu.NONE, VibeVault.EMAIL_LINK, Menu.NONE, "Email Link to Show");
            menu.add(Menu.NONE, VibeVault.ADD_TO_FAVORITE_LIST, Menu.NONE, "Bookmark Show");
        }
    });

    Object retained = getLastNonConfigurationInstance();
    if (retained instanceof GetSelectedShowsListTask) {

        workerTask = (GetSelectedShowsListTask) retained;
        workerTask.setActivity(this);
    } else {
        workerTask = new GetSelectedShowsListTask(this);
        if (VibeVault.featuredShows.size() == 0) {
            this.fetchSelectedShows("http://andrewpearson.org/vibevault/shows/vvshows1");
        }
        this.refreshSelectedShowsList();
    }
}

From source file:info.degois.damien.android.CustomFontHtml.CaseInsensitiveAssetFontLoader.java

@Override
public Typeface getTypeFace(String typefaceName) {
    String lowerTypefaceName = typefaceName.toLowerCase();
    Typeface typeface = sTypefaceCache.get(lowerTypefaceName);

    if (typeface == null) {
        String fontFile = mTypefacenameMapping.get(lowerTypefaceName);

        try {//  ww  w .  j  ava 2 s . c om
            typeface = Typeface.createFromAsset(mAssetManager, fontFile);
            sTypefaceCache.put(lowerTypefaceName, typeface);
        } catch (java.lang.RuntimeException e) {
            return android.graphics.Typeface.DEFAULT;
        }
    }
    return typeface;
}

From source file:piuk.blockchain.android.util.ViewPagerTabs.java

@Override
protected void onDraw(final Canvas canvas) {
    super.onDraw(canvas);

    final int viewWidth = getWidth();
    final int viewHalfWidth = viewWidth / 2;
    final int viewBottom = getHeight();

    final float density = getResources().getDisplayMetrics().density;
    final float spacing = 32 * density;

    final Path path = new Path();
    path.moveTo(viewHalfWidth, viewBottom - 5 * density);
    path.lineTo(viewHalfWidth + 5 * density, viewBottom);
    path.lineTo(viewHalfWidth - 5 * density, viewBottom);
    path.close();/*from  www.j  a  va 2  s  .  com*/

    paint.setColor(Color.WHITE);
    canvas.drawPath(path, paint);

    paint.setTypeface(Typeface.DEFAULT_BOLD);
    final float y = getPaddingTop() + -paint.getFontMetrics().top;

    for (int i = 0; i < labels.size(); i++) {
        final String label = labels.get(i);

        paint.setTypeface(i == pagePosition ? Typeface.DEFAULT_BOLD : Typeface.DEFAULT);
        paint.setColor(i == pagePosition ? Color.BLACK : Color.DKGRAY);

        final float x = viewHalfWidth + (maxWidth + spacing) * (i - pageOffset);
        final float labelWidth = paint.measureText(label);
        final float labelHalfWidth = labelWidth / 2;

        final float labelLeft = x - labelHalfWidth;
        final float labelVisibleLeft = labelLeft >= 0 ? 1f : 1f - (-labelLeft / labelWidth);

        final float labelRight = x + labelHalfWidth;
        final float labelVisibleRight = labelRight < viewWidth ? 1f
                : 1f - ((labelRight - viewWidth) / labelWidth);

        final float labelVisible = Math.min(labelVisibleLeft, labelVisibleRight);

        paint.setAlpha((int) (labelVisible * 255));

        canvas.drawText(label, labelLeft, y, paint);
    }
}