164 lines
6.9 KiB
Java
164 lines
6.9 KiB
Java
|
|
|
||
|
|
package com.pukka.jiecheng.utils;
|
||
|
|
|
||
|
|
import android.annotation.SuppressLint;
|
||
|
|
import android.content.Context;
|
||
|
|
import android.content.Intent;
|
||
|
|
import android.text.TextUtils;
|
||
|
|
import android.view.View;
|
||
|
|
import android.widget.Toast;
|
||
|
|
import com.google.gson.Gson;
|
||
|
|
import com.migu.bean.GetLayoutBean;
|
||
|
|
import com.pukka.jiecheng.filter.FilterActivity;
|
||
|
|
import com.pukka.jiecheng.index.IndexAmberManager;
|
||
|
|
import com.pukka.jiecheng.index.IndexConstant;
|
||
|
|
import com.pukka.jiecheng.video.VideoDetailActivity;
|
||
|
|
import com.pukka.libcore.base.BaseUrl;
|
||
|
|
import com.pukka.libcore.base.BuildConfig;
|
||
|
|
import com.pukka.libcore.utils.AppUtils;
|
||
|
|
import com.pukka.libcore.utils.JsonUtils;
|
||
|
|
import com.pukka.libcore.utils.LogUtils;
|
||
|
|
import com.pukka.libcore.utils.StringUtils;
|
||
|
|
|
||
|
|
import org.json.JSONObject;
|
||
|
|
|
||
|
|
import java.util.HashMap;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Author: wxf
|
||
|
|
* Date: 2023/3/15 16:19
|
||
|
|
* Description:首页点击处理
|
||
|
|
*/
|
||
|
|
public class ItemOnClickUtils {
|
||
|
|
|
||
|
|
// 首页推荐位点击处理
|
||
|
|
@SuppressLint("WrongConstant")
|
||
|
|
public static void indexItemOnClick(View view, GetLayoutBean.DataBean floor, int position, Context mContext) {
|
||
|
|
GetLayoutBean.DataBean.ExtraDataBean mItemData = floor.getExtraData().get(position);
|
||
|
|
if (mItemData == null) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
IndexAmberManager.recommendClick(mItemData,(position+1)+"");
|
||
|
|
String targetType = mItemData.getType();
|
||
|
|
LogUtils.d("getType-----" + targetType);
|
||
|
|
switch (targetType) {
|
||
|
|
// 点播详情页
|
||
|
|
case "1":
|
||
|
|
String showType = mItemData.getShowtype();
|
||
|
|
if(StringUtils.isEmpty(showType) || showType.equals("1")){
|
||
|
|
LogUtils.d("视频推荐位==");
|
||
|
|
String reserved = mItemData.getReserved1();
|
||
|
|
if(!StringUtils.isEmpty(reserved)) {
|
||
|
|
try {
|
||
|
|
JSONObject jsonObject = new JSONObject(reserved);
|
||
|
|
String code = jsonObject.getString("code");
|
||
|
|
LogUtils.d("vod reserved getContentcode=" + code);
|
||
|
|
if (!TextUtils.isEmpty(code)) {
|
||
|
|
MgRoute.go2DetailActivity(mContext, code);
|
||
|
|
} else {
|
||
|
|
Toast.makeText(mContext, "未找到内容id", Toast.LENGTH_LONG).show();
|
||
|
|
}
|
||
|
|
}catch (Exception exception){
|
||
|
|
exception.printStackTrace();
|
||
|
|
}
|
||
|
|
} else {
|
||
|
|
LogUtils.d("vod getContentcode=" + mItemData.getContentcode());
|
||
|
|
if (!TextUtils.isEmpty(mItemData.getContentcode())) {
|
||
|
|
MgRoute.go2DetailActivity(mContext, mItemData.getContentcode());
|
||
|
|
} else {
|
||
|
|
Toast.makeText(mContext, "未找到内容id", Toast.LENGTH_LONG).show();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
} else {
|
||
|
|
LogUtils.d("普通推荐位 vod getContentcode=" + mItemData.getContentcode());
|
||
|
|
if (!TextUtils.isEmpty(mItemData.getContentcode())) {
|
||
|
|
MgRoute.go2DetailActivity(mContext, mItemData.getContentcode());
|
||
|
|
} else {
|
||
|
|
Toast.makeText(mContext, "未找到内容id", Toast.LENGTH_LONG).show();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
break;
|
||
|
|
// 点播播放页
|
||
|
|
case "2":
|
||
|
|
if(!StringUtils.isEmpty(mItemData.getReserved1())) {
|
||
|
|
try {
|
||
|
|
JSONObject jsonObject = new JSONObject(mItemData.getReserved1());
|
||
|
|
String code1 = jsonObject.getString("code");
|
||
|
|
LogUtils.d("vod reserved getContentcode=" + code1);
|
||
|
|
if (!TextUtils.isEmpty(code1)) {
|
||
|
|
MgRoute.go2DetailActivity(mContext, code1);
|
||
|
|
} else {
|
||
|
|
Toast.makeText(mContext, "未找到内容id", Toast.LENGTH_LONG).show();
|
||
|
|
}
|
||
|
|
}catch (Exception exception){
|
||
|
|
exception.printStackTrace();
|
||
|
|
}
|
||
|
|
}else {
|
||
|
|
LogUtils.d("vod getContentcode=" + mItemData.getContentcode());
|
||
|
|
if (!TextUtils.isEmpty(mItemData.getContentcode())) {
|
||
|
|
MgRoute.go2FullPlayerActivity(mContext, mItemData.getContentcode());
|
||
|
|
} else {
|
||
|
|
Toast.makeText(mContext, "未找到内容id", Toast.LENGTH_LONG).show();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
break;
|
||
|
|
// 列表页
|
||
|
|
case "3":
|
||
|
|
String listParam = mItemData.getPlayurl();
|
||
|
|
if (!TextUtils.isEmpty(listParam)) {
|
||
|
|
String[] split = listParam.split("&");
|
||
|
|
String listId="";
|
||
|
|
String parentId="";
|
||
|
|
if (split.length>=2){
|
||
|
|
// 子栏目id
|
||
|
|
listId = split[0];
|
||
|
|
// 父栏目id
|
||
|
|
parentId = split[1];
|
||
|
|
}else if (split.length == 1){
|
||
|
|
parentId = listParam;
|
||
|
|
}
|
||
|
|
MgRoute.go2ListActivity(mContext,parentId,listId);
|
||
|
|
} else {
|
||
|
|
Toast.makeText(mContext, "未找到栏目id", Toast.LENGTH_LONG).show();
|
||
|
|
}
|
||
|
|
break;
|
||
|
|
// 外链
|
||
|
|
case "5":
|
||
|
|
String url =mItemData.getPlayurl();
|
||
|
|
if(!StringUtils.isEmpty(url)) {
|
||
|
|
MgRoute.go2SimpleWebActivity(mContext, url);
|
||
|
|
}else{
|
||
|
|
Toast.makeText(mContext, "没有配置外链地址", Toast.LENGTH_LONG).show();
|
||
|
|
}
|
||
|
|
break;
|
||
|
|
// 跳转APK
|
||
|
|
case "6":
|
||
|
|
String playurl = mItemData.getPlayurl();
|
||
|
|
if(!StringUtils.isEmpty(playurl)){
|
||
|
|
LogUtils.d("playUrl="+playurl);
|
||
|
|
String[] strings = playurl.split("&&");
|
||
|
|
if(strings.length>1){
|
||
|
|
String packageName = strings[0];
|
||
|
|
String className = strings[1];
|
||
|
|
LogUtils.d("packageName="+packageName+" className="+className);
|
||
|
|
AppUtils.startApkByPackageAndClass(mContext,packageName,className);
|
||
|
|
}else{
|
||
|
|
AppUtils.startApkByPackageAndClass(mContext,playurl,"");
|
||
|
|
}
|
||
|
|
}else{
|
||
|
|
Toast.makeText(mContext, "配置包名和类名为空", Toast.LENGTH_LONG).show();
|
||
|
|
}
|
||
|
|
break;
|
||
|
|
// 无动作
|
||
|
|
case "7":
|
||
|
|
break;
|
||
|
|
case "8":
|
||
|
|
FilterActivity.start(mContext);
|
||
|
|
break;
|
||
|
|
default:
|
||
|
|
LogUtils.d("do nothing");
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|