下面列出了怎么用android.support.v7.widget.AppCompatImageView的API类实例代码及写法,或者点击链接到github查看源代码。
@Override
protected void convert(MultipleViewHolder holder, MultipleItemEntity entity) {
switch (holder.getItemViewType()){
case ItemType.SINGLE_BIG_IMAGE:
final AppCompatImageView view = holder.getView(R.id.image_rv_item);
final String url = entity.getField(MultipleFields.IMAGE_URL);
Glide.with(mContext)
.load(url)
.apply(OPTIONS)
.into(view);
break;
default:
break;
}
}
@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
final RuuviTag tag = getItem(position);
if (convertView == null) {
convertView = LayoutInflater.from(getContext()).inflate(R.layout.row_item_add, parent, false);
}
((TextView)convertView.findViewById(R.id.address)).setText(tag.id);
((TextView)convertView.findViewById(R.id.rssi)).setText(String.format(getContext().getResources().getString(R.string.signal_reading), tag.rssi));
AppCompatImageView signalIcon = convertView.findViewById(R.id.signalIcon);
if (tag.rssi < -80) signalIcon.setImageResource(R.drawable.icon_connection_1);
else if (tag.rssi < -50) signalIcon.setImageResource(R.drawable.icon_connection_2);
else signalIcon.setImageResource(R.drawable.icon_connection_3);
return convertView;
}
protected void showInfo(String header, String desc, @Nullable Drawable drawable, boolean error) {
hideKeyboard();
AppCompatTextView infoHeader = (AppCompatTextView) llBottomSheet.findViewById(R.id.info_header);
AppCompatTextView infoDesc = (AppCompatTextView) llBottomSheet.findViewById(R.id.info_desc);
AppCompatImageView infoImg = (AppCompatImageView) llBottomSheet.findViewById(R.id.info_img);
if (error) {
llBottomSheet.findViewById(R.id.info_img).setVisibility(View.GONE);
((AppCompatButton) findViewById(R.id.ok_dimiss)).setText("Close");
} else {
llBottomSheet.findViewById(R.id.info_img).setVisibility(View.VISIBLE);
((AppCompatButton) findViewById(R.id.ok_dimiss)).setText("Ok");
}
infoHeader.setText(header);
infoDesc.setText(desc);
if (drawable != null)
infoImg.setImageDrawable(drawable);
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
}
private void showInfo(String header, String desc, @Nullable Drawable drawable, boolean error) {
hideKeyboard();
AppCompatTextView infoHeader = (AppCompatTextView) llBottomSheet.findViewById(R.id.info_header);
AppCompatTextView infoDesc = (AppCompatTextView) llBottomSheet.findViewById(R.id.info_desc);
AppCompatImageView infoImg = (AppCompatImageView) llBottomSheet.findViewById(R.id.info_img);
if (error) {
llBottomSheet.findViewById(R.id.info_img).setVisibility(View.GONE);
((AppCompatButton) findViewById(R.id.ok_dimiss)).setText("Close");
} else {
llBottomSheet.findViewById(R.id.info_img).setVisibility(View.VISIBLE);
((AppCompatButton) findViewById(R.id.ok_dimiss)).setText("Ok");
}
infoHeader.setText(header);
infoDesc.setText(desc);
if (drawable != null)
infoImg.setImageDrawable(drawable);
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
}
/**
* It's important to set overflowDescription atribute in styles, so we can grab the reference
* to the overflow icon. Check: res/values/styles.xml
*
* @param activity
* @param colorFilter
*/
private static void setOverflowButtonColor(final Activity activity, final PorterDuffColorFilter colorFilter) {
final String overflowDescription = activity.getString(R.string.abc_action_menu_overflow_description);
final ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView();
final ViewTreeObserver viewTreeObserver = decorView.getViewTreeObserver();
viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
final ArrayList<View> outViews = new ArrayList<View>();
decorView.findViewsWithText(outViews, overflowDescription,
View.FIND_VIEWS_WITH_CONTENT_DESCRIPTION);
if (outViews.isEmpty()) {
return;
}
AppCompatImageView overflow = (AppCompatImageView) outViews.get(0);
overflow.setColorFilter(colorFilter);
removeOnGlobalLayoutListener(decorView, this);
}
});
}
/**
* 指示器整体由数据列表容量数量的AppCompatImageView均匀分布在一个横向的LinearLayout中构成
* 使用AppCompatImageView的好处是在Fragment中也使用Compat相关属性
*/
private void createIndicators() {
mLinearLayout.removeAllViews();
for (int i = 0; i < mData.size(); i++) {
AppCompatImageView img = new AppCompatImageView(getContext());
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
lp.leftMargin = mSpace / 2;
lp.rightMargin = mSpace / 2;
if (mSize >= dp2px(4)) { // 设置了indicatorSize属性
lp.width = lp.height = mSize;
} else {
// 如果设置的resource.xml没有明确的宽高,默认最小2dp,否则太小看不清
img.setMinimumWidth(dp2px(2));
img.setMinimumHeight(dp2px(2));
}
img.setImageDrawable(i == 0 ? mSelectedDrawable : mUnselectedDrawable);
mLinearLayout.addView(img, lp);
}
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
AppCompatImageView img = new AppCompatImageView(parent.getContext());
RecyclerView.LayoutParams params = new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT);
img.setLayoutParams(params);
img.setId(R.id.rvb_banner_image_view_id);
img.setScaleType(AppCompatImageView.ScaleType.CENTER_CROP);
img.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (onRvBannerClickListener != null) {
onRvBannerClickListener.onClick(currentIndex % mData.size());
}
}
});
return new RecyclerView.ViewHolder(img) {
};
}
private void init(Context context, AttributeSet attrs, int defStyleAttr) {
mImageHeart = new AppCompatImageView(context);
TypedArray a = context.getTheme().obtainStyledAttributes(
attrs,
R.styleable.InstaLikeView,
defStyleAttr, 0);
int likeColor = a.getColor(R.styleable.InstaLikeView_likeColor, ContextCompat.getColor(context, R.color.heartColor));
int likeSrc = a.getResourceId(R.styleable.InstaLikeView_likeSrc, R.drawable.img_heart);
int likeSize = a.getDimensionPixelSize(R.styleable.InstaLikeView_likeSize, getResources().getDimensionPixelSize(R.dimen.likeSize));
LayoutParams heartParams = new LayoutParams(likeSize, likeSize);
heartParams.addRule(CENTER_IN_PARENT, TRUE);
mImageHeart.setLayoutParams(heartParams);
mImageHeart.setVisibility(GONE);
mImageHeart.setImageResource(likeSrc);
mImageHeart.setColorFilter(likeColor);
addView(mImageHeart);
}
void adjustPositionAndSize(BottomBarTab tab) {
AppCompatImageView iconView = tab.getIconView();
ViewGroup.LayoutParams params = getLayoutParams();
int size = Math.max(getWidth(), getHeight());
float xOffset = (float) (iconView.getWidth() / 1.25);
setX(iconView.getX() + xOffset);
setTranslationY(10);
if (params.width != size || params.height != size) {
params.width = size;
params.height = size;
setLayoutParams(params);
}
}
void prepareLayout() {
inflate(getContext(), getLayoutResource(), this);
setOrientation(VERTICAL);
setGravity(isTitleless? Gravity.CENTER : Gravity.CENTER_HORIZONTAL);
setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
setBackgroundResource(MiscUtils.getDrawableRes(getContext(), R.attr.selectableItemBackgroundBorderless));
iconView = (AppCompatImageView) findViewById(R.id.bb_bottom_bar_icon);
iconView.setImageResource(iconResId);
if (type != Type.TABLET && !isTitleless) {
titleView = (TextView) findViewById(R.id.bb_bottom_bar_title);
titleView.setVisibility(VISIBLE);
if (type == Type.SHIFTING) {
findViewById(R.id.spacer).setVisibility(VISIBLE);
}
updateTitle();
}
updateCustomTextAppearance();
updateCustomTypeface();
}
public static void setOverflowButtonColor(@NonNull Activity activity,
final @ColorInt int color) {
final String overflowDescription = activity
.getString(R.string.abc_action_menu_overflow_description);
final ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView();
final ViewTreeObserver viewTreeObserver = decorView.getViewTreeObserver();
viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
final ArrayList<View> outViews = new ArrayList<>();
decorView.findViewsWithText(outViews, overflowDescription,
View.FIND_VIEWS_WITH_CONTENT_DESCRIPTION);
if (outViews.isEmpty()) {
return;
}
final AppCompatImageView overflow = (AppCompatImageView) outViews.get(0);
overflow.setImageDrawable(TintHelper.createTintedDrawable(overflow.getDrawable(), color));
decorView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
}
});
}
private void wireUpViews(){
tvAccount = (AppCompatTextView) findViewById(R.id.account);
tvPasswd = (AppCompatTextView) findViewById(R.id.password);
tvAdditional = (AppCompatTextView) findViewById(R.id.additional);
tvTitle = (AppCompatTextView) findViewById(R.id.id_name);
image = (AppCompatImageView) findViewById(R.id.account_image);
tvWebSite = (AppCompatTextView) findViewById(R.id.id_website_link);
tvWebSiteTitle = (AppCompatTextView) findViewById(R.id.website_title);
webSiteContainer = (LinearLayout) findViewById(R.id.website_container);
tvLastAccess = (AppCompatTextView) findViewById(R.id.last_accessed);
webSiteContainer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String url = account.getWebsite();
if (!url.startsWith("http://") && !url.startsWith("https://"))
url = "http://" + url;
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
}
});
}
private void initViews() {
setLayoutParams(new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1));
setOrientation(HORIZONTAL);
setGravity(Gravity.CENTER);
imageView = new AppCompatImageView(getContext());
imageView.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT) {{
gravity = Gravity.CENTER;
}});
setDrawableAttrs();
addView(imageView);
textView = new AppCompatTextView(getContext());
textView.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT) {{
gravity = Gravity.CENTER;
}});
setTextAttrs();
addView(textView);
}
private void updatePadding(View view, boolean hasOtherView) {
if (null == view)
return;
int[] paddings = {paddingLeft, paddingTop, paddingRight, paddingBottom};
if (hasOtherView) {
int g = drawableGravity.getIntValue();
if (view instanceof AppCompatImageView) {
g = g > 1 ? g - 2 : g + 2;
}
paddings[g] = drawablePadding / 2;
}
MarginLayoutParams params = (MarginLayoutParams) view.getLayoutParams();
params.setMargins(paddings[0], paddings[1], paddings[2], paddings[3]);
}
private void initPreContainer(){
preContainer=new LinearLayout(getContext());
preContainer.setOrientation(LinearLayout.HORIZONTAL);
LayoutParams lp=new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
lp.gravity=Gravity.CENTER_VERTICAL;
preContainer.setLayoutParams(lp);
preContainer.setOnClickListener(this);
AppCompatImageView tmpImageView=new AppCompatImageView(getContext());
tmpImageView.setBackgroundResource(R.mipmap.ic_image_black_24dp);
AppCompatTextView tmpTextView=new AppCompatTextView(getContext());
LinearLayout.LayoutParams lp1=new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
lp1.gravity=Gravity.CENTER_VERTICAL;
tmpImageView.setLayoutParams(lp1);
tmpTextView.setLayoutParams(lp1);
tmpTextView.setText(getContext().getString(R.string.select_photo));
preContainer.addView(tmpImageView);
preContainer.addView(tmpTextView);
this.addView(preContainer);
}
private void initImgContainer(){
LinearLayout linearLayout=new LinearLayout(getContext());
linearLayout.setOrientation(LinearLayout.VERTICAL);
linearLayout.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
imageView=new AppCompatImageView(getContext());
LinearLayout.LayoutParams lp=new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
imageView.setLayoutParams(lp);
linearLayout.addView(imageView);
imageView.setOnClickListener(this);
editText=new AppCompatEditText(getContext());
linearLayout.addView(editText);
editText.setVisibility(GONE);
editText.setTextAppearance(getContext(),R.style.NoteTextAppearance);
editText.setGravity(Gravity.CENTER);
editText.setOnKeyListener(new OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if(keyCode==KeyEvent.KEYCODE_DEL&&editText.getText().toString().isEmpty()){
editText.setVisibility(GONE);
}
return false;
}
});
this.addView(linearLayout);
}
public LinearLayout getView(Context context,boolean left,WindowManager windowManager,SideBarService sideBarService) {
mContext = context;
mLeft = left;
mWindowManager = windowManager;
mSideBarService = sideBarService;
mParams = new WindowManager.LayoutParams();
// compatible
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
mParams.type = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
} else {
mParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;
}
// set bg transparent
mParams.format = PixelFormat.RGBA_8888;
// can not focusable
mParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
mParams.x = 0;
mParams.y = 0;
// window size
mParams.width = ViewGroup.LayoutParams.WRAP_CONTENT;
mParams.height = ViewGroup.LayoutParams.WRAP_CONTENT;
// get layout
LayoutInflater inflater = LayoutInflater.from(context);
mArrowView = (LinearLayout) inflater.inflate(R.layout.layout_arrow, null);
AppCompatImageView arrow = mArrowView.findViewById(R.id.arrow);
arrow.setOnClickListener(this);
if(left) {
arrow.setRotation(180);
mParams.gravity = Gravity.START | Gravity.CENTER_VERTICAL;
mParams.windowAnimations = R.style.LeftSeekBarAnim;
}else {
mParams.gravity = Gravity.END | Gravity.CENTER_VERTICAL;
mParams.windowAnimations = R.style.RightSeekBarAnim;
}
mWindowManager.addView(mArrowView,mParams);
return mArrowView;
}
@Override
protected void convert(BaseViewHolder helper, MultipleItemEntity item) {
switch (helper.getItemViewType()){
case OrderListItemType.ITEM_ORDER_LIST_HEADER:
//订单ID
String orderId = item.getField(OrderItemFields.ORDER_ID);
//创建时间
String createTime = item.getField(OrderItemFields.CREATE_TIME);
//订单状态
String orderStatus = item.getField(OrderItemFields.PAY_STATE);
final AppCompatTextView orderIdView = helper.getView(R.id.tv_item_allorder_orderid);
helper.setText(R.id.tv_item_allorder_state, orderStatus);
//helper.setText(R.id.tv_item_allorder_createtime, createTime);
orderIdView.setText(String.valueOf("订单编号:"+orderId));
break;
case OrderListItemType.ITEM_ORDER_LIST_CONTENT:
final String goodsName = item.getField(OrderItemFields.PRODUCT_NAME);
final String goodsPic = item.getField(OrderItemFields.PRODUCT_IMG);
final double goodsPrice = item.getField(OrderItemFields.PRODUCT_PRICE);
final int count = item.getField(OrderItemFields.PRODUCT_COUNT);
helper.setText(R.id.tv_item_allorder_title, goodsName);
helper.setText(R.id.tv_item_allorder_item_num, "共"+count+"件");
helper.setText(R.id.tv_item_allorder_item_price, goodsPrice+"");
final AppCompatImageView imgThumb = helper.getView(R.id.iv_item_allorder_pic);
Glide.with(mContext)
.load(goodsPic)
.apply(OPTIONS)
.into(imgThumb);
break;
case OrderListItemType.ITEM_ORDER_LIST_FOOTER:
final Double totalPrice = item.getField(OrderItemFields.TOTAL_PRICE);
helper.setText(R.id.tv_item_allorder_total, totalPrice+"");
break;
default:
break;
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == PHOTO_RESULT && resultCode == RESULT_OK ) {
AppCompatImageView imageView = findViewById(R.id.imageView);
imageView.setImageBitmap(BitmapFactory.decodeFile(mLastPhotoURI.getPath()));
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_slide, container, false);
AppCompatImageView imageView = rootView.findViewById(R.id.imageView);
imageView.setImageResource(mImageResourceID);
return rootView;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
AppCompatImageView imageView = findViewById(R.id.imageViewThumbnail);
imageView.setImageBitmap(
loadSampledResource(R.drawable.miguel_henriques_789508_unsplash, 100, 100));
}
@NonNull @Override public Object instantiateItem(@NonNull ViewGroup container, int position) {
AppCompatImageView imageView = new AppCompatImageView(container.getContext());
ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(WRAP_CONTENT, MATCH_PARENT);
imageView.setLayoutParams(params);
imageView.setPadding(12, 0, 12, 0);
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
container.addView(imageView);
loadImage(imageView, position);
return imageView;
}
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
viewPager = (ViewPager) view.findViewById(R.id.vp_explore);
tab = (TabLayout) view.findViewById(R.id.tab_explore);
progress = (MaterialProgressBar) view.findViewById(R.id.progress);
ivBookTypeRetry = (AppCompatImageView) view.findViewById(R.id.iv_book_type_retry);
ivBookTypeMore = view.findViewById(R.id.iv_book_type_more);
view.findViewById(R.id.view_search).setOnClickListener(this);
view.findViewById(R.id.fl_action).setOnClickListener(this);
}
private void initView(Context context){
this.fingerprintManager = (FingerprintManager) context.getSystemService(Context.FINGERPRINT_SERVICE);
this.cipherHelper = null;
this.handler = new Handler();
this.fingerprintCallback = null;
this.fingerprintSecureCallback = null;
this.counterCallback = null;
this.cryptoObject = null;
this.tryCounter = 0;
this.delayAfterError = DEFAULT_DELAY_AFTER_ERROR;
int fingerprintSize = (int) (size*SCALE);
int circleSize = size;
fingerprintImageView = new AppCompatImageView(context);
fingerprintImageView.setLayoutParams(new RelativeLayout.LayoutParams(fingerprintSize, fingerprintSize));
fingerprintImageView.setBackgroundResource(R.drawable.fingerprint);
((RelativeLayout.LayoutParams)fingerprintImageView.getLayoutParams()).addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
circleView = new View(context);
circleView.setLayoutParams(new RelativeLayout.LayoutParams(circleSize, circleSize));
circleView.setBackgroundResource(R.drawable.circle);
((RelativeLayout.LayoutParams)circleView.getLayoutParams()).addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT));
addView(circleView);
addView(fingerprintImageView);
setStatus(R.drawable.fingerprint, fingerprintScanning, circleScanning);
}
private void init(Context context, AttributeSet attrs) {
final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.AnimatedPencil);
if (typedArray != null) {
color = typedArray.getColor(R.styleable.AnimatedPencil_pencil_color, color);
typedArray.recycle();
}
imageView = new AppCompatImageView(getContext());
addView(imageView, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
drawable = AppCompatDrawableManager.get().getDrawable(getContext(), R.drawable.awsb_ic_edit_animated_24);
drawable = DrawableCompat.wrap(drawable).mutate();
DrawableCompat.setTint(drawable, color);
imageView.setImageDrawable(drawable);
}
private void init(Context context) {
View view = LayoutInflater.from(context).inflate(R.layout.header_dialog_content, null);
ctvj = (ContentTextViewJustified) view.findViewById(R.id.content_justified);
ctv = (ContentTextView) view.findViewById(R.id.content);
tv = (TitleTextView) view.findViewById(R.id.title);
tv.setGravity(Gravity.CENTER_HORIZONTAL);
ctv.setMovementMethod(LinkMovementMethod.getInstance());
iv = (AppCompatImageView) view.findViewById(R.id.icon);
ly = (LinearLayout) view.findViewById(R.id.layout);
shadow = view.findViewById(R.id.top_shadow);
customLayout = (LinearLayout) view.findViewById(R.id.contentView);
setView(view);
}
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
AppCompatImageView img = (AppCompatImageView) holder.itemView.findViewById(R.id.rvb_banner_image_view_id);
if (onSwitchRvBannerListener != null) {
onSwitchRvBannerListener.switchBanner(position % mData.size(), img);
}
}
/**
* 改变导航的指示点
*/
private void switchIndicator() {
if (mLinearLayout != null && mLinearLayout.getChildCount() > 0) {
for (int i = 0; i < mLinearLayout.getChildCount(); i++) {
((AppCompatImageView) mLinearLayout.getChildAt(i)).setImageDrawable(
i == currentIndex % mData.size() ? mSelectedDrawable : mUnselectedDrawable);
}
}
}
public void showResultIcon(boolean isSuccess, boolean shouldReset) {
animateFadeHide(context, progressBar);
final AppCompatImageView failureIcon = new AppCompatImageView(context);
RelativeLayout.LayoutParams icLayoutParams =
new RelativeLayout.LayoutParams(dpToPx(50), dpToPx(50));
failureIcon.setLayoutParams(icLayoutParams);
failureIcon.setVisibility(GONE);
int icon;
if (isSuccess)
icon = R.drawable.ic_check_circle_36dp;
else
icon = R.drawable.ic_cancel_full_24dp;
failureIcon.setImageResource(icon);
contentContainer.addView(failureIcon);
animateFadeShow(context, failureIcon);
if (shouldReset) {
// expand the btn again
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
animateFadeHide(context, failureIcon);
morphToRect();
arrowHintContainer.setX(0);
animateFadeShow(context, arrowHintContainer);
animateFadeShow(context, contentTv);
}
}, 1000);
}
}
private void updatePlayPauseButton(boolean reverse) {
AudioManager am = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
if (!am.isMusicActive())
((AppCompatImageView) findViewById(R.id.play)).setImageResource(reverse ? R.drawable.ic_play : R.drawable.ic_pause);
else
((AppCompatImageView) findViewById(R.id.play)).setImageResource(reverse ? R.drawable.ic_pause : R.drawable.ic_play);
}