Java Code Examples for android.widget.TextView#setPaintFlags()

The following examples show how to use android.widget.TextView#setPaintFlags() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AlertList.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
void FillLists() {
    // We use a - sign to tell that this text should be stiked through
    SimpleAdapter.ViewBinder vb = new SimpleAdapter.ViewBinder() {
        public boolean setViewValue(View view, Object data, String textRepresentation) {
            TextView tv = (TextView) view;
            tv.setText(textRepresentation.substring(1));
            if (textRepresentation.substring(0, 1).equals("-")) {
                tv.setPaintFlags(tv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
            }
            return true;
        }
    };

    ArrayList<HashMap<String, String>> feedList;
    feedList = createAlertsMap(false);
    SimpleAdapter simpleAdapterLow = new SimpleAdapter(this, feedList, R.layout.row_alerts, new String[]{"alertName", "alertThreshold", "alertTime", "alertMp3File", "alertOverrideSilenceMode"}, new int[]{R.id.alertName, R.id.alertThreshold, R.id.alertTime, R.id.alertMp3File, R.id.alertOverrideSilent});
    simpleAdapterLow.setViewBinder(vb);

    listViewLow.setAdapter(simpleAdapterLow);

    feedList = createAlertsMap(true);
    SimpleAdapter simpleAdapterHigh = new SimpleAdapter(this, feedList, R.layout.row_alerts, new String[]{"alertName", "alertThreshold", "alertTime", "alertMp3File", "alertOverrideSilenceMode"}, new int[]{R.id.alertName, R.id.alertThreshold, R.id.alertTime, R.id.alertMp3File, R.id.alertOverrideSilent});
    simpleAdapterHigh.setViewBinder(vb);
    listViewHigh.setAdapter(simpleAdapterHigh);
}
 
Example 2
Source File: AttendanceActivity.java    From bunk with MIT License 6 votes vote down vote up
private void setupDrawer() {
    DrawerLayout drawer = findViewById(R.id.drawer_layout);
    Toolbar toolbar = findViewById(R.id.toolbar);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.addDrawerListener(toggle);
    toggle.syncState();
    NavigationView navigationView = findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    View navigationViewHeader = navigationView.getHeaderView(0);
    ((TextView) navigationViewHeader.findViewById(R.id.name)).setText(this.newStudent.name);
    ((TextView) navigationViewHeader.findViewById(R.id.username)).setText(this.newStudent.username);
    String prompts[] = {"open source?", "coding?", "programming?", "code+coffee?"};
    TextView opensource = drawer.findViewById(R.id.opensource);
    opensource.setText(prompts[new Random().nextInt(prompts.length)]);
    TextView github = drawer.findViewById(R.id.github);
    github.setPaintFlags(Paint.UNDERLINE_TEXT_FLAG);
    github.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(getResources().getString(R.string.github_url))));
        }
    });
}
 
Example 3
Source File: RecyclerViewHolder.java    From LLApp with Apache License 2.0 5 votes vote down vote up
public RecyclerViewHolder setTypeface(Typeface typeface, int... viewIds) {
    for (int viewId : viewIds) {
        TextView view = getView(viewId);
        view.setTypeface(typeface);
        view.setPaintFlags(view.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG);
    }
    return this;
}
 
Example 4
Source File: BaseAdapterHelper.java    From AndroidBase with Apache License 2.0 5 votes vote down vote up
/** 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);
    view.setPaintFlags(view.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG);
    return this;
}
 
Example 5
Source File: TaskArrayAdapter.java    From SyncManagerAndroid-DemoGoogleTasks with MIT License 5 votes vote down vote up
private void updateViewGivenStatus(boolean isCompleted, TextView title, CheckBox status) {
       status.setChecked(isCompleted);
       if (isCompleted) {
           title.setPaintFlags(title.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
       } else {
           title.setPaintFlags(title.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
       }
}
 
Example 6
Source File: ViewHolder.java    From baseAdapter with Apache License 2.0 5 votes vote down vote up
public ViewHolder setTypeface(Typeface typeface, int... viewIds)
{
    for (int viewId : viewIds)
    {
        TextView view = getView(viewId);
        view.setTypeface(typeface);
        view.setPaintFlags(view.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG);
    }
    return this;
}
 
Example 7
Source File: BaseViewHolder.java    From basic-adapter with MIT License 5 votes vote down vote up
/**
 * Apply the typeface to all the given viewIds, and enable subpixel rendering.
 */
public BaseViewHolder setTypeface(Typeface typeface, int... viewIds) {
    for (int viewId : viewIds) {
        TextView view = getView(viewId);
        view.setTypeface(typeface);
        view.setPaintFlags(view.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG);
    }
    return this;
}
 
Example 8
Source File: BaseRecyclerHolder.java    From CoordinatorLayoutExample with Apache License 2.0 5 votes vote down vote up
public BaseRecyclerHolder setTypeface(Typeface typeface, int... viewIds) {
    for (int viewId : viewIds) {
        TextView view = getView(viewId);
        view.setTypeface(typeface);
        view.setPaintFlags(view.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG);
    }
    return this;
}
 
Example 9
Source File: BaseAdapterHelper.java    From BigApp_Discuz_Android with Apache License 2.0 5 votes vote down vote up
/**
 * Apply the typeface to all the given viewIds, and enable subpixel
 * rendering.
 */
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;
}
 
Example 10
Source File: EasyRVHolder.java    From fangzhuishushenqi with Apache License 2.0 5 votes vote down vote up
@Override
public EasyRVHolder setTypeface(int viewId, Typeface typeface) {
    TextView view = getView(viewId);
    view.setTypeface(typeface);
    view.setPaintFlags(view.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG);
    return this;
}
 
Example 11
Source File: Home.java    From NightWatch with GNU General Public License v3.0 5 votes vote down vote up
public void displayCurrentInfo() {
    final TextView currentBgValueText = (TextView) findViewById(R.id.currentBgValueRealTime);
    final TextView notificationText = (TextView) findViewById(R.id.notices);
    if ((currentBgValueText.getPaintFlags() & Paint.STRIKE_THRU_TEXT_FLAG) > 0) {
        currentBgValueText.setPaintFlags(currentBgValueText.getPaintFlags() & (~Paint.STRIKE_THRU_TEXT_FLAG));
    }
    Bg lastBgreading = Bg.last();

    if (lastBgreading != null) {
        //TODO: Adrian: Remove raw string?
        notificationText.setText(lastBgreading.readingAge() + "\n" + Bg.threeRaw((prefs.getString("units", "mgdl").equals("mgdl"))));
        currentBgValueText.setText(bgGraphBuilder.unitized_string(lastBgreading.sgv_double()) + " " + lastBgreading.slopeArrow());
        if ((new Date().getTime()) - (60000 * 16) - lastBgreading.datetime > 0) {
            notificationText.setTextColor(Color.parseColor("#C30909"));
            currentBgValueText.setPaintFlags(currentBgValueText.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
        } else {
            notificationText.setTextColor(Color.WHITE);
        }
        double estimate = lastBgreading.sgv_double();
        if (bgGraphBuilder.unitized(estimate) <= bgGraphBuilder.lowMark) {
            currentBgValueText.setTextColor(Color.parseColor("#C30909"));
        } else if (bgGraphBuilder.unitized(estimate) >= bgGraphBuilder.highMark) {
            currentBgValueText.setTextColor(Color.parseColor("#FFBB33"));
        } else {
            currentBgValueText.setTextColor(Color.WHITE);
        }
    }
}
 
Example 12
Source File: BaseViewHolder.java    From NIM_Android_UIKit with MIT License 5 votes vote down vote up
/**
 * Apply the typeface to the given viewId, and enable subpixel rendering.
 */
public BaseViewHolder setTypeface(int viewId, Typeface typeface) {
    TextView view = getView(viewId);
    view.setTypeface(typeface);
    view.setPaintFlags(view.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG);
    return this;
}
 
Example 13
Source File: OpenSourceAdapter.java    From sms-ticket with Apache License 2.0 5 votes vote down vote up
private void openPlayServices(TextView textView) {
    textView.setPaintFlags(textView.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
    textView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            PlayServicesLicenceDialogFragment.show(mFragmentManager);
        }
    });
}
 
Example 14
Source File: ViewHolder.java    From PocketEOS-Android with GNU Lesser General Public License v3.0 5 votes vote down vote up
public ViewHolder setTypeface(Typeface typeface, int... viewIds)
{
    for (int viewId : viewIds)
    {
        TextView view = getView(viewId);
        view.setTypeface(typeface);
        view.setPaintFlags(view.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG);
    }
    return this;
}
 
Example 15
Source File: BaseViewHolder.java    From demo4Fish with MIT License 5 votes vote down vote up
/**
 * Apply the typeface to the given viewId, and enable subpixel rendering.
 */
public BaseViewHolder setTypeface(int viewId, Typeface typeface) {
    TextView view = getView(viewId);
    view.setTypeface(typeface);
    view.setPaintFlags(view.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG);
    return this;
}
 
Example 16
Source File: BaseAdapterHelper.java    From BigApp_WordPress_Android with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
    view.setPaintFlags(view.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG);
    return this;
}
 
Example 17
Source File: LocationConfigView.java    From SuntimesWidget with GNU General Public License v3.0 5 votes vote down vote up
private View listItemView(int position, View convertView, @NonNull ViewGroup parent)
{
    View view = convertView;
    if (view == null)
    {
        LayoutInflater inflater = LayoutInflater.from(context);
        view = inflater.inflate(R.layout.layout_listitem_locations, parent, false);
    }

    WidgetSettings.LocationMode item = modes.get(position);

    //ImageView icon = (ImageView) view.findViewById(android.R.id.icon1);
    //icon.setImageResource(item.getIcon());

    TextView text = (TextView) view.findViewById(android.R.id.text1);
    text.setText(item.getDisplayString());

    if (item == WidgetSettings.LocationMode.CURRENT_LOCATION && !autoAllowed)
    {
        text.setTypeface(text.getTypeface(), Typeface.ITALIC);
        text.setPaintFlags(text.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
        text.setTextColor(text.getHintTextColors());
        view.setEnabled(false);
    }

    //TextView text2 = (TextView) view.findViewById(android.R.id.text2);
    //text2.setText(item.toString());

    return view;
}
 
Example 18
Source File: BaseViewHolder.java    From imsdk-android with MIT License 5 votes vote down vote up
/**
 * Apply the typeface to all the given viewIds, and enable subpixel rendering.
 */
public BaseViewHolder setTypeface(Typeface typeface, int... viewIds) {
    for (int viewId : viewIds) {
        TextView view = getView(viewId);
        view.setTypeface(typeface);
        view.setPaintFlags(view.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG);
    }
    return this;
}
 
Example 19
Source File: EquinoxView.java    From SuntimesWidget with GNU General Public License v3.0 5 votes vote down vote up
private void highlight( TextView view, boolean value )
{
    if (view != null)
    {
        if (value)
        {
            view.setTypeface(view.getTypeface(), Typeface.BOLD);
            view.setPaintFlags(view.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);

        } else {
            view.setTypeface(view.getTypeface(), Typeface.NORMAL);
            view.setPaintFlags(view.getPaintFlags() & (~Paint.UNDERLINE_TEXT_FLAG));
        }
    }
}
 
Example 20
Source File: DeleteProductsItemViewHolder.java    From privacy-friendly-shopping-list with Apache License 2.0 5 votes vote down vote up
private void updateVisibilityFormat(ProductItem item)
{
    Resources resources = deleteProductItemCache.getProductCard().getContext().getResources();
    TextView productNameTextView = deleteProductItemCache.getProductNameTextView();
    TextView productQuantityTextView = deleteProductItemCache.getProductQuantityTextView();
    AppCompatCheckBox checkBox = (AppCompatCheckBox) deleteProductItemCache.getCheckBox();
    if ( item.isSelectedForDeletion() )
    {
        int transparent = resources.getColor(R.color.transparent);
        int grey = resources.getColor(R.color.middlegrey);

        deleteProductItemCache.getProductCard().setCardBackgroundColor(transparent);
        productNameTextView.setTextColor(grey);
        productQuantityTextView.setTextColor(grey);
        checkBox.setSupportButtonTintList(ColorStateList.valueOf(grey));
        productNameTextView.setPaintFlags(productNameTextView.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
        productQuantityTextView.setPaintFlags(productQuantityTextView.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
    }
    else
    {
        int white = resources.getColor(R.color.white);
        int black = resources.getColor(R.color.black);

        deleteProductItemCache.getProductCard().setCardBackgroundColor(white);
        productNameTextView.setTextColor(black);
        productQuantityTextView.setTextColor(black);
        checkBox.setSupportButtonTintList(ColorStateList.valueOf(black));
        productNameTextView.setPaintFlags(productNameTextView.getPaintFlags() & (~Paint.STRIKE_THRU_TEXT_FLAG));
        productQuantityTextView.setPaintFlags(productQuantityTextView.getPaintFlags() & (~Paint.STRIKE_THRU_TEXT_FLAG));
    }
}