Browse Source

no message

master
lh 8 years ago
parent
commit
1b3a35fe4b
6 changed files with 73 additions and 17 deletions
  1. +1
    -1
      app/src/main/assets/litepal.xml
  2. +15
    -5
      app/src/main/java/com/qhclh/ytzh/bean/NewsBean.java
  3. +2
    -10
      app/src/main/java/com/qhclh/ytzh/index/GetjpActivity.java
  4. +31
    -1
      app/src/main/java/com/qhclh/ytzh/index/JPInfoActivity.java
  5. +17
    -0
      app/src/main/java/com/qhclh/ytzh/index/MyBoradCReceiver.java
  6. +7
    -0
      app/src/main/java/com/qhclh/ytzh/utils/DateTimeUtil.java

+ 1
- 1
app/src/main/assets/litepal.xml View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<litepal>
<dbname value="BWP_ytzh.db"></dbname>
<version value="2"></version>
<version value="3"></version>
<list>
<mapping class="com.qhclh.ytzh.bean.NewsBean"></mapping>


+ 15
- 5
app/src/main/java/com/qhclh/ytzh/bean/NewsBean.java View File

@ -12,9 +12,18 @@ public class NewsBean extends DataSupport{
private String title;
private String content;
private String time;
private int type;
private String type;
///< 0点过 1没点过
private int red;
// public NewsBean(int id, String url, String title, String content, String time) {
public int getRed() {
return red;
}
public void setRed(int red) {
this.red = red;
}
// public NewsBean(int id, String url, String title, String content, String time) {
// this.id = id;
// this.url = url;
// this.title = title;
@ -23,11 +32,11 @@ public class NewsBean extends DataSupport{
// }
public int getType() {
public String getType() {
return type;
}
public void setType(int type) {
public void setType(String type) {
this.type = type;
}
@ -79,7 +88,8 @@ public class NewsBean extends DataSupport{
", title='" + title + '\'' +
", content='" + content + '\'' +
", time='" + time + '\'' +
", type=" + type +
", type='" + type + '\'' +
", red=" + red +
'}';
}
}

+ 2
- 10
app/src/main/java/com/qhclh/ytzh/index/GetjpActivity.java View File

@ -8,8 +8,7 @@ import android.widget.TextView;
import com.qhclh.ytzh.R;
import com.qhclh.ytzh.base.BaseActivity;
import com.qhclh.ytzh.bean.NewsBean;
import com.qhclh.ytzh.utils.DateTimeUtil;
import butterknife.BindView;
import cn.jpush.android.api.JPushInterface;
@ -50,14 +49,7 @@ public class GetjpActivity extends BaseActivity{
content = bundle.getString(JPushInterface.EXTRA_ALERT);
}
System.out.println("aaa++++++++"+bundle.getString(JPushInterface.EXTRA_EXTRA));
tv_getjp.setText("Title : " + title + " " + "Content : " + content);
NewsBean newsBean = new NewsBean();
newsBean.setTitle(title);
newsBean.setContent(content);
newsBean.setUrl("https://www.baidu.com/img/bd_logo1.png");
newsBean.setTime(DateTimeUtil.getYMDHMS1());
newsBean.save();
tv_getjp.setText("消息 : " + content);
}
}


+ 31
- 1
app/src/main/java/com/qhclh/ytzh/index/JPInfoActivity.java View File

@ -2,9 +2,16 @@ package com.qhclh.ytzh.index;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.qhclh.ytzh.R;
import com.qhclh.ytzh.base.BaseActivity;
import com.qhclh.ytzh.bean.NewsBean;
import org.litepal.crud.DataSupport;
import java.util.List;
import butterknife.BindView;
@ -15,6 +22,29 @@ import butterknife.BindView;
public class JPInfoActivity extends BaseActivity {
@BindView(R.id.toolbar)
Toolbar mToolbar;
@BindView(R.id.system_pic)
ImageView system_pic;
@BindView(R.id.system_title)
TextView system_title;
@BindView(R.id.system_content)
TextView system_content;
@BindView(R.id.system_time)
TextView system_time;
@BindView(R.id.system_red)
TextView system_red;
@BindView(R.id.warninginfo_pic)
ImageView warninginfo_pic;
@BindView(R.id.warninginfo_title)
TextView warninginfo_title;
@BindView(R.id.warninginfo_content)
TextView warninginfo_content;
@BindView(R.id.warninginfo_time)
TextView warninginfo_time;
@BindView(R.id.warninginfo_red)
TextView warninginfo_red;
private List<NewsBean> newsBeanList;
@Override
protected int setLayoutId() {
return R.layout.act_jpinfo;
@ -32,7 +62,7 @@ public class JPInfoActivity extends BaseActivity {
@Override
protected void initData() {
newsBeanList = DataSupport.select("id", "url", "title", "content", "time", "type").order("time desc").find(NewsBean.class);
}
@Override


+ 17
- 0
app/src/main/java/com/qhclh/ytzh/index/MyBoradCReceiver.java View File

@ -6,6 +6,9 @@ import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import com.qhclh.ytzh.bean.NewsBean;
import com.qhclh.ytzh.utils.DateTimeUtil;
import org.json.JSONException;
import org.json.JSONObject;
@ -25,6 +28,20 @@ public class MyBoradCReceiver extends BroadcastReceiver {
try {
Bundle bundle = intent.getExtras();
// Log.d(TAG, "[MyReceiver] onReceive - " + intent.getAction() + ", extras: " + printBundle(bundle));
System.out.println("aaa1111111111++++++"+bundle.getString(JPushInterface.EXTRA_EXTRA));
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);
NewsBean newsBean = new NewsBean();
newsBean.setTitle(title);
newsBean.setContent(content);
newsBean.setUrl("https://www.baidu.com/img/bd_logo1.png");
newsBean.setTime(DateTimeUtil.getDateToString(1514336108));
newsBean.setType("系统消息");
newsBean.save();
}
if (JPushInterface.ACTION_REGISTRATION_ID.equals(intent.getAction())) {
String regId = bundle.getString(JPushInterface.EXTRA_REGISTRATION_ID);


+ 7
- 0
app/src/main/java/com/qhclh/ytzh/utils/DateTimeUtil.java View File

@ -131,4 +131,11 @@ public final class DateTimeUtil {
return days;
}
/*时间戳转换成字符窜*/
public static String getDateToString(long time) {
Date d = new Date(time);
SimpleDateFormat sf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
return sf.format(d);
}
}

Loading…
Cancel
Save