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:com.physphil.android.restaurantroulette.RestaurantFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_restaurant, container, false);

    mTf = Typeface.createFromAsset(getActivity().getAssets(), Constants.FONT_DEFAULT);

    etName = (EditText) v.findViewById(R.id.restaurant_name);
    spinnerGenre = (Spinner) v.findViewById(R.id.spinner_restaurant_genre);
    rbUserRating = (RatingBar) v.findViewById(R.id.rating_bar_restaurant);
    rbPriceLevel = (RatingBar) v.findViewById(R.id.price_restaurant);
    etNotes = (EditText) v.findViewById(R.id.restaurant_notes);
    btnDirections = (Button) v.findViewById(R.id.btn_get_directions);

    setFonts(v);/* w  ww. j  a v a 2  s . c o  m*/

    return v;
}

From source file:com.example.igorklimov.popularmoviesdemo.activities.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //        Stetho.initializeWithDefaults(this);
    //        OkHttpClient client = new OkHttpClient();
    //        client.networkInterceptors().add(new StethoInterceptor());
    //        Stetho.initialize(
    //                Stetho.newInitializerBuilder(this)
    //                        .enableDumpapp(Stetho.defaultDumperPluginsProvider(this))
    //                        .enableWebKitInspector(Stetho.defaultInspectorModulesProvider(this))
    //                        .build());
    ///* ww  w . j  av  a  2 s.  c o m*/
    //        client.networkInterceptors().add(new StethoInterceptor());

    setContentView(R.layout.drawer);
    Utility.setIsTabletPreference(this, findViewById(R.id.details_fragment) != null);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    if (savedInstanceState == null)
        Utility.setSortByPreference(this, 1);

    SyncAdapter.initializeSyncAdapter(this);

    mDrawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, mDrawer, toolbar,
            R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    mDrawer.addDrawerListener(toggle);
    toggle.syncState();
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
    navigationView.setItemIconTintList(null);
    navigationView.setItemTextColor(null);
    Typeface typeface = Typeface.createFromAsset(getAssets(), "fonts/RemachineScript_Personal_Use.ttf");
    TextView title = (TextView) findViewById(R.id.app_title);
    if (title != null)
        title.setTypeface(typeface);

}

From source file:com.example.lowviscam.GalleryActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    isLight = getIntent().getExtras().getBoolean("isLight");
    if (isLight == false) {
        this.setTheme(R.style.AppBaseThemeDark);
    } else {/*  w  w  w.j  a va 2  s . c  o m*/
        this.setTheme(R.style.AppBaseTheme);
    }
    setContentView(R.layout.activity_gallery);

    // Retrieve APHont font and apply it
    mFace = Typeface.createFromAsset(getAssets(), "fonts/APHont-Regular_q15c.otf");
    SpannableString s = new SpannableString("Image Gallery");
    s.setSpan(new TypefaceSpan(this, "APHont-Bold_q15c.otf"), 0, s.length(),
            Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

    // Update the action bar title with the TypefaceSpan instance
    ActionBar actionBar = getActionBar();
    actionBar.setTitle(s);

    actionBar.setDisplayHomeAsUpEnabled(true);

    // Fetch the {@link LayoutInflater} service so that new views can be created
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    // Find the {@link GridView} that was already defined in the XML layout
    GridView gridView = (GridView) findViewById(R.id.grid);

    // Initialize the adapter with all the coupons. Set the adapter on the {@link GridView}.
    try {
        gridView.setAdapter(new CouponAdapter(inflater, createAllCoupons()));
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    // Set a click listener for each picture in the grid
    gridView.setOnItemClickListener(this);
    gridView.setOnTouchListener(new OnSwipeTouchListener() {

        public void onSwipeTop() {
            //Toast.makeText(GalleryActivity.this, "top", Toast.LENGTH_SHORT).show();
        }

        public void onSwipeRight() {
            //Toast.makeText(GalleryActivity.this, "right", Toast.LENGTH_SHORT).show();
        }

        public void onSwipeLeft() {
            //Toast.makeText(GalleryActivity.this, "left", Toast.LENGTH_SHORT).show();
        }

        public void onSwipeBottom() {
            //Toast.makeText(GalleryActivity.this, "bottom", Toast.LENGTH_SHORT).show();
        }

    });
    gridView.setOnItemLongClickListener(new OnItemLongClickListener() {

        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            // Find coupon that was clicked based off of position in adapter
            Coupon coupon = (Coupon) parent.getItemAtPosition(position);
            //Get absolutepath of image for adding.
            File list[] = mediaStorageDir.listFiles();
            File tmpFile = list[list.length - position - 1];
            String photoUri = coupon.mImageUri.toString();
            try {
                photoUri = MediaStore.Images.Media.insertImage(getContentResolver(), tmpFile.getAbsolutePath(),
                        null, null);
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            // Create share intent
            Intent shareIntent = ShareCompat.IntentBuilder.from(GalleryActivity.this).setText(coupon.mTitle)
                    .setType("image/jpeg").setStream(Uri.parse(photoUri))
                    .setChooserTitle(getString(R.string.share_using)).createChooserIntent();
            startActivity(shareIntent);

            return true;
        }
    });

}

From source file:com.example.xyzreader.cp4.ArticleDetailFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_article_detail, container, false);

    // Show the dummy content as text in a TextView.
    if (mItem != null) {
        ((TextView) rootView.findViewById(R.id.article_title)).setText(mItem.title);
        ((TextView) rootView.findViewById(R.id.article_byline))
                .setText(Html.fromHtml(mItem.time.toUpperCase(Locale.getDefault()) + " BY <font color='"
                        + getResources().getString(R.string.author_font_color) + "'>"
                        + mItem.author.toUpperCase(Locale.getDefault()) + "</a>"));
        ((TextView) rootView.findViewById(R.id.article_body)).setText(Html.fromHtml(mItem.content));
        ((TextView) rootView.findViewById(R.id.article_body))
                .setTypeface(Typeface.createFromAsset(getResources().getAssets(), "Rosario-Regular.ttf"));
        ((ImageView) rootView.findViewById(R.id.photo))
                .setImageDrawable(getResources().getDrawable(mItem.photoResId));
    }/*from www  .j  a va2  s . co m*/

    return rootView;
}

From source file:de.handler.mobile.android.weatherapp.app.ui.WeatherFragment.java

@AfterViews
void afterView() {
    locationButton.setOnClickListener(this);
    ccImageView.setOnClickListener(this);

    ArrayList<Bitmap> bitmaps = app.getImages();
    List<String> authors = app.getAuthors();
    // Get data from arguments bundle
    WeatherDataDaily weatherDataDaily = getArguments().getParcelable(WEATHER_DATA);
    mPosition = getArguments().getInt(POSITION);

    // prepare data
    OWMTemperature owmTemperature = weatherDataDaily.getList()[mPosition].getTemp();
    OWMResult[] weatherList = weatherDataDaily.getList();

    //Handle data
    //Background Image
    Bitmap background = null;/*from  w  w  w  .j  a v  a2 s  .co  m*/
    if (bitmaps != null && !(bitmaps.size() < mPosition)) {
        background = bitmaps.get(mPosition);
    }
    if (background != null) {
        fragmentBackground.setImageBitmap(background);
    } else {
        fragmentBackground.setImageResource(R.drawable.splash_small);
    }

    //Owner of picture
    if (authors != null && authors.size() >= mPosition) {
        copyright.setText(authors.get(mPosition) + " on ");
    }

    // Location
    if (!weatherDataDaily.getCity().getName().equals("")) {
        location.setText(weatherDataDaily.getCity().getName());

        // Days
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("EEEE");
        day.setText(String.valueOf(simpleDateFormat.format(weatherList[mPosition].getDate() * 1000)));
        // Dates
        simpleDateFormat = new SimpleDateFormat("dd.MM.yyyy");
        date.setText(String.valueOf(simpleDateFormat.format(weatherList[mPosition].getDate() * 1000)));
        // Create custom typeface
        Typeface myTypeface = Typeface.createFromAsset(getActivity().getAssets(), "fonts/WeatherIcons.ttf");
        String iconString = IconHandler.getIcon(weatherList[mPosition].getWeather()[0].getIcon());
        icon.setText(iconString);
        icon.setTypeface(myTypeface);

        temperature.setText(
                String.valueOf((int) owmTemperature.getMin()) + " / " + (int) owmTemperature.getMax() + " C");
        condition.setText(weatherList[mPosition].getWeather()[0].getDescription());
        humidity.setText(String.valueOf((int) weatherList[mPosition].getHumidity()) + " %");

    } else {
        location.setText(getString(R.string.location_unknown));
        day.setVisibility(View.INVISIBLE);
        date.setVisibility(View.INVISIBLE);
        icon.setVisibility(View.INVISIBLE);
        temperature.setVisibility(View.INVISIBLE);
        condition.setVisibility(View.INVISIBLE);
        humidityIcon.setVisibility(View.INVISIBLE);
        humidity.setVisibility(View.INVISIBLE);
    }
}

From source file:tech.salroid.filmy.activities.MainActivity.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 a  v  a2  s .  c  om*/
        setTheme(R.style.AppTheme_Base);

    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_main);
    ButterKnife.bind(this);

    setSupportActionBar(toolbar);

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

    introLogic();

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

    if (nightMode)
        allThemeLogic();

    mErrorView.setConfig(ErrorView.Config.create().title(getString(R.string.error_title_damn))
            .titleColor(ContextCompat.getColor(this, R.color.dark)).subtitle(getString(R.string.error_details))
            .retryText(getString(R.string.error_retry)).build());

    mErrorView.setOnRetryListener(new ErrorView.RetryListener() {
        @Override
        public void onRetry() {

            if (Network.isNetworkConnected(MainActivity.this)) {

                fetchingFromNetwork = true;

                setScheduler();

            }

            canProceed();

        }
    });

    mErrorView.setVisibility(View.GONE);

    setupViewPager(viewPager);
    tabLayout.setupWithViewPager(viewPager);

    materialSearchView.setVoiceSearch(true);
    materialSearchView.setOnQueryTextListener(new MaterialSearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            //Do some magic

            getSearchedResult(query);
            searchFragment.showProgress();

            return true;
        }

        @Override
        public boolean onQueryTextChange(String newText) {

            //getSearchedResult(newText);
            return true;

        }
    });

    materialSearchView.setOnSearchViewListener(new MaterialSearchView.SearchViewListener() {
        @Override
        public void onSearchViewShown() {
            //Do some magic

            tabLayout.setVisibility(View.GONE);

            disableToolbarScrolling();

            searchFragment = new SearchFragment();
            getSupportFragmentManager().beginTransaction().replace(R.id.search_container, searchFragment)
                    .commit();

        }

        @Override
        public void onSearchViewClosed() {
            //Do some magic

            getSupportFragmentManager().beginTransaction().remove(searchFragment).commit();

            if (!cantProceed)
                tabLayout.setVisibility(View.VISIBLE);

            enableToolbarScrolling();

        }
    });

    if (Network.isNetworkConnected(this)) {

        fetchingFromNetwork = true;
        setScheduler();
    }

}

From source file:com.example.xyzreader.cp3.ArticleDetailFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_article_detail, container, false);

    // Show the dummy content as text in a TextView.
    if (mItem != null) {
        ((TextView) rootView.findViewById(R.id.article_title)).setText(mItem.title);
        ((TextView) rootView.findViewById(R.id.article_byline))
                .setText(Html.fromHtml(mItem.time.toUpperCase(Locale.getDefault()) + " BY <font color='"
                        + getResources().getString(R.string.author_font_color) + "'>"
                        + mItem.author.toUpperCase(Locale.getDefault()) + "</a>"));
        //            ((TextView) rootView.findViewById(R.id.article_date))
        //                    .setText(mItem.time);
        ((TextView) rootView.findViewById(R.id.article_body)).setText(Html.fromHtml(mItem.content));
        ((TextView) rootView.findViewById(R.id.article_body))
                .setTypeface(Typeface.createFromAsset(getResources().getAssets(), "Rosario-Regular.ttf"));
        ((ImageView) rootView.findViewById(R.id.photo))
                .setImageDrawable(getResources().getDrawable(mItem.photoResId));
    }//from   w  w  w .  j  a va 2 s . c o m

    return rootView;
}

From source file:br.com.GUI.avaliacoes.AvaliacoesAluno.java

public void mapearComponentes() {
    b = new Banco(this, null, null, 0);
    pref = this.getApplicationContext().getSharedPreferences("MyPref", 0);
    Typeface font = Typeface.createFromAsset(this.getAssets(), "BebasNeue Bold.ttf");
    lstMinhasAvaliacoes = (ListView) this.findViewById(R.id.lstMinhasAvaliacoes);
    lstMinhasAvaliacoes.setDivider(null);
    usuarioAluno = getIntent().getExtras().getString("usuario");
    /*/* w  w  w .  j  a  v a  2 s.com*/
    avaliacoesAluno.setChecked(false);
            
    if(pref.getString("tipo", null).equals("aluno")){
       avaliacoesPersonal.setVisibility(View.GONE);
       avaliacoesAluno.setVisibility(View.GONE);
            
       atualizarAvaliacoesPessoaisAlunos("");
       setHasOptionsMenu(false);
    }
            
    //listeners
            
    avaliacoesPersonal.setOnCheckedChangeListener(new OnCheckedChangeListener() {
               
       @Override
       public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
    if(isChecked){
       avaliacoesAluno.setChecked(false);
       atualizarAvaliacoesPersonal("");
    }
            
       }
    });
            
    avaliacoesAluno.setOnCheckedChangeListener(new OnCheckedChangeListener() {
               
       @Override
       public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
    if(isChecked){
       avaliacoesPersonal.setChecked(false);
       atualizarAvaliacoesAluno("");
    }
            
       }
    });
            
    avaliacoesPersonal.setChecked(true);
    atualizarAvaliacoesPersonal("");*/
}

From source file:co.dilaver.quoter.activities.ShareActivity.java

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

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);//from www  .  j a v  a  2 s  .com

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

    storage = new SharedPrefStorage(this);

    chooseTextColor = (FButton) findViewById(R.id.btChooseTextColor);
    chooseBackgroundColor = (FButton) findViewById(R.id.btChooseBackgroundColor);
    chooseTextFont = (FButton) findViewById(R.id.btChooseTextFont);
    chooseQuoteTextSize = (SeekBar) findViewById(R.id.sbChooseQuoteTextSize);
    chooseAuthorTextSize = (SeekBar) findViewById(R.id.sbChooseAuthorTextSize);
    quoteTextSizeDisplay = (TextView) findViewById(R.id.tvQuoteTextSizeDisplay);
    authorTextSizeDisplay = (TextView) findViewById(R.id.tvAuthorTextSizeDisplay);

    previewLayout = (RelativeLayout) findViewById(R.id.rlPreviewLayout);
    finalImage = (ImageView) findViewById(R.id.ivPreviewBackground);
    previewQuote = (TextView) findViewById(R.id.tvPreviewQuote);
    previewAuthor = (TextView) findViewById(R.id.tvPreviewAuthor);

    textFontAdapter = new TextFontAdapter(this);

    chooseTextColor.setOnClickListener(this);
    chooseBackgroundColor.setOnClickListener(this);
    chooseTextFont.setOnClickListener(this);
    chooseQuoteTextSize.setOnSeekBarChangeListener(this);
    chooseAuthorTextSize.setOnSeekBarChangeListener(this);

    chooseQuoteTextSize.setProgress(25);
    chooseAuthorTextSize.setProgress(15);

    Typeface typeface = Typeface.createFromAsset(getAssets(), storage.getQodFont());
    finalImage.setBackgroundColor(ContextCompat.getColor(this, R.color.colorPrimary));
    previewQuote.setText(getIntent().getStringExtra("quote"));
    previewAuthor.setText(getIntent().getStringExtra("author"));
    previewQuote.setTextColor(Color.WHITE);
    previewAuthor.setTextColor(Color.WHITE);
    previewQuote.setTextSize(25);
    previewAuthor.setTextSize(15);
    previewQuote.setTypeface(typeface);
    previewAuthor.setTypeface(typeface);
    chooseTextFont.setTypeface(typeface);
}

From source file:com.cloverstudio.spika.SpikaApp.java

@Override
public void onCreate() {
    super.onCreate();
    sInstance = this;
    mPreferences = new Preferences(this);
    mPreferences.clearFlagsForTutorialEachBoot(getApplicationContext().getPackageName());
    gOpenFromBackground = true;/*from   w  ww .  j  a  v a2  s  .  co m*/
    mFileDir = new FileDir(this);

    ImageLoader.initImageLoaderInstance(this);

    mLocalBroadcastManager = LocalBroadcastManager.getInstance(this);

    // Create typefaces
    mTfMyriadPro = Typeface.createFromAsset(getAssets(), "fonts/Roboto-Regular.ttf");
    mTfMyriadProBold = Typeface.createFromAsset(getAssets(), "fonts/Roboto-Bold.ttf");

    setTransportBasedOnScreenDensity(42);

    // Example interpolator; could use linear or accelerate interpolator
    // instead
    final AccelerateDecelerateInterpolator accDecInterpolator = new AccelerateDecelerateInterpolator();
    final LinearInterpolator linearInterpolator = new LinearInterpolator();
    final int slidingDuration = getResources().getInteger(R.integer.sliding_duration);

    // Set up animations
    mSlideInLeft = new TranslateAnimation(-mTransport, 0, 0, 0);
    mSlideInLeft.setDuration(slidingDuration);
    // mSlideInLeft.setFillAfter(true); // hmm not sure
    mSlideInLeft.setFillEnabled(false);
    mSlideInLeft.setInterpolator(linearInterpolator);

    mSlideOutRight = new TranslateAnimation(0, mTransport, 0, 0);
    mSlideOutRight.setDuration(slidingDuration);
    mSlideOutRight.setFillAfter(true);
    mSlideOutRight.setFillEnabled(true);
    mSlideOutRight.setInterpolator(linearInterpolator);

    mSlideOutLeft = new TranslateAnimation(0, -mTransport, 0, 0);
    mSlideOutLeft.setDuration(slidingDuration);
    mSlideOutLeft.setInterpolator(linearInterpolator);

    mSlideInRight = new TranslateAnimation(mTransport, 0, 0, 0);
    mSlideInRight.setDuration(slidingDuration);
    mSlideInRight.setFillAfter(true);
    mSlideInRight.setFillEnabled(true);
    mSlideInRight.setInterpolator(linearInterpolator);

    mSlideFromTop.setFillAfter(true);
    mSlideFromTop.setFillEnabled(true);
    mSlideFromTop.setDuration(this.getResources().getInteger(android.R.integer.config_mediumAnimTime));
    mSlideFromTop.setInterpolator(linearInterpolator);

    mSlideOutTop.setDuration(this.getResources().getInteger(android.R.integer.config_mediumAnimTime));
    mSlideOutTop.setInterpolator(linearInterpolator);

    String strUUID = UUID.randomUUID().toString();
    Logger.debug("uuid", strUUID);

    mBaseUrl = mPreferences.getUserServerURL();
}