use of android.support.v7.text.AllCapsTransformationMethod in project materialistic by hidroh.
the class ItemActivity method bindData.
@SuppressWarnings("ConstantConditions")
private void bindData(@Nullable final WebItem story) {
if (story == null) {
return;
}
mCustomTabsDelegate.mayLaunchUrl(Uri.parse(story.getUrl()), null, null);
bindFavorite();
mSessionManager.view(this, story.getId());
mVoteButton.setVisibility(View.VISIBLE);
mVoteButton.setOnClickListener(v -> vote(story));
final TextView titleTextView = (TextView) findViewById(android.R.id.text2);
if (story.isStoryType()) {
titleTextView.setText(story.getDisplayedTitle());
setTaskTitle(story.getDisplayedTitle());
if (!TextUtils.isEmpty(story.getSource())) {
TextView sourceTextView = (TextView) findViewById(R.id.source);
sourceTextView.setText(story.getSource());
sourceTextView.setVisibility(View.VISIBLE);
}
} else {
AppUtils.setTextAppearance(titleTextView, R.style.TextAppearance_App_Small);
titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(AppUtils.getThemedResId(this, R.attr.contentTextSize)));
CharSequence title = AppUtils.fromHtml(story.getDisplayedTitle(), true);
titleTextView.setText(title);
setTaskTitle(title);
}
final TextView postedTextView = (TextView) findViewById(R.id.posted);
postedTextView.setText(story.getDisplayedTime(this));
postedTextView.append(story.getDisplayedAuthor(this, true, 0));
postedTextView.setMovementMethod(LinkMovementMethod.getInstance());
switch(story.getType()) {
case Item.JOB_TYPE:
postedTextView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_work_white_18dp, 0, 0, 0);
break;
case Item.POLL_TYPE:
postedTextView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_poll_white_18dp, 0, 0, 0);
break;
}
mAdapter = new ItemPagerAdapter(this, getSupportFragmentManager(), new ItemPagerAdapter.Builder().setItem(story).setShowArticle(!mExternalBrowser).setCacheMode(getIntent().getIntExtra(EXTRA_CACHE_MODE, ItemManager.MODE_DEFAULT)).setRetainInstance(true).setDefaultViewMode(mStoryViewMode));
mAdapter.bind(mViewPager, mTabLayout, mNavButton, mReplyButton);
mTabLayout.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(mViewPager) {
@Override
public void onTabReselected(TabLayout.Tab tab) {
mAppBar.setExpanded(true, true);
}
});
if (story.isStoryType() && mExternalBrowser) {
TextView buttonArticle = (TextView) findViewById(R.id.button_article);
buttonArticle.setTransformationMethod(new AllCapsTransformationMethod(this));
buttonArticle.setVisibility(View.VISIBLE);
buttonArticle.setOnClickListener(v -> AppUtils.openWebUrlExternal(ItemActivity.this, story, story.getUrl(), mCustomTabsDelegate.getSession()));
}
if (mFullscreen) {
setFullscreen();
}
}
use of android.support.v7.text.AllCapsTransformationMethod in project Douya by DreaminginCodeZH.
the class FriendlySwitchCompat method setSwitchTextAppearance.
/**
* Sets the switch text color, size, style, hint color, and highlight color
* from the specified TextAppearance resource.
*
* @attr ref android.support.v7.appcompat.R.styleable#SwitchCompat_switchTextAppearance
*/
public void setSwitchTextAppearance(Context context, int resid) {
TintTypedArray appearance = TintTypedArray.obtainStyledAttributes(context, resid, R.styleable.TextAppearance);
ColorStateList colors;
int ts;
colors = appearance.getColorStateList(R.styleable.TextAppearance_android_textColor);
if (colors != null) {
mTextColors = colors;
} else {
// If no color set in TextAppearance, default to the view's textColor
mTextColors = getTextColors();
}
ts = appearance.getDimensionPixelSize(R.styleable.TextAppearance_android_textSize, 0);
if (ts != 0) {
if (ts != mTextPaint.getTextSize()) {
mTextPaint.setTextSize(ts);
requestLayout();
}
}
int typefaceIndex, styleIndex;
typefaceIndex = appearance.getInt(R.styleable.TextAppearance_android_typeface, -1);
styleIndex = appearance.getInt(R.styleable.TextAppearance_android_textStyle, -1);
setSwitchTypefaceByIndex(typefaceIndex, styleIndex);
boolean allCaps = appearance.getBoolean(R.styleable.TextAppearance_textAllCaps, false);
if (allCaps) {
mSwitchTransformationMethod = new AllCapsTransformationMethod(getContext());
} else {
mSwitchTransformationMethod = null;
}
appearance.recycle();
}
Aggregations