修改分享框界面,适配点击操作
This commit is contained in:
@@ -41,6 +41,9 @@ class ShareVoiceCmdReceiver : BroadcastReceiver() {
|
||||
"交通事故"->{
|
||||
UploadHelper.upload(context, TYPE_ACCIDENT)
|
||||
}
|
||||
"施工"->{
|
||||
UploadHelper.upload(context, TYPE_ROAD_CONSTRUCTION)
|
||||
}
|
||||
}
|
||||
}
|
||||
VOICE_CMD_PUB_ROAD_CONDITION->{
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
package com.mogo.module.share.adapter
|
||||
|
||||
import android.content.Context
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.mogo.module.share.R
|
||||
import com.mogo.module.share.bean.ShareBtn
|
||||
import com.mogo.module.share.listener.OnShareBtnClickListener
|
||||
import com.mogo.utils.glide.GlideApp
|
||||
import com.mogo.utils.logger.Logger
|
||||
import kotlinx.android.synthetic.main.item_share_btn.view.*
|
||||
|
||||
class ShareBtnAdapter(val context: Context): RecyclerView.Adapter<ShareBtnAdapter.ShareViewHolder>() {
|
||||
private val TAG = "ShareBtnAdapter"
|
||||
|
||||
private val btnList = ArrayList<ShareBtn>()
|
||||
|
||||
var onShareBtnClickListener:OnShareBtnClickListener? = null
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ShareViewHolder {
|
||||
return ShareViewHolder(LayoutInflater.from(context).inflate(R.layout.item_share_btn, parent, false))
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
return btnList.size
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: ShareViewHolder, position: Int) {
|
||||
holder.bindData(btnList[position])
|
||||
}
|
||||
|
||||
fun setShareBtnList(btns:List<ShareBtn>){
|
||||
btnList.clear()
|
||||
btnList.addAll(btns)
|
||||
Logger.d(TAG, "setShareBtnList: $btnList")
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
inner class ShareViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView){
|
||||
init {
|
||||
itemView.setOnClickListener {
|
||||
onShareBtnClickListener?.onShareBtnClick(btnList[adapterPosition])
|
||||
}
|
||||
}
|
||||
fun bindData(shareBtn: ShareBtn) = with(itemView) {
|
||||
tvShareContent.text = shareBtn.content
|
||||
GlideApp.with(context).load(shareBtn.iconRes).into(ivShareIcon)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package com.mogo.module.share.bean
|
||||
|
||||
/**
|
||||
* 分享按钮内容封装
|
||||
*
|
||||
* @param icon 分享按钮图标资源,暂时用不到,默认为空,以后如果引入服务端配置按钮,图片资源可以用这个参数
|
||||
* @param iconRes 分享按钮图标本地资源id,默认是-1
|
||||
*/
|
||||
data class ShareBtn(var type: String, var icon: String = "", var iconRes: Int = -1, var content: String)
|
||||
@@ -37,4 +37,5 @@ public class ShareConstants {
|
||||
public static final String TYPE_STAGNANT_WATER = "10008";
|
||||
public static final String TYPE_ROAD_ICY = "10011";
|
||||
public static final String TYPE_DENSE_FOG = "10010";
|
||||
public static final String TYPE_ROAD_CONSTRUCTION = "10006";
|
||||
}
|
||||
|
||||
@@ -12,17 +12,12 @@ import android.view.WindowManager;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.module.common.utils.CarSeries;
|
||||
import com.mogo.module.share.R;
|
||||
import com.mogo.module.share.ShareControl;
|
||||
import com.mogo.module.share.adapter.ShareBtnAdapter;
|
||||
import com.mogo.module.share.bean.ShareBtn;
|
||||
import com.mogo.module.share.constant.ShareConstants;
|
||||
import com.mogo.module.share.listener.OnShareBtnClickListener;
|
||||
import com.mogo.module.share.manager.ISeekHelpListener;
|
||||
import com.mogo.module.share.manager.SeekHelpManager;
|
||||
import com.mogo.module.share.manager.UploadHelper;
|
||||
@@ -33,11 +28,7 @@ import com.mogo.service.statusmanager.IMogoStatusManager;
|
||||
import com.mogo.utils.WindowUtils;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@@ -53,24 +44,22 @@ public class LaucherShareDialog implements View.OnClickListener {
|
||||
|
||||
private boolean isShown = false;
|
||||
|
||||
// private TextView tvBlock;
|
||||
// private TextView tvTrafficCheck;
|
||||
// private TextView tvClosure;
|
||||
// private TextView tvNeedHelp;
|
||||
//
|
||||
// private TextView tvAccident;
|
||||
// private TextView tvRealTimeTraffic;
|
||||
// private TextView tvStagnantWater;
|
||||
// private TextView tvRoadIcy;
|
||||
// private TextView tvDenseFog;
|
||||
private TextView tvBlock;
|
||||
private TextView tvTrafficCheck;
|
||||
private TextView tvClosure;
|
||||
private TextView tvNeedHelp;
|
||||
|
||||
private TextView tvAccident;
|
||||
private TextView tvRealTimeTraffic;
|
||||
private TextView tvStagnantWater;
|
||||
private TextView tvRoadIcy;
|
||||
private TextView tvDenseFog;
|
||||
private TextView tvConstruction;
|
||||
|
||||
private Context mContext;
|
||||
private IMogoAnalytics mAnalytics;
|
||||
private IMogoStatusManager mStatusManager;
|
||||
private IMogoServiceApis mApis;
|
||||
private RecyclerView rvShareBtnContainer;
|
||||
private ShareBtnAdapter adapter;
|
||||
|
||||
|
||||
private WindowManager windowManager;
|
||||
|
||||
@@ -93,101 +82,86 @@ public class LaucherShareDialog implements View.OnClickListener {
|
||||
});
|
||||
|
||||
|
||||
rvShareBtnContainer = body.findViewById(R.id.rvShareBtnContainer);
|
||||
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(mContext,RecyclerView.HORIZONTAL,false);
|
||||
rvShareBtnContainer.setLayoutManager(linearLayoutManager);
|
||||
adapter = new ShareBtnAdapter(mContext);
|
||||
rvShareBtnContainer.setAdapter(adapter);
|
||||
tvBlock = body.findViewById(R.id.tvBlock);
|
||||
tvTrafficCheck = body.findViewById(R.id.tvTrafficCheck);
|
||||
tvClosure = body.findViewById(R.id.tvClosure);
|
||||
tvNeedHelp = body.findViewById(R.id.tvSeekHelp);
|
||||
|
||||
// tvBlock = body.findViewById(R.id.tvBlock);
|
||||
// tvTrafficCheck = body.findViewById(R.id.tvTrafficCheck);
|
||||
// tvClosure = body.findViewById(R.id.tvClosure);
|
||||
// tvNeedHelp = body.findViewById(R.id.tvNeedHelp);
|
||||
tvAccident = body.findViewById(R.id.tvAccident);
|
||||
tvRealTimeTraffic = body.findViewById(R.id.tvRealTimeTraffic);
|
||||
tvStagnantWater = body.findViewById(R.id.tvStagnantWater);
|
||||
tvRoadIcy = body.findViewById(R.id.tvRoadIcy);
|
||||
tvDenseFog = body.findViewById(R.id.tvDenseFog);
|
||||
tvConstruction = body.findViewById(R.id.tvConstruction);
|
||||
}
|
||||
|
||||
|
||||
private void initListener() {
|
||||
adapter.setOnShareBtnClickListener(new OnShareBtnClickListener() {
|
||||
@Override
|
||||
public void onShareBtnClick(@NotNull ShareBtn shareBtn) {
|
||||
Logger.d(TAG,"分享按钮点击: "+shareBtn);
|
||||
traceData("1");
|
||||
if (ShareConstants.TYPE_SEEK_HELP.equalsIgnoreCase(shareBtn.getType())) {
|
||||
// 点击发起求助
|
||||
SeekHelpManager.INSTANCE.seekHelp(mContext,seekListener,true);
|
||||
}else{
|
||||
sendShareReceiver(shareBtn.getType());
|
||||
dismiss();
|
||||
}
|
||||
}
|
||||
});
|
||||
tvBlock.setOnClickListener(this);
|
||||
tvNeedHelp.setOnClickListener(this);
|
||||
tvTrafficCheck.setOnClickListener(this);
|
||||
tvClosure.setOnClickListener(this);
|
||||
|
||||
// tvBlock.setOnClickListener(this);
|
||||
// tvNeedHelp.setOnClickListener(this);
|
||||
// tvTrafficCheck.setOnClickListener(this);
|
||||
// tvClosure.setOnClickListener(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化默认的分享按钮
|
||||
*/
|
||||
private void initShareBtn(){
|
||||
List<ShareBtn> btns = new ArrayList<>();
|
||||
ShareBtn btn = new ShareBtn(ShareConstants.TYPE_BLOCK, "", R.drawable.share_block_up, "上报拥堵");
|
||||
btns.add(btn);
|
||||
btn = new ShareBtn(ShareConstants.TYPE_TRAFFIC_CHECK, "", R.drawable.share_traffic_check, "上报交通检查");
|
||||
btns.add(btn);
|
||||
btn = new ShareBtn(ShareConstants.TYPE_CLOSURE, "", R.drawable.share_road_closure, "上报封路");
|
||||
btns.add(btn);
|
||||
btn = new ShareBtn(ShareConstants.TYPE_ACCIDENT, "", R.drawable.share_seek_help, "上报事故");
|
||||
btns.add(btn);
|
||||
btn = new ShareBtn(ShareConstants.TYPE_REAL_TIME_TRAFFIC, "", R.drawable.share_seek_help, "实时路况");
|
||||
btns.add(btn);
|
||||
btn = new ShareBtn(ShareConstants.TYPE_SEEK_HELP, "", R.drawable.share_seek_help, "发起求助");
|
||||
btns.add(btn);
|
||||
btn = new ShareBtn(ShareConstants.TYPE_STAGNANT_WATER, "", R.drawable.share_seek_help, "道路积水");
|
||||
btns.add(btn);
|
||||
btn = new ShareBtn(ShareConstants.TYPE_ROAD_ICY, "", R.drawable.share_seek_help, "道路结冰");
|
||||
btns.add(btn);
|
||||
btn = new ShareBtn(ShareConstants.TYPE_DENSE_FOG, "", R.drawable.share_seek_help, "浓雾");
|
||||
btns.add(btn);
|
||||
adapter.setShareBtnList(btns);
|
||||
tvAccident.setOnClickListener(this);
|
||||
tvRealTimeTraffic.setOnClickListener(this);
|
||||
tvStagnantWater.setOnClickListener(this);
|
||||
tvRoadIcy.setOnClickListener(this);
|
||||
tvDenseFog.setOnClickListener(this);
|
||||
tvConstruction.setOnClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
int id = view.getId();
|
||||
Logger.d(TAG, "onClick: " + id);
|
||||
// if (id == R.id.tvBlock) {
|
||||
// //拥堵
|
||||
// traceTanluData("1");
|
||||
// sendShareReceiver("1");
|
||||
// traceTypeData("1");
|
||||
// dismiss();
|
||||
// } else if (id == R.id.oil_price_layout) {
|
||||
// // 分享油价,入口被屏蔽了
|
||||
// traceData("1");
|
||||
// Intent intent = new Intent();
|
||||
// intent.setData(Uri.parse("freshthing://com.zhidao.fresh.things/shareOilPrice"));
|
||||
// mContext.startActivity(intent);
|
||||
// traceTypeData("2");
|
||||
// dismiss();
|
||||
// } else if (id == R.id.tvTrafficCheck) {
|
||||
// //交通检查
|
||||
// traceData("1");
|
||||
// sendShareReceiver("2");
|
||||
// traceTypeData("3");
|
||||
// dismiss();
|
||||
// } else if (id == R.id.tvClosure) {
|
||||
// //封路
|
||||
// traceData("1");
|
||||
// sendShareReceiver("3");
|
||||
// traceTypeData("4");
|
||||
// dismiss();
|
||||
// } else if (id == R.id.tvNeedHelp) {
|
||||
// // 故障求助
|
||||
// SeekHelpManager.INSTANCE.seekHelp(mContext,seekListener,true);
|
||||
// }
|
||||
if (id == R.id.tvBlock) {
|
||||
//拥堵
|
||||
traceTanluData("1");
|
||||
sendShareReceiver("1");
|
||||
traceTypeData("1");
|
||||
dismiss();
|
||||
} else if (id == R.id.oil_price_layout) {
|
||||
// 分享油价,入口被屏蔽了
|
||||
traceData("1");
|
||||
Intent intent = new Intent();
|
||||
intent.setData(Uri.parse("freshthing://com.zhidao.fresh.things/shareOilPrice"));
|
||||
mContext.startActivity(intent);
|
||||
traceTypeData("2");
|
||||
dismiss();
|
||||
} else if (id == R.id.tvTrafficCheck) {
|
||||
//交通检查
|
||||
traceData("1");
|
||||
sendShareReceiver("2");
|
||||
traceTypeData("3");
|
||||
dismiss();
|
||||
} else if (id == R.id.tvClosure) {
|
||||
//封路
|
||||
traceData("1");
|
||||
sendShareReceiver("3");
|
||||
traceTypeData("4");
|
||||
dismiss();
|
||||
} else if (id == R.id.tvSeekHelp) {
|
||||
// 故障求助
|
||||
SeekHelpManager.INSTANCE.seekHelp(mContext,seekListener,true);
|
||||
} else if (id == R.id.tvAccident) {
|
||||
// 事故
|
||||
sendShareReceiver(ShareConstants.TYPE_ACCIDENT);
|
||||
} else if (id == R.id.tvConstruction) {
|
||||
// 道路施工
|
||||
sendShareReceiver(ShareConstants.TYPE_ROAD_CONSTRUCTION);
|
||||
} else if (id == R.id.tvRealTimeTraffic) {
|
||||
// 实时路况
|
||||
sendShareReceiver(ShareConstants.TYPE_REAL_TIME_TRAFFIC);
|
||||
} else if (id == R.id.tvStagnantWater) {
|
||||
// 道路积水
|
||||
sendShareReceiver(ShareConstants.TYPE_STAGNANT_WATER);
|
||||
} else if (id == R.id.tvRoadIcy) {
|
||||
// 道路结冰
|
||||
sendShareReceiver(ShareConstants.TYPE_ROAD_ICY);
|
||||
} else if (id == R.id.tvDenseFog) {
|
||||
// 浓雾
|
||||
sendShareReceiver(ShareConstants.TYPE_DENSE_FOG);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -273,7 +247,6 @@ public class LaucherShareDialog implements View.OnClickListener {
|
||||
layoutParams.y = 0;
|
||||
initView();
|
||||
initListener();
|
||||
initShareBtn();
|
||||
windowManager.addView(body, layoutParams);
|
||||
isShown = true;
|
||||
}
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
package com.mogo.module.share.listener
|
||||
|
||||
import com.mogo.module.share.bean.ShareBtn
|
||||
|
||||
interface OnShareBtnClickListener {
|
||||
fun onShareBtnClick(shareBtn: ShareBtn)
|
||||
}
|
||||
Reference in New Issue
Block a user