贵族特权:贵族气泡实现
This commit is contained in:
@@ -50,6 +50,7 @@ import com.yizhuan.erban.avroom.dialog.PKResultDialog;
|
||||
import com.yizhuan.erban.common.widget.CustomAutoWidthImageSpan;
|
||||
import com.yizhuan.erban.common.widget.CustomImageSpan;
|
||||
import com.yizhuan.erban.common.widget.OriginalDrawStatusClickSpan;
|
||||
import com.yizhuan.erban.ui.utils.ImageLoadUtils;
|
||||
import com.yizhuan.erban.ui.widget.DividerItemDecoration;
|
||||
import com.yizhuan.erban.ui.widget.MyItemAnimator;
|
||||
import com.yizhuan.erban.ui.widget.UserInfoDialog;
|
||||
@@ -1327,39 +1328,10 @@ public class MessageView extends FrameLayout {
|
||||
}
|
||||
|
||||
public void setRoomMessageBackground(ChatRoomMessage chatRoomMessage, View view) {
|
||||
int level = 0;
|
||||
try {
|
||||
String levelStr = NobleUtil.getNobleLevel(chatRoomMessage);
|
||||
if (TextUtils.isEmpty(levelStr)) return;
|
||||
level = Integer.valueOf(levelStr);
|
||||
if (level <= 0) {
|
||||
return;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return;
|
||||
}
|
||||
|
||||
Drawable drawable = null;
|
||||
switch (level) {
|
||||
case 4:
|
||||
drawable = view.getResources().getDrawable(R.drawable.bg_room_message_noble_4);
|
||||
break;
|
||||
case 5:
|
||||
drawable = view.getResources().getDrawable(R.drawable.bg_room_message_noble_5);
|
||||
break;
|
||||
case 6:
|
||||
drawable = view.getResources().getDrawable(R.drawable.bg_room_message_noble_6);
|
||||
break;
|
||||
case 7:
|
||||
drawable = view.getResources().getDrawable(R.drawable.bg_room_message_noble_7);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (drawable != null) {
|
||||
view.setBackground(drawable);
|
||||
view.setPadding(paddingWidth, paddingHeight, paddingWidth, paddingHeight);
|
||||
}
|
||||
String androidBubbleUrl = NobleUtil.getResource(UserInfo.BUBBLE_URL_ANDROID, chatRoomMessage);
|
||||
if (TextUtils.isEmpty(androidBubbleUrl)) return;
|
||||
view.setPadding(paddingWidth, paddingHeight, paddingWidth, paddingHeight);
|
||||
ImageLoadUtils.loadNinePatchBg(view,androidBubbleUrl);
|
||||
}
|
||||
|
||||
private void openRoomPKModeMsg(RoomPkAttachment attachment, TextView tvContent) {
|
||||
|
@@ -91,7 +91,7 @@ public class MyChatBubbleFragment extends BaseBindingFragment<FrgMyDecorationCom
|
||||
|
||||
// id == 0标识不使用头饰
|
||||
|
||||
String cardId = bubbleInfo.isUsed() ? null : bubbleInfo.getBubbleId();
|
||||
String cardId = bubbleInfo.isHasUsed() ? null : bubbleInfo.getBubbleId();
|
||||
|
||||
wearVm.userChatBubble(cardId)
|
||||
.compose(bindUntilEvent(FragmentEvent.DESTROY))
|
||||
@@ -100,7 +100,7 @@ public class MyChatBubbleFragment extends BaseBindingFragment<FrgMyDecorationCom
|
||||
})
|
||||
.subscribe(s -> {
|
||||
for (int i = 0; i < bubbleAdapter.getData().size(); i++) {
|
||||
bubbleAdapter.getData().get(i).setUsed(Objects.equals(cardId, bubbleAdapter.getData().get(i).getBubbleId()));
|
||||
bubbleAdapter.getData().get(i).setHasUsed(Objects.equals(cardId, bubbleAdapter.getData().get(i).getBubbleId()));
|
||||
}
|
||||
bubbleAdapter.notifyDataSetChanged();
|
||||
//更新用户信息
|
||||
|
@@ -1,13 +1,20 @@
|
||||
package com.yizhuan.erban.ui.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.NinePatch;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
import androidx.annotation.DrawableRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import android.graphics.drawable.NinePatchDrawable;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
|
||||
@@ -39,7 +46,11 @@ import com.yizhuan.xchat_android_core.utils.SystemUtils;
|
||||
import com.yizhuan.xchat_android_library.utils.codec.MD5Utils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import io.reactivex.Single;
|
||||
@@ -549,4 +560,35 @@ public class ImageLoadUtils {
|
||||
|
||||
}
|
||||
|
||||
public static void loadNinePatchBg(View view, String bgUrl) {
|
||||
GlideApp.with(view)
|
||||
.asBitmap()
|
||||
.load(bgUrl)
|
||||
.into(new CustomTarget<Bitmap>() {
|
||||
@Override
|
||||
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
|
||||
try {
|
||||
NinePatchDrawable drawable = NinePatchBitmapFactory.createNinePatchDrawable(view.getResources(), resource);
|
||||
view.setBackground(drawable);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadCleared(@Nullable Drawable placeholder) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFailed(@Nullable Drawable errorDrawable) {
|
||||
super.onLoadFailed(errorDrawable);
|
||||
LogUtils.d("onLoadFailed");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,194 @@
|
||||
package com.yizhuan.erban.ui.utils;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.NinePatchDrawable;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* User: bgriffey
|
||||
* Date: 12/27/12
|
||||
* Time: 2:37 PM
|
||||
*/
|
||||
public class NinePatchBitmapFactory {
|
||||
|
||||
private static final int NO_COLOR = 0x00000001;
|
||||
|
||||
private static final int TRANSPARENT_COLOR = 0x00000000;
|
||||
|
||||
public static NinePatchDrawable createNinePatchDrawable(Resources res, Bitmap bitmap) {
|
||||
RangeLists rangeLists = checkBitmap(bitmap);
|
||||
Bitmap trimedBitmap = trimBitmap(bitmap);
|
||||
NinePatchDrawable drawable = createNinePatchWithCapInsets(res, trimedBitmap, rangeLists.rangeListX, rangeLists.rangeListY, null);
|
||||
return drawable;
|
||||
}
|
||||
|
||||
|
||||
public static NinePatchDrawable createNinePatchWithCapInsets(Resources res, Bitmap bitmap,
|
||||
List<Range> rangeListX, List<Range> rangeListY, String srcName) {
|
||||
ByteBuffer buffer = getByteBuffer(rangeListX, rangeListY);
|
||||
NinePatchDrawable drawable = new NinePatchDrawable(res, bitmap, buffer.array(), new Rect(), srcName);
|
||||
return drawable;
|
||||
}
|
||||
|
||||
private static ByteBuffer getByteBuffer(List<Range> rangeListX, List<Range> rangeListY) {
|
||||
ByteBuffer buffer = ByteBuffer.allocate(4 + 4 * 7 + 4 * 2 * rangeListX.size() + 4 * 2 * rangeListY.size() + 4 * 9).order(ByteOrder.nativeOrder());
|
||||
buffer.put((byte) 0x01); // was serialised
|
||||
buffer.put((byte) (rangeListX.size() * 2)); // x div
|
||||
buffer.put((byte) (rangeListY.size() * 2)); // y div
|
||||
buffer.put((byte) 0x09); // color
|
||||
|
||||
// skip
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
|
||||
// padding
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
|
||||
// skip 4 bytes
|
||||
buffer.putInt(0);
|
||||
|
||||
for (Range range : rangeListX) {
|
||||
buffer.putInt(range.start);
|
||||
buffer.putInt(range.end);
|
||||
}
|
||||
for (Range range : rangeListY) {
|
||||
buffer.putInt(range.start);
|
||||
buffer.putInt(range.end);
|
||||
}
|
||||
buffer.putInt(NO_COLOR);
|
||||
buffer.putInt(NO_COLOR);
|
||||
buffer.putInt(NO_COLOR);
|
||||
buffer.putInt(NO_COLOR);
|
||||
buffer.putInt(NO_COLOR);
|
||||
buffer.putInt(NO_COLOR);
|
||||
buffer.putInt(NO_COLOR);
|
||||
buffer.putInt(NO_COLOR);
|
||||
buffer.putInt(NO_COLOR);
|
||||
|
||||
return buffer;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static RangeLists checkBitmap(Bitmap bitmap) {
|
||||
int width = bitmap.getWidth();
|
||||
int height = bitmap.getHeight();
|
||||
|
||||
List<Range> rangeListX = new ArrayList<>();
|
||||
|
||||
int pos = -1;
|
||||
for (int i = 1; i < width - 1; i++) {
|
||||
int color = bitmap.getPixel(i, 0);
|
||||
int alpha = Color.alpha(color);
|
||||
int red = Color.red(color);
|
||||
int green = Color.green(color);
|
||||
int blue = Color.blue(color);
|
||||
if (alpha == 255 && red == 0 && green == 0 && blue == 0) {
|
||||
if (pos == -1) {
|
||||
pos = i - 1;
|
||||
}
|
||||
} else {
|
||||
if (pos != -1) {
|
||||
Range range = new Range();
|
||||
range.start = pos;
|
||||
range.end = i - 1;
|
||||
rangeListX.add(range);
|
||||
pos = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pos != -1) {
|
||||
Range range = new Range();
|
||||
range.start = pos;
|
||||
range.end = width - 2;
|
||||
rangeListX.add(range);
|
||||
}
|
||||
List<Range> rangeListY = new ArrayList<Range>();
|
||||
|
||||
pos = -1;
|
||||
for (int i = 1; i < height - 1; i++) {
|
||||
int color = bitmap.getPixel(0, i);
|
||||
int alpha = Color.alpha(color);
|
||||
int red = Color.red(color);
|
||||
int green = Color.green(color);
|
||||
int blue = Color.blue(color);
|
||||
if (alpha == 255 && red == 0 && green == 0 && blue == 0) {
|
||||
if (pos == -1) {
|
||||
pos = i - 1;
|
||||
}
|
||||
} else {
|
||||
if (pos != -1) {
|
||||
Range range = new Range();
|
||||
range.start = pos;
|
||||
range.end = i - 1;
|
||||
rangeListY.add(range);
|
||||
pos = -1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (pos != -1) {
|
||||
Range range = new Range();
|
||||
range.start = pos;
|
||||
range.end = height - 2;
|
||||
rangeListY.add(range);
|
||||
}
|
||||
RangeLists rangeLists = new RangeLists();
|
||||
rangeLists.rangeListX = rangeListX;
|
||||
rangeLists.rangeListY = rangeListY;
|
||||
|
||||
return rangeLists;
|
||||
}
|
||||
|
||||
public static Bitmap trimBitmap(Bitmap bitmap) {
|
||||
int width = bitmap.getWidth();
|
||||
int height = bitmap.getHeight();
|
||||
|
||||
Bitmap result = Bitmap.createBitmap(bitmap, 1, 1, width - 2, height - 2);
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
public static Bitmap loadBitmap(File file) {
|
||||
BufferedInputStream bis = null;
|
||||
try {
|
||||
bis = new BufferedInputStream(new FileInputStream(file));
|
||||
return BitmapFactory.decodeStream(bis);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
bis.close();
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static class RangeLists {
|
||||
public List<Range> rangeListX;
|
||||
public List<Range> rangeListY;
|
||||
}
|
||||
|
||||
public static class Range {
|
||||
public int start;
|
||||
public int end;
|
||||
}
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 9.2 KiB |
@@ -7,7 +7,7 @@
|
||||
|
||||
<variable
|
||||
name="headWearInfo"
|
||||
type="com.yizhuan.xchat_android_core.decoration.headwear.bean.UserCardWearInfo" />
|
||||
type="com.yizhuan.xchat_android_core.decoration.headwear.bean.ChatBubbleInfo" />
|
||||
</data>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
@@ -72,10 +72,10 @@
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_marginEnd="@dimen/dp_9"
|
||||
android:background="@{headWearInfo.used ? @drawable/bg_common_cancel : @drawable/bg_common_confirm}"
|
||||
android:background="@{headWearInfo.hasUsed ? @drawable/bg_common_cancel : @drawable/bg_common_confirm}"
|
||||
android:gravity="center"
|
||||
android:text="@{headWearInfo.used ? @string/label_used : @string/label_can_use}"
|
||||
android:textColor="@{headWearInfo.used ? @color/color_4C5AF1 : @color/white}"
|
||||
android:text="@{headWearInfo.hasUsed ? @string/label_used : @string/label_can_use}"
|
||||
android:textColor="@{headWearInfo.hasUsed ? @color/color_4C5AF1 : @color/white}"
|
||||
android:textSize="14sp"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
|
@@ -131,7 +131,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_above="@+id/fl_speedy_message"
|
||||
android:layout_below="@id/message_view"
|
||||
android:layout_below="@id/vip_broadcast_view"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_marginTop="@dimen/dp_10"
|
||||
android:layout_marginEnd="90dp"
|
||||
|
@@ -11,6 +11,6 @@ public class ChatBubbleInfo {
|
||||
private boolean hasExpired;
|
||||
private String name;
|
||||
private String bubbleUrl;
|
||||
private boolean used;
|
||||
private boolean hasUsed;
|
||||
private int labelType;
|
||||
}
|
||||
|
@@ -48,6 +48,8 @@ public class UserInfo implements Serializable {
|
||||
public static String NAMEPLATE_WORD = "inRoomNameplateWord";
|
||||
public static String NAMEPLATE_PIC = "inRoomNameplatePic";
|
||||
public static String VIP_ICON = "vipIcon";
|
||||
public static String BUBBLE_URL_ANDROID = "androidBubbleUrl";
|
||||
public static String BUBBLE_URL_IOS = "iosBubbleUrl";
|
||||
/**
|
||||
* PK的时候队伍ID
|
||||
* GroupType_default = 0,//默认
|
||||
@@ -247,6 +249,13 @@ public class UserInfo implements Serializable {
|
||||
@Setter
|
||||
private LiveTagInfo userInfoSkillVo;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private String androidBubbleUrl;
|
||||
@Getter
|
||||
@Setter
|
||||
private String iosBubbleUrl;
|
||||
|
||||
public UserInfo() {
|
||||
|
||||
}
|
||||
@@ -345,21 +354,7 @@ public class UserInfo implements Serializable {
|
||||
this.userRankList = userRankList;
|
||||
}
|
||||
|
||||
//
|
||||
// public String getBirthStr(){
|
||||
// return TimeUtil.getDateTimeString(Long.valueOf(birth),"yyyy-MM-dd");
|
||||
// }
|
||||
// public void setBirth(String birth) {
|
||||
// this.birth = birth;
|
||||
// }
|
||||
//
|
||||
// public String getStar() {
|
||||
// if(null != birth){
|
||||
// return StarUtils.getConstellation(new Date(Long.valueOf(birth)/1000));
|
||||
// }else{
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
|
||||
public long getUid() {
|
||||
return uid;
|
||||
}
|
||||
@@ -597,6 +592,14 @@ public class UserInfo implements Serializable {
|
||||
map.put(VIP_ICON, userVipInfo.getVipIcon());
|
||||
}
|
||||
|
||||
if (!TextUtils.isEmpty(androidBubbleUrl)) {
|
||||
map.put(BUBBLE_URL_ANDROID, androidBubbleUrl);
|
||||
}
|
||||
|
||||
if (!TextUtils.isEmpty(iosBubbleUrl)) {
|
||||
map.put(BUBBLE_URL_IOS, androidBubbleUrl);
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user