List of usage examples for android.graphics Typeface createFromAsset
public static Typeface createFromAsset(AssetManager mgr, String path)
From source file:info.tellmetime.DaydreamService.java
private void inflateMinutesIndicators() { FrameLayout minutesLayout = (FrameLayout) findViewById(R.id.minutes_indicators); minutesLayout.removeAllViews();// w ww .jav a 2s . co m LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); final boolean isLandscape = getResources() .getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE; inflater.inflate(isLandscape ? R.layout.minutes_land : R.layout.minutes_portrait, minutesLayout); RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams( FrameLayout.LayoutParams.MATCH_PARENT, isLandscape ? FrameLayout.LayoutParams.MATCH_PARENT : FrameLayout.LayoutParams.WRAP_CONTENT); if (!isLandscape) { layoutParams.addRule(RelativeLayout.BELOW, R.id.clock); layoutParams.topMargin = (int) -TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, mMinutesSize / 3, getResources().getDisplayMetrics()); } minutesLayout.setLayoutParams(layoutParams); Typeface mTypefaceBold = Typeface.createFromAsset(getAssets(), "Roboto-BoldCondensed.ttf"); ViewGroup minutesDots = (ViewGroup) findViewById(R.id.minutes_dots); for (int i = 0; i < minutesDots.getChildCount(); i++) { TextView m = (TextView) minutesDots.getChildAt(i); m.setTypeface(mTypefaceBold); m.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mMinutesSize); m.setTextColor(mBacklightColor); m.setShadowLayer(mShorterEdge / 200 * mDensity, 0, 0, mBacklightColor); } }
From source file:com.elpstudio.player.externals.Common.java
@Override public void onCreate() { super.onCreate(); //Application context. mContext = getApplicationContext();//from w ww . ja v a 2 s . c o m sInstance = this; light = Typeface.createFromAsset(getApplicationContext().getAssets(), "segoeuil.ttf"); reg = Typeface.createFromAsset(getApplicationContext().getAssets(), "segoeui.ttf"); //SharedPreferences. mSharedPreferences = this.getSharedPreferences("com.jams.music.player", Context.MODE_PRIVATE); //Init the database. mDBAccessHelper = new DBAccessHelper(mContext); //Playback kickstarter. //mPlaybackKickstarter = new PlaybackKickstarter(this.getApplicationContext()); //Picasso. // mPicasso = new Picasso.Builder(mContext).build(); //ImageLoader. mImageLoader = ImageLoader.getInstance(); mImageLoaderConfiguration = new ImageLoaderConfiguration.Builder(getApplicationContext()) .memoryCache(new WeakMemoryCache()).memoryCacheSizePercentage(13) .imageDownloader(new ByteArrayUniversalImageLoader(mContext)).build(); mImageLoader.init(mImageLoaderConfiguration); //Init DisplayImageOptions. initDisplayImageOptions(); //Log the user into Google Play Music only if the account is currently set up and active. if (mSharedPreferences.getBoolean("GOOGLE_PLAY_MUSIC_ENABLED", false) == true) { //Create a temp WebView to retrieve the user agent string. String userAgentString = ""; if (mSharedPreferences.getBoolean("GOT_USER_AGENT", false) == false) { WebView webView = new WebView(getApplicationContext()); webView.setVisibility(View.GONE); webView.loadUrl("http://www.google.com"); userAgentString = webView.getSettings().getUserAgentString(); mSharedPreferences.edit().putBoolean("GOT_USER_AGENT", true).commit(); mSharedPreferences.edit().putString("USER_AGENT", userAgentString).commit(); webView = null; } /*setGMusicClientCalls(GMusicClientCalls.getInstance(getApplicationContext())); GMusicClientCalls.setWebClientUserAgent(userAgentString); String accountName = mSharedPreferences.getString("GOOGLE_PLAY_MUSIC_ACCOUNT", ""); //Authenticate with Google. AsyncGoogleMusicAuthenticationTask task = new AsyncGoogleMusicAuthenticationTask(mContext, false, accountName); task.execute(); */ } }
From source file:com.moonpi.swiftnotes.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Get lobster_two asset and create typeface // Set action bar title to lobster_two typeface lobsterTwo = Typeface.createFromAsset(getAssets(), "lobster_two.otf"); actionBarTitle = Resources.getSystem().getIdentifier("action_bar_title", "id", "android"); TextView actionBarTitleView = null;/*from w w w. j ava 2s.c o m*/ if (actionBarTitle != 0) actionBarTitleView = (TextView) getWindow().findViewById(actionBarTitle); if (actionBarTitleView != null) { if (lobsterTwo != null) actionBarTitleView.setTypeface(lobsterTwo); } readFromJSON(); writeToJSON(); readFromJSON(); File folder = new File(Environment.getExternalStorageDirectory() + "/Swiftnotes"); File backupFile = new File(folder, "swiftnotes_backup.json"); if (backupFile.exists()) backupFilePath = backupFile.getAbsolutePath(); setContentView(R.layout.activity_main); listView = (ListView) findViewById(R.id.listView); ImageButton newNote = (ImageButton) findViewById(R.id.newNote); noNotes = (TextView) findViewById(R.id.noNotes); // Initialize NoteAdapter with notes array adapter = new NoteAdapter(this, notes); registerForContextMenu(listView); listView.setAdapter(adapter); listView.setOnItemClickListener(this); newNote.setOnClickListener(this); // If no notes, show 'Press + to add new note' text, invisible otherwise if (notes.length() == 0) noNotes.setVisibility(View.VISIBLE); else noNotes.setVisibility(View.INVISIBLE); }
From source file:com.udacity.movietimes.adapter.MovieDetailAdapter.java
public void updateFavoriteButton(final MovieViewHolder viewHolder, final Context context, final Cursor cursor) { // set the favorite button of the movie. First we check in the database if the favorite column // is Y or N. Based on that we switch the indicator as well as update the data in Movie DB. // Its basically act like a switch to update favorite column in the Movie Table Uri uri = MovieContract.MovieEntry.buildMovieWithMovieId(cursor.getLong(COL_ID)); Cursor temp = context.getContentResolver().query(uri, null, null, null, null, null); temp.moveToFirst();// w ww. j a v a 2 s .c om final ContentValues values = new ContentValues(); DatabaseUtils.cursorRowToContentValues(temp, values); Typeface fontFamily = Typeface.createFromAsset(context.getAssets(), "fonts/fontawesome.ttf"); viewHolder.favorite.setTypeface(fontFamily); if (values.get(MovieContract.MovieEntry.COLUMN_FAVORITE).equals("N")) { viewHolder.favorite.setText("\uf196"); } else { viewHolder.favorite.setText("\uf14a"); } viewHolder.favorite.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String movieId = (String) values.get(MovieContract.MovieEntry.COLUMN_MOVIE_ID); if (values.get(MovieContract.MovieEntry.COLUMN_FAVORITE).equals("N")) { values.put(MovieContract.MovieEntry.COLUMN_FAVORITE, "Y"); viewHolder.favorite.setText("\uf14a"); } else { values.put(MovieContract.MovieEntry.COLUMN_FAVORITE, "N"); viewHolder.favorite.setText("\uf196"); } context.getContentResolver().update(MovieContract.MovieEntry.CONTENT_URI, values, MovieContract.MovieEntry.COLUMN_MOVIE_ID + " = ? ", new String[] { movieId }); } }); }
From source file:cl.smartcities.isci.transportinspector.adapters.dialogAdapters.IncomingBusesAdapter.java
public View getView(final int position, View convertView, ViewGroup parent) { /* here for every row a view is set. Each row can show 2 buses. Every pair of buses belongs to one service./*from w w w .j a va2s .c om*/ */ ViewHolder holder; /* set view if this is the first time using it */ if (convertView == null) { convertView = mInflater.inflate(R.layout.bus_list_row, parent, false); holder = new ViewHolder(); /* First bus (the one that is nearer to the bus stop)*/ holder.bus = (TextView) convertView.findViewById(R.id.bus_route); holder.amountOfReports = (ImageButton) convertView.findViewById(R.id.amount_of_bus_reports); holder.busTime = (TextView) convertView.findViewById(R.id.bus_time_to_bus_stop); holder.busDistance = (TextView) convertView.findViewById(R.id.bus_distance_to_bus_stop); holder.busPlate = (TextView) convertView.findViewById(R.id.bus_plate); holder.moreButton = (AppCompatImageView) convertView.findViewById(R.id.next_bus); holder.moreButton.setImageDrawable(this.next); holder.viewIcon = (AppCompatImageView) convertView.findViewById(R.id.show_on_off_icon); /* get necessary Typefaces */ Typeface robotoRegular = Typeface.createFromAsset(this.getContext().getAssets(), this.context.getString(R.string.roboto_regular_font)); Typeface robotoBold = Typeface.createFromAsset(this.getContext().getAssets(), this.context.getString(R.string.roboto_bold_font)); holder.setHolderTypefaceRegular(robotoRegular); holder.setHolderTypefaceBold(robotoBold); /* save holder */ convertView.setTag(holder); } /* If is not the first time we can recharge it */ else { holder = (ViewHolder) convertView.getTag(); } final Service service = services.get(position); if (!service.isEmptyService()) { setCorrectView(holder, position, service); if (service.getBuses().size() == 1) { holder.moreButton.setClickable(false); holder.moreButton.setVisibility(View.INVISIBLE); } } /* if there are no buses coming we show the service anyway */ else { String serviceName = service.getServiceName(); holder.bus.setText(serviceName); holder.busTime.setText(context.getString(R.string.not_license_plate)); holder.busDistance.setText(context.getString(R.string.not_info_for_any_bus)); holder.busPlate.setText(context.getString(R.string.not_license_plate)); holder.moreButton.setVisibility(View.GONE); holder.amountOfReports.setImageDrawable(new BusListReportsDrawable(this.context, 0, R.drawable.bus01)); } if (isVisible(service.getServiceName())) { setViewIconOn(holder.viewIcon, service); } else { setViewIconOff(holder.viewIcon, service); } /* background is set with slightly different colors depending if the row is odd or not */ if (position % 2 == 1) { int backGroundColor = ContextCompat.getColor(context, R.color.odd_row); convertView.setBackgroundColor(backGroundColor); } else { int backGroundColor = ContextCompat.getColor(context, R.color.even_row); convertView.setBackgroundColor(backGroundColor); } return convertView; }
From source file:com.fexcon.demolayout.RecipeAdapter.java
/** * Get a View that displays the data at the specified position in the data set. You can either * create a View manually or inflate it from an XML layout file. When the View is inflated, the * parent View (GridView, ListView...) will apply default layout parameters unless you use * {@link LayoutInflater#inflate(int, ViewGroup, boolean)} * to specify a root view and to prevent attachment to the root. * * @param position The position of the item within the adapter's data set of the item whose view * we want./*from ww w. java 2 s . c o m*/ * @param convertView The old view to reuse, if possible. Note: You should check that this view * is non-null and of an appropriate type before using. If it is not possible to convert * this view to display the correct data, this method can create a new view. * Heterogeneous lists can specify their number of view types, so that this View is * always of the right type (see {@link #getViewTypeCount()} and * {@link #getItemViewType(int)}). * @param parent The parent that this view will eventually be attached to * @return A View corresponding to the data at the specified position. */ @Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder; // check if the view already exists if so, no need to inflate and findViewById again! if (convertView == null) { // Inflate the custom row layout from your XML. convertView = mInflater.inflate(R.layout.list_item_recipe, parent, false); // create a new "Holder" with subviews holder = new ViewHolder(); holder.thumbnailImageView = (ImageView) convertView.findViewById(R.id.recipe_list_thumbnail); holder.titleTextView = (TextView) convertView.findViewById(R.id.recipe_list_title); holder.subtitleTextView = (TextView) convertView.findViewById(R.id.recipe_list_subtitle); holder.detailTextView = (TextView) convertView.findViewById(R.id.recipe_list_detail); // hang onto this holder for future recyclage convertView.setTag(holder); } else { // skip all the expensive inflation/findViewById and just get the holder you already made holder = (ViewHolder) convertView.getTag(); } // Get relevant subviews of row view TextView titleTextView = holder.titleTextView; TextView subtitleTextView = holder.subtitleTextView; TextView detailTextView = holder.detailTextView; ImageView thumbnailImageView = holder.thumbnailImageView; //Get corresponding recipe for row Recipe recipe = (Recipe) getItem(position); // Update row view's textviews to display recipe information titleTextView.setText(recipe.title); subtitleTextView.setText(recipe.description); detailTextView.setText(recipe.label); // Use Picasso to load the image. Temporarily have a placeholder in case it's slow to load // Picasso.with(mContext).load(recipe.imageUrl).placeholder(R.mipmap // .ic_launcher).error(R.drawable.image1).into(thumbnailImageView); Picasso.Builder builder = new Picasso.Builder(mContext); builder.listener(new Picasso.Listener() { @Override public void onImageLoadFailed(Picasso picasso, Uri uri, Exception exception) { exception.printStackTrace(); } }); builder.build().load(recipe.imageUrl).placeholder(R.mipmap.ic_launcher).into(thumbnailImageView); // Style text views Typeface titleTypeFace = Typeface.createFromAsset(mContext.getAssets(), "fonts/CaviarDreams.ttf"); titleTextView.setTypeface(titleTypeFace); Typeface subtitleTypeFace = Typeface.createFromAsset(mContext.getAssets(), "fonts/ostrich-regular.ttf"); subtitleTextView.setTypeface(subtitleTypeFace); Typeface detailTypeFace = Typeface.createFromAsset(mContext.getAssets(), "fonts/OstrichSans-Light.otf"); detailTextView.setTypeface(detailTypeFace); // detailTextView.setTextColor(android.support.v4.content.ContextCompat.getColor(mContext, LABEL_COLORS // .get(recipe.label))); return convertView; }
From source file:net.inbox.Pager.java
private void activity_load() { // Init notification sound beep = new ToneGenerator(AudioManager.STREAM_NOTIFICATION, 1000); // Init vibrations vvv = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); Toolbar tb = (Toolbar) findViewById(R.id.home_toolbar); setSupportActionBar(tb);//from w ww. ja v a 2s. c o m tf = Typeface.createFromAsset(getAssets(), "fonts/Dottz.ttf"); // Find the title TextView tv_t; for (int i = 0; i < tb.getChildCount(); ++i) { int idd = tb.getChildAt(i).getId(); if (idd == -1) { tv_t = (TextView) tb.getChildAt(i); tv_t.setTextColor(ContextCompat.getColor(this, R.color.color_title)); tv_t.setTypeface(tf); break; } } if (getSupportActionBar() != null) { getSupportActionBar().setTitle(getString(R.string.activity_pager_title).toUpperCase()); } // Unread Messages Counter tv_page_counter = (TextView) findViewById(R.id.page_counter); tv_page_counter.setTypeface(tf); // Mass Refresh Button ImageButton iv_refresh = (ImageButton) findViewById(R.id.refresh); iv_refresh.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mass_refresh_check(); } }); // No accounts message is visible if the user has not init-ed the app tv_no_account = (TextView) findViewById(R.id.no_accounts); tv_no_account.setTypeface(tf); // Filling the ListView of the home window inbox_list_view = (ListView) findViewById(R.id.accounts_list_view); populate_list_view(); }
From source file:gov.wa.wsdot.android.wsdot.ui.FerriesRouteSchedulesDayDeparturesFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); tf = Typeface.createFromAsset(getActivity().getAssets(), "fonts/Roboto-Regular.ttf"); tfb = Typeface.createFromAsset(getActivity().getAssets(), "fonts/Roboto-Bold.ttf"); if (adapter == null) { adapter = new DepartureTimesAdapter(getActivity()); }/* w ww.ja v a 2 s. co m*/ this.getListView().addHeaderView(mHeaderView); setListAdapter(adapter); // Prepare the loaders. Either re-connect with an existing one, or start new ones. getLoaderManager().initLoader(FERRIES_DEPARTURES_LOADER_ID, null, this); getLoaderManager().initLoader(FERRIES_VEHICLE_SPACE_LOADER_ID, null, ferriesTerminalSyncCallbacks); TextView t = (TextView) mEmptyView; t.setText(R.string.no_day_departures); getListView().setEmptyView(mEmptyView); }
From source file:com.sythealth.fitness.util.Utils.java
public static void setTypeface1(Context context, TextView tv) { Typeface typeface = Typeface.createFromAsset(context.getAssets(), "fonts/fzcqjw.ttf"); tv.setTypeface(typeface);//from ww w.java2 s . c o m }
From source file:org.getlantern.firetweet.activity.support.SignInActivity.java
@Override protected void onCreate(final Bundle savedInstanceState) { supportRequestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); super.onCreate(savedInstanceState); mPreferences = getSharedPreferences(SHARED_PREFERENCES_NAME, MODE_PRIVATE); mResolver = getContentResolver();/*from w ww . j a va 2s . c om*/ mApplication = FiretweetApplication.getInstance(this); setContentView(R.layout.activity_sign_in); setSupportProgressBarIndeterminateVisibility(false); final long[] account_ids = getActivatedAccountIds(this); final ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(account_ids.length > 0); } if (savedInstanceState != null) { mAPIUrlFormat = savedInstanceState.getString(Accounts.API_URL_FORMAT); mAuthType = savedInstanceState.getInt(Accounts.AUTH_TYPE); mSameOAuthSigningUrl = savedInstanceState.getBoolean(Accounts.SAME_OAUTH_SIGNING_URL); mConsumerKey = trim(savedInstanceState.getString(Accounts.CONSUMER_KEY)); mConsumerSecret = trim(savedInstanceState.getString(Accounts.CONSUMER_SECRET)); mUsername = savedInstanceState.getString(Accounts.SCREEN_NAME); mPassword = savedInstanceState.getString(Accounts.PASSWORD); mAPIChangeTimestamp = savedInstanceState.getLong(EXTRA_API_LAST_CHANGE); } Typeface font = Typeface.createFromAsset(getAssets(), "fonts/ProximaNova-Semibold.ttf"); mSigninSignupContainer.setOrientation( mAuthType == Accounts.AUTH_TYPE_TWIP_O_MODE ? LinearLayout.VERTICAL : LinearLayout.HORIZONTAL); final Resources resources = getResources(); final ColorStateList color = ColorStateList.valueOf(resources.getColor(R.color.material_light_blue)); mSignInButton.setTextColor(Color.parseColor("#38c6f3")); mSignInButton.setBackgroundColor(Color.parseColor("#E7E7E7")); mSignInButton.setBackgroundResource(R.drawable.sign_in_btn); mSignInButton.setTypeface(font); mSignUpButton.setTypeface(font); poweredByButton.setTypeface(font); autoTweetCheckBox = (CheckBox) findViewById(R.id.autotweet_checkbox); autoTweetText = (TextView) findViewById(R.id.should_send_autotweet); // don't display the auto tweet text on subsequent runs if (mPreferences.contains(APP_RAN_BEFORE)) { autoTweetCheckBox.setVisibility(View.GONE); autoTweetText.setVisibility(View.GONE); } else { // the checkbox color attribute isn't a simple attribute // we have to grab the default checkbox and apply a color filter int id = Resources.getSystem().getIdentifier("btn_check_holo_light", "drawable", "android"); Drawable drawable = ResourcesCompat.getDrawable(getResources(), id, null); if (drawable != null) { drawable.setColorFilter(Color.parseColor("white"), PorterDuff.Mode.SRC_ATOP); autoTweetCheckBox.setButtonDrawable(drawable); } autoTweetText.setTypeface(font); autoTweetText.setTextColor(Color.parseColor("white")); } setSignInButton(); }