提交 e24665d5 authored 作者: lgd's avatar lgd

1.推送1.0,待确认

上级 21ae58f1
......@@ -70,13 +70,9 @@ dependencies {
//rxjava依赖
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
//沉浸式
implementation 'com.gyf.immersionbar:immersionbar:2.3.3'
// glide 依赖
implementation 'com.github.bumptech.glide:glide:4.11.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
//banner依赖
implementation 'com.youth.banner:banner:1.4.9'
//design库
implementation 'com.google.android.material:material:1.0.0-beta01'
//recyclerview
......
package com.wd.workoffice.bean.event;
/**
* author : flexible
* email : lgd19940421@163.com
* github: https://github.com/FlexibleXd
**/
public class NotifyEvent {
int type;// 0, 通知,1,是点击
String msgType;// approval 审批 notice 消息
public NotifyEvent(int type, String msgType) {
this.type = type;
this.msgType = msgType;
}
public int getType() {
return type;
}
public String getMsgType() {
return msgType;
}
}
......@@ -6,7 +6,12 @@ import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import com.wd.workoffice.bean.event.NotifyEvent;
import com.wd.workoffice.ui.activity.MainActivity;
import com.wd.workoffice.util.DataKeeper;
import com.wd.workoffice.util.UserKeeper;
import org.greenrobot.eventbus.EventBus;
import cn.jpush.android.api.JPushInterface;
......@@ -44,17 +49,20 @@ public class JPushReceive extends BroadcastReceiver {
Log.d(TAG, "[MyReceiver] 接收到推送下来的通知");
int notifactionId = bundle.getInt(JPushInterface.EXTRA_NOTIFICATION_ID);
Log.d(TAG, "[MyReceiver] 接收到推送下来的通知的ID: " + notifactionId);
//TODO 判断消息.审核无动作,消息维系按钮
DataKeeper.getInstance().keepMsgStatus(true);
EventBus.getDefault().post(new NotifyEvent(0,"notice"));
} else if (JPushInterface.ACTION_NOTIFICATION_OPENED.equals(intent.getAction())) {
Log.d(TAG, "[MyReceiver] 用户点击打开了通知");
//TODO 判断消息,审核跳转,消息无动作
//打开自定义的Activity
Intent i = new Intent(context, MainActivity.class);
i.putExtras(bundle);
//i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP );
context.startActivity(i);
EventBus.getDefault().post(new NotifyEvent(1,"approval"));
} else if (JPushInterface.ACTION_RICHPUSH_CALLBACK.equals(intent.getAction())) {
Log.d(TAG, "[MyReceiver] 用户收到到RICH PUSH CALLBACK: " + bundle.getString(JPushInterface.EXTRA_EXTRA));
//在这里根据 JPushInterface.EXTRA_EXTRA 的内容处理代码,比如打开新的Activity, 打开一个网页等..
......
......@@ -11,12 +11,15 @@ import android.widget.RelativeLayout;
import com.ashokvarma.bottomnavigation.BottomNavigationBar;
import com.ashokvarma.bottomnavigation.BottomNavigationItem;
import com.ashokvarma.bottomnavigation.ShapeBadgeItem;
import com.ashokvarma.bottomnavigation.TextBadgeItem;
import com.qmuiteam.qmui.util.QMUIStatusBarHelper;
import com.wd.workoffice.R;
import com.wd.workoffice.app.WorkBaseActivity;
import com.wd.workoffice.bean.event.MesLoginEvent;
import com.wd.workoffice.bean.event.NotifyEvent;
import com.wd.workoffice.bean.event.RefreshTokenEvent;
import com.wd.workoffice.ui.activity.bat.approval.WorkApprovalActivity;
import com.wd.workoffice.ui.activity.login.LoginActivity;
import com.wd.workoffice.ui.activity.mes.MesLoginActivity;
import com.wd.workoffice.ui.adapter.VpMainAdapter;
......@@ -25,6 +28,7 @@ import com.wd.workoffice.ui.fg.MesFragment;
import com.wd.workoffice.ui.fg.MsgFragment;
import com.wd.workoffice.ui.fg.MyFragment;
import com.wd.workoffice.ui.fg.WorkFragment;
import com.wd.workoffice.util.DataKeeper;
import com.wd.workoffice.util.UserKeeper;
import com.wd.workoffice.util.WorkUtils;
......@@ -54,8 +58,8 @@ public class MainActivity extends WorkBaseActivity implements BottomNavigationBa
private ArrayList<Fragment> fragments;
private FragmentManager fm;
private TextBadgeItem numberBadgeItem;
private int oldPosition;
private ShapeBadgeItem shapeBadgeItem;
// private MainActivityPresenter mainPresenter;
@Override
......@@ -71,10 +75,9 @@ public class MainActivity extends WorkBaseActivity implements BottomNavigationBa
bnbMainBottomBar.setMode(BottomNavigationBar.MODE_FIXED);
bnbMainBottomBar.setBackgroundStyle(BottomNavigationBar.BACKGROUND_STYLE_STATIC);
bnbMainBottomBar.setBackgroundColor(getResources().getColor(R.color.white));
// numberBadgeItem = new TextBadgeItem();
// numberBadgeItem.setBorderWidth(4)
// .setBackgroundColorResource(R.color.red)
// .setText("0");
shapeBadgeItem = new ShapeBadgeItem();
shapeBadgeItem.setShape(ShapeBadgeItem.SHAPE_OVAL);
shapeIsShow();
bnbMainBottomBar
.addItem(new BottomNavigationItem(R.mipmap.main_bat_choose, "首页").
setActiveColorResource(R.color.main_icon_select).
......@@ -87,7 +90,7 @@ public class MainActivity extends WorkBaseActivity implements BottomNavigationBa
setInactiveIconResource(R.mipmap.main_mes))
.addItem(new BottomNavigationItem(R.mipmap.main_msg_choose, "消息").
setActiveColorResource(R.color.main_icon_select).setInActiveColorResource(R.color.main_icon).
setInactiveIconResource(R.mipmap.main_msg))
setInactiveIconResource(R.mipmap.main_msg).setBadgeItem(shapeBadgeItem))
.addItem(new BottomNavigationItem(R.mipmap.main_my_choose, "我的")
.setActiveColorResource(R.color.main_icon_select).setInActiveColorResource(R.color.main_icon).
setInactiveIconResource(R.mipmap.main_my))
......@@ -104,6 +107,7 @@ public class MainActivity extends WorkBaseActivity implements BottomNavigationBa
// }
}
@Override
protected void initData() {
......@@ -158,6 +162,8 @@ public class MainActivity extends WorkBaseActivity implements BottomNavigationBa
startActivity(MesLoginActivity.class);
return;
}
DataKeeper.getInstance().keepMsgStatus(false);
shapeBadgeItem.hide(true);
}
oldPosition = position;
mainContent.setCurrentItem(position);
......@@ -197,7 +203,17 @@ public class MainActivity extends WorkBaseActivity implements BottomNavigationBa
super.onBackPressed();
}
}
/**
* 消息红点是否显示
*/
private void shapeIsShow() {
Boolean msgStatus = DataKeeper.getInstance().getMsgStatus();
if (msgStatus) {
shapeBadgeItem.show();
} else {
shapeBadgeItem.hide();
}
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void login(LoginEvent lg) {
if (!UserKeeper.getInstance().getMesLogin()) {
......@@ -220,4 +236,12 @@ public class MainActivity extends WorkBaseActivity implements BottomNavigationBa
}
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void notify(NotifyEvent event) {
if (event.getType() == 0) {
shapeIsShow();
}else {
startActivity(WorkApprovalActivity.class, "type", "2", "status", "0", "title", "待我审批");
}
}
}
......@@ -12,6 +12,8 @@ public class DataKeeper {
private SPUtils sp = SPUtils.getInstance("DataKeeper");
private final String MES_MENU_ID = "MES_MENU_ID";
private final String MES_MENU = "MES_MENU";
private final String MSG_STATUS = "MSG_STATUS";
private DataKeeper() {
}
......@@ -43,6 +45,24 @@ public class DataKeeper {
sp.put(MES_MENU, "");
}
/**
* 消息红点状态
*
* @param info
*/
public void keepMsgStatus(Boolean info) {
sp.put(MSG_STATUS, info);
}
public Boolean getMsgStatus() {
return sp.getBoolean(MSG_STATUS);
}
public void clearMsgStatus() {
sp.put(MSG_STATUS, false);
}
// /**
// * mes菜单id
// *
......@@ -62,5 +82,6 @@ public class DataKeeper {
public void clearAll() {
clearMenu();
clearMsgStatus();
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论