Browse Source

no message

master
lh 8 years ago
parent
commit
2dc0088fa9
5 changed files with 191 additions and 150 deletions
  1. +42
    -0
      app/src/main/java/com/qhclh/ytzh/bean/ReceiverNewsBean.java
  2. +34
    -146
      app/src/main/java/com/qhclh/ytzh/index/JPInfoActivity.java
  3. +9
    -4
      app/src/main/java/com/qhclh/ytzh/index/MyBoradCReceiver.java
  4. +29
    -0
      app/src/main/res/layout/act_jpinfos.xml
  5. +77
    -0
      app/src/main/res/layout/view_jp.xml

+ 42
- 0
app/src/main/java/com/qhclh/ytzh/bean/ReceiverNewsBean.java View File

@ -0,0 +1,42 @@
package com.qhclh.ytzh.bean;
/**
* Created by 青花瓷 on 2018/2/6.
*/
public class ReceiverNewsBean {
/**
* TimeStamp : 1517884524
* Title : xitongxiaoxi
* Category : 01
*/
private long TimeStamp;
private String Title;
private String Category;
public long getTimeStamp() {
return TimeStamp;
}
public void setTimeStamp(long TimeStamp) {
this.TimeStamp = TimeStamp;
}
public String getTitle() {
return Title;
}
public void setTitle(String Title) {
this.Title = Title;
}
public String getCategory() {
return Category;
}
public void setCategory(String Category) {
this.Category = Category;
}
}

+ 34
- 146
app/src/main/java/com/qhclh/ytzh/index/JPInfoActivity.java View File

@ -2,6 +2,7 @@ package com.qhclh.ytzh.index;
import android.content.Intent; import android.content.Intent;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
@ -27,67 +28,15 @@ import butterknife.OnClick;
public class JPInfoActivity extends BaseActivity { public class JPInfoActivity extends BaseActivity {
@BindView(R.id.toolbar) @BindView(R.id.toolbar)
Toolbar mToolbar; 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;
@BindView(R.id.chickscan_pic)
ImageView chickscan_pic;
@BindView(R.id.chickscan_title)
TextView chickscan_title;
@BindView(R.id.chickscan_content)
TextView chickscan_content;
@BindView(R.id.chickscan_time)
TextView chickscan_time;
@BindView(R.id.chickscan_red)
TextView chickscan_red;
@BindView(R.id.killc_pic)
ImageView killc_pic;
@BindView(R.id.killc_title)
TextView killc_title;
@BindView(R.id.killc_content)
TextView killc_content;
@BindView(R.id.killc_time)
TextView killc_time;
@BindView(R.id.killc_red)
TextView killc_red;
@BindView(R.id.system_ll)
LinearLayout system_ll;
@BindView(R.id.warninginfo_ll)
LinearLayout warninginfo_ll;
@BindView(R.id.chickscan_ll)
LinearLayout chickscan_ll;
@BindView(R.id.killc_ll)
LinearLayout killc_ll;
private List<NewsBean> newsBeanListsystem; private List<NewsBean> newsBeanListsystem;
private List<NewsBean> newsBeanListwarning;
private List<NewsBean> newsBeanListchick;
private List<NewsBean> newsBeanListkillc;
@BindView(R.id.jpcontent)
LinearLayout jpcontent;
@Override @Override
protected int setLayoutId() { protected int setLayoutId() {
return R.layout.act_jpinfo;
return R.layout.act_jpinfos;
} }
@Override @Override
@ -110,102 +59,41 @@ public class JPInfoActivity extends BaseActivity {
} }
private ImageView system_pic;
private TextView system_title;
private TextView system_content;
private TextView system_time;
private TextView system_red;
private LinearLayout system_ll;
@Override @Override
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
newsBeanListsystem = DataSupport.select("id", "url", "title", "content", "time", "type","red").where("type = ?","01").order("time desc").find(NewsBean.class);
newsBeanListwarning = DataSupport.select("id", "url", "title", "content", "time", "type","red").where("type = ?","02").order("time desc").find(NewsBean.class);
newsBeanListchick = DataSupport.select("id", "url", "title", "content", "time", "type","red").where("type = ?","03").order("time desc").find(NewsBean.class);
newsBeanListkillc = DataSupport.select("id", "url", "title", "content", "time", "type","red").where("type = ?","04").order("time desc").find(NewsBean.class);
// System.out.println("aaa11++++++"+newsBeanListsystem.toString());
// System.out.println("aaa22++++++"+newsBeanListwarning.toString());
// System.out.println("aaa33++++++"+newsBeanListchick.toString());
// System.out.println("aaa44++++++"+newsBeanListkillc.toString());
if (newsBeanListsystem!=null && newsBeanListsystem.size()>0) {
Glide.with(this).load(newsBeanListsystem.get(0).getUrl()).placeholder(R.mipmap.ic_launcher_round).error(R.mipmap.ic_launcher_round).into(system_pic);
system_title.setText("系统提示");
system_content.setText(newsBeanListsystem.get(0).getContent());
system_time.setText(newsBeanListsystem.get(0).getTime());
if (newsBeanListsystem.get(0).getRed() == 1) {
system_red.setVisibility(View.VISIBLE);
}else {
system_red.setVisibility(View.INVISIBLE);
}
}else {
system_ll.setVisibility(View.GONE);
}
if (newsBeanListwarning!=null && newsBeanListwarning.size()>0) {
Glide.with(this).load(newsBeanListwarning.get(0).getUrl()).placeholder(R.mipmap.ic_launcher_round).error(R.mipmap.ic_launcher_round).into(warninginfo_pic);
warninginfo_title.setText("预警提示");
warninginfo_content.setText(newsBeanListwarning.get(0).getContent());
warninginfo_time.setText(newsBeanListwarning.get(0).getTime());
if (newsBeanListwarning.get(0).getRed() == 1) {
warninginfo_red.setVisibility(View.VISIBLE);
}else {
warninginfo_red.setVisibility(View.INVISIBLE);
}
}else {
warninginfo_ll.setVisibility(View.GONE);
}
if (newsBeanListchick!=null && newsBeanListchick.size()>0) {
Glide.with(this).load(newsBeanListchick.get(0).getUrl()).placeholder(R.mipmap.ic_launcher_round).error(R.mipmap.ic_launcher_round).into(chickscan_pic);
chickscan_title.setText("鸡苗扫码推送");
chickscan_content.setText(newsBeanListchick.get(0).getContent());
chickscan_time.setText(newsBeanListchick.get(0).getTime());
if (newsBeanListchick.get(0).getRed() == 1) {
chickscan_red.setVisibility(View.VISIBLE);
}else {
chickscan_red.setVisibility(View.INVISIBLE);
}
}else {
chickscan_ll.setVisibility(View.GONE);
}
newsBeanListsystem = DataSupport.select("id", "url", "title", "content", "time", "type","red").order("time desc").find(NewsBean.class);
if (newsBeanListkillc!=null && newsBeanListkillc.size()>0) {
Glide.with(this).load(newsBeanListkillc.get(0).getUrl()).placeholder(R.mipmap.ic_launcher_round).error(R.mipmap.ic_launcher_round).into(killc_pic);
killc_title.setText("屠宰单");
killc_content.setText(newsBeanListkillc.get(0).getContent());
killc_time.setText(newsBeanListkillc.get(0).getTime());
if (newsBeanListkillc.get(0).getRed() == 1) {
killc_red.setVisibility(View.VISIBLE);
}else {
killc_red.setVisibility(View.INVISIBLE);
System.out.println("aaa++++++++++"+newsBeanListsystem.toString());
if (newsBeanListsystem!=null && newsBeanListsystem.size()>0) {
for (int i=0;i<newsBeanListsystem.size();i++) {
View view = LayoutInflater.from(this).inflate(R.layout.view_jp, null);
system_pic = view.findViewById(R.id.system_pic);
system_title = view.findViewById(R.id.system_title);
system_content = view.findViewById(R.id.system_content);
system_time = view.findViewById(R.id.system_time);
system_red = view.findViewById(R.id.system_red);
system_ll = view.findViewById(R.id.system_ll);
// Glide.with(this).load(newsBeanListsystem.get(0).getUrl()).placeholder(R.mipmap.ic_launcher_round).error(R.mipmap.ic_launcher_round).into(system_pic);
system_title.setText(newsBeanListsystem.get(i).getTitle());
system_content.setText(newsBeanListsystem.get(i).getContent());
system_time.setText(newsBeanListsystem.get(i).getTime());
if (newsBeanListsystem.get(i).getRed() == 1) {
system_red.setVisibility(View.VISIBLE);
} else {
system_red.setVisibility(View.INVISIBLE);
}
jpcontent.addView(view);
} }
}else {
killc_ll.setVisibility(View.GONE);
} }
}
private Intent intent;
@OnClick({R.id.system_ll, R.id.warninginfo_ll, R.id.chickscan_ll,R.id.killc_ll})
public void onClick(View view) {
intent = new Intent(JPInfoActivity.this, WarningActivity.class);
switch (view.getId()) {
///< 系统消息
case R.id.system_ll: {
intent.putExtra("type","01");
break;
}
///< 预警消息
case R.id.warninginfo_ll: {
intent.putExtra("type","02");
break;
}
///< 扫描消息
case R.id.chickscan_ll: {
intent.putExtra("type","03");
break;
}
///< 屠宰消息
case R.id.killc_ll: {
intent.putExtra("type","04");
break;
}
}
startActivity(intent);
} }
} }

+ 9
- 4
app/src/main/java/com/qhclh/ytzh/index/MyBoradCReceiver.java View File

@ -6,7 +6,9 @@ import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.text.TextUtils; import android.text.TextUtils;
import com.google.gson.Gson;
import com.qhclh.ytzh.bean.NewsBean; import com.qhclh.ytzh.bean.NewsBean;
import com.qhclh.ytzh.bean.ReceiverNewsBean;
import com.qhclh.ytzh.utils.DateTimeUtil; import com.qhclh.ytzh.utils.DateTimeUtil;
import org.json.JSONException; import org.json.JSONException;
@ -36,19 +38,22 @@ public class MyBoradCReceiver extends BroadcastReceiver {
String title = bundle.getString(JPushInterface.EXTRA_NOTIFICATION_TITLE); String title = bundle.getString(JPushInterface.EXTRA_NOTIFICATION_TITLE);
String content = bundle.getString(JPushInterface.EXTRA_ALERT); String content = bundle.getString(JPushInterface.EXTRA_ALERT);
String typetime = bundle.getString(JPushInterface.EXTRA_EXTRA); String typetime = bundle.getString(JPushInterface.EXTRA_EXTRA);
System.out.println("aaa++ttt+++++"+title);
System.out.println("aaa++ccc+++++"+content);
System.out.println("aaa++ttt+++++"+typetime);
if (!JPushInterface.ACTION_NOTIFICATION_OPENED.equals(intent.getAction())) { if (!JPushInterface.ACTION_NOTIFICATION_OPENED.equals(intent.getAction())) {
if ((title != null && !"".equals(title)) && (content != null && !"".equals(content)) && (typetime != null && !"".equals(typetime))) {
NewsBean newsBean = new NewsBean(); NewsBean newsBean = new NewsBean();
newsBean.setTitle(title); newsBean.setTitle(title);
newsBean.setContent(content); newsBean.setContent(content);
newsBean.setTime(DateTimeUtil.getDateToString(Long.parseLong(System.currentTimeMillis() + "")));
newsBean.setType("01");
Gson gson = new Gson();
ReceiverNewsBean data = gson.fromJson(typetime,ReceiverNewsBean.class);
newsBean.setTime(DateTimeUtil.getDateToString(data.getTimeStamp()));
newsBean.setType(data.getCategory());
newsBean.setRed(1); newsBean.setRed(1);
newsBean.save(); newsBean.save();
// ContentValues values = new ContentValues(); // ContentValues values = new ContentValues();
// values.put("flag", 1); // values.put("flag", 1);
// DataSupport.updateAll(FalgBean.class, values); // DataSupport.updateAll(FalgBean.class, values);
}
} }
} }
// } // }


+ 29
- 0
app/src/main/res/layout/act_jpinfos.xml View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/greyf4f4f4"
android:orientation="vertical">
<include layout="@layout/include_tool_bar"/>
<ScrollView
android:scrollbars="none"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="vertical"
android:background="@color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/jpcontent"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
</ScrollView>
</LinearLayout>

+ 77
- 0
app/src/main/res/layout/view_jp.xml View File

@ -0,0 +1,77 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="@+id/system_ll"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:orientation="horizontal"
android:padding="@dimen/dp_10">
<ImageView
android:id="@+id/system_pic"
android:layout_width="60dp"
android:layout_height="60dp"
android:background="@drawable/shape_bg"
android:padding="@dimen/dp_2"
android:scaleType="fitXY"
android:visibility="gone" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/dp_5"
android:orientation="vertical">
<TextView
android:id="@+id/system_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/black303030"
android:textSize="@dimen/text_size_18" />
<TextView
android:id="@+id/system_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:ellipsize="end"
android:maxEms="6"
android:maxLines="1"
android:textColor="@color/grey888888"
android:textSize="@dimen/text_size_16" />
</LinearLayout>
<View
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_weight="1" />
<TextView
android:id="@+id/system_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textColor="@color/grey888888"
android:textSize="@dimen/text_size_14" />
<TextView
android:id="@+id/system_red"
android:layout_width="@dimen/dp_8"
android:layout_height="@dimen/dp_8"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/dp_5"
android:background="@drawable/shape_red"
android:visibility="invisible" />
</LinearLayout>
<include layout="@layout/include_line" />
</LinearLayout>

Loading…
Cancel
Save