diff --git a/common/src/main/res/values-zh/strings.xml b/common/src/main/res/values-zh/strings.xml index b4627cfe7..a8b57e1b0 100644 --- a/common/src/main/res/values-zh/strings.xml +++ b/common/src/main/res/values-zh/strings.xml @@ -1545,5 +1545,6 @@ 違規原因: 處罰內容: 處罰時間: + 處罰通知 diff --git a/common/src/main/res/values/colors.xml b/common/src/main/res/values/colors.xml index d0ad06807..5fe3b1b9b 100644 --- a/common/src/main/res/values/colors.xml +++ b/common/src/main/res/values/colors.xml @@ -85,4 +85,6 @@ #FFF6F6F6 #F4F4F4 + #555555 + #525252 diff --git a/common/src/main/res/values/strings.xml b/common/src/main/res/values/strings.xml index 979a76d34..2e4a23c3b 100644 --- a/common/src/main/res/values/strings.xml +++ b/common/src/main/res/values/strings.xml @@ -1554,4 +1554,5 @@ Violation reasons: Penalty content: Penalty time: + Punishment Notice diff --git a/live/src/main/AndroidManifest.xml b/live/src/main/AndroidManifest.xml index 4603df43e..c7c8a66b3 100644 --- a/live/src/main/AndroidManifest.xml +++ b/live/src/main/AndroidManifest.xml @@ -1,7 +1,6 @@ + xmlns:tools="http://schemas.android.com/tools"> @@ -132,6 +131,10 @@ + \ No newline at end of file diff --git a/live/src/main/java/com/yunbao/live/activity/PunishActivity.java b/live/src/main/java/com/yunbao/live/activity/PunishActivity.java new file mode 100644 index 000000000..b750b9c11 --- /dev/null +++ b/live/src/main/java/com/yunbao/live/activity/PunishActivity.java @@ -0,0 +1,78 @@ +package com.yunbao.live.activity; + +import androidx.recyclerview.widget.LinearLayoutManager; + +import com.alibaba.fastjson.JSON; +import com.yunbao.common.activity.AbsActivity; +import com.yunbao.common.adapter.RefreshAdapter; +import com.yunbao.common.custom.CommonRefreshView; +import com.yunbao.common.http.HttpCallback; +import com.yunbao.live.R; +import com.yunbao.live.adapter.PunishAdapter; +import com.yunbao.live.bean.PunishBean; +import com.yunbao.live.http.ImHttpUtil; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +//处罚通知单 +public class PunishActivity extends AbsActivity { + + private CommonRefreshView mRefreshView; + private PunishAdapter adapter; + private List mData = new ArrayList<>(); + + @Override + protected int getLayoutId() { + return R.layout.activity_punish; + } + + @Override + protected void main() { + super.main(); + findViewById(R.id.btn_back).setOnClickListener(v -> finish()); + mRefreshView = findViewById(R.id.refreshView); + mRefreshView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false)); + adapter = new PunishAdapter(this, mData); + + mRefreshView.setEmptyLayoutId(R.layout.activity_punish_no_data); + mRefreshView.setDataHelper(new CommonRefreshView.DataHelper() { + @Override + public RefreshAdapter getAdapter() { + return adapter; + } + + @Override + public void loadData(int p, HttpCallback callback) { + ImHttpUtil.getPenalizeList(p, callback); + } + + @Override + public List processData(String[] info) { + return JSON.parseArray(Arrays.toString(info), PunishBean.class); + } + + @Override + public void onRefreshSuccess(List list, int listCount) { + + } + + @Override + public void onRefreshFailure() { + + } + + @Override + public void onLoadMoreSuccess(List loadItemList, int loadItemCount) { + + } + + @Override + public void onLoadMoreFailure() { + + } + }); + mRefreshView.initData(); + } +} diff --git a/live/src/main/java/com/yunbao/live/activity/SystemMessageActivity.java b/live/src/main/java/com/yunbao/live/activity/SystemMessageActivity.java index 4ba054ea5..ffed237b0 100644 --- a/live/src/main/java/com/yunbao/live/activity/SystemMessageActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/SystemMessageActivity.java @@ -5,19 +5,18 @@ import android.content.Intent; import android.util.Log; import android.view.View; import android.view.ViewGroup; +import android.widget.TextView; import com.yunbao.common.Constants; import com.yunbao.common.activity.AbsActivity; import com.yunbao.common.activity.SelectImageActivity; import com.yunbao.common.bean.ImageEntity; -import com.yunbao.common.bean.UserBean; -import com.yunbao.common.interfaces.CommonCallback; +import com.yunbao.common.http.HttpCallback; import com.yunbao.live.R; -import com.yunbao.live.bean.SystemMessageBean; +import com.yunbao.live.http.ImHttpUtil; import com.yunbao.live.views.SystemMessageViewHolder; -import org.greenrobot.eventbus.Subscribe; -import org.greenrobot.eventbus.ThreadMode; +import org.json.JSONObject; import java.util.ArrayList; import java.util.Date; @@ -36,6 +35,7 @@ public class SystemMessageActivity extends AbsActivity { public static String type;//-1=单聊消息,1=系统消息,2=互动消息,3=猜你喜欢,-2=web页面打开 public static String type2 = "0";//判断是否注册监听 public static String nowUid, nowTitle, mowHeadImg; + private TextView punish, punishNotice;//处罚通知 public static void forward(Context context, String type, String uid, String title, String headImg) { context.startActivity(new Intent(context, SystemMessageActivity.class).putExtra("type", type).putExtra("uid", uid).putExtra("title", title).putExtra("headImg", headImg)); @@ -72,6 +72,14 @@ public class SystemMessageActivity extends AbsActivity { // mSystemMessageViewHolder.loadData(); // } init(); + punish = findViewById(R.id.tv_sys_msg_punish); + punish.setVisibility(View.VISIBLE); + punishNotice = findViewById(R.id.tv_sys_msg_punish_notice); + punish.setOnClickListener(v -> { + Intent intent = new Intent(getApplicationContext(), PunishActivity.class); + startActivity(intent); + punishNotice.setVisibility(View.GONE); + }); mSystemMessageViewHolder.btn_back.setOnClickListener(new View.OnClickListener() { @Override @@ -79,6 +87,25 @@ public class SystemMessageActivity extends AbsActivity { finish(); } }); + ImHttpUtil.getPenalizeStatus(new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + if (code == 0 && info != null && info.length > 0) { + try { + JSONObject ob = new JSONObject(info[0]); + if (ob.getInt("unread_num") > 0) { + punishNotice.setVisibility(View.VISIBLE); + } else { + punishNotice.setVisibility(View.GONE); + } + } catch (Exception e) { + punishNotice.setVisibility(View.GONE); + } + } else { + punishNotice.setVisibility(View.GONE); + } + } + }); } //更新新消息 diff --git a/live/src/main/java/com/yunbao/live/adapter/PunishAdapter.java b/live/src/main/java/com/yunbao/live/adapter/PunishAdapter.java new file mode 100644 index 000000000..0762d4ac0 --- /dev/null +++ b/live/src/main/java/com/yunbao/live/adapter/PunishAdapter.java @@ -0,0 +1,56 @@ +package com.yunbao.live.adapter; + +import android.content.Context; +import android.text.TextUtils; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.yunbao.common.adapter.RefreshAdapter; +import com.yunbao.live.R; +import com.yunbao.live.bean.PunishBean; + +import java.util.List; + +public class PunishAdapter extends RefreshAdapter { + + public PunishAdapter(Context context, List list) { + super(context, list); + } + + @NonNull + @Override + public PunishHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + return new PunishHolder(mInflater.inflate(R.layout.activity_punish_item, parent, false)); + } + + @Override + public void onBindViewHolder(@NonNull RecyclerView.ViewHolder h, int position) { + PunishHolder holder = (PunishHolder) h; + PunishBean item = mList.get(position); + holder.title.setText(item.title); + if (TextUtils.isEmpty(item.content)) { + holder.line.setVisibility(View.GONE); + } else { + holder.line.setVisibility(View.VISIBLE); + } + holder.value.setText(item.content); + } + + class PunishHolder extends RecyclerView.ViewHolder { + + public TextView title, value; + public View line; + + public PunishHolder(@NonNull View itemView) { + super(itemView); + title = itemView.findViewById(R.id.tv_punish_title); + value = itemView.findViewById(R.id.tv_punish_value); + line = itemView.findViewById(R.id.view_punish_line); + } + } + +} diff --git a/live/src/main/java/com/yunbao/live/adapter/SystemMessageNewAdapter.java b/live/src/main/java/com/yunbao/live/adapter/SystemMessageNewAdapter.java index 7d6d76ebf..533b2221e 100644 --- a/live/src/main/java/com/yunbao/live/adapter/SystemMessageNewAdapter.java +++ b/live/src/main/java/com/yunbao/live/adapter/SystemMessageNewAdapter.java @@ -1,6 +1,5 @@ package com.yunbao.live.adapter; -import android.app.Activity; import android.content.Context; import android.content.Intent; import android.text.TextUtils; @@ -20,7 +19,6 @@ import com.yunbao.common.bean.IMLoginModel; import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.manager.IMLoginManager; -import com.yunbao.common.utils.L; import com.yunbao.common.utils.RouteUtil; import com.yunbao.common.utils.WordUtil; import com.yunbao.live.R; @@ -77,9 +75,13 @@ public class SystemMessageNewAdapter extends RefreshAdapter { } void setData(SystemMessageBean bean, int position) { - SimpleDateFormat sdf = new SimpleDateFormat("MM-dd HH:mm"); - Date currenTimeZone = new Date(Long.parseLong(bean.getAddtime() + "000")); - messageTime.setText(sdf.format(currenTimeZone)); + if (!TextUtils.isEmpty(bean.getAddtime())) { + SimpleDateFormat sdf = new SimpleDateFormat("MM-dd HH:mm"); + Date currenTimeZone = new Date(Long.parseLong(bean.getAddtime() + "000")); + messageTime.setText(sdf.format(currenTimeZone)); + } else { + messageTime.setText(""); + } messageContext.setText(bean.getContent()); title.setText(String.valueOf(bean.getTitle())); diff --git a/live/src/main/java/com/yunbao/live/bean/PunishBean.java b/live/src/main/java/com/yunbao/live/bean/PunishBean.java new file mode 100644 index 000000000..1a3e24371 --- /dev/null +++ b/live/src/main/java/com/yunbao/live/bean/PunishBean.java @@ -0,0 +1,9 @@ +package com.yunbao.live.bean; + +//处罚消息的对象 +public class PunishBean { + + public String id; + public String title, content; + +} diff --git a/live/src/main/java/com/yunbao/live/http/ImHttpUtil.java b/live/src/main/java/com/yunbao/live/http/ImHttpUtil.java index ab3dfc4ab..dfa65a318 100644 --- a/live/src/main/java/com/yunbao/live/http/ImHttpUtil.java +++ b/live/src/main/java/com/yunbao/live/http/ImHttpUtil.java @@ -1,6 +1,5 @@ package com.yunbao.live.http; -import com.yunbao.common.CommonAppConfig; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.HttpClient; @@ -110,4 +109,22 @@ public class ImHttpUtil { .params("message_id", msgid) .execute(callback); } + + /** + * 处罚通知是否有未读消息 + */ + public static void getPenalizeStatus(HttpCallback callback) { + HttpClient.getInstance().get("Message.penalizeStatus", "Message.penalizeStatus") + .execute(callback); + } + + /** + * 处罚通知列表 + */ + public static void getPenalizeList(int p, HttpCallback callback) { + HttpClient.getInstance().get("Message.penalizeList", "Message.penalizeList") + .params("p", p) + .execute(callback); + } + } diff --git a/live/src/main/res/drawable/bg_bk_ffffff_555555_8dp.xml b/live/src/main/res/drawable/bg_bk_ffffff_555555_8dp.xml new file mode 100644 index 000000000..8587b86d6 --- /dev/null +++ b/live/src/main/res/drawable/bg_bk_ffffff_555555_8dp.xml @@ -0,0 +1,15 @@ + + + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/drawable/bg_ffae04_6dp.xml b/live/src/main/res/drawable/bg_ffae04_6dp.xml new file mode 100644 index 000000000..ba445586f --- /dev/null +++ b/live/src/main/res/drawable/bg_ffae04_6dp.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/drawable/bg_red_yuan.xml b/live/src/main/res/drawable/bg_red_yuan.xml new file mode 100644 index 000000000..c92ab1608 --- /dev/null +++ b/live/src/main/res/drawable/bg_red_yuan.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/layout/activity_punish.xml b/live/src/main/res/layout/activity_punish.xml new file mode 100644 index 000000000..ce7063919 --- /dev/null +++ b/live/src/main/res/layout/activity_punish.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/layout/activity_punish_item.xml b/live/src/main/res/layout/activity_punish_item.xml new file mode 100644 index 000000000..cbddb792b --- /dev/null +++ b/live/src/main/res/layout/activity_punish_item.xml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/layout/activity_punish_no_data.xml b/live/src/main/res/layout/activity_punish_no_data.xml new file mode 100644 index 000000000..61127c9ab --- /dev/null +++ b/live/src/main/res/layout/activity_punish_no_data.xml @@ -0,0 +1,28 @@ + + + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/layout/view_sys_msg.xml b/live/src/main/res/layout/view_sys_msg.xml index 6813f4f5a..cc30fbe79 100644 --- a/live/src/main/res/layout/view_sys_msg.xml +++ b/live/src/main/res/layout/view_sys_msg.xml @@ -1,5 +1,6 @@ + android:tint="@color/textColor" + tools:ignore="UseAppTint" /> + + + + + + android:background="@color/gray_ededed" + android:visibility="gone" />