List of usage examples for android.widget TextView setPaintFlags
@android.view.RemotableViewMethod public void setPaintFlags(int flags)
From source file:com.bt.download.android.gui.adapters.SearchResultListAdapter.java
protected void populateFilePart(View view, FileSearchResult sr) { ImageView fileTypeIcon = findView(view, R.id.view_bittorrent_search_result_list_item_filetype_icon); fileTypeIcon.setImageResource(getFileTypeIconId()); TextView adIndicator = findView(view, R.id.view_bittorrent_search_result_list_item_ad_indicator); adIndicator.setVisibility(View.GONE); TextView title = findView(view, R.id.view_bittorrent_search_result_list_item_title); title.setText(sr.getDisplayName());// w w w . jav a 2 s . co m // if marked as downloading // title.setTextColor(GlobalConstants.COLOR_DARK_BLUE); TextView fileSize = findView(view, R.id.view_bittorrent_search_result_list_item_file_size); if (sr.getSize() > 0) { fileSize.setText(UIUtils.getBytesInHuman(sr.getSize())); } else { fileSize.setText(""); } TextView extra = findView(view, R.id.view_bittorrent_search_result_list_item_text_extra); extra.setText(FilenameUtils.getExtension(sr.getFilename())); TextView seeds = findView(view, R.id.view_bittorrent_search_result_list_item_text_seeds); seeds.setText(""); String license = sr.getLicense().equals(License.UNKNOWN) ? "" : " - " + sr.getLicense(); TextView sourceLink = findView(view, R.id.view_bittorrent_search_result_list_item_text_source); sourceLink.setText(sr.getSource() + license); // TODO: ask for design sourceLink.setTag(sr.getDetailsUrl()); sourceLink.setPaintFlags(sourceLink.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG); sourceLink.setOnClickListener(linkListener); }
From source file:com.frostwire.android.gui.adapters.SearchResultListAdapter.java
private void populateFilePart(View view, FileSearchResult sr) { ImageView fileTypeIcon = findView(view, R.id.view_bittorrent_search_result_list_item_filetype_icon); fileTypeIcon.setImageResource(getFileTypeIconId()); TextView adIndicator = findView(view, R.id.view_bittorrent_search_result_list_item_ad_indicator); adIndicator.setVisibility(View.GONE); TextView title = findView(view, R.id.view_bittorrent_search_result_list_item_title); title.setText(sr.getDisplayName());/*w ww.ja v a 2 s . co m*/ TextView fileSize = findView(view, R.id.view_bittorrent_search_result_list_item_file_size); if (sr.getSize() > 0) { fileSize.setText(UIUtils.getBytesInHuman(sr.getSize())); } else { fileSize.setText("..."); } TextView extra = findView(view, R.id.view_bittorrent_search_result_list_item_text_extra); extra.setText(FilenameUtils.getExtension(sr.getFilename())); TextView seeds = findView(view, R.id.view_bittorrent_search_result_list_item_text_seeds); seeds.setText(""); String license = sr.getLicense().equals(Licenses.UNKNOWN) ? "" : " - " + sr.getLicense(); TextView sourceLink = findView(view, R.id.view_bittorrent_search_result_list_item_text_source); sourceLink.setText(sr.getSource() + license); // TODO: ask for design sourceLink.setTag(sr.getDetailsUrl()); sourceLink.setPaintFlags(sourceLink.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG); sourceLink.setOnClickListener(linkListener); }
From source file:com.cicada.yuanxiaobao.common.BaseAdapterHelper.java
/** Apply the typeface to the given viewId, and enable subpixel rendering. */ public BaseAdapterHelper setTypeface(int viewId, Typeface typeface) { TextView view = retrieveView(viewId); view.setTypeface(typeface);//w w w. j ava 2 s .co m view.setPaintFlags(view.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG); return this; }
From source file:com.aniruddhc.acemusic.player.Dialogs.BlacklistedElementsDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { mApp = (Common) getActivity().getApplicationContext(); final BlacklistedElementsDialog dialog = this; MANAGER_TYPE = getArguments().getString("MANAGER_TYPE"); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); //Get a cursor with a list of blacklisted elements. if (MANAGER_TYPE.equals("ARTISTS")) { builder.setTitle(R.string.blacklisted_artists); cursor = mApp.getDBAccessHelper().getBlacklistedArtists(); } else if (MANAGER_TYPE.equals("ALBUMS")) { builder.setTitle(R.string.blacklisted_albums); cursor = mApp.getDBAccessHelper().getBlacklistedAlbums(); } else if (MANAGER_TYPE.equals("SONGS")) { builder.setTitle(R.string.blacklisted_songs); cursor = mApp.getDBAccessHelper().getAllBlacklistedSongs(); } else if (MANAGER_TYPE.equals("PLAYLISTS")) { builder.setTitle(R.string.blacklisted_playlists); /*DBAccessHelper playlistsDBHelper = new DBAccessHelper(getActivity()); cursor = playlistsDBHelper.getAllBlacklistedPlaylists();*/ } else {// www . jav a 2 s. co m Toast.makeText(getActivity(), R.string.error_occurred, Toast.LENGTH_LONG).show(); return builder.create(); } //Dismiss the dialog if there are no blacklisted elements. if (cursor.getCount() == 0) { Toast.makeText(getActivity(), R.string.no_blacklisted_items_found, Toast.LENGTH_LONG).show(); return builder.create(); } //Loop through checkboxStatuses and insert "TRUE" at every position by default. for (int i = 0; i < cursor.getCount(); i++) { checkboxStatuses.add(true); } View rootView = this.getLayoutInflater(savedInstanceState).inflate(R.layout.fragment_blacklist_manager, null); TextView blacklistManagerInfoText = (TextView) rootView.findViewById(R.id.blacklist_manager_info_text); ListView blacklistManagerListView = (ListView) rootView.findViewById(R.id.blacklist_manager_list); blacklistManagerInfoText.setTypeface(TypefaceHelper.getTypeface(getActivity(), "RobotoCondensed-Light")); blacklistManagerInfoText.setPaintFlags( blacklistManagerInfoText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); blacklistManagerListView.setFastScrollEnabled(true); BlacklistedElementsAdapter adapter = new BlacklistedElementsAdapter(getActivity(), cursor); blacklistManagerListView.setAdapter(adapter); builder.setView(rootView); builder.setNegativeButton(R.string.cancel, new OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { dialog.dismiss(); } }); builder.setPositiveButton(R.string.done, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { //Loop through checkboxStatuses and unblacklist the elements that have been unchecked. for (int i = 0; i < checkboxStatuses.size(); i++) { cursor.moveToPosition(i); if (checkboxStatuses.get(i) == true) { //The item is still blacklisted. continue; } else { //The item has been unblacklisted. if (MANAGER_TYPE.equals("ARTISTS")) { mApp.getDBAccessHelper().setBlacklistForArtist( cursor.getString(cursor.getColumnIndex(DBAccessHelper.SONG_ARTIST)), false); } else if (MANAGER_TYPE.equals("ALBUMS")) { mApp.getDBAccessHelper().setBlacklistForAlbum( cursor.getString(cursor.getColumnIndex(DBAccessHelper.SONG_ALBUM)), cursor.getString(cursor.getColumnIndex(DBAccessHelper.SONG_ARTIST)), false); } else if (MANAGER_TYPE.equals("SONGS")) { mApp.getDBAccessHelper().setBlacklistForSong( cursor.getString(cursor.getColumnIndex(DBAccessHelper.SONG_FILE_PATH)), false); } else if (MANAGER_TYPE.equals("PLAYLISTS")) { /*DBAccessHelper playlistsDBHelper = new DBAccessHelper(getActivity()); playlistsDBHelper.unBlacklistPlaylist(cursor.getString(cursor.getColumnIndex(DBAccessHelper.PLAYLIST_BLACKLIST_STATUS)));*/ } } } dialog.dismiss(); } }); return builder.create(); }
From source file:com.cicada.yuanxiaobao.common.BaseAdapterHelper.java
/** * Apply the typeface to all the given viewIds, and enable subpixel * rendering.//w w w.jav a2 s . co m */ public BaseAdapterHelper setTypeface(Typeface typeface, int... viewIds) { for (int viewId : viewIds) { TextView view = retrieveView(viewId); view.setTypeface(typeface); view.setPaintFlags(view.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG); } return this; }
From source file:se.frikod.payday.DailyBudgetFragment.java
private void updateBudgetItems() { TableLayout itemsTable = (TableLayout) V.findViewById(R.id.budgetItems); itemsTable.removeAllViews();/*from w w w . j av a 2s . com*/ for (int i = 0; i < budget.budgetItems.size(); i++) { BudgetItem bi = budget.budgetItems.get(i); final int currentIndex = i; LayoutInflater inflater = activity.getLayoutInflater(); TableRow budgetItemView = (TableRow) inflater.inflate(R.layout.daily_budget_budget_item, itemsTable, false); TextView amount = (TextView) budgetItemView.findViewById(R.id.budgetItemAmount); TextView title = (TextView) budgetItemView.findViewById(R.id.budgetItemLabel); amount.setText(budget.formatter.format(bi.amount)); title.setText(bi.title); if (bi.exclude) { amount.setTextColor(0xffCCCCCC); amount.setPaintFlags(amount.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); title.setTextColor(0xffCCCCCC); title.setPaintFlags(title.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); } budgetItemView.setClickable(true); budgetItemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Vibrator vibrator = (Vibrator) activity.getSystemService(Context.VIBRATOR_SERVICE); vibrator.vibrate(10); BudgetItem bi = budget.budgetItems.get(currentIndex); bi.exclude = !bi.exclude; budget.saveBudgetItems(); updateBudgetItems(); } }); budgetItemView.setLongClickable(true); budgetItemView.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { editBudgetItem(v, currentIndex); return true; } }); itemsTable.addView(budgetItemView); } FontUtils.setRobotoFont(activity, itemsTable); updateBudget(); }
From source file:com.aniruddhc.acemusic.player.BlacklistManagerActivity.BlacklistManagerFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mApp = (Common) getActivity().getApplicationContext(); View rootView = (ViewGroup) inflater.inflate(R.layout.fragment_blacklist_manager, container, false); mContext = getActivity().getApplicationContext(); ImageView blacklistImage = (ImageView) rootView.findViewById(R.id.blacklist_image); blacklistImage.setImageResource(UIElementsHelper.getIcon(mContext, "manage_blacklists")); MANAGER_TYPE = getArguments().getString("MANAGER_TYPE"); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); //Get a cursor with a list of blacklisted elements. if (MANAGER_TYPE.equals("ARTISTS")) { builder.setTitle(R.string.blacklisted_artists); cursor = mApp.getDBAccessHelper().getBlacklistedArtists(); //Finish the activity if there are no blacklisted elements. if (cursor.getCount() == 0) { Toast.makeText(getActivity(), R.string.no_blacklisted_items_found, Toast.LENGTH_LONG).show(); getActivity().finish();/*from ww w . j a v a2 s . c om*/ } else { //Load the cursor data into temporary ArrayLists. for (int i = 0; i < cursor.getCount(); i++) { cursor.moveToPosition(i); elementNameList.add(cursor.getString(cursor.getColumnIndex(DBAccessHelper.SONG_ARTIST))); } } } else if (MANAGER_TYPE.equals("ALBUMS")) { builder.setTitle(R.string.blacklisted_albums); cursor = mApp.getDBAccessHelper().getBlacklistedAlbums(); //Finish the activity if there are no blacklisted elements. if (cursor.getCount() == 0) { Toast.makeText(getActivity(), R.string.no_blacklisted_items_found, Toast.LENGTH_LONG).show(); getActivity().finish(); } else { //Load the cursor data into temporary ArrayLists. for (int i = 0; i < cursor.getCount(); i++) { cursor.moveToPosition(i); elementNameList.add(cursor.getString(cursor.getColumnIndex(DBAccessHelper.SONG_ALBUM))); artistNameList.add(cursor.getString(cursor.getColumnIndex(DBAccessHelper.SONG_ARTIST))); } } } else if (MANAGER_TYPE.equals("SONGS")) { builder.setTitle(R.string.blacklisted_songs); cursor = mApp.getDBAccessHelper().getAllBlacklistedSongs(); //Finish the activity if there are no blacklisted elements. if (cursor.getCount() == 0) { Toast.makeText(getActivity(), R.string.no_blacklisted_items_found, Toast.LENGTH_LONG).show(); getActivity().finish(); } else { //Load the cursor data into temporary ArrayLists. for (int i = 0; i < cursor.getCount(); i++) { cursor.moveToPosition(i); elementNameList.add(cursor.getString(cursor.getColumnIndex(DBAccessHelper.SONG_TITLE))); artistNameList.add(cursor.getString(cursor.getColumnIndex(DBAccessHelper.SONG_ARTIST))); filePathList.add(cursor.getString(cursor.getColumnIndex(DBAccessHelper.SONG_FILE_PATH))); songIdsList.add(cursor.getString(cursor.getColumnIndex(DBAccessHelper.SONG_ID))); } } } else if (MANAGER_TYPE.equals("PLAYLISTS")) { /*builder.setTitle(R.string.blacklisted_playlists); DBAccessHelper playlistsDBHelper = new DBAccessHelper(getActivity()); cursor = playlistsDBHelper.getAllBlacklistedPlaylists(); //Finish the activity if there are no blacklisted elements. if (cursor.getCount()==0) { Toast.makeText(getActivity(), R.string.no_blacklisted_items_found, Toast.LENGTH_LONG).show(); getActivity().finish(); } else { //Load the cursor data into temporary ArrayLists. for (int i=0; i < cursor.getCount(); i++) { cursor.moveToPosition(i); elementNameList.add(cursor.getString(cursor.getColumnIndex(DBAccessHelper.PLAYLIST_NAME))); artistNameList.add(cursor.getString(cursor.getColumnIndex(DBAccessHelper.NUMBER_OF_SONGS))); filePathList.add(cursor.getString(cursor.getColumnIndex(DBAccessHelper.PLAYLIST_FILE_PATH))); } }*/ } else { Toast.makeText(getActivity(), R.string.error_occurred, Toast.LENGTH_LONG).show(); getActivity().finish(); } TextView blacklistManagerInfoText = (TextView) rootView.findViewById(R.id.blacklist_manager_info_text); DragSortListView blacklistManagerListView = (DragSortListView) rootView .findViewById(R.id.blacklist_manager_list); blacklistManagerListView.setRemoveListener(onRemove); blacklistManagerInfoText.setTypeface(TypefaceHelper.getTypeface(getActivity(), "RobotoCondensed-Light")); blacklistManagerInfoText.setPaintFlags( blacklistManagerInfoText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); blacklistManagerListView.setFastScrollEnabled(true); adapter = new BlacklistedElementsAdapter(getActivity(), elementNameList, artistNameList, MANAGER_TYPE); blacklistManagerListView.setAdapter(adapter); return rootView; }
From source file:com.todoroo.astrid.adapter.TaskAdapter.java
/** Helper method to adjust a tasks' appearance if the task is completed or * uncompleted./* ww w . ja va 2 s . c o m*/ */ private void setTaskAppearance(ViewHolder viewHolder, Task task) { boolean completed = task.isCompleted(); TextView name = viewHolder.nameView; if (completed) { name.setEnabled(false); name.setPaintFlags(name.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); } else { name.setEnabled(true); name.setPaintFlags(name.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG); } name.setTextSize(fontSize); setupDueDateAndTags(viewHolder, task); float detailTextSize = Math.max(10, fontSize * 14 / 20); if (viewHolder.dueDate != null) { viewHolder.dueDate.setTextSize(detailTextSize); viewHolder.dueDate.setTypeface(null, 0); } setupCompleteBox(viewHolder); }
From source file:com.evandroid.musica.fragment.LyricsViewFragment.java
public void update(Lyrics lyrics, View layout, boolean animation) { TextSwitcher textSwitcher = ((TextSwitcher) layout.findViewById(R.id.switcher)); LrcView lrcView = (LrcView) layout.findViewById(R.id.lrc_view); View v = getActivity().findViewById(R.id.tracks_msg); if (v != null) ((ViewGroup) v.getParent()).removeView(v); TextView id3TV = (TextView) layout.findViewById(R.id.id3_tv); RelativeLayout bugLayout = (RelativeLayout) layout.findViewById(R.id.error_msg); this.mLyrics = lyrics; if (SDK_INT >= ICE_CREAM_SANDWICH) beamLyrics(lyrics, this.getActivity()); new PresenceChecker().execute(this, new String[] { lyrics.getArtist(), lyrics.getTrack(), lyrics.getOriginalArtist(), lyrics.getOriginalTrack() }); if (isActiveFragment) ((RefreshIcon) getActivity().findViewById(R.id.refresh_fab)).show(); EditText newLyrics = (EditText) getActivity().findViewById(R.id.edit_lyrics); if (newLyrics != null) newLyrics.setText(""); if (lyrics.getFlag() == Lyrics.POSITIVE_RESULT) { if (!lyrics.isLRC()) { textSwitcher.setVisibility(View.VISIBLE); lrcView.setVisibility(View.GONE); if (animation) textSwitcher.setText(Html.fromHtml(lyrics.getText())); else/*from w w w. j a v a 2 s . c o m*/ textSwitcher.setCurrentText(Html.fromHtml(lyrics.getText())); } else { textSwitcher.setVisibility(View.GONE); lrcView.setVisibility(View.VISIBLE); lrcView.setOriginalLyrics(lyrics); lrcView.setSourceLrc(lyrics.getText()); updateLRC(); } bugLayout.setVisibility(View.INVISIBLE); if ("Storage".equals(lyrics.getSource())) id3TV.setVisibility(View.VISIBLE); else id3TV.setVisibility(View.GONE); mScrollView.post(new Runnable() { @Override public void run() { mScrollView.scrollTo(0, 0); //only useful when coming from localLyricsFragment mScrollView.smoothScrollTo(0, 0); } }); } else { textSwitcher.setText(""); textSwitcher.setVisibility(View.INVISIBLE); lrcView.setVisibility(View.INVISIBLE); bugLayout.setVisibility(View.VISIBLE); int message; int whyVisibility; if (lyrics.getFlag() == Lyrics.ERROR || !OnlineAccessVerifier.check(getActivity())) { message = R.string.connection_error; whyVisibility = TextView.GONE; } else { message = R.string.no_results; whyVisibility = TextView.VISIBLE; updateSearchView(false, lyrics.getTrack(), false); } TextView whyTextView = ((TextView) bugLayout.findViewById(R.id.bugtext_why)); ((TextView) bugLayout.findViewById(R.id.bugtext)).setText(message); whyTextView.setVisibility(whyVisibility); whyTextView.setPaintFlags(whyTextView.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG); id3TV.setVisibility(View.GONE); } stopRefreshAnimation(); getActivity().getIntent().setAction(""); getActivity().invalidateOptionsMenu(); }
From source file:com.shopify.buy.ui.ProductDetailsFragmentView.java
/** * Fills in the views with all the {@link Product} details. *///from ww w . j ava 2 s. com private void updateProductDetails() { Resources res = getResources(); findViewById(R.id.product_details_container).setBackgroundColor(theme.getBackgroundColor(res)); // Product title TextView textViewTitle = (TextView) findViewById(R.id.product_title); textViewTitle.setText(product.getTitle()); textViewTitle.setTextColor(theme.getProductTitleColor(res)); // Product price TextView textViewPrice = (TextView) findViewById(R.id.product_price); String priceWithCurrency = currencyFormat.format(Double.parseDouble(variant.getPrice())); textViewPrice.setText(priceWithCurrency); textViewPrice.setTextColor(theme.getAccentColor()); // Product "compare at" price (appears below the actual price with a strikethrough style) TextView textViewCompareAtPrice = (TextView) findViewById(R.id.product_compare_at_price); if (!variant.isAvailable()) { textViewCompareAtPrice.setVisibility(View.VISIBLE); textViewCompareAtPrice.setText(getResources().getString(R.string.sold_out)); textViewCompareAtPrice.setTextColor(getResources().getColor(R.color.error_background)); textViewCompareAtPrice.setPaintFlags(0); } else if (!TextUtils.isEmpty(variant.getCompareAtPrice())) { textViewCompareAtPrice.setVisibility(View.VISIBLE); String compareAtPriceWithCurrency = currencyFormat .format(Double.parseDouble(variant.getCompareAtPrice())); textViewCompareAtPrice.setText(compareAtPriceWithCurrency); textViewCompareAtPrice.setTextColor(theme.getCompareAtPriceColor(res)); textViewCompareAtPrice .setPaintFlags(textViewCompareAtPrice.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); } else { textViewCompareAtPrice.setVisibility(View.GONE); } // Set the correct values on the ProductDetailsVariantOptionViews List<OptionValue> optionValues = variant.getOptionValues(); for (OptionValue optionValue : optionValues) { ProductDetailsVariantOptionView optionView = visibleOptionViews .get(Long.valueOf(optionValue.getOptionId())); if (optionView != null) { optionView.setOptionValue(optionValue); } } // Product description TextView textViewDescription = (TextView) findViewById(R.id.product_description); textViewDescription.setText(Html.fromHtml(product.getBodyHtml()), TextView.BufferType.SPANNABLE); textViewDescription.setTextColor(theme.getProductDescriptionColor(res)); // Make the links clickable in the description // http://stackoverflow.com/questions/2734270/how-do-i-make-links-in-a-textview-clickable textViewDescription.setMovementMethod(LinkMovementMethod.getInstance()); }