Commit fc0ad32ac60e7ebe4db3c7823facf5e66d884fc2
1 parent
bc58b7bb
Exists in
yxb_dev
and in
1 other branch
no message
Showing
8 changed files
with
37 additions
and
29 deletions
 
Show diff stats
app/src/main/AndroidManifest.xml
| ... | ... | @@ -154,6 +154,7 @@ | 
| 154 | 154 | android:windowSoftInputMode="adjustPan|stateAlwaysHidden" /> | 
| 155 | 155 | <activity | 
| 156 | 156 | android:name=".ui.MainActivity" | 
| 157 | + android:launchMode="singleTask" | |
| 157 | 158 | android:screenOrientation="portrait" /> | 
| 158 | 159 | <activity | 
| 159 | 160 | android:name=".ui.activity.ChildDetialActivity" | ... | ... | 
app/src/main/java/com/shunzhi/parent/bean/message/PHMessage.java
| ... | ... | @@ -65,6 +65,7 @@ public class PHMessage { | 
| 65 | 65 | return dao.queryBuilder() | 
| 66 | 66 | .where(PHMessageDao.Properties.SessionType.in( | 
| 67 | 67 | PHMessageSession.sessionType_homework, | 
| 68 | + PHMessageSession.sessionType_kaoqin, | |
| 68 | 69 | PHMessageSession.sessionType_notification//新加通知类型请在此处加上,否则会导致计数不准确 | 
| 69 | 70 | )) | 
| 70 | 71 | .count(); | ... | ... | 
app/src/main/java/com/shunzhi/parent/bean/message/PHMessageSession.java
| ... | ... | @@ -2,12 +2,14 @@ package com.shunzhi.parent.bean.message; | 
| 2 | 2 | |
| 3 | 3 | import com.shunzhi.parent.AppConfig; | 
| 4 | 4 | import com.shunzhi.parent.AppContext; | 
| 5 | + | |
| 5 | 6 | import org.greenrobot.greendao.annotation.Entity; | 
| 6 | -import org.greenrobot.greendao.annotation.Id; | |
| 7 | -import java.util.Date; | |
| 8 | 7 | import org.greenrobot.greendao.annotation.Generated; | 
| 8 | +import org.greenrobot.greendao.annotation.Id; | |
| 9 | 9 | import org.greenrobot.greendao.annotation.Keep; | 
| 10 | 10 | |
| 11 | +import java.util.Date; | |
| 12 | + | |
| 11 | 13 | /** | 
| 12 | 14 | * Created by 10501 on 2018/3/20. | 
| 13 | 15 | */ | 
| ... | ... | @@ -29,6 +31,8 @@ public class PHMessageSession { | 
| 29 | 31 | public static final int sessionType_notification = 101; | 
| 30 | 32 | @Keep | 
| 31 | 33 | public static final int sessionType_homework = 102; | 
| 34 | + @Keep | |
| 35 | + public static final int sessionType_kaoqin = 103; | |
| 32 | 36 | |
| 33 | 37 | @Generated(hash = 1156938953) | 
| 34 | 38 | public PHMessageSession(Long id, String sessionId, String sessionText, String sessionName, | 
| ... | ... | @@ -60,6 +64,10 @@ public class PHMessageSession { | 
| 60 | 64 | session.setSessionId(AppConfig.getAppConfig(AppContext.getInstance()).get(AppConfig.USER_ID) + "_homework_" + System.currentTimeMillis()); | 
| 61 | 65 | session.setSessionName("作业通知"); | 
| 62 | 66 | break; | 
| 67 | + case sessionType_kaoqin: | |
| 68 | + session.setSessionId(AppConfig.getAppConfig(AppContext.getInstance()).get(AppConfig.USER_ID) + "_kaoqin_" + System.currentTimeMillis()); | |
| 69 | + session.setSessionName("考勤通知"); | |
| 70 | + break; | |
| 63 | 71 | } | 
| 64 | 72 | AppContext.getInstance().getDaoSession().getPHMessageSessionDao().insert(session); | 
| 65 | 73 | } | ... | ... | 
app/src/main/java/com/shunzhi/parent/manager/MessageManager.java
| ... | ... | @@ -99,7 +99,7 @@ public class MessageManager { | 
| 99 | 99 | } | 
| 100 | 100 | |
| 101 | 101 | private void onCustomNotificationReceive(CustomNotification customNotification) { | 
| 102 | - Timber.d("sss-==" + customNotification.getSessionId()); | |
| 102 | + Timber.d("sss-==" + customNotification.getContent()); | |
| 103 | 103 | try { | 
| 104 | 104 | JSONObject json = new JSONObject(customNotification.getContent()); | 
| 105 | 105 | Timber.d("sss-==" + json.toString()); | 
| ... | ... | @@ -124,20 +124,21 @@ public class MessageManager { | 
| 124 | 124 | notifyNotification(uuid, id, "收到一条作业通知"); | 
| 125 | 125 | } else if ("attend".equals(type)) { | 
| 126 | 126 | //考勤 | 
| 127 | - PHMessageSession session = PHMessageSession.findAndCreateSession(PHMessageSession.sessionType_homework, true); | |
| 127 | + PHMessageSession session = PHMessageSession.findAndCreateSession(PHMessageSession.sessionType_kaoqin, true); | |
| 128 | 128 | session.setSessionName("考勤通知"); | 
| 129 | 129 | session.setDate(new Date(customNotification.getTime())); | 
| 130 | 130 | session.setSessionText(json.optString("title")); | 
| 131 | -// ToastUtils.showToast(json.optString("title")+"uuid="+uuid); | |
| 132 | 131 | |
| 133 | 132 | PHMessage message = new PHMessage(); | 
| 134 | 133 | PHMessageDao messageDao = AppContext.getInstance().getDaoSession().getPHMessageDao(); | 
| 135 | 134 | message.setDate(new Date(customNotification.getTime())); | 
| 136 | 135 | message.setMessageId(uuid); | 
| 137 | 136 | message.setSessionId(session.getSessionId()); | 
| 137 | + message.setMessageText("不能为空的字段。。。"); | |
| 138 | 138 | message.setExValue(customNotification.getContent()); | 
| 139 | 139 | message.setSessionType(session.getSessionType()); | 
| 140 | 140 | Long id = messageDao.insert(message); | 
| 141 | + Log.e("aaaaa","------"+id); | |
| 141 | 142 | notifyNotification(uuid, id, "收到一条考勤通知"); | 
| 142 | 143 | } | 
| 143 | 144 | } catch (JSONException e) { | 
| ... | ... | @@ -146,8 +147,9 @@ public class MessageManager { | 
| 146 | 147 | } | 
| 147 | 148 | |
| 148 | 149 | public void notifyNotification(String uuid, long msgLongId, String text) { | 
| 149 | - if (!isNotiNotification) | |
| 150 | + if (!isNotiNotification) { | |
| 150 | 151 | return; | 
| 152 | + } | |
| 151 | 153 | int notificationCount = (int) PHMessage.findUnreadNotificationCount();//XSTMessage.findUnreadNotificationCount(); | 
| 152 | 154 | boolean setBadgerSuccessful = ShortcutBadger.applyCount(AppContext.getInstance(), notificationCount); | 
| 153 | 155 | Timber.i("----== notificationCount : %s ,setBadgerSuccessful : %s", notificationCount, setBadgerSuccessful); | ... | ... | 
app/src/main/java/com/shunzhi/parent/ui/MainActivity.java
| ... | ... | @@ -15,9 +15,7 @@ import com.shunzhi.parent.AppContext; | 
| 15 | 15 | import com.shunzhi.parent.R; | 
| 16 | 16 | import com.shunzhi.parent.bean.message.PHMessage; | 
| 17 | 17 | import com.shunzhi.parent.bean.message.PHMessageDao; | 
| 18 | -import com.shunzhi.parent.bean.message.PHMessageSession; | |
| 19 | 18 | import com.shunzhi.parent.manager.MessageManager; | 
| 20 | -import com.shunzhi.parent.ui.fragment.CePingFragment; | |
| 21 | 19 | import com.shunzhi.parent.ui.fragment.ConsultFragment; | 
| 22 | 20 | import com.shunzhi.parent.ui.fragment.MineFragment; | 
| 23 | 21 | import com.shunzhi.parent.ui.fragment.ReportFragment; | 
| ... | ... | @@ -36,6 +34,7 @@ public class MainActivity extends BaseCompatActivity implements PermissionUtils. | 
| 36 | 34 | |
| 37 | 35 | Fragment[] fragments = null; | 
| 38 | 36 | |
| 37 | + | |
| 39 | 38 | private int CEPING_INDEX = 0, CONSULT_INDEX = 0, REPORT_INDEX = 1, MINE_INDEX = 2; | 
| 40 | 39 | |
| 41 | 40 | FragmentTransaction fragmentTransaction = null; | 
| ... | ... | @@ -43,10 +42,8 @@ public class MainActivity extends BaseCompatActivity implements PermissionUtils. | 
| 43 | 42 | @Override | 
| 44 | 43 | protected void initView(Bundle savedInstanceState) { | 
| 45 | 44 | |
| 46 | - | |
| 47 | 45 | PermissionUtils.requestMultiPermissions(this, this); | 
| 48 | 46 | bottom_navigationView = findViewById(R.id.bottom_navigationView); | 
| 49 | - | |
| 50 | 47 | BottomNavigationViewHelper.disableShiftMode(bottom_navigationView); | 
| 51 | 48 | |
| 52 | 49 | bottom_navigationView.setSelectedItemId(R.id.bottom_navigationView); | 
| ... | ... | @@ -73,6 +70,8 @@ public class MainActivity extends BaseCompatActivity implements PermissionUtils. | 
| 73 | 70 | }); | 
| 74 | 71 | |
| 75 | 72 | initFragments(); | 
| 73 | + handIntent(getIntent()); | |
| 74 | + | |
| 76 | 75 | } | 
| 77 | 76 | |
| 78 | 77 | private void initFragments() { | 
| ... | ... | @@ -113,7 +112,7 @@ public class MainActivity extends BaseCompatActivity implements PermissionUtils. | 
| 113 | 112 | @Override | 
| 114 | 113 | protected void onNewIntent(Intent intent) { | 
| 115 | 114 | super.onNewIntent(intent); | 
| 116 | -// handIntent(intent); | |
| 115 | + handIntent(intent); | |
| 117 | 116 | } | 
| 118 | 117 | |
| 119 | 118 | private void handIntent(Intent intent) { | 
| ... | ... | @@ -121,8 +120,8 @@ public class MainActivity extends BaseCompatActivity implements PermissionUtils. | 
| 121 | 120 | PHMessageDao dao = AppContext.getInstance().getDaoSession().getPHMessageDao(); | 
| 122 | 121 | PHMessage message = dao.queryBuilder().where(PHMessageDao.Properties.Id.eq(msgLongId)).unique(); | 
| 123 | 122 | if (message == null) return; | 
| 124 | - if (message.getSessionType() == PHMessageSession.sessionType_homework) { | |
| 125 | - //TODO 跳转 | |
| 123 | + if(msgLongId!=-1){ | |
| 124 | + showFragment(2); | |
| 126 | 125 | } | 
| 127 | 126 | } | 
| 128 | 127 | ... | ... | 
app/src/main/java/com/shunzhi/parent/ui/activity/message/MesageActivity.java
| 1 | 1 | package com.shunzhi.parent.ui.activity.message; | 
| 2 | 2 | |
| 3 | -import android.support.v7.app.AppCompatActivity; | |
| 4 | 3 | import android.os.Bundle; | 
| 5 | 4 | import android.support.v7.widget.LinearLayoutManager; | 
| 6 | 5 | import android.support.v7.widget.RecyclerView; | 
| ... | ... | @@ -14,9 +13,9 @@ import com.share.mvpsdk.base.activity.BaseCompatActivity; | 
| 14 | 13 | import com.share.mvpsdk.base.adapter.BaseRecyclerViewAdapter; | 
| 15 | 14 | import com.share.mvpsdk.base.adapter.BaseRecyclerViewHolder; | 
| 16 | 15 | import com.share.mvpsdk.utils.DateUtils; | 
| 16 | +import com.shunzhi.parent.AppContext; | |
| 17 | 17 | import com.shunzhi.parent.R; | 
| 18 | 18 | import com.shunzhi.parent.bean.message.PHMessage; | 
| 19 | -import com.shunzhi.parent.bean.message.PHMessageSession; | |
| 20 | 19 | |
| 21 | 20 | import java.util.ArrayList; | 
| 22 | 21 | import java.util.List; | 
| ... | ... | @@ -52,6 +51,9 @@ public class MesageActivity extends BaseCompatActivity implements View.OnClickLi | 
| 52 | 51 | |
| 53 | 52 | if (null==mEssageAdapter)mEssageAdapter=new MEssageAdapter(); | 
| 54 | 53 | if (null==recyclerView.getAdapter())recyclerView.setAdapter(mEssageAdapter); | 
| 54 | + | |
| 55 | + | |
| 56 | + phMessages= AppContext.getInstance().getDaoSession().getPHMessageDao().loadAll(); | |
| 55 | 57 | mEssageAdapter.addAll(phMessages); | 
| 56 | 58 | recyclerView.setAdapter(mEssageAdapter); | 
| 57 | 59 | ... | ... | 
app/src/main/java/com/shunzhi/parent/ui/fragment/StartFragment.java
| 1 | 1 | package com.shunzhi.parent.ui.fragment; | 
| 2 | 2 | |
| 3 | -import android.media.MediaMetadataRetriever; | |
| 4 | 3 | import android.os.Bundle; | 
| 5 | 4 | import android.os.CountDownTimer; | 
| 6 | 5 | import android.support.annotation.NonNull; | 
| 7 | 6 | import android.support.annotation.Nullable; | 
| 8 | 7 | import android.text.TextUtils; | 
| 9 | -import android.util.Log; | |
| 10 | 8 | import android.view.View; | 
| 11 | 9 | import android.widget.ImageView; | 
| 12 | 10 | import android.widget.TextView; | 
| ... | ... | @@ -29,9 +27,6 @@ import com.stx.xhb.xbanner.XBanner; | 
| 29 | 27 | import java.util.ArrayList; | 
| 30 | 28 | import java.util.List; | 
| 31 | 29 | |
| 32 | -import cn.jzvd.JZVideoPlayerStandard; | |
| 33 | -import timber.log.Timber; | |
| 34 | - | |
| 35 | 30 | public class StartFragment extends BaseMVPCompatFragment<ConsultContract.ConsultPresenter, ConsultContract.IConsultModel> | 
| 36 | 31 | implements ConsultContract.IConsultView { | 
| 37 | 32 | |
| ... | ... | @@ -102,8 +97,9 @@ public class StartFragment extends BaseMVPCompatFragment<ConsultContract.Consult | 
| 102 | 97 | return new ConsultPresenter(); | 
| 103 | 98 | } | 
| 104 | 99 | |
| 100 | + | |
| 105 | 101 | @Override | 
| 106 | - public void showTools() { | |
| 102 | + public void showVote(int position) { | |
| 107 | 103 | |
| 108 | 104 | } | 
| 109 | 105 | ... | ... | 
app/src/main/java/com/shunzhi/parent/ui/service/BadgeIntentService.java
| ... | ... | @@ -7,9 +7,8 @@ import android.app.PendingIntent; | 
| 7 | 7 | import android.content.Context; | 
| 8 | 8 | import android.content.Intent; | 
| 9 | 9 | import android.os.Build; | 
| 10 | -import android.support.annotation.Nullable; | |
| 11 | 10 | import android.support.v4.app.NotificationCompat; | 
| 12 | -import android.text.TextUtils; | |
| 11 | +import android.util.Log; | |
| 13 | 12 | |
| 14 | 13 | import com.shunzhi.parent.AppConfig; | 
| 15 | 14 | import com.shunzhi.parent.AppContext; | 
| ... | ... | @@ -71,9 +70,10 @@ public class BadgeIntentService extends IntentService { | 
| 71 | 70 | //String uuid, long xstsid | 
| 72 | 71 | String uuid = intent.getStringExtra("uuid"); | 
| 73 | 72 | long xstsid = intent.getLongExtra("xstsid", -1); | 
| 74 | - if (xstsid == -1 || TextUtils.isEmpty(uuid)) | |
| 75 | - createIntentNotification(badgeCount, title, message); | |
| 76 | - if (xstsid != -1 && !TextUtils.isEmpty(uuid)) | |
| 73 | + Log.e("1234-===","uuid=="+uuid+"xstsid=="+xstsid); | |
| 74 | +// if (xstsid == -1 || TextUtils.isEmpty(uuid)) | |
| 75 | +// createIntentNotification(badgeCount, title, message); | |
| 76 | +// if (xstsid != -1 && !TextUtils.isEmpty(uuid)) | |
| 77 | 77 | createPendingIntentNotification(badgeCount, title, message, uuid, xstsid); | 
| 78 | 78 | |
| 79 | 79 | } | 
| ... | ... | @@ -89,13 +89,12 @@ public class BadgeIntentService extends IntentService { | 
| 89 | 89 | mNotificationManager.cancel(notificationId); | 
| 90 | 90 | |
| 91 | 91 | notificationId++; | 
| 92 | - | |
| 93 | 92 | Notification.Builder builder = new Notification.Builder(getApplicationContext()) | 
| 94 | 93 | .setContentTitle(title) | 
| 95 | 94 | .setContentText(message) | 
| 96 | 95 | .setSmallIcon(R.mipmap.ic_launcher); | 
| 97 | 96 | Notification notification = Build.VERSION.SDK_INT > 15 ? builder.build() : builder.getNotification(); | 
| 98 | - ShortcutBadger.applyNotification(getApplicationContext(), notification, badgeCount); | |
| 97 | + ShortcutBadger.applyNotification(getApplicationContext(), notification, badgeCount); | |
| 99 | 98 | if (mNotificationManager != null) | 
| 100 | 99 | mNotificationManager.notify(notificationId, notification); | 
| 101 | 100 | } | 
| ... | ... | @@ -104,7 +103,7 @@ public class BadgeIntentService extends IntentService { | 
| 104 | 103 | if (mNotificationManager == null) { | 
| 105 | 104 | mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); | 
| 106 | 105 | } | 
| 107 | - Intent resultIntent = new Intent(AppContext.getInstance(), MainActivity.class); | |
| 106 | + Intent resultIntent = new Intent(AppContext.getInstance(),MainActivity.class); | |
| 108 | 107 | resultIntent.putExtra("sid", xstsid); | 
| 109 | 108 | resultIntent.putExtra("uuid", uuid); | 
| 110 | 109 | mNotificationManager.cancel(notificationId); | ... | ... |