喇叭,个人中心贵族添加中心
This commit is contained in:
@@ -14,6 +14,7 @@ import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.CommonAppContext;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.bean.FansMedalBean;
|
||||
import com.yunbao.common.bean.MsgModel;
|
||||
import com.yunbao.common.bean.SocketModel;
|
||||
import com.yunbao.common.bean.UserBean;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
@@ -441,8 +442,10 @@ public class SocketRyClient {
|
||||
break;
|
||||
case Constants.TRUMPET_NOTIFY://全站喇叭
|
||||
SocketModel model = GsonUtils.fromJson(socketMsg, SocketModel.class);
|
||||
Log.e(Constants.TRUMPET_NOTIFY,model.getMsg().get(0).getTrumpetMsg());
|
||||
Log.e(Constants.TRUMPET_NOTIFY,model.getMsg().get(0).getUserName());
|
||||
List<MsgModel> msg = model.getMsg();
|
||||
if (msg.size() > 0) {
|
||||
EventBus.getDefault().post(msg.get(0));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,28 +1,39 @@
|
||||
package com.yunbao.live.views;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.os.CountDownTimer;
|
||||
import android.os.Handler;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.ViewFlipper;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.opensource.svgaplayer.SVGACallback;
|
||||
import com.opensource.svgaplayer.SVGADrawable;
|
||||
import com.opensource.svgaplayer.SVGAImageView;
|
||||
import com.opensource.svgaplayer.SVGAParser;
|
||||
import com.opensource.svgaplayer.SVGAVideoEntity;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.bean.MsgModel;
|
||||
import com.yunbao.common.event.MessageIMEvent;
|
||||
import com.yunbao.common.event.UpdateTablePoint;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.http.HttpClient;
|
||||
import com.yunbao.common.manager.imrongcloud.MessageIMManager;
|
||||
@@ -41,11 +52,6 @@ import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
import static com.yunbao.live.views.LiveRoomViewHolder.mNameText;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/10/9.
|
||||
* 观众直播间逻辑
|
||||
@@ -58,9 +64,13 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder {
|
||||
private String url;
|
||||
private LinearLayout lt_trickery;
|
||||
private TextView tv_trickery_time;
|
||||
private View v_msg_redpoint;
|
||||
private View v_msg_redpoint, stationHornBanner;
|
||||
private Activity context;
|
||||
private SVGAImageView svga_new_user_gif,svga_new_user_double,svga_new_user_follow;
|
||||
private SVGAImageView svga_new_user_gif, svga_new_user_double, svga_new_user_follow, svga_station_horn;
|
||||
private ViewFlipper viewFlipper;
|
||||
private TextView goToRomm;
|
||||
private int icon = 0;
|
||||
private String nobleName, nobleTtext;
|
||||
|
||||
public LiveAudienceViewHolder(Context context, ViewGroup parentView) {
|
||||
super(context, parentView);
|
||||
@@ -71,30 +81,30 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder {
|
||||
public void onUpdata(String str) {
|
||||
if ("svga_new_user_gif".equals(str)) {
|
||||
svga_new_user_gif();
|
||||
}else if ("svga_new_user_double".equals(str)) {
|
||||
} else if ("svga_new_user_double".equals(str)) {
|
||||
svga_new_user_double();
|
||||
}else if ("svga_new_user_follow".equals(str)) {
|
||||
} else if ("svga_new_user_follow".equals(str)) {
|
||||
svga_new_user_follow();
|
||||
}else if("stop_svga_new_user_double".equals(str)){
|
||||
} else if ("stop_svga_new_user_double".equals(str)) {
|
||||
svga_new_user_double.setVisibility(View.GONE);
|
||||
svga_new_user_double.stopAnimation();
|
||||
svga_new_user_double.clear();
|
||||
} else if("stop_svga_new_user_follow".equals(str)) {
|
||||
} else if ("stop_svga_new_user_follow".equals(str)) {
|
||||
svga_new_user_follow.setVisibility(View.GONE);
|
||||
svga_new_user_follow.stopAnimation();
|
||||
svga_new_user_follow.clear();
|
||||
}else if("stop_svga_new_user_gif".equals(str)) {
|
||||
} else if ("stop_svga_new_user_gif".equals(str)) {
|
||||
svga_new_user_gif.setVisibility(View.GONE);
|
||||
svga_new_user_gif.stopAnimation();
|
||||
svga_new_user_gif.clear();
|
||||
}else if("name_true".equals(str)){
|
||||
if(LiveRoomViewHolder.mName.getText().length()<=4){
|
||||
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(DpUtil.dp2px(116),DpUtil.dp2px(40));
|
||||
layoutParams.setMargins(DpUtil.dp2px(80),DpUtil.dp2px(80),0,0);
|
||||
} else if ("name_true".equals(str)) {
|
||||
if (LiveRoomViewHolder.mName.getText().length() <= 4) {
|
||||
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(DpUtil.dp2px(116), DpUtil.dp2px(40));
|
||||
layoutParams.setMargins(DpUtil.dp2px(80), DpUtil.dp2px(80), 0, 0);
|
||||
svga_new_user_follow.setLayoutParams(layoutParams);
|
||||
}else{
|
||||
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(DpUtil.dp2px(116),DpUtil.dp2px(40));
|
||||
layoutParams.setMargins(DpUtil.dp2px(100),DpUtil.dp2px(80),0,0);
|
||||
} else {
|
||||
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(DpUtil.dp2px(116), DpUtil.dp2px(40));
|
||||
layoutParams.setMargins(DpUtil.dp2px(100), DpUtil.dp2px(80), 0, 0);
|
||||
svga_new_user_follow.setLayoutParams(layoutParams);
|
||||
}
|
||||
}
|
||||
@@ -102,7 +112,7 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder {
|
||||
}
|
||||
|
||||
|
||||
private void svga_new_user_gif(){
|
||||
private void svga_new_user_gif() {
|
||||
new SVGAParser(mContext).decodeFromAssets("free_gift_tip.svga", new SVGAParser.ParseCompletion() {
|
||||
@Override
|
||||
public void onComplete(SVGAVideoEntity videoItem) {
|
||||
@@ -113,10 +123,11 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder {
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
Log.e("errqs","errl");
|
||||
Log.e("errqs", "errl");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void svga_new_user_double() {
|
||||
new SVGAParser(mContext).decodeFromAssets("double_click_tip.svga", new SVGAParser.ParseCompletion() {
|
||||
@Override
|
||||
@@ -133,6 +144,7 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void svga_new_user_follow() {
|
||||
new SVGAParser(mContext).decodeFromAssets("live_follow_tip.svga", new SVGAParser.ParseCompletion() {
|
||||
@Override
|
||||
@@ -149,6 +161,7 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder {
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.view_live_audience;
|
||||
@@ -163,11 +176,12 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder {
|
||||
findViewById(R.id.btn_red_pack).setOnClickListener(this);
|
||||
findViewById(R.id.btn_gift).setOnClickListener(this);
|
||||
findViewById(R.id.btn_zg).setOnClickListener(this);
|
||||
svga_new_user_gif = (SVGAImageView)findViewById(R.id.svga_new_user_gif);
|
||||
svga_new_user_double = (SVGAImageView)findViewById(R.id.svga_new_user_double);
|
||||
svga_new_user_follow = (SVGAImageView)findViewById(R.id.svga_new_user_follow);
|
||||
|
||||
|
||||
svga_new_user_gif = (SVGAImageView) findViewById(R.id.svga_new_user_gif);
|
||||
svga_new_user_double = (SVGAImageView) findViewById(R.id.svga_new_user_double);
|
||||
svga_new_user_follow = (SVGAImageView) findViewById(R.id.svga_new_user_follow);
|
||||
svga_station_horn = (SVGAImageView) findViewById(R.id.svga_station_horn);
|
||||
viewFlipper = (ViewFlipper) findViewById(R.id.viewflipper_banner);
|
||||
stationHornBanner = findViewById(R.id.station_horn_banner);
|
||||
svga_new_user_double.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
@@ -179,7 +193,7 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder {
|
||||
public void onClick(View v) {
|
||||
//获取房间连麦状态
|
||||
HttpClient.getInstance().get("live.getDrLm", "live.getDrLm")
|
||||
.params("uid", mLiveUid,true)
|
||||
.params("uid", mLiveUid, true)
|
||||
.execute(new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
@@ -217,6 +231,65 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder {
|
||||
v_msg_redpoint = (View) findViewById(R.id.v_msg_redpoint);
|
||||
//获取系统未读消息
|
||||
MessageIMManager.get(mContext).getSystemMessages();
|
||||
//全站喇叭
|
||||
svga_station_horn.setCallback(new SVGACallback() {
|
||||
@Override
|
||||
public void onPause() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinished() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRepeat() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStep(int frame, double percentage) {
|
||||
Log.e("SVGADynamicEntity", "frame:" + frame);
|
||||
Log.e("SVGADynamicEntity", "percentage:" + percentage);
|
||||
if ((int) (percentage * 100) == 5) {
|
||||
viewFlipper.removeAllViews();
|
||||
stationHornBanner.setVisibility(View.VISIBLE);
|
||||
if ((nobleName + nobleTtext).length() > 15) {
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
//展示内容子布局
|
||||
View childrenView = LayoutInflater.from(mContext).inflate(R.layout.view_whole_station_horn, null, false);
|
||||
ImageView iconImg = childrenView.findViewById(R.id.icon_img);
|
||||
TextView userName = childrenView.findViewById(R.id.rc_user_name);
|
||||
TextView userText = childrenView.findViewById(R.id.rc_user_text);
|
||||
userName.setText(nobleName);
|
||||
userText.setText(" : " + nobleTtext);
|
||||
ImgLoader.display2(mContext, icon, iconImg);
|
||||
viewFlipper.addView(childrenView);
|
||||
}
|
||||
|
||||
} else {
|
||||
//展示内容子布局
|
||||
View childrenView = LayoutInflater.from(mContext).inflate(R.layout.view_whole_station_horn, null, false);
|
||||
ImageView iconImg = childrenView.findViewById(R.id.icon_img);
|
||||
TextView userName = childrenView.findViewById(R.id.rc_user_name);
|
||||
TextView userText = childrenView.findViewById(R.id.rc_user_text);
|
||||
userName.setText(nobleName);
|
||||
userText.setText(" : " + nobleTtext);
|
||||
ImgLoader.display2(mContext, icon, iconImg);
|
||||
viewFlipper.addView(childrenView);
|
||||
}
|
||||
|
||||
}
|
||||
if ((int) (percentage * 100) == 50 && viewFlipper.getChildCount() > 1) {
|
||||
viewFlipper.showNext();
|
||||
}
|
||||
if ((int) (percentage * 100) == 92) {
|
||||
stationHornBanner.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static Handler handler = new Handler();
|
||||
@@ -503,4 +576,83 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder {
|
||||
super.release();
|
||||
EventBus.getDefault().unregister(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 绘制全站喇叭的样式
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@SuppressLint("SetTextI18n")
|
||||
private Bitmap canvasBitmap(int icon, String name, String text) {
|
||||
// Log.e("SVGADynamicEntity", "子布局宽度:" + name);
|
||||
// Log.e("SVGADynamicEntity", "fu布局宽度:" + text);
|
||||
//计算设备分辨率
|
||||
WindowManager manager = ((Activity) mContext).getWindowManager();
|
||||
DisplayMetrics metrics = new DisplayMetrics();
|
||||
manager.getDefaultDisplay().getMetrics(metrics);
|
||||
int width = metrics.widthPixels;
|
||||
int height = metrics.heightPixels;
|
||||
View view = LayoutInflater.from(mContext).inflate(R.layout.view_whole_station_horn_layout, null, false);
|
||||
ViewFlipper viewFlipper = view.findViewById(R.id.viewflipper_banner);
|
||||
//展示内容子布局
|
||||
View childrenView = LayoutInflater.from(mContext).inflate(R.layout.view_whole_station_horn, null, false);
|
||||
ImageView iconImg = childrenView.findViewById(R.id.icon_img);
|
||||
TextView userName = childrenView.findViewById(R.id.rc_user_name);
|
||||
TextView userText = childrenView.findViewById(R.id.rc_user_text);
|
||||
userName.setText(name);
|
||||
userText.setText(" : " + text);
|
||||
ImgLoader.display2(mContext, icon, iconImg);
|
||||
viewFlipper.addView(childrenView);
|
||||
//测量使得view指定大小
|
||||
int measureWidth = View.MeasureSpec.makeMeasureSpec(width / 3 * 2 - 30, View.MeasureSpec.AT_MOST);
|
||||
int measureHeight = View.MeasureSpec.makeMeasureSpec(height, View.MeasureSpec.AT_MOST);
|
||||
view.measure(measureWidth, measureHeight);
|
||||
//调用layout方法布局后,可以得到view的尺寸
|
||||
view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight());
|
||||
// Log.e("SVGADynamicEntity", "子布局宽度:" + childrenView.getWidth());
|
||||
// Log.e("SVGADynamicEntity", "fu布局宽度:" + (width / 3 * 2 - 30));
|
||||
Bitmap bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888);
|
||||
Canvas bitmapCanvas = new Canvas(bitmap);
|
||||
bitmapCanvas.drawColor(Color.TRANSPARENT);
|
||||
view.draw(bitmapCanvas);
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 全站喇叭
|
||||
*/
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onMsgModelEvent(MsgModel model) {
|
||||
nobleName = model.getUserName();
|
||||
nobleTtext = model.getTrumpetMsg();
|
||||
if (!svga_station_horn.isAnimating()) {
|
||||
svga_station_horn.setLoops(1);
|
||||
String backPath = "";
|
||||
|
||||
if (model.getNobleId() == 5) {
|
||||
backPath = "icon_livemsgbg_guowang.svga";
|
||||
icon = R.mipmap.imng_guowang;
|
||||
} else if (model.getNobleId() == 6) {
|
||||
backPath = "icon_livemsgbg_huangdi.svga";
|
||||
icon = R.mipmap.img_huangdi;
|
||||
} else {
|
||||
backPath = "icon_livemsgbg_chaohuang.svga";
|
||||
icon = R.mipmap.img_chaohuang;
|
||||
}
|
||||
new SVGAParser(mContext).decodeFromAssets(backPath, new SVGAParser.ParseCompletion() {
|
||||
@Override
|
||||
public void onComplete(SVGAVideoEntity videoItem) {
|
||||
SVGADrawable drawable = new SVGADrawable(videoItem);
|
||||
svga_station_horn.setImageDrawable(drawable);
|
||||
svga_station_horn.startAnimation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
Log.e("errqs", "errl");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user