|
|
@ -1,16 +1,19 @@ |
|
|
package com.qhclh.ytzh.index; |
|
|
package com.qhclh.ytzh.index; |
|
|
|
|
|
|
|
|
import android.content.BroadcastReceiver; |
|
|
import android.content.BroadcastReceiver; |
|
|
|
|
|
import android.content.ContentValues; |
|
|
import android.content.Context; |
|
|
import android.content.Context; |
|
|
import android.content.Intent; |
|
|
import android.content.Intent; |
|
|
import android.os.Bundle; |
|
|
import android.os.Bundle; |
|
|
import android.text.TextUtils; |
|
|
import android.text.TextUtils; |
|
|
|
|
|
|
|
|
|
|
|
import com.qhclh.ytzh.bean.FalgBean; |
|
|
import com.qhclh.ytzh.bean.NewsBean; |
|
|
import com.qhclh.ytzh.bean.NewsBean; |
|
|
import com.qhclh.ytzh.utils.DateTimeUtil; |
|
|
import com.qhclh.ytzh.utils.DateTimeUtil; |
|
|
|
|
|
|
|
|
import org.json.JSONException; |
|
|
import org.json.JSONException; |
|
|
import org.json.JSONObject; |
|
|
import org.json.JSONObject; |
|
|
|
|
|
import org.litepal.crud.DataSupport; |
|
|
|
|
|
|
|
|
import java.util.Iterator; |
|
|
import java.util.Iterator; |
|
|
|
|
|
|
|
|
@ -30,19 +33,25 @@ public class MyBoradCReceiver extends BroadcastReceiver { |
|
|
// Log.d(TAG, "[MyReceiver] onReceive - " + intent.getAction() + ", extras: " + printBundle(bundle)); |
|
|
// Log.d(TAG, "[MyReceiver] onReceive - " + intent.getAction() + ", extras: " + printBundle(bundle)); |
|
|
// System.out.println("aaa1111111111++++++"+bundle.getString(JPushInterface.EXTRA_EXTRA)); |
|
|
// System.out.println("aaa1111111111++++++"+bundle.getString(JPushInterface.EXTRA_EXTRA)); |
|
|
// System.out.println("aaa2222222222++++++"+bundle.getString(JPushInterface.EXTRA_ALERT)); |
|
|
// System.out.println("aaa2222222222++++++"+bundle.getString(JPushInterface.EXTRA_ALERT)); |
|
|
if (bundle!=null) { |
|
|
|
|
|
String title = bundle.getString(JPushInterface.EXTRA_NOTIFICATION_TITLE); |
|
|
|
|
|
String content = bundle.getString(JPushInterface.EXTRA_ALERT); |
|
|
|
|
|
String typetime = bundle.getString(JPushInterface.EXTRA_EXTRA); |
|
|
|
|
|
if ((title!=null && !"".equals(title)) && (content!=null && !"".equals(content)) && (typetime!=null && !"".equals(typetime))) { |
|
|
|
|
|
NewsBean newsBean = new NewsBean(); |
|
|
|
|
|
newsBean.setTitle(title); |
|
|
|
|
|
newsBean.setContent(content); |
|
|
|
|
|
newsBean.setUrl("https://www.baidu.com/img/bd_logo1.png"); |
|
|
|
|
|
newsBean.setTime(DateTimeUtil.getDateToString(Long.parseLong(System.currentTimeMillis() + ""))); |
|
|
|
|
|
newsBean.setType("01"); |
|
|
|
|
|
newsBean.setRed(1); |
|
|
|
|
|
newsBean.save(); |
|
|
|
|
|
|
|
|
int flag = DataSupport.findAll(FalgBean.class).get(0).getFlag(); |
|
|
|
|
|
if (flag ==0) { |
|
|
|
|
|
if (bundle != null) { |
|
|
|
|
|
String title = bundle.getString(JPushInterface.EXTRA_NOTIFICATION_TITLE); |
|
|
|
|
|
String content = bundle.getString(JPushInterface.EXTRA_ALERT); |
|
|
|
|
|
String typetime = bundle.getString(JPushInterface.EXTRA_EXTRA); |
|
|
|
|
|
if ((title != null && !"".equals(title)) && (content != null && !"".equals(content)) && (typetime != null && !"".equals(typetime))) { |
|
|
|
|
|
NewsBean newsBean = new NewsBean(); |
|
|
|
|
|
newsBean.setTitle(title); |
|
|
|
|
|
newsBean.setContent(content); |
|
|
|
|
|
newsBean.setUrl("https://www.baidu.com/img/bd_logo1.png"); |
|
|
|
|
|
newsBean.setTime(DateTimeUtil.getDateToString(Long.parseLong(System.currentTimeMillis() + ""))); |
|
|
|
|
|
newsBean.setType("01"); |
|
|
|
|
|
newsBean.setRed(1); |
|
|
|
|
|
newsBean.save(); |
|
|
|
|
|
ContentValues values = new ContentValues(); |
|
|
|
|
|
values.put("flag", 1); |
|
|
|
|
|
DataSupport.updateAll(FalgBean.class, values); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|