Example usage for android.graphics Typeface createFromAsset

List of usage examples for android.graphics Typeface createFromAsset

Introduction

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

Prototype

public static Typeface createFromAsset(AssetManager mgr, String path) 

Source Link

Document

Create a new typeface from the specified font data.

Usage

From source file:aerizostudios.com.cropshop.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    fragmentManager = getSupportFragmentManager();
    initMenuFragment();/*  w w w.j  a  v a2s  .  c  o m*/

    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    toolbarText = (TextView) findViewById(R.id.toolbarText);

    //shared pref
    if (isFirstTime()) {
        prefs = getSharedPreferences(prefName, MODE_PRIVATE);
        SharedPreferences.Editor editor = prefs.edit();
        editor.putInt("res", 300);
        editor.commit();

    }

    prefs = getSharedPreferences(prefName, MODE_PRIVATE);
    quality = prefs.getInt("res", 300);

    Typeface billabong = Typeface.createFromAsset(getAssets(), "fonts/Billabong.ttf");

    toolbarText.setTypeface(billabong);

    cropButton = (FancyButton) findViewById(R.id.OpenPhotoButton);
    followButton = (FancyButton) findViewById(R.id.FollowButton);

    followButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Uri uri = Uri.parse("http://instagram.com/_u/crop__shop");
            Intent likeIng = new Intent(Intent.ACTION_VIEW, uri);

            likeIng.setPackage("com.instagram.android");

            try {
                startActivity(likeIng);
            } catch (ActivityNotFoundException e) {
                startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://instagram.com/crop__shop")));
            }

        }
    });
    cropButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            startActivityForResult(GetImageFromGallery.getPickImageIntent(MainActivity.this), REQUEST_PICTURE);

        }
    });

    mLayout = (SlidingUpPanelLayout) findViewById(R.id.sliding_layout);

    mLayout.setTouchEnabled(true);
    mLayout.setPanelSlideListener(new SlidingUpPanelLayout.PanelSlideListener() {
        @Override
        public void onPanelSlide(View panel, float slideOffset) {
            if (mLayout != null) {
                if (mLayout.getAnchorPoint() == 1.0f) {
                    mLayout.setAnchorPoint(0.7f);
                    mLayout.setPanelState(SlidingUpPanelLayout.PanelState.ANCHORED);
                } else {
                    mLayout.setAnchorPoint(1.0f);
                    mLayout.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED);
                }
            }
        }

        @Override
        public void onPanelExpanded(View panel) {
            getSupportActionBar().hide();
        }

        @Override
        public void onPanelCollapsed(View panel) {
            getSupportActionBar().show();
        }

        @Override
        public void onPanelAnchored(View panel) {
            getSupportActionBar().show();
        }

        @Override
        public void onPanelHidden(View panel) {

        }
    });

    final ListView friends = (ListView) findViewById(R.id.flipAbout);

    FlipSettings settings = new FlipSettings.Builder().defaultPage(1).build();
    friends.setAdapter(new FriendsAdapter(this, Utils.friends, settings));

}

From source file:com.janacare.walkmeter.MainActivity.java

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

    vPref = getApplicationContext().getSharedPreferences(ActivityUtils.SHARED_PREFERENCES,
            Context.MODE_PRIVATE);

    // Set the main layout

    requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
    setContentView(R.layout.pedometer);//from w w w. j a v  a 2 s  .c om

    getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.window_title);

    showStepsToday = (TextView) findViewById(R.id.tvStepsToday);
    showStepsYesterday = (TextView) findViewById(R.id.tvStepsYesterday);
    showStepsHighest = (TextView) findViewById(R.id.tvStepsHighest);
    btnCount = (Button) findViewById(R.id.btnCount);
    tvwindow_title = (TextView) findViewById(R.id.tvwindow_tite);
    tvtodayAfter = (TextView) findViewById(R.id.tvStepsTodayAfter);
    headToday = (TextView) findViewById(R.id.tvStepsToday1);
    headYesterday = (TextView) findViewById(R.id.tvStepsYesterday2);
    headHighest = (TextView) findViewById(R.id.tvStepsHighest3);

    Typeface regular = Typeface.createFromAsset(getAssets(), "Roboto-Regular.ttf");
    Typeface thin = Typeface.createFromAsset(getAssets(), "Roboto-Thin.ttf");

    tvwindow_title.setTypeface(regular);
    showStepsToday.setTypeface(thin);
    showStepsYesterday.setTypeface(thin);
    showStepsHighest.setTypeface(thin);

    tvtodayAfter.setTypeface(regular);
    headToday.setTypeface(regular);
    headYesterday.setTypeface(regular);
    headHighest.setTypeface(regular);
    btnCount.setTypeface(regular);

    int i = vPref.getInt(Constants.KEY_STEPS_TODAY, 0);
    int j = vPref.getInt("steps_yesterday", 0);
    int k = vPref.getInt("minutes_highest", i);
    Log.d("step  in", Long.toString(i));
    Log.d("show steps", "showStepsToday: " + showStepsToday);

    showStepsToday.setText(Integer.toString(i));
    showStepsYesterday.setText(Integer.toString(j));
    showStepsHighest.setText(Integer.toString(k));

    mBroadcastManager = LocalBroadcastManager.getInstance(this);

    // Create a new Intent filter for the broadcast receiver
    mBroadcastFilter = new IntentFilter(ActivityUtils.ACTION_REFRESH_STATUS_LIST);
    mBroadcastFilter.addCategory(ActivityUtils.CATEGORY_LOCATION_SERVICES);

    // Get detection requester and remover objects
    mDetectionRequester = new DetectionRequester(this);
    mDetectionRemover = new DetectionRemover(this);

    // Create a new LogFile object
    mLogFile = LogFile.getInstance(this);

    btnCount.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub

            Log.d(TAG, "before btn action" + vPref.getBoolean("btnFlag", false));

            Editor editor = vPref.edit();

            if (!vPref.getBoolean("btnFlag", false)) {

                Log.d(TAG, "first time btn pressed");
                if (!servicesConnected()) {
                    return;
                }
                mRequestType = ActivityUtils.REQUEST_TYPE.ADD;
                mDetectionRequester.requestUpdates();
                btnCount.setText("Stop Counting");

                editor.putBoolean("btnFlag", true);
                editor.commit();

                Log.d(TAG, "" + vPref.getBoolean("btnFlag", false));
            } else {

                Log.d(TAG, "in onClick after btn shows stop counting");
                if (!servicesConnected()) {

                    return;
                }

                mRequestType = ActivityUtils.REQUEST_TYPE.REMOVE;
                PendingIntent pendingIntent = mDetectionRequester.getRequestPendingIntent();

                if (pendingIntent == null) {
                    Intent intent = new Intent(getApplicationContext(), ActivityRecognitionIntentService.class);
                    pendingIntent = PendingIntent.getService(getApplicationContext(), 0, intent,
                            PendingIntent.FLAG_UPDATE_CURRENT);
                }

                if (pendingIntent != null) {
                    // Pass the remove request to the remover object
                    mDetectionRemover.removeUpdates(pendingIntent);
                    pendingIntent.cancel();
                }

                editor.putBoolean("btnFlag", false);
                editor.commit();
                btnCount.setText("Start Counting!");
            }

        }
    });

}

From source file:tech.salroid.filmy.activities.SavedMovies.java

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

    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
    nightMode = sp.getBoolean("dark", false);
    if (nightMode)
        setTheme(R.style.AppTheme_Base_Dark);
    else//from   w ww.java 2s. c  o  m
        setTheme(R.style.AppTheme_Base);

    setContentView(R.layout.activity_saved_movies);

    ButterKnife.bind(this);

    setSupportActionBar(toolbar);

    if (getSupportActionBar() != null) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setTitle("");
    }

    Typeface typeface = Typeface.createFromAsset(getAssets(), "fonts/canaro_extra_bold.otf");
    logo.setTypeface(typeface);

    if (nightMode)
        allThemeLogic();

    /*GridLayoutManager gridLayoutManager = new GridLayoutManager(this, 3);
    my_saved_movies_recycler.setLayoutManager(gridLayoutManager);*/

    boolean tabletSize = getResources().getBoolean(R.bool.isTablet);

    if (tabletSize) {

        if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {

            StaggeredGridLayoutManager gridLayoutManager = new StaggeredGridLayoutManager(6,
                    StaggeredGridLayoutManager.VERTICAL);
            my_saved_movies_recycler.setLayoutManager(gridLayoutManager);
        } else {
            StaggeredGridLayoutManager gridLayoutManager = new StaggeredGridLayoutManager(8,
                    StaggeredGridLayoutManager.VERTICAL);
            my_saved_movies_recycler.setLayoutManager(gridLayoutManager);
        }

    } else {

        if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {

            StaggeredGridLayoutManager gridLayoutManager = new StaggeredGridLayoutManager(3,
                    StaggeredGridLayoutManager.VERTICAL);
            my_saved_movies_recycler.setLayoutManager(gridLayoutManager);
        } else {
            StaggeredGridLayoutManager gridLayoutManager = new StaggeredGridLayoutManager(5,
                    StaggeredGridLayoutManager.VERTICAL);
            my_saved_movies_recycler.setLayoutManager(gridLayoutManager);
        }

    }

    mainActivityAdapter = new SavedMoviesAdapter(this, null);
    my_saved_movies_recycler.setAdapter(mainActivityAdapter);
    mainActivityAdapter.setClickListener(this);
    mainActivityAdapter.setLongClickListener(this);

    getSupportLoaderManager().initLoader(SAVED_DETAILS_LOADER, null, this);

}

From source file:tech.salroid.filmy.activities.CharacterDetailsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
    nightMode = sp.getBoolean("dark", false);
    if (nightMode)
        setTheme(R.style.AppTheme_Base_Dark);
    else/* w w  w. j  av a 2 s . c  o m*/
        setTheme(R.style.AppTheme_Base);

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_detailed_cast);
    ButterKnife.bind(this);

    setSupportActionBar(toolbar);

    if (getSupportActionBar() != null)
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setTitle("");

    Typeface typeface = Typeface.createFromAsset(getAssets(), "fonts/canaro_extra_bold.otf");
    logo.setTypeface(typeface);

    if (nightMode)
        allThemeLogic();

    more.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

            if (!(movie_json == null && character_title == null)) {
                Intent intent = new Intent(CharacterDetailsActivity.this, FullMovieActivity.class);
                intent.putExtra("cast_json", movie_json);
                intent.putExtra("toolbar_title", character_title);
                startActivity(intent);

            }

        }
    });

    char_recycler.setLayoutManager(new LinearLayoutManager(CharacterDetailsActivity.this));
    char_recycler.setNestedScrollingEnabled(false);

    headerContainer.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

            if (character_title != null && character_bio != null) {

                fullReadFragment = new FullReadFragment();
                Bundle args = new Bundle();
                args.putString("title", character_title);
                args.putString("desc", character_bio);

                fullReadFragment.setArguments(args);

                getSupportFragmentManager().beginTransaction().replace(R.id.main, fullReadFragment, "DESC")
                        .commit();
            }

        }
    });

    Intent intent = getIntent();
    if (intent != null) {
        character_id = intent.getStringExtra("id");
    }

    getDetailedMovieAndCast();

}

From source file:edu.mecc.race2ged.helpers.Utils.java

/**
 * Sets the font of a view to Roboto-Bold
 * @param context The context of the activity.
 * @param view The view that will use Roboto-Bold
 *//*from ww w.j a v  a  2  s .c o m*/
public static void setRobotoBold(Context context, View view) {
    if (sRobotoBold == null) {
        sRobotoBold = Typeface.createFromAsset(context.getAssets(), "Roboto-Bold.ttf");
    }
    setFont(view, sRobotoBold);
}

From source file:id.co.datascrip.dtswarehousesystem.activity.Form_Scan_Scandid.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    bundle = getIntent().getBundleExtra("bundle");
    initScanner();/*from   w w w  . ja v  a2s .  co m*/

    RelativeLayout overlayView = mPicker.getOverlayView();
    final FloatingActionButton floatingActionButton = new FloatingActionButton(this);
    floatingActionButton.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_create_white_18dp));

    ShitTextView tx_title = new ShitTextView(this);
    tx_title.setText(bundle.getString("TitleScan"));
    ShitTextView tx_input_manual = new ShitTextView(this);
    tx_input_manual.setText(bundle.getString("TitleInput").trim().replace(":", ""));

    floatingActionButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Dialog_Input_Manual dialog = new Dialog_Input_Manual(Form_Scan_Scandid.this, bundle);
            dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
                @Override
                public void onDismiss(DialogInterface dialog) {
                    if (!Function.isEmpty(no)) {
                        Intent intent = new Intent();
                        intent.putExtra(getString(R.string.intent_result_scan), no);
                        setResult(RESULT_OK, intent);
                        no = "";
                        finish();
                    }
                }
            });
        }
    });

    RelativeLayout.LayoutParams rParams = new RelativeLayout.LayoutParams(
            AppBarLayout.LayoutParams.WRAP_CONTENT, AppBarLayout.LayoutParams.WRAP_CONTENT);
    rParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    rParams.topMargin = 60;
    rParams.rightMargin = 20;

    RelativeLayout.LayoutParams infoParam = new RelativeLayout.LayoutParams(
            AppBarLayout.LayoutParams.WRAP_CONTENT, AppBarLayout.LayoutParams.WRAP_CONTENT);
    infoParam.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    infoParam.topMargin = 20;
    infoParam.rightMargin = 10;
    tx_input_manual.setTextColor(ContextCompat.getColor(this, R.color.GREEN));
    tx_title.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/Felbridge-Light.otf"));

    RelativeLayout.LayoutParams titleParam = new RelativeLayout.LayoutParams(
            AppBarLayout.LayoutParams.MATCH_PARENT, AppBarLayout.LayoutParams.WRAP_CONTENT);
    titleParam.topMargin = 300;
    titleParam.leftMargin = 50;
    tx_title.setTextSize(24);
    tx_title.setTextColor(ContextCompat.getColor(this, R.color.GREEN));
    tx_title.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/Felbridge-Bold.otf"));

    overlayView.addView(floatingActionButton, rParams);
    overlayView.addView(tx_input_manual, infoParam);
    overlayView.addView(tx_title, titleParam);
}

From source file:com.semfapp.adamdilger.semf.Take5PdfDocument.java

public Take5PdfDocument(Context appContext) {
    can = new Canvas();
    mContext = appContext;/*from   w w w  .ja  va 2  s  .c  om*/

    //        FONT11 = mContext.getResources().getDimensionPixelSize(R.dimen.font_11);
    //        FONT12 = mContext.getResources().getDimensionPixelSize(R.dimen.font_12);
    //        FONT14 = mContext.getResources().getDimensionPixelSize(R.dimen.font_14);
    //        FONT16 = mContext.getResources().getDimensionPixelSize(R.dimen.font_16);

    FONT11 = 10;
    FONT12 = 11;
    FONT14 = 13;
    FONT16 = 15;

    Take5Data d = Take5Data.get(appContext);

    mCheckBoxSectionOne = d.getSectionOneCheckBoxs();
    mCheckBoxSectionTwo = d.getSectionTwoCheckBoxs();
    mCheckBoxSectionThree = d.getSectionThreeCheckBoxs();
    mEditTextValues = d.getEditTexts();
    mDate = d.getDate();
    mRiskElements = d.getRiskElements();
    setDateTime(mDate);

    //Create custom font Typefaces
    impact = Typeface.createFromAsset(appContext.getAssets(), "impact.ttf");
    roboto = Typeface.createFromAsset(appContext.getAssets(), "Roboto-LightItalic.ttf");
    carlitoBold = Typeface.createFromAsset(appContext.getAssets(), "Carlito-Bold.ttf");
}

From source file:com.github.antoniodisanto92.swipeselector.SwipeAdapter.java

private SwipeAdapter(ViewPager viewPager, ViewGroup indicatorContainer, int indicatorSize, int indicatorMargin,
        int inActiveIndicatorColor, int activeIndicatorColor, int leftButtonResource, int rightButtonResource,
        ImageView leftButton, ImageView rightButton, String customFontPath, int titleTextAppearance,
        int descriptionTextAppearance, int descriptionGravity) {
    mContext = viewPager.getContext();// www  .  j  a  v a2 s .c o m

    mViewPager = viewPager;
    mViewPager.addOnPageChangeListener(this);

    mIndicatorContainer = indicatorContainer;
    mCircleParams = new LinearLayout.LayoutParams(indicatorSize, indicatorSize);
    mCircleParams.leftMargin = indicatorMargin;

    mInActiveCircleDrawable = Indicator.newOne(indicatorSize, inActiveIndicatorColor);
    mActiveCircleDrawable = Indicator.newOne(indicatorSize, activeIndicatorColor);

    if (customFontPath != null
            && ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB && !customFontPath.isEmpty())
                    || customFontPath.length() > 0)) {
        mCustomTypeFace = Typeface.createFromAsset(mContext.getAssets(), customFontPath);
    }

    mTitleTextAppearance = titleTextAppearance;
    mDescriptionTextAppearance = descriptionTextAppearance;
    mDescriptionGravity = getGravity(descriptionGravity);

    mLeftButton = leftButton;
    mLeftButton.setImageResource(leftButtonResource);

    mRightButton = rightButton;
    mRightButton.setImageResource(rightButtonResource);

    // Calculate paddings for the content so the left and right buttons
    // don't overlap.
    mSweetSixteen = (int) PixelUtils.dpToPixel(mContext, 16);
    mContentLeftPadding = ContextCompat.getDrawable(mContext, leftButtonResource).getIntrinsicWidth()
            + mSweetSixteen;
    mContentRightPadding = ContextCompat.getDrawable(mContext, rightButtonResource).getIntrinsicWidth()
            + mSweetSixteen;

    mLeftButton.setOnClickListener(this);
    mRightButton.setOnClickListener(this);

    mLeftButton.setTag(TAG_HIDDEN);
    mLeftButton.setClickable(false);

    setAlpha(0.0f, mLeftButton);
}

From source file:br.com.GUI.perfil.MeuPersonal.java

public void mapearComponentes() {
    pref = getActivity().getApplicationContext().getSharedPreferences("MyPref", 0);
    b = new Banco(getActivity(), null, null, 0);
    foto = (ImageView) getActivity().findViewById(R.id.imgFotoMeuPersonal);
    usuario = (TextView) getActivity().findViewById(R.id.infoUsuarioMeuPersonal);
    nome = (TextView) getActivity().findViewById(R.id.infoNomeMeuPersonal);
    dataDeNascimento = (TextView) getActivity().findViewById(R.id.infoDataDeNascimentoMeuPersonal);
    sexo = (TextView) getActivity().findViewById(R.id.infoSexoMeuPersonal);
    email = (TextView) getActivity().findViewById(R.id.infoEmailMeuPersonal);
    adicionarRemover = (Button) getActivity().findViewById(R.id.btnAdicionarRemover);
    Typeface font = Typeface.createFromAsset(getActivity().getAssets(), "BebasNeue Bold.ttf");
    adicionarRemover.setTypeface(font);//from   w  ww. ja  v a  2 s . com

    adicionarRemover.setVisibility(View.GONE);
}

From source file:hongik.android.project.best.HistoryActivity.java

public void drawHistory() {
    int rowCnt = historyTable.getChildCount();
    Log.i("ROWCOUNT", rowCnt + "");
    String query = "func=history&cid=" + cid;
    DBConnector conn = new DBConnector(query);
    conn.start();/*from  w ww . jav a 2  s  .c  o m*/

    try {
        conn.join();
        JSONObject jsonResult = conn.getResult();
        boolean result = (boolean) jsonResult.get("result");

        if (!result)
            return;

        TableRow motive = (TableRow) historyTable.getChildAt(1);
        JSONArray jsonArray = jsonResult.getJSONArray("values");

        for (int i = 0; i < jsonArray.length(); i++) {
            TableRow tbRow = new TableRow(this);
            final TextViewPlus[] tbCols = new TextViewPlus[4];
            JSONObject json = jsonArray.getJSONObject(i);
            String[] elements = new String[4];

            elements[0] = json.getString("SNAME");
            elements[1] = Double.parseDouble(json.getString("GRADE")) + "";
            elements[2] = json.getString("NOTE");
            elements[3] = json.getString("DAY");
            final String license = json.getString("LICENSE#");

            if (elements[2].length() > 14)
                elements[2] = elements[2].substring(0, 14) + "...";

            for (int j = 0; j < 4; j++) {
                tbCols[j] = new TextViewPlus(this);
                tbCols[j].setText(elements[j]);
                tbCols[j].setLayoutParams(motive.getChildAt(j).getLayoutParams());
                tbCols[j].setGravity(Gravity.CENTER);
                tbCols[j].setTypeface(Typeface.createFromAsset(tbCols[j].getContext().getAssets(),
                        "InterparkGothicBold.ttf"));
                final HistoryActivity originActivity = this;
                tbCols[j].setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Intent reviewIntent = new Intent(originActivity, ReviewDetailActivity.class);
                        reviewIntent.putExtra("ACCESS", "HISTORY");
                        reviewIntent.putExtra("CID", cid);
                        reviewIntent.putExtra("LICENSE", license);
                        startActivity(reviewIntent);
                    }
                });

                Log.i("History", "COL" + j + ":" + elements[j]);

                tbRow.addView(tbCols[j]);
            }
            historyTable.addView(tbRow);
        }
        for (int i = 1; i < rowCnt; i++) {
            historyTable.removeViewAt(1);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}