diff --git a/app/agconnect-services.json b/app/agconnect-services.json new file mode 100644 index 000000000..34dcec94e --- /dev/null +++ b/app/agconnect-services.json @@ -0,0 +1,92 @@ +{ + "agcgw":{ + "backurl":"connect-drcn.hispace.hicloud.com", + "url":"connect-drcn.dbankcloud.cn", + "websocketbackurl":"connect-ws-drcn.hispace.dbankcloud.com", + "websocketurl":"connect-ws-drcn.hispace.dbankcloud.cn" + }, + "agcgw_all":{ + "CN":"connect-drcn.dbankcloud.cn", + "CN_back":"connect-drcn.hispace.hicloud.com", + "DE":"connect-dre.dbankcloud.cn", + "DE_back":"connect-dre.hispace.hicloud.com", + "RU":"connect-drru.hispace.dbankcloud.ru", + "RU_back":"connect-drru.hispace.dbankcloud.cn", + "SG":"connect-dra.dbankcloud.cn", + "SG_back":"connect-dra.hispace.hicloud.com" + }, + "websocketgw_all":{ + "CN":"connect-ws-drcn.hispace.dbankcloud.cn", + "CN_back":"connect-ws-drcn.hispace.dbankcloud.com", + "DE":"connect-ws-dre.hispace.dbankcloud.cn", + "DE_back":"connect-ws-dre.hispace.dbankcloud.com", + "RU":"connect-ws-drru.hispace.dbankcloud.ru", + "RU_back":"connect-ws-drru.hispace.dbankcloud.cn", + "SG":"connect-ws-dra.hispace.dbankcloud.cn", + "SG_back":"connect-ws-dra.hispace.dbankcloud.com" + }, + "client":{ + "cp_id":"30086000612391734", + "product_id":"99536292102564216", + "client_id":"964994320723627840", + "client_secret":"6D5FE29D85B967D3A66BDCD473641E4C7B5524F7F4935CA0EF4A842730C3402D", + "project_id":"99536292102564216", + "app_id":"106936673", + "api_key":"DAEDADYGta/0O4ZSdrnug52NgC67/w/RIyTq9A8LyAY0+mp6g6XeJDbxugpluFPLAhaqjaMs5c0PLnRx14UzWbPPADgi1EqihbWLoA==", + "package_name":"com.pdlive.shayu" + }, + "oauth_client":{ + "client_id":"106936673", + "client_type":1 + }, + "app_info":{ + "app_id":"106936673", + "package_name":"com.pdlive.shayu" + }, + "service":{ + "analytics":{ + "collector_url":"datacollector-drcn.dt.hicloud.com,datacollector-drcn.dt.dbankcloud.cn", + "collector_url_ru":"datacollector-drru.dt.dbankcloud.ru,datacollector-drru.dt.hicloud.com", + "collector_url_sg":"datacollector-dra.dt.hicloud.com,datacollector-dra.dt.dbankcloud.cn", + "collector_url_de":"datacollector-dre.dt.hicloud.com,datacollector-dre.dt.dbankcloud.cn", + "collector_url_cn":"datacollector-drcn.dt.hicloud.com,datacollector-drcn.dt.dbankcloud.cn", + "resource_id":"p1", + "channel_id":"" + }, + "search":{ + "url":"https://search-drcn.cloud.huawei.com" + }, + "cloudstorage":{ + "storage_url_sg_back":"https://agc-storage-dra.cloud.huawei.asia", + "storage_url_ru_back":"https://agc-storage-drru.cloud.huawei.ru", + "storage_url_ru":"https://agc-storage-drru.cloud.huawei.ru", + "storage_url_de_back":"https://agc-storage-dre.cloud.huawei.eu", + "storage_url_de":"https://ops-dre.agcstorage.link", + "storage_url":"https://agc-storage-drcn.platform.dbankcloud.cn", + "storage_url_sg":"https://ops-dra.agcstorage.link", + "storage_url_cn_back":"https://agc-storage-drcn.cloud.huawei.com.cn", + "storage_url_cn":"https://agc-storage-drcn.platform.dbankcloud.cn" + }, + "ml":{ + "mlservice_url":"ml-api-drcn.ai.dbankcloud.com,ml-api-drcn.ai.dbankcloud.cn" + } + }, + "region":"CN", + "configuration_version":"3.0", + "appInfos":[ + { + "package_name":"com.pdlive.shayu", + "client":{ + "app_id":"106936673" + }, + "app_info":{ + "package_name":"com.pdlive.shayu", + "app_id":"106936673" + }, + "oauth_client":{ + "client_type":1, + "client_id":"106936673" + } + } + ] +} \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 59eb31b94..2896af99a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -110,4 +110,6 @@ dependencies { //短视频 api project(':video') annotationProcessor rootProject.ext.dependencies["arouter-compiler"] + + } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index fa8da8be4..f11913b70 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -91,20 +91,20 @@ android:theme="@style/AppTheme" android:usesCleartextTraffic="true" tools:replace="theme,label,icon,allowBackup"> - - - - - - - - + - + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/shayu/phonelive/AppContext.java b/app/src/main/java/com/shayu/phonelive/AppContext.java index d08d84b24..b4b8498b4 100644 --- a/app/src/main/java/com/shayu/phonelive/AppContext.java +++ b/app/src/main/java/com/shayu/phonelive/AppContext.java @@ -101,6 +101,8 @@ public class AppContext extends CommonAppContext { @Override public void onCreate() { super.onCreate(); + //注册全局异常捕获 + //registerError(); sInstance = this; L.setDeBug(BuildConfig.DEBUG); AppEventsLogger.activateApp(this); @@ -118,11 +120,6 @@ public class AppContext extends CommonAppContext { } ARouter.init(this); - //谷歌推送 - PushConfig gconfig = new PushConfig.Builder() - .enableFCM(true) - .build(); - RongPushClient.setPushConfig(gconfig); //初始化 邀请码库 if (isMainProcess()) { @@ -180,7 +177,7 @@ public class AppContext extends CommonAppContext { msg.obj = content.getContent(); if (SocketRyClient.mSocketHandler != null && (TextUtils.equals("__system__", message.getTargetId()) - || (TextUtils.equals("g" + PortraitLiveManager.liveID, message.getTargetId())))) { + || ("g" + PortraitLiveManager.liveID).contains(message.getTargetId()))) { SocketRyClient.mSocketHandler.sendMessage(msg); } } @@ -192,6 +189,7 @@ public class AppContext extends CommonAppContext { } }); + //监听im消息 V2TIMManager.getInstance().addSimpleMsgListener(new V2TIMSimpleMsgListener() { @Override @@ -238,4 +236,21 @@ public class AppContext extends CommonAppContext { RongcloudIMManager.removeRongcloudIMOnReceiveMessageListener(); super.onTerminate(); } + + /** + * 注册全局异常捕获,有需要时可以在onCreate调用 + */ + private void registerError() { + NeverCrashUtils.getInstance() + .setDebugMode(BuildConfig.DEBUG) + .setMainCrashHandler((t, e) -> { + Log.e("ApplicationError", "主线程异常");//此处log只是展示,当debug为true时,主类内部log会打印异常信息 + e.printStackTrace(); + }) + .setUncaughtCrashHandler((t, e) -> { + Log.e("ApplicationError", "子线程异常");//此处log只是展示,当debug为true时,主类内部log会打印异常信息 + e.printStackTrace(); + }) + .register(this); + } } diff --git a/app/src/main/java/com/shayu/phonelive/NeverCrashUtils.java b/app/src/main/java/com/shayu/phonelive/NeverCrashUtils.java new file mode 100644 index 000000000..bf9b557c4 --- /dev/null +++ b/app/src/main/java/com/shayu/phonelive/NeverCrashUtils.java @@ -0,0 +1,110 @@ +package com.shayu.phonelive; +import android.app.Application; +import android.os.Handler; +import android.os.Looper; +import android.util.Log; + +/** + * @ClassName NeverCrashUtils + * @Description 全局捕获异常 + */ +public class NeverCrashUtils { + + private final static String TAG = NeverCrashUtils.class.getSimpleName(); + private final static NeverCrashUtils INSTANCE = new NeverCrashUtils(); + + private boolean debugMode; + private MainCrashHandler mainCrashHandler; + private UncaughtCrashHandler uncaughtCrashHandler; + + private NeverCrashUtils() { + } + + public static NeverCrashUtils getInstance() { + return INSTANCE; + } + + private synchronized MainCrashHandler getMainCrashHandler() { + if (null == mainCrashHandler) { + mainCrashHandler = (t, e) -> { + }; + } + return mainCrashHandler; + } + + /** + * 主线程发生异常时的回调,可用于打印日志文件 + *

+ * 注意跨线程操作的可能 + */ + public NeverCrashUtils setMainCrashHandler(MainCrashHandler mainCrashHandler) { + mainCrashHandler = mainCrashHandler; + return this; + } + + private synchronized UncaughtCrashHandler getUncaughtCrashHandler() { + if (null == uncaughtCrashHandler) { + uncaughtCrashHandler = (t, e) -> { + }; + } + return uncaughtCrashHandler; + } + + /** + * 子线程发生异常时的回调,可用于打印日志文件 + *

+ * 注意跨线程操作的可能 + */ + public NeverCrashUtils setUncaughtCrashHandler(UncaughtCrashHandler uncaughtCrashHandler) { + this.uncaughtCrashHandler = uncaughtCrashHandler; + return this; + } + + private boolean isDebugMode() { + return debugMode; + } + + /** + * debug模式,会打印log日志,且toast提醒发生异常,反之则都没有 + */ + public NeverCrashUtils setDebugMode(boolean debugMode) { + this.debugMode = debugMode; + return this; + } + + /** + * 完成监听异常的注册 + * @param application application + */ + public void register(Application application) { + //主线程异常拦截 + new Handler(Looper.getMainLooper()).post(() -> { + while (true) { + try { + Looper.loop(); + } catch (Throwable e) { + if (isDebugMode()) { + Log.e(TAG, "未捕获的主线程异常行为", e); + } + getMainCrashHandler().mainException(Looper.getMainLooper().getThread(), e); + } + } + }); + + //子线程异常拦截 + Thread.setDefaultUncaughtExceptionHandler((t, e) -> { + if (isDebugMode()) { + Log.e(TAG, "未捕获的子线程异常行为", e); + } + getUncaughtCrashHandler().uncaughtException(t, e); + }); + } + + public interface MainCrashHandler { + void mainException(Thread t, Throwable e); + } + + public interface UncaughtCrashHandler { + void uncaughtException(Thread t, Throwable e); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/shayu/phonelive/activity/LauncherActivity.java b/app/src/main/java/com/shayu/phonelive/activity/LauncherActivity.java index aa2fd57ee..f04f54a46 100644 --- a/app/src/main/java/com/shayu/phonelive/activity/LauncherActivity.java +++ b/app/src/main/java/com/shayu/phonelive/activity/LauncherActivity.java @@ -31,6 +31,8 @@ import com.tencent.rtmp.TXLivePlayer; import com.tencent.rtmp.ui.TXCloudVideoView; import com.tencent.ugc.TXUGCBase; import com.yunbao.common.CommonAppConfig; +import com.yunbao.common.Constants; +import com.yunbao.common.activity.WebViewActivity; import com.yunbao.common.bean.AdBean; import com.yunbao.common.bean.ConfigBean; import com.yunbao.common.bean.IMLoginModel; @@ -40,6 +42,7 @@ import com.yunbao.common.event.DataUserInfoEvent; import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.http.CommonHttpConsts; import com.yunbao.common.http.CommonHttpUtil; +import com.yunbao.common.http.HttpCallback; import com.yunbao.common.interfaces.CommonCallback; import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.manager.imrongcloud.RongcloudIMManager; @@ -50,11 +53,17 @@ import com.yunbao.common.utils.RouteUtil; import com.yunbao.common.utils.SpUtil; import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.WordUtil; +import com.yunbao.live.activity.LiveAudienceActivity; +import com.yunbao.live.bean.LiveBean; +import com.yunbao.live.http.LiveHttpUtil; +import com.yunbao.live.presenter.LiveRoomCheckLivePresenter; import com.yunbao.live.views.LauncherAdViewHolder; import com.yunbao.main.activity.EntryActivity; import com.yunbao.main.activity.MainActivity; +import com.yunbao.main.activity.PDLiveConversationListActivity; import com.yunbao.main.http.MainHttpConsts; import com.yunbao.main.http.MainHttpUtil; +import com.yunbao.main.manager.imrongcloud.ConversationIMListManager; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; @@ -78,8 +87,8 @@ public class LauncherActivity extends AppCompatActivity implements View.OnClickL private static final String TAG = "LauncherActivity"; private static final int WHAT_GET_CONFIG = 0; private static final int WHAT_COUNT_DOWN = 1; - private Handler mHandler; protected Context mContext; + private Handler mHandler; private ViewGroup mRoot; private ImageView mCover; private ViewGroup mContainer; @@ -261,11 +270,25 @@ public class LauncherActivity extends AppCompatActivity implements View.OnClickL */ private void forwardMainActivity() { releaseVideo(); - MainActivity.forward(mContext); + Intent intent = new Intent( + LauncherActivity.this, MainActivity.class); + intent.putExtra(Constants.SHOW_INVITE, false); + + if (getIntent().getStringExtra("liveid") != null) { + intent.putExtra("liveid", getIntent().getStringExtra("liveid")); + } + if (getIntent().getStringExtra("type") != null) { + intent.putExtra("type", getIntent().getStringExtra("type")); + } + + if (getIntent().getStringExtra("activityUrl") != null) { + intent.putExtra("activityUrl", getIntent().getStringExtra("activityUrl")); + } + + LauncherActivity.this.startActivity(intent); finish(); } - @Override protected void onDestroy() { EventBus.getDefault().unregister(this); diff --git a/app/src/main/java/com/shayu/phonelive/utils/CustomMessageReceiver.java b/app/src/main/java/com/shayu/phonelive/utils/CustomMessageReceiver.java new file mode 100644 index 000000000..7da523062 --- /dev/null +++ b/app/src/main/java/com/shayu/phonelive/utils/CustomMessageReceiver.java @@ -0,0 +1,282 @@ +package com.shayu.phonelive.utils; + +import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TOP; + +import android.annotation.SuppressLint; +import android.app.Notification; +import android.app.NotificationChannel; +import android.app.NotificationManager; +import android.app.PendingIntent; +import android.content.Context; +import android.content.Intent; +import android.graphics.Bitmap; +import android.graphics.Canvas; +import android.graphics.Paint; +import android.graphics.PorterDuff; +import android.graphics.PorterDuffXfermode; +import android.graphics.Rect; +import android.graphics.RectF; +import android.net.Uri; +import android.util.Log; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.RemoteViews; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.core.app.NotificationCompat; + +import com.bumptech.glide.Glide; +import com.bumptech.glide.request.target.SimpleTarget; +import com.bumptech.glide.request.target.Target; +import com.bumptech.glide.request.transition.Transition; +import com.makeramen.roundedimageview.RoundedImageView; +import com.shayu.phonelive.activity.LauncherActivity; +import com.yunbao.common.bean.NotificationMsgBean; +import com.yunbao.common.glide.ImgLoader; +import com.yunbao.main.activity.MainActivity; + +import org.json.JSONException; +import org.json.JSONObject; + +import io.rong.imlib.ConnectChangeReceiver; +import io.rong.push.PushType; +import io.rong.push.notification.PushMessageReceiver; +import io.rong.push.notification.PushNotificationMessage; +import myname.pdlive.shayu.R; + +public class CustomMessageReceiver extends PushMessageReceiver { + + + private String createNotificationChannel(Context context, String channelID, String channelNAME, int level) { + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { + NotificationManager manager = (NotificationManager) context.getSystemService(context.NOTIFICATION_SERVICE); + NotificationChannel channel = new NotificationChannel(channelID, channelNAME, level); + channel.setSound(Uri.parse("android.resource://" + context.getPackageName() + "/raw/pdlive_sound"),null); + manager.createNotificationChannel(channel); + return channelID; + } else { + return null; + } + } + + @Override + public boolean onNotificationMessageClicked( + Context context, PushType pushType, PushNotificationMessage message) { + if (pushType.equals(PushType.GOOGLE_FCM)) { + + Log.i("gmc", "gmc"); + + // TODO + } else { + Log.i("gmc", "gmc1111"); + } + // 返回 true 表示拦截,false 为不拦截 + return true; + } + + + NotificationMsgBean msg = new NotificationMsgBean(); + + @Override + public boolean onNotificationMessageArrived(Context context, PushType pushType, PushNotificationMessage notificationMessage) { + Log.i("gmc", notificationMessage.getPushContent() + "VVV" + notificationMessage.getPushTitle() + "gmc11112222" + notificationMessage.getExtra()); + if (notificationMessage.getExtra() == null) { + msg.setImg("" + notificationMessage.getSenderPortrait()); + msg.setTitle(notificationMessage.getPushTitle()); + msg.setContent(notificationMessage.getPushContent()); + msg.setType("-1"); + sendNotification(context, msg); + } else { + try { + JSONObject obj = new JSONObject(notificationMessage.getExtra()); + Log.i("gmc", "1111222"); + //开播 + if (obj.getString("type").equals("1") || obj.getString("type").equals("9")) { + Log.i("gmc", "1111"); + msg.setImg("" + obj.getString("avatar")); + msg.setTitle(notificationMessage.getPushTitle()); + msg.setContent(notificationMessage.getPushContent()); + msg.setLiveuid(obj.getString("liveuid")); + msg.setType("1"); + liveNotification(context, msg); + //发布动态 2 + //点赞 3 + //评论 4 + //鼓励 5 + } else if (obj.getString("type").equals("2") || obj.getString("type").equals("3") || obj.getString("type").equals("4") || obj.getString("type").equals("5")) { + msg.setImg("" + obj.getString("avatar")); + msg.setTitle(notificationMessage.getPushTitle()); + msg.setContent(notificationMessage.getPushContent()); + msg.setType("2"); + dynamicNotification(context, msg); + } else if (obj.getString("type").equals("8") || obj.getString("type").equals("7")) { + msg.setImg("" + obj.getString("avatar")); + msg.setTitle(notificationMessage.getPushTitle()); + msg.setContent(notificationMessage.getPushContent()); + msg.setType(obj.getString("type")); + msg.setActivityurl(obj.getString("activityUrl")); + serviceNotification(context, msg); + } + + } catch (JSONException e) { + Log.i("gmc", "1111" + e.getMessage()); + e.printStackTrace(); + } + } + return true; + } + + public static Bitmap makeRoundCorner(Bitmap bitmap, float roundPx) { + try { + Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), + bitmap.getHeight(), Bitmap.Config.ARGB_8888); + Canvas canvas = new Canvas(output); + final int color = 0xff424242;// 颜色值(0xff---alpha) + final Paint paint = new Paint(); + final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()); + final RectF rectF = new RectF(rect);// Rect是使用int类型作为数值,RectF是使用float类型作为数值 + // --------抗锯齿-------// + paint.setAntiAlias(true); + canvas.drawARGB(0, 0, 0, 0); + paint.setColor(color); + canvas.drawRoundRect(rectF, roundPx, roundPx, paint); + paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN)); + final Rect src = new Rect(0, 0, bitmap.getWidth(), + bitmap.getHeight()); + canvas.drawBitmap(bitmap, null, rect, paint); + return output; + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + //私聊 + private void sendNotification(Context context, NotificationMsgBean message) { + // 设置通知的点击行为:这里启动一个 Activity + Intent intent = new Intent(context, MainActivity.class); + intent.setFlags(FLAG_ACTIVITY_CLEAR_TOP); + PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0); + String channelId = createNotificationChannel(context, "my_channel_ID", "my_channel_NAME", NotificationManager.IMPORTANCE_HIGH); + // 构建 remoteView + RemoteViews remoteView = new RemoteViews(context.getPackageName(), R.layout.notification_message); + remoteView.setTextViewText(R.id.title, message.getTitle()); + remoteView.setTextViewText(R.id.content, message.getContent()); + Glide.with(context).asBitmap().load(message.getImg()).into(new SimpleTarget() { + @Override + public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition transition) { + remoteView.setImageViewBitmap(R.id.img, makeRoundCorner(resource, 50)); + + NotificationCompat.Builder builder = new NotificationCompat.Builder(context, channelId); + // 设置自定义 RemoteViews + builder.setContent(remoteView).setSmallIcon(R.drawable.small_icons); + // 设置通知的优先级(悬浮通知) + builder.setPriority(NotificationCompat.PRIORITY_MAX); + builder.setContentIntent(pendingIntent); + builder.setAutoCancel(true); + Notification notification = builder.build(); + NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); + manager.notify(0, notification); + } + }); + + } + + int id = 1; + + //动态 + private void dynamicNotification(Context context, NotificationMsgBean message) { + // 设置通知的点击行为:这里启动一个 Activity + Intent intent = new Intent(context, MainActivity.class); + intent.putExtra("type", "2"); + intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); + String channelId = createNotificationChannel(context, "my_channel_ID", "my_channel_NAME", NotificationManager.IMPORTANCE_HIGH); + // 构建 remoteView + RemoteViews remoteView = new RemoteViews(context.getPackageName(), R.layout.notification_message); + remoteView.setTextViewText(R.id.title, message.getTitle()); + remoteView.setTextViewText(R.id.content, message.getContent()); + remoteView.setImageViewResource(R.id.img, R.mipmap.ic_launcher); + + NotificationCompat.Builder builder = new NotificationCompat.Builder(context, channelId); + // 设置自定义 RemoteViews + builder.setContent(remoteView).setSmallIcon(R.drawable.small_icons); + // 设置通知的优先级(悬浮通知) + builder.setPriority(NotificationCompat.PRIORITY_MAX); + builder.setContentIntent(pendingIntent); + builder.setAutoCancel(true); + Notification notification = builder.build(); + NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); + id = (int) (id + System.currentTimeMillis()); + manager.notify(id, notification); + + } + + //开播 + private void liveNotification(Context context, NotificationMsgBean message) { + // 设置通知的点击行为:这里启动一个 Activity + Intent intent = new Intent(context, LauncherActivity.class); + intent.setFlags(FLAG_ACTIVITY_CLEAR_TOP); + intent.putExtra("liveid", message.getLiveuid()); + Log.e("gmc", message.getLiveuid() + "21121"); + PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); + String channelId = createNotificationChannel(context, "my_channel_ID", "my_channel_NAME", NotificationManager.IMPORTANCE_HIGH); + // 构建 remoteView + RemoteViews remoteView = new RemoteViews(context.getPackageName(), R.layout.notification_message); + remoteView.setTextViewText(R.id.title, message.getTitle()); + remoteView.setTextViewText(R.id.content, message.getContent()); + Glide.with(context).asBitmap().load(message.getImg()).into(new SimpleTarget() { + @Override + public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition transition) { + remoteView.setImageViewBitmap(R.id.img, makeRoundCorner(resource, 50)); + + NotificationCompat.Builder builder = new NotificationCompat.Builder(context, channelId); + // 设置自定义 RemoteViews + builder.setContent(remoteView).setSmallIcon(R.drawable.small_icons); + // 设置通知的优先级(悬浮通知) + builder.setPriority(NotificationCompat.PRIORITY_MAX); + builder.setContentIntent(pendingIntent); + builder.setAutoCancel(true); + Notification notification = builder.build(); + NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); + id = (int) (id + System.currentTimeMillis()); + manager.notify(id, notification); + } + }); + + Log.i("gmc", "11123231"); + + } + + //后台 + private void serviceNotification(Context context, NotificationMsgBean message) { + // 设置通知的点击行为:这里启动一个 Activity + Intent intent = new Intent(context, MainActivity.class); + intent.putExtra("type", message.getType()); + if (message.getType().equals("8")) { + intent.putExtra("activityUrl", message.getActivityurl()); + } + intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); + String channelId = createNotificationChannel(context, "my_channel_ID", "my_channel_NAME", NotificationManager.IMPORTANCE_HIGH); + // 构建 remoteView + RemoteViews remoteView = new RemoteViews(context.getPackageName(), R.layout.notification_message); + remoteView.setTextViewText(R.id.title, message.getTitle()); + remoteView.setTextViewText(R.id.content, message.getContent()); + remoteView.setImageViewResource(R.id.img, R.mipmap.ic_launcher); + + NotificationCompat.Builder builder = new NotificationCompat.Builder(context, channelId); + // 设置自定义 RemoteViews + builder.setContent(remoteView).setSmallIcon(R.drawable.small_icons); + // 设置通知的优先级(悬浮通知) + builder.setPriority(NotificationCompat.PRIORITY_MAX); + builder.setContentIntent(pendingIntent); + builder.setAutoCancel(true); + Notification notification = builder.build(); + NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); + id = (int) (id + System.currentTimeMillis()); + manager.notify(id, notification); + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/shayu/phonelive/utils/MyNotificationService.java b/app/src/main/java/com/shayu/phonelive/utils/MyNotificationService.java index c8d229464..7f01161ff 100644 --- a/app/src/main/java/com/shayu/phonelive/utils/MyNotificationService.java +++ b/app/src/main/java/com/shayu/phonelive/utils/MyNotificationService.java @@ -22,9 +22,15 @@ import com.google.firebase.messaging.RemoteMessage; import com.yunbao.common.utils.ToastUtil; import com.yunbao.main.activity.MainActivity; +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.Map; + import myname.pdlive.shayu.R; public class MyNotificationService extends FirebaseMessagingService { + private String createNotificationChannel(String channelID, String channelNAME, int level) { if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); @@ -35,36 +41,70 @@ public class MyNotificationService extends FirebaseMessagingService { return null; } } - public void onMessageReceived(RemoteMessage remoteMessage) { - Log.e("gmc","remoteMessage"); + + public void onMessageReceived(RemoteMessage message) { // do nothing - sendNotification("remoteMessage"); + Map params = message.getData(); + JSONObject object = new JSONObject(params); + Log.e("JSON_OBJECT", object.toString()); + JSONObject remoteMessage = null; + try { + remoteMessage = new JSONObject(object.getString("message")); + Log.e("gmc","remoteMessage1"+remoteMessage.toString()); + Log.e("gmc","remoteMessage"+remoteMessage.getString("fromUserName")); + } catch (JSONException e) { + e.printStackTrace(); + } +// if(remoteMessage!=null && remoteMessage.isNull("fcm_token")) { +// String title = remoteMessage.getData().get("title"); +// String message = remoteMessage.getData().get("text"); +// String username = remoteMessage.getData().get("username"); +// String uid = remoteMessage.getData().get("uid"); +// String fcmToken = remoteMessage.getData().get("fcm_token"); +// Log.e("gmc","remoteMessage"+remoteMessage.getData().get("username")); +// +// //Muestro la notifiación +//// sendNotification(title, message, username, uid, fcmToken); +// }else { +// /// Si es de tipo inserción la muestro sino no. +// //Es una nueva notificación de que alguien ha creado algo +// if(remoteMessage.getData().get("accion")!=null && +// remoteMessage.getData().get("accion").compareTo("insert")==0) +//// displayNotification(remoteMessage.getNotification(), remoteMessage.getData()); +//// //Envío los datos al RecyclerView correspondiente para que se actualice +//// addNotificacion(remoteMessage); +// Log.e("gmc","remoteMessage"+remoteMessage.getData().get("username")); +// +// } + +// sendNotification("remoteMessage"); } - private void sendNotification(String messageBody) { - - // 设置通知的点击行为:这里启动一个 Activity - Intent intent = new Intent(this, MainActivity.class); - intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); - PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 0); - String channelId = createNotificationChannel("my_channel_ID", "my_channel_NAME", NotificationManager.IMPORTANCE_HIGH); - // 构建 remoteView - RemoteViews remoteView = new RemoteViews(getPackageName(), R.layout.notification_message); -// remoteView.setTextViewText(R.id.tvMsg, "RemoteViews"); -// remoteView.setImageViewResource(R.id.ivIcon, R.mipmap.ic_launcher_round); - NotificationCompat.Builder builder = new NotificationCompat.Builder(this,channelId); - // 设置自定义 RemoteViews - builder.setContent(remoteView).setSmallIcon(R.mipmap.ic_launcher); - // 设置通知的优先级(悬浮通知) - builder.setPriority(NotificationCompat.PRIORITY_MAX); - builder.setContentIntent(pendingIntent); - builder.setAutoCancel(true); - Notification notification = builder.build(); - NotificationManager manager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE); - manager.notify(0, notification); - - } +// private void sendNotification(String messageBody) { +// +// // 设置通知的点击行为:这里启动一个 Activity +// Intent intent = new Intent(this, MainActivity.class); +// intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); +// PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 0); +// String channelId = createNotificationChannel("my_channel_ID", "my_channel_NAME", NotificationManager.IMPORTANCE_HIGH); +// // 构建 remoteView +//// RemoteViews remoteView = new RemoteViews(getPackageName(), R.layout.notification_message); +// +//// remoteView.setTextViewText(R.id.tvMsg, "RemoteViews"); +//// remoteView.setImageViewResource(R.id.ivIcon, R.mipmap.ic_launcher_round); +// NotificationCompat.Builder builder = new NotificationCompat.Builder(this,channelId); +// // 设置自定义 RemoteViews +// builder.setContent(remoteView).setSmallIcon(R.mipmap.ic_launcher); +// // 设置通知的优先级(悬浮通知) +// builder.setPriority(NotificationCompat.PRIORITY_MAX); +// builder.setContentIntent(pendingIntent); +// builder.setAutoCancel(true); +// Notification notification = builder.build(); +// NotificationManager manager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE); +// manager.notify(0, notification); +// +// } } diff --git a/app/src/main/res/drawable/small_icons.png b/app/src/main/res/drawable/small_icons.png new file mode 100644 index 000000000..2c58682a4 Binary files /dev/null and b/app/src/main/res/drawable/small_icons.png differ diff --git a/app/src/main/res/raw/pdlive_sound.mp3 b/app/src/main/res/raw/pdlive_sound.mp3 new file mode 100644 index 000000000..bddcd1d39 Binary files /dev/null and b/app/src/main/res/raw/pdlive_sound.mp3 differ diff --git a/common/build.gradle b/common/build.gradle index a7bff4708..eb03a2177 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -178,5 +178,5 @@ dependencies { api 'com.wang.avi:library:2.1.3' api 'com.google.firebase:firebase-messaging:23.0.6' api 'com.google.firebase:firebase-analytics:21.1.0' - +// api 'com.huawei.hms:push:4.0.2.300' } diff --git a/common/src/main/java/com/yunbao/common/CommonAppContext.java b/common/src/main/java/com/yunbao/common/CommonAppContext.java index 33d802f28..5d1e34975 100644 --- a/common/src/main/java/com/yunbao/common/CommonAppContext.java +++ b/common/src/main/java/com/yunbao/common/CommonAppContext.java @@ -6,16 +6,21 @@ import android.os.Build; import android.os.Bundle; import androidx.multidex.MultiDex; import androidx.multidex.MultiDexApplication; + +import android.text.TextUtils; import android.util.Log; import com.facebook.FacebookSdk; import com.facebook.appevents.AppEventsLogger; +import com.google.android.gms.common.api.ApiException; import com.google.firebase.analytics.FirebaseAnalytics; import com.yunbao.common.http.CommonHttpUtil; import com.yunbao.common.utils.L; import java.util.Locale; +import io.rong.push.RongPushClient; +import io.rong.push.pushconfig.PushConfig; import me.leolin.shortcutbadger.ShortcutBadger; import static com.facebook.FacebookSdk.setAdvertiserIDCollectionEnabled; @@ -46,6 +51,16 @@ public class CommonAppContext extends MultiDexApplication { sInstance = this; //初始化Http CommonHttpUtil.init(); +// //华为推送 +// PushConfig config = new PushConfig.Builder() +// .enableHWPush(true) +// .build(); +// RongPushClient.setPushConfig(config); //将推送相关配置设置到 SDK + //谷歌推送 + PushConfig gconfig = new PushConfig.Builder() + .enableFCM(true) + .build(); + RongPushClient.setPushConfig(gconfig); //初始化友盟统计 // UMConfigure.init(this, UMConfigure.DEVICE_TYPE_PHONE, null); FacebookSdk.sdkInitialize(getApplicationContext()); @@ -54,6 +69,7 @@ public class CommonAppContext extends MultiDexApplication { mFirebaseAnalytics.setUserProperty("ALLOW_AD_PERSONALIZATION_SIGNALS", "true" ); + logger = AppEventsLogger.newLogger(this); setAutoLogAppEventsEnabled(true); FacebookSdk.fullyInitialize(); @@ -75,6 +91,7 @@ public class CommonAppContext extends MultiDexApplication { } + @Override protected void attachBaseContext(Context base) { MultiDex.install(this); diff --git a/common/src/main/java/com/yunbao/common/Constants.java b/common/src/main/java/com/yunbao/common/Constants.java index 65dea4f09..1fc271e19 100644 --- a/common/src/main/java/com/yunbao/common/Constants.java +++ b/common/src/main/java/com/yunbao/common/Constants.java @@ -46,6 +46,7 @@ public class Constants { public static final String LIVE_NEAR = "liveNear"; public static final String LIVE_CLASS_PREFIX = "liveClass_"; public static final String LIVE_ADMIN_ROOM = "liveAdminRoom"; + public static final String LIVE_ANCHER_NAME = "ancherName";//主播名 public static final String HAS_GAME = "hasGame"; public static final String OPEN_FLASH = "openFlash"; public static final String SHARE_QR_CODE_FILE = "shareQrCodeFile.png"; diff --git a/common/src/main/java/com/yunbao/common/bean/AnchorRecommendModel.java b/common/src/main/java/com/yunbao/common/bean/AnchorRecommendModel.java index e64e48793..21125ed50 100644 --- a/common/src/main/java/com/yunbao/common/bean/AnchorRecommendModel.java +++ b/common/src/main/java/com/yunbao/common/bean/AnchorRecommendModel.java @@ -22,6 +22,17 @@ public class AnchorRecommendModel extends BaseModel { private int upShow = 0; @SerializedName("list") private List list = new ArrayList<>(); + @SerializedName("slide") + private List slide = new ArrayList<>(); + + public List getSlide() { + return slide; + } + + public AnchorRecommendModel setSlide(List slide) { + this.slide = slide; + return this; + } public int getListShow() { return listShow; diff --git a/common/src/main/java/com/yunbao/common/bean/MsgSwitchDetailModel.java b/common/src/main/java/com/yunbao/common/bean/MsgSwitchDetailModel.java new file mode 100644 index 000000000..fa9e51d86 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/bean/MsgSwitchDetailModel.java @@ -0,0 +1,60 @@ +package com.yunbao.common.bean; + +import com.google.gson.annotations.SerializedName; + +import java.util.ArrayList; +import java.util.List; + +public class MsgSwitchDetailModel extends BaseModel { + @SerializedName("dynamic_msg_switch") + String dynamic_msg_switch; + @SerializedName("interaction_show_msg_switch") + String interaction_show_msg_switch; + @SerializedName("chat_msg_switch") + String chat_msg_switch; + @SerializedName("system_msg_switch") + String system_msg_switch; + + @SerializedName("followList") + private List followList = new ArrayList<>(); + + public String getDynamic_msg_switch() { + return dynamic_msg_switch; + } + + public void setDynamic_msg_switch(String dynamic_msg_switch) { + this.dynamic_msg_switch = dynamic_msg_switch; + } + + public String getInteraction_show_msg_switch() { + return interaction_show_msg_switch; + } + + public void setInteraction_show_msg_switch(String interaction_show_msg_switch) { + this.interaction_show_msg_switch = interaction_show_msg_switch; + } + + public String getChat_msg_switch() { + return chat_msg_switch; + } + + public void setChat_msg_switch(String chat_msg_switch) { + this.chat_msg_switch = chat_msg_switch; + } + + public String getSystem_msg_switch() { + return system_msg_switch; + } + + public void setSystem_msg_switch(String system_msg_switch) { + this.system_msg_switch = system_msg_switch; + } + + public List getFollowList() { + return followList; + } + + public void setFollowList(List followList) { + this.followList = followList; + } +} diff --git a/common/src/main/java/com/yunbao/common/bean/MsgSwitchFollowlModel.java b/common/src/main/java/com/yunbao/common/bean/MsgSwitchFollowlModel.java new file mode 100644 index 000000000..d69f074be --- /dev/null +++ b/common/src/main/java/com/yunbao/common/bean/MsgSwitchFollowlModel.java @@ -0,0 +1,46 @@ +package com.yunbao.common.bean; + +import com.google.gson.annotations.SerializedName; + +public class MsgSwitchFollowlModel extends BaseModel{ + @SerializedName("status") + String status; + @SerializedName("user_nicename") + String user_nicename; + @SerializedName("avatar") + String avatar; + @SerializedName("liveuid") + String liveuid; + + public String getLiveuid() { + return liveuid; + } + + public void setLiveuid(String liveuid) { + this.liveuid = liveuid; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getUser_nicename() { + return user_nicename; + } + + public void setUser_nicename(String user_nicename) { + this.user_nicename = user_nicename; + } + + public String getAvatar() { + return avatar; + } + + public void setAvatar(String avatar) { + this.avatar = avatar; + } +} diff --git a/common/src/main/java/com/yunbao/common/bean/NotificationMsgBean.java b/common/src/main/java/com/yunbao/common/bean/NotificationMsgBean.java new file mode 100644 index 000000000..0493d2d37 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/bean/NotificationMsgBean.java @@ -0,0 +1,58 @@ +package com.yunbao.common.bean; + +public class NotificationMsgBean { + String img; + String title; + String content; + String type; + String liveuid; + String activityurl; + + public String getActivityurl() { + return activityurl; + } + + public void setActivityurl(String activityurl) { + this.activityurl = activityurl; + } + + public String getLiveuid() { + return liveuid; + } + + public void setLiveuid(String liveuid) { + this.liveuid = liveuid; + } + + public String getImg() { + return img; + } + + public void setImg(String img) { + this.img = img; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } +} diff --git a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java index 97998d2db..abb5122a5 100644 --- a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java +++ b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java @@ -7,6 +7,7 @@ import com.yunbao.common.bean.ContributeModel; import com.yunbao.common.bean.FaceBookUpModel; import com.yunbao.common.bean.IMLoginModel; import com.yunbao.common.bean.LiveInfoModel; +import com.yunbao.common.bean.MsgSwitchDetailModel; import com.yunbao.common.bean.NewPeopleInfo; import com.yunbao.common.bean.NobleTrumpetModel; import com.yunbao.common.bean.SearchModel; @@ -115,6 +116,17 @@ public interface PDLiveApi { @Query("num") String num ); + /** + * 直播间上下滚动列表 + * + * @param num 请求数量 + * @return + */ + @GET("/api/public/?service=Home.anchorRecommend ") + Observable> anchorRecommend( + @Query("num") String num, @Query("type") String type + ); + /** * 获取直播间信息 * @@ -132,7 +144,7 @@ public interface PDLiveApi { * @param liveuid * @return */ - @GET("/api/public/?service=User.setAttents") + @GET("/api/public/?service=User.slketAttents") Observable>> setAttents( @Query("touid") String liveuid ); @@ -150,6 +162,7 @@ public interface PDLiveApi { */ @GET("/api/public/?service=Active.getActiveList") Observable>> getActiveList(); + /** * 获取活动 */ @@ -158,16 +171,38 @@ public interface PDLiveApi { /** * 获取日榜、周榜数据 + * * @param uid 直播间id,并非用户uid * @return 榜单结构 */ @GET("/api/public/?service=Contribute.index") - Observable> getRanksList(@Query("uid")String uid); + Observable> getRanksList(@Query("uid") String uid); /** * 直播间新人特惠信息 + * * @return 新人特惠数据 */ @GET("/api/public/?service=Live.newUserPreferential") Observable> getNewPeopleInfo(); + + /** + * 获取推送关注的开关和关注列表 + * + */ + @GET("/api/public/?service=Tx.offlineMsgSwitchDetail") + Observable> getMsgSwitchDetail(); + + /** + * 推送关注的开关设置 + */ + @GET("/api/public/?service=Tx.setMsgMasterSwitch") + Observable> setMsgMasterSwitch(@Query("status") String status,@Query("type") String type); + + /** + *开播推送设置开关 + */ + @GET("/api/public/?service=Tx.setBeginShowMsgSwitch") + Observable>> setBeginShowMsgSwitch(@Query("status") String status,@Query("isAll") String isAll,@Query("liveuid") String liveuid); + } diff --git a/common/src/main/java/com/yunbao/common/http/main/MainNetManager.java b/common/src/main/java/com/yunbao/common/http/main/MainNetManager.java index 72f572e39..0807642a7 100644 --- a/common/src/main/java/com/yunbao/common/http/main/MainNetManager.java +++ b/common/src/main/java/com/yunbao/common/http/main/MainNetManager.java @@ -3,13 +3,17 @@ package com.yunbao.common.http.main; import android.app.Activity; import com.yunbao.common.bean.AnchorRecommendModel; +import com.yunbao.common.bean.BaseModel; import com.yunbao.common.bean.FaceBookUpModel; import com.yunbao.common.bean.IMLoginModel; +import com.yunbao.common.bean.MsgSwitchDetailModel; import com.yunbao.common.bean.SearchModel; import com.yunbao.common.bean.SlideInfoModel; import com.yunbao.common.http.API; +import com.yunbao.common.http.ResponseData; import com.yunbao.common.http.ResponseModel; import com.yunbao.common.http.base.HttpCallback; +import com.yunbao.common.utils.ToastUtil; import java.util.List; @@ -112,6 +116,28 @@ public class MainNetManager { }).isDisposed(); } + /** + * 猜你喜欢 + * + * @param num 请求数量 + * @return + */ + public void anchorRecommendType(String num, HttpCallback httpCallback) { + API.get().pdLiveApi(mContext).anchorRecommend(num, "1") + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(anchorRecommendModelResponseModel -> { + if (httpCallback != null) { + AnchorRecommendModel model = anchorRecommendModelResponseModel.getData().getInfo(); + httpCallback.onSuccess(model); + } + }, throwable -> { + if (httpCallback != null) { + httpCallback.onError(throwable.getMessage()); + } + }).isDisposed(); + } + /** * 搜索 * @@ -168,12 +194,72 @@ public class MainNetManager { .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(slideInBannerModelResponseModel -> { - if (!mContext.isFinishing() && callback != null) { + if (callback != null) { List slideInfoModels = slideInBannerModelResponseModel.getData().getInfo().get(0).getSlide(); callback.onSuccess(slideInfoModels); } }, throwable -> { - if (!mContext.isFinishing() && callback != null) { + if (callback != null) { + callback.onError(throwable.getMessage()); + } + }).isDisposed(); + } + + /** + * 获取推送关注的设置和关注列表 + * @param callback + */ + public void getMsgSwitchDetail(HttpCallback callback) { + API.get().pdLiveApi(mContext).getMsgSwitchDetail() + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(msgSwitchDetailModelResponseModel -> { + if (callback != null) { + MsgSwitchDetailModel msgSwitchDetailModel = msgSwitchDetailModelResponseModel.getData().getInfo(); + callback.onSuccess(msgSwitchDetailModel); + } + }, throwable -> { + if (callback != null) { + callback.onError(throwable.getMessage()); + } + }).isDisposed(); + } + + /** + * 推送开关设置 + * @param callback + */ + public void setMsgMasterSwitch(String status,String type,HttpCallback callback) { + API.get().pdLiveApi(mContext).setMsgMasterSwitch(status,type) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(BaseModel -> { + if (callback != null) { + ResponseData responseData = BaseModel.getData(); + callback.onSuccess(responseData); + } + }, throwable -> { + if (callback != null) { + callback.onError(throwable.getMessage()); + } + }).isDisposed(); + } + + /** + * 主播开播推送开关设置 + * @param callback + */ + public void setBeginShowMsgSwitch(String status,String isAll,String liveuid,HttpCallback callback) { + API.get().pdLiveApi(mContext).setBeginShowMsgSwitch(status,isAll,liveuid) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(BaseModel -> { + if (callback != null) { + ResponseData responseData = BaseModel.getData(); + callback.onSuccess(responseData); + } + }, throwable -> { + if (callback != null) { callback.onError(throwable.getMessage()); } }).isDisposed(); diff --git a/common/src/main/java/com/yunbao/common/manager/imrongcloud/RongcloudIMManager.java b/common/src/main/java/com/yunbao/common/manager/imrongcloud/RongcloudIMManager.java index 06a13aee5..4494d6149 100644 --- a/common/src/main/java/com/yunbao/common/manager/imrongcloud/RongcloudIMManager.java +++ b/common/src/main/java/com/yunbao/common/manager/imrongcloud/RongcloudIMManager.java @@ -53,6 +53,7 @@ public class RongcloudIMManager { private static RongIMClient.OnReceiveMessageWrapperListener mListener; /** + * * 设置消息接受监听器 */ public static void addRongcloudIMOnReceiveMessageListener(RongIMClient.OnReceiveMessageWrapperListener listener) { diff --git a/common/src/main/java/com/yunbao/common/utils/DialogUitl.java b/common/src/main/java/com/yunbao/common/utils/DialogUitl.java index d7e23fe33..f309a0b24 100644 --- a/common/src/main/java/com/yunbao/common/utils/DialogUitl.java +++ b/common/src/main/java/com/yunbao/common/utils/DialogUitl.java @@ -97,7 +97,7 @@ public class DialogUitl { } public static void showSimpleDialog(Context context, String content, SimpleCallback callback) { - showSimpleDialog(context, content, true, callback); + showSimpleDialog(context, content, false, callback); } public static void showSimpleDialog(Context context, String content, boolean cancelable, SimpleCallback callback) { @@ -114,6 +114,15 @@ public class DialogUitl { .show(); } + public static void showSimpleDialog(Context context, String title, String content, boolean cancelable, SimpleCallback3 callback) { + new Builder(context) + .setTitle(title) + .setContent(content) + .setCancelable(cancelable) + .setClickCallback3(callback) + .build() + .show(); + } public static void showSimpleInputDialog(Context context, String title, String hint, int inputType, int length, SimpleCallback callback) { new Builder(context).setTitle(title) @@ -290,6 +299,7 @@ public class DialogUitl { private int mInputType; private int mLength; private SimpleCallback mClickCallback; + private SimpleCallback3 mClickCallback3; public Builder(Context context) { mContext = context; @@ -350,6 +360,11 @@ public class DialogUitl { return this; } + public Builder setClickCallback3(SimpleCallback3 clickCallback) { + mClickCallback3 = clickCallback; + return this; + } + public Dialog build() { final Dialog dialog = new Dialog(mContext, mBackgroundDimEnabled ? R.style.dialog : R.style.dialog2); dialog.setContentView(mInput ? R.layout.dialog_input : R.layout.dialog_simple); @@ -397,12 +412,24 @@ public class DialogUitl { } } else { dialog.dismiss(); + if (mClickCallback3 != null) { + mClickCallback3.onConfirmClick(dialog); + } + } + } else { dialog.dismiss(); - if (mClickCallback instanceof SimpleCallback2) { - ((SimpleCallback2) mClickCallback).onCancelClick(); + if (mClickCallback3 != null) { + mClickCallback3.onCancel(); + + } else { + + if (mClickCallback instanceof SimpleCallback2) { + ((SimpleCallback2) mClickCallback).onCancelClick(); + } } + } } }; @@ -429,6 +456,12 @@ public class DialogUitl { void onCancelClick(); } + public interface SimpleCallback3 { + void onConfirmClick(Dialog dialog); + + void onCancel(); + } + /** * 城市选择 diff --git a/common/src/main/java/com/yunbao/common/views/weight/VerticalViewPager.java b/common/src/main/java/com/yunbao/common/views/weight/VerticalViewPager.java index d09c17b4d..60207de8c 100644 --- a/common/src/main/java/com/yunbao/common/views/weight/VerticalViewPager.java +++ b/common/src/main/java/com/yunbao/common/views/weight/VerticalViewPager.java @@ -75,6 +75,10 @@ public class VerticalViewPager extends ViewGroup { private boolean mEnableScroll = true; + public boolean ismEnableScroll() { + return mEnableScroll; + } + /** * Used to track what the expected number of items in the adapter should be. * If the app changes this when we don't expect it, we'll throw a big obnoxious exception. diff --git a/common/src/main/res/drawable/bg_live_tota.xml b/common/src/main/res/drawable/bg_live_tota.xml index 74ca8bdc9..97920b7a7 100644 --- a/common/src/main/res/drawable/bg_live_tota.xml +++ b/common/src/main/res/drawable/bg_live_tota.xml @@ -1,5 +1,5 @@ - + \ No newline at end of file diff --git a/common/src/main/res/layout/item_sidebar_lives.xml b/common/src/main/res/layout/item_sidebar_lives.xml index 582388b5e..2d6a3bc40 100644 --- a/common/src/main/res/layout/item_sidebar_lives.xml +++ b/common/src/main/res/layout/item_sidebar_lives.xml @@ -21,9 +21,10 @@ + + android:layout_width="60dp" + android:layout_height="60dp"/> - - + + \ No newline at end of file diff --git a/common/src/main/res/mipmap-xxhdpi/live_bg.jpg b/common/src/main/res/mipmap-xxhdpi/live_bg.jpg index 6d9899eb1..b6cd42cda 100644 Binary files a/common/src/main/res/mipmap-xxhdpi/live_bg.jpg and b/common/src/main/res/mipmap-xxhdpi/live_bg.jpg differ diff --git a/live/src/main/java/com/yunbao/live/activity/LiveActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveActivity.java index 4832c1d38..4d5515766 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveActivity.java @@ -6,9 +6,6 @@ import android.content.ClipboardManager; import android.content.Intent; import android.os.Bundle; import android.os.Handler; - -import androidx.fragment.app.DialogFragment; - import android.text.TextUtils; import android.util.Log; import android.view.View; @@ -16,9 +13,10 @@ import android.view.ViewGroup; import android.view.WindowManager; import android.widget.TextView; +import androidx.fragment.app.DialogFragment; + import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; -import com.tencent.imsdk.conversation.ConversationManager; import com.yunbao.common.CommonAppConfig; import com.yunbao.common.Constants; import com.yunbao.common.activity.AbsActivity; @@ -49,15 +47,15 @@ import com.yunbao.live.bean.LivePKUserListBean; import com.yunbao.live.bean.LiveReceiveGiftBean; import com.yunbao.live.bean.LiveUserGiftBean; import com.yunbao.live.dialog.GiftPrizePoolFragment; -import com.yunbao.live.dialog.LiveChatListDialogFragment; import com.yunbao.live.dialog.LiveChatRoomDialogFragment; import com.yunbao.live.dialog.LiveFansFragment; import com.yunbao.live.dialog.LiveFansMedalOkDialogFragment; +import com.yunbao.live.dialog.LiveGiveHotDialogFragment; import com.yunbao.live.dialog.LiveGuardBuyDialogFragment; import com.yunbao.live.dialog.LiveGuardDialogFragment; -import com.yunbao.live.dialog.LiveGiveHotDialogFragment; import com.yunbao.live.dialog.LiveInputDialogFragment; import com.yunbao.live.dialog.LiveMoreDialogFragment; +import com.yunbao.live.dialog.LiveNewGuardBuyDialogFragment; import com.yunbao.live.dialog.LiveRedPackListDialogFragment; import com.yunbao.live.dialog.LiveRedPackSendDialogFragment; import com.yunbao.live.dialog.LiveShareDialogFragment; @@ -69,7 +67,6 @@ import com.yunbao.live.presenter.LiveLinkMicAnchorPresenter; import com.yunbao.live.presenter.LiveLinkMicPkPresenter; import com.yunbao.live.presenter.LiveLinkMicPresenter; import com.yunbao.live.presenter.LiveRyLinkMicPkPresenter; -import com.yunbao.live.socket.SocketChatUtil; import com.yunbao.live.socket.SocketClient; import com.yunbao.live.socket.SocketMessageListener; import com.yunbao.live.socket.SocketRyChatUtil; @@ -91,8 +88,6 @@ import org.greenrobot.eventbus.ThreadMode; import java.util.HashSet; import java.util.List; -import io.rong.imkit.utils.RouteUtils; - /** * Created by cxf on 2018/10/7. */ @@ -138,7 +133,7 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL private LiveChatRoomDialogFragment mLiveChatRoomDialogFragment;//私信聊天窗口 protected LiveGuardInfo mLiveGuardInfo; private HashSet mDialogFragmentSet; - public boolean isRy = false; +// public static boolean isRy = true; @Override protected void main() { @@ -149,7 +144,6 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL EventBus.getDefault().register(this); mImageUtil = new ProcessImageUtil(this); mDialogFragmentSet = new HashSet<>(); - //解压 美颜模型 try { CommonAppConfig.VIDEO_TIE_MODEl_PATH = getFilesDir().getAbsolutePath() + "/model";//app安装路径 @@ -205,17 +199,17 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL if (!mFirstConnectSocket) { mFirstConnectSocket = true; if (mLiveType == Constants.LIVE_TYPE_PAY || mLiveType == Constants.LIVE_TYPE_TIME) { - if (isRy == false) { - SocketChatUtil.sendUpdateVotesMessage(mLiveUid, mLiveTypeVal, 1); - } else { - SocketRyChatUtil.sendUpdateVotesMessage(mLiveUid, mLiveTypeVal, 1); - } - } - if (isRy == false) { - SocketChatUtil.getFakeFans(mLiveUid); - } else { - SocketRyChatUtil.getFakeFans(mLiveUid); +// if (isRy == false) { +// SocketChatUtil.sendUpdateVotesMessage(mLiveUid, mLiveTypeVal, 1); +// } else { + SocketRyChatUtil.sendUpdateVotesMessage(mLiveUid, mLiveTypeVal, 1); +// } } +// if (isRy == false) { +// SocketChatUtil.getFakeFans(mLiveUid); +// } else { + SocketRyChatUtil.getFakeFans(mLiveUid); +// } } } } @@ -333,6 +327,8 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL } } + + @Override public void onBuyLiangName(LiveReceiveGiftBean bean) { if (mLiveRoomViewHolder != null) { @@ -364,15 +360,15 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL */ @Override public void onSendGiftPk(long leftGift, long rightGift, LivePKUserListBean bean) { - if (isRy == false) { - if (mLiveLinkMicPkPresenter != null) { - mLiveLinkMicPkPresenter.onPkProgressChanged(leftGift, rightGift, bean); - } - } else { - if (mLiveRyLinkMicPkPresenter != null) { - mLiveRyLinkMicPkPresenter.onPkProgressChanged(leftGift, rightGift, bean); - } +// if (isRy == false) { +// if (mLiveLinkMicPkPresenter != null) { +// mLiveLinkMicPkPresenter.onPkProgressChanged(leftGift, rightGift, bean); +// } +// } else { + if (mLiveRyLinkMicPkPresenter != null) { + mLiveRyLinkMicPkPresenter.onPkProgressChanged(leftGift, rightGift, bean); } +// } } /** @@ -615,21 +611,21 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL */ @Override public void onLinkMicAnchorClose() { - if (isRy == false) { - if (mLiveLinkMicAnchorPresenter != null) { - mLiveLinkMicAnchorPresenter.onLinkMicAnchorClose(); - } - if (mLiveLinkMicPkPresenter != null) { - mLiveLinkMicPkPresenter.onLinkMicPkClose(1); - } - } else { - if (mLiveLinkMicAnchorPresenter != null) { - mLiveLinkMicAnchorPresenter.onLinkMicAnchorClose(); - } - if (mLiveRyLinkMicPkPresenter != null) { - mLiveRyLinkMicPkPresenter.onLinkMicPkClose(1); - } +// if (isRy == false) { +// if (mLiveLinkMicAnchorPresenter != null) { +// mLiveLinkMicAnchorPresenter.onLinkMicAnchorClose(); +// } +// if (mLiveLinkMicPkPresenter != null) { +// mLiveLinkMicPkPresenter.onLinkMicPkClose(1); +// } +// } else { + if (mLiveLinkMicAnchorPresenter != null) { + mLiveLinkMicAnchorPresenter.onLinkMicAnchorClose(); } + if (mLiveRyLinkMicPkPresenter != null) { + mLiveRyLinkMicPkPresenter.onLinkMicPkClose(1); + } +// } if (this instanceof LiveAudienceActivity) { @@ -688,40 +684,40 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL @Override public void onLinkMicPkStart(final String pkUid, final String pkhead, final String pkname) { Log.e("ry", "pkUid" + pkUid + "pkhead" + pkhead + "pkname" + pkname); - if (isRy == false) { - if (mLiveLinkMicPkPresenter != null && mLiveRoomViewHolder != null) { - mLiveLinkMicPkPresenter.onLinkMicPkStart(pkUid, pkhead, pkname); - Handler handler = new Handler(); - handler.postDelayed(new Runnable() { - @Override - public void run() { - if (mLiveRoomViewHolder != null) { - if (mIsAnchor == false) { - mLiveRoomViewHolder.setOtherInfo(pkUid, pkhead, pkname); - } +// if (isRy == false) { +// if (mLiveLinkMicPkPresenter != null && mLiveRoomViewHolder != null) { +// mLiveLinkMicPkPresenter.onLinkMicPkStart(pkUid, pkhead, pkname); +// Handler handler = new Handler(); +// handler.postDelayed(new Runnable() { +// @Override +// public void run() { +// if (mLiveRoomViewHolder != null) { +// if (mIsAnchor == false) { +// mLiveRoomViewHolder.setOtherInfo(pkUid, pkhead, pkname); +// } +// } +// } +// }, 4000);//3秒后执行Runnable中的run方法 +// +// } +// } else { + if (mLiveRyLinkMicPkPresenter != null && mLiveRoomViewHolder != null) { + mLiveRyLinkMicPkPresenter.onLinkMicPkStart(pkUid, 1); + Handler handler = new Handler(); + handler.postDelayed(new Runnable() { + @Override + public void run() { + if (mLiveRoomViewHolder != null) { + Log.e("tasdsdg", mLiveUid + "1111" + CommonAppConfig.getInstance().getUid()); + if (!mLiveUid.equals(CommonAppConfig.getInstance().getUid())) { + mLiveRoomViewHolder.setOtherInfo(pkUid, pkhead, pkname); } } - }, 4000);//3秒后执行Runnable中的run方法 + } + }, 4000);//3秒后执行Runnable中的run方法 - } - } else { - if (mLiveRyLinkMicPkPresenter != null && mLiveRoomViewHolder != null) { - mLiveRyLinkMicPkPresenter.onLinkMicPkStart(pkUid, 1); - Handler handler = new Handler(); - handler.postDelayed(new Runnable() { - @Override - public void run() { - if (mLiveRoomViewHolder != null) { - Log.e("tasdsdg", mLiveUid + "1111" + CommonAppConfig.getInstance().getUid()); - if (!mLiveUid.equals(CommonAppConfig.getInstance().getUid())) { - mLiveRoomViewHolder.setOtherInfo(pkUid, pkhead, pkname); - } - } - } - }, 4000);//3秒后执行Runnable中的run方法 - - } } +// } } @@ -730,16 +726,16 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL */ @Override public void onLinkMicPkClose(int i) { - if (isRy == false) { - if (mLiveLinkMicPkPresenter != null) { - mLiveLinkMicPkPresenter.onLinkMicPkClose(i); - } - } else { - if (mLiveRyLinkMicPkPresenter != null) { - mLiveRyLinkMicPkPresenter.onLinkMicPkClose(i); - } else if (mLiveLinkMicPkPresenter != null) { - mLiveLinkMicPkPresenter.onLinkMicPkClose(i); - } +// if (isRy == false) { +// if (mLiveLinkMicPkPresenter != null) { +// mLiveLinkMicPkPresenter.onLinkMicPkClose(i); +// } +// } else { + if (mLiveRyLinkMicPkPresenter != null) { + mLiveRyLinkMicPkPresenter.onLinkMicPkClose(i); + } else if (mLiveLinkMicPkPresenter != null) { + mLiveLinkMicPkPresenter.onLinkMicPkClose(i); +// } } } @@ -772,20 +768,20 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL */ @Override public void onLinkMicPkEnd(String winUid) { - if (isRy == false) { - if (mLiveLinkMicPkPresenter != null) { - mLiveLinkMicPkPresenter.onLinkMicPkEnd(winUid); - mLiveRoomViewHolder.setDelOtherInfo(); - } - } else { - if (mLiveRyLinkMicPkPresenter != null) { - mLiveRyLinkMicPkPresenter.onLinkMicPkEnd(winUid); - mLiveRoomViewHolder.setDelOtherInfo(); - } else if (mLiveLinkMicPkPresenter != null) { - mLiveLinkMicPkPresenter.onLinkMicPkEnd(winUid); - mLiveRoomViewHolder.setDelOtherInfo(); - } +// if (isRy == false) { +// if (mLiveLinkMicPkPresenter != null) { +// mLiveLinkMicPkPresenter.onLinkMicPkEnd(winUid); +// mLiveRoomViewHolder.setDelOtherInfo(); +// } +// } else { + if (mLiveRyLinkMicPkPresenter != null) { + mLiveRyLinkMicPkPresenter.onLinkMicPkEnd(winUid); + mLiveRoomViewHolder.setDelOtherInfo(); + } else if (mLiveLinkMicPkPresenter != null) { + mLiveLinkMicPkPresenter.onLinkMicPkEnd(winUid); + mLiveRoomViewHolder.setDelOtherInfo(); } +// } } @@ -856,20 +852,20 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL * 打开聊天输入框 */ public void openChatWindow() { - if (mKeyBoardHeightUtil == null) { - mKeyBoardHeightUtil = new KeyBoardHeightUtil2(mContext, super.findViewById(android.R.id.content), this); - mKeyBoardHeightUtil.start(); - } - if (mLiveRoomViewHolder != null) { - mLiveRoomViewHolder.chatScrollToBottom(); - } - LiveInputDialogFragment fragment = new LiveInputDialogFragment(); - Bundle bundle = new Bundle(); - bundle.putString(Constants.LIVE_DANMU_PRICE, mDanmuPrice); - bundle.putString(Constants.COIN_NAME, mCoinName); - bundle.putString(Constants.LIVE_UID, mLiveUid); - fragment.setArguments(bundle); - fragment.show(getSupportFragmentManager(), "LiveInputDialogFragment"); + if (mKeyBoardHeightUtil == null) { + mKeyBoardHeightUtil = new KeyBoardHeightUtil2(mContext, super.findViewById(android.R.id.content), this); + mKeyBoardHeightUtil.start(); + } + if (mLiveRoomViewHolder != null) { + mLiveRoomViewHolder.chatScrollToBottom(); + } + LiveInputDialogFragment fragment = new LiveInputDialogFragment(); + Bundle bundle = new Bundle(); + bundle.putString(Constants.LIVE_DANMU_PRICE, mDanmuPrice); + bundle.putString(Constants.COIN_NAME, mCoinName); + bundle.putString(Constants.LIVE_UID, mLiveUid); + fragment.setArguments(bundle); + fragment.show(getSupportFragmentManager(), "LiveInputDialogFragment"); } private void showTaskDialog() { @@ -908,7 +904,6 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL } - /** * 发 弹幕 消息 */ @@ -939,11 +934,11 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL onCoinChanged(coin); } String[] data = new String[]{obj.getString("barragetoken")}; - if (isRy == false) { - SocketChatUtil.sendDanmuMessage(mLiveUid, contents); - } else { - SocketRyChatUtil.sendDanmuMessage(mLiveUid, contents); - } +// if (isRy == false) { +// SocketChatUtil.sendDanmuMessage(mLiveUid, contents); +// } else { + SocketRyChatUtil.sendDanmuMessage(mLiveUid, contents); +// } } else { ToastUtil.show(msg); } @@ -963,20 +958,20 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL } } int guardType = mLiveGuardInfo != null ? mLiveGuardInfo.getMyGuardType() : Constants.GUARD_TYPE_NONE; - if (isRy == false) { - SocketChatUtil.sendChatMessage(mLiveUid, content, mIsAnchor, mSocketUserType, guardType); - } else { - SocketRyChatUtil.sendChatMessage(mLiveUid, content, mIsAnchor, mSocketUserType, guardType); - } +// if (isRy == false) { +// SocketChatUtil.sendChatMessage(mLiveUid, content, mIsAnchor, mSocketUserType, guardType); +// } else { + SocketRyChatUtil.sendChatMessage(mLiveUid, content, mIsAnchor, mSocketUserType, guardType); +// } } /** * 发 系统 消息 */ public static void sendSystemMessage(String content) { -// if(isRy == false) { - SocketChatUtil.sendSystemMessage(mLiveUid, content); -// }else{ +// if (isRy == false) { +// SocketChatUtil.sendSystemMessage(mLiveUid, content); +// } else { SocketRyChatUtil.sendSystemMessage(mLiveUid, content); // } } @@ -988,11 +983,11 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL public void sendGiftMessage(LiveGiftBean giftBean, String giftToken, String ancherName, String by) { int guardType = mLiveGuardInfo != null ? mLiveGuardInfo.getMyGuardType() : Constants.GUARD_TYPE_NONE; - if (isRy == false) { - SocketChatUtil.sendGiftMessage(giftBean.getType(), giftToken, mLiveUid, ancherName, guardType, by); - } else { - SocketRyChatUtil.sendGiftMessage(giftBean.getType(), giftToken, mLiveUid, ancherName, guardType, by); - } +// if (isRy == false) { +// SocketChatUtil.sendGiftMessage(giftBean.getType(), giftToken, mLiveUid, ancherName, guardType, by); +// } else { + SocketRyChatUtil.sendGiftMessage(giftBean.getType(), giftToken, mLiveUid, ancherName, guardType, by); +// } } @@ -1000,33 +995,33 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL * 主播或管理员踢人 */ public void kickUser(String toUid, String toName) { - if (isRy == false) { - SocketChatUtil.sendKickMessage(mLiveUid, toUid, toName); - } else { - SocketRyChatUtil.sendKickMessage(mLiveUid, toUid, toName); - } +// if (isRy == false) { +// SocketChatUtil.sendKickMessage(mLiveUid, toUid, toName); +// } else { + SocketRyChatUtil.sendKickMessage(mLiveUid, toUid, toName); +// } } /** * 禁言 */ public void setShutUp(String toUid, String toName, int type) { - if (isRy == false) { - SocketChatUtil.sendShutUpMessage(mLiveUid, toUid, toName, type); - } else { - SocketRyChatUtil.sendShutUpMessage(mLiveUid, toUid, toName, type); - } +// if (isRy == false) { +// SocketChatUtil.sendShutUpMessage(mLiveUid, toUid, toName, type); +// } else { + SocketRyChatUtil.sendShutUpMessage(mLiveUid, toUid, toName, type); +// } } /** * 设置或取消管理员消息 */ public void sendSetAdminMessage(int action, String toUid, String toName) { - if (isRy == false) { - SocketChatUtil.sendSetAdminMessage(mLiveUid, action, toUid, toName); - } else { - SocketRyChatUtil.sendSetAdminMessage(mLiveUid, action, toUid, toName); - } +// if (isRy == false) { +// SocketChatUtil.sendSetAdminMessage(mLiveUid, action, toUid, toName); +// } else { + SocketRyChatUtil.sendSetAdminMessage(mLiveUid, action, toUid, toName); +// } } @@ -1034,22 +1029,22 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL * 超管关闭直播间 */ public void superCloseRoom() { - if (isRy == false) { - SocketChatUtil.superCloseRoom(mLiveUid); - } else { - SocketRyChatUtil.superCloseRoom(mLiveUid); - } +// if (isRy == false) { +// SocketChatUtil.superCloseRoom(mLiveUid); +// } else { + SocketRyChatUtil.superCloseRoom(mLiveUid); +// } } /** * 更新主播映票数 */ public void sendUpdateVotesMessage(int deltaVal) { - if (isRy == false) { - SocketChatUtil.sendUpdateVotesMessage(mLiveUid, deltaVal); - } else { - SocketRyChatUtil.sendUpdateVotesMessage(mLiveUid, deltaVal); - } +// if (isRy == false) { +// SocketChatUtil.sendUpdateVotesMessage(mLiveUid, deltaVal); +// } else { + SocketRyChatUtil.sendUpdateVotesMessage(mLiveUid, deltaVal); +// } } @@ -1057,20 +1052,20 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL * 发送购买守护成功消息 */ public void sendBuyGuardMessage(String votes, int guardNum, int guardType) { - if (isRy == false) { - SocketChatUtil.sendBuyGuardMessage(mLiveUid, votes, guardNum, guardType); - } else { - SocketRyChatUtil.sendBuyGuardMessage(mLiveUid, votes, guardNum, guardType); - } +// if (isRy == false) { +// SocketChatUtil.sendBuyGuardMessage(mLiveUid, votes, guardNum, guardType); +// } else { + SocketRyChatUtil.sendBuyGuardMessage(mLiveUid, votes, guardNum, guardType); +// } } public void sendBuyGuardMessage2(String votes, int guardNum, int guardType, String ancherName, String liveId) { if (guardType != 1) { - if (isRy == false) { - SocketChatUtil.sendBuyGuardMessage2(mLiveUid, votes, guardNum, guardType, ancherName, liveId); - } else { - SocketRyChatUtil.sendBuyGuardMessage2(mLiveUid, votes, guardNum, guardType, ancherName, liveId); - } +// if (isRy == false) { +// SocketChatUtil.sendBuyGuardMessage2(mLiveUid, votes, guardNum, guardType, ancherName, liveId); +// } else { + SocketRyChatUtil.sendBuyGuardMessage2(mLiveUid, votes, guardNum, guardType, ancherName, liveId); +// } } } @@ -1078,11 +1073,11 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL * 发送发红包成功消息 */ public void sendRedPackMessage() { - if (isRy == false) { - SocketChatUtil.sendRedPackMessage(mLiveUid); - } else { - SocketRyChatUtil.sendRedPackMessage(mLiveUid); - } +// if (isRy == false) { +// SocketChatUtil.sendRedPackMessage(mLiveUid); +// } else { + SocketRyChatUtil.sendRedPackMessage(mLiveUid); +// } } @@ -1214,7 +1209,6 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL } - /** * 监听关注变化事件 */ @@ -1225,6 +1219,9 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL mLiveRoomViewHolder.setAttention(e.getIsAttention()); } } + if (this instanceof LiveAudienceActivity) { + ((LiveAudienceActivity) this).onFollowEvent(e); + } } @@ -1278,14 +1275,14 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL /** * 打开观看列表弹窗 */ - public void openUserMoreListWindow(int i,boolean isOnly) { + public void openUserMoreListWindow(int i, boolean isOnly) { LiveUserMoreDialogFragment fragment = new LiveUserMoreDialogFragment(); fragment.setLiveGuardInfo(mLiveGuardInfo); Bundle bundle = new Bundle(); bundle.putString(Constants.LIVE_UID, mLiveUid); bundle.putString(Constants.STREAM, mStream); bundle.putString("By", i + ""); - bundle.putBoolean("only",isOnly); + bundle.putBoolean("only", isOnly); fragment.setArguments(bundle); fragment.show(getSupportFragmentManager(), "LiveUserMoreDialogFragment"); LiveUserMoreDialogFragment.activity = this; @@ -1304,6 +1301,23 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL fragment.show(getSupportFragmentManager(), "LiveHotDialogFragment"); } + /** + * 打开购买新版守护的弹窗 + */ + public void openNewBuyGuardWindow() { + if (TextUtils.isEmpty(mLiveUid) || TextUtils.isEmpty(mStream) || mLiveGuardInfo == null) { + return; + } + LiveNewGuardBuyDialogFragment fragment = new LiveNewGuardBuyDialogFragment(); + fragment.setLiveGuardInfo(mLiveGuardInfo); + Bundle bundle = new Bundle(); + bundle.putString(Constants.COIN_NAME, mCoinName); + bundle.putString(Constants.LIVE_UID, mLiveUid); + bundle.putString(Constants.LIVE_ANCHER_NAME, mAncherName); + bundle.putString(Constants.STREAM, mStream); + fragment.setArguments(bundle); + fragment.show(getSupportFragmentManager(), "LiveGuardBuyDialogFragment"); + } /** * 打开购买守护的弹窗 */ diff --git a/live/src/main/java/com/yunbao/live/activity/LiveAnchorActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveAnchorActivity.java index 99ae87e51..c87ad778b 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveAnchorActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveAnchorActivity.java @@ -4,11 +4,12 @@ import android.app.Dialog; import android.content.Context; import android.content.Intent; import android.os.Bundle; -import androidx.fragment.app.DialogFragment; import android.text.TextUtils; import android.view.View; import android.view.ViewGroup; +import androidx.fragment.app.DialogFragment; + import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.lzy.okgo.callback.Callback; @@ -122,7 +123,7 @@ public class LiveAnchorActivity extends LiveActivity implements LiveFunctionClic @Override protected void main() { super.main(); - isRy = false; +// isRy = false; Intent intent = getIntent(); mLiveSDK = intent.getIntExtra(Constants.LIVE_SDK, Constants.LIVE_SDK_KSY); mLiveKsyConfigBean = intent.getParcelableExtra(Constants.LIVE_KSY_CONFIG); @@ -170,7 +171,7 @@ public class LiveAnchorActivity extends LiveActivity implements LiveFunctionClic mLiveReadyViewHolder.addToParent(); mLiveReadyViewHolder.subscribeActivityLifeCycle(); mLiveLinkMicPresenter = new LiveLinkMicPresenter(mContext, mLivePushViewHolder, true, mLiveSDK, mContainer); - mLiveLinkMicPresenter.setLiveUid(mLiveUid); +// mLiveLinkMicPresenter.setLiveUid(mLiveUid); mLiveLinkMicAnchorPresenter = new LiveLinkMicAnchorPresenter(mContext, mLivePushViewHolder, true, mLiveSDK, mContainer); mLiveLinkMicPkPresenter = new LiveLinkMicPkPresenter(mContext, mLivePushViewHolder, true, mContainer); } @@ -413,7 +414,7 @@ public class LiveAnchorActivity extends LiveActivity implements LiveFunctionClic hasGame = mGameList.size() > 0; } bundle.putBoolean(Constants.HAS_GAME, hasGame); - bundle.putBoolean("isRy", false); +// bundle.putBoolean("isRy", true); bundle.putBoolean(Constants.OPEN_FLASH, mLivePushViewHolder != null && mLivePushViewHolder.isFlashOpen()); fragment.setArguments(bundle); fragment.setFunctionClickListener(this); @@ -507,7 +508,7 @@ public class LiveAnchorActivity extends LiveActivity implements LiveFunctionClic mLiveLinkMicPkPresenter.setLiveUid(mLiveUid, mUrl); mLiveLinkMicPkPresenter.setSelfStream(mStream); } - if(mLiveRyLinkMicPkPresenter!=null) { + if (mLiveRyLinkMicPkPresenter != null) { mLiveRyLinkMicPkPresenter.setLiveUid(mLiveUid, ""); } @@ -597,30 +598,30 @@ public class LiveAnchorActivity extends LiveActivity implements LiveFunctionClic @Override public void onSuccess(int code, String msg, String[] info) { if (code == 0) { - if (isRy == false) { - SocketChatUtil.closeLive(mLiveUid, mSocketClient); - - //断开socket - if (mSocketClient != null) { - mSocketClient.disConnect(); - } - - if (LivePushTxViewHolder.mTRTCCloud != null) { - - LivePushTxViewHolder.mTRTCCloud.exitRoom(); - } - - if (LiveLinkMicPkPresenter.mTRTCCloud1 != null) { - LiveLinkMicPkPresenter.mTRTCCloud1.exitRoom(); - LiveLinkMicPkPresenter.mTRTCCloud1.stopLocalPreview(); - } - if (LivePushTxViewHolder.mTRTCCloud != null) { - - LivePushTxViewHolder.mTRTCCloud.exitRoom(); - LivePushTxViewHolder.mTRTCCloud.stopLocalPreview(); - - } - } else { +// if (isRy == false) { +// SocketChatUtil.closeLive(mLiveUid, mSocketClient); +// +// //断开socket +// if (mSocketClient != null) { +// mSocketClient.disConnect(); +// } +// +// if (LivePushTxViewHolder.mTRTCCloud != null) { +// +// LivePushTxViewHolder.mTRTCCloud.exitRoom(); +// } +// +// if (LiveLinkMicPkPresenter.mTRTCCloud1 != null) { +// LiveLinkMicPkPresenter.mTRTCCloud1.exitRoom(); +// LiveLinkMicPkPresenter.mTRTCCloud1.stopLocalPreview(); +// } +// if (LivePushTxViewHolder.mTRTCCloud != null) { +// +// LivePushTxViewHolder.mTRTCCloud.exitRoom(); +// LivePushTxViewHolder.mTRTCCloud.stopLocalPreview(); +// +// } +// } else { // SocketRyChatUtil.closeLive(mLiveUid, mSocketRyClient); //断开socket if (mSocketRyClient != null) { @@ -628,7 +629,7 @@ public class LiveAnchorActivity extends LiveActivity implements LiveFunctionClic } } if (mLiveEndViewHolder == null) { - mLiveEndViewHolder = new LiveEndViewHolder(mContext, mRoot,mLiveBean.getUid()); + mLiveEndViewHolder = new LiveEndViewHolder(mContext, mRoot, mLiveBean.getUid()); mLiveEndViewHolder.subscribeActivityLifeCycle(); mLiveEndViewHolder.addToParent(); mLiveEndViewHolder.showData(mLiveBean, mStream); @@ -644,7 +645,7 @@ public class LiveAnchorActivity extends LiveActivity implements LiveFunctionClic } mLivePushViewHolder = null; mLiveLinkMicPresenter = null; - } +// } } else { ToastUtil.show(msg); } diff --git a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java index 903b70d5e..f1e61654e 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java @@ -1,6 +1,5 @@ package com.yunbao.live.activity; -import android.app.Dialog; import android.content.Context; import android.content.Intent; import android.media.AudioManager; @@ -30,6 +29,7 @@ import com.yunbao.common.bean.SlideInfoModel; import com.yunbao.common.bean.UserBean; import com.yunbao.common.dialog.EffectsSettingsDialog; import com.yunbao.common.dialog.LiveChargeDialogFragment; +import com.yunbao.common.event.FollowEvent; import com.yunbao.common.http.CommonHttpConsts; import com.yunbao.common.http.CommonHttpUtil; import com.yunbao.common.http.HttpCallback; @@ -61,28 +61,15 @@ import com.yunbao.live.event.LiveRoomChangeEvent; import com.yunbao.live.http.LiveHttpConsts; import com.yunbao.live.http.LiveHttpUtil; import com.yunbao.live.presenter.LiveRoomCheckLivePresenter; -import com.yunbao.live.socket.SocketSendBean; -import com.yunbao.live.utils.LiveImDeletUtil; import com.yunbao.live.views.LiveRoomPlayViewHolder; -import com.yunbao.live.views.LoadingView; import com.yunbao.live.views.PortraitLiveManager; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; import java.util.ArrayList; -import java.util.Collections; import java.util.List; -import cn.rongcloud.rtc.api.RCRTCEngine; -import cn.rongcloud.rtc.api.callback.IRCRTCResultCallback; -import cn.rongcloud.rtc.api.callback.IRCRTCSwitchRoleCallback; -import cn.rongcloud.rtc.base.RTCErrorCode; -import io.rong.imlib.IRongCallback; -import io.rong.imlib.RongIMClient; -import io.rong.imlib.model.Conversation; -import io.rong.message.TextMessage; - import static com.yunbao.live.views.LivePlayRyViewHolder.Micing; /** @@ -111,7 +98,7 @@ public class LiveAudienceActivity extends LiveActivity { public static int fansNum; public static ProcessResultUtil mProcessResultUtil; - private LiveImDeletUtil liveImDeletUtil; + public static int isattention; private LiveBean mLiveBean; @@ -121,7 +108,7 @@ public class LiveAudienceActivity extends LiveActivity { private int mLastPosition = -1; private ViewGroup mViewGroup; - private LoadingView loadingView; + private int liveBg = 0; @Override @@ -140,7 +127,7 @@ public class LiveAudienceActivity extends LiveActivity { Bus.getOn(this); super.main(); liveAudienceActivity = this; - liveImDeletUtil = new LiveImDeletUtil(); + mProcessResultUtil = new ProcessResultUtil(this); Intent intent = getIntent(); mLiveSDK = intent.getIntExtra(Constants.LIVE_SDK, Constants.LIVE_SDK_KSY); @@ -150,11 +137,6 @@ public class LiveAudienceActivity extends LiveActivity { mLiveBean = intent.getParcelableExtra(Constants.LIVE_BEAN); mLiveUid = mLiveBean.getUid(); mStream = mLiveBean.getStream(); - if (getIntent().getIntExtra("isry", 0) == 1) { - isRy = true; - } else { - isRy = false; - } setVolumeControlStream(AudioManager.STREAM_MUSIC); manager = new PortraitLiveManager(this, intent); initView(); @@ -167,8 +149,6 @@ public class LiveAudienceActivity extends LiveActivity { private void initView() { // 竖直滑动 ViewPager verticalViewPager = findViewById(R.id.view_pager); - loadingView = findViewById(R.id.loading); - loadingView.show(); } public void setBackIndex(int backIndex) { @@ -187,58 +167,47 @@ public class LiveAudienceActivity extends LiveActivity { * 初始化数据 */ private void initData() { - //直播间列表 - MainNetManager.get(mContext) - .anchorRecommend("30", new com.yunbao.common.http.base.HttpCallback() { - @Override - public void onSuccess(AnchorRecommendModel data) { - itemModelList = data.getList(); - //查询直播间状态 - int index = -1; - for (int i = 0; i < itemModelList.size(); i++) { - AnchorRecommendItemModel model = itemModelList.get(i); - if (TextUtils.equals(mLiveBean.getUid(), model.getUid())) { - index = i; - } - } - if (index > -1) { - Collections.swap(itemModelList, index, 0); - } else { - String json = GsonUtils.toJson(mLiveBean); - AnchorRecommendItemModel model = GsonUtils.fromJson(json, AnchorRecommendItemModel.class); - itemModelList.add(0, model); - } - mPagerAdapter = new VerticalPagerAdapter(itemModelList, mContext); - verticalViewPager.setAdapter(mPagerAdapter); - loadingView.hide(); - } - - @Override - public void onError(String error) { - } - }); - - + String json = GsonUtils.toJson(mLiveBean); + AnchorRecommendItemModel model = GsonUtils.fromJson(json, AnchorRecommendItemModel.class); + itemModelList.add(0, model); + mPagerAdapter = new VerticalPagerAdapter(itemModelList, mContext); + verticalViewPager.setAdapter(mPagerAdapter); verticalViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { - mCurrentItem = position; - Log.e(TAG, "mCurrentItem:" + mCurrentItem); - if (mCurrentItem == itemModelList.size() - 1) { - MainNetManager.get(mContext) - .anchorRecommend("30", new com.yunbao.common.http.base.HttpCallback() { - @Override - public void onSuccess(AnchorRecommendModel data) { - itemModelList.addAll(data.getList()); - mPagerAdapter.notifyDataSetChanged(); - } + if (Micing == 1) { - @Override - public void onError(String error) { - } - }); + manager.micIngTypeOne(mLiveBean, mLiveType, mLiveTypeVal); + verticalViewPager.setEnableScroll(false); + } else if (Micing == 2) { + verticalViewPager.setEnableScroll(false); + manager.micIngTypeTwo(mLiveBean, mLiveType, mLiveTypeVal); + + } else { + verticalViewPager.setEnableScroll(true); + mCurrentItem = position; + Log.e(TAG, "mCurrentItem:" + mCurrentItem); + if (mCurrentItem == itemModelList.size() - 1) { + MainNetManager.get(mContext) + .anchorRecommendType("30", new com.yunbao.common.http.base.HttpCallback() { + @Override + public void onSuccess(AnchorRecommendModel data) { + if (TextUtils.equals(data.getList().get(0).getUid(), mLiveBean.getUid())) { + data.getList().remove(0); + } + itemModelList.addAll(data.getList()); + mPagerAdapter.notifyDataSetChanged(); + } + + @Override + public void onError(String error) { + } + }); + } } + + } @Override @@ -266,7 +235,6 @@ public class LiveAudienceActivity extends LiveActivity { // 满足此种条件,表明需要加载直播视频,以及聊天室了 if (viewGroup.getId() == mCurrentItem && (position == 0) && mCurrentItem != mLastPosition) { - loadData(viewGroup, mCurrentItem); } } @@ -443,115 +411,15 @@ public class LiveAudienceActivity extends LiveActivity { @Override public void onBackPressed() { + manager.onBackPressed(); if (Micing == 1) { - DialogUitl.showSimpleDialog(mContext, "您已申請,退出將取消語音連麥申請!", new DialogUitl.SimpleCallback() { - @Override - public void onConfirmClick(Dialog dialog, String content) { - Micing = 0; - //用户申请联麦 - final SocketSendBean msg = new SocketSendBean() - .param("_method_", Constants.LIAN_MAI) - .param("action", 7) - .param("uname", CommonAppConfig.getInstance().getUserBean().getUserNiceName()) - .param("avatar", CommonAppConfig.getInstance().getUserBean().getAvatar()) - .param("uid", CommonAppConfig.getInstance().getUid()); - msg.create(); - - String targetId = mLiveUid; - Conversation.ConversationType conversationType = Conversation.ConversationType.PRIVATE; - TextMessage messageContent = TextMessage.obtain(msg.mResult.toString()); - io.rong.imlib.model.Message message = io.rong.imlib.model.Message.obtain(targetId, conversationType, messageContent); - - RongIMClient.getInstance().sendMessage(message, null, null, new IRongCallback.ISendMessageCallback() { - @Override - public void onAttached(io.rong.imlib.model.Message message) { - - } - - @Override - public void onSuccess(io.rong.imlib.model.Message message) { - Log.e("ry", "发送成功"); - liveImDeletUtil.deleteMessages(message.getTargetId(), message.getMessageId()); - } - - @Override - public void onError(io.rong.imlib.model.Message message, RongIMClient.ErrorCode errorCode) { - Log.e("ry", "发送失敗" + errorCode.toString()); - liveImDeletUtil.deleteMessages(message.getTargetId(), message.getMessageId()); - } - }); - end(); - } - }); - return; + manager.micIngTypeOne(mLiveBean, mLiveType, mLiveTypeVal); } else if (Micing == 2) { - DialogUitl.showSimpleDialog(mContext, "連麥中,退出將斷開語音連麥!", new DialogUitl.SimpleCallback() { - @Override - public void onConfirmClick(Dialog dialog, String content) { - ToastUtil.show("下麥中,稍等....."); - RCRTCEngine.getInstance().getRoom().getLocalUser().switchToAudience(new IRCRTCSwitchRoleCallback() { - - /** - * 当切换失败且SDK处于无法回退状态时回调,该角色已经无法使用当前角色继续进行音视频。 - * SDK内部会退出房间并清理所有资源,该用户只能重新加入房间才能继续音视频。 - */ - @Override - public void onKicked() { - - } - - @Override - public void onSuccess() { - Log.e("ry", "下麦成功"); - // 该用户切换为观众成功,可以以观众身份进行音视频 - //退出多人房间 - HttpClient.getInstance().get("live.leaveDrLm", "live.leaveDrLm") - .params("roomid", LiveActivity.mLiveUid) - .execute(new HttpCallback() { - @Override - public void onSuccess(int code, String msg, String[] info) { - Log.e("ry", code + "退出多人"); - - } - }); - //退出rtc播放 - RCRTCEngine.getInstance().leaveRoom(new IRCRTCResultCallback() { - @Override - public void onSuccess() { - Log.e("ry", "退出多人房间成功"); - new Handler(Looper.getMainLooper()).post(new Runnable() { - public void run() { - Micing = 0; - end(); - } - }); - } - - @Override - public void onFailed(RTCErrorCode errorCode) { - Log.e("ry", errorCode + "退出多人房间失敗"); - - } - }); - - } - - /** - * 当切换失败且不影响当前角色继续音视频时回调 - * @param errorCode 失败错误码 - */ - @Override - public void onFailed(RTCErrorCode errorCode) { - Log.e("ry", "下麦失败" + errorCode); - - } - }); - - } - }); - return; + manager.micIngTypeTwo(mLiveBean, mLiveType, mLiveTypeVal); + } else { + super.onBackPressed(); } - end(); + } public void end() { @@ -664,20 +532,34 @@ public class LiveAudienceActivity extends LiveActivity { fragment.show(getSupportFragmentManager(), "ChatChargeDialogFragment"); } + public void setEnableScroll(boolean enableScroll) { + verticalViewPager.setEnableScroll(enableScroll); + } @Subscribe(threadMode = ThreadMode.MAIN) public void onLiveRoomChangeEvent(LiveRoomChangeEvent e) { - LiveBean liveBean = e.getLiveBean(); - if (liveBean != null) { - LiveHttpUtil.cancel(LiveHttpConsts.CHECK_LIVE); - LiveHttpUtil.cancel(LiveHttpConsts.ENTER_ROOM); - LiveHttpUtil.cancel(LiveHttpConsts.ROOM_CHARGE); - manager.onRemove(); - mLiveType = e.getLiveType(); - mLiveTypeVal = e.getLiveTypeVal(); - manager.onAdd(liveBean, mLiveType, mLiveTypeVal, mLiveSDK); + if (verticalViewPager.ismEnableScroll()) { + LiveBean liveBean = e.getLiveBean(); + if (liveBean != null) { + LiveHttpUtil.cancel(LiveHttpConsts.CHECK_LIVE); + LiveHttpUtil.cancel(LiveHttpConsts.ENTER_ROOM); + LiveHttpUtil.cancel(LiveHttpConsts.ROOM_CHARGE); + manager.onRemove(); + mLiveType = e.getLiveType(); + mLiveTypeVal = e.getLiveTypeVal(); + mLiveBean = liveBean; + mLiveUid = liveBean.getUid(); + mStream = liveBean.getStream(); + mAncherName = liveBean.getUserNiceName(); + manager.onAdd(liveBean, mLiveType, mLiveTypeVal, mLiveSDK); + + } + } else { + verticalViewPager.setEnableScroll(true); } + + } @Override @@ -698,11 +580,21 @@ public class LiveAudienceActivity extends LiveActivity { IMLoginModel userInfo = IMLoginManager.get(mContext).getUserInfo(); switch (event.getType()) { case SIDEBAR: + int userIndex = -1; + for (int i = 0; i < list.size(); i++) { + if (TextUtils.equals(list.get(i).getUid(), PortraitLiveManager.liveID)) { + userIndex = i; + } + } + if (userIndex != -1) { + list.remove(userIndex); + } //从右边打开侧边栏 SidebarLiveAudience sidebarLiveAudience = new SidebarLiveAudience(); bundle.putString("Avatar", mLiveBean.getAvatar()); bundle.putString("banner", GsonUtils.toJson(slideInfoModels)); bundle.putString("list", GsonUtils.toJson(list)); + bundle.putInt("LiveBg", liveBg); sidebarLiveAudience.setArguments(bundle); sidebarLiveAudience.show(getSupportFragmentManager(), "SidebarLiveAudience"); // manager.openDrawer(); @@ -773,26 +665,32 @@ public class LiveAudienceActivity extends LiveActivity { ZhuangBanActivity.forward(mContext, nobleUrl, false); break; case LIAN_MAI: - //获取房间连麦状态 - HttpClient.getInstance().get("live.getDrLm", "live.getDrLm") - .params("uid", mLiveUid, true) - .execute(new HttpCallback() { - @Override - public void onSuccess(int code, String msg, String[] info) { - if (code == 0) { - LiveMicUserDialogFragment fragment = new LiveMicUserDialogFragment(); - Bundle bundle = new Bundle(); - bundle.putString(Constants.LIVE_UID, mLiveUid); - bundle.putString(Constants.STREAM, mStream); - bundle.putString("By", "1"); - fragment.setArguments(bundle); - fragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveUserMoreDialogFragment"); - LiveMicUserDialogFragment.activity = ((LiveAudienceActivity) mContext); - } else { - ToastUtil.show(R.string.no_mic_opn); + if (event.getMicIng() == 1) { + manager.micIngTypeOne(event.getBean(), event.getLiveType(), event.getLiveTypeVal()); + } else if (event.getMicIng() == 2) { + manager.micIngTypeTwo(event.getBean(), event.getLiveType(), event.getLiveTypeVal()); + } else { + //获取房间连麦状态 + HttpClient.getInstance().get("live.getDrLm", "live.getDrLm") + .params("uid", mLiveUid, true) + .execute(new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + if (code == 0) { + LiveMicUserDialogFragment fragment = new LiveMicUserDialogFragment(); + Bundle bundle = new Bundle(); + bundle.putString(Constants.LIVE_UID, mLiveUid); + bundle.putString(Constants.STREAM, mStream); + bundle.putString("By", "1"); + fragment.setArguments(bundle); + fragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveUserMoreDialogFragment"); + LiveMicUserDialogFragment.activity = ((LiveAudienceActivity) mContext); + } else { + ToastUtil.show(R.string.no_mic_opn); + } } - } - }); + }); + } break; case EFFECTS_SETTINGS: EffectsSettingsDialog effectsSettingsDialog = new EffectsSettingsDialog(); @@ -821,17 +719,33 @@ public class LiveAudienceActivity extends LiveActivity { mLiveTypeVal : event.getParametersModel().getmLiveTypeVal(); mLiveGuardInfo = event.getParametersModel().getmLiveGuardInfo() == null ? mLiveGuardInfo : event.getParametersModel().getmLiveGuardInfo(); + liveBg = TextUtils.equals(String.valueOf(liveBg), String.valueOf(event.getParametersModel().getLiveBg())) ? + liveBg : event.getParametersModel().getLiveBg(); break; case ACTIVITY_CENTER://活动中心 String url = CommonAppConfig.HOST + "/h5/live/hallOfFame/index.html?g=Appapi&m=Turntable&a=tricky"; url += "&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&anchorUid=" + mLiveUid; Log.i("tag", url); - Intent intent=new Intent(mContext,ZhuangBanActivity.class); + Intent intent = new Intent(mContext, ZhuangBanActivity.class); intent.putExtra("url", url); - intent.putExtra("isFull",true); + intent.putExtra("isFull", true); mContext.startActivity(intent); break; + case LIVE_ROOM_EXCEPTION: + //主播未直播时自动下滑至下一个直播间 + itemModelList.remove(mCurrentPage); + mPagerAdapter.notifyDataSetChanged(); + verticalViewPager.setCurrentItem(mCurrentPage + 1); + break; + case REFRESH_THE_LIVEl_PAGE: +// loadingView.show(); +// AnchorRecommendItemModel model = event.getAnchorRecommendItemModel(); +// itemModelList.add(0, model); +// mPagerAdapter.notifyDataSetChanged(); +// verticalViewPager.setCurrentItem(0); + getDrawer(); + break; } @@ -855,7 +769,7 @@ public class LiveAudienceActivity extends LiveActivity { intent.putExtra(Constants.LIVE_SDK, liveSdk); intent.putExtra(Constants.LIVE_SDK, liveSdk); intent.putExtra("landscape", liveBean.getLandscape()); - intent.putExtra("isry", liveBean.getIs_rong()); +// intent.putExtra("isry", true); context.startActivity(intent); } @@ -866,26 +780,19 @@ public class LiveAudienceActivity extends LiveActivity { private List list = new ArrayList<>(); private void getDrawer() { - //侧边栏轮播 - MainNetManager.get(mContext) - .getHot(1, new com.yunbao.common.http.base.HttpCallback>() { - @Override - public void onSuccess(List data) { - slideInfoModels = data; - } - @Override - public void onError(String error) { - - } - }); //推荐位 MainNetManager.get(mContext) - .anchorRecommend("10", new com.yunbao.common.http.base.HttpCallback() { + .anchorRecommend("12", new com.yunbao.common.http.base.HttpCallback() { @Override public void onSuccess(AnchorRecommendModel anchorRecommendModel) { - list = anchorRecommendModel.getList(); + list.clear(); + slideInfoModels.clear(); + List models = anchorRecommendModel.getList(); + models.add(0, new AnchorRecommendItemModel()); + list.addAll(models); + slideInfoModels = anchorRecommendModel.getSlide(); } @Override @@ -894,4 +801,7 @@ public class LiveAudienceActivity extends LiveActivity { }); } + public void onFollowEvent(FollowEvent e) { + manager.onFollowEvent(e); + } } diff --git a/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java index a133ccf82..5654ff869 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java @@ -146,7 +146,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl @Override protected void main() { super.main(); - isRy = true; +// isRy = true; Intent intent = getIntent(); mLiveSDK = intent.getIntExtra(Constants.LIVE_SDK, Constants.LIVE_SDK_KSY); mLiveKsyConfigBean = intent.getParcelableExtra(Constants.LIVE_KSY_CONFIG); @@ -190,7 +190,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl mLiveReadyViewHolder.addToParent(); mLiveReadyViewHolder.subscribeActivityLifeCycle(); mLiveLinkMicPresenter = new LiveLinkMicPresenter(mContext, mLivePushViewHolder, true, mLiveSDK, mContainer); - mLiveLinkMicPresenter.setLiveUid(mLiveUid); +// mLiveLinkMicPresenter.setLiveUid(mLiveUid); mLiveLinkMicAnchorPresenter = new LiveLinkMicAnchorPresenter(mContext, mLivePushViewHolder, true, mLiveSDK, mContainer); mLivePushViewHolder.setLivePushListener(new LivePushListener() { @Override @@ -590,7 +590,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl hasGame = mGameList.size() > 0; } bundle.putBoolean(Constants.HAS_GAME, hasGame); - bundle.putBoolean("isRy", true); +// bundle.putBoolean("isRy", true); bundle.putBoolean(Constants.OPEN_FLASH, mLivePushViewHolder != null && mLivePushViewHolder.isFlashOpen()); fragment.setArguments(bundle); fragment.setFunctionClickListener(this); diff --git a/live/src/main/java/com/yunbao/live/adapter/GuardRightAdapter.java b/live/src/main/java/com/yunbao/live/adapter/GuardRightAdapter.java index 9daf2acea..e304b0cd1 100644 --- a/live/src/main/java/com/yunbao/live/adapter/GuardRightAdapter.java +++ b/live/src/main/java/com/yunbao/live/adapter/GuardRightAdapter.java @@ -36,6 +36,9 @@ public class GuardRightAdapter extends RecyclerView.Adapter mList) { + this.mList = mList; + } @NonNull @Override diff --git a/live/src/main/java/com/yunbao/live/adapter/LiveNewGuardBuyItemsAdapter.java b/live/src/main/java/com/yunbao/live/adapter/LiveNewGuardBuyItemsAdapter.java new file mode 100644 index 000000000..b4b1bb8a4 --- /dev/null +++ b/live/src/main/java/com/yunbao/live/adapter/LiveNewGuardBuyItemsAdapter.java @@ -0,0 +1,109 @@ +package com.yunbao.live.adapter; + +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.LinearLayout; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.yunbao.common.utils.WordUtil; +import com.yunbao.live.R; +import com.yunbao.live.bean.GuardBuyBean; + +import java.util.ArrayList; +import java.util.List; + +/** + * 守护购买列表适配器 + */ +public class LiveNewGuardBuyItemsAdapter extends RecyclerView.Adapter { + + List items = new ArrayList<>(); + private final Context context; + private int selectId = 1; + private OnItemSelectListener itemSelect; + + public LiveNewGuardBuyItemsAdapter(Context context) { + this.context = context; + } + + public void setItems(List items) { + this.items = items; + } + public void setOnItemSelectListener(OnItemSelectListener listener){ + this.itemSelect=listener; + } + + @NonNull + @Override + public Vh onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + return new Vh(LayoutInflater.from(context).inflate(R.layout.item_dialog_guard_buy, parent, false)); + } + + @Override + public void onBindViewHolder(@NonNull Vh holder, int position) { + GuardBuyBean bean = items.get(position); + holder.setData(bean, bean.getId()); + } + + public void changeItem(int id) { + this.selectId = id; + } + + + @Override + public int getItemCount() { + return items.size(); + } + + protected class Vh extends RecyclerView.ViewHolder { + private LinearLayout buyButton; + private TextView title; + private TextView msg; + private TextView coin; + + public Vh(@NonNull View itemView) { + super(itemView); + buyButton = itemView.findViewById(R.id.guard_buy_button); + title = itemView.findViewById(R.id.guard_buy_title); + msg = itemView.findViewById(R.id.guard_buy_goback); + coin = itemView.findViewById(R.id.guard_buy_money); + + buyButton.setOnClickListener(view -> { + buyButton.setBackgroundResource(R.drawable.img_k_selected); + changeItem((int)title.getTag()); + notifyDataSetChanged(); + if(itemSelect!=null){ + itemSelect.onSelectId((int)title.getTag()); + } + + }); + } + + private void setData(GuardBuyBean bean, int id) { + String coin = bean.getCoin() + ""; + title.setText(bean.getName()); + title.setTag(id); + String msgText = WordUtil.getString(R.string.buy_guard_back_coin); + msg.setText(msgText + coin); + this.coin.setText(coin); + if(id==selectId){ + buyButton.setBackgroundResource(R.drawable.img_k_selected); + }else { + buyButton.setBackgroundResource(R.drawable.img_k_uncheck); + } + + } + } + + /** + * 用于回调通知当前选择id + */ + public interface OnItemSelectListener { + void onSelectId(int id); + } +} diff --git a/live/src/main/java/com/yunbao/live/adapter/LiveRoomFastMessageRecyclerViewAdapter.java b/live/src/main/java/com/yunbao/live/adapter/LiveRoomFastMessageRecyclerViewAdapter.java new file mode 100644 index 000000000..0cbd71630 --- /dev/null +++ b/live/src/main/java/com/yunbao/live/adapter/LiveRoomFastMessageRecyclerViewAdapter.java @@ -0,0 +1,109 @@ +package com.yunbao.live.adapter; + +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.constraintlayout.widget.ConstraintLayout; +import androidx.recyclerview.widget.RecyclerView; + +import com.yunbao.live.R; + +import java.util.ArrayList; +import java.util.List; + +/** + * 直播间打招呼适配器 + */ +public class LiveRoomFastMessageRecyclerViewAdapter extends RecyclerView.Adapter { + private Context context; + private List items; + private OnSendMessageListener messageListener; + public LiveRoomFastMessageRecyclerViewAdapter(Context context) { + this.context = context; + this.items=new ArrayList<>(); + } + + /** + * 设置点击消息回调 + * @param messageListener 消息回调 + */ + public void setMessageListener(OnSendMessageListener messageListener) { + this.messageListener = messageListener; + } + + /** + * 添加消息 + * @param msg 消息 + */ + public void addMessage(String msg){ + items.add(msg); + notifyDataSetChanged(); + } + + /** + * 添加消息 + * @param items 消息组 + */ + public void setMessage(List items){ + this.items=items; + notifyDataSetChanged(); + + } + + @NonNull + @Override + public Vh onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + return new Vh(LayoutInflater.from(context).inflate(R.layout.item_fast_msg,parent,false)); + } + + @Override + public void onBindViewHolder(@NonNull Vh holder, int position) { + holder.setData(items.get(position)); + } + + @Override + public int getItemCount() { + return items.size(); + } + + protected class Vh extends RecyclerView.ViewHolder{ + private final TextView message; + + public Vh(@NonNull View itemView) { + super(itemView); + message=itemView.findViewById(R.id.room_fast_message_text_view); + ConstraintLayout layout = itemView.findViewById(R.id.room_fast_layout); + layout.setOnClickListener(view -> { + int position= getPosition((String) message.getTag()); + if(position==-1){{ + return; + }} + if(messageListener!=null){ + messageListener.onMessage((String) message.getTag()); + } + items.remove(position); + notifyItemRemoved(position); + }); + } + private int getPosition(String msg){ + for (int i = 0; i < items.size(); i++) { + if(items.get(i).equals(msg)){ + return i; + } + } + return -1; + } + public void setData(String msg){ + message.setTag(msg); + message.setText(msg); + } + + } + public interface OnSendMessageListener{ + void onMessage(String msg); + } +} diff --git a/live/src/main/java/com/yunbao/live/adapter/VerticalPagerAdapter.java b/live/src/main/java/com/yunbao/live/adapter/VerticalPagerAdapter.java index 419c9041c..8329841b6 100644 --- a/live/src/main/java/com/yunbao/live/adapter/VerticalPagerAdapter.java +++ b/live/src/main/java/com/yunbao/live/adapter/VerticalPagerAdapter.java @@ -50,7 +50,7 @@ public class VerticalPagerAdapter extends androidx.viewpager.widget.PagerAdapter ImageView ivLoading = view.findViewById(R.id.iv_loading); AnimationDrawable frameAnimation = (AnimationDrawable) ivLoading.getBackground(); frameAnimation.start(); - +// ImgLoader.displayGif(mContext, R.drawable.live_loading, ivLoading); view.setId(position); container.addView(view); return view; diff --git a/live/src/main/java/com/yunbao/live/bean/GuardBuyBean.java b/live/src/main/java/com/yunbao/live/bean/GuardBuyBean.java index a296d04f9..1aa495bdb 100644 --- a/live/src/main/java/com/yunbao/live/bean/GuardBuyBean.java +++ b/live/src/main/java/com/yunbao/live/bean/GuardBuyBean.java @@ -3,6 +3,8 @@ package com.yunbao.live.bean; import com.yunbao.common.utils.WordUtil; import com.yunbao.live.R; +import java.util.Arrays; + /** * Created by cxf on 2018/11/6. * 守护商品类型 @@ -67,4 +69,15 @@ public class GuardBuyBean { } return ""; } + + @Override + public String toString() { + return "GuardBuyBean{" + + "id=" + id + + ", name='" + name + '\'' + + ", type=" + type + + ", coin=" + coin + + ", privilege=" + Arrays.toString(privilege) + + '}'; + } } diff --git a/live/src/main/java/com/yunbao/live/bean/OpenParametersModel.java b/live/src/main/java/com/yunbao/live/bean/OpenParametersModel.java index b30e16ca6..c2f2c738b 100644 --- a/live/src/main/java/com/yunbao/live/bean/OpenParametersModel.java +++ b/live/src/main/java/com/yunbao/live/bean/OpenParametersModel.java @@ -15,6 +15,16 @@ public class OpenParametersModel extends BaseModel { //收费价格,计时收费每次扣费的值 private int mLiveTypeVal = 0; private LiveGuardInfo mLiveGuardInfo = null; + private int liveBg = 0; + + public int getLiveBg() { + return liveBg; + } + + public OpenParametersModel setLiveBg(int liveBg) { + this.liveBg = liveBg; + return this; + } public int getmLiveType() { return mLiveType; diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveFunctionDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveFunctionDialogFragment.java index 8b569d3e0..1afe6f482 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveFunctionDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveFunctionDialogFragment.java @@ -24,7 +24,7 @@ import com.yunbao.live.interfaces.LiveFunctionClickListener; public class LiveFunctionDialogFragment extends AbsDialogFragment implements OnItemClickListener { private LiveFunctionClickListener mFunctionClickListener; - boolean isRy = false; +// boolean isRy = false; @Override protected int getLayoutId() { return R.layout.dialog_live_function; @@ -60,7 +60,7 @@ public class LiveFunctionDialogFragment extends AbsDialogFragment implements OnI if (bundle != null) { hasGame = bundle.getBoolean(Constants.HAS_GAME, false); openFlash = bundle.getBoolean(Constants.OPEN_FLASH, false); - isRy = bundle.getBoolean("isRy", false); +// isRy = bundle.getBoolean("isRy", false); } RecyclerView recyclerView = (RecyclerView) mRootView.findViewById(R.id.recyclerView); recyclerView.setHasFixedSize(true); @@ -85,11 +85,11 @@ public class LiveFunctionDialogFragment extends AbsDialogFragment implements OnI @Override public void onDestroy() { mFunctionClickListener = null; - if(isRy == false) { - ((LiveAnchorActivity) mContext).setBtnFunctionDark(); - }else{ +// if(isRy == false) { +// ((LiveAnchorActivity) mContext).setBtnFunctionDark(); +// }else{ ((LiveRyAnchorActivity) mContext).setBtnFunctionDark(); - } +// } super.onDestroy(); } } diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveGuardDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveGuardDialogFragment.java index 86cb28ac1..ed0f4a67c 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveGuardDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveGuardDialogFragment.java @@ -93,6 +93,12 @@ public class LiveGuardDialogFragment extends AbsDialogFragment implements View.O mTip = (TextView) mRootView.findViewById(R.id.tip); mBtnBuy = (TextView) mRootView.findViewById(R.id.btn_buy); mBtnBuy.setOnClickListener(this); + /* mBtnBuy.setOnLongClickListener(view -> { + //长按调用老版购买守护页面,调试用 + dismiss(); + ((LiveActivity) mContext).openBuyGuardWindow(); + return false; + });*/ if (mLiveGuardInfo != null) { mGuardNum.setText(WordUtil.getString(R.string.guard_guard) + "(" + mLiveGuardInfo.getGuardNum() + ")"); int guardType = mLiveGuardInfo.getMyGuardType(); @@ -158,7 +164,7 @@ public class LiveGuardDialogFragment extends AbsDialogFragment implements View.O @Override public void onClick(View v) { dismiss(); - ((LiveActivity) mContext).openBuyGuardWindow(); + ((LiveActivity) mContext).openNewBuyGuardWindow(); } @Override diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveMicUserDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveMicUserDialogFragment.java index 2daf5052d..d5f3f2c84 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveMicUserDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveMicUserDialogFragment.java @@ -212,7 +212,7 @@ public class LiveMicUserDialogFragment extends AbsDialogFragment implements View public void onError(io.rong.imlib.model.Message message, RongIMClient.ErrorCode errorCode) { Log.e("ry", "发送失敗" + errorCode.toString()); liveImDeletUtil.deleteMessages(message.getTargetId(), message.getMessageId()); - } + }//BIZ_ERROR_DATABASE_ERROR }); } else { ToastUtil.show(msg); diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveNewGuardBuyDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveNewGuardBuyDialogFragment.java new file mode 100644 index 000000000..0cbce77cf --- /dev/null +++ b/live/src/main/java/com/yunbao/live/dialog/LiveNewGuardBuyDialogFragment.java @@ -0,0 +1,316 @@ +package com.yunbao.live.dialog; + +import android.app.Dialog; +import android.os.Bundle; +import android.text.TextUtils; +import android.util.Log; +import android.view.Gravity; +import android.view.View; +import android.view.Window; +import android.view.WindowManager; +import android.widget.TextView; + +import androidx.annotation.Nullable; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.yunbao.common.CommonAppConfig; +import com.yunbao.common.Constants; +import com.yunbao.common.bean.UserBean; +import com.yunbao.common.dialog.AbsDialogFragment; +import com.yunbao.common.http.HttpCallback; +import com.yunbao.common.utils.DialogUitl; +import com.yunbao.common.utils.RouteUtil; +import com.yunbao.common.utils.ToastUtil; +import com.yunbao.common.utils.WordUtil; +import com.yunbao.live.R; +import com.yunbao.live.activity.LiveActivity; +import com.yunbao.live.adapter.GuardRightAdapter; +import com.yunbao.live.adapter.LiveNewGuardBuyItemsAdapter; +import com.yunbao.live.bean.GuardBuyBean; +import com.yunbao.live.bean.GuardRightBean; +import com.yunbao.live.bean.LiveGuardInfo; +import com.yunbao.live.http.LiveHttpConsts; +import com.yunbao.live.http.LiveHttpUtil; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by cxf on 2018/11/6. + * 直播间购买守护弹窗 + * 改版后效果 + */ + +public class LiveNewGuardBuyDialogFragment extends AbsDialogFragment implements View.OnClickListener { + + private RecyclerView mRights;//权益列表 + private RecyclerView mBuys;//购买列表 + private TextView anchorName; + private TextView mCoin; + private String mCoinName; + private TextView mCoinNameTextView; + private View mBtnBuy; + private List mRightList=new ArrayList<>();//权限列表 + private List mBuyList;//商品列表 + private long mCoinVal;//余额 + private String mLiveUid; + private String mStream; + private String mAncherName; + private LiveGuardInfo mLiveGuardInfo; + private GuardBuyBean mTargetBuyBean; + + private LiveNewGuardBuyItemsAdapter buyItemsAdapter; + private GuardRightAdapter mGuardRightAdapter; + + + @Override + protected int getLayoutId() { + return R.layout.dialog_new_guard_buy; + } + + @Override + protected int getDialogStyle() { + return R.style.dialog2; + } + + @Override + protected boolean canCancel() { + return true; + } + + @Override + protected void setWindowAttributes(Window window) { + window.setWindowAnimations(R.style.bottomToTopAnim); + WindowManager.LayoutParams params = window.getAttributes(); + params.width = WindowManager.LayoutParams.MATCH_PARENT; + params.height = WindowManager.LayoutParams.WRAP_CONTENT; + params.gravity = Gravity.BOTTOM; + window.setAttributes(params); + } + + public void setLiveGuardInfo(LiveGuardInfo info) { + mLiveGuardInfo = info; + } + + @Override + public void onActivityCreated(@Nullable Bundle savedInstanceState) { + super.onActivityCreated(savedInstanceState); + + mCoinNameTextView = mRootView.findViewById(R.id.guard_coin_name); + mCoin = mRootView.findViewById(R.id.guard_coin); + mBtnBuy = mRootView.findViewById(R.id.guard_btn_buy); + mRights = mRootView.findViewById(R.id.guard_rights); + mBuys = mRootView.findViewById(R.id.guard_buys); + anchorName = mRootView.findViewById(R.id.guard_anchor_name); + mBtnBuy.setOnClickListener(this); + mRights.setHasFixedSize(true); + mRights.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false)); + mBuys.setHasFixedSize(true); + mBuys.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, false){ + @Override + public boolean canScrollHorizontally() {//购买列表禁止滑动 + return false; + } + }); + mBuys.setItemViewCacheSize(3); + + buyItemsAdapter = new LiveNewGuardBuyItemsAdapter(mContext); + mGuardRightAdapter = new GuardRightAdapter(mContext, mRightList); + mRights.setAdapter(mGuardRightAdapter); + mBuys.setAdapter(buyItemsAdapter); + buyItemsAdapter.setOnItemSelectListener(this::refreshList); + + Bundle bundle = getArguments(); + if (bundle != null) { + mLiveUid = bundle.getString(Constants.LIVE_UID); + mStream = bundle.getString(Constants.STREAM); + mAncherName=bundle.getString(Constants.LIVE_ANCHER_NAME); + String coinName = WordUtil.getString(R.string.diamond); + mCoinName = coinName; + mCoinNameTextView.setText(WordUtil.getString(R.string.guard_my) + coinName + ":"); + anchorName.setText(String.format("成爲%s的守護", mAncherName)); + } + LiveHttpUtil.getGuardBuyList(new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + if (code == 0 && info.length > 0) { + JSONObject obj = JSON.parseObject(info[0]); + mRightList = JSON.parseArray(obj.getString("privilege"), GuardRightBean.class); + mBuyList = JSON.parseArray(obj.getString("list"), GuardBuyBean.class); + try { + mCoinVal = obj.getLongValue("coin"); + } catch (Exception e) { + e.printStackTrace(); + } + mCoin.setText(String.valueOf(mCoinVal)); + buyItemsAdapter.setItems(mBuyList); + mGuardRightAdapter.setList(mRightList); + buyItemsAdapter.notifyDataSetChanged(); + + refreshList(1); + + } else { + ToastUtil.show(msg); + } + } + }); + } + + + private void refreshList(int index) { + if (!mRightList.isEmpty()) { + GuardBuyBean guardBuyBean = mBuyList.get(index - 1); + mTargetBuyBean=guardBuyBean; + for (GuardRightBean bean : mRightList) { + bean.setChecked(false); + } + for (int i : guardBuyBean.getPrivilege()) { + mRightList.get(i).setChecked(true); + } + mGuardRightAdapter.notifyDataSetChanged(); + mBtnBuy.setEnabled(mCoinVal >= guardBuyBean.getCoin()); + } + + } + + + + @Override + public void onClick(View view) { + int i = view.getId(); + if (i == R.id.guard_btn_buy) { + clickBuyGuard(); + + } +// else if (i == R.id.coin) { +// forwardMyCoin(); +// +// } + } + + /** + * 跳转到我的钻石 + */ + private void forwardMyCoin() { + dismiss(); + RouteUtil.forwardMyCoin(mContext); + } + + /** + * 点击购买守护按钮 + */ + private void clickBuyGuard() { + if (TextUtils.isEmpty(mLiveUid) || TextUtils.isEmpty(mStream) || mLiveGuardInfo == null || mTargetBuyBean == null) { + return; + } + Log.d("ffffff", "" + mLiveGuardInfo.getMyGuardType() + " " + mTargetBuyBean.getType()); + if (mLiveGuardInfo.getMyGuardType() == Constants.GUARD_TYPE_MONTH && mTargetBuyBean.getType() == Constants.GUARD_TYPE_DAY) { + DialogUitl.showSimpleTipDialog(mContext, WordUtil.getString(R.string.guard_buy_tip)); + return; + } else if (mLiveGuardInfo.getMyGuardType() == Constants.GUARD_TYPE_YEAR && mTargetBuyBean.getType() == Constants.GUARD_TYPE_DAY) { + DialogUitl.showSimpleTipDialog(mContext, "您為當前主播的年守護無法開通周守護"); + return; + } else if (mLiveGuardInfo.getMyGuardType() == Constants.GUARD_TYPE_YEAR && mTargetBuyBean.getType() == Constants.GUARD_TYPE_MONTH) { + DialogUitl.showSimpleTipDialog(mContext, "您為當前主播的年守護無法開通月守護"); + return; + } else { + if (mLiveGuardInfo.getMyGuardType() == Constants.GUARD_TYPE_MONTH + && mTargetBuyBean.getType() == Constants.GUARD_TYPE_YEAR) { + DialogUitl.showSimpleDialog(mContext, WordUtil.getString(R.string.guard_buy_tip_2), new DialogUitl.SimpleCallback() { + @Override + public void onConfirmClick(Dialog dialog, String content) { + doBuyGuard(); + } + }); + return; + } else if (mLiveGuardInfo.getMyGuardType() == Constants.GUARD_TYPE_DAY + && mTargetBuyBean.getType() == Constants.GUARD_TYPE_MONTH) { + DialogUitl.showSimpleDialog(mContext, "您為當前主播的周守護,開通月守護將覆蓋您的周守護時長,是否開通?", new DialogUitl.SimpleCallback() { + @Override + public void onConfirmClick(Dialog dialog, String content) { + doBuyGuard(); + } + }); + return; + } else if (mLiveGuardInfo.getMyGuardType() == Constants.GUARD_TYPE_DAY + && mTargetBuyBean.getType() == Constants.GUARD_TYPE_YEAR) { + DialogUitl.showSimpleDialog(mContext, "您為當前主播的周守護,開通年守護將覆蓋您的周守護時長,是否開通?", new DialogUitl.SimpleCallback() { + @Override + public void onConfirmClick(Dialog dialog, String content) { + doBuyGuard(); + } + }); + return; + } + + } + buyGuard(); + } + + /** + * 购买守护 + */ + private void buyGuard() { + if (mTargetBuyBean == null) { + return; + } + DialogUitl.showSimpleDialog(mContext, + String.format(WordUtil.getString(R.string.guard_buy_tip_3), mTargetBuyBean.getCoin(), mCoinName, mTargetBuyBean.getShopName()), + new DialogUitl.SimpleCallback() { + + @Override + public void onConfirmClick(Dialog dialog, String content) { + doBuyGuard(); + } + }); + } + + /** + * 购买守护 + */ + private void doBuyGuard() { + if (mTargetBuyBean == null) { + return; + } + LiveHttpUtil.buyGuard(mLiveUid, mStream, mTargetBuyBean.getId(), new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + if (code == 0 && info.length > 0) { + JSONObject obj = JSON.parseObject(info[0]); + String votes = obj.getString("votestotal");//主播当前的映票数 + int guardNum = obj.getIntValue("guard_nums");//主播当前的守护人数 + int guardType = obj.getIntValue("type"); + String ancherName = obj.getString("ancherName"); + String liveuid = obj.getString("liveuid"); + if (mLiveGuardInfo != null) { + mLiveGuardInfo.setMyGuardType(guardType); + mLiveGuardInfo.setMyGuardEndTime(obj.getString("endtime")); + mLiveGuardInfo.setGuardNum(guardNum); + } + mCoinVal = obj.getLongValue("coin"); + String coinString = String.valueOf(mCoinVal); + mCoin.setText(coinString); + UserBean u = CommonAppConfig.getInstance().getUserBean(); + if (u != null) { + u.setCoin(coinString); + u.setLevel(obj.getIntValue("level")); + } + ((LiveActivity) mContext).sendBuyGuardMessage2(votes, guardNum, guardType, ancherName, liveuid); + dismiss(); + } + ToastUtil.show(msg); + } + }); + } + + + @Override + public void onDestroy() { + mLiveGuardInfo = null; + LiveHttpUtil.cancel(LiveHttpConsts.GET_GUARD_BUY_LIST); + super.onDestroy(); + } +} diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveUserMoreDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveUserMoreDialogFragment.java index eea5cf065..70a5a88c0 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveUserMoreDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveUserMoreDialogFragment.java @@ -272,6 +272,9 @@ public class LiveUserMoreDialogFragment extends AbsDialogFragment implements Vie } private List processUserData(JSONObject json){ List data = JSON.parseArray(json.getString("userlist"), LiveUserGiftBean.class); + if(data==null){ + return new ArrayList<>(); + } Log.i("tag222", "ssss"); if (data.size() > 0 && pg == 1) { nums = 0; @@ -297,6 +300,9 @@ public class LiveUserMoreDialogFragment extends AbsDialogFragment implements Vie /** * 由于在线观众和粉丝列表实体结构与榜单结构不一致,做个兼容操作 */ + if(rank==null){ + return data; + } for (Object o : rank) { JSONObject item= (JSONObject) o; LiveUserRankBean bean=JSON.parseObject(item.getString("userinfo"),LiveUserRankBean.class); @@ -332,8 +338,11 @@ public class LiveUserMoreDialogFragment extends AbsDialogFragment implements Vie } void Up() { + userMoreInfoAdapter.clearData(); bottom_msg.setVisibility(View.VISIBLE); title.setVisibility(View.GONE); + LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) mRefreshView.getLayoutParams(); + params.bottomMargin=DpUtil.dp2px(65); if (Tips.equals("1")) { tags.setText("開通貴族,尊享超多特權!"); btn.setBackgroundResource(R.mipmap.btn_openvip); @@ -361,6 +370,7 @@ public class LiveUserMoreDialogFragment extends AbsDialogFragment implements Vie type = "fans"; no_more.setImageResource(R.mipmap.bixin); }else if(Tips.equals("4")){ + params.bottomMargin=DpUtil.dp2px(0); userMoreInfoAdapter.type = "4"; bottom_msg.setVisibility(View.GONE); type="dayRank"; @@ -368,6 +378,7 @@ public class LiveUserMoreDialogFragment extends AbsDialogFragment implements Vie gz_view.setVisibility(View.GONE); no_more.setImageResource(R.drawable.img_rank_empty); }else if (Tips.equals("5")){ + params.bottomMargin=DpUtil.dp2px(0); userMoreInfoAdapter.type = "5"; bottom_msg.setVisibility(View.GONE); type="weekRank"; @@ -375,6 +386,7 @@ public class LiveUserMoreDialogFragment extends AbsDialogFragment implements Vie no_more.setImageResource(R.drawable.img_rank_empty); setTextColor(weekRank,audience_btn,guard_btn,fans_btn,gz_view,dayRank); } + mRefreshView.setLayoutParams(params); } /** diff --git a/live/src/main/java/com/yunbao/live/dialog/SidebarLiveAudience.java b/live/src/main/java/com/yunbao/live/dialog/SidebarLiveAudience.java index 3cddb178c..bd87ea77c 100644 --- a/live/src/main/java/com/yunbao/live/dialog/SidebarLiveAudience.java +++ b/live/src/main/java/com/yunbao/live/dialog/SidebarLiveAudience.java @@ -1,6 +1,8 @@ package com.yunbao.live.dialog; +import android.content.DialogInterface; import android.os.Bundle; +import android.text.TextUtils; import android.view.Display; import android.view.Gravity; import android.view.View; @@ -22,14 +24,20 @@ import com.yunbao.common.dialog.AbsDialogFragment; import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.main.MainNetManager; +import com.yunbao.common.utils.Bus; import com.yunbao.common.utils.DeviceUtils; import com.yunbao.common.utils.RouteUtil; import com.yunbao.live.R; -import com.yunbao.live.activity.LiveAudienceActivity; import com.yunbao.live.adapter.SidebarAdapter; import com.yunbao.live.bean.LiveBean; +import com.yunbao.live.event.LiveAudienceEvent; +import com.yunbao.live.event.LiveRoomChangeEvent; import com.yunbao.live.http.LiveHttpUtil; import com.yunbao.live.presenter.LiveRoomCheckLivePresenter; +import com.yunbao.live.views.LivePlayRyViewHolder; +import com.yunbao.live.views.PortraitLiveManager; + +import org.greenrobot.eventbus.EventBus; import java.util.ArrayList; import java.util.List; @@ -40,6 +48,7 @@ import java.util.List; public class SidebarLiveAudience extends AbsDialogFragment { //侧边栏背景 private ImageView sidebarBack; + private View mask; //侧边栏刷新列表 public CommonRefreshView sidebarList; @@ -48,6 +57,8 @@ public class SidebarLiveAudience extends AbsDialogFragment { private List slideInfoModels = new ArrayList<>(); private List list = new ArrayList<>(); + private int index = 0; + @Override protected int getLayoutId() { return R.layout.view_sidebar_live_audience; @@ -63,14 +74,23 @@ public class SidebarLiveAudience extends AbsDialogFragment { super.onActivityCreated(savedInstanceState); Bundle bundle = getArguments(); sidebarBack = (ImageView) findViewById(R.id.sidebar_back); + mask = findViewById(R.id.mask); if (bundle != null) { String avatar = bundle.getString("Avatar"); + int liveBg = bundle.getInt("LiveBg"); slideInfoModels = GsonUtils.fromJson(bundle.getString("banner"), new TypeToken>() { }.getType()); list = GsonUtils.fromJson(bundle.getString("list"), new TypeToken>() { }.getType()); //侧边栏背景 - ImgLoader.displayBlurLive(mContext, avatar, sidebarBack); + if (liveBg == 1) { + ImgLoader.displayBlurLive(mContext, avatar, sidebarBack); + mask.setVisibility(View.VISIBLE); + } else { + ImgLoader.display(mContext, R.mipmap.live_bg, sidebarBack); + mask.setVisibility(View.GONE); + } + } sidebarList = (CommonRefreshView) findViewById(R.id.sidebarList); @@ -106,39 +126,46 @@ public class SidebarLiveAudience extends AbsDialogFragment { @Override public void refresh() { - //推荐位 - MainNetManager.get(getActivity()) - .anchorRecommend("10", new com.yunbao.common.http.base.HttpCallback() { - @Override - public void onSuccess(AnchorRecommendModel anchorRecommendModel) { - //侧边栏 - MainNetManager.get(getActivity()) - .getHot(1, new com.yunbao.common.http.base.HttpCallback>() { - @Override - public void onSuccess(List data) { - List list = anchorRecommendModel.getList(); - list.add(0, new AnchorRecommendItemModel()); - sidebarAdapter.addData(list); - sidebarList.onFinish(); - sidebarAdapter.setData(data); - } + if (index > 0) { + //推荐位 + MainNetManager.get(getActivity()) + .anchorRecommend("12", new com.yunbao.common.http.base.HttpCallback() { + @Override + public void onSuccess(AnchorRecommendModel anchorRecommendModel) { + List list = anchorRecommendModel.getList(); + int userIndex = -1; + for (int i = 0; i < list.size(); i++) { + if (TextUtils.equals(list.get(i).getUid(), PortraitLiveManager.liveID)) { + userIndex = i; + } + } + if (userIndex != -1) { + list.remove(userIndex); + } - @Override - public void onError(String error) { + list.add(0, new AnchorRecommendItemModel()); - } - }); + sidebarAdapter.addData(list); + sidebarAdapter.setData(anchorRecommendModel.getSlide()); + sidebarList.onFinish(); + } - } + @Override + public void onError(String error) { + } + }); + } else { + index = index + 1; + } - @Override - public void onError(String error) { - } - }); } }); sidebarList.initData(); - sidebarAdapter.setOnItemClickListener((bean, position) -> gotoLive(bean.getUid())); + sidebarAdapter.setOnItemClickListener((bean, position) -> { + + gotoLive(bean.getUid()); + dismiss(); + }); } @Override @@ -176,16 +203,35 @@ public class SidebarLiveAudience extends AbsDialogFragment { if (liveBean1 == null) { return; } - LiveAudienceActivity.forward(getActivity(), liveBean1, liveType, liveTypeVal, "", 0, liveSdk); - (getActivity()).finish(); + if (LivePlayRyViewHolder.Micing == 1) { + Bus.get().post(new LiveAudienceEvent() + .setType(LiveAudienceEvent.LiveAudienceType.LIAN_MAI) + .setMicIng(1) + .setBean(liveBean).setLiveType(liveType).setLiveTypeVal(liveTypeVal)); + } else if (LivePlayRyViewHolder.Micing == 2) { + Bus.get().post(new LiveAudienceEvent() + .setType(LiveAudienceEvent.LiveAudienceType.LIAN_MAI) + .setMicIng(2) + .setBean(liveBean).setLiveType(liveType).setLiveTypeVal(liveTypeVal)); + } else { + EventBus.getDefault().post(new LiveRoomChangeEvent(liveBean, liveType, liveTypeVal)); + } + }); mCheckLivePresenter.checkLive(liveBean); } else { RouteUtil.forwardUserHome(getActivity(), liveId, 0); - getActivity().finish(); } } }); } + + @Override + public void onDismiss(DialogInterface dialog) { + super.onDismiss(dialog); + Bus.get().post(new LiveAudienceEvent() + .setType(LiveAudienceEvent.LiveAudienceType.REFRESH_THE_LIVEl_PAGE) + ); + } } diff --git a/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java b/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java index c73e74afc..0626a282d 100644 --- a/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java +++ b/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java @@ -1,7 +1,9 @@ package com.yunbao.live.event; import com.yunbao.common.bean.ActiveModel; +import com.yunbao.common.bean.AnchorRecommendItemModel; import com.yunbao.common.bean.BaseModel; +import com.yunbao.live.bean.LiveBean; import com.yunbao.live.bean.OpenParametersModel; public class LiveAudienceEvent extends BaseModel { @@ -9,6 +11,56 @@ public class LiveAudienceEvent extends BaseModel { private ActiveModel model = new ActiveModel(); private String avatar = ""; private OpenParametersModel parametersModel = new OpenParametersModel(); + private AnchorRecommendItemModel anchorRecommendItemModel = new AnchorRecommendItemModel(); + private int micIng = 0;//连麦状态 + private LiveBean bean; + private int liveType; + private int liveTypeVal; + + public int getLiveType() { + return liveType; + } + + public LiveAudienceEvent setLiveType(int liveType) { + this.liveType = liveType; + return this; + } + + public int getLiveTypeVal() { + return liveTypeVal; + } + + public LiveAudienceEvent setLiveTypeVal(int liveTypeVal) { + this.liveTypeVal = liveTypeVal; + return this; + } + + public LiveBean getBean() { + return bean; + } + + public LiveAudienceEvent setBean(LiveBean bean) { + this.bean = bean; + return this; + } + + public int getMicIng() { + return micIng; + } + + public LiveAudienceEvent setMicIng(int micIng) { + this.micIng = micIng; + return this; + } + + public AnchorRecommendItemModel getAnchorRecommendItemModel() { + return anchorRecommendItemModel; + } + + public LiveAudienceEvent setAnchorRecommendItemModel(AnchorRecommendItemModel anchorRecommendItemModel) { + this.anchorRecommendItemModel = anchorRecommendItemModel; + return this; + } public OpenParametersModel getParametersModel() { return parametersModel; @@ -59,7 +111,9 @@ public class LiveAudienceEvent extends BaseModel { EFFECTS_SETTINGS(10, "特效設置"), WISH_LIST(11, "心愿单"), OPEN_PARAMETERS(12, "开放参数"), - ACTIVITY_CENTER(13, "活動中心"); + ACTIVITY_CENTER(13, "活動中心"), + LIVE_ROOM_EXCEPTION(14, "直播间异常"), + REFRESH_THE_LIVEl_PAGE(15, "刷新直播页面"); private int type; private String name; diff --git a/live/src/main/java/com/yunbao/live/presenter/LiveLinkMicPresenter.java b/live/src/main/java/com/yunbao/live/presenter/LiveLinkMicPresenter.java index 87846ad27..d8d428d34 100644 --- a/live/src/main/java/com/yunbao/live/presenter/LiveLinkMicPresenter.java +++ b/live/src/main/java/com/yunbao/live/presenter/LiveLinkMicPresenter.java @@ -3,7 +3,6 @@ package com.yunbao.live.presenter; import android.Manifest; import android.app.Dialog; import android.content.Context; -import android.content.Intent; import android.graphics.Outline; import android.graphics.drawable.ColorDrawable; import android.os.Bundle; @@ -17,7 +16,6 @@ import android.view.View; import android.view.ViewGroup; import android.view.ViewOutlineProvider; import android.widget.ImageView; -import android.widget.LinearLayout; import android.widget.PopupWindow; import android.widget.TextView; import android.widget.Toast; @@ -55,9 +53,6 @@ import com.yunbao.live.R; import com.yunbao.live.activity.LiveActivity; import com.yunbao.live.activity.LiveAnchorActivity; import com.yunbao.live.activity.LiveAudienceActivity; -import com.yunbao.live.activity.ZhuangBanActivity; -import com.yunbao.live.bean.LiveWishlistBean; -import com.yunbao.live.dialog.LiveHDDialogFragment; import com.yunbao.live.dialog.LiveOneDialogFragment; import com.yunbao.live.dialog.LiveTurnTableDialogFragment4Audience; import com.yunbao.live.dialog.LiveWishListDialogFragment4Audience; @@ -72,7 +67,6 @@ import com.yunbao.live.socket.SocketLinkMicUtil; import com.yunbao.live.utils.CountDownView; import com.yunbao.live.views.AbsLiveLinkMicPlayViewHolder; import com.yunbao.live.views.AbsLiveLinkMicPushViewHolder; -import com.yunbao.live.views.CustomViewHolder; import com.yunbao.live.views.LiveLinkMicPlayTxViewHolder; import com.yunbao.live.views.LiveLinkMicPushTxViewHolder; @@ -83,8 +77,6 @@ import org.greenrobot.eventbus.ThreadMode; import java.util.ArrayList; import java.util.List; -import static com.blankj.utilcode.util.ActivityUtils.startActivity; - /** * Created by cxf on 2018/10/25. * 观众和主播连麦的逻辑 @@ -118,21 +110,21 @@ public class LiveLinkMicPresenter implements View.OnClickListener { private int mLiveSdk; private View btnWishList; private View btnTurnTable; - private View btnEvent; + private View btnEvent3; private View btn_onecz_event; - private ImageView imgEvent; + private String eventUrl; - private Banner mBanner1; - public static Banner mBanner2, mBanner3; + // + public Banner mBanner3; private List mBannerList1 = new ArrayList<>(); private List mBannerList3 = new ArrayList<>(); - public static List mBannerList2 = new ArrayList<>(); + public static CountDownView date; public static String link = ""; - LinearLayout btn_event2; + // public static LiveGiftBean bean1 = new LiveGiftBean(); String gold, experience; @@ -151,7 +143,7 @@ public class LiveLinkMicPresenter implements View.OnClickListener { } } } - } else if ("stop_svga_new_user_follow".equals(str)&& mBannerList3.size() > 1) { + } else if ("stop_svga_new_user_follow".equals(str) && mBannerList3.size() > 1) { mBannerList3.get(1).setLink("1"); mBanner3.update(mBannerList3); @@ -162,7 +154,7 @@ public class LiveLinkMicPresenter implements View.OnClickListener { } } } - } else if ("stop_new_user_gif".equals(str)&& mBannerList3.size() > 0) { + } else if ("stop_new_user_gif".equals(str) && mBannerList3.size() > 0) { IMLoginManager.get(mContext).setNewUserGif(false); mBannerList3.get(0).setLink("1"); mBanner3.update(mBannerList3); @@ -298,26 +290,13 @@ public class LiveLinkMicPresenter implements View.OnClickListener { btnLinkMic.setOnClickListener(this); btnWishList.setOnClickListener(this); btnTurnTable.setOnClickListener(this); - btnEvent = root.findViewById(R.id.btn_event); + btnEvent3 = root.findViewById(R.id.btn_event3); - mBanner1 = (Banner) root.findViewById(R.id.banner1); - mBanner2 = (Banner) root.findViewById(R.id.banner2); + + mBanner3 = (Banner) root.findViewById(R.id.banner3); - btn_event2 = root.findViewById(R.id.btn_event2); - mBanner1.setOutlineProvider(new ViewOutlineProvider() { - @Override - public void getOutline(View view, Outline outline) { - outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), 10); - } - }); - mBanner2.setOutlineProvider(new ViewOutlineProvider() { - @Override - public void getOutline(View view, Outline outline) { - outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), 10); - } - }); mBanner3.setOutlineProvider(new ViewOutlineProvider() { @Override public void getOutline(View view, Outline outline) { @@ -397,8 +376,7 @@ public class LiveLinkMicPresenter implements View.OnClickListener { fragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveOneDialogFragment"); } }); - imgEvent = root.findViewById(R.id.img_event); - btnEvent.setOnClickListener(this); + mLinkMicTip = btnLinkMic.findViewById(R.id.link_mic_tip); } mLinkMicWaitString = WordUtil.getString(R.string.link_mic_wait); @@ -420,12 +398,7 @@ public class LiveLinkMicPresenter implements View.OnClickListener { } } }; - mHandler.postDelayed(new Runnable() { - @Override - public void run() { - loadWishlistData(); - } - }, 500); + String turntableEnable = CommonAppConfig.getInstance().getTurnTableEnable(); getEvent(); @@ -444,35 +417,6 @@ public class LiveLinkMicPresenter implements View.OnClickListener { mSocketClient = socketClient; } - public void setLiveUid(String liveUid) { - mLiveUid = liveUid; - LiveHttpUtil.geteEvent(mLiveUid, new HttpCallback() { - @Override - public void onSuccess(int code, String msg, String[] info) { - if (code == 0 && imgEvent != null) { - for (int i = 0; i < info.length; i++) { - JSONObject obj = JSONObject.parseObject(info[i]); - if (obj.getString("is_hidden").equals("0")) { - BannerBean bannerBean = new BannerBean(); - bannerBean.setImageUrl(obj.getString("img")); - bannerBean.setLink(obj.getString("link")); - bannerBean.setShow_type(obj.getString("show_type")); - mBannerList2.add(bannerBean); - } - } - if (mBannerList2.size() <= 0) { - btn_event2.setVisibility(View.GONE); - } - showBanner2(); - } else { - if (btn_event2 != null) { - btn_event2.setVisibility(View.GONE); - } - } - } - }); - } - /** * 主播收到观众申请连麦的回调 @@ -764,11 +708,7 @@ public class LiveLinkMicPresenter implements View.OnClickListener { anchorCloseLinkMic(); } - //打开活动窗口 - else if (i == R.id.btn_event) { - Log.i("tag", eventUrl); - startActivity(new Intent(mContext, ZhuangBanActivity.class).putExtra("url", eventUrl)); - } + } @@ -799,43 +739,6 @@ public class LiveLinkMicPresenter implements View.OnClickListener { } - //获取心愿单列表 - private void loadWishlistData() { - LiveHttpUtil.getWishList(mLiveUid, new HttpCallback() { - @Override - public void onSuccess(int code, String msg, String[] info) { - if (code == 0 && info.length > 0) { - try { - JSONObject obj = JSON.parseObject(info[0]); - String giftJson = obj.getString("wishlist"); - List mWishlist = JSON.parseArray(giftJson, LiveWishlistBean.class); - if (btnWishList != null) { - if (mWishlist.size() > 0) { - btnWishList.setVisibility(View.GONE); - //心单 - BannerBean bannerBean2 = new BannerBean(); - bannerBean2.setImageUrl(obj.getString("img")); - bannerBean2.setLink("xyd"); - mBannerList1.add(bannerBean2); - } else { - btnWishList.setVisibility(View.GONE); - } - } - - - showBanner(); - } catch (Exception e) { - e.printStackTrace(); - } - } - } - - @Override - public void onFinish() { - } - }); - } - private void onLinkMicBtnClick() { if (((LiveActivity) mContext).isGamePlaying()) { ToastUtil.show(R.string.live_game_cannot_link_mic); @@ -868,109 +771,6 @@ public class LiveLinkMicPresenter implements View.OnClickListener { }); } - private void showBanner() { - if (mBannerList1 == null || mBannerList1.size() == 0 || mBanner1 == null) { - return; - } - mBanner1.setAutoPlay(true) - .setPages(mBannerList1, new CustomViewHolder()) - .setDelayTime(3000) - .setBannerStyle(BannerConfig.NOT_INDICATOR) - .setOnBannerClickListener(new OnBannerClickListener() { - @Override - public void onBannerClick(List datas, int p) { - if (mBannerList1 != null) { - if (p >= 0 && p < mBannerList1.size()) { - BannerBean bean = mBannerList1.get(p); - if (bean != null) { - String link = bean.getLink(); - if (link.equals("sc")) { - String url; - if (!"".equals(bean.getmIntoUrl()) && bean.getmIntoUrl() != null) { - url = CommonAppConfig.HOST + bean.getmIntoUrl() + "?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken(); - } else { - url = CommonAppConfig.HOST + "/h5/activity/firstTopUp/newUp.html?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken(); - } -// Bundle bundle = new Bundle(); -// bundle.putString("url", url); -// LiveOneDialogFragment fragment = new LiveOneDialogFragment(); -// fragment.setArguments(bundle); -// fragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveOneDialogFragment"); - ZhuangBanActivity.forward(mContext, url, false); - } else if (link.equals("zxb")) { - String url = CommonAppConfig.HOST + "/h5/activity/weekStar/index.html?&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&anchorUid=" + mLiveUid; - ZhuangBanActivity.forward(mContext, url, false); - } else if (link.equals("xyd")) { - openWishListWindow(); - } - } - } - } - } - }) - .start(); - } - - private void showBanner2() { - if (mBannerList2 == null || mBannerList2.size() == 0 || mBanner2 == null) { - return; - } - if (mBannerList2.size() == 1) { - mBanner2.setAutoPlay(false) - .setPages(mBannerList2, new CustomViewHolder()) - .setDelayTime(3000) - .setBannerStyle(BannerConfig.NOT_INDICATOR) - .setOnBannerClickListener(new OnBannerClickListener() { - @Override - public void onBannerClick(List datas, int p) { - if (mBannerList2 != null) { - if (p >= 0 && p < mBannerList2.size()) { - BannerBean bean = mBannerList2.get(p); - if (bean.getShow_type().equals("1")) { - String url = bean.getLink() + "?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&anchorUid=" + mLiveUid + "&t=" + System.currentTimeMillis(); - ZhuangBanActivity.forward(mContext, url, false); - } else { - String url = bean.getLink() + "?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&anchorUid=" + mLiveUid + "&t=" + System.currentTimeMillis(); - Bundle bundle = new Bundle(); - bundle.putString("url", url); - LiveHDDialogFragment fragment = new LiveHDDialogFragment(); - fragment.setArguments(bundle); - fragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment"); - } - } - } - } - }) - .start(); - } else { - mBanner2.setAutoPlay(true) - .setPages(mBannerList2, new CustomViewHolder()) - .setDelayTime(3000) - .setBannerStyle(BannerConfig.NOT_INDICATOR) - .setOnBannerClickListener(new OnBannerClickListener() { - @Override - public void onBannerClick(List datas, int p) { - if (mBannerList2 != null) { - if (p >= 0 && p < mBannerList2.size()) { - BannerBean bean = mBannerList2.get(p); - if (bean.getShow_type().equals("1")) { - String url = bean.getLink() + "?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&anchorUid=" + mLiveUid; - ZhuangBanActivity.forward(mContext, url, false); - } else { - String url = bean.getLink() + "?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&anchorUid=" + mLiveUid; - Bundle bundle = new Bundle(); - bundle.putString("url", url); - LiveHDDialogFragment fragment = new LiveHDDialogFragment(); - fragment.setArguments(bundle); - fragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment"); - } - } - } - } - }) - .start(); - } - } private void showBanner3() { btnEvent3.setVisibility(View.VISIBLE); diff --git a/live/src/main/java/com/yunbao/live/presenter/LiveRoomCheckLivePresenter.java b/live/src/main/java/com/yunbao/live/presenter/LiveRoomCheckLivePresenter.java index 14be245be..5531a0158 100644 --- a/live/src/main/java/com/yunbao/live/presenter/LiveRoomCheckLivePresenter.java +++ b/live/src/main/java/com/yunbao/live/presenter/LiveRoomCheckLivePresenter.java @@ -9,12 +9,14 @@ import com.alibaba.fastjson.JSONObject; import com.yunbao.common.CommonAppConfig; import com.yunbao.common.Constants; import com.yunbao.common.http.HttpCallback; +import com.yunbao.common.utils.Bus; import com.yunbao.common.utils.DialogUitl; import com.yunbao.common.utils.MD5Util; import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.WordUtil; import com.yunbao.live.R; import com.yunbao.live.bean.LiveBean; +import com.yunbao.live.event.LiveAudienceEvent; import com.yunbao.live.http.LiveHttpConsts; import com.yunbao.live.http.LiveHttpUtil; @@ -76,6 +78,8 @@ public class LiveRoomCheckLivePresenter { } } } else { + Bus.get().post(new LiveAudienceEvent() + .setType(LiveAudienceEvent.LiveAudienceType.LIVE_ROOM_EXCEPTION)); ToastUtil.show(msg); } } @@ -119,7 +123,7 @@ public class LiveRoomCheckLivePresenter { } } }); - }else { + } else { enterLiveRoom(); isRoom = false; } diff --git a/live/src/main/java/com/yunbao/live/socket/SocketChatUtil.java b/live/src/main/java/com/yunbao/live/socket/SocketChatUtil.java index ae2c06b6c..c7990935d 100644 --- a/live/src/main/java/com/yunbao/live/socket/SocketChatUtil.java +++ b/live/src/main/java/com/yunbao/live/socket/SocketChatUtil.java @@ -61,7 +61,7 @@ public class SocketChatUtil { @Override public void onError(int code, String desc) { - Log.i("tx", code + "发送失败" + desc); + Log.i("tx", code + "发送失败1" + desc); } }); @@ -114,7 +114,7 @@ public class SocketChatUtil { @Override public void onError(int code, String desc) { - Log.i("tx", code + "发送失败" + desc); + Log.i("tx", code + "发送失败2" + desc); } }); @@ -170,7 +170,7 @@ public class SocketChatUtil { @Override public void onError(int code, String desc) { - Log.i("tx", code + "发送失败" + desc); + Log.i("tx", code + "发送失败3" + desc); } }); @@ -210,7 +210,7 @@ public class SocketChatUtil { @Override public void onError(int code, String desc) { - Log.i("tx", code + "发送失败" + desc); + Log.i("tx", code + "发送失败4" + desc); } }); @@ -339,7 +339,7 @@ public class SocketChatUtil { @Override public void onError(int code, String desc) { - Log.i("tx", code + "发送失败" + desc); + Log.i("tx", code + "发送失败5" + desc); } }); @@ -381,7 +381,7 @@ public class SocketChatUtil { @Override public void onError(int code, String desc) { - Log.i("tx", code + "发送失败" + desc); + Log.i("tx", code + "发送失败6" + desc); } }); @@ -423,7 +423,7 @@ public class SocketChatUtil { @Override public void onError(int code, String desc) { - Log.i("tx", code + "发送失败" + desc); + Log.i("tx", code + "发送失败7" + desc); } }); @@ -456,7 +456,7 @@ public class SocketChatUtil { @Override public void onError(int code, String desc) { - Log.i("tx", code + "发送失败" + desc); + Log.i("tx", code + "发送失败7" + desc); } }); @@ -493,7 +493,7 @@ public class SocketChatUtil { @Override public void onError(int code, String desc) { - Log.i("tx", code + "发送失败" + desc); + Log.i("tx", code + "发送失败9" + desc); } }); @@ -528,7 +528,7 @@ public class SocketChatUtil { @Override public void onError(int code, String desc) { - Log.i("tx", code + "发送失败" + desc); + Log.i("tx", code + "发送失败10" + desc); } }); diff --git a/live/src/main/java/com/yunbao/live/socket/SocketRyChatUtil.java b/live/src/main/java/com/yunbao/live/socket/SocketRyChatUtil.java index 4d98df654..6fa41d05a 100644 --- a/live/src/main/java/com/yunbao/live/socket/SocketRyChatUtil.java +++ b/live/src/main/java/com/yunbao/live/socket/SocketRyChatUtil.java @@ -118,7 +118,7 @@ public class SocketRyChatUtil { @Override public void onSuccess(Message message) { - Log.i("tx", "发送成功" + mLiveUid); + Log.i("tx", "ssss"+"发送成功" + mLiveUid); //首发言成功 AdjustEvent adjustEvent1 = new AdjustEvent("j7isvr"); Adjust.trackEvent(adjustEvent1); @@ -141,7 +141,7 @@ public class SocketRyChatUtil { @Override public void onError(Message message, RongIMClient.ErrorCode errorCode) { - + Log.e("tx","aaa"+errorCode.toString()); } }); @@ -543,7 +543,7 @@ public class SocketRyChatUtil { @Override public void onSuccess(Message message) { Log.i("tx", "发送成功"); -// SocketRyClient.mSocketHandler.processBroadcast(msg.mResult.toString() + ""); + SocketRyClient.mSocketHandler.processBroadcast(msg.mResult.toString() + ""); } @Override diff --git a/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java index 24c2f8dac..3f5a15c81 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java @@ -61,7 +61,6 @@ import org.greenrobot.eventbus.ThreadMode; import java.util.Locale; import io.reactivex.android.schedulers.AndroidSchedulers; -import io.reactivex.functions.Consumer; import io.reactivex.schedulers.Schedulers; /** @@ -377,7 +376,14 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder { NewPeopleInfo peopleInfo = stringResponseModel.getData().getInfo(); if (peopleInfo.getIsShow()) { liveNewPeople.setVisibility(View.VISIBLE); - newPeopleUrl = peopleInfo.getLink(); + if(peopleInfo.getLink().startsWith("http")){ + newPeopleUrl = peopleInfo.getLink(); + if(!newPeopleUrl.contains("?")){ + newPeopleUrl+="?"; + } + }else { + newPeopleUrl = CommonAppConfig.HOST + peopleInfo.getLink(); + } } }, Throwable::printStackTrace).isDisposed(); } @@ -410,7 +416,7 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder { showTrickeryDialog(); }else if (i==R.id.live_new_people){ Bundle bundle=new Bundle(); - String url= newPeopleUrl+"?g=Appapi&m=Turntable&a=tricky"; + String url= newPeopleUrl+"&g=Appapi&m=Turntable&a=tricky"; url += "&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&anchorUid=" + mLiveUid; bundle.putString("url", url); diff --git a/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java b/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java index 0ca597137..50fbf8d0a 100644 --- a/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java @@ -226,6 +226,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { } public static void setViewUP(int i) { + if (mVideoView == null) return; Log.i("收", "整理" + i); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams(); params.height = vHeight; diff --git a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java index cadd636bd..c142ccf31 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -3,6 +3,8 @@ package com.yunbao.live.views; import android.app.Activity; import android.app.Dialog; import android.content.Context; +import android.content.Intent; +import android.graphics.Outline; import android.os.Bundle; import android.os.Handler; import android.os.Message; @@ -12,6 +14,7 @@ import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.view.ViewOutlineProvider; import android.view.WindowManager; import android.widget.FrameLayout; import android.widget.ImageView; @@ -21,6 +24,7 @@ import android.widget.TextView; import android.widget.ViewFlipper; import androidx.annotation.Nullable; +import androidx.recyclerview.widget.DefaultItemAnimator; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; @@ -37,12 +41,16 @@ import com.bumptech.glide.request.RequestListener; import com.bumptech.glide.request.RequestOptions; import com.bumptech.glide.request.target.Target; import com.makeramen.roundedimageview.RoundedImageView; +import com.ms.banner.Banner; +import com.ms.banner.BannerConfig; +import com.ms.banner.listener.OnBannerClickListener; 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.BannerBean; import com.yunbao.common.bean.LevelBean; import com.yunbao.common.bean.UserBean; import com.yunbao.common.glide.ImgLoader; @@ -66,7 +74,9 @@ import com.yunbao.live.activity.LiveActivity; import com.yunbao.live.activity.LiveAnchorActivity; import com.yunbao.live.activity.LiveAudienceActivity; import com.yunbao.live.activity.LiveRyAnchorActivity; +import com.yunbao.live.activity.ZhuangBanActivity; import com.yunbao.live.adapter.LiveChatAdapter; +import com.yunbao.live.adapter.LiveRoomFastMessageRecyclerViewAdapter; import com.yunbao.live.adapter.LiveUserAdapter; import com.yunbao.live.bean.DrPkbean; import com.yunbao.live.bean.LiveBuyGuardMsgBean; @@ -78,6 +88,7 @@ import com.yunbao.live.bean.LiveLuckGiftWinBean; import com.yunbao.live.bean.LivePKUserListBean; import com.yunbao.live.bean.LiveReceiveGiftBean; import com.yunbao.live.bean.LiveUserGiftBean; +import com.yunbao.live.bean.LiveWishlistBean; import com.yunbao.live.bean.WishlistItemModel; import com.yunbao.live.custom.LiveLightView; import com.yunbao.live.custom.RightGradual; @@ -85,6 +96,7 @@ import com.yunbao.live.custom.TopGradual; import com.yunbao.live.dialog.LiveFansMedalDialogFragment; import com.yunbao.live.dialog.LiveHDDialogFragment; import com.yunbao.live.dialog.LiveUserDialogFragment; +import com.yunbao.live.dialog.LiveWishListDialogFragment4Audience; import com.yunbao.live.event.LiveAudienceEvent; import com.yunbao.live.http.LiveHttpConsts; import com.yunbao.live.http.LiveHttpUtil; @@ -92,7 +104,6 @@ import com.yunbao.live.presenter.LiveDanmuPresenter; import com.yunbao.live.presenter.LiveEnterRoomAnimPresenter; import com.yunbao.live.presenter.LiveGiftAnimPresenter; import com.yunbao.live.presenter.LiveLightAnimPresenter; -import com.yunbao.live.socket.SocketChatUtil; import org.greenrobot.eventbus.EventBus; @@ -100,12 +111,12 @@ import java.lang.ref.WeakReference; import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import java.util.Random; import pl.droidsonroids.gif.GifImageView; +import static com.blankj.utilcode.util.ActivityUtils.startActivity; import static com.yunbao.common.CommonAppContext.logger; import static com.yunbao.common.CommonAppContext.mFirebaseAnalytics; @@ -231,13 +242,23 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis public static RelativeLayout lt_pk_line; public WindowManager windowManager; - public boolean isRy = false; + // public boolean isRy = false; + private Banner mBanner1, mBanner2; + private List mBannerList1 = new ArrayList<>(); + private List mBannerList2 = new ArrayList<>(); + private LinearLayout btn_event2; + private ImageView imgEvent; + private View btnEvent; + private RecyclerView fastMsgRecyclerView; + private LiveRoomFastMessageRecyclerViewAdapter fastMessageRecyclerViewAdapter; + + private LiveUserGiftBean nowGuardUser; public LiveRoomViewHolder(boolean isRys, int forActivity, Context context, ViewGroup parentView, GifImageView gifImageView, SVGAImageView svgaImageView, ViewGroup liveGiftPrizePoolContainer, WindowManager windowManager) { super(context, parentView); Contexts = context; this.forAct = forActivity; - this.isRy = isRys; +// this.isRy = isRys; mGifImageView = gifImageView; mSVGAImageView = svgaImageView; mLiveGiftPrizePoolContainer = liveGiftPrizePoolContainer; @@ -245,6 +266,9 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis } + public void clearList() { + mBannerList2.clear(); + } //更新连麦人 public static List mic_ids = new ArrayList<>(); @@ -550,8 +574,12 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis @Override public void init() { - + btnEvent = findViewById(R.id.btn_event); + imgEvent = (ImageView) findViewById(R.id.img_event); + btn_event2 = (LinearLayout) findViewById(R.id.btn_event2); + mBanner1 = (Banner) findViewById(R.id.banner1); time = (TextView) findViewById(R.id.time); + mBanner2 = (Banner) findViewById(R.id.banner2); pkText1 = (TextView) findViewById(R.id.pk_text1); pkText2 = (TextView) findViewById(R.id.pk_text2); pkText3 = (TextView) findViewById(R.id.pk_text3); @@ -811,7 +839,204 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis ViewClicksAntiShake.clicksAntiShake(wishListLayout, () -> Bus.get().post(new LiveAudienceEvent() .setType(LiveAudienceEvent.LiveAudienceType.WISH_LIST))); + mBanner1.setOutlineProvider(new ViewOutlineProvider() { + @Override + public void getOutline(View view, Outline outline) { + outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), 10); + } + }); + mBanner2.setOutlineProvider(new ViewOutlineProvider() { + @Override + public void getOutline(View view, Outline outline) { + outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), 10); + } + }); + loadWishlistData(); + //打开活动窗口 + ViewClicksAntiShake.clicksAntiShake(wishListLayout, () -> startActivity(new Intent(mContext, ZhuangBanActivity.class).putExtra("url", ""))); + //打招呼消息 + fastMsgRecyclerView = (RecyclerView) findViewById(R.id.room_fast_msg); + fastMsgRecyclerView.setLayoutManager(new LinearLayoutManager(mContext,LinearLayoutManager.HORIZONTAL,false)); + fastMessageRecyclerViewAdapter=new LiveRoomFastMessageRecyclerViewAdapter(mContext); + fastMsgRecyclerView.setAdapter(fastMessageRecyclerViewAdapter); + fastMessageRecyclerViewAdapter.setMessageListener(msg -> { + //点击的消息发送出去 + ((LiveActivity) mContext).sendChatMessage(msg); + fastMsgRecyclerView.setVisibility(View.GONE); + }); + // fastMsgRecyclerView.setItemAnimator(new DefaultItemAnimator()); + } + private void showBanner2() { + if (mBannerList2 == null || mBannerList2.size() == 0 || mBanner2 == null) { + return; + } + if (mBannerList2.size() == 1) { + mBanner2.setAutoPlay(false) + .setPages(mBannerList2, new CustomViewHolder()) + .setDelayTime(3000) + .setBannerStyle(BannerConfig.NOT_INDICATOR) + .setOnBannerClickListener(new OnBannerClickListener() { + @Override + public void onBannerClick(List datas, int p) { + if (mBannerList2 != null) { + if (p >= 0 && p < mBannerList2.size()) { + BannerBean bean = mBannerList2.get(p); + if (bean.getShow_type().equals("1")) { + String url = bean.getLink() + "?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&anchorUid=" + mLiveUid + "&t=" + System.currentTimeMillis(); + ZhuangBanActivity.forward(mContext, url, false); + } else { + String url = bean.getLink() + "?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&anchorUid=" + mLiveUid + "&t=" + System.currentTimeMillis(); + Bundle bundle = new Bundle(); + bundle.putString("url", url); + LiveHDDialogFragment fragment = new LiveHDDialogFragment(); + fragment.setArguments(bundle); + fragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment"); + } + } + } + } + }) + .start(); + } else { + mBanner2.setAutoPlay(true) + .setPages(mBannerList2, new CustomViewHolder()) + .setDelayTime(3000) + .setBannerStyle(BannerConfig.NOT_INDICATOR) + .setOnBannerClickListener(new OnBannerClickListener() { + @Override + public void onBannerClick(List datas, int p) { + if (mBannerList2 != null) { + if (p >= 0 && p < mBannerList2.size()) { + BannerBean bean = mBannerList2.get(p); + if (bean.getShow_type().equals("1")) { + String url = bean.getLink() + "?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&anchorUid=" + mLiveUid; + ZhuangBanActivity.forward(mContext, url, false); + } else { + String url = bean.getLink() + "?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&anchorUid=" + mLiveUid; + Bundle bundle = new Bundle(); + bundle.putString("url", url); + LiveHDDialogFragment fragment = new LiveHDDialogFragment(); + fragment.setArguments(bundle); + fragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment"); + } + } + } + } + }) + .start(); + } + } + + public void setLiveUid(String liveUid) { + mLiveUid = liveUid; + LiveHttpUtil.geteEvent(mLiveUid, new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + if (code == 0 && imgEvent != null) { + for (int i = 0; i < info.length; i++) { + JSONObject obj = JSONObject.parseObject(info[i]); + if (obj.getString("is_hidden").equals("0")) { + BannerBean bannerBean = new BannerBean(); + bannerBean.setImageUrl(obj.getString("img")); + bannerBean.setLink(obj.getString("link")); + bannerBean.setShow_type(obj.getString("show_type")); + mBannerList2.add(bannerBean); + } + } + if (mBannerList2.size() <= 0) { + btn_event2.setVisibility(View.GONE); + } + showBanner2(); + } else { + if (btn_event2 != null) { + btn_event2.setVisibility(View.GONE); + } + } + } + }); + } + + //获取心愿单列表 + private void loadWishlistData() { + LiveHttpUtil.getWishList(mLiveUid, new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + if (code == 0 && info.length > 0) { + try { + JSONObject obj = JSON.parseObject(info[0]); + String giftJson = obj.getString("wishlist"); + List mWishlist = JSON.parseArray(giftJson, LiveWishlistBean.class); + if (mWishlist.size() > 0) { + //心单 + BannerBean bannerBean2 = new BannerBean(); + bannerBean2.setImageUrl(obj.getString("img")); + bannerBean2.setLink("xyd"); + mBannerList1.add(bannerBean2); + } + + showBanner(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + @Override + public void onFinish() { + } + }); + } + + private void showBanner() { + if (mBannerList1 == null || mBannerList1.size() == 0 || mBanner1 == null) { + return; + } + mBanner1.setAutoPlay(true) + .setPages(mBannerList1, new CustomViewHolder()) + .setDelayTime(3000) + .setBannerStyle(BannerConfig.NOT_INDICATOR) + .setOnBannerClickListener(new OnBannerClickListener() { + @Override + public void onBannerClick(List datas, int p) { + if (mBannerList1 != null) { + if (p >= 0 && p < mBannerList1.size()) { + BannerBean bean = mBannerList1.get(p); + if (bean != null) { + String link = bean.getLink(); + if (link.equals("sc")) { + String url; + if (!"".equals(bean.getmIntoUrl()) && bean.getmIntoUrl() != null) { + url = CommonAppConfig.HOST + bean.getmIntoUrl() + "?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken(); + } else { + url = CommonAppConfig.HOST + "/h5/activity/firstTopUp/newUp.html?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken(); + } + ZhuangBanActivity.forward(mContext, url, false); + } else if (link.equals("zxb")) { + String url = CommonAppConfig.HOST + "/h5/activity/weekStar/index.html?&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&anchorUid=" + mLiveUid; + ZhuangBanActivity.forward(mContext, url, false); + } else if (link.equals("xyd")) { + openWishListWindow(); + } + } + } + } + } + }) + .start(); + } + + /** + * 观众打开主播的心愿单窗口 + */ + public void openWishListWindow() { + LiveWishListDialogFragment4Audience fragment = new LiveWishListDialogFragment4Audience(); + Bundle bundle = new Bundle(); + bundle.putString(Constants.LIVE_UID, mLiveUid); + fragment.setArguments(bundle); + if (mContext instanceof LiveAudienceActivity) { + fragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveWishListDialogFragmentAudience"); + } } /** @@ -1128,7 +1353,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis */ public void setUserList(List list) { if (mLiveUserAdapter != null) { - resetUserListWidth(DpUtil.dp2px((Math.min(list.size(), 3))*38)); + resetUserListWidth(DpUtil.dp2px((Math.min(list.size(), 3)) * 38)); mLiveUserAdapter.refreshList(list); } } @@ -1196,20 +1421,23 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis getIsHot(); getGuardInfo(); } - private void getGuardInfo(){ + + private void getGuardInfo() { LiveHttpUtil.getUserList(mLiveUid, mStream, "guard", 1, new HttpCallback() { @Override public void onSuccess(int code, String msg, String[] info) { - JSONObject json=JSONObject.parseObject(info[0]); + JSONObject json = JSONObject.parseObject(info[0]); JSONArray userlist = json.getJSONArray("userlist"); - if(userlist.size()!=0){ - setGuardIcon(JSONArray.parseArray(userlist.toJSONString(),LiveUserGiftBean.class).get(0)); + if (userlist.size() != 0) { + setGuardIcon(JSONArray.parseArray(userlist.toJSONString(), LiveUserGiftBean.class).get(0)); } } }); } - private void setGuardIcon(LiveUserGiftBean guard){ - if (guard!=null){ + + private void setGuardIcon(LiveUserGiftBean guard) { + if (guard != null) { + nowGuardUser=guard; ImgLoader.displayAvatar(mContext, guard.getAvatar(), userGuard); gift_svga.setVisibility(View.VISIBLE); } @@ -1276,9 +1504,9 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis } else if (i == R.id.btn_prize_pool_level) { ((LiveActivity) mContext).openPrizePoolWindow(); } else if (i == R.id.user_more) { - ((LiveActivity) mContext).openUserMoreListWindow(4,false); + ((LiveActivity) mContext).openUserMoreListWindow(4, false); } else if (i == R.id.hot_btn) { - ((LiveActivity) mContext).openUserMoreListWindow(1,false); + ((LiveActivity) mContext).openUserMoreListWindow(1, false); } else if (i == R.id.btn_close) { close(); @@ -1287,8 +1515,9 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis ((LiveActivity) mContext).openLuckGiftTip(); } else if (i == R.id.ft_hot_add) { ((LiveActivity) mContext).openHotListWindow(1); - } else if (i == R.id.user_guard){ - ((LiveActivity) mContext).openUserMoreListWindow(2,true); + } else if (i == R.id.user_guard) { + // ((LiveActivity) mContext).openUserMoreListWindow(2, true); + ((LiveActivity) mContext).openGuardListWindow(); } } @@ -1322,7 +1551,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis logger.logEvent("FB_Follow", null); AdjustEvent adjustEvent1 = new AdjustEvent("oess6a"); Adjust.trackEvent(adjustEvent1); - SocketChatUtil.sendSystemMessage(mLiveUid, CommonAppConfig.getInstance().getUserBean().getUserNiceName() + WordUtil.getString(R.string.live_follow_anchor)); +// SocketChatUtil.sendSystemMessage(mLiveUid, CommonAppConfig.getInstance().getUserBean().getUserNiceName() + WordUtil.getString(R.string.live_follow_anchor)); LiveActivity.sendSystemMessage( CommonAppConfig.getInstance().getUserBean().getUserNiceName() + WordUtil.getString(R.string.live_follow_anchor)); } @@ -1367,7 +1596,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis * 退出直播间 */ private void close() { - if (isRy == false) { + if (mContext instanceof LiveAudienceActivity) { if (forAct == 1) { //是否关注0==没关注 if (isAttention == 0) { @@ -1385,7 +1614,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis ((LiveAudienceActivity) mContext).setBackIndex(1); ((LiveAnchorActivity) mContext).onBackPressed(); } - } else { + } else if (mContext instanceof LiveRyAnchorActivity) { if (forAct == 1) { //是否关注0==没关注 if (isAttention == 0) { @@ -1404,6 +1633,43 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis ((LiveRyAnchorActivity) mContext).onBackPressed(); } } +// if (isRy == false) { +// if (forAct == 1) { +// //是否关注0==没关注 +// if (isAttention == 0) { +// if (isStayRoomfive) { +// showFollowDialog(mNameText, mAvatarUrl, mContext); +// } else { +// ((LiveAudienceActivity) mContext).setBackIndex(1); +// ((LiveAudienceActivity) mContext).onBackPressed(); +// } +// } else { +// ((LiveAudienceActivity) mContext).setBackIndex(1); +// ((LiveAudienceActivity) mContext).onBackPressed(); +// } +// } else { +// ((LiveAudienceActivity) mContext).setBackIndex(1); +// ((LiveAnchorActivity) mContext).onBackPressed(); +// } +// } else { +// if (forAct == 1) { +// //是否关注0==没关注 +// if (isAttention == 0) { +// if (isStayRoomfive) { +// showFollowDialog(mNameText, mAvatarUrl, mContext); +// } else { +// LiveRyAnchorActivity.backIndex = 1; +// ((LiveRyAnchorActivity) mContext).onBackPressed(); +// } +// } else { +// LiveRyAnchorActivity.backIndex = 1; +// ((LiveRyAnchorActivity) mContext).onBackPressed(); +// } +// } else { +// LiveRyAnchorActivity.backIndex = 1; +// ((LiveRyAnchorActivity) mContext).onBackPressed(); +// } +// } } /** @@ -1422,7 +1688,6 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis public void refreshUserList(JSONObject obj) { List list = JSON.parseArray(obj.getString("userlist"), LiveUserGiftBean.class); mLiveUserAdapter.refreshList(list); - getGuardInfo(); } /** @@ -1531,6 +1796,24 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis mLiveEnterRoomAnimPresenter.enterRoom(bean); } room_hot.setText(formatBigNum.formatBigNum(bean.getLiveChatBean().getHot_num())); + LiveUserGiftBean chatBean = bean.getUserBean(); + if(chatBean!=null&&nowGuardUser!=null) { + LiveUserGiftBean tmp = null; + if (chatBean.getGuardType() != 0 && chatBean.getGuardType() > nowGuardUser.getGuardType()) { + tmp = chatBean; + } else if (chatBean.getGuardType() != 0 && chatBean.getGuardType() == nowGuardUser.getGuardType() && chatBean.getLevel() > nowGuardUser.getLevel()) { + tmp = chatBean; + } + setGuardIcon(tmp); + } + } + + /** + * 用户离开房间 + * @param bean 用户 + */ + public void onExitRoom(UserBean bean){ + // getGuardInfo(); } /** @@ -1844,9 +2127,10 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis } }); } - public void resetUserListWidth(int width){ + + public void resetUserListWidth(int width) { ViewGroup.LayoutParams params = mUserRecyclerView.getLayoutParams(); - params.width=width; + params.width = width; mUserRecyclerView.setLayoutParams(params); } @@ -1919,6 +2203,10 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis mLiveRoomHandler.removeCallbacksAndMessages(null); } + public void setFastMessage(List greetings) { + fastMessageRecyclerViewAdapter.setMessage(greetings); + } + private static class LiveRoomHandler extends Handler { private LiveRoomViewHolder mLiveRoomViewHolder; diff --git a/live/src/main/java/com/yunbao/live/views/LoadingView.java b/live/src/main/java/com/yunbao/live/views/LoadingView.java index 6f8d7209c..6cfbf8cd1 100644 --- a/live/src/main/java/com/yunbao/live/views/LoadingView.java +++ b/live/src/main/java/com/yunbao/live/views/LoadingView.java @@ -36,7 +36,7 @@ public class LoadingView extends FrameLayout { private void init(Context context) { this.mContext = context; - View view = LayoutInflater.from(mContext).inflate(R.layout.layout_portrait_live_item, this, true); + View view = LayoutInflater.from(mContext).inflate(R.layout.layout_portrait_comm_item, this, true); mIvLoading = view.findViewById(R.id.iv_loading); } @@ -46,7 +46,6 @@ public class LoadingView extends FrameLayout { ImageView ivLoading = mIvLoading.findViewById(R.id.iv_loading); AnimationDrawable frameAnimation = (AnimationDrawable) ivLoading.getBackground(); frameAnimation.start(); - setVisibility(VISIBLE); } diff --git a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java index 107cbfe37..73988ca0a 100644 --- a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java +++ b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java @@ -5,6 +5,8 @@ import android.app.Dialog; import android.content.Intent; import android.content.res.Configuration; import android.os.CountDownTimer; +import android.os.Handler; +import android.os.Looper; import android.text.TextUtils; import android.util.Log; import android.view.LayoutInflater; @@ -20,6 +22,7 @@ import androidx.viewpager.widget.PagerAdapter; import com.adjust.sdk.Adjust; import com.adjust.sdk.AdjustEvent; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.blankj.utilcode.util.GsonUtils; import com.tencent.imsdk.v2.V2TIMCallback; @@ -29,14 +32,15 @@ import com.yunbao.common.CommonAppContext; import com.yunbao.common.Constants; import com.yunbao.common.bean.UserBean; import com.yunbao.common.custom.MyViewPager; +import com.yunbao.common.event.FollowEvent; import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.http.CommonHttpConsts; import com.yunbao.common.http.CommonHttpUtil; import com.yunbao.common.http.HttpCallback; +import com.yunbao.common.http.HttpClient; import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.utils.Bus; import com.yunbao.common.utils.DialogUitl; -import com.yunbao.common.utils.DpUtil; import com.yunbao.common.utils.RandomUtil; import com.yunbao.common.utils.RouteUtil; import com.yunbao.common.utils.ToastUtil; @@ -62,30 +66,39 @@ import com.yunbao.live.dialog.BlowkissDialog; import com.yunbao.live.dialog.NewUserDialog; import com.yunbao.live.event.LinkMicTxAccEvent; import com.yunbao.live.event.LiveAudienceEvent; +import com.yunbao.live.event.LiveRoomChangeEvent; import com.yunbao.live.http.LiveHttpConsts; import com.yunbao.live.http.LiveHttpUtil; import com.yunbao.live.presenter.LiveLinkMicAnchorPresenter; -import com.yunbao.live.presenter.LiveLinkMicPkPresenter; import com.yunbao.live.presenter.LiveLinkMicPresenter; import com.yunbao.live.presenter.LiveRyLinkMicPkPresenter; -import com.yunbao.live.socket.SocketChatUtil; import com.yunbao.live.socket.SocketClient; import com.yunbao.live.socket.SocketMessageListener; import com.yunbao.live.socket.SocketRyChatUtil; import com.yunbao.live.socket.SocketRyClient; +import com.yunbao.live.socket.SocketSendBean; +import com.yunbao.live.utils.LiveImDeletUtil; import org.greenrobot.eventbus.EventBus; +import java.util.ArrayList; import java.util.List; +import cn.rongcloud.rtc.api.RCRTCEngine; +import cn.rongcloud.rtc.api.callback.IRCRTCResultCallback; +import cn.rongcloud.rtc.api.callback.IRCRTCSwitchRoleCallback; +import cn.rongcloud.rtc.base.RTCErrorCode; +import io.rong.imlib.IRongCallback; import io.rong.imlib.IRongCoreCallback; import io.rong.imlib.IRongCoreEnum; +import io.rong.imlib.RongIMClient; import io.rong.imlib.chatroom.base.RongChatRoomClient; +import io.rong.imlib.model.Conversation; +import io.rong.message.TextMessage; import static com.yunbao.common.CommonAppContext.logger; import static com.yunbao.common.CommonAppContext.mFirebaseAnalytics; -import static com.yunbao.live.presenter.LiveLinkMicPresenter.mBannerList2; -import static com.yunbao.live.views.LivePlayKsyViewHolder.setViewUP; +import static com.yunbao.live.views.LivePlayRyViewHolder.Micing; import static com.yunbao.live.views.LiveRoomViewHolder.isStayRoomfive; /** @@ -108,7 +121,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe //直播间背景 private ImageView liveBack; - + private View mask; //侧滑布局 // private DrawerLayout drawerLayout; //直播间拆分布局 @@ -125,8 +138,6 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe //主播与主播连麦逻辑 private LiveLinkMicAnchorPresenter mLiveLinkMicAnchorPresenter; //主播与主播PK逻辑 - private LiveLinkMicPkPresenter mLiveLinkMicPkPresenter; - //主播与主播PK逻辑 private LiveRyLinkMicPkPresenter mLiveRyLinkMicPkPresenter; //直播间的类型 普通 密码 门票 计时等 private int mLiveType; @@ -151,10 +162,14 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe private boolean mLighted; private boolean mCoinNotEnough;//余额不足 private boolean mFirstConnectSocket;//是否是第一次连接成功socket + private int liveBg; + private LiveImDeletUtil liveImDeletUtil; + private List greetings = new ArrayList<>(); public PortraitLiveManager(Activity context, Intent intent) { this.mContext = context; this.mIntent = intent; + liveImDeletUtil = new LiveImDeletUtil(); ininView(); } @@ -186,6 +201,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe //直播页面背景 liveBack = mRootContainer.findViewById(R.id.live_back); + mask = mRootContainer.findViewById(R.id.mask); } @@ -202,11 +218,8 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe .setParametersModel(new OpenParametersModel() .setmLiveType(mLiveType) .setmLiveTypeVal(mLiveTypeVal))); - if (mIntent.getIntExtra("isry", 0) == 1) { - mLivePlayViewHolder = new LivePlayRyViewHolder(mContext, playContainer, mIntent.getIntExtra("landscape", 0)); - } else { - mLivePlayViewHolder = new LivePlayKsyViewHolder(mContext, playContainer, mIntent.getIntExtra("landscape", 0)); - } + + mLivePlayViewHolder = new LivePlayRyViewHolder(mContext, playContainer, mIntent.getIntExtra("landscape", 0)); mLivePlayViewHolder.addToParent(); mLivePlayViewHolder.subscribeActivityLifeCycle(); mLiveRoomViewHolder = new LiveRoomViewHolder(false, 1, mContext, mContainer, mSecondPage.findViewById(R.id.gift_gif), mSecondPage.findViewById(R.id.gift_svga), mContainerWrap, mContext.getWindowManager()); @@ -218,15 +231,13 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe mLiveAudienceViewHolder.subscribeActivityLifeCycle(); mLiveLinkMicPresenter = new LiveLinkMicPresenter(mContext, mLivePlayViewHolder, false, mLiveSDK, mLiveAudienceViewHolder.getContentView()); mLiveLinkMicAnchorPresenter = new LiveLinkMicAnchorPresenter(mContext, mLivePlayViewHolder, false, mLiveSDK, null); - if (!(mIntent.getIntExtra("isry", 0) == 1)) { - mLiveLinkMicPkPresenter = new LiveLinkMicPkPresenter(mContext, mLivePlayViewHolder, false, null); - } else { - mLiveRyLinkMicPkPresenter = new LiveRyLinkMicPkPresenter(mContext, mLivePlayViewHolder, false, null); - } + + mLiveRyLinkMicPkPresenter = new LiveRyLinkMicPkPresenter(mContext, mLivePlayViewHolder, false, null); + //直播间背景 - ImgLoader.displayBlurLive(mContext, mLiveBean.getAvatar(), liveBack); - + ImgLoader.display(mContext, R.mipmap.live_bg, liveBack); + mask.setVisibility(View.GONE); mLivePlayViewHolder.setCover(data.getThumb()); mLivePlayViewHolder.play(data.getPull()); mLiveRoomViewHolder.setAvatar(data.getAvatar()); @@ -234,12 +245,10 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe mLiveRoomViewHolder.setName(data.getUserNiceName()); mLiveRoomViewHolder.setRoomNum(data.getLiangNameTip()); mLiveRoomViewHolder.setTitle(data.getTitle()); - if (!(mIntent.getIntExtra("isry", 0) == 1)) { - mLiveLinkMicPkPresenter.setLiveUid(data.getUid(), ""); - } else { - mLiveRyLinkMicPkPresenter.setLiveUid(data.getUid(), ""); - } - mLiveLinkMicPresenter.setLiveUid(data.getUid()); + + mLiveRyLinkMicPkPresenter.setLiveUid(data.getUid(), ""); + + mLiveRoomViewHolder.setLiveUid(data.getUid()); //心愿单 LiveHttpUtil.getWishList(mLiveBean.getUid(), new HttpCallback() { @Override @@ -263,19 +272,19 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe @Override public void onRemove() { - mLiveAudienceViewHolder.removeCallbacks(); - //断开socket - if (!(mIntent.getIntExtra("isry", 0) == 1)) { - if (mSocketClient != null) { - mSocketClient.disConnect(); - } - mSocketClient = null; - } else { - if (mSocketRyClient != null) { - mSocketRyClient.disConnect(); - } - mSocketRyClient = null; + if (mLiveAudienceViewHolder != null) { + mLiveAudienceViewHolder.removeFromParent(); + mLiveAudienceViewHolder.countDownTimerTrickery = null; + mLiveAudienceViewHolder.removeCallbacks(); } + mLiveAudienceViewHolder = null; + //断开socket + + if (mSocketRyClient != null) { + mSocketRyClient.disConnect(); + } + mSocketRyClient = null; + //结束播放 if (mLivePlayViewHolder != null) { @@ -314,17 +323,10 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe if (mLiveLinkMicAnchorPresenter != null) { mLiveLinkMicAnchorPresenter.clearData(); } - if (mLiveLinkMicPkPresenter != null) { - mLiveLinkMicPkPresenter.clearData(); - } if (mLiveRyLinkMicPkPresenter != null) { mLiveRyLinkMicPkPresenter.clearData(); } - if (mLiveAudienceViewHolder != null) { - mLiveAudienceViewHolder.removeFromParent(); - mLiveAudienceViewHolder.countDownTimerTrickery = null; - mLiveAudienceViewHolder = null; - } + } @Override @@ -377,9 +379,146 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe } + /** + * 申请连麦但是主播还未同意的状态 + */ + public void micIngTypeOne(LiveBean bean, int liveType, int liveTypeVal) { + DialogUitl.showSimpleDialog(mContext, null, "您已申請,退出將取消語音連麥申請!", false, new DialogUitl.SimpleCallback3() { + @Override + public void onConfirmClick(Dialog dialog) { + Micing = 0; + //用户申请联麦 + final SocketSendBean msg = new SocketSendBean() + .param("_method_", Constants.LIAN_MAI) + .param("action", 7) + .param("uname", CommonAppConfig.getInstance().getUserBean().getUserNiceName()) + .param("avatar", CommonAppConfig.getInstance().getUserBean().getAvatar()) + .param("uid", CommonAppConfig.getInstance().getUid()); + msg.create(); + + Conversation.ConversationType conversationType = Conversation.ConversationType.PRIVATE; + TextMessage messageContent = TextMessage.obtain(msg.mResult.toString()); + io.rong.imlib.model.Message message = io.rong.imlib.model.Message.obtain(liveID, conversationType, messageContent); + + RongIMClient.getInstance().sendMessage(message, null, null, new IRongCallback.ISendMessageCallback() { + @Override + public void onAttached(io.rong.imlib.model.Message message) { + + } + + @Override + public void onSuccess(io.rong.imlib.model.Message message) { + Log.e("ry", "发送成功"); + liveImDeletUtil.deleteMessages(message.getTargetId(), message.getMessageId()); + if (isBackPressed) { + ((LiveAudienceActivity) mContext).onBackPressed(); + } else { + EventBus.getDefault().post(new LiveRoomChangeEvent(bean, liveType, liveTypeVal)); + } + } + + @Override + public void onError(io.rong.imlib.model.Message message, RongIMClient.ErrorCode errorCode) { + Log.e("ry", "发送失敗" + errorCode.toString()); + liveImDeletUtil.deleteMessages(message.getTargetId(), message.getMessageId()); + } + }); + } + + @Override + public void onCancel() { + ((LiveAudienceActivity) mContext).setEnableScroll(true); + } + }); + + + } + + /** + * 正处于连麦中 + */ + public void micIngTypeTwo(LiveBean bean, int liveType, int liveTypeVal) { + DialogUitl.showSimpleDialog(mContext, null, "連麥中,退出將斷開語音連麥!", false, new DialogUitl.SimpleCallback3() { + @Override + public void onConfirmClick(Dialog dialog) { + ToastUtil.show("下麥中,稍等....."); + RCRTCEngine.getInstance().getRoom().getLocalUser().switchToAudience(new IRCRTCSwitchRoleCallback() { + + /** + * 当切换失败且SDK处于无法回退状态时回调,该角色已经无法使用当前角色继续进行音视频。 + * SDK内部会退出房间并清理所有资源,该用户只能重新加入房间才能继续音视频。 + */ + @Override + public void onKicked() { + + } + + @Override + public void onSuccess() { + Log.e("ry", "下麦成功"); + // 该用户切换为观众成功,可以以观众身份进行音视频 + //退出多人房间 + HttpClient.getInstance().get("live.leaveDrLm", "live.leaveDrLm") + .params("roomid", liveID) + .execute(new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + Log.e("ry", code + "退出多人"); + + } + }); + //退出rtc播放 + RCRTCEngine.getInstance().leaveRoom(new IRCRTCResultCallback() { + @Override + public void onSuccess() { + Log.e("ry", "退出多人房间成功"); + new Handler(Looper.getMainLooper()).post(new Runnable() { + public void run() { + Micing = 0; + } + }); + if (isBackPressed) { + ((LiveAudienceActivity) mContext).onBackPressed(); + } else { + EventBus.getDefault().post(new LiveRoomChangeEvent(bean, liveType, liveTypeVal)); + } + } + + @Override + public void onFailed(RTCErrorCode errorCode) { + Log.e("ry", errorCode + "退出多人房间失敗"); + + } + }); + + } + + /** + * 当切换失败且不影响当前角色继续音视频时回调 + * @param errorCode 失败错误码 + */ + @Override + public void onFailed(RTCErrorCode errorCode) { + Log.e("ry", "下麦失败" + errorCode); + + } + }); + } + + @Override + public void onCancel() { + ((LiveAudienceActivity) mContext).setEnableScroll(true); + } + }); + + } + + //是否处于返回键 + private boolean isBackPressed = false; + @Override public void onBackPressed() { - + isBackPressed = true; } @Override @@ -388,17 +527,11 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe if (!mFirstConnectSocket) { mFirstConnectSocket = true; if (mLiveType == Constants.LIVE_TYPE_PAY || mLiveType == Constants.LIVE_TYPE_TIME) { - if (!(mIntent.getIntExtra("isry", 0) == 1)) { - SocketChatUtil.sendUpdateVotesMessage(mLiveBean.getUid(), mLiveTypeVal, 1); - } else { - SocketRyChatUtil.sendUpdateVotesMessage(mLiveBean.getUid(), mLiveTypeVal, 1); - } - } - if (!(mIntent.getIntExtra("isry", 0) == 1)) { - SocketChatUtil.getFakeFans(mLiveBean.getUid()); - } else { - SocketRyChatUtil.getFakeFans(mLiveBean.getUid()); + + SocketRyChatUtil.sendUpdateVotesMessage(mLiveBean.getUid(), mLiveTypeVal, 1); + } + SocketRyChatUtil.getFakeFans(mLiveBean.getUid()); } } } @@ -443,9 +576,12 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe mLiveLinkMicPresenter.onAudienceLeaveRoom(bean); } try { - if (mLiveRoomViewHolder.room_hot != null) { - if (!"".equals(bean.getHot_num()) && !"0".equals(bean.getHot_num())) { - mLiveRoomViewHolder.room_hot.setText(formatBigNum.formatBigNum(bean.getHot_num())); + if(mLiveRoomViewHolder!=null){ + mLiveRoomViewHolder.onExitRoom(bean); + if (mLiveRoomViewHolder.room_hot != null) { + if (!"".equals(bean.getHot_num()) && !"0".equals(bean.getHot_num())) { + mLiveRoomViewHolder.room_hot.setText(formatBigNum.formatBigNum(bean.getHot_num())); + } } } } catch (Exception ignored) { @@ -499,14 +635,10 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe @Override public void onSendGiftPk(long leftGift, long rightGift, LivePKUserListBean bean) { - if (!(mIntent.getIntExtra("isry", 0) == 1)) { - if (mLiveLinkMicPkPresenter != null) { - mLiveLinkMicPkPresenter.onPkProgressChanged(leftGift, rightGift, bean); - } - } else { - if (mLiveRyLinkMicPkPresenter != null) { - mLiveRyLinkMicPkPresenter.onPkProgressChanged(leftGift, rightGift, bean); - } + + if (mLiveRyLinkMicPkPresenter != null) { + mLiveRyLinkMicPkPresenter.onPkProgressChanged(leftGift, rightGift, bean); + } } @@ -814,34 +946,41 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe private void enterRoom() { //进入直播间IM - if (!(mIntent.getIntExtra("isry", 0) == 1)) { - mSocketClient = new SocketClient(mLiveBean.getUid(), this); - if (mLiveLinkMicPresenter != null) { - mLiveLinkMicPresenter.setSocketClient(mSocketClient); - } - } else { - mSocketRyClient = new SocketRyClient(mLiveBean.getUid(), this); - if (mLiveLinkMicPresenter != null) { - mLiveLinkMicPresenter.setSocketClient(mSocketClient); - } + + mSocketRyClient = new SocketRyClient(mLiveBean.getUid(), this); + if (mLiveLinkMicPresenter != null) { + mLiveLinkMicPresenter.setSocketClient(mSocketClient); } + timeIndex = 0; LiveHttpUtil.enterRoom(mLiveBean.getUid(), mLiveBean.getStream(), new HttpCallback() { @Override public void onSuccess(int code, String msg, String[] info) { + if (code == 0 && info.length > 0) { JSONObject obj = JSON.parseObject(info[0]); mDanmuPrice = obj.getString("barrage_fee"); mSocketUserType = obj.getIntValue("usertype"); mChatLevel = obj.getIntValue("speak_limit"); mDanMuLevel = obj.getIntValue("barrage_limit"); + liveBg = obj.getIntValue("live_bg"); + if (obj.containsKey("greetings")) { + greetings = JSONArray.parseArray(obj.getJSONArray("greetings").toJSONString(), String.class); + } + + if (liveBg == 1) { + //直播间背景 + ImgLoader.displayBlurLive(mContext, mLiveBean.getAvatar(), liveBack); + mask.setVisibility(View.VISIBLE); + } //回传参数 Bus.get().post(new LiveAudienceEvent() .setType(LiveAudienceEvent.LiveAudienceType.OPEN_PARAMETERS) .setParametersModel(new OpenParametersModel().setmDanmuPrice(mDanmuPrice) .setmSocketUserType(mSocketUserType) .setmChatLevel(mChatLevel) - .setmDanMuLevel(mDanMuLevel))); + .setmDanMuLevel(mDanMuLevel) + .setLiveBg(liveBg))); EventBus.getDefault().post("close_login"); EventBus.getDefault().post("oneUesrOver"); @@ -903,6 +1042,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe LivePlayKsyViewHolder.setLandscape(obj.getIntValue("landscape")); mLiveRoomViewHolder.setLiveInfo(mLiveBean.getUid(), mLiveBean.getStream(), obj.getIntValue("userlist_time") * 4000); + mLiveRoomViewHolder.setFastMessage(greetings); mLiveRoomViewHolder.setVotes(obj.getString("votestotal")); //真爱排行 数量 mLiveRoomViewHolder.setMedaRankNum(obj.getString("medalRankNum")); @@ -932,7 +1072,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe } List list = JSON.parseArray(obj.getString("userlists"), LiveUserGiftBean.class); mLiveRoomViewHolder.setUserList(list); - // resetUserListWidth(list); + // resetUserListWidth(list); mLiveRoomViewHolder.startRefreshUserList(); if (mLiveType == Constants.LIVE_TYPE_TIME) {//计时收费 mLiveRoomViewHolder.startRequestTimeCharge(); @@ -971,50 +1111,33 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe } if (obj.getString("isconnection") != null && obj.getString("isconnection").equals("1")) { - if (!(mIntent.getIntExtra("isry", 0) == 1)) { - setViewUP(); - } else { - LivePlayRyViewHolder.setViewUP(1); - } + + LivePlayRyViewHolder.setViewUP(1); + } if (pkInfo.getIntValue("ifpk") == 1 && pkInfo.getString("end_pk_time").equals("0")) {//pk开始了 - if (!(mIntent.getIntExtra("isry", 0) == 1)) { - setViewUP(); - } else { - LivePlayRyViewHolder.setViewUP(2); - } + + LivePlayRyViewHolder.setViewUP(2); + //pk排名数据 LivePKUserListBean livePKUserListBean = JSON.parseObject(pkInfo.getString("pk_top_users"), LivePKUserListBean.class); if (mLiveRoomViewHolder != null) { mLiveRoomViewHolder.setOtherInfo(pkInfo.getString("pkuid"), pkInfo.getString("pkuimg"), pkInfo.getString("pkuname")); } - if (mLiveLinkMicPkPresenter != null) { - mLiveLinkMicPkPresenter.onEnterRoomPkStart(pkUid, pkInfo.getLongValue("pk_gift_liveuid"), pkInfo.getLongValue("pk_gift_pkuid"), pkInfo.getIntValue("pk_time"), livePKUserListBean); - } else { - mLiveRyLinkMicPkPresenter.onEnterRoomPkStart(pkUid, pkInfo.getLongValue("pk_gift_liveuid"), pkInfo.getLongValue("pk_gift_pkuid"), pkInfo.getIntValue("pk_time"), livePKUserListBean); - } + mLiveRyLinkMicPkPresenter.onEnterRoomPkStart(pkUid, pkInfo.getLongValue("pk_gift_liveuid"), pkInfo.getLongValue("pk_gift_pkuid"), pkInfo.getIntValue("pk_time"), livePKUserListBean); } else if (!pkInfo.getString("end_pk_time").equals("0")) { - if (!(mIntent.getIntExtra("isry", 0) == 1)) { - setViewUP(); - } else { - LivePlayRyViewHolder.setViewUP(3); - } + + LivePlayRyViewHolder.setViewUP(3); + //pk排名数据 LivePKUserListBean livePKUserListBean = JSON.parseObject(pkInfo.getString("pk_top_users"), LivePKUserListBean.class); - if (mLiveLinkMicPkPresenter != null) { - mLiveLinkMicPkPresenter.onEnterRoomCFStart(pkUid, pkInfo.getLongValue("pk_gift_liveuid"), pkInfo.getLongValue("pk_gift_pkuid"), pkInfo.getIntValue("end_pk_time"), livePKUserListBean); - } else { - mLiveRyLinkMicPkPresenter.onEnterRoomCFStart(pkUid, pkInfo.getLongValue("pk_gift_liveuid"), pkInfo.getLongValue("pk_gift_pkuid"), pkInfo.getIntValue("end_pk_time"), livePKUserListBean); - - } + mLiveRyLinkMicPkPresenter.onEnterRoomCFStart(pkUid, pkInfo.getLongValue("pk_gift_liveuid"), pkInfo.getLongValue("pk_gift_pkuid"), pkInfo.getIntValue("end_pk_time"), livePKUserListBean); } //多人PK } else if (pkInfo != null && pkInfo.getIntValue("drpk_status") == 1) { - if (!(mIntent.getIntExtra("isry", 0) == 1)) { - setViewUP(); - } else { - LivePlayRyViewHolder.setViewUP(4); - } + + LivePlayRyViewHolder.setViewUP(4); + mLiveRoomViewHolder.UpPkBar(pkInfo.getJSONArray("userlist"), mLiveBean.getUid(), pkInfo.getIntValue("drpk_time")); } @@ -1136,17 +1259,12 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe } mEnd = true; //断开socket - if (!(mIntent.getIntExtra("isry", 0) == 1)) { - if (mSocketClient != null) { - mSocketClient.disConnect(); - } - mSocketClient = null; - } else { - if (mSocketRyClient != null) { - mSocketRyClient.disConnect(); - } - mSocketRyClient = null; + + if (mSocketRyClient != null) { + mSocketRyClient.disConnect(); } + mSocketRyClient = null; + //结束播放 if (mLivePlayViewHolder != null) { @@ -1157,6 +1275,8 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe } public void end() { + if (mLiveRoomViewHolder != null) + mLiveRoomViewHolder.clearList(); boolean canBackPressed = true; if (mContext instanceof LiveAudienceActivity) { canBackPressed = ((LiveAudienceActivity) mContext).canBackPressed(); @@ -1185,7 +1305,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe } else { exitLiveRoom(); } - mBannerList2.clear(); + } /** @@ -1266,11 +1386,8 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe if (!mLighted) { mLighted = true; int guardType = mLiveGuardInfo != null ? mLiveGuardInfo.getMyGuardType() : Constants.GUARD_TYPE_NONE; - if (!(mIntent.getIntExtra("isry", 0) == 1)) { - SocketChatUtil.sendLightMessage(mLiveBean.getUid(), 1 + RandomUtil.nextInt(6), guardType); - } else { - SocketRyChatUtil.sendLightMessage(mLiveBean.getUid(), 1 + RandomUtil.nextInt(6), guardType); - } + SocketRyChatUtil.sendLightMessage(mLiveBean.getUid(), 1 + RandomUtil.nextInt(6), guardType); + } if (mLiveRoomViewHolder != null) { mLiveRoomViewHolder.playLightAnim(); @@ -1324,10 +1441,17 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe * 更新主播映票数 */ public void sendUpdateVotesMessage() { - if (!(mIntent.getIntExtra("isry", 0) == 1)) { - SocketChatUtil.sendUpdateVotesMessage(mLiveBean.getUid(), mLiveTypeVal); - } else { - SocketRyChatUtil.sendUpdateVotesMessage(mLiveBean.getUid(), mLiveTypeVal); + + SocketRyChatUtil.sendUpdateVotesMessage(mLiveBean.getUid(), mLiveTypeVal); + + } + + public void onFollowEvent(FollowEvent e) { + if (!TextUtils.isEmpty(liveID) && liveID.equals(e.getToUid())) { + if (mLiveRoomViewHolder != null) { + mLiveRoomViewHolder.setAttention(e.getIsAttention()); + } } + } } diff --git a/live/src/main/res/drawable/bg_fast_meg.xml b/live/src/main/res/drawable/bg_fast_meg.xml new file mode 100644 index 000000000..4b8c2a6db --- /dev/null +++ b/live/src/main/res/drawable/bg_fast_meg.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/drawable/bg_guard_info.xml b/live/src/main/res/drawable/bg_guard_info.xml new file mode 100644 index 000000000..e7a43f71c --- /dev/null +++ b/live/src/main/res/drawable/bg_guard_info.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/drawable/bg_guard_up_title.xml b/live/src/main/res/drawable/bg_guard_up_title.xml new file mode 100644 index 000000000..15af2f005 --- /dev/null +++ b/live/src/main/res/drawable/bg_guard_up_title.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/drawable/guardian_img_bg.png b/live/src/main/res/drawable/guardian_img_bg.png new file mode 100644 index 000000000..2a6bc02e6 Binary files /dev/null and b/live/src/main/res/drawable/guardian_img_bg.png differ diff --git a/live/src/main/res/drawable/guardian_img_wings.png b/live/src/main/res/drawable/guardian_img_wings.png new file mode 100644 index 000000000..25aaed820 Binary files /dev/null and b/live/src/main/res/drawable/guardian_img_wings.png differ diff --git a/live/src/main/res/drawable/img_diamond.png b/live/src/main/res/drawable/img_diamond.png new file mode 100644 index 000000000..b1de36b8f Binary files /dev/null and b/live/src/main/res/drawable/img_diamond.png differ diff --git a/live/src/main/res/drawable/img_guard_bottom.png b/live/src/main/res/drawable/img_guard_bottom.png new file mode 100644 index 000000000..94de45974 Binary files /dev/null and b/live/src/main/res/drawable/img_guard_bottom.png differ diff --git a/live/src/main/res/drawable/img_k_selected.png b/live/src/main/res/drawable/img_k_selected.png new file mode 100644 index 000000000..efdc9aba2 Binary files /dev/null and b/live/src/main/res/drawable/img_k_selected.png differ diff --git a/live/src/main/res/drawable/img_k_uncheck.png b/live/src/main/res/drawable/img_k_uncheck.png new file mode 100644 index 000000000..e803cb8a1 Binary files /dev/null and b/live/src/main/res/drawable/img_k_uncheck.png differ diff --git a/live/src/main/res/drawable/img_venosa.png b/live/src/main/res/drawable/img_venosa.png new file mode 100644 index 000000000..8171bc178 Binary files /dev/null and b/live/src/main/res/drawable/img_venosa.png differ diff --git a/live/src/main/res/drawable/live_loading.gif b/live/src/main/res/drawable/live_loading.gif new file mode 100644 index 000000000..c3802a88b Binary files /dev/null and b/live/src/main/res/drawable/live_loading.gif differ diff --git a/live/src/main/res/drawable/loading_00000.png b/live/src/main/res/drawable/loading_00000.png new file mode 100644 index 000000000..e54a417e2 Binary files /dev/null and b/live/src/main/res/drawable/loading_00000.png differ diff --git a/live/src/main/res/drawable/loading_00001.png b/live/src/main/res/drawable/loading_00001.png new file mode 100644 index 000000000..6e1023d84 Binary files /dev/null and b/live/src/main/res/drawable/loading_00001.png differ diff --git a/live/src/main/res/drawable/loading_00002.png b/live/src/main/res/drawable/loading_00002.png new file mode 100644 index 000000000..88e175b08 Binary files /dev/null and b/live/src/main/res/drawable/loading_00002.png differ diff --git a/live/src/main/res/drawable/loading_00003.png b/live/src/main/res/drawable/loading_00003.png new file mode 100644 index 000000000..f4733ef60 Binary files /dev/null and b/live/src/main/res/drawable/loading_00003.png differ diff --git a/live/src/main/res/drawable/loading_00004.png b/live/src/main/res/drawable/loading_00004.png new file mode 100644 index 000000000..4fbd57ebc Binary files /dev/null and b/live/src/main/res/drawable/loading_00004.png differ diff --git a/live/src/main/res/drawable/loading_00005.png b/live/src/main/res/drawable/loading_00005.png new file mode 100644 index 000000000..229bdc2aa Binary files /dev/null and b/live/src/main/res/drawable/loading_00005.png differ diff --git a/live/src/main/res/drawable/loading_00006.png b/live/src/main/res/drawable/loading_00006.png new file mode 100644 index 000000000..651a8e94d Binary files /dev/null and b/live/src/main/res/drawable/loading_00006.png differ diff --git a/live/src/main/res/drawable/loading_00007.png b/live/src/main/res/drawable/loading_00007.png new file mode 100644 index 000000000..e972df8ee Binary files /dev/null and b/live/src/main/res/drawable/loading_00007.png differ diff --git a/live/src/main/res/drawable/loading_00008.png b/live/src/main/res/drawable/loading_00008.png new file mode 100644 index 000000000..bbb7a49af Binary files /dev/null and b/live/src/main/res/drawable/loading_00008.png differ diff --git a/live/src/main/res/drawable/loading_00009.png b/live/src/main/res/drawable/loading_00009.png new file mode 100644 index 000000000..a04be6772 Binary files /dev/null and b/live/src/main/res/drawable/loading_00009.png differ diff --git a/live/src/main/res/drawable/loading_00010.png b/live/src/main/res/drawable/loading_00010.png new file mode 100644 index 000000000..1fbbc70a6 Binary files /dev/null and b/live/src/main/res/drawable/loading_00010.png differ diff --git a/live/src/main/res/drawable/loading_00011.png b/live/src/main/res/drawable/loading_00011.png new file mode 100644 index 000000000..f3e14f0fb Binary files /dev/null and b/live/src/main/res/drawable/loading_00011.png differ diff --git a/live/src/main/res/drawable/loading_00012.png b/live/src/main/res/drawable/loading_00012.png new file mode 100644 index 000000000..668f158b7 Binary files /dev/null and b/live/src/main/res/drawable/loading_00012.png differ diff --git a/live/src/main/res/drawable/loading_00013.png b/live/src/main/res/drawable/loading_00013.png new file mode 100644 index 000000000..f40771758 Binary files /dev/null and b/live/src/main/res/drawable/loading_00013.png differ diff --git a/live/src/main/res/drawable/loading_00014.png b/live/src/main/res/drawable/loading_00014.png new file mode 100644 index 000000000..b1c0e4685 Binary files /dev/null and b/live/src/main/res/drawable/loading_00014.png differ diff --git a/live/src/main/res/drawable/loading_00015.png b/live/src/main/res/drawable/loading_00015.png new file mode 100644 index 000000000..8bc567693 Binary files /dev/null and b/live/src/main/res/drawable/loading_00015.png differ diff --git a/live/src/main/res/drawable/loading_animation.xml b/live/src/main/res/drawable/loading_animation.xml index ee74d0819..4a98f36b8 100644 --- a/live/src/main/res/drawable/loading_animation.xml +++ b/live/src/main/res/drawable/loading_animation.xml @@ -2,13 +2,53 @@ + android:drawable="@drawable/loading_00000" + android:duration="100" /> + android:drawable="@drawable/loading_00001" + android:duration="100" /> + android:drawable="@drawable/loading_00002" + android:duration="100" /> + + + + + + + + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/drawable/sh_img_title.png b/live/src/main/res/drawable/sh_img_title.png new file mode 100644 index 000000000..9fc187e8b Binary files /dev/null and b/live/src/main/res/drawable/sh_img_title.png differ diff --git a/live/src/main/res/layout/activity_live_audience.xml b/live/src/main/res/layout/activity_live_audience.xml index d3fa3a24a..3c77a5a7f 100644 --- a/live/src/main/res/layout/activity_live_audience.xml +++ b/live/src/main/res/layout/activity_live_audience.xml @@ -18,6 +18,7 @@ android:src="@mipmap/live_bg" /> diff --git a/live/src/main/res/layout/activity_live_detail.xml b/live/src/main/res/layout/activity_live_detail.xml index bf7edf6a4..b709ef276 100644 --- a/live/src/main/res/layout/activity_live_detail.xml +++ b/live/src/main/res/layout/activity_live_detail.xml @@ -9,10 +9,6 @@ android:layout_height="match_parent" android:overScrollMode="never" /> - + \ No newline at end of file diff --git a/live/src/main/res/layout/dialog_guard_list.xml b/live/src/main/res/layout/dialog_guard_list.xml index 5ee191918..6b97a3ee6 100644 --- a/live/src/main/res/layout/dialog_guard_list.xml +++ b/live/src/main/res/layout/dialog_guard_list.xml @@ -48,8 +48,7 @@ android:gravity="center" android:text="@string/guard_buy_2" android:textColor="@color/white" - android:textSize="14sp" - /> + android:textSize="14sp" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/layout/dialog_user_more_list.xml b/live/src/main/res/layout/dialog_user_more_list.xml index 21e4ea6ed..e04a0f272 100644 --- a/live/src/main/res/layout/dialog_user_more_list.xml +++ b/live/src/main/res/layout/dialog_user_more_list.xml @@ -73,7 +73,7 @@ android:text="@string/live_guard" android:textColor="#ff646464" android:textSize="16sp" - android:visibility="gone" /> + android:visibility="visible" /> + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/layout/item_fast_msg.xml b/live/src/main/res/layout/item_fast_msg.xml new file mode 100644 index 000000000..400d66e9e --- /dev/null +++ b/live/src/main/res/layout/item_fast_msg.xml @@ -0,0 +1,24 @@ + + + + + \ No newline at end of file diff --git a/live/src/main/res/layout/layout_portrait_comm_item.xml b/live/src/main/res/layout/layout_portrait_comm_item.xml new file mode 100644 index 000000000..2194219a7 --- /dev/null +++ b/live/src/main/res/layout/layout_portrait_comm_item.xml @@ -0,0 +1,19 @@ + + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/layout/layout_portrait_live_item.xml b/live/src/main/res/layout/layout_portrait_live_item.xml index a1f63e882..021e2cc7a 100644 --- a/live/src/main/res/layout/layout_portrait_live_item.xml +++ b/live/src/main/res/layout/layout_portrait_live_item.xml @@ -12,8 +12,8 @@ diff --git a/live/src/main/res/layout/view_live_audience.xml b/live/src/main/res/layout/view_live_audience.xml index a37447338..a87799079 100644 --- a/live/src/main/res/layout/view_live_audience.xml +++ b/live/src/main/res/layout/view_live_audience.xml @@ -85,47 +85,6 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + android:src="@mipmap/img_guardian_empty" + app:riv_oval="true" /> + app:autoPlay="true" /> - + + android:outAnimation="@anim/anim_marquee_out" /> @@ -1796,7 +1866,11 @@ android:layout_centerHorizontal="true" android:layout_centerVertical="true" /> - + diff --git a/live/src/main/res/layout/view_sidebar_live_audience.xml b/live/src/main/res/layout/view_sidebar_live_audience.xml index 633315de9..87d7479a4 100644 --- a/live/src/main/res/layout/view_sidebar_live_audience.xml +++ b/live/src/main/res/layout/view_sidebar_live_audience.xml @@ -10,6 +10,7 @@ android:scaleType="centerCrop" /> diff --git a/live/src/main/res/mipmap-xxxhdpi/live_bg.jpg b/live/src/main/res/mipmap-xxxhdpi/live_bg.jpg index 6d9899eb1..b6cd42cda 100644 Binary files a/live/src/main/res/mipmap-xxxhdpi/live_bg.jpg and b/live/src/main/res/mipmap-xxxhdpi/live_bg.jpg differ diff --git a/live/src/main/res/values/strings.xml b/live/src/main/res/values/strings.xml index 7abc06d3b..491888253 100644 --- a/live/src/main/res/values/strings.xml +++ b/live/src/main/res/values/strings.xml @@ -1 +1,4 @@ - + + 成爲TA的守護,爲TA保駕護航! + 返還 + diff --git a/main/src/main/java/com/yunbao/main/activity/GoogleFragment.java b/main/src/main/java/com/yunbao/main/activity/GoogleFragment.java index 01d34f8a7..0efe1940d 100644 --- a/main/src/main/java/com/yunbao/main/activity/GoogleFragment.java +++ b/main/src/main/java/com/yunbao/main/activity/GoogleFragment.java @@ -62,7 +62,7 @@ public class GoogleFragment extends Fragment { private View view; - private static String mOrderid,mProductId,MoneyUsds; + private String mOrderid,mProductId,MoneyUsds; private WebView rlWebview; private String url; @@ -84,9 +84,6 @@ public class GoogleFragment extends Fragment { new Thread(new Runnable() { public void run() { try { - - - try { adid = AdvertisingIdClient.getAdvertisingIdInfo(getActivity()).getId(); Log.e("vssss",adid); diff --git a/main/src/main/java/com/yunbao/main/activity/MainActivity.java b/main/src/main/java/com/yunbao/main/activity/MainActivity.java index 6ff5f2677..4a5648ee9 100644 --- a/main/src/main/java/com/yunbao/main/activity/MainActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/MainActivity.java @@ -46,8 +46,10 @@ import com.tencent.imsdk.v2.V2TIMSDKConfig; import com.tencent.imsdk.v2.V2TIMSDKListener; import com.tencent.imsdk.v2.V2TIMUserFullInfo; import com.yunbao.common.CommonAppConfig; +import com.yunbao.common.CommonAppContext; import com.yunbao.common.Constants; import com.yunbao.common.activity.AbsActivity; +import com.yunbao.common.activity.WebViewActivity; import com.yunbao.common.adapter.ViewPagerAdapter; import com.yunbao.common.bean.AnchorRecommendModel; import com.yunbao.common.bean.ChatRemarksBean; @@ -133,6 +135,7 @@ import io.rong.imlib.RongIMClient; import kotlin.Unit; import static com.yunbao.common.CommonAppContext.isReady; +import static com.yunbao.live.activity.SystemMessageActivity.type; import io.rong.imlib.model.Message; import io.rong.push.PushManager; @@ -267,6 +270,37 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene }; +// private void getToken() { +// // 创建一个新线程 +// new Thread() { +// @Override +// public void run() { +// try { +// // 从agconnect-service.json文件中读取appId +// String appId = "106936673"; +// +// // 输入token标识"HCM" +// String tokenScope = "HCM"; +// String token = HmsInstanceId.getInstance(MainActivity.this).getToken(appId, tokenScope); +// Log.i("hw", "get token: " + token); +// +// // 判断token是否为空 +// if(!TextUtils.isEmpty(token)) { +// sendRegTokenToServer(token); +// } +// } catch (Exception e) { +// Log.e("hw","get token failed, " + e); +// } +// } +// }.start(); +// } +// private void sendRegTokenToServer(String token) { +// PushManager.getInstance() +// .onReceiveToken(MainActivity.this, PushType.HUAWEI, token); +// Log.i("hw", "sending token to server. token:" + token); +// } + + @Override protected void main() { ConversationIMListManager.get(this); @@ -287,6 +321,40 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene // RTCLib 初始化 RCRTCConfig.Builder config = RCRTCConfig.Builder.create(); RCRTCEngine.getInstance().init(MainActivity.this, config.build()); + //推送跳直播间 + if(getIntent().getStringExtra("liveid")!=null){ + LiveHttpUtil.getLiveInfo(getIntent().getStringExtra("liveid") + "", new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + if (code == 0 && info.length > 0) { + LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class); + + LiveRoomCheckLivePresenter mCheckLivePresenter = new LiveRoomCheckLivePresenter(mContext, new LiveRoomCheckLivePresenter.ActionListener() { + @Override + public void onLiveRoomChanged(LiveBean liveBean, int liveType, int liveTypeVal, int liveSdk) { + if (liveBean == null) { + return; + } + LiveAudienceActivity.forward(mContext, liveBean, liveType, liveTypeVal, "", 0, liveSdk); + + } + }); + + mCheckLivePresenter.checkLive(liveBean); + } else { + ToastUtil.show("直播已结束"); + } + } + }); + }else if(getIntent().getStringExtra("type")!=null&&getIntent().getStringExtra("type").equals("2")){ + //跳转消息列表 + Bundle bundle = new Bundle(); + bundle.putInt(PDLiveConversationListActivity.MESSAGENUMBER, messageNumber); + bundle.putInt(PDLiveConversationListActivity.NUMBERME, numberMe); + ConversationIMListManager.get(this).jumpConversationList(bundle); + }else if(getIntent().getStringExtra("type")!=null&&getIntent().getStringExtra("type").equals("8")){ + WebViewActivity.forward(mContext, getIntent().getStringExtra("activityUrl"), true); + } FirebaseMessaging.getInstance().getToken() .addOnCompleteListener(new OnCompleteListener() { @Override @@ -306,6 +374,10 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene // Toast.makeText(MainActivity.this, token, Toast.LENGTH_SHORT).show(); } }); + + //华为推送 +// getToken(); + boolean showInvite = getIntent().getBooleanExtra(Constants.SHOW_INVITE, false); mRootView = (ViewGroup) findViewById(R.id.rootView); floatBanner = findViewById(R.id.float_banner_home); diff --git a/main/src/main/java/com/yunbao/main/activity/MsgSettActivity.java b/main/src/main/java/com/yunbao/main/activity/MsgSettActivity.java index d33226cb4..05c52cbb8 100644 --- a/main/src/main/java/com/yunbao/main/activity/MsgSettActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/MsgSettActivity.java @@ -1,15 +1,34 @@ package com.yunbao.main.activity; import androidx.appcompat.app.AppCompatActivity; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; import android.os.Bundle; +import android.util.Log; +import android.view.View; +import android.widget.ImageView; import com.yunbao.common.activity.AbsActivity; +import com.yunbao.common.bean.BaseModel; +import com.yunbao.common.bean.MsgSwitchDetailModel; +import com.yunbao.common.bean.SlideInfoModel; +import com.yunbao.common.http.ResponseData; +import com.yunbao.common.http.base.HttpCallback; +import com.yunbao.common.http.main.MainNetManager; +import com.yunbao.common.utils.ToastUtil; +import com.yunbao.live.views.LoadingView; import com.yunbao.main.R; +import com.yunbao.main.adapter.MainHomeLivesClassAdapter; +import com.yunbao.main.adapter.MsgFollowAdapter; + +import java.util.List; public class MsgSettActivity extends AbsActivity { + ImageView dt_switch,hdd_switch,lt_switch,xt_switch,kb_switch; + RecyclerView follow_list; @Override protected int getLayoutId() { return R.layout.activity_msg_sett; @@ -19,5 +38,201 @@ public class MsgSettActivity extends AbsActivity { protected void main() { super.main(); setTitle("消息通知"); + follow_list = (RecyclerView) findViewById(R.id.follow_list); + dt_switch = (ImageView) findViewById(R.id.dt_switch); + hdd_switch= (ImageView) findViewById(R.id.hdd_switch); + lt_switch = (ImageView) findViewById(R.id.lt_switch); + xt_switch= (ImageView) findViewById(R.id.xt_switch); + kb_switch= (ImageView) findViewById(R.id.kb_switch); + getData(); + dt_switch.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + //打开的 + if (dt_switch.getDrawable().getCurrent().getConstantState().equals(getResources().getDrawable(R.mipmap.special_icon_on).getConstantState())){ + if(setMsgMasterSwitch("2","1")){ + dt_switch.setImageResource(R.mipmap.special_icon_off); + }; + }else{ + if(setMsgMasterSwitch("1","1")){ + dt_switch.setImageResource(R.mipmap.special_icon_on); + }; + } + } + }); + + hdd_switch.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + //打开的 + if (hdd_switch.getDrawable().getCurrent().getConstantState().equals(getResources().getDrawable(R.mipmap.special_icon_on).getConstantState())){ + if(setMsgMasterSwitch("2","2")){ + hdd_switch.setImageResource(R.mipmap.special_icon_off); + }; + }else{ + if(setMsgMasterSwitch("1","2")){ + hdd_switch.setImageResource(R.mipmap.special_icon_on); + }; + } + } + }); + + lt_switch.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + //打开的 + if (lt_switch.getDrawable().getCurrent().getConstantState().equals(getResources().getDrawable(R.mipmap.special_icon_on).getConstantState())){ + if(setMsgMasterSwitch("2","3")){ + lt_switch.setImageResource(R.mipmap.special_icon_off); + }; + }else{ + if(setMsgMasterSwitch("1","3")){ + lt_switch.setImageResource(R.mipmap.special_icon_on); + }; + } + } + }); + + xt_switch.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + //打开的 + if (xt_switch.getDrawable().getCurrent().getConstantState().equals(getResources().getDrawable(R.mipmap.special_icon_on).getConstantState())){ + if(setMsgMasterSwitch("2","4")){ + xt_switch.setImageResource(R.mipmap.special_icon_off); + }; + }else{ + if(setMsgMasterSwitch("1","4")){ + xt_switch.setImageResource(R.mipmap.special_icon_on); + }; + } + } + }); + + follow_list.setVisibility(View.GONE); + kb_switch.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + int is =1; + //打开的 + if (kb_switch.getDrawable().getCurrent().getConstantState().equals(getResources().getDrawable(R.mipmap.special_icon_on).getConstantState())){ + is = 2; + }else{ + is = 1; + } + MainNetManager.get(mContext).setBeginShowMsgSwitch(is+"", "1","", new HttpCallback() { + @Override + public void onSuccess(ResponseData data) { + + Log.e("ds",data.getCode()+""); + if(data.getCode() == 200 ){ + Log.e("ds",kb_switch.getDrawable().getCurrent().getConstantState()+""); + if (kb_switch.getDrawable().getCurrent().getConstantState().equals(getResources().getDrawable(R.mipmap.special_icon_on).getConstantState())){ + kb_switch.setImageResource(R.mipmap.special_icon_off); + follow_list.setVisibility(View.GONE); + }else{ + getData(); + } + } + + } + + @Override + public void onError(String error) { + Log.e("ds",kb_switch.getDrawable().getCurrent().getConstantState()+"11"+error); + + } + }); + } + }); + + follow_list.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false)); + follow_list.setHasFixedSize(true); + follow_list.setNestedScrollingEnabled(true); + + } + + public void getData(){ + MainNetManager.get(mContext) + .getMsgSwitchDetail(new HttpCallback() { + @Override + public void onSuccess(MsgSwitchDetailModel data) { + + if(data.getDynamic_msg_switch().equals("2")){ + dt_switch.setImageResource(R.mipmap.special_icon_off); + }else{ + dt_switch.setImageResource(R.mipmap.special_icon_on); + } + + if(data.getInteraction_show_msg_switch().equals("2")){ + hdd_switch.setImageResource(R.mipmap.special_icon_off); + }else{ + hdd_switch.setImageResource(R.mipmap.special_icon_on); + } + + if(data.getChat_msg_switch().equals("2")){ + lt_switch.setImageResource(R.mipmap.special_icon_off); + }else{ + lt_switch.setImageResource(R.mipmap.special_icon_on); + } + + if(data.getChat_msg_switch().equals("2")){ + lt_switch.setImageResource(R.mipmap.special_icon_off); + }else{ + lt_switch.setImageResource(R.mipmap.special_icon_on); + } + + if(data.getSystem_msg_switch().equals("2")){ + xt_switch.setImageResource(R.mipmap.special_icon_off); + }else{ + xt_switch.setImageResource(R.mipmap.special_icon_on); + } + + if(data.getSystem_msg_switch().equals("2")){ + xt_switch.setImageResource(R.mipmap.special_icon_off); + }else{ + xt_switch.setImageResource(R.mipmap.special_icon_on); + } + + for(int i = 0; i < data.getFollowList().size();i++) { + if(!data.getFollowList().get(i).getStatus().equals("2")){ + kb_switch.setImageResource(R.mipmap.special_icon_on); + follow_list.setVisibility(View.VISIBLE); + break; + } + + } + MsgFollowAdapter topAdapter = new MsgFollowAdapter(MsgSettActivity.this, data.getFollowList()); + follow_list.setAdapter(topAdapter); + follow_list.setVisibility(View.VISIBLE); + kb_switch.setImageResource(R.mipmap.special_icon_on); + } + + @Override + public void onError(String error) { + + } + }); + } + boolean ret = false; + public boolean setMsgMasterSwitch(String status,String type){ + ret =false; + MainNetManager.get(mContext).setMsgMasterSwitch(status, type, new HttpCallback() { + @Override + public void onSuccess(ResponseData data) { + + if(data.getCode() == 200 ){ + ret = true; + } + + } + + @Override + public void onError(String error) { + + } + }); + + return true; } } \ No newline at end of file diff --git a/main/src/main/java/com/yunbao/main/adapter/MsgFollowAdapter.java b/main/src/main/java/com/yunbao/main/adapter/MsgFollowAdapter.java new file mode 100644 index 000000000..21574f708 --- /dev/null +++ b/main/src/main/java/com/yunbao/main/adapter/MsgFollowAdapter.java @@ -0,0 +1,124 @@ +package com.yunbao.main.adapter; + +import android.app.Activity; +import android.content.Context; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.makeramen.roundedimageview.RoundedImageView; +import com.yunbao.common.bean.MsgSwitchDetailModel; +import com.yunbao.common.bean.MsgSwitchFollowlModel; +import com.yunbao.common.bean.UserItemBean; +import com.yunbao.common.glide.ImgLoader; +import com.yunbao.common.http.ResponseData; +import com.yunbao.common.http.base.HttpCallback; +import com.yunbao.common.http.main.MainNetManager; +import com.yunbao.common.interfaces.OnItemClickListener; +import com.yunbao.common.views.weight.ViewClicksAntiShake; +import com.yunbao.main.R; + +import java.util.List; + +public class MsgFollowAdapter extends RecyclerView.Adapter { + + private Activity mContext; + private List mList; + private LayoutInflater mInflater; + private OnItemClickListener mOnItemClickListener; + public MsgFollowAdapter(Activity context, List list) { + mContext = context; + mList = list; + mInflater = LayoutInflater.from(context); + } + + public void setOnItemClickListener(OnItemClickListener onItemClickListener) { + mOnItemClickListener = onItemClickListener; + } + + + + + + @NonNull + @Override + public Vh onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + + return new Vh(mInflater.inflate( R.layout.item_msg_follow, parent, false)); + } + + @Override + public void onBindViewHolder(@NonNull Vh holder, int position) { + holder.setData(mList.get(position),position); + } + + + + @Override + public int getItemCount() { + return mList.size(); + } + + class Vh extends RecyclerView.ViewHolder { + + RoundedImageView avatar; + TextView anchor_name; + ImageView sb_switch; + + public Vh(View itemView) { + super(itemView); + avatar = (RoundedImageView) itemView.findViewById(R.id.avatar); + anchor_name = (TextView) itemView.findViewById(R.id.anchor_name); + sb_switch = (ImageView) itemView.findViewById(R.id.sb_switch); + ViewClicksAntiShake.clicksAntiShake(itemView, () -> { + Object tag = itemView.getTag(); + if (tag != null) { + MsgSwitchFollowlModel bean = (MsgSwitchFollowlModel) tag; + if (mOnItemClickListener != null) { + mOnItemClickListener.onItemClick(bean, 0); + } + } + }); + } + String is = "1"; + void setData(MsgSwitchFollowlModel bean,int position) { + itemView.setTag(bean); + ImgLoader.display(mContext, bean.getAvatar(), avatar); + anchor_name.setText(bean.getUser_nicename()); + if(bean.getStatus().equals("2")) { + is = "1"; + sb_switch.setImageResource(R.mipmap.special_icon_off); + }else{ + is = "2"; + sb_switch.setImageResource(R.mipmap.special_icon_on); + } + sb_switch.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + MainNetManager.get(mContext).setBeginShowMsgSwitch(is + "", "", bean.getLiveuid(), new HttpCallback() { + @Override + public void onSuccess(ResponseData data) { + if(data.getCode() == 200){ + mList.get(position).setStatus(is); + notifyDataSetChanged(); + } + + } + + @Override + public void onError(String error) { + + } + }); + } + }); + } + } +} + diff --git a/main/src/main/java/com/yunbao/main/views/MainHomeCommunityViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainHomeCommunityViewHolder.java index 40a728f60..82e3b5758 100644 --- a/main/src/main/java/com/yunbao/main/views/MainHomeCommunityViewHolder.java +++ b/main/src/main/java/com/yunbao/main/views/MainHomeCommunityViewHolder.java @@ -4,6 +4,7 @@ import android.content.ClipData; import android.content.ClipboardManager; import android.content.Context; import android.content.Intent; +import android.graphics.drawable.AnimationDrawable; import android.net.Uri; import android.os.Build; import android.os.Handler; @@ -22,6 +23,7 @@ import android.webkit.WebChromeClient; import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebViewClient; +import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ProgressBar; import android.widget.TextView; @@ -47,6 +49,7 @@ import com.yunbao.live.bean.LiveBean; import com.yunbao.live.bean.ReportCommunityBean; import com.yunbao.live.http.LiveHttpUtil; import com.yunbao.live.presenter.LiveRoomCheckLivePresenter; +import com.yunbao.live.views.LoadingView; import com.yunbao.main.R; import com.yunbao.main.activity.FansActivity; import com.yunbao.main.activity.MainActivity; @@ -106,6 +109,11 @@ public class MainHomeCommunityViewHolder extends AbsMainHomeChildViewHolder impl mWebView.setLayoutParams(params); mWebView.setOverScrollMode(View.OVER_SCROLL_NEVER); + LoadingView loadingView = new LoadingView(mContext); + loadingView.show(); + + rootView.addView(loadingView); + mWebView.getSettings().setJavaScriptEnabled(true); mWebView.getSettings().setDomStorageEnabled(true); String appCachePath = mContext.getCacheDir().getAbsolutePath(); @@ -158,8 +166,10 @@ public class MainHomeCommunityViewHolder extends AbsMainHomeChildViewHolder impl @Override public void onProgressChanged(WebView view, int newProgress) { if (newProgress == 100) { + loadingView.hide(); mProgressBar.setVisibility(View.GONE); } else { + loadingView.show(); mProgressBar.setProgress(newProgress); } } diff --git a/main/src/main/res/layout/activity_msg_sett.xml b/main/src/main/res/layout/activity_msg_sett.xml index 794671e14..fb9409119 100644 --- a/main/src/main/res/layout/activity_msg_sett.xml +++ b/main/src/main/res/layout/activity_msg_sett.xml @@ -8,7 +8,7 @@ - @@ -47,7 +47,7 @@ @@ -81,12 +81,12 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="10dp" - android:text="主播發佈新動態通知" + android:text="點讚、評論、鼓勵送禮" android:textColor="#ffc7c8c9" android:textSize="12sp" /> - @@ -120,12 +120,13 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="10dp" - android:text="主播發佈新動態通知" + android:text="用戶聊天訊息" android:textColor="#ffc7c8c9" android:textSize="12sp" /> @@ -159,12 +160,13 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="10dp" - android:text="主播發佈新動態通知" + android:text="新活動、系統消息" android:textColor="#ffc7c8c9" android:textSize="12sp" /> @@ -200,12 +202,13 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="10dp" - android:text="主播發佈新動態通知" + android:text="開啟後獲得直播通知" android:textColor="#ffc7c8c9" android:textSize="12sp" /> + - + \ No newline at end of file diff --git a/main/src/main/res/layout/item_msg_follow.xml b/main/src/main/res/layout/item_msg_follow.xml new file mode 100644 index 000000000..b3713d601 --- /dev/null +++ b/main/src/main/res/layout/item_msg_follow.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + \ No newline at end of file