1:修改K歌房
This commit is contained in:
@@ -183,6 +183,17 @@ public class ImageUtils {
|
||||
|
||||
|
||||
public static void loadHeadCC(String path, ImageView mImageView) {
|
||||
if (mImageView == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Context context = mImageView.getContext();
|
||||
if (context instanceof android.app.Activity) {
|
||||
android.app.Activity activity = (android.app.Activity) context;
|
||||
if (activity.isFinishing() || (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && activity.isDestroyed())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
Glide.with(mImageView).load(path).error(R.mipmap.default_avatar).placeholder(R.mipmap.default_avatar).centerCrop().diskCacheStrategy(DiskCacheStrategy.ALL).into(mImageView);
|
||||
|
||||
}
|
||||
|
||||
@@ -78,6 +78,9 @@ public class GiftDisplayManager {
|
||||
}
|
||||
|
||||
public void receiveGift(GiftBean gift) {
|
||||
if (isInBackground){
|
||||
return;
|
||||
}
|
||||
if (gift == null) return;
|
||||
|
||||
Log.d("GiftDisplayManager", "Received gift: " + gift.getSenderName() +
|
||||
@@ -201,6 +204,20 @@ public class GiftDisplayManager {
|
||||
// 立即处理队列,而不是延迟
|
||||
mainHandler.post(this::processGiftQueue);
|
||||
}
|
||||
private boolean isInBackground=false;
|
||||
public void isBackGround(){
|
||||
for (GiftDisplayView view : displayViews) {
|
||||
view.finishAnimationImmediately();
|
||||
}
|
||||
giftQueue.clear();
|
||||
accumulatedGifts.clear();
|
||||
isProcessingQueue = false;
|
||||
isInBackground=true;
|
||||
}
|
||||
|
||||
public void becomeFront(){
|
||||
isInBackground=false;
|
||||
}
|
||||
|
||||
public void clearAll() {
|
||||
Log.d("GiftDisplayManager", "Clear all gifts and queue");
|
||||
|
||||
@@ -124,7 +124,9 @@ public class GiftDisplayView extends FrameLayout {
|
||||
|
||||
// 临时用颜色代替
|
||||
// avatarImageView.setBackgroundColor(getRandomColor());
|
||||
ImageUtils.loadHeadCC(avatarUrl, avatarImageView);
|
||||
if (avatarImageView!=null&&avatarImageView.getContext()!=null) {
|
||||
ImageUtils.loadHeadCC(avatarUrl, avatarImageView);
|
||||
}
|
||||
} else {
|
||||
avatarImageView.setBackgroundColor(Color.LTGRAY);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user