From 2fb92928740de78c35902ab1333ac74359e87585 Mon Sep 17 00:00:00 2001 From: lh <1209405678@qq.com> Date: Tue, 5 Dec 2017 13:21:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=9E=81=E5=85=89=E6=8E=A8?= =?UTF-8?q?=E9=80=81=EF=BC=8C=E5=85=88=E6=B3=A8=E9=87=8A=E5=90=AF=E5=8A=A8?= =?UTF-8?q?=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 36 ++-- app/src/main/AndroidManifest.xml | 164 +++++++++++++++++- .../com/qhclh/ytzh/home/MyApplication.java | 10 ++ .../main/java/com/qhclh/ytzh/home/RpcUrl.java | 2 + .../qhclh/ytzh/index/MyBoradCReceiver.java | 124 +++++++++++++ .../com/qhclh/ytzh/index/MyJPReceiver.java | 10 ++ .../com/qhclh/ytzh/index/TestActivity.java | 32 ++++ .../com/qhclh/ytzh/splash/SplashActivity.java | 4 +- .../ProductiondailyActivity.java | 103 ++++++++++- gradle.properties | 1 + 10 files changed, 467 insertions(+), 19 deletions(-) create mode 100644 app/src/main/java/com/qhclh/ytzh/index/MyBoradCReceiver.java create mode 100644 app/src/main/java/com/qhclh/ytzh/index/MyJPReceiver.java create mode 100644 app/src/main/java/com/qhclh/ytzh/index/TestActivity.java diff --git a/app/build.gradle b/app/build.gradle index 2f52849..dab57f5 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -12,6 +12,18 @@ android { versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + + ndk { + //选择要添加的对应cpu类型的.so库。 + abiFilters 'armeabi', 'armeabi-v7a', 'arm64-v8a' + // 还可以添加 'x86', 'x86_64', 'mips', 'mips64' + } + + manifestPlaceholders = [ + JPUSH_PKGNAME : applicationId, + JPUSH_APPKEY : "53d7a345ed1d408462447820", //JPush上注册的包名对应的appkey. + JPUSH_CHANNEL : "developer-default", //暂时填写默认值即可. + ] } aaptOptions.cruncherEnabled = false //禁止检查图片的合理性 aaptOptions.useNewCruncher = false @@ -28,37 +40,39 @@ dependencies { androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) - ///< 黄油刀 - ///< 图片加载 - ///< 广播 - ///< 友盟 - ///< 动态权限 - ///< 数据库 - ///< 二维码扫描 - ///< 轮播图 compile project(':jsonrpc') - ///< 图表工具 - ///< 时间选择器 compile 'com.android.support:appcompat-v7:26.+' + ///< 图片加载 compile 'com.github.bumptech.glide:glide:3.7.0' compile 'com.android.support:support-v4:26.0.0-alpha1' compile 'com.android.support:design:26.0.0-alpha1' + ///< 广播 compile 'org.greenrobot:eventbus:3.0.0' + ///< 友盟 compile 'com.umeng.analytics:analytics:latest.integration' + ///< 动态权限 compile 'pub.devrel:easypermissions:0.2.1' compile 'com.google.code.gson:gson:2.8.1' + ///< 数据库 compile 'org.litepal.android:core:1.3.0' + ///< 二维码扫描 compile 'com.journeyapps:zxing-android-embedded:3.5.0' compile 'com.google.zxing:core:3.3.0' + ///< 轮播图 compile 'com.youth.banner:banner:1.4.10' compile 'com.android.support:cardview-v7:26.0.0-alpha1' + ///< 图表工具 compile 'com.github.lecho:hellocharts-library:1.5.8@aar' + ///< 时间选择器 compile 'com.prolificinteractive:material-calendarview:1.4.0' compile 'com.android.support.constraint:constraint-layout:1.0.2' testCompile 'junit:junit:4.12' //相册选择 compile 'com.github.YancyYe:GalleryPick:1.2.1' - + ///< 黄油刀 compile 'com.jakewharton:butterknife:8.5.1' annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1' + + compile 'cn.jiguang.sdk:jpush:3.0.9' // 此处以JPush 3.0.9 版本为例。 + compile 'cn.jiguang.sdk:jcore:1.1.7' // 此处以JCore 1.1.7 版本为例。 } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index ee8a86f..fd23194 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -2,14 +2,35 @@ + + + + + + + + - + + + + + + + + + + + + @@ -42,9 +63,9 @@ - + + + @@ -102,6 +123,139 @@ android:label="@string/title_activity_mine_info" android:theme="@style/AppTheme" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/qhclh/ytzh/home/MyApplication.java b/app/src/main/java/com/qhclh/ytzh/home/MyApplication.java index 9e4fbb8..c62c2c5 100644 --- a/app/src/main/java/com/qhclh/ytzh/home/MyApplication.java +++ b/app/src/main/java/com/qhclh/ytzh/home/MyApplication.java @@ -9,8 +9,12 @@ import com.qhclh.ytzh.configs.ServerConfig; import org.forks.jsonrpc.RpcFacade; import org.litepal.LitePalApplication; +import java.util.LinkedHashSet; import java.util.LinkedList; import java.util.List; +import java.util.Set; + +import cn.jpush.android.api.JPushInterface; /** * Created by 青花瓷 on 2017/11/23. @@ -45,6 +49,12 @@ public class MyApplication extends LitePalApplication { ConfigUtil.Save(config); RpcFacade.init(this.getApplicationContext(),NAME); + JPushInterface.setDebugMode(true); + JPushInterface.init(this); + + Set setTags = new LinkedHashSet<>(); + setTags.add("aaa"); + JPushInterface.setTags(this,0,setTags); } public void exit() { diff --git a/app/src/main/java/com/qhclh/ytzh/home/RpcUrl.java b/app/src/main/java/com/qhclh/ytzh/home/RpcUrl.java index f9a30c9..5343002 100644 --- a/app/src/main/java/com/qhclh/ytzh/home/RpcUrl.java +++ b/app/src/main/java/com/qhclh/ytzh/home/RpcUrl.java @@ -10,6 +10,8 @@ public class RpcUrl { public static String BaseAppUrl = "http://221.1.97.114:86/B3/"; public static String DayProductRpc_Query = "/MainSystem/B3_ZhongHui/Rpcs/DayProductRpc/Query"; + public static String DayProductRpc_Query_canshu = "/MainSystem/B3_ZhongHui/Rpcs/DayProductRpc/Query"; + public static String DayProductRpc_Query_fanhui = "/MainSystem/B3_ZhongHui/Rpcs/DayProductRpc/Query"; public static String DayProductRpc_New = "/MainSystem/B3_ZhongHui/Rpcs/DayProductRpc/New"; public static String DayProductRpc_Insert = "/MainSystem/B3_ZhongHui/Rpcs/DayProductRpc/Insert"; diff --git a/app/src/main/java/com/qhclh/ytzh/index/MyBoradCReceiver.java b/app/src/main/java/com/qhclh/ytzh/index/MyBoradCReceiver.java new file mode 100644 index 0000000..7e3f816 --- /dev/null +++ b/app/src/main/java/com/qhclh/ytzh/index/MyBoradCReceiver.java @@ -0,0 +1,124 @@ +package com.qhclh.ytzh.index; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.os.Bundle; +import android.text.TextUtils; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.Iterator; + +import cn.jpush.android.api.JPushInterface; + +/** + * Created by 青花瓷 on 2017/11/27. + */ + +public class MyBoradCReceiver extends BroadcastReceiver { + private static final String TAG = "ytzh"; + + @Override + public void onReceive(Context context, Intent intent) { + try { + Bundle bundle = intent.getExtras(); +// Logger.d(TAG, "[MyReceiver] onReceive - " + intent.getAction() + ", extras: " + printBundle(bundle)); + + if (JPushInterface.ACTION_REGISTRATION_ID.equals(intent.getAction())) { + String regId = bundle.getString(JPushInterface.EXTRA_REGISTRATION_ID); +// Logger.d(TAG, "[MyReceiver] 接收Registration Id : " + regId); + //send the Registration Id to your server... + + } else if (JPushInterface.ACTION_MESSAGE_RECEIVED.equals(intent.getAction())) { +// Logger.d(TAG, "[MyReceiver] 接收到推送下来的自定义消息: " + bundle.getString(JPushInterface.EXTRA_MESSAGE)); +// processCustomMessage(context, bundle); + + } else if (JPushInterface.ACTION_NOTIFICATION_RECEIVED.equals(intent.getAction())) { +// Logger.d(TAG, "[MyReceiver] 接收到推送下来的通知"); + int notifactionId = bundle.getInt(JPushInterface.EXTRA_NOTIFICATION_ID); +// Logger.d(TAG, "[MyReceiver] 接收到推送下来的通知的ID: " + notifactionId); + + } else if (JPushInterface.ACTION_NOTIFICATION_OPENED.equals(intent.getAction())) { +// Logger.d(TAG, "[MyReceiver] 用户点击打开了通知"); + + //打开自定义的Activity + Intent i = new Intent(context, TestActivity.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); + + } else if (JPushInterface.ACTION_RICHPUSH_CALLBACK.equals(intent.getAction())) { +// Logger.d(TAG, "[MyReceiver] 用户收到到RICH PUSH CALLBACK: " + bundle.getString(JPushInterface.EXTRA_EXTRA)); + //在这里根据 JPushInterface.EXTRA_EXTRA 的内容处理代码,比如打开新的Activity, 打开一个网页等.. + + } else if(JPushInterface.ACTION_CONNECTION_CHANGE.equals(intent.getAction())) { + boolean connected = intent.getBooleanExtra(JPushInterface.EXTRA_CONNECTION_CHANGE, false); +// Logger.w(TAG, "[MyReceiver]" + intent.getAction() +" connected state change to "+connected); + } else { +// Logger.d(TAG, "[MyReceiver] Unhandled intent - " + intent.getAction()); + } + } catch (Exception e){ + + } + + } + + // 打印所有的 intent extra 数据 + private static String printBundle(Bundle bundle) { + StringBuilder sb = new StringBuilder(); + for (String key : bundle.keySet()) { + if (key.equals(JPushInterface.EXTRA_NOTIFICATION_ID)) { + sb.append("\nkey:" + key + ", value:" + bundle.getInt(key)); + }else if(key.equals(JPushInterface.EXTRA_CONNECTION_CHANGE)){ + sb.append("\nkey:" + key + ", value:" + bundle.getBoolean(key)); + } else if (key.equals(JPushInterface.EXTRA_EXTRA)) { + if (TextUtils.isEmpty(bundle.getString(JPushInterface.EXTRA_EXTRA))) { +// Logger.i(TAG, "This message has no Extra data"); + continue; + } + + try { + JSONObject json = new JSONObject(bundle.getString(JPushInterface.EXTRA_EXTRA)); + Iterator it = json.keys(); + + while (it.hasNext()) { + String myKey = it.next(); + sb.append("\nkey:" + key + ", value: [" + + myKey + " - " +json.optString(myKey) + "]"); + } + } catch (JSONException e) { +// Logger.e(TAG, "Get message extra JSON error!"); + } + + } else { + sb.append("\nkey:" + key + ", value:" + bundle.getString(key)); + } + } + return sb.toString(); + } + + //send msg to MainActivity +// private void processCustomMessage(Context context, Bundle bundle) { +// if (MainActivity.isForeground) { +// String message = bundle.getString(JPushInterface.EXTRA_MESSAGE); +// String extras = bundle.getString(JPushInterface.EXTRA_EXTRA); +// Intent msgIntent = new Intent(MainActivity.MESSAGE_RECEIVED_ACTION); +// msgIntent.putExtra(MainActivity.KEY_MESSAGE, message); +// if (!ExampleUtil.isEmpty(extras)) { +// try { +// JSONObject extraJson = new JSONObject(extras); +// if (extraJson.length() > 0) { +// msgIntent.putExtra(MainActivity.KEY_EXTRAS, extras); +// } +// } catch (JSONException e) { +// +// } +// +// } +// LocalBroadcastManager.getInstance(context).sendBroadcast(msgIntent); +// } +// } +} diff --git a/app/src/main/java/com/qhclh/ytzh/index/MyJPReceiver.java b/app/src/main/java/com/qhclh/ytzh/index/MyJPReceiver.java new file mode 100644 index 0000000..6047314 --- /dev/null +++ b/app/src/main/java/com/qhclh/ytzh/index/MyJPReceiver.java @@ -0,0 +1,10 @@ +package com.qhclh.ytzh.index; + +import cn.jpush.android.service.JPushMessageReceiver; + +/** + * Created by 青花瓷 on 2017/12/5. + */ + +public class MyJPReceiver extends JPushMessageReceiver { +} diff --git a/app/src/main/java/com/qhclh/ytzh/index/TestActivity.java b/app/src/main/java/com/qhclh/ytzh/index/TestActivity.java new file mode 100644 index 0000000..642376d --- /dev/null +++ b/app/src/main/java/com/qhclh/ytzh/index/TestActivity.java @@ -0,0 +1,32 @@ +package com.qhclh.ytzh.index; + +import android.app.Activity; +import android.content.Intent; +import android.os.Bundle; +import android.view.ViewGroup.LayoutParams; +import android.widget.TextView; + +import cn.jpush.android.api.JPushInterface; + +public class TestActivity extends Activity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + TextView tv = new TextView(this); + tv.setText("用户自定义打开的Activity"); + Intent intent = getIntent(); + if (null != intent) { + Bundle bundle = getIntent().getExtras(); + String title = null; + String content = null; + if(bundle!=null){ + title = bundle.getString(JPushInterface.EXTRA_NOTIFICATION_TITLE); + content = bundle.getString(JPushInterface.EXTRA_ALERT); + } + tv.setText("Title : " + title + " " + "Content : " + content); + } + addContentView(tv, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); + } + +} diff --git a/app/src/main/java/com/qhclh/ytzh/splash/SplashActivity.java b/app/src/main/java/com/qhclh/ytzh/splash/SplashActivity.java index 6850548..1c27305 100644 --- a/app/src/main/java/com/qhclh/ytzh/splash/SplashActivity.java +++ b/app/src/main/java/com/qhclh/ytzh/splash/SplashActivity.java @@ -7,7 +7,7 @@ import android.widget.LinearLayout; import com.qhclh.ytzh.R; import com.qhclh.ytzh.base.BaseActivity; -import com.qhclh.ytzh.home.MainActivity; +import com.qhclh.ytzh.login.LoginActivity; import butterknife.BindView; @@ -60,7 +60,7 @@ public class SplashActivity extends BaseActivity { } private void redirectTo() { - startActivity(new Intent(this, MainActivity.class)); + startActivity(new Intent(this, LoginActivity.class)); finish(); } } diff --git a/app/src/main/java/com/qhclh/ytzh/work/productiondaily/ProductiondailyActivity.java b/app/src/main/java/com/qhclh/ytzh/work/productiondaily/ProductiondailyActivity.java index 95ce2fc..c15cfab 100644 --- a/app/src/main/java/com/qhclh/ytzh/work/productiondaily/ProductiondailyActivity.java +++ b/app/src/main/java/com/qhclh/ytzh/work/productiondaily/ProductiondailyActivity.java @@ -1,6 +1,7 @@ package com.qhclh.ytzh.work.productiondaily; import android.content.Intent; +import android.support.v4.widget.SwipeRefreshLayout; import android.support.v7.widget.Toolbar; import android.view.Menu; import android.view.MenuItem; @@ -11,12 +12,20 @@ import android.widget.ListView; import com.qhclh.ytzh.R; import com.qhclh.ytzh.base.BaseActivity; import com.qhclh.ytzh.bean.ProductionDailyBean; +import com.qhclh.ytzh.home.RpcUrl; +import com.qhclh.ytzh.tasks.ViewOnClickTask; import com.qhclh.ytzh.ui.CalendarDialogFragment; +import com.qhclh.ytzh.ui.RefreshLayout; import com.qhclh.ytzh.utils.DateTimeUtil; +import org.forks.jsonrpc.JsonRpcResult; +import org.forks.jsonrpc.RpcFacade; +import org.forks.jsonrpc.RpcObject; + import java.util.ArrayList; import java.util.Date; import java.util.List; +import java.util.Map; import butterknife.BindView; @@ -24,11 +33,14 @@ import butterknife.BindView; * Created by 青花瓷 on 2017/12/4. */ ///< 生产日报 -public class ProductiondailyActivity extends BaseActivity implements CalendarDialogFragment.CalendarClickListener{ +public class ProductiondailyActivity extends BaseActivity implements CalendarDialogFragment.CalendarClickListener, RefreshLayout.OnLoadListener, SwipeRefreshLayout.OnRefreshListener { @BindView(R.id.toolbar) Toolbar mToolbar; @BindView(R.id.lv_productiondaily) ListView lv_productiondaily; + @BindView(R.id.rfl_productiondaily) + RefreshLayout rfl_productiondaily; + private int page =0; private List productionDailyBeanList; private ProductiondailyAdapter productiondailyAdapter; @Override @@ -44,6 +56,7 @@ public class ProductiondailyActivity extends BaseActivity implements CalendarDia finish(); } }); + rfl_productiondaily.setEnabled(false); } @Override @@ -64,6 +77,78 @@ public class ProductiondailyActivity extends BaseActivity implements CalendarDia startActivity(new Intent(ProductiondailyActivity.this,ProductiondailyInfoActivity.class)); } }); + rfl_productiondaily.setOnLoadListener(this); + rfl_productiondaily.setOnRefreshListener(this); + } + + @Override + protected void onResume() { + super.onResume(); + DayProductRpcNew(); + DayProductRpcQuery(); + } + + private void DayProductRpcNew() { + ViewOnClickTask DayProductRpcNewTask = new ViewOnClickTask(this,"加载中...") { + RpcObject rpcobj; + + @Override + protected void successUI() { + + } + + @Override + public Object call() throws Exception { + + JsonRpcResult result = RpcFacade.rpcCall(RpcUrl.DayProductRpc_New); + rpcobj = result.getRpcObject(RpcUrl.DayProductRpc_Query_fanhui); + return null; + } + }; + DayProductRpcNewTask.execute(); + } + + private void DayProductRpcQuery() { + ViewOnClickTask DayProductRpcQueryTask = new ViewOnClickTask(this,"加载中...") { + List rpcobj; + + @Override + protected void successUI() { + + } + + @Override + public Object call() throws Exception { + RpcObject queryObj = RpcObject.create(RpcUrl.DayProductRpc_Query_canshu); + queryObj.setInt("PageSize",10); + queryObj.setInt("CurrentPageIndex",page); + List select = queryObj.getList("Select"); + select.add("ID"); +// select.add("CreateTime"); +// select.add("CreateUser_Name"); + select.add("Batch_ID"); + select.add("Batch_Name"); + select.add("BreedFactory_ID"); + select.add("BreedFactory_Name"); + select.add("Date"); +// select.add("Remark"); +// select.add("AccountingUnit_ID"); +// select.add("AccountingUnit_Name"); + +// Map where = queryObj.getMap("Where"); +// where.put("MobileToDo",true); + +// List orderList = queryObj.getList("OrderBy"); +// RpcObject orderBy1 = RpcObject.create(RpcUrl.paixu); +// orderBy1.setString("Name", "CreateTime"); +// orderBy1.setBoolean("Desc", true); +// orderList.add(orderBy1); + JsonRpcResult result = RpcFacade.rpcCall(RpcUrl.DayProductRpc_Query); + rpcobj = result.getRpcObjectList(RpcUrl.DayProductRpc_Query_fanhui); + return null; + } + }; + DayProductRpcQueryTask.execute(); } @Override @@ -92,4 +177,20 @@ public class ProductiondailyActivity extends BaseActivity implements CalendarDia public void onEndCalendarClick(Date date) { showToast(DateTimeUtil.FormatDate(date)); } + + @Override + public void onLoad() { + rfl_productiondaily.postDelayed(new Runnable() { + @Override + public void run() { + rfl_productiondaily.setLoading(false); + + } + },1000); + } + + @Override + public void onRefresh() { + rfl_productiondaily.setRefreshing(false); + } } diff --git a/gradle.properties b/gradle.properties index aac7c9b..7e9900a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,3 +15,4 @@ org.gradle.jvmargs=-Xmx1536m # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true +android.useDeprecatedNdk=true \ No newline at end of file