diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000000000000000000000000000000000000..007f365e9b30f462a3211fdb7b78ad668bede8b6 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,4 @@ +日常修改记录 + +## 2020/11/22 +1. 优化listView显示效果。 \ No newline at end of file diff --git a/Photo.md b/Photo.md new file mode 100644 index 0000000000000000000000000000000000000000..198911afb6f8e66415bb29c7ea7fc357b9598916 --- /dev/null +++ b/Photo.md @@ -0,0 +1 @@ +[picasso-强大的Android图片下载缓存库](http://www.jcodecraeer.com/a/anzhuokaifa/androidkaifa/2014/0731/1639.html) \ No newline at end of file diff --git a/README.md b/README.md index bde6177e6b4a18ba747f4fd343ccd25e03c8cca0..9fd186a4c4214ef66a02176f86bedad01fb8c5b7 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,9 @@ +## 后端程序 + +https://gitee.com/bufengyi/scan-server + +!!! 网络请求非常重要的一点,在main线程中的不可以是同步!!! + ## TODO @@ -5,8 +11,20 @@ - [ ] 服务器返回成功信息提示 - [ ] service与dao分开,dao仅仅数据库操作,不要掺杂同步服务器等操作 - [ ] MIUI手机权限问题 https://gitee.com/pengfeilu/PermissionDemo.git +- [ ] 今日菜价线上同步文字图片等。 +- [ ] 本地图片压缩 +- [ ] 用户登录角色设计,每个人有自己的数据 +- [ ] 报菜软件,及时统计数据,打造一流的物流系统 + https://blog.csdn.net/lupengfei1009/article/details/78140047 +# Android基础学习 + +## Service + +Activity由Service来操作完成长时间的耗时操作,然后通过广播来更新Activity。 + +https://www.runoob.com/android/android-services.html ## 问题 @@ -16,6 +34,17 @@ sdkmanager.bat --licenses 执行之后,它会提示你去允许认证,然后命令会提醒你确定y/n(accept lincense),一路y下去便可以了。 +## 安卓相关技术 + +https://github.com/blindmonk/Android + + +https://github.com/inferjay/AndroidDevTools + +https://github.com/XXApple/AndroidLibs + +https://github.com/itheima1/Android + # commit表情 @@ -33,6 +62,10 @@ https://gitee.com/simplepeng/SpiderMan ## GreenDao +https://www.jianshu.com/p/53083f782ea2 + +![](./asset/img/greedao.png) + https://blog.csdn.net/u013110200/article/details/78782058 二次开发的插件 @@ -53,6 +86,8 @@ https://www.cnblogs.com/minghualiyan/p/5212751.html https://github.com/xuyisheng/ZXingLib +https://gitee.com/aliwean/NBZxing + https://gitee.com/xuexiangjys/XQRCode ## xml到activity代码生成 @@ -116,6 +151,30 @@ https://www.jianshu.com/p/88488e954de1 https://blog.csdn.net/qq_36243942/article/details/82085986 +cnblogs.com/yuhanghzsd/p/5595532.html + + +#### 去掉横线 +https://blog.csdn.net/cn2007/article/details/22812021 +```xml + android:padding="10dp" + android:divider="@null" + android:dividerHeight="5dp" +``` +![](./asset/img/listview-remove-line.png) + +## Android 应用版本号配置修改 + +https://www.jianshu.com/p/15c62d098dc7 + +![img.png](asset/img/version.png) +## Android阴影效果 + +https://www.jianshu.com/p/eb71401ae0ec + + +## Android布局中的layout_weight和weightSum属性的详解及使用 +https://blog.csdn.net/android_cmos/article/details/50783745 ## 脚手架 https://gitee.com/hljdrl/fastlite-2016 @@ -127,7 +186,8 @@ https://gitee.com/rqhua/AndroidFire https://gitee.com/shangtianhao/AndroidFire ## logback android -https://gitee.com/mirrors/logback-android + +https://github.com/tony19/logback-android https://gitee.com/henengorg/logback-android ## 开发设计工具 @@ -147,6 +207,13 @@ https://gitee.com/LISER_LIN/one-family-android https://gitee.com/fluorineion/notepad +https://gitee.com/mirrors/qbox-android + +## QR二维码扫码 + +https://github.com/xuexiangjys/XQRCode + + ## 问题-错误信息 @@ -247,4 +314,28 @@ keytool -genkey -alias tomcathttps -keypass newpass -keyalg RSA -keysize 2048 -v Build -> Generate Signed bundle /apk ![](./asset/img/relase1.png) -![](./asset/img/relase2.png) \ No newline at end of file + +![](./asset/img/release2.png) + +密码 newpass + +![img.png](asset/img/relase.png) + +## 文件存储获取 + +https://blog.csdn.net/shving/article/details/101057082 + +### 拍照后图片存储正常,但是onActivityResult的resultCode总是返回0 + +原因可能是加了下面这句代码 +```java + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); +``` +### android通过Intent.ACTION_VIEW打开时出现异常卡顿 + +解决办法 + intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); + +https://www.cnblogs.com/kinoyo/p/12787226.html + + diff --git a/app/.gitignore b/app/.gitignore index 796b96d1c402326528b4ba3c12ee9d92d0e212e9..dc5ca963c57ae011229c58dcca83ce9226677f26 100644 --- a/app/.gitignore +++ b/app/.gitignore @@ -1 +1,2 @@ /build +/release/ diff --git a/app/build.gradle b/app/build.gradle index 80f2ae94d8c4fa10e6499db00eae591b78bfcac4..aa532bf7fa7ac800fae3131d23b4babf2a138844 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,14 +1,28 @@ apply plugin: 'com.android.application' apply plugin: 'org.greenrobot.greendao' +//repositories { +//// jCenter() +// // 加载本地文件夹的jar包依赖 +//// flatDir { dirs 'asset/' } +// mavenLocal() +// maven { url 'https://maven.aliyun.com/repository/public/' } +// maven { url "https://repo.spring.io/libs-release" } +// maven { url "https://maven.aliyun.com/nexus/content/groups/public" } +// maven { url "https://maven.aliyun.com/nexus/content/repositories/gradle-plugin" } +// mavenCentral() +// maven { url "https://plugins.gradle.org/m2/" } +//} + + android { compileSdkVersion 28 defaultConfig { applicationId "com.hxy.manager" minSdkVersion 25 // Android7.1最低 - targetSdkVersion 28 - versionCode 1 - versionName "1.0" + targetSdkVersion 30 + versionCode 3 + versionName "1.18.7" // 版本号由这里决定 testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" //添加如下配置 开启annotation processor javaCompileOptions { @@ -34,18 +48,19 @@ android { } } -def spider_man = "1.1.6" +def spider_man = "v1.1.9" dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') -// implementation 'com.android.support:appcompat-v7:28.0.0' implementation 'com.android.support.constraint:constraint-layout:1.1.3' + implementation 'com.android.support:support-annotations:28.0.0' testImplementation 'junit:junit:4.12' -// androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' implementation files('libs/zxing.jar') - implementation files('libs/json-20180813.jar') + api 'com.google.android.material:material:1.3.0-alpha02' + implementation 'com.google.firebase:firebase-auth:19.3.2' +// implementation files('libs/json-20180813.jar') // https://mvnrepository.com/artifact/net.sf.json-lib/json-lib //// compile 'net.sf.json-lib:json-lib:2.4' // // https://mvnrepository.com/artifact/commons-collections/commons-collections @@ -59,11 +74,10 @@ dependencies { // //// https://mvnrepository.com/artifact/commons-logging/commons-logging // compile group: 'commons-logging', name: 'commons-logging', version: '1.2' -// implementation files('libs/fastjson-1.2.56.jar') - // https://mvnrepository.com/artifact/com.alibaba/fastjson - implementation group: 'com.alibaba', name: 'fastjson', version: '1.2.56' - implementation group: 'com.ejlchina', name: 'okhttps-jackson', version: '2.1.0' + implementation group: 'com.alibaba', name: 'fastjson', version: '1.2.79' + implementation group: 'com.ejlchina', name: 'okhttps-jackson', version: '3.5.1' + implementation 'com.android.volley:volley:1.1.1' implementation'org.greenrobot:greendao:3.2.2' implementation'org.greenrobot:greendao-generator:3.2.2' @@ -72,7 +86,13 @@ dependencies { implementation 'org.slf4j:slf4j-api:1.7.25' implementation 'com.github.tony19:logback-android:2.0.0' - implementation "com.simple:spiderman:$spider_man" + implementation "com.github.simplepeng.SpiderMan:spiderman:${spider_man}" + + + implementation 'com.intuit.sdp:sdp-android:1.0.6' + implementation 'com.intuit.ssp:ssp-android:1.0.6' + + implementation 'com.uncopt:android.justified:1.0' annotationProcessor 'org.projectlombok:lombok:1.18.10' compileOnly 'org.projectlombok:lombok:1.18.10' diff --git a/app/src/androidTest/java/com/hxy/manager/ExampleInstrumentedTest.java b/app/src/androidTest/java/com/hxy/manager/ExampleInstrumentedTest.java index b64357f3eb86201a377e18487e0296147d98948c..92455bc98a4727bef8159b1e41268b09c7ad4756 100644 --- a/app/src/androidTest/java/com/hxy/manager/ExampleInstrumentedTest.java +++ b/app/src/androidTest/java/com/hxy/manager/ExampleInstrumentedTest.java @@ -1,5 +1,7 @@ package com.hxy.manager; +import static org.junit.Assert.assertEquals; + import android.content.Context; import androidx.test.InstrumentationRegistry; @@ -8,8 +10,6 @@ import androidx.test.runner.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; -import static org.junit.Assert.*; - /** * Instrumented test, which will execute on an Android device. * diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 22d0453a59da66ab64be881dd9e1264c096d9e4f..0dcb7a6a878d06e22b9aeaa4042fe0098f885aa7 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -2,9 +2,8 @@ - + android:versionCode="2" + android:versionName="1.18.5"> @@ -14,7 +13,8 @@ - + + @@ -23,40 +23,62 @@ + android:theme="@style/AppTheme2" + android:usesCleartextTraffic="true" + tools:replace="android:appComponentFactory"> - + - - - + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/assets/logback.xml b/app/src/main/assets/logback.xml index 8f7c81b81c2e09a35ce4a4638deb58d7af30aeaf..9e72a4a2a4c09b1cffa19438b63f36516edce810 100644 --- a/app/src/main/assets/logback.xml +++ b/app/src/main/assets/logback.xml @@ -4,11 +4,22 @@ %logger{12} - [%-20thread] %msg + %d{HH:mm:ss.SSS} %contextName [%thread] \(%file:%line\) - %msg%n + + + + + + /data/data/hxy.shop.scan/files/foo.log + + %d{HH:mm:ss.SSS} %contextName [%thread] %-5level %logger{36} - %msg%n + + + \ No newline at end of file diff --git a/app/src/main/java/com/hxy/manager/App.java b/app/src/main/java/com/hxy/manager/App.java index 775d64f913b014afd3b10725fa1afb522285b2ae..91d5a681e6c65af351475e20661b4cff08f56e95 100644 --- a/app/src/main/java/com/hxy/manager/App.java +++ b/app/src/main/java/com/hxy/manager/App.java @@ -1,18 +1,11 @@ package com.hxy.manager; -import android.Manifest; import android.app.Application; import android.content.Context; -import android.content.pm.PackageManager; -import androidx.core.app.ActivityCompat; -import androidx.core.content.ContextCompat; - -import com.hxy.manager.activity.goods.GoodsAddActivity; import com.hxy.manager.entity.DaoMaster; import com.hxy.manager.entity.DaoSession; import com.hxy.manager.util.Constant; -import com.simple.spiderman.SpiderMan; import org.greenrobot.greendao.database.Database; import org.slf4j.Logger; @@ -29,12 +22,9 @@ public class App extends Application { super.onCreate(); context = this; //放在其他库初始化前,用于崩溃日志获取的 - SpiderMan.init(this); Logger log = LoggerFactory.getLogger(App.class); log.info("hello world"); initGreenDao(); - - } private void initGreenDao() { diff --git a/app/src/main/java/com/hxy/manager/activity/CaptureActivity.java b/app/src/main/java/com/hxy/manager/activity/CaptureActivity.java index a8a3e147101e485c07cc181dedb28fa36e62e94f..f169710c0ce845e166adc39762f26e5fae4382b8 100755 --- a/app/src/main/java/com/hxy/manager/activity/CaptureActivity.java +++ b/app/src/main/java/com/hxy/manager/activity/CaptureActivity.java @@ -15,10 +15,11 @@ */ package com.hxy.manager.activity; +import android.app.ActionBar; import android.app.Activity; import android.app.AlertDialog; +import android.content.Context; import android.content.DialogInterface; -import android.content.Intent; import android.graphics.Rect; import android.os.Bundle; import android.os.Handler; @@ -33,14 +34,9 @@ import android.view.animation.Animation; import android.view.animation.TranslateAnimation; import android.widget.ImageView; import android.widget.RelativeLayout; -import android.widget.Toast; import com.google.zxing.Result; import com.hxy.manager.R; -import com.hxy.manager.activity.goods.GoodsAddActivity; -import com.hxy.manager.activity.goods.GoodsShowActivity; -import com.hxy.manager.activity.goods.GoodsUpdateActivity; -import com.hxy.manager.entity.GoodsEntity; import com.hxy.manager.service.GoodsEntityService; import com.hxy.manager.zxing.camera.CameraManager; import com.hxy.manager.zxing.decode.DecodeThread; @@ -48,10 +44,14 @@ import com.hxy.manager.zxing.utils.BeepManager; import com.hxy.manager.zxing.utils.CaptureActivityHandler; import com.hxy.manager.zxing.utils.InactivityTimer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.io.IOException; import java.lang.reflect.Field; /** + * 处理扫码的Activity * This activity opens the camera and does the actual scanning on a background * thread. It draws a viewfinder to help the user place the barcode correctly, * shows feedback as the image processing is happening, and then overlays瑕嗙洊 the @@ -60,6 +60,7 @@ import java.lang.reflect.Field; public final class CaptureActivity extends Activity implements SurfaceHolder.Callback { private static final String TAG = CaptureActivity.class.getSimpleName(); + Logger log = LoggerFactory.getLogger(CaptureActivity.class); private CameraManager cameraManager; private CaptureActivityHandler handler; @@ -73,6 +74,8 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal private Rect mCropRect = null; private boolean isHasSurface = false; + public static CaptureActivity captureActivity; + public Handler getHandler() { return handler; } @@ -88,7 +91,12 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); setContentView(R.layout.capture_activity); - getActionBar().setDisplayHomeAsUpEnabled(true);//向上返回 + captureActivity = this; + + ActionBar actionBar = getActionBar(); + if (actionBar != null) { + actionBar.setDisplayHomeAsUpEnabled(true);//向上返回 + }//向上返回 scanPreview = (SurfaceView) findViewById(R.id.capture_surfaceview); scanContainer = (RelativeLayout) findViewById(R.id.capture_container); scanCropView = (RelativeLayout) findViewById(R.id.capture_crop_view); @@ -191,6 +199,7 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal inactivityTimer.onActivity(); beepManager.playBeepSoundAndVibrate(); String scanCode = rawResult.getText(); + log.info("扫码结果{}", scanCode); // Intent resultIntent = new Intent(); // bundle.putString("result", scanCode); @@ -199,33 +208,12 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal // 查询数据库,有就显示,没有就添加 - GoodsEntity goodsEntity = GoodsEntityService.getOneByNumber(this, scanCode); + GoodsEntityService.getOneFromServer(this, scanCode); // 如果在数据库中不存在,那么就跳转到添加中 - if (goodsEntity == null) { - GoodsAddActivity goodsAddActivity = GoodsAddActivity.goodsAddActivity; - if (goodsAddActivity != null) { - goodsAddActivity.finish(); - } - - Intent intent = new Intent(CaptureActivity.this, GoodsAddActivity.class); - intent.putExtra("scanCode", scanCode); - startActivity(intent); - - } else { - - GoodsShowActivity goodsShowActivity = GoodsShowActivity.goodsShowActivity; - if (goodsShowActivity != null) { - goodsShowActivity.finish(); - } -// 说明查询到了记录 - Intent intent = new Intent(CaptureActivity.this, GoodsShowActivity.class); - intent.putExtra("scanCode", scanCode); - startActivity(intent); - - } + // TODO 接收结束广播 //关闭当前activity - CaptureActivity.this.finish(); +// CaptureActivity.this.finish(); } private void initCamera(SurfaceHolder surfaceHolder) { @@ -303,7 +291,7 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal scanCropView.getLocationInWindow(location); int cropLeft = location[0]; - int cropTop = location[1] - getStatusBarHeight(); + int cropTop = location[1] - getStatusBarHeightCompat(CaptureActivity.this); //鎵弿妗嗗緱甯冨眬鐨勯珮搴︿笌瀹藉害 int cropWidth = scanCropView.getWidth(); @@ -340,6 +328,19 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal return 0; } + public static int getStatusBarHeightCompat(Context context) { + int result = 0; + int resId = context.getResources().getIdentifier("status_bar_height", "dimen", "android"); + if (resId > 0) { + result = context.getResources().getDimensionPixelOffset(resId); + } + if (result <= 0) { + result = context.getResources().getDimensionPixelOffset(R.dimen._25sdp); + } + return result; + } + + @Override public boolean onCreateOptionsMenu(Menu menu) { // getMenuInflater().inflate(R.menu.main,menu); diff --git a/app/src/main/java/com/hxy/manager/activity/IndexActivity.java b/app/src/main/java/com/hxy/manager/activity/IndexActivity.java index 3a5f1ca0144ed01a98adc05999fdf5d6bb63777d..7cd255ae5fc5c592ba33c00a3ee1dccda8417331 100755 --- a/app/src/main/java/com/hxy/manager/activity/IndexActivity.java +++ b/app/src/main/java/com/hxy/manager/activity/IndexActivity.java @@ -2,9 +2,13 @@ package com.hxy.manager.activity; import android.Manifest; import android.app.Activity; +import android.content.ActivityNotFoundException; +import android.content.ComponentName; import android.content.Intent; import android.content.pm.PackageManager; import android.os.Bundle; +import android.provider.Settings; +import android.text.TextUtils; import android.util.Log; import android.view.MotionEvent; import android.view.View; @@ -16,7 +20,7 @@ import androidx.core.app.ActivityCompat; import androidx.core.content.ContextCompat; import com.hxy.manager.R; -import com.hxy.manager.activity.bill.Bill; +import com.hxy.manager.activity.bill.BillActivity; import com.hxy.manager.activity.goods.GoodsAddActivity; import com.hxy.manager.activity.goods.GoodsShowActivity; import com.hxy.manager.activity.goods.GoodsStoreActivity; @@ -46,41 +50,65 @@ public class IndexActivity extends Activity { menu(); - // 检查权限 + // 检查权限 if (ContextCompat.checkSelfPermission(IndexActivity.this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(IndexActivity.this, new String[]{Manifest.permission.CAMERA}, 1); } if (ContextCompat.checkSelfPermission(IndexActivity.this, Manifest.permission.INTERNET) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(IndexActivity.this, new String[]{Manifest.permission.INTERNET}, 1); - }else { + } else { Log.i("kkk", "网络权限已经有了"); + } + if (!isNotificationListenersEnabled()) { + gotoNotificationAccessSetting(); } + } - - /* - //读取shareperf - SharedPreferences pref= getSharedPreferences("com.hxy.manager_preferences",MODE_PRIVATE); - String string =pref.getString("ServerUrl", null); - Log.i("kkk", "pref1"+pref+string); + public boolean isNotificationListenersEnabled() { + String pkgName = getPackageName(); + final String flat = Settings.Secure.getString(getContentResolver(), "enabled_notification_listeners"); + if (!TextUtils.isEmpty(flat)) { + final String[] names = flat.split(":"); + for (int i = 0; i < names.length; i++) { + final ComponentName cn = ComponentName.unflattenFromString(names[i]); + if (cn != null) { + if (TextUtils.equals(pkgName, cn.getPackageName())) { + return true; + } + } + } + } + return false; + } - */ - - - - /* - //setTitle("薛家岗新店管理中心"); - //去掉状态栏 - - getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN - | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar - | View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar - // remove the following flag for version < API 19 - | View.SYSTEM_UI_FLAG_IMMERSIVE); - */ + protected boolean gotoNotificationAccessSetting() { + try { + Intent intent = new Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS"); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + startActivity(intent); + return true; + + } catch (ActivityNotFoundException e) {//普通情况下找不到的时候需要再特殊处理找一次 + try { + Intent intent = new Intent(); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + ComponentName cn = new ComponentName("com.android.settings", "com.android.settings.Settings$NotificationAccessSettingsActivity"); + intent.setComponent(cn); + intent.putExtra(":settings:show_fragment", "NotificationAccessSettings"); + startActivity(intent); + return true; + } catch (Exception e1) { + e1.printStackTrace(); + } + Toast.makeText(this, "对不起,您的手机暂不支持", Toast.LENGTH_SHORT).show(); + e.printStackTrace(); + return false; + } } + //侧滑菜单 public void menu() { // attach to current activity; @@ -226,7 +254,7 @@ public class IndexActivity extends Activity { //账单 public void bill(View v) { - Intent intent = new Intent(IndexActivity.this, Bill.class); + Intent intent = new Intent(IndexActivity.this, BillActivity.class); startActivity(intent); } diff --git a/app/src/main/java/com/hxy/manager/activity/LoginActivity.java b/app/src/main/java/com/hxy/manager/activity/LoginActivity.java deleted file mode 100755 index 7a92f821e04cf49dbedec958b162a55c653b15e2..0000000000000000000000000000000000000000 --- a/app/src/main/java/com/hxy/manager/activity/LoginActivity.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.hxy.manager.activity; - -import android.app.Activity; - -public class LoginActivity extends Activity { - - - -} diff --git a/app/src/main/java/com/hxy/manager/activity/LogsActivity.java b/app/src/main/java/com/hxy/manager/activity/LogsActivity.java deleted file mode 100755 index a237ba6e15b757a8402e2f534b9c65e277e0fb05..0000000000000000000000000000000000000000 --- a/app/src/main/java/com/hxy/manager/activity/LogsActivity.java +++ /dev/null @@ -1,121 +0,0 @@ -package com.hxy.manager.activity; - -import com.hxy.manager.R; -import com.hxy.manager.R.id; -import com.hxy.manager.R.layout; - -import android.app.Activity; -import android.os.Bundle; -import android.text.method.ScrollingMovementMethod; -import android.view.Menu; -import android.view.MenuItem; -import android.widget.TextView; - - - -/** - * Created by 傲寒宏志 on 2018/1/14. - */ - -public class LogsActivity extends Activity{ - TextView Logs; - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(layout.logs); - setTitle("日志"); - getActionBar().setDisplayHomeAsUpEnabled(true);//向上返回 - Logs = (TextView) findViewById(id.textView13); - Logs.setText( - " 第27次修改:\n 1.18.2:2020年11月06日。重新调整Activity调用逻辑"+ - " 第26次修改:\n 1.18.1:2020年11月03日。采用lombok和okhttps。修复库存统计的bug"+ - " 第25次修改:\n 1.18.0:2019年2月10日。由原来的socket通信修改成了现在的http post传输json数据通信,本质上还是传输文字流,同时服务器由Tomcat接管,servlet,线程池与MyBatis数据库持久层管理。\n\n"+ - " 第24次修改:\n 1.17.8:2018年3月25日。修改按钮样式,以及EditText样式,更加人性化。\n\n"+ - " 第23次修改:\n 1.17.7:2018年3月20日。修改主页面背景,修改侧滑打开时返回是恢复主界面,而不是直接退出。\n\n"+ - " 第22次修改:\n 1.17.6:2018年3月20日。加入自定义登陆界面\n\n"+ - " 第21次修改:\n 1.17.5:服务器端修改,成功连接服务器数据库。修改设置的选项。\n\n"+ - " 第20次修改:\n 1.17.4:2018年3月15日。Vector.add添加的应该是地址,一次new Leixing()创建的是同一个地址。重新new才是不同地址\n\n"+ - " 第19次修改:\n 1.17.3:重新设计从服务器接收数据之后写入本地数据库的机制,分层设计原则,先全部接收完成之后再写入。不再是边接收边写入.\n\n"+ - " 第18次修改:\n 1.17.2:2018年3月14日。加入sharedPreferences定义IP与PORT\n\n"+ - - " 第17次修改:\n 1.17.1加入侧滑菜单,迁移工程到eclipse下面。侧滑项目地址:https://github.com/SpecialCyCi/AndroidResideMenu/blob/master/README_CN.md\n\n"+ - " 第16次修改:\n" + - " 1.0.14:2018/02/15:修复时间排序短按的bug。从数据库查询即按照时间排序。\n\n" + - " 第15次修改:\n" + - " 1.0.14:2018/02/14:在存档处连续两次添加商品,第二次不会自动加入登记时间。修改数据的时候更新修改的操作时间。解决库存的最近显示。\n\n" + - " 第三版:\n" + - " 1.0.13:2018/02/07:解决查询的名字和number两种查询方式。修改查询后,点击查看,又恢复没有查询的现状。\n\n" + - " 第三版:\n" + - " 1.0.12:\n\n" + - " 第三版:\n" + - " 1.0.11:\n\n" + - " 第三版:\n" + - " 1.0.10:\n\n" + - " 第三版:\n" + - " 1.0.9:2018/01/29:加入商品总数统计功能。\n\n" + - " 第三版:\n" + - " 1.0.8:2018年1月28日:修复,登记,的时间没有加入的bug,会导致应用同步的时候崩溃!\n\n" + - " 第三版:\n" + - " 1.0.7:加入版本检测机制,目前只对最新版本支持,不支持旧版本。\n\n" + - " 第三版:\n" + - " 1.0.3:\n\n" + - " 第三版:\n" + - " 1.0.6:加入时间,更新机制修改!以最新时间为最新数据。\n\n" + - " 第三版:\n" + - " 1.0.5:解决恢复数据的时候,恢复完成后刷新列表。\n\n" + - " 第三版:\n" + - " 1.0.4加入库存查询功能。\n\n" + - " 第三版:\n" + - " 1.0.3:\n\n" + - " 第二版:\n" + - " 1.0.2:2018年1月2日,解决扫码。\n\n" + - " 第1次修改:\n" + - " 1.0.1:2018年1月1日,开始初步设计。设计一款扫码的超市管理软件,命名为\"薛家岗新店管理中心\"。"); - Logs.setMovementMethod(ScrollingMovementMethod.getInstance()); - - } - - @Override - public boolean onCreateOptionsMenu(Menu menu){ - // getMenuInflater().inflate(R.menu.main,menu); - return super.onCreateOptionsMenu(menu); - } - - - public boolean onOptionsItemSelected(MenuItem item){ - - switch(item.getItemId()){ - case android.R.id.home: //默认添加的,返回上一层 - finish(); - break; } - return false; - } - /* - 1.照片的像素,大小! - 2.照片的转向,所有都横向 - - 日志: - 1.0.5解决恢复数据的时候,恢复完成后刷新列表。 - 1.0.6加入时间,更新机制修改!以最新时间为最新数据。 - - 1.0.7加入版本检测机制,目前只对最新版本支持,不支持旧版本。 - 1.0.8-2018年1月28日:修复,登记,的时间没有加入的bug,会导致应用同步的时候崩溃! - 1.0.9 - 2018/01/29:加入商品总数统计功能。 - - 2018/02/07:解决查询的名字和number两种查询方式。修改查询后,点击查看,又恢复没有查询的现状。 - - - - 值得学习与思考的问题: - 安卓的长页面怎么处理,例如,网页那样的日志更新记录? - - select * from table where 用户ID like "%关键字%" or 性别 like "%关键字%" or 家庭住址 like "%关键字%" or 邮政编码 like "%关键字%" - -单个字段查找:select * from 表名 where 字段列名 like "%查找关键字%" - - - - - */ -} diff --git a/app/src/main/java/com/hxy/manager/activity/MainActivity.java b/app/src/main/java/com/hxy/manager/activity/MainActivity.java deleted file mode 100644 index 785fa39a1f240a21cf817679ef9ffd10b79d2da3..0000000000000000000000000000000000000000 --- a/app/src/main/java/com/hxy/manager/activity/MainActivity.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.hxy.manager.activity; - -import android.os.Bundle; - -import androidx.appcompat.app.AppCompatActivity; - -import com.hxy.manager.R; - -public class MainActivity extends AppCompatActivity { - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); - } -} diff --git a/app/src/main/java/com/hxy/manager/activity/RecordActivity.java b/app/src/main/java/com/hxy/manager/activity/RecordActivity.java index ad2958eab720faa8fd48c2e0f23de4f5fe9a8517..189beb39dfb4995c2c1da10f2e9bbd3224624bcc 100755 --- a/app/src/main/java/com/hxy/manager/activity/RecordActivity.java +++ b/app/src/main/java/com/hxy/manager/activity/RecordActivity.java @@ -1,7 +1,7 @@ package com.hxy.manager.activity; -import android.app.Activity; +import android.app.ActionBar; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; @@ -10,6 +10,8 @@ import android.widget.Button; import android.widget.EditText; import android.widget.Toast; +import androidx.appcompat.app.AppCompatActivity; + import com.hxy.manager.R; import com.hxy.manager.entity.GoodsEntity; @@ -21,8 +23,8 @@ import java.util.Date; * Created by 傲寒宏志 on 2018/1/13. */ -public class RecordActivity extends Activity { - // EditText editText0; +public class RecordActivity extends AppCompatActivity { + // EditText editText0; EditText editText1; EditText editText2; EditText editText3; @@ -31,30 +33,27 @@ public class RecordActivity extends Activity { EditText editText6; - - @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.record); setTitle("登记商品"); - getActionBar().setDisplayHomeAsUpEnabled(true);//向上返回 - // editText0=(EditText)findViewById(R.id.editText0); - editText1=(EditText)findViewById(R.id.editText1); - editText2=(EditText)findViewById(R.id.editText2); - editText3=(EditText)findViewById(R.id.editText3); - editText4=(EditText)findViewById(R.id.editText4); - editText5=(EditText)findViewById(R.id.editText5); - editText6=(EditText)findViewById(R.id.editDateEditText); + ActionBar actionBar = getActionBar(); + if (actionBar != null) { + actionBar.setDisplayHomeAsUpEnabled(true);//向上返回 + } + editText1 = (EditText) findViewById(R.id.name_edit_text); + editText2 = (EditText) findViewById(R.id.price_edit_text); + editText3 = (EditText) findViewById(R.id.price2_edit_text); + editText4 = (EditText) findViewById(R.id.product_edit_text); + editText5 = (EditText) findViewById(R.id.baozhiqi_edit_text); + editText6 = (EditText) findViewById(R.id.date_edit_text); Calendar now = Calendar.getInstance(); - editText6.setText(now.get(Calendar.YEAR)+"年"+(now.get(Calendar.MONTH) + 1) +"月"+now.get(Calendar.DAY_OF_MONTH)+"日"); - + editText6.setText(now.get(Calendar.YEAR) + "年" + (now.get(Calendar.MONTH) + 1) + "月" + now.get(Calendar.DAY_OF_MONTH) + "日"); - - - Button save =(Button)findViewById(R.id.save); + Button save = (Button) findViewById(R.id.save); save.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { @@ -65,19 +64,17 @@ public class RecordActivity extends Activity { String dateNowStr = sdf.format(d); - if(editText1.getText().toString().equals("")){ + if (editText1.getText().toString().equals("")) { // if(editText0.getText().toString().equals("")||editText1.getText().toString().equals("")||editText2.getText().toString().equals("")||editText3.getText().toString().equals("")||editText4.getText().toString().equals("")||editText4.getText().toString().equals("")||editText5.getText().toString().equals("")||editText6.getText().toString().equals("")) { - Toast.makeText(RecordActivity.this,"名称不可为空!",Toast.LENGTH_SHORT).show(); + Toast.makeText(RecordActivity.this, "名称不可为空!", Toast.LENGTH_SHORT).show(); - }else - if(editText2.getText().toString().equals("")){ + } else if (editText2.getText().toString().equals("")) { // if(editText0.getText().toString().equals("")||editText1.getText().toString().equals("")||editText2.getText().toString().equals("")||editText3.getText().toString().equals("")||editText4.getText().toString().equals("")||editText4.getText().toString().equals("")||editText5.getText().toString().equals("")||editText6.getText().toString().equals("")) { - Toast.makeText(RecordActivity.this,"价格不可为空!",Toast.LENGTH_SHORT).show(); + Toast.makeText(RecordActivity.this, "价格不可为空!", Toast.LENGTH_SHORT).show(); - }else - { + } else { GoodsEntity user = new GoodsEntity(); //服务器接收数据,并且写入到数据库 @@ -90,18 +87,7 @@ public class RecordActivity extends Activity { user.setAuthor(editText5.getText().toString()); user.setLocation(editText6.getText().toString()); user.setUpdateTime(System.currentTimeMillis()); -// MakeTable mt=new MakeTable(Record.this); -// -// if(mt.addData(user)){ -// Toast.makeText(Record.this,"保存成功!",Toast.LENGTH_SHORT).show(); -// // editText0.setText(""); -// editText1.setText(""); -// editText2.setText(""); -// editText3.setText(""); -// editText4.setText(""); -// editText5.setText(""); -// // editText6.setText(""); -// } + } } @@ -109,19 +95,21 @@ public class RecordActivity extends Activity { } + @Override - public boolean onCreateOptionsMenu(Menu menu){ - // getMenuInflater().inflate(R.menu.main,menu); + public boolean onCreateOptionsMenu(Menu menu) { + // getMenuInflater().inflate(R.menu.main,menu); return super.onCreateOptionsMenu(menu); } - public boolean onOptionsItemSelected(MenuItem item){ + public boolean onOptionsItemSelected(MenuItem item) { - switch(item.getItemId()){ - case android.R.id.home: //默认添加的 - finish(); - break; } + switch (item.getItemId()) { + case android.R.id.home: //默认添加的 + finish(); + break; + } return false; } } diff --git a/app/src/main/java/com/hxy/manager/activity/SettingActivity.java b/app/src/main/java/com/hxy/manager/activity/SettingActivity.java index d858261066106834afef225283acb27782e9adac..201a287d6447559717761ad4cbf4c401c5ea8135 100755 --- a/app/src/main/java/com/hxy/manager/activity/SettingActivity.java +++ b/app/src/main/java/com/hxy/manager/activity/SettingActivity.java @@ -1,11 +1,11 @@ package com.hxy.manager.activity; +import android.app.ActionBar; import android.app.AlertDialog; import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; import android.content.DialogInterface.OnClickListener; -import android.content.Intent; import android.os.Bundle; import android.preference.EditTextPreference; import android.preference.Preference; @@ -33,19 +33,13 @@ public class SettingActivity extends PreferenceActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - getActionBar().setDisplayHomeAsUpEnabled(true);//向上返回 + ActionBar actionBar = getActionBar(); + if (actionBar != null) { + actionBar.setDisplayHomeAsUpEnabled(true);//向上返回 + }//向上返回 addPreferencesFromResource(R.xml.settings); setTitle("设置"); SwitchPreference useDefault = (SwitchPreference) findPreference("use_default_image"); - PreferenceScreen chekcb = (PreferenceScreen) findPreference("logs"); - chekcb.setOnPreferenceClickListener(new OnPreferenceClickListener() { - - @Override - public boolean onPreferenceClick(Preference preference) { - startActivity(new Intent(SettingActivity.this, LogsActivity.class)); - return false; - } - }); PreferenceScreen about = (PreferenceScreen) findPreference("about"); about.setOnPreferenceClickListener(new OnPreferenceClickListener() { @@ -75,30 +69,6 @@ public class SettingActivity extends PreferenceActivity { @Override public boolean onPreferenceClick(Preference preference) { - /* - //界面自定义方式 - AlertDialog.Builder ab= new AlertDialog.Builder(SettingActivity.this); - ab.setTitle("用户登陆"); - ab.setIcon(R.drawable.login);//图片大小需要仔细研究 - LayoutInflater liInflater=(SettingActivity.this).getLayoutInflater(); - ab.setView(liInflater.inflate(R.layout.login, null)); - ab.setPositiveButton("登陆", new OnClickListener() { - - @Override - public void onClick(DialogInterface dialog, int which) { - - } - }); - ab.setNegativeButton("取消", new OnClickListener() { - - @Override - public void onClick(DialogInterface dialog, int which) { - - } - }); - ab.create(); - ab.show(); - */ //完全自定义方式 new LoginDialog(SettingActivity.this).show(); @@ -120,26 +90,7 @@ public class SettingActivity extends PreferenceActivity { return true; } }); - - } - /* - public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) { - if ( (preference == mAirplaneModePreference) && - (Boolean.parseBoolean( - SystemProperties.get(TelephonyProperties.PROPERTY_INECM_MODE))) ) { - // In ECM mode launch ECM app dialog - startActivityForResult( - new Intent(TelephonyIntents.ACTION_SHOW_NOTICE_ECM_BLOCK_OTHERS, null), - REQUEST_CODE_EXIT_ECM); - return true; - } - else { - // Let the intents be launched by the Preference manager - return false; - } - } - */ //内部类?********************/ @@ -198,33 +149,4 @@ public class SettingActivity extends PreferenceActivity { } return false; } -} -/* - 这个写在其他的Activity - @Override - public void onStart()//重新启动的时候 - { - mSurfaceHolder = mSurfaceview.getHolder(); // 绑定SurfaceView,取得SurfaceHolder对象 - mSurfaceHolder.addCallback(this); // SurfaceHolder加入回调接口 - mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);// 设置显示器类型,setType必须设置 - //读取配置文件 - SharedPreferences preParas = PreferenceManager.getDefaultSharedPreferences(SocketCameraActivity.this); - pUsername=preParas.getString("Username", "XZY"); - serverUrl=preParas.getString("ServerUrl", "192.168.0.100"); - String tempStr=preParas.getString("ServerPort", "8888"); - serverPort=Integer.parseInt(tempStr); - tempStr=preParas.getString("VideoPreRate", "1"); - VideoPreRate=Integer.parseInt(tempStr); - tempStr=preParas.getString("VideoQuality", "85"); - VideoQuality=Integer.parseInt(tempStr); - tempStr=preParas.getString("VideoWidthRatio", "100"); - VideoWidthRatio=Integer.parseInt(tempStr); - tempStr=preParas.getString("VideoHeightRatio", "100"); - VideoHeightRatio=Integer.parseInt(tempStr); - VideoWidthRatio=VideoWidthRatio/100f; - VideoHeightRatio=VideoHeightRatio/100f; - - super.onStart(); - } - - */ \ No newline at end of file +} \ No newline at end of file diff --git a/app/src/main/java/com/hxy/manager/activity/bill/Bill.java b/app/src/main/java/com/hxy/manager/activity/bill/BillActivity.java similarity index 55% rename from app/src/main/java/com/hxy/manager/activity/bill/Bill.java rename to app/src/main/java/com/hxy/manager/activity/bill/BillActivity.java index 9432912336a856ca3062986f107b01b8977b6f93..55c19c5c8c2fe6cedab08a30d688eafc230de950 100755 --- a/app/src/main/java/com/hxy/manager/activity/bill/Bill.java +++ b/app/src/main/java/com/hxy/manager/activity/bill/BillActivity.java @@ -1,8 +1,7 @@ package com.hxy.manager.activity.bill; -import com.hxy.manager.R; - +import android.app.ActionBar; import android.app.Activity; import android.content.Intent; import android.database.sqlite.SQLiteDatabase; @@ -11,54 +10,61 @@ import android.view.Menu; import android.view.MenuItem; import android.view.View; +import com.hxy.manager.R; + /** * Created by 傲寒宏志 on 2018/2/4. */ -public class Bill extends Activity { +public class BillActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.bill); setTitle("新店账单"); - + CreateSqlBill(); - getActionBar().setDisplayHomeAsUpEnabled(true);//向上返回 - - + ActionBar actionBar = getActionBar(); + if (actionBar != null) { + actionBar.setDisplayHomeAsUpEnabled(true);//向上返回 + }//向上返回 + + } - public void nianhuodan(View v){ - //Toast.makeText(getApplicationContext(), "年货单!", Toast.LENGTH_SHORT).show(); - startActivity(new Intent(Bill.this,BillNianhuo.class)); + + public void nianhuodan(View v) { + //Toast.makeText(getApplicationContext(), "年货单!", Toast.LENGTH_SHORT).show(); + startActivity(new Intent(BillActivity.this, BillNianhuoActivity.class)); } - void CreateSqlBill(){ - - SQLiteDatabase db = openOrCreateDatabase("My_DB.db",MODE_PRIVATE,null); + void CreateSqlBill() { + + SQLiteDatabase db = openOrCreateDatabase("My_DB.db", MODE_PRIVATE, null); db.execSQL("create table if not exists BillInCompany(id integer primary key, name text,price text,date text,photo text,time text)"); db.execSQL("create table if not exists BillInBill(id integer primary key autoincrement, name text,price text,date text,photo text,time text)"); - //年货单的表 + //年货单的表 db.execSQL("create table if not exists BillNianhuo(id integer primary key autoincrement, name text,phone text,address text,date text,photo text,photo1 text,photo2 text,photo3 text,time text)"); - - + + } + @Override - public boolean onCreateOptionsMenu(Menu menu){ - // getMenuInflater().inflate(R.menu.main,menu); + public boolean onCreateOptionsMenu(Menu menu) { + // getMenuInflater().inflate(R.menu.main,menu); return super.onCreateOptionsMenu(menu); } - - public boolean onOptionsItemSelected(MenuItem item){ + public boolean onOptionsItemSelected(MenuItem item) { - switch(item.getItemId()){ - case android.R.id.home: //默认添加的 - finish(); - break; } + switch (item.getItemId()) { + case android.R.id.home: //默认添加的 + finish(); + break; + } return false; } } diff --git a/app/src/main/java/com/hxy/manager/activity/bill/BillIn.java b/app/src/main/java/com/hxy/manager/activity/bill/BillInActivity.java similarity index 96% rename from app/src/main/java/com/hxy/manager/activity/bill/BillIn.java rename to app/src/main/java/com/hxy/manager/activity/bill/BillInActivity.java index e96ac1a132c2c92ea32bf8d7b91ca5ebb15b0e66..ec24487690af4e1926e4b01a8bf5d3fb81de6e9b 100755 --- a/app/src/main/java/com/hxy/manager/activity/bill/BillIn.java +++ b/app/src/main/java/com/hxy/manager/activity/bill/BillInActivity.java @@ -1,5 +1,6 @@ package com.hxy.manager.activity.bill; +import android.app.ActionBar; import android.app.Activity; import android.os.Bundle; import android.widget.BaseAdapter; @@ -7,7 +8,7 @@ import android.widget.ListView; import com.hxy.manager.R; -public class BillIn extends Activity { +public class BillInActivity extends Activity { ListView listView; private BaseAdapter listViewAdapter; //当前选择 @@ -17,7 +18,10 @@ public class BillIn extends Activity { super.onCreate(savedInstanceState); setContentView(R.layout.store); - getActionBar().setDisplayHomeAsUpEnabled(true);//向上返回 + ActionBar actionBar = getActionBar(); + if (actionBar != null) { + actionBar.setDisplayHomeAsUpEnabled(true);//向上返回 + }//向上返回 listView =(ListView)findViewById(R.id.listViewBillIn); // loadBillIn(); diff --git a/app/src/main/java/com/hxy/manager/activity/bill/BillNianHuoConsumerAddActivity.java b/app/src/main/java/com/hxy/manager/activity/bill/BillNianHuoConsumerAddActivity.java new file mode 100755 index 0000000000000000000000000000000000000000..c7d7b06b1a9f395c208f1ede7897701a5818c81f --- /dev/null +++ b/app/src/main/java/com/hxy/manager/activity/bill/BillNianHuoConsumerAddActivity.java @@ -0,0 +1,57 @@ +package com.hxy.manager.activity.bill; + +import android.app.Activity; +import android.content.Context; +import android.os.Bundle; +import android.view.View; +import android.widget.Button; +import android.widget.EditText; + +import com.hxy.manager.R; +import com.hxy.manager.entity.NianHuoCustomerEntity; +import com.hxy.manager.service.NianHuoCustomerService; + +/** + * 年货单添加客户 + */ +public class BillNianHuoConsumerAddActivity extends Activity { + + EditText nameEditText; + EditText phoneEditText; + EditText addressEditText; + EditText reputationEditText; + EditText noteEditText; + EditText registerDateEditText; + + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.bill_nianhuo_consumer_add_activity); + setTitle("添加客户"); + + View view; + nameEditText = (EditText) findViewById(R.id.editText1); + phoneEditText = (EditText) findViewById(R.id.editText2); + addressEditText = (EditText) findViewById(R.id.editText3); + reputationEditText = (EditText) findViewById(R.id.editText4); + noteEditText = (EditText) findViewById(R.id.editText5); + registerDateEditText = (EditText) findViewById(R.id.editDateEditText); + + + Button button = findViewById(R.id.save); + final Context context = this; + button.setOnClickListener(view1 -> { + NianHuoCustomerEntity nianHuoCustomerEntity = new NianHuoCustomerEntity(); + nianHuoCustomerEntity.setName(nameEditText.getText().toString()); + nianHuoCustomerEntity.setPhone(phoneEditText.getText().toString()); + nianHuoCustomerEntity.setAddress(addressEditText.getText().toString()); + nianHuoCustomerEntity.setReputation(reputationEditText.getText().toString()); + + NianHuoCustomerService.postToServer(context, nianHuoCustomerEntity); + + }); + + + } +} diff --git a/app/src/main/java/com/hxy/manager/activity/bill/BillNianhuo.java b/app/src/main/java/com/hxy/manager/activity/bill/BillNianhuo.java deleted file mode 100755 index 0874a519dbe1539811187dad2b9c1c7186b0e8b2..0000000000000000000000000000000000000000 --- a/app/src/main/java/com/hxy/manager/activity/bill/BillNianhuo.java +++ /dev/null @@ -1,188 +0,0 @@ -package com.hxy.manager.activity.bill; - -import android.app.Activity; -import android.app.AlertDialog; -import android.content.DialogInterface; -import android.content.Intent; -import android.os.Bundle; -import android.view.Menu; -import android.view.MenuItem; -import android.widget.BaseAdapter; -import android.widget.ListView; - -import com.hxy.manager.R; - -public class BillNianhuo extends Activity { - private ListView listView; - // ListView列表适配器 - private BaseAdapter listViewAdapter; - // 当前选择 - private int selecteItem = 0; - - @Override - protected void onCreate(Bundle savedInstanceState) { - - super.onCreate(savedInstanceState); - setContentView(R.layout.bill_nianhuo_activity); - setTitle("年货单"); - getActionBar().setDisplayHomeAsUpEnabled(true);// 向上返回 - listView = (ListView) findViewById(R.id.listView1); - } - - void loadNianhuo() { - - /* - * - * //获取所有通讯录联系人 MakeTable ct = new MakeTable(this); users = - * ct.getAllData(); /* 并没有解决逆序 for (int start = 0, end = users.length - - * 1; start < end; start++, end--) { LeiXing temp = users[end]; - * users[end] = users[start]; users[start] = temp; } - * - * //listView列表实现适配器 listViewAdapter = new BaseAdapter() { - * - * - * - * @Override public View getView(int position, View convertView, - * ViewGroup parent) { - * - * //逆序的实现,貌似会带来listView的卡顿。position是listview的位置。position2是的数据库的位置 int - * position2= users.length-1-position; - * - * //加入,这个类是自定义的静态类。 ViewHolder holder; - * - * if(convertView==null){ /* TextView textView= new - * TextView(Store.this); textView.setTextSize(22); convertView=textView; - * - * - * final LayoutInflater inflater = (LayoutInflater) - * getApplicationContext().getSystemService(Context. - * LAYOUT_INFLATER_SERVICE); convertView = - * inflater.inflate(R.layout.item,null); holder = new ViewHolder(); - * holder.icon=(ImageView)convertView.findViewById(R.id.imageView); - * holder.name=(TextView)convertView.findViewById(R.id.nameView); - * holder.price=(TextView)convertView.findViewById(R.id.priceView); - * convertView.setTag(holder); - * - * } else { holder=(ViewHolder)convertView.getTag(); } - * - * - * - * /************************三元运算符**************************** // String - * price = - * users[position].getPrice()==null?"":users[position].getPrice(); // - * ((TextView)convertView).setText(""+users[position].getName() - * +"\n "+position+"价格: "+price); // - * ((TextView)convertView).setText((position+1)+".书名:"+users[position]. - * getName()+"\n "+"价格: "+price); - * - * - * holder.icon.setImageResource(R.drawable.store); - * holder.name.setText(users[position2].getName()); - * holder.price.setText(users[position2].getPrice()); - * - * // position是listview的位置。 if(position==selecteItem){ - * convertView.setBackgroundColor(0x5f1296db); // Toast.makeText(this, - * "text", Toast.LENGTH_LONG).show(); } else{ - * convertView.setBackgroundColor(0); } return convertView; } - * - * @Override public long getItemId(int position) { // TODO - * Auto-generated method stub return position; } - * - * @Override public Object getItem(int position) { // TODO - * Auto-generated method stub return users[position]; } - * - * @Override public int getCount() { // TODO Auto-generated method stub - * return users.length; } }; //设置listView控件的适配器 - * listView.setAdapter(listViewAdapter); //长按 - * listView.setOnItemLongClickListener(new - * AdapterView.OnItemLongClickListener() { - * - * @Override public boolean onItemLongClick(AdapterView arg0, View - * arg1, int arg2, long arg3) { // TODO Auto-generated method stub - * selecteItem=arg2; //逆序的实现,貌似会带来listView的卡顿。 int selecteItem2= - * users.length-1-selecteItem; // - * Toast.makeText(Store.this,"长按修改",Toast.LENGTH_SHORT).show(); - * if(users[selecteItem2].getNumber()!=null){ Intent intent3 = new - * Intent(Store.this,Update.class); intent3.putExtra("scanCode", - * users[selecteItem2].getNumber()); startActivity(intent3); } else { - * Toast.makeText(Store.this, "没有数据",Toast.LENGTH_SHORT).show(); } - * - * return true; - * - * } } ); //短按 listView.setOnItemClickListener(new - * AdapterView.OnItemClickListener() { - * - * @Override public void onItemClick(AdapterView arg0, View arg1, int - * arg2, long arg3) { // TODO Auto-generated method stub /* //记录单击列的位置 - * selecteItem=arg2; //刷新列表 listViewAdapter.notifyDataSetChanged(); - * - * - * selecteItem=arg2; //逆序的实现,貌似会带来listView的卡顿。 int selecteItem2= - * users.length-1-selecteItem; - * - * if(users[selecteItem2].getNumber()!=null){ Intent intent3 = new - * Intent(Store.this,Show.class); intent3.putExtra("scanCode", - * users[selecteItem2].getNumber()); startActivity(intent3); } else { - * Toast.makeText(Store.this, "空",Toast.LENGTH_SHORT).show(); } - * - * - * } - * - * }); - * - * - */ - - } - - @Override - public boolean onCreateOptionsMenu(Menu menu) { - getMenuInflater().inflate(R.menu.bill_nianhuo_comsumer, menu); - return super.onCreateOptionsMenu(menu); - } - - public boolean onOptionsItemSelected(MenuItem item) { - - switch (item.getItemId()) { - case android.R.id.home: // 默认添加的,左边的TItle向上返回 - finish(); - break; - case R.id.consumer_add:// 保存 - startActivity(new Intent(BillNianhuo.this, BillNianhuoConsumerAddActivity.class)); - // Toast.makeText(Store.this,"点击了添加!",Toast.LENGTH_SHORT).show(); - break; - case R.id.action_find: - // Toast.makeText(this, "点击了查询!", Toast.LENGTH_LONG).show(); - // new Today.FindDialog(this).show(); - break; - case R.id.action_statistics: - - AlertDialog.Builder builder = new AlertDialog.Builder(this); - builder.setTitle("统计"); - // 04 builder.setIcon(R.drawable.scan); - // 下一步进行主页面adapter的列表自定义。 - - //builder.setMessage("菜品:" + TP.length + " 种"); - builder.setPositiveButton("确定", new DialogInterface.OnClickListener() { - - @Override - public void onClick(DialogInterface arg0, int arg1) { - // TODO Auto-generated method stub - } - }); - builder.create(); - builder.show(); - break; - /* - * case R.id.action_logs: startActivity(new - * Intent(Today.this,Logs.class)); // - * Toast.makeText(Store.this,"点击了添加!",Toast.LENGTH_SHORT).show(); break; - * - */ - - } - return false; - - } - -} diff --git a/app/src/main/java/com/hxy/manager/activity/bill/BillNianhuoActivity.java b/app/src/main/java/com/hxy/manager/activity/bill/BillNianhuoActivity.java new file mode 100755 index 0000000000000000000000000000000000000000..5a02c42308dfd47877c14fe26dd2875271351327 --- /dev/null +++ b/app/src/main/java/com/hxy/manager/activity/bill/BillNianhuoActivity.java @@ -0,0 +1,87 @@ +package com.hxy.manager.activity.bill; + +import android.app.ActionBar; +import android.app.Activity; +import android.app.AlertDialog; +import android.content.DialogInterface; +import android.content.Intent; +import android.os.Bundle; +import android.view.Menu; +import android.view.MenuItem; +import android.widget.BaseAdapter; +import android.widget.ListView; + +import com.hxy.manager.R; + +public class BillNianhuoActivity extends Activity { + private ListView listView; + // ListView列表适配器 + private BaseAdapter listViewAdapter; + // 当前选择 + private int selecteItem = 0; + + @Override + protected void onCreate(Bundle savedInstanceState) { + + super.onCreate(savedInstanceState); + setContentView(R.layout.bill_nianhuo_activity); + setTitle("年货单"); + ActionBar actionBar = getActionBar(); + if (actionBar != null) { + actionBar.setDisplayHomeAsUpEnabled(true);//向上返回 + }// 向上返回 + listView = (ListView) findViewById(R.id.listView1); + + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.bill_nianhuo_comsumer, menu); + return super.onCreateOptionsMenu(menu); + } + + public boolean onOptionsItemSelected(MenuItem item) { + + switch (item.getItemId()) { + case android.R.id.home: // 默认添加的,左边的TItle向上返回 + finish(); + break; + case R.id.consumer_add:// 保存 + startActivity(new Intent(BillNianhuoActivity.this, BillNianHuoConsumerAddActivity.class)); + // Toast.makeText(Store.this,"点击了添加!",Toast.LENGTH_SHORT).show(); + break; + case R.id.action_find: + // Toast.makeText(this, "点击了查询!", Toast.LENGTH_LONG).show(); + // new Today.FindDialog(this).show(); + break; + case R.id.action_statistics: + + AlertDialog.Builder builder = new AlertDialog.Builder(this); + builder.setTitle("统计"); + // 04 builder.setIcon(R.drawable.scan); + // 下一步进行主页面adapter的列表自定义。 + + //builder.setMessage("菜品:" + TP.length + " 种"); + builder.setPositiveButton("确定", new DialogInterface.OnClickListener() { + + @Override + public void onClick(DialogInterface arg0, int arg1) { + // TODO Auto-generated method stub + } + }); + builder.create(); + builder.show(); + break; + /* + * case R.id.action_logs: startActivity(new + * Intent(Today.this,Logs.class)); // + * Toast.makeText(Store.this,"点击了添加!",Toast.LENGTH_SHORT).show(); break; + * + */ + + } + return false; + + } + +} diff --git a/app/src/main/java/com/hxy/manager/activity/bill/BillNianhuoConsumerAddActivity.java b/app/src/main/java/com/hxy/manager/activity/bill/BillNianhuoConsumerAddActivity.java deleted file mode 100755 index d6366332f4dd6a2e0f384ad68e72645c91543b77..0000000000000000000000000000000000000000 --- a/app/src/main/java/com/hxy/manager/activity/bill/BillNianhuoConsumerAddActivity.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.hxy.manager.activity.bill; - -import com.hxy.manager.R; - -import android.app.Activity; -import android.os.Bundle; - -public class BillNianhuoConsumerAddActivity extends Activity{ - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.bill_nianhuo_consumer_add_activity); - setTitle("添加客户"); - } -} diff --git a/app/src/main/java/com/hxy/manager/activity/goods/GoodsAddActivity.java b/app/src/main/java/com/hxy/manager/activity/goods/GoodsAddActivity.java index c71d567ef5380f074baee3d47a9c1d549b4ebbca..6b6f415ec285b89b84bd39081e1ca7ff1243f311 100755 --- a/app/src/main/java/com/hxy/manager/activity/goods/GoodsAddActivity.java +++ b/app/src/main/java/com/hxy/manager/activity/goods/GoodsAddActivity.java @@ -1,7 +1,9 @@ package com.hxy.manager.activity.goods; +import static com.hxy.manager.service.GoodsEntityService.postToServer; + import android.Manifest; -import android.app.Activity; +import android.app.ActionBar; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; @@ -14,12 +16,14 @@ import android.widget.Button; import android.widget.EditText; import android.widget.Toast; +import androidx.appcompat.app.AppCompatActivity; import androidx.core.app.ActivityCompat; import androidx.core.content.ContextCompat; import com.hxy.manager.R; import com.hxy.manager.activity.CaptureActivity; import com.hxy.manager.dao.DBManager; +import com.hxy.manager.dao.GoodsMapper; import com.hxy.manager.entity.GoodsEntity; import com.hxy.manager.entity.GoodsEntityDao; import com.hxy.manager.service.GoodsEntityService; @@ -30,13 +34,11 @@ import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; -import static com.hxy.manager.service.GoodsEntityService.postToServer; - /** * Created by admin-home on 2017/12/31. */ -public class GoodsAddActivity extends Activity { +public class GoodsAddActivity extends AppCompatActivity { EditText editText0; EditText editText1; @@ -54,7 +56,11 @@ public class GoodsAddActivity extends Activity { setContentView(R.layout.add); setTitle("添加"); goodsAddActivity = this; - getActionBar().setDisplayHomeAsUpEnabled(true);//向上返回 + ActionBar actionBar = getActionBar(); + if (actionBar != null) { + actionBar.setDisplayHomeAsUpEnabled(true);//向上返回 + actionBar.setTitle("设置"); + } editText0 = (EditText) findViewById(R.id.editText0); editText1 = (EditText) findViewById(R.id.editText1); editText2 = (EditText) findViewById(R.id.editText2); @@ -95,8 +101,6 @@ public class GoodsAddActivity extends Activity { } else { startActivityForResult(new Intent(GoodsAddActivity.this, CaptureActivity.class), 0); } - // Intent intent = new Intent(Add.this, CaptureActivity.class); - // startActivityForResult(intent , 0x1); } }); Button save = (Button) findViewById(R.id.save); @@ -113,7 +117,6 @@ public class GoodsAddActivity extends Activity { Toast.makeText(GoodsAddActivity.this, "条形码不能为空!", Toast.LENGTH_SHORT).show(); // TODO 查询是否存在了 - } else if (editText1.getText().toString().equals("")) { // if(editText0.getText().toString().equals("")||editText1.getText().toString().equals("")||editText2.getText().toString().equals("")||editText3.getText().toString().equals("")||editText4.getText().toString().equals("")||editText4.getText().toString().equals("")||editText5.getText().toString().equals("")||editText6.getText().toString().equals("")) { @@ -140,7 +143,7 @@ public class GoodsAddActivity extends Activity { goodsEntity.setUpdateTime(System.currentTimeMillis()); - long id = GoodsEntityService.save(context, goodsEntity); + long id = GoodsMapper.save(context, goodsEntity); // 同步到线上服务器 postToServer(context, goodsEntity); goodsEntity.setId(id); @@ -153,13 +156,9 @@ public class GoodsAddActivity extends Activity { editText4.setText(""); editText5.setText(""); } - } - } }); - - } diff --git a/app/src/main/java/com/hxy/manager/activity/goods/GoodsShowActivity.java b/app/src/main/java/com/hxy/manager/activity/goods/GoodsShowActivity.java index e4cf045ff2bd1b51a77aa2b61ee366fb56c911b1..11250a98df0abbf4f5407c2334704f1a2970443b 100755 --- a/app/src/main/java/com/hxy/manager/activity/goods/GoodsShowActivity.java +++ b/app/src/main/java/com/hxy/manager/activity/goods/GoodsShowActivity.java @@ -2,7 +2,7 @@ package com.hxy.manager.activity.goods; import android.Manifest; -import android.app.Activity; +import android.app.ActionBar; import android.content.Intent; import android.content.pm.PackageManager; import android.os.Bundle; @@ -14,6 +14,7 @@ import android.widget.Button; import android.widget.TextView; import android.widget.Toast; +import androidx.appcompat.app.AppCompatActivity; import androidx.core.app.ActivityCompat; import androidx.core.content.ContextCompat; @@ -22,21 +23,27 @@ import com.hxy.manager.activity.CaptureActivity; import com.hxy.manager.dao.DBManager; import com.hxy.manager.entity.GoodsEntity; import com.hxy.manager.entity.GoodsEntityDao; -import com.hxy.manager.service.GoodsEntityService; +import com.uncopt.android.widget.text.justify.JustifiedTextView; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Created by 傲寒宏志 on 2018/1/1. */ -public class GoodsShowActivity extends Activity { +public class GoodsShowActivity extends AppCompatActivity { + + Logger log = LoggerFactory.getLogger(GoodsStoreActivity.class); + TextView textView0; - TextView textView1; - TextView textView2; + JustifiedTextView textView1; + JustifiedTextView textView2; TextView textView3; TextView textView4; TextView textView5; TextView textView6; - String scanCode; + GoodsEntity goodsEntity; public static GoodsShowActivity goodsShowActivity; @@ -47,40 +54,23 @@ public class GoodsShowActivity extends Activity { setContentView(R.layout.show); setTitle("商品内容"); - getActionBar().setDisplayHomeAsUpEnabled(true);//向上返回 - + ActionBar actionBar = getActionBar(); + if (actionBar != null) { + actionBar.setDisplayHomeAsUpEnabled(true);//向上返回 + }//向上返回 goodsShowActivity = this; textView0 = (TextView) findViewById(R.id.TextView0); - textView1 = (TextView) findViewById(R.id.TextView1); - textView2 = (TextView) findViewById(R.id.TextView2); + textView1 = (JustifiedTextView) findViewById(R.id.TextView1); + + textView2 = (JustifiedTextView) findViewById(R.id.TextView2); textView3 = (TextView) findViewById(R.id.TextView3); textView4 = (TextView) findViewById(R.id.TextView4); textView5 = (TextView) findViewById(R.id.TextView5); textView6 = (TextView) findViewById(R.id.TextView6); - Intent intent = getIntent(); - scanCode = intent.getStringExtra("scanCode"); - Log.i("kan", "show页面的scanCode:" + scanCode); - - if (scanCode != null) { - - - GoodsEntity user = GoodsEntityService.getOneByNumber(GoodsShowActivity.this, scanCode); - - if (user != null) { - textView0.setText(user.getNumber()); - textView1.setText(user.getName()); - textView2.setText(user.getPrice()); - textView3.setText(user.getPress()); - textView4.setText(user.getDate()); - textView5.setText(user.getAuthor()); - textView6.setText(user.getLocation()); - } - } - Button scan = (Button) findViewById(R.id.scan); scan.setOnClickListener(new View.OnClickListener() { @@ -93,11 +83,9 @@ public class GoodsShowActivity extends Activity { } else { startActivityForResult(new Intent(GoodsShowActivity.this, CaptureActivity.class), 0); } - } }); - } @Override @@ -113,14 +101,11 @@ public class GoodsShowActivity extends Activity { case android.R.id.home: //默认添加的,左边的TItle向上返回 finish(); break; - /* - case R.id.message://保存 - Toast.makeText(Show.this,"点击了添加!",Toast.LENGTH_SHORT).show(); - break; - */ case R.id.modify: Intent intent3 = new Intent(GoodsShowActivity.this, GoodsUpdateActivity.class); - intent3.putExtra("scanCode", scanCode); + Bundle bundle = new Bundle(); + bundle.putSerializable("goodsEntity", goodsEntity); + intent3.putExtras(bundle); startActivity(intent3); } return false; @@ -134,14 +119,13 @@ public class GoodsShowActivity extends Activity { if (resultCode == RESULT_OK && intent1 != null) { Bundle bundle = intent1.getExtras(); - // Toast.makeText(this,"扫描结果:"+bundle.getString("result"),Toast.LENGTH_LONG).show(); - //查询数据库 - scanCode = bundle.getString("result"); - + String scanCode = bundle.getString("result"); + Log.i("kkk", "扫码后的结果:" + scanCode); + Toast.makeText(this, "扫描结果:" + scanCode, Toast.LENGTH_LONG).show(); + // 查询数据库 GoodsEntityDao goodsEntityDao = DBManager.getReadSession(this).getGoodsEntityDao(); GoodsEntity user = goodsEntityDao.queryBuilder().where(GoodsEntityDao.Properties.Number.eq(scanCode)).unique(); -// //如果在数据库中不存在,那么就跳转到添加中 if (user == null) { Intent intent = new Intent(GoodsShowActivity.this, GoodsAddActivity.class); intent.putExtra("scanCode", scanCode); @@ -149,8 +133,7 @@ public class GoodsShowActivity extends Activity { //跳转并关闭当前activity finish(); } else { - - + //如果在数据库中不存在,那么就跳转到添加中 Intent intent = new Intent(GoodsShowActivity.this, GoodsShowActivity.class); intent.putExtra("scanCode", scanCode); startActivity(intent); @@ -158,10 +141,8 @@ public class GoodsShowActivity extends Activity { Toast.makeText(this, "你又扫了一次", Toast.LENGTH_LONG).show(); } - - } else { - + log.info("展示界面的resultCode={}", resultCode); } } @@ -171,42 +152,23 @@ public class GoodsShowActivity extends Activity { super.onResume(); Intent intent = getIntent(); - String scanCode = intent.getStringExtra("scanCode"); - if (scanCode != null) { - - - - GoodsEntity user = GoodsEntityService.getOneByNumber(GoodsShowActivity.this, scanCode); - - Log.i("kkk", "检查user是:" + user); - //不为空就说明这个个是修改后所得到数据 - if (user != null) { - - textView0 = (TextView) findViewById(R.id.TextView0); - textView1 = (TextView) findViewById(R.id.TextView1); - textView2 = (TextView) findViewById(R.id.TextView2); - textView3 = (TextView) findViewById(R.id.TextView3); - textView4 = (TextView) findViewById(R.id.TextView4); - textView5 = (TextView) findViewById(R.id.TextView5); - textView6 = (TextView) findViewById(R.id.TextView6); - - - textView0.setText(user.getNumber()); - textView1.setText(user.getName()); - textView2.setText(user.getPrice()); - textView3.setText(user.getPress()); - textView4.setText(user.getDate()); - textView5.setText(user.getAuthor()); - textView6.setText(user.getLocation()); - } else { - Log.e("kkk", "scanCode为空就说明已经删除了就可以直接关闭当前Activity"); - //空就说明已经删除了就可以直接关闭当前Activity - finish(); - } - - + goodsEntity = (GoodsEntity) intent.getSerializableExtra("goodsEntity"); + if (goodsEntity != null) { + + Log.i("kkk", "检查goodsEntity是:" + goodsEntity); + + textView0.setText(goodsEntity.getNumber()); + textView1.setText(goodsEntity.getName()); + textView2.setText(goodsEntity.getPrice()); + textView3.setText(goodsEntity.getPress()); + textView4.setText(goodsEntity.getDate()); + textView5.setText(goodsEntity.getAuthor()); + textView6.setText(goodsEntity.getLocation()); + } else { + Log.e("kkk", "scanCode为空就说明已经删除了就可以直接关闭当前Activity"); + //空就说明已经删除了就可以直接关闭当前Activity + finish(); } - } } diff --git a/app/src/main/java/com/hxy/manager/activity/goods/GoodsStoreActivity.java b/app/src/main/java/com/hxy/manager/activity/goods/GoodsStoreActivity.java index ca9fc2f7638ec4cc32df7a4ad0c88f5ca517d5dd..564c92669bea0caa96154fdf34d1c2c177806265 100755 --- a/app/src/main/java/com/hxy/manager/activity/goods/GoodsStoreActivity.java +++ b/app/src/main/java/com/hxy/manager/activity/goods/GoodsStoreActivity.java @@ -1,7 +1,6 @@ package com.hxy.manager.activity.goods; import android.Manifest; -import android.app.Activity; import android.app.AlertDialog; import android.app.Dialog; import android.content.BroadcastReceiver; @@ -12,6 +11,7 @@ import android.content.Intent; import android.content.IntentFilter; import android.content.ServiceConnection; import android.content.pm.PackageManager; +import android.graphics.drawable.Drawable; import android.os.Bundle; import android.os.IBinder; import android.util.Log; @@ -30,6 +30,7 @@ import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; +import androidx.appcompat.app.AppCompatActivity; import androidx.core.app.ActivityCompat; import androidx.core.content.ContextCompat; @@ -40,6 +41,7 @@ import com.hxy.manager.entity.GoodsEntity; import com.hxy.manager.service.GoodsEntityService; import com.hxy.manager.service.SyncService; import com.hxy.manager.util.Constant; +import com.hxy.manager.util.StringUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -53,9 +55,9 @@ import java.util.List; * 库存 */ -public class GoodsStoreActivity extends Activity { +public class GoodsStoreActivity extends AppCompatActivity { - List userList = new ArrayList<>(); + List goodsEntities = new ArrayList<>(); public static GoodsStoreActivity goodsStoreActivity; /** @@ -68,11 +70,14 @@ public class GoodsStoreActivity extends Activity { */ private BaseAdapter listViewAdapter; - // 当前选择 + /** + * 当前选择 + */ private int selecteItem = 0; - // 判断是查询还是添加 - + /** + * 判断是查询还是添加 + */ int flag = 0; int i = 0;// 用于判断是点击了查询还是其他,然后决定返回键的作用 @@ -80,9 +85,15 @@ public class GoodsStoreActivity extends Activity { private SyncService syncService; + /** + * 注册广播,用来Service和Activity之间通信,用来数据加载之后刷新界面 + */ BroadcastReceiver receiver = null; - Intent intent; + public static GoodsStoreActivity getCurrentActivity() { + return goodsStoreActivity; + } + @Override protected void onCreate(Bundle savedInstanceState) { @@ -90,7 +101,12 @@ public class GoodsStoreActivity extends Activity { super.onCreate(savedInstanceState); setTitle("库存商品"); setContentView(R.layout.store); - getActionBar().setDisplayHomeAsUpEnabled(true);// 向上返回 + + android.app.ActionBar actionBar1 = getActionBar(); + if (actionBar1 != null) { + actionBar1.setTitle("库存商品"); + actionBar1.setDisplayHomeAsUpEnabled(true);// 向上返回 + } listView = (ListView) findViewById(R.id.listView1); goodsStoreActivity = this; loadBook(); @@ -107,17 +123,21 @@ public class GoodsStoreActivity extends Activity { receiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { - String s = intent.getExtras().getString(Constant.MESSAGE); - log.info("\n===>广播接收到信息[{}]",s); - userList = GoodsEntityService.listAll(GoodsStoreActivity.this); - // 刷新列表 - listViewAdapter.notifyDataSetChanged(); - Toast.makeText(GoodsStoreActivity.this, "更新成功!", Toast.LENGTH_SHORT).show(); - if ("postexception".equals(s)) { - Toast.makeText(GoodsStoreActivity.this, "网络异常!", Toast.LENGTH_SHORT).show(); - } else - Toast.makeText(GoodsStoreActivity.this, s, Toast.LENGTH_LONG).show(); - + log.info("\n===>广播开始接收到信息"); + Bundle extras = intent.getExtras(); + if (extras != null) { + String message = extras.getString(Constant.MESSAGE); + log.info("\n===>广播接收到信息[{}]", message); + goodsEntities = GoodsEntityService.listAll(GoodsStoreActivity.this); + // 刷新列表 + listViewAdapter.notifyDataSetChanged(); + if (StringUtil.hasText(message)) { + Toast.makeText(GoodsStoreActivity.this, message, Toast.LENGTH_LONG).show(); + } + } else { + log.info("没有广播信息"); + throw new RuntimeException("不应该没有信息,否则上面无法 "); + } } }; IntentFilter filter = new IntentFilter(Constant.BROADCAST_ACTION); @@ -141,14 +161,12 @@ public class GoodsStoreActivity extends Activity { /** * 修改后重新加载 */ - @Override protected void onResume() { super.onResume(); - userList = GoodsEntityService.listAll(this); + goodsEntities = GoodsEntityService.listAll(this); // 刷新列表 - listViewAdapter.notifyDataSetChanged(); } @@ -163,7 +181,7 @@ public class GoodsStoreActivity extends Activity { // 点击了查询,后的结果,然后点击返回,再返回到所有数据的列表 if (flag == 1 && i == 0) { i++; - userList = GoodsEntityService.listAll(this); + goodsEntities = GoodsEntityService.listAll(this); // 刷新列表 listViewAdapter.notifyDataSetChanged(); } else @@ -189,8 +207,6 @@ public class GoodsStoreActivity extends Activity { flag = 0; break; case R.id.action_scan: - // Toast.makeText(this, "点击了扫码!", Toast.LENGTH_LONG).show(); - if (ContextCompat.checkSelfPermission(GoodsStoreActivity.this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(GoodsStoreActivity.this, new String[]{Manifest.permission.CAMERA}, 1); @@ -210,8 +226,8 @@ public class GoodsStoreActivity extends Activity { // 04 builder.setIcon(R.drawable.scan); // 下一步进行主页面adapter的列表自定义。 - int size = userList.size(); - if (size == 1 && userList.get(0).getName().contains("数据为空")) { + int size = goodsEntities.size(); + if (size == 1 && goodsEntities.get(0).getName().contains("数据为空")) { builder1.setMessage("当前没有库存商品"); } else { builder1.setMessage("共计:" + size + " 种商品"); @@ -221,52 +237,21 @@ public class GoodsStoreActivity extends Activity { @Override public void onClick(DialogInterface arg0, int arg1) { - // TODO Auto-generated method stub } }); builder1.create(); builder1.show(); break; - /* - * case R.id.action_about: - * - * AlertDialog.Builder builder= new AlertDialog.Builder(this); - * builder.setTitle("关于"); //04 builder.setIcon(R.drawable.scan); - * //下一步进行主页面adapter的列表自定义。 - * - * builder.setMessage("版本:1.17.5\n作者:aohanhongzhi@qq.com\n日期:2018年3月16日" - * ); builder.setPositiveButton("确定", new - * DialogInterface.OnClickListener() { - * - * @Override public void onClick(DialogInterface arg0, int arg1) { // - * TODO Auto-generated method stub } }); builder.create(); - * builder.show(); break; - */ case R.id.action_sync: -// 同步数据到服务器 - // Intent intent = new Intent(Store.this,MainService.class); - // Toast.makeText(this, "点击了同步!", Toast.LENGTH_SHORT).show(); - // intent = new Intent(Store.this,SyncService.class); - // startService(intent); +// 数据同步 同步数据到服务器 if (syncService == null) { Toast.makeText(this, "服务未绑定成功!", Toast.LENGTH_SHORT).show(); return false; } else { Log.i("kan", "开始同步数据!"); -// Toast.makeText(this, "开始同步数据!", Toast.LENGTH_SHORT).show(); - syncService.uploadData();// 同步数据 + startService(new Intent(getBaseContext(), SyncService.class)); } - break; -// case R.id.action_nosync: -//// syncService.download(); -// Toast.makeText(this, "开始恢复数据!", Toast.LENGTH_SHORT).show(); -// break; - /* - * case R.id.action_settings: startActivity(new - * Intent(Store.this,SettingActivity.class)); break; - */ - } return false; @@ -280,8 +265,6 @@ public class GoodsStoreActivity extends Activity { // Toast.makeText(this,"扫描结果:"+bundle.getString("result"),Toast.LENGTH_LONG).show(); // 查询数据库 String scanCode = bundle.getString("result"); -// MakeTable mt = new MakeTable(Store.this); -// GoodsEntity user = mt.getUserByNumber(scanCode); GoodsEntity oneByNumber = GoodsEntityService.getOneByNumber(this, scanCode); // 如果在数据库中不存在,那么就跳转到添加中 if (oneByNumber == null) { @@ -298,7 +281,7 @@ public class GoodsStoreActivity extends Activity { } } - // 内部类?********************/ + public class FindDialog extends Dialog { public FindDialog(Context context) { @@ -324,22 +307,7 @@ public class GoodsStoreActivity extends Activity { public void onClick(View v) { EditText value = (EditText) findViewById(R.id.value); String values = value.getText().toString(); - /* - * //捕获异常的方法判断是否为数字 try{ Integer.parseInt(values); - * - * - * - * }catch(NumberFormatException e) { Log.i("kan","异常:\"" + - * values + "\"不是数字/整数..."); - * - * } - */ - userList = GoodsEntityService.getOneBySearch(GoodsStoreActivity.this, values); - - // for(int i=0 ; i arg0, View arg1, int arg2, long arg3) { selecteItem = arg2; // 逆序的实现,貌似会带来listView的卡顿。 - int selecteItem2 = userList.size() - 1 - selecteItem; - // Toast.makeText(Store.this,"长按修改",Toast.LENGTH_SHORT).show(); - GoodsEntity goodsEntity = userList.get(selecteItem2); + int selecteItem2 = goodsEntities.size() - 1 - selecteItem; + GoodsEntity goodsEntity = goodsEntities.get(selecteItem2); if (goodsEntity.getNumber() != null) { Intent intent3 = new Intent(GoodsStoreActivity.this, GoodsUpdateActivity.class); intent3.putExtra("scanCode", goodsEntity.getNumber()); + intent3.putExtra("goodsEntity", goodsEntity); startActivity(intent3); } else { Toast.makeText(GoodsStoreActivity.this, "没有数据", Toast.LENGTH_SHORT).show(); } - return true; - } }); + // 短按 listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView arg0, View arg1, int arg2, long arg3) { - /* - * //记录单击列的位置 selecteItem=arg2; //刷新列表 - * listViewAdapter.notifyDataSetChanged(); - */ selecteItem = arg2; // 逆序的实现,貌似会带来listView的卡顿。 - int selecteItem2 = userList.size() - 1 - selecteItem; - GoodsEntity goodsEntity = userList.get(selecteItem2); + int selecteItem2 = goodsEntities.size() - 1 - selecteItem; + GoodsEntity goodsEntity = goodsEntities.get(selecteItem2); String number = goodsEntity.getNumber(); if (number != null) { - Log.i("kan", "当前" + number); + Log.i("kan", "====>当前" + number); + log.info("\n====>当前的number{}", number); Intent intent3 = new Intent(GoodsStoreActivity.this, GoodsShowActivity.class); - intent3.putExtra("scanCode", number); + Bundle bundle = new Bundle(); + bundle.putSerializable("goodsEntity", goodsEntity); + intent3.putExtras(bundle); startActivity(intent3); + } else { Toast.makeText(GoodsStoreActivity.this, "空", Toast.LENGTH_SHORT).show(); } - } - }); - } @Override diff --git a/app/src/main/java/com/hxy/manager/activity/goods/GoodsUpdateActivity.java b/app/src/main/java/com/hxy/manager/activity/goods/GoodsUpdateActivity.java index 09bc4686d9893aeb835b9836bf5a8bdc5e3b13a0..51ce6564c8779c08390777f0661a66dc6e847964 100755 --- a/app/src/main/java/com/hxy/manager/activity/goods/GoodsUpdateActivity.java +++ b/app/src/main/java/com/hxy/manager/activity/goods/GoodsUpdateActivity.java @@ -1,7 +1,7 @@ package com.hxy.manager.activity.goods; -import android.app.Activity; +import android.app.ActionBar; import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; @@ -16,6 +16,8 @@ import android.widget.EditText; import android.widget.TextView; import android.widget.Toast; +import androidx.appcompat.app.AppCompatActivity; + import com.hxy.manager.R; import com.hxy.manager.entity.GoodsEntity; import com.hxy.manager.service.GoodsEntityService; @@ -29,7 +31,7 @@ import java.util.Date; * Created by 傲寒宏志 on 2018/1/1. */ -public class GoodsUpdateActivity extends Activity { +public class GoodsUpdateActivity extends AppCompatActivity { TextView textView; EditText editText1; EditText editText2; @@ -37,16 +39,21 @@ public class GoodsUpdateActivity extends Activity { EditText editText4; EditText editText5; EditText editText6; - GoodsEntity user; + GoodsEntity goodsEntity; Context context; + public static GoodsUpdateActivity goodsUpdateActivity; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.update); setTitle("商品修改"); - - getActionBar().setDisplayHomeAsUpEnabled(true);//向上返回 + goodsUpdateActivity = this; + ActionBar actionBar = getActionBar(); + if (actionBar != null) { + actionBar.setDisplayHomeAsUpEnabled(true);//向上返回 + }//向上返回 textView = (TextView) findViewById(R.id.textView); editText1 = (EditText) findViewById(R.id.editText1); editText2 = (EditText) findViewById(R.id.editText2); @@ -56,25 +63,22 @@ public class GoodsUpdateActivity extends Activity { editText6 = (EditText) findViewById(R.id.editDateEditText); Intent intent = getIntent(); - String scanCode = intent.getStringExtra("scanCode"); - Log.i("kan", "Update页面的接收:" + scanCode); - - user = GoodsEntityService.getOneByNumber(GoodsUpdateActivity.this, scanCode); - - if (user != null) { - textView.setText(user.getNumber()); - editText1.setText(user.getName()); - editText2.setText(user.getPrice()); - editText3.setText(user.getPress()); - editText4.setText(user.getDate()); - editText5.setText(user.getAuthor()); + goodsEntity = (GoodsEntity) intent.getSerializableExtra("goodsEntity"); + Log.i("kan", "Update页面的接收:" + goodsEntity); + + if (goodsEntity != null) { + textView.setText(goodsEntity.getNumber()); + editText1.setText(goodsEntity.getName()); + editText2.setText(goodsEntity.getPrice()); + editText3.setText(goodsEntity.getPress()); + editText4.setText(goodsEntity.getDate()); + editText5.setText(goodsEntity.getAuthor()); // editText6.setText(user.getLocation()); Calendar now = Calendar.getInstance(); editText6.setText(now.get(Calendar.YEAR) + "年" + (now.get(Calendar.MONTH) + 1) + "月" + now.get(Calendar.DAY_OF_MONTH) + "日"); } else { Toast.makeText(GoodsUpdateActivity.this, "数据异常", Toast.LENGTH_SHORT).show(); - } context = this; @@ -93,15 +97,15 @@ public class GoodsUpdateActivity extends Activity { } else { - user.setNumber(textView.getText().toString()); - user.setName(editText1.getText().toString()); - user.setPrice(editText2.getText().toString()); - user.setPress(editText3.getText().toString()); - user.setDate(editText4.getText().toString()); - user.setAuthor(editText5.getText().toString()); + goodsEntity.setNumber(textView.getText().toString()); + goodsEntity.setName(editText1.getText().toString()); + goodsEntity.setPrice(editText2.getText().toString()); + goodsEntity.setPress(editText3.getText().toString()); + goodsEntity.setDate(editText4.getText().toString()); + goodsEntity.setAuthor(editText5.getText().toString()); Calendar now = Calendar.getInstance(); - user.setLocation(now.get(Calendar.YEAR) + "年" + (now.get(Calendar.MONTH) + 1) + "月" + now.get(Calendar.DAY_OF_MONTH) + "日"); - user.setLocation(editText6.getText().toString()); + goodsEntity.setLocation(now.get(Calendar.YEAR) + "年" + (now.get(Calendar.MONTH) + 1) + "月" + now.get(Calendar.DAY_OF_MONTH) + "日"); + goodsEntity.setLocation(editText6.getText().toString()); //取当前年月日时分秒最为编码 Date d = new Date(); @@ -109,9 +113,9 @@ public class GoodsUpdateActivity extends Activity { SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");//yyyy/MM/dd HH:mm:ss String dateNowStr = sdf.format(d); - user.setUpdateTime(System.currentTimeMillis()); + goodsEntity.setUpdateTime(System.currentTimeMillis()); - GoodsEntityService.update(context, user); + GoodsEntityService.update(context, goodsEntity); Toast.makeText(GoodsUpdateActivity.this, "保存成功!", Toast.LENGTH_SHORT).show(); finish(); @@ -150,7 +154,9 @@ public class GoodsUpdateActivity extends Activity { return false; } - //删除联系人 + /** + * 删除提示框 + */ private void delete() { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle("系统信息"); @@ -159,10 +165,8 @@ public class GoodsUpdateActivity extends Activity { @Override public void onClick(DialogInterface dialog, int whichButton) { - GoodsEntityService.delete(context, user); + GoodsEntityService.delete(context, goodsEntity); Toast.makeText(GoodsUpdateActivity.this, "删除成功!", Toast.LENGTH_LONG).show(); - finish(); - } }); diff --git a/app/src/main/java/com/hxy/manager/activity/today/TodayActivity.java b/app/src/main/java/com/hxy/manager/activity/today/TodayActivity.java index f819eb4c514b0b7ba25032ac4e474f664422223f..1c2126ede62020c3316e636e7057aa5b582c8cf9 100755 --- a/app/src/main/java/com/hxy/manager/activity/today/TodayActivity.java +++ b/app/src/main/java/com/hxy/manager/activity/today/TodayActivity.java @@ -1,7 +1,7 @@ package com.hxy.manager.activity.today; -import android.app.Activity; +import android.app.ActionBar; import android.app.AlertDialog; import android.app.Dialog; import android.content.Context; @@ -24,6 +24,8 @@ import android.widget.EditText; import android.widget.ListView; import android.widget.TextView; +import androidx.appcompat.app.AppCompatActivity; + import com.hxy.manager.R; import com.hxy.manager.activity.ViewHolder; import com.hxy.manager.entity.TodayPriceEntity; @@ -34,7 +36,7 @@ import java.util.Vector; * Created by 傲寒宏志 on 2018/1/13. */ -public class TodayActivity extends Activity { +public class TodayActivity extends AppCompatActivity { ListView listView; //ListView列表适配器 private BaseAdapter listViewAdapter; @@ -47,9 +49,12 @@ public class TodayActivity extends Activity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.today); - setTitle("今日菜价"); + setTitle("今日"); - getActionBar().setDisplayHomeAsUpEnabled(true);//向上返回 + ActionBar actionBar = getActionBar(); + if (actionBar != null) { + actionBar.setDisplayHomeAsUpEnabled(true);//向上返回 + }//向上返回 listView = (ListView) findViewById(R.id.listView1); LoadToday(); diff --git a/app/src/main/java/com/hxy/manager/activity/today/TodayAddActivity.java b/app/src/main/java/com/hxy/manager/activity/today/TodayAddActivity.java index 8e90d861028318ff6cadd07200a2170f954e7e54..3d60ca6cba71409dbeb13597e71ef3e43c60d323 100755 --- a/app/src/main/java/com/hxy/manager/activity/today/TodayAddActivity.java +++ b/app/src/main/java/com/hxy/manager/activity/today/TodayAddActivity.java @@ -1,7 +1,8 @@ package com.hxy.manager.activity.today; import android.Manifest; -import android.app.Activity; +import android.app.ActionBar; +import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.database.Cursor; @@ -13,6 +14,7 @@ import android.media.ExifInterface; import android.net.Uri; import android.os.Bundle; import android.os.Environment; +import android.os.StrictMode; import android.provider.MediaStore; import android.util.Log; import android.view.Menu; @@ -23,59 +25,67 @@ import android.widget.EditText; import android.widget.ImageView; import android.widget.Toast; - +import androidx.appcompat.app.AppCompatActivity; import androidx.core.app.ActivityCompat; import androidx.core.content.ContextCompat; +import com.ejlchina.okhttps.HttpResult; +import com.hxy.manager.R; +import com.hxy.manager.entity.TodayPriceEntity; +import com.hxy.manager.service.TodayEntityService; +import com.hxy.manager.util.FileUtil; + import java.io.File; import java.io.IOException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; -import com.hxy.manager.R; -import com.hxy.manager.entity.TodayPriceEntity; - /** * Created by 傲寒宏志 on 2018/1/13. */ -public class TodayAddActivity extends Activity { +public class TodayAddActivity extends AppCompatActivity { ImageView imageView; EditText editText7; EditText editText8; EditText editText9; TodayPriceEntity tp; Uri uri; - private static String picFileFullName=""; + private static String picFileFullName = ""; private static final int CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE = 100; private static final int PICK_IMAGE_ACTIVITY_REQUEST_CODE = 200; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.today_add); setTitle("添加商品"); - getActionBar().setDisplayHomeAsUpEnabled(true);//向上返回 + ActionBar actionBar = getActionBar(); + if (actionBar != null) { + actionBar.setDisplayHomeAsUpEnabled(true);//向上返回 + }//向上返回 Calendar now = Calendar.getInstance(); + initPhotoError(); - editText9=(EditText)findViewById(R.id.editText9); - editText9.setText(now.get(Calendar.YEAR)+"年"+(now.get(Calendar.MONTH) + 1) +"月"+now.get(Calendar.DAY_OF_MONTH)+"日"); + editText9 = (EditText) findViewById(R.id.editText9); + editText9.setText(now.get(Calendar.YEAR) + "年" + (now.get(Calendar.MONTH) + 1) + "月" + now.get(Calendar.DAY_OF_MONTH) + "日"); - tp=new TodayPriceEntity(); - imageView=(ImageView)findViewById(R.id.imageView7); + tp = new TodayPriceEntity(); + imageView = (ImageView) findViewById(R.id.imageView7); imageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { //获取两个权限,一个是相机权限,一个是读写外部存储器权限 - if (ContextCompat.checkSelfPermission(TodayAddActivity.this, Manifest.permission.CAMERA)!= PackageManager.PERMISSION_GRANTED){ ActivityCompat.requestPermissions(TodayAddActivity.this,new String[]{Manifest.permission.CAMERA},1); } - else if(ContextCompat.checkSelfPermission(TodayAddActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE)!= PackageManager.PERMISSION_GRANTED){ - ActivityCompat.requestPermissions(TodayAddActivity.this,new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},1); - } - else - takePicture(); + if (ContextCompat.checkSelfPermission(TodayAddActivity.this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) { + ActivityCompat.requestPermissions(TodayAddActivity.this, new String[]{Manifest.permission.CAMERA}, 1); + } else if (ContextCompat.checkSelfPermission(TodayAddActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { + ActivityCompat.requestPermissions(TodayAddActivity.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1); + } else + takePicture(); } }); imageView.setOnLongClickListener(new View.OnLongClickListener() { @@ -84,26 +94,25 @@ public class TodayAddActivity extends Activity { Intent intent = new Intent(Intent.ACTION_VIEW); //Uri mUri = Uri.parse("file://" + picFile.getPath());Android3.0以后最好不要通过该方法,存在一些小Bug - // intent.setDataAndType(Uri.fromFile(picFile), "image/*"); + // intent.setDataAndType(Uri.fromFile(picFile), "image/*"); intent.setDataAndType(uri, "image/*"); startActivity(intent); return false; } }); + final Context context = this; - - Button save = (Button)findViewById(R.id.save); + Button save = (Button) findViewById(R.id.save); save.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - editText7=(EditText)findViewById(R.id.editText7); - editText8=(EditText)findViewById(R.id.editText8); - editText9=(EditText)findViewById(R.id.editText9); - if(editText7.getText().toString().equals("")){ + editText7 = (EditText) findViewById(R.id.editText7); + editText8 = (EditText) findViewById(R.id.editText8); + editText9 = (EditText) findViewById(R.id.editText9); + if (editText7.getText().toString().equals("")) { toast("名字不能为空!"); - } - else if(editText8.getText().toString().equals("")){ + } else if (editText8.getText().toString().equals("")) { toast("价格不能为空!"); } /* @@ -126,22 +135,27 @@ public class TodayAddActivity extends Activity { tp.setName(editText7.getText().toString()); tp.setPrice(editText8.getText().toString()); tp.setDate(editText9.getText().toString()); - SQLiteDatabase db = openOrCreateDatabase("My_DB.db",MODE_PRIVATE,null); + SQLiteDatabase db = openOrCreateDatabase("My_DB.db", MODE_PRIVATE, null); db.execSQL("create table if not exists TodayPrice(id integer primary key autoincrement, name text,price text,date text,photo text,time text)"); - Log.i("kan","TodayAdd数据库连接成功,Todayprice打开成功!"); + Log.i("kan", "TodayAdd数据库连接成功,Todayprice打开成功!"); //取当前年月日时分秒最为编码 Date d = new Date(); //格式化为一串数字 SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); String dateNowStr = sdf.format(d); - Log.i("kan",tp.getName()+"\t"+tp.getPrice()+"\t"+tp.getDate()+"\t"+tp.getPhoto()+"\t"+dateNowStr); - db.execSQL("insert into TodayPrice(name,price,date,photo,time)values('"+tp.getName()+"','"+tp.getPrice()+"','"+tp.getDate()+"','"+tp.getPhoto()+"','"+dateNowStr+"')"); - Log.i("kan","插入TodayPrice成功!"); + Log.i("kan", tp.getName() + "\t" + tp.getPrice() + "\t" + tp.getDate() + "\t" + tp.getPhoto() + "\t" + dateNowStr); + db.execSQL("insert into TodayPrice(name,price,date,photo,time)values('" + tp.getName() + "','" + tp.getPrice() + "','" + tp.getDate() + "','" + tp.getPhoto() + "','" + dateNowStr + "')"); + Log.i("kan", "插入TodayPrice成功!"); toast("保存成功!"); - picFileFullName=""; + picFileFullName = ""; editText7.setText(""); editText8.setText(""); - // editText9.setText(""); +// 推送到服务器 + + HttpResult httpResult = TodayEntityService.postToServer(context, tp); + String s = httpResult.getBody().toString(); + + // editText9.setText(""); db.close(); } @@ -149,18 +163,29 @@ public class TodayAddActivity extends Activity { }); + } - - + private void initPhotoError() { + // android 7.0系统解决拍照的问题 + StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder(); + StrictMode.setVmPolicy(builder.build()); + builder.detectFileUriExposure(); } - //打开相机 - public void takePicture(){ + /** + * 打开相机 + */ + + public void takePicture() { String state = Environment.getExternalStorageState(); //判断外置存储器是否挂载。 if (state.equals(Environment.MEDIA_MOUNTED)) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); - File outDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES); +// 拍照后图片存储正常,但是onActivityResult的resultCode总是返回0 +// intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); + intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); + File outDir = getExternalFilesDir(Environment.DIRECTORY_PICTURES); if (!outDir.exists()) { outDir.mkdirs(); } @@ -171,55 +196,57 @@ public class TodayAddActivity extends Activity { SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); String dateNowStr = sdf.format(d); - File outFile = new File(outDir,"CAI"+dateNowStr + ".jpg"); - // File outFile = new File(outDir, System.currentTimeMillis() + ".jpg"); + File outFile = new File(outDir, "shop" + dateNowStr + ".jpg"); + // File outFile = new File(outDir, System.currentTimeMillis() + ".jpg"); picFileFullName = outFile.getAbsolutePath(); //得到图片的uri - uri=Uri.fromFile(outFile); + uri = FileUtil.getUriForFile(TodayAddActivity.this, outFile, getPackageName()); + intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(outFile)); intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1); //跳转到相机滞后于接收返回值(文件地址),再onActivityResult里面处理 startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE); - } else{ + } else { // Log.e(tag, "无法挂在存储器"); } } + @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE) { if (resultCode == RESULT_OK) { - // Log.e(tag, "="+picFileFullName); - toast("保存路径:"+picFileFullName); + // Log.e(tag, "="+picFileFullName); + toast("保存路径:" + picFileFullName); setImageView(picFileFullName); } else if (resultCode == RESULT_CANCELED) { } else { - // Log.e(tag, ""); + // Log.e(tag, ""); } } else //选择图片的 if (requestCode == PICK_IMAGE_ACTIVITY_REQUEST_CODE) { - if (resultCode == RESULT_OK) { - //返回值得到的是文件地址! - Uri uri = data.getData(); - if(uri != null){ - String realPath = getRealPathFromURI(uri); - // Log.e(tag, ""+realPath); - toast("图片路径:"+realPath); - //设置图片,就可以了 - setImageView(realPath); - }else{ - // Log.e(tag, ""); + if (resultCode == RESULT_OK) { + //返回值得到的是文件地址! + Uri uri = data.getData(); + if (uri != null) { + String realPath = getRealPathFromURI(uri); + // Log.e(tag, ""+realPath); + toast("图片路径:" + realPath); + //设置图片,就可以了 + setImageView(realPath); + } else { + // Log.e(tag, ""); + } } } - } } - private void setImageView(String realPath){ + private void setImageView(String realPath) { - //这个地方需要文件读写权限呢,没有权限,会一直为null! + //这个地方需要文件读写权限呢,没有权限,会一直为null! //所以安卓6.0以上需要加入一些代码解决! //if (ContextCompat.checkSelfPermission(Today_add.this, Manifest.permission.WRITE_EXTERNAL_STORAGE)!= PackageManager.PERMISSION_GRANTED){ // ActivityCompat.requestPermissions(Today_add.this,new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},1); } @@ -227,23 +254,23 @@ public class TodayAddActivity extends Activity { Bitmap bmp = BitmapFactory.decodeFile(realPath); int degree = readPictureDegree(realPath); - if(degree <= 0){ + if (degree <= 0) { imageView.setImageBitmap(bmp); - }else{ - // Log.e(tag, "rotate:"+degree); + } else { + // Log.e(tag, "rotate:"+degree); // - Matrix matrix=new Matrix(); + Matrix matrix = new Matrix(); // matrix.postRotate(degree); // - Bitmap resizedBitmap=Bitmap.createBitmap(bmp,0,0,bmp.getWidth(),bmp.getHeight(),matrix,true); + Bitmap resizedBitmap = Bitmap.createBitmap(bmp, 0, 0, bmp.getWidth(), bmp.getHeight(), matrix, true); imageView.setImageBitmap(resizedBitmap); } } - public String getRealPathFromURI(Uri contentUri){ - try{ + public String getRealPathFromURI(Uri contentUri) { + try { String[] proj = {MediaStore.Images.Media.DATA}; // Do not call Cursor.close() on a cursor obtained using this method, // because the activity will do that for you at the appropriate time @@ -251,14 +278,14 @@ public class TodayAddActivity extends Activity { int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); cursor.moveToFirst(); return cursor.getString(column_index); - }catch (Exception e){ + } catch (Exception e) { return contentUri.getPath(); } } public static int readPictureDegree(String path) { - int degree = 0; + int degree = 0; try { ExifInterface exifInterface = new ExifInterface(path); int orientation = exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL); @@ -279,22 +306,32 @@ public class TodayAddActivity extends Activity { return degree; } - public void toast(String msg){ + public void toast(String msg) { Toast.makeText(this, msg, Toast.LENGTH_LONG).show(); } + @Override - public boolean onCreateOptionsMenu(Menu menu){ - // getMenuInflater().inflate(R.menu.main,menu); + public boolean onCreateOptionsMenu(Menu menu) { + // getMenuInflater().inflate(R.menu.main,menu); return super.onCreateOptionsMenu(menu); } - public boolean onOptionsItemSelected(MenuItem item){ + public boolean onOptionsItemSelected(MenuItem item) { - switch(item.getItemId()){ - case android.R.id.home: //默认添加的 - finish(); - break; } + switch (item.getItemId()) { + case android.R.id.home: //默认添加的 + finish(); + break; + } return false; } + + //是否有外存 + public static boolean hasExternalStorage() { + return Environment.getExternalStorageState(). + equals(Environment.MEDIA_MOUNTED); + } + + } diff --git a/app/src/main/java/com/hxy/manager/activity/today/TodayShowActivity.java b/app/src/main/java/com/hxy/manager/activity/today/TodayShowActivity.java index 9b0ba96072b9e85d3c7452b0e992373ca8dcb5ce..e687b48b07c51c34b3a5581db682bc1b2f19efb9 100755 --- a/app/src/main/java/com/hxy/manager/activity/today/TodayShowActivity.java +++ b/app/src/main/java/com/hxy/manager/activity/today/TodayShowActivity.java @@ -1,6 +1,6 @@ package com.hxy.manager.activity.today; -import android.app.Activity; +import android.app.ActionBar; import android.content.Intent; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; @@ -16,16 +16,19 @@ import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; - -import java.io.File; +import androidx.appcompat.app.AppCompatActivity; import com.hxy.manager.R; +import com.hxy.manager.util.FileUtil; +import com.hxy.manager.util.StringUtil; + +import java.io.File; /** * Created by 傲寒宏志 on 2018/1/13. */ -public class TodayShowActivity extends Activity { +public class TodayShowActivity extends AppCompatActivity { TextView textView7; TextView textView8; TextView textView9; @@ -37,63 +40,66 @@ public class TodayShowActivity extends Activity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.today_show); - Log.i("kan","设置todayshow布局"); + Log.i("kan", "设置todayshow布局"); setTitle("内容"); - getActionBar().setDisplayHomeAsUpEnabled(true);//向上返回 - textView7=(TextView)findViewById(R.id.textView7); - textView8=(TextView)findViewById(R.id.textView8); - textView9=(TextView)findViewById(R.id.textView9); - imageView=(ImageView)findViewById(R.id.imageView7); + ActionBar actionBar = getActionBar(); + if (actionBar != null) { + actionBar.setDisplayHomeAsUpEnabled(true);//向上返回 + }//向上返回 + textView7 = (TextView) findViewById(R.id.textView7); + textView8 = (TextView) findViewById(R.id.textView8); + textView9 = (TextView) findViewById(R.id.textView9); + imageView = (ImageView) findViewById(R.id.imageView7); Intent intent = getIntent(); id = intent.getStringExtra("id"); - Log.i("kan","Todayshow接收的id值是:"+id); - // Toast.makeText(Today_show.this,id,Toast.LENGTH_SHORT).show(); - SQLiteDatabase db = openOrCreateDatabase("My_DB.db",MODE_PRIVATE,null); + Log.i("kan", "Todayshow接收的id值是:" + id); + // Toast.makeText(Today_show.this,id,Toast.LENGTH_SHORT).show(); + SQLiteDatabase db = openOrCreateDatabase("My_DB.db", MODE_PRIVATE, null); - Cursor cursor=db.rawQuery("select * from TodayPrice where id = "+id,null); - Log.i("kan","cursor的长度是:"+cursor.getCount()); -while (cursor.moveToNext()){ + Cursor cursor = db.rawQuery("select * from TodayPrice where id = " + id, null); + Log.i("kan", "cursor的长度是:" + cursor.getCount()); + while (cursor.moveToNext()) { //莫名其妙的bug,把图片的设置语句放在textView7的上面就会导致系统崩溃,放在textView9的下面就正常了 - textView7.setText(cursor.getString(cursor.getColumnIndex("name"))); - textView8.setText(cursor.getString(cursor.getColumnIndex("price"))); - textView9.setText(cursor.getString(cursor.getColumnIndex("date"))); - Log.i("kan","设置setText完成!"); - mPath =cursor.getString(cursor.getColumnIndex("photo")).trim(); - Log.i("kan","图片路径mPath="+mPath); - - Bitmap bmp = BitmapFactory.decodeFile(cursor.getString(cursor.getColumnIndex("photo"))); - cursor.close(); - db.close(); - imageView.setImageBitmap(bmp); - //单击打开相册 - imageView.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - Log.i("kan","点击了图片"); - - if(!mPath.equals("")){ - Log.i("kan","路径不为空!mPath="+mPath); - Intent intent = new Intent(Intent.ACTION_VIEW); - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - intent.setDataAndType(Uri.fromFile(new File(mPath)), ".jpg"); - startActivity(intent); - } - else - Toast.makeText(TodayShowActivity.this,"没有图片",Toast.LENGTH_SHORT).show(); - - // mPath 是图片路劲 - // mType 是图片mimetype,.png对应image/png,.gif对应image/gif,.jpg对应image/jpg,.jpeg对应image/jpeg,.bmp对应image/bmp - } - }); - - -} - - - + textView7.setText(cursor.getString(cursor.getColumnIndex("name"))); + textView8.setText(cursor.getString(cursor.getColumnIndex("price"))); + textView9.setText(cursor.getString(cursor.getColumnIndex("date"))); + Log.i("kan", "设置setText完成!"); + mPath = cursor.getString(cursor.getColumnIndex("photo")).trim(); + Log.i("kan", "图片路径mPath=" + mPath); + + Bitmap bmp = BitmapFactory.decodeFile(cursor.getString(cursor.getColumnIndex("photo"))); + cursor.close(); + db.close(); + imageView.setImageBitmap(bmp); + //单击打开相册 + imageView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Log.i("kan", "点击了图片"); + + if (StringUtil.hasText(mPath)) { + Log.i("kan", "路径不为空!mPath=" + mPath); + Intent intent = new Intent(Intent.ACTION_VIEW); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); + Uri uri = FileUtil.getUriForFile(TodayShowActivity.this, new File(mPath), getPackageName()); + //设置数据和类型可以用setData( )或setType( ) ,但是同时设置的话是不生效的, + // 只能使用setDataAndType( ) ,image代表图片,星号代表图片中所有格式, + // 可根据自己需要筛选,如只想打开jpg类型图片可用“image/jpg” + intent.setDataAndType(uri,"image/*"); +// intent.setDataAndType(uri, ".jpg"); + startActivity(intent); + } else + Toast.makeText(TodayShowActivity.this, "没有图片", Toast.LENGTH_SHORT).show(); + + // mPath 是图片路劲 + // mType 是图片mimetype,.png对应image/png,.gif对应image/gif,.jpg对应image/jpg,.jpeg对应image/jpeg,.bmp对应image/bmp + } + }); + } } @@ -101,19 +107,19 @@ while (cursor.moveToNext()){ @Override protected void onResume() { super.onResume(); - Log.i("kan","TodayShow的onResume()的方法启动");//首次启动也会启动这个方法 + Log.i("kan", "TodayShow的onResume()的方法启动");//首次启动也会启动这个方法 textView7 = (TextView) findViewById(R.id.textView7); textView8 = (TextView) findViewById(R.id.textView8); textView9 = (TextView) findViewById(R.id.textView9); imageView = (ImageView) findViewById(R.id.imageView7); - Log.i("kan","传入的id值:"+id); + Log.i("kan", "传入的id值:" + id); SQLiteDatabase db = openOrCreateDatabase("My_DB.db", MODE_PRIVATE, null); Cursor cursor = db.rawQuery("select * from TodayPrice where id = " + id, null); - Log.i("kan","数据库查询成功!cursor的值是"+cursor.getCount()); + Log.i("kan", "数据库查询成功!cursor的值是" + cursor.getCount()); - if(cursor.getCount()>0){//说明数据是被修改的! + if (cursor.getCount() > 0) {//说明数据是被修改的! while (cursor.moveToNext()) { mPath = cursor.getString(cursor.getColumnIndex("photo")); Bitmap bmp = BitmapFactory.decodeFile(cursor.getString(cursor.getColumnIndex("photo"))); @@ -125,29 +131,28 @@ while (cursor.moveToNext()){ } cursor.close(); db.close(); - } - else + } else finish();//cursor.getCount()=0说明数据是被删除了,所以直接关闭当前Activity返回Today页面 } @Override - public boolean onCreateOptionsMenu(Menu menu){ + public boolean onCreateOptionsMenu(Menu menu) { - getMenuInflater().inflate(R.menu.message,menu); + getMenuInflater().inflate(R.menu.message, menu); return super.onCreateOptionsMenu(menu); } - public boolean onOptionsItemSelected(MenuItem item){ - switch(item.getItemId()){ + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { /* case R.id.message://保存 Toast.makeText(Show.this,"点击了添加!",Toast.LENGTH_SHORT).show(); break; */ - case android.R.id.home: //默认添加的 - finish(); - break; + case android.R.id.home: //默认添加的 + finish(); + break; case R.id.modify: Intent intent3 = new Intent(TodayShowActivity.this, TodayUpdateActivity.class); intent3.putExtra("id", id); diff --git a/app/src/main/java/com/hxy/manager/activity/today/TodayUpdateActivity.java b/app/src/main/java/com/hxy/manager/activity/today/TodayUpdateActivity.java index b8536cb0a99afa180c404062a76bc84acac31612..8c34c0e8a51ebf2c54a5fe856614147545f8ea81 100755 --- a/app/src/main/java/com/hxy/manager/activity/today/TodayUpdateActivity.java +++ b/app/src/main/java/com/hxy/manager/activity/today/TodayUpdateActivity.java @@ -1,7 +1,7 @@ package com.hxy.manager.activity.today; -import android.app.Activity; +import android.app.ActionBar; import android.content.Intent; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; @@ -14,21 +14,20 @@ import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.ImageView; -import android.widget.TextView; -import android.widget.Toast; +import androidx.appcompat.app.AppCompatActivity; + +import com.hxy.manager.R; import java.io.File; import java.text.SimpleDateFormat; import java.util.Date; -import com.hxy.manager.R; - /** * Created by 傲寒宏志 on 2018/1/14. */ -public class TodayUpdateActivity extends Activity { +public class TodayUpdateActivity extends AppCompatActivity { String id; ImageView imageView; EditText editText7; @@ -41,7 +40,10 @@ public class TodayUpdateActivity extends Activity { super.onCreate(savedInstanceState); setContentView(R.layout.today_update); - getActionBar().setDisplayHomeAsUpEnabled(true);//向上返回 + ActionBar actionBar = getActionBar(); + if (actionBar != null) { + actionBar.setDisplayHomeAsUpEnabled(true);//向上返回 + }//向上返回 editText7=(EditText)findViewById(R.id.editText7); editText8=(EditText)findViewById(R.id.editText8); editText9=(EditText)findViewById(R.id.editText9); diff --git a/app/src/main/java/com/hxy/manager/dao/GoodsMapper.java b/app/src/main/java/com/hxy/manager/dao/GoodsMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..95ba563993b7b39c9b228900c17ae510f8c98569 --- /dev/null +++ b/app/src/main/java/com/hxy/manager/dao/GoodsMapper.java @@ -0,0 +1,25 @@ +package com.hxy.manager.dao; + +import android.content.Context; + +import com.hxy.manager.entity.DaoSession; +import com.hxy.manager.entity.GoodsEntity; +import com.hxy.manager.entity.GoodsEntityDao; + +public class GoodsMapper { + + /** + * @param context + * @param goodsEntity + * @return 插入后的id + */ + public static long save(Context context, GoodsEntity goodsEntity) { + // 保存到本地并且同步到线上数据库 + DaoSession writeSession = DBManager.getWriteSession(context); + GoodsEntityDao goodsEntityDao = writeSession.getGoodsEntityDao(); + long insert = goodsEntityDao.insert(goodsEntity); + writeSession.clear(); + return insert; + } + +} diff --git a/app/src/main/java/com/hxy/manager/entity/BaseResponse.java b/app/src/main/java/com/hxy/manager/entity/BaseResponse.java index 4d24c883c04de33c3e8ce340cbae5998a186c563..11823ecf8e137ca0c77e33585deb9d2d0620e694 100644 --- a/app/src/main/java/com/hxy/manager/entity/BaseResponse.java +++ b/app/src/main/java/com/hxy/manager/entity/BaseResponse.java @@ -1,18 +1,39 @@ package com.hxy.manager.entity; -import lombok.Data; - /** * @program erp-server * @description ${description}* @author eric* @date 2020/2/27 */ -@Data public class BaseResponse { String message; Integer code; T data; + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public Integer getCode() { + return code; + } + + public void setCode(Integer code) { + this.code = code; + } + + public T getData() { + return data; + } + + public void setData(T data) { + this.data = data; + } + public BaseResponse() { } diff --git a/app/src/main/java/com/hxy/manager/entity/DaoMaster.java b/app/src/main/java/com/hxy/manager/entity/DaoMaster.java index 713478556df9039be1a82ee35b970187d8b4a347..f30c03b3061108482533626f35ed0d422160d8e0 100644 --- a/app/src/main/java/com/hxy/manager/entity/DaoMaster.java +++ b/app/src/main/java/com/hxy/manager/entity/DaoMaster.java @@ -22,11 +22,15 @@ public class DaoMaster extends AbstractDaoMaster { /** Creates underlying database table using DAOs. */ public static void createAllTables(Database db, boolean ifNotExists) { GoodsEntityDao.createTable(db, ifNotExists); + NianHuoCustomerEntityDao.createTable(db, ifNotExists); + TodayPriceEntityDao.createTable(db, ifNotExists); } /** Drops underlying database table using DAOs. */ public static void dropAllTables(Database db, boolean ifExists) { GoodsEntityDao.dropTable(db, ifExists); + NianHuoCustomerEntityDao.dropTable(db, ifExists); + TodayPriceEntityDao.dropTable(db, ifExists); } /** @@ -46,6 +50,8 @@ public class DaoMaster extends AbstractDaoMaster { public DaoMaster(Database db) { super(db, SCHEMA_VERSION); registerDaoClass(GoodsEntityDao.class); + registerDaoClass(NianHuoCustomerEntityDao.class); + registerDaoClass(TodayPriceEntityDao.class); } public DaoSession newSession() { diff --git a/app/src/main/java/com/hxy/manager/entity/DaoSession.java b/app/src/main/java/com/hxy/manager/entity/DaoSession.java index 40a8750219ac143dc173514a8848d8519c35e65a..358981b236213258879e658c1c0fb13c22618652 100644 --- a/app/src/main/java/com/hxy/manager/entity/DaoSession.java +++ b/app/src/main/java/com/hxy/manager/entity/DaoSession.java @@ -9,8 +9,12 @@ import org.greenrobot.greendao.identityscope.IdentityScopeType; import org.greenrobot.greendao.internal.DaoConfig; import com.hxy.manager.entity.GoodsEntity; +import com.hxy.manager.entity.NianHuoCustomerEntity; +import com.hxy.manager.entity.TodayPriceEntity; import com.hxy.manager.entity.GoodsEntityDao; +import com.hxy.manager.entity.NianHuoCustomerEntityDao; +import com.hxy.manager.entity.TodayPriceEntityDao; // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. @@ -22,8 +26,12 @@ import com.hxy.manager.entity.GoodsEntityDao; public class DaoSession extends AbstractDaoSession { private final DaoConfig goodsEntityDaoConfig; + private final DaoConfig nianHuoCustomerEntityDaoConfig; + private final DaoConfig todayPriceEntityDaoConfig; private final GoodsEntityDao goodsEntityDao; + private final NianHuoCustomerEntityDao nianHuoCustomerEntityDao; + private final TodayPriceEntityDao todayPriceEntityDao; public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> daoConfigMap) { @@ -32,17 +40,37 @@ public class DaoSession extends AbstractDaoSession { goodsEntityDaoConfig = daoConfigMap.get(GoodsEntityDao.class).clone(); goodsEntityDaoConfig.initIdentityScope(type); + nianHuoCustomerEntityDaoConfig = daoConfigMap.get(NianHuoCustomerEntityDao.class).clone(); + nianHuoCustomerEntityDaoConfig.initIdentityScope(type); + + todayPriceEntityDaoConfig = daoConfigMap.get(TodayPriceEntityDao.class).clone(); + todayPriceEntityDaoConfig.initIdentityScope(type); + goodsEntityDao = new GoodsEntityDao(goodsEntityDaoConfig, this); + nianHuoCustomerEntityDao = new NianHuoCustomerEntityDao(nianHuoCustomerEntityDaoConfig, this); + todayPriceEntityDao = new TodayPriceEntityDao(todayPriceEntityDaoConfig, this); registerDao(GoodsEntity.class, goodsEntityDao); + registerDao(NianHuoCustomerEntity.class, nianHuoCustomerEntityDao); + registerDao(TodayPriceEntity.class, todayPriceEntityDao); } public void clear() { goodsEntityDaoConfig.clearIdentityScope(); + nianHuoCustomerEntityDaoConfig.clearIdentityScope(); + todayPriceEntityDaoConfig.clearIdentityScope(); } public GoodsEntityDao getGoodsEntityDao() { return goodsEntityDao; } + public NianHuoCustomerEntityDao getNianHuoCustomerEntityDao() { + return nianHuoCustomerEntityDao; + } + + public TodayPriceEntityDao getTodayPriceEntityDao() { + return todayPriceEntityDao; + } + } diff --git a/app/src/main/java/com/hxy/manager/entity/GoodsEntity.java b/app/src/main/java/com/hxy/manager/entity/GoodsEntity.java index 36f8fe1daf8361abe6bacc38a33d3f05a2a7359a..ccc6da84df6866fa5da6cf5dd157698f11fdd52d 100644 --- a/app/src/main/java/com/hxy/manager/entity/GoodsEntity.java +++ b/app/src/main/java/com/hxy/manager/entity/GoodsEntity.java @@ -1,16 +1,19 @@ package com.hxy.manager.entity; -import androidx.annotation.NonNull; - import org.greenrobot.greendao.annotation.Entity; -import org.greenrobot.greendao.annotation.Id; import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; + +import java.io.Serializable; /** * Created by admin-home on 2017/12/31. */ @Entity -public class GoodsEntity { +public class GoodsEntity implements Serializable { + + private static final long serialVersionUID = 5368710081L; + /** * 本地CRUD操作 */ @@ -135,10 +138,25 @@ public class GoodsEntity { this.createTime = createTime; } - - @NonNull @Override public String toString() { - return "id=" + id + "name=" + name; - } + return "GoodsEntity{" + + "id=" + id + + ", number='" + number + '\'' + + ", name='" + name + '\'' + + ", price='" + price + '\'' + + ", press='" + press + '\'' + + ", date='" + date + '\'' + + ", author='" + author + '\'' + + ", location='" + location + '\'' + + ", updateTime=" + updateTime + + ", createTime=" + createTime + + '}'; + } + +// @NonNull +// @Override +// public String toString() { +// return "id=" + id + "name=" + name; +// } } diff --git a/app/src/main/java/com/hxy/manager/entity/NianHuoCustomerEntity.java b/app/src/main/java/com/hxy/manager/entity/NianHuoCustomerEntity.java new file mode 100644 index 0000000000000000000000000000000000000000..cf444dc311694a35a818fcd96c352f32d2a499b1 --- /dev/null +++ b/app/src/main/java/com/hxy/manager/entity/NianHuoCustomerEntity.java @@ -0,0 +1,68 @@ +package com.hxy.manager.entity; + + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; + +@Entity +public class NianHuoCustomerEntity { + String name; + String phone; + String address; + String reputation; + String registerDate; + + @Generated(hash = 1290360732) + public NianHuoCustomerEntity(String name, String phone, String address, + String reputation, String registerDate) { + this.name = name; + this.phone = phone; + this.address = address; + this.reputation = reputation; + this.registerDate = registerDate; + } + + @Generated(hash = 1976036496) + public NianHuoCustomerEntity() { + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public String getReputation() { + return reputation; + } + + public void setReputation(String reputation) { + this.reputation = reputation; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public String getRegisterDate() { + return registerDate; + } + + public void setRegisterDate(String registerDate) { + this.registerDate = registerDate; + } +} diff --git a/app/src/main/java/com/hxy/manager/entity/NianHuoCustomerEntityDao.java b/app/src/main/java/com/hxy/manager/entity/NianHuoCustomerEntityDao.java new file mode 100644 index 0000000000000000000000000000000000000000..60bbaa6a747e16c220494f0de5dc1b248457dbda --- /dev/null +++ b/app/src/main/java/com/hxy/manager/entity/NianHuoCustomerEntityDao.java @@ -0,0 +1,166 @@ +package com.hxy.manager.entity; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "NIAN_HUO_CUSTOMER_ENTITY". +*/ +public class NianHuoCustomerEntityDao extends AbstractDao { + + public static final String TABLENAME = "NIAN_HUO_CUSTOMER_ENTITY"; + + /** + * Properties of entity NianHuoCustomerEntity.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Name = new Property(0, String.class, "name", false, "NAME"); + public final static Property Phone = new Property(1, String.class, "phone", false, "PHONE"); + public final static Property Address = new Property(2, String.class, "address", false, "ADDRESS"); + public final static Property Reputation = new Property(3, String.class, "reputation", false, "REPUTATION"); + public final static Property RegisterDate = new Property(4, String.class, "registerDate", false, "REGISTER_DATE"); + } + + + public NianHuoCustomerEntityDao(DaoConfig config) { + super(config); + } + + public NianHuoCustomerEntityDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"NIAN_HUO_CUSTOMER_ENTITY\" (" + // + "\"NAME\" TEXT," + // 0: name + "\"PHONE\" TEXT," + // 1: phone + "\"ADDRESS\" TEXT," + // 2: address + "\"REPUTATION\" TEXT," + // 3: reputation + "\"REGISTER_DATE\" TEXT);"); // 4: registerDate + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"NIAN_HUO_CUSTOMER_ENTITY\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, NianHuoCustomerEntity entity) { + stmt.clearBindings(); + + String name = entity.getName(); + if (name != null) { + stmt.bindString(1, name); + } + + String phone = entity.getPhone(); + if (phone != null) { + stmt.bindString(2, phone); + } + + String address = entity.getAddress(); + if (address != null) { + stmt.bindString(3, address); + } + + String reputation = entity.getReputation(); + if (reputation != null) { + stmt.bindString(4, reputation); + } + + String registerDate = entity.getRegisterDate(); + if (registerDate != null) { + stmt.bindString(5, registerDate); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, NianHuoCustomerEntity entity) { + stmt.clearBindings(); + + String name = entity.getName(); + if (name != null) { + stmt.bindString(1, name); + } + + String phone = entity.getPhone(); + if (phone != null) { + stmt.bindString(2, phone); + } + + String address = entity.getAddress(); + if (address != null) { + stmt.bindString(3, address); + } + + String reputation = entity.getReputation(); + if (reputation != null) { + stmt.bindString(4, reputation); + } + + String registerDate = entity.getRegisterDate(); + if (registerDate != null) { + stmt.bindString(5, registerDate); + } + } + + @Override + public Void readKey(Cursor cursor, int offset) { + return null; + } + + @Override + public NianHuoCustomerEntity readEntity(Cursor cursor, int offset) { + NianHuoCustomerEntity entity = new NianHuoCustomerEntity( // + cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0), // name + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // phone + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // address + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // reputation + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4) // registerDate + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, NianHuoCustomerEntity entity, int offset) { + entity.setName(cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0)); + entity.setPhone(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setAddress(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setReputation(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setRegisterDate(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + } + + @Override + protected final Void updateKeyAfterInsert(NianHuoCustomerEntity entity, long rowId) { + // Unsupported or missing PK type + return null; + } + + @Override + public Void getKey(NianHuoCustomerEntity entity) { + return null; + } + + @Override + public boolean hasKey(NianHuoCustomerEntity entity) { + // TODO + return false; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/hxy/manager/entity/TodayPriceEntity.java b/app/src/main/java/com/hxy/manager/entity/TodayPriceEntity.java index 502566ae1af5f791bf2787f2c3954e1299840146..b6a4e9f427291242b933479b3ec9dbebe999e45b 100755 --- a/app/src/main/java/com/hxy/manager/entity/TodayPriceEntity.java +++ b/app/src/main/java/com/hxy/manager/entity/TodayPriceEntity.java @@ -1,17 +1,86 @@ package com.hxy.manager.entity; -import lombok.Data; +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; /** * Created by 傲寒宏志 on 2018/1/13. */ - -@Data +@Entity public class TodayPriceEntity { + /** + * 作为主键 + */ String name; String price; String date; String photo; - // String time; + @Id int id; + + /** + * 最新时间,服务器更新用,unix时间戳 + */ + private Long updateTime;// + /** + * 数据新建时间,unix时间戳 + */ + private Long createTime; + @Generated(hash = 1909597601) + public TodayPriceEntity(String name, String price, String date, String photo, + int id, Long updateTime, Long createTime) { + this.name = name; + this.price = price; + this.date = date; + this.photo = photo; + this.id = id; + this.updateTime = updateTime; + this.createTime = createTime; + } + @Generated(hash = 923545986) + public TodayPriceEntity() { + } + public String getName() { + return this.name; + } + public void setName(String name) { + this.name = name; + } + public String getPrice() { + return this.price; + } + public void setPrice(String price) { + this.price = price; + } + public String getDate() { + return this.date; + } + public void setDate(String date) { + this.date = date; + } + public String getPhoto() { + return this.photo; + } + public void setPhoto(String photo) { + this.photo = photo; + } + public int getId() { + return this.id; + } + public void setId(int id) { + this.id = id; + } + public Long getUpdateTime() { + return this.updateTime; + } + public void setUpdateTime(Long updateTime) { + this.updateTime = updateTime; + } + public Long getCreateTime() { + return this.createTime; + } + public void setCreateTime(Long createTime) { + this.createTime = createTime; + } } diff --git a/app/src/main/java/com/hxy/manager/entity/TodayPriceEntityDao.java b/app/src/main/java/com/hxy/manager/entity/TodayPriceEntityDao.java new file mode 100644 index 0000000000000000000000000000000000000000..ffa08252a532797d10b3b99e1461445d0d4fe4e9 --- /dev/null +++ b/app/src/main/java/com/hxy/manager/entity/TodayPriceEntityDao.java @@ -0,0 +1,188 @@ +package com.hxy.manager.entity; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "TODAY_PRICE_ENTITY". +*/ +public class TodayPriceEntityDao extends AbstractDao { + + public static final String TABLENAME = "TODAY_PRICE_ENTITY"; + + /** + * Properties of entity TodayPriceEntity.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Name = new Property(0, String.class, "name", false, "NAME"); + public final static Property Price = new Property(1, String.class, "price", false, "PRICE"); + public final static Property Date = new Property(2, String.class, "date", false, "DATE"); + public final static Property Photo = new Property(3, String.class, "photo", false, "PHOTO"); + public final static Property Id = new Property(4, int.class, "id", true, "ID"); + public final static Property UpdateTime = new Property(5, Long.class, "updateTime", false, "UPDATE_TIME"); + public final static Property CreateTime = new Property(6, Long.class, "createTime", false, "CREATE_TIME"); + } + + + public TodayPriceEntityDao(DaoConfig config) { + super(config); + } + + public TodayPriceEntityDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"TODAY_PRICE_ENTITY\" (" + // + "\"NAME\" TEXT," + // 0: name + "\"PRICE\" TEXT," + // 1: price + "\"DATE\" TEXT," + // 2: date + "\"PHOTO\" TEXT," + // 3: photo + "\"ID\" INTEGER PRIMARY KEY NOT NULL ," + // 4: id + "\"UPDATE_TIME\" INTEGER," + // 5: updateTime + "\"CREATE_TIME\" INTEGER);"); // 6: createTime + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"TODAY_PRICE_ENTITY\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, TodayPriceEntity entity) { + stmt.clearBindings(); + + String name = entity.getName(); + if (name != null) { + stmt.bindString(1, name); + } + + String price = entity.getPrice(); + if (price != null) { + stmt.bindString(2, price); + } + + String date = entity.getDate(); + if (date != null) { + stmt.bindString(3, date); + } + + String photo = entity.getPhoto(); + if (photo != null) { + stmt.bindString(4, photo); + } + stmt.bindLong(5, entity.getId()); + + Long updateTime = entity.getUpdateTime(); + if (updateTime != null) { + stmt.bindLong(6, updateTime); + } + + Long createTime = entity.getCreateTime(); + if (createTime != null) { + stmt.bindLong(7, createTime); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, TodayPriceEntity entity) { + stmt.clearBindings(); + + String name = entity.getName(); + if (name != null) { + stmt.bindString(1, name); + } + + String price = entity.getPrice(); + if (price != null) { + stmt.bindString(2, price); + } + + String date = entity.getDate(); + if (date != null) { + stmt.bindString(3, date); + } + + String photo = entity.getPhoto(); + if (photo != null) { + stmt.bindString(4, photo); + } + stmt.bindLong(5, entity.getId()); + + Long updateTime = entity.getUpdateTime(); + if (updateTime != null) { + stmt.bindLong(6, updateTime); + } + + Long createTime = entity.getCreateTime(); + if (createTime != null) { + stmt.bindLong(7, createTime); + } + } + + @Override + public Integer readKey(Cursor cursor, int offset) { + return cursor.getInt(offset + 4); + } + + @Override + public TodayPriceEntity readEntity(Cursor cursor, int offset) { + TodayPriceEntity entity = new TodayPriceEntity( // + cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0), // name + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // price + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // date + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // photo + cursor.getInt(offset + 4), // id + cursor.isNull(offset + 5) ? null : cursor.getLong(offset + 5), // updateTime + cursor.isNull(offset + 6) ? null : cursor.getLong(offset + 6) // createTime + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, TodayPriceEntity entity, int offset) { + entity.setName(cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0)); + entity.setPrice(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setDate(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setPhoto(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setId(cursor.getInt(offset + 4)); + entity.setUpdateTime(cursor.isNull(offset + 5) ? null : cursor.getLong(offset + 5)); + entity.setCreateTime(cursor.isNull(offset + 6) ? null : cursor.getLong(offset + 6)); + } + + @Override + protected final Integer updateKeyAfterInsert(TodayPriceEntity entity, long rowId) { + return entity.getId(); + } + + @Override + public Integer getKey(TodayPriceEntity entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(TodayPriceEntity entity) { + throw new UnsupportedOperationException("Unsupported for entities with a non-null key"); + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/hxy/manager/menu/ResideMenu.java b/app/src/main/java/com/hxy/manager/menu/ResideMenu.java index ddd0c437369f8dbc1a15492aacd371d81f08fa09..83d171faca34b96d3fe4e15b3a2f88448229a370 100755 --- a/app/src/main/java/com/hxy/manager/menu/ResideMenu.java +++ b/app/src/main/java/com/hxy/manager/menu/ResideMenu.java @@ -7,17 +7,27 @@ import android.content.res.Configuration; import android.content.res.Resources; import android.graphics.Rect; import android.util.DisplayMetrics; -import android.view.*; +import android.view.KeyCharacterMap; +import android.view.KeyEvent; +import android.view.LayoutInflater; +import android.view.MotionEvent; +import android.view.View; +import android.view.ViewGroup; import android.view.animation.AnimationUtils; -import android.widget.*; -import java.util.ArrayList; -import java.util.List; +import android.widget.FrameLayout; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.RelativeLayout; + import com.hxy.manager.R; import com.nineoldandroids.animation.Animator; import com.nineoldandroids.animation.AnimatorSet; import com.nineoldandroids.animation.ObjectAnimator; import com.nineoldandroids.view.ViewHelper; +import java.util.ArrayList; +import java.util.List; + /** * User: special * Date: 13-12-10 diff --git a/app/src/main/java/com/hxy/manager/menu/ResideMenuItem.java b/app/src/main/java/com/hxy/manager/menu/ResideMenuItem.java index 0b9964637d9c2f478f13f554caaf636dc260711d..22fe7e619ab72840f9bfcb2584fa3b00c1df0021 100755 --- a/app/src/main/java/com/hxy/manager/menu/ResideMenuItem.java +++ b/app/src/main/java/com/hxy/manager/menu/ResideMenuItem.java @@ -1,12 +1,12 @@ package com.hxy.manager.menu; -import com.hxy.manager.R; - import android.content.Context; import android.view.LayoutInflater; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; + +import com.hxy.manager.R; /** * User: special * Date: 13-12-10 diff --git a/app/src/main/java/com/hxy/manager/request/NotificationRequest.java b/app/src/main/java/com/hxy/manager/request/NotificationRequest.java new file mode 100644 index 0000000000000000000000000000000000000000..18cfa12eead270f87b16b5aa46f9a84fa1e604fb --- /dev/null +++ b/app/src/main/java/com/hxy/manager/request/NotificationRequest.java @@ -0,0 +1,33 @@ +package com.hxy.manager.request; + +import android.content.Context; +import android.util.Log; + +import com.ejlchina.okhttps.OkHttps; +import com.hxy.manager.util.Tags; + +import java.io.IOException; + +public class NotificationRequest { + /** + * @param msg 消息发送到服务器 + */ + public static void put(Context context, String msg) { + OkHttps.async("/goods") + .bind(context) // 绑定(生命周期|Context获取) +// .tag(Tags.TOKEN) // 自动添加 TOEKN + .tag(Tags.LOADING) // 自动显示加载框 + .addBodyPara("msg", msg) + .bodyType(OkHttps.JSON) + .setOnResponse(res -> { +// editText4.setText(res.toString()); + }) + .setOnException((IOException e) -> { + // 这里处理请求异常 + Log.i("kkk", "异步异常捕获:" + e.getMessage()); +// editText4.setText(e.getMessage()); + }) + // 请求参数设置... + .put(); + } +} diff --git a/app/src/main/java/com/hxy/manager/service/GoodsEntityService.java b/app/src/main/java/com/hxy/manager/service/GoodsEntityService.java index 64948e3b3285d732e2a26b61ed5fc5aa416dd85e..c09691ee9da35390e17ea932671fb868c106dc94 100644 --- a/app/src/main/java/com/hxy/manager/service/GoodsEntityService.java +++ b/app/src/main/java/com/hxy/manager/service/GoodsEntityService.java @@ -1,16 +1,22 @@ package com.hxy.manager.service; import android.content.Context; +import android.content.Intent; import android.database.sqlite.SQLiteDatabase; +import android.os.Bundle; import android.util.Log; import android.widget.Toast; import com.alibaba.fastjson.JSONObject; import com.ejlchina.okhttps.HttpResult; import com.ejlchina.okhttps.OkHttps; -import com.ejlchina.okhttps.internal.AsyncHttpTask; +import com.hxy.manager.activity.CaptureActivity; +import com.hxy.manager.activity.goods.GoodsAddActivity; +import com.hxy.manager.activity.goods.GoodsShowActivity; import com.hxy.manager.activity.goods.GoodsStoreActivity; +import com.hxy.manager.activity.goods.GoodsUpdateActivity; import com.hxy.manager.dao.DBManager; +import com.hxy.manager.dao.GoodsMapper; import com.hxy.manager.entity.DaoMaster; import com.hxy.manager.entity.DaoSession; import com.hxy.manager.entity.GoodsEntity; @@ -19,6 +25,9 @@ import com.hxy.manager.util.Constant; import com.hxy.manager.util.StringUtil; import com.hxy.manager.util.Tags; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.io.IOException; import java.util.List; @@ -26,6 +35,7 @@ import java.util.List; * 商品添加的逻辑 */ public class GoodsEntityService { + private static final Logger log = LoggerFactory.getLogger(GoodsEntityService.class); private Context context; @@ -33,27 +43,15 @@ public class GoodsEntityService { this.context = context; } - /** - * @param context - * @param goodsEntity - * @return 插入后的id - */ - public static long save(Context context, GoodsEntity goodsEntity) { - // 保存到本地并且同步到线上数据库 - DaoSession writeSession = DBManager.getWriteSession(context); - GoodsEntityDao goodsEntityDao = writeSession.getGoodsEntityDao(); - long insert = goodsEntityDao.insert(goodsEntity); - writeSession.clear(); - return insert; - } /** + * 保存到本地并且同步到线上数据库 + * * @param context * @param goodsEntity * @return 插入后的id */ public static void saveBatch(Context context, GoodsEntity... goodsEntity) { - // 保存到本地并且同步到线上数据库 DaoSession writeSession = DBManager.getWriteSession(context); GoodsEntityDao goodsEntityDao = writeSession.getGoodsEntityDao(); goodsEntityDao.insertInTx(goodsEntity); @@ -103,6 +101,12 @@ public class GoodsEntityService { } + /** + * 查询数据库 + * + * @param context + * @return + */ public static List listAll(Context context) { DaoMaster.DevOpenHelper devOpenHelper = new DaoMaster.DevOpenHelper(context, Constant.SQLITE_DATABASE, null); SQLiteDatabase readableDatabase = devOpenHelper.getReadableDatabase(); @@ -125,28 +129,116 @@ public class GoodsEntityService { return list; } + /** + * 逐步废弃本地数据库 + * + * @param context + * @param number + * @return + * @see GoodsEntityService#getOneFromServer(android.content.Context, java.lang.String) + */ + @Deprecated public static GoodsEntity getOneByNumber(Context context, String number) { + DaoSession readSession = DBManager.getReadSession(context); GoodsEntityDao goodsEntityDao = readSession.getGoodsEntityDao(); GoodsEntity goodsEntity = goodsEntityDao.queryBuilder().where(GoodsEntityDao.Properties.Number.eq(number)).unique(); readSession.clear(); + return goodsEntity; } + + /** + * // 这里需要异步获取信息,而且加载圈圈 + *

+ * 不要从本地获取数据,直接从服务器获取数据 + * + * @param context + * @param number + * @return + */ + public static void getOneFromServer(Context context, String number) { + + OkHttps.async("/goods") + .bind(context) // 绑定(生命周期|Context获取) +// .tag(Tags.TOKEN) // 自动添加 TOEKN + .tag(Tags.LOADING) // 自动显示加载框 + .addUrlPara("number", number) + .setOnResponse(res -> { + + HttpResult.Body body1 = res.getBody().cache(); + String bodyStr = body1.toString(); + if (StringUtil.hasText(bodyStr)) { + JSONObject jsonObject = JSONObject.parseObject(bodyStr); + if (jsonObject != null) { + String message = jsonObject.getString("message"); + Integer code = jsonObject.getInteger("code"); + if (code != Constant.STATUS_CODE) { + Toast.makeText(context, message, Toast.LENGTH_LONG).show(); + } + String data = jsonObject.getString("data"); + if (StringUtil.hasText(data) && JSONObject.parseObject(data, GoodsEntity.class) != null) { + GoodsEntity goodsEntity = JSONObject.parseObject(data, GoodsEntity.class); + // 广播消息通知结果 + GoodsShowActivity goodsShowActivity = GoodsShowActivity.goodsShowActivity; + if (goodsShowActivity != null) { + goodsShowActivity.finish(); + } + // 说明查询到了记录 + Intent intent = new Intent(context, GoodsShowActivity.class); + intent.putExtra("scanCode", number); + Bundle bundle = new Bundle(); + bundle.putSerializable("goodsEntity", goodsEntity); + intent.putExtras(bundle); + + context.startActivity(intent); + + } else { + GoodsAddActivity goodsAddActivity = GoodsAddActivity.goodsAddActivity; + if (goodsAddActivity != null) { + goodsAddActivity.finish(); + } + + Intent intent = new Intent(context, GoodsAddActivity.class); + intent.putExtra("scanCode", number); + context.startActivity(intent); + } + CaptureActivity.captureActivity.finish(); + } + } + + }) + .setOnException((IOException e) -> { + Log.e("kkk", "异步异常捕获:" + e.getMessage()); + }) + .get(); + + } + /** * 获取我的信息 **/ - public AsyncHttpTask updatePasswrod(String passwrod) { + public String updatePasswrod(String passwrod) { + return OkHttps.async("/mine/passwrod") .bind(context) .tag(Tags.TOKEN) // 自动添加 TOEKN .tag(Tags.LOADING) // 自动显示加载框 - .addBodyPara("passwrod", passwrod); + .addBodyPara("passwrod", passwrod).get().getResult().getBody().toString(); + } - public static HttpResult postToServer(Context context, GoodsEntity goodsEntity) { - return OkHttps.async("/goods") + /** + * 新增推送到服务器 + * + * @param context + * @param goodsEntity + * @return + */ + public static void postToServer(Context context, GoodsEntity goodsEntity) { + OkHttps.async("/goods") .bind(context) // 绑定(生命周期|Context获取) // .tag(Tags.TOKEN) // 自动添加 TOEKN .tag(Tags.LOADING) // 自动显示加载框 @@ -159,14 +251,22 @@ public class GoodsEntityService { // 这里处理请求异常 Log.i("kkk", "异步异常捕获:" + e.getMessage()); // editText4.setText(e.getMessage()); + // TODO 广播消息通知 }) // 请求参数设置... - .post().getResult(); + .post(); } - public static HttpResult putToServer(Context context, GoodsEntity goodsEntity) { - return OkHttps.async("/goods") + /** + * 修改到服务器 + * + * @param context + * @param goodsEntity + * @return + */ + public static void putToServer(Context context, GoodsEntity goodsEntity) { + OkHttps.async("/goods") .bind(context) // 绑定(生命周期|Context获取) // .tag(Tags.TOKEN) // 自动添加 TOEKN .tag(Tags.LOADING) // 自动显示加载框 @@ -181,37 +281,47 @@ public class GoodsEntityService { // editText4.setText(e.getMessage()); }) // 请求参数设置... - .put().getResult(); + .put(); } - public static HttpResult deleteFromServer(Context context, GoodsEntity goodsEntity) { - return OkHttps.async("/goods") + /** + * 从服务器 + * + * @param context + * @param goodsEntity + * @return + */ + public static void deleteFromServer(Context context, GoodsEntity goodsEntity) { + OkHttps.async("/goods") .bind(context) // 绑定(生命周期|Context获取) // .tag(Tags.TOKEN) // 自动添加 TOEKN .tag(Tags.LOADING) // 自动显示加载框 .setBodyPara(goodsEntity) .bodyType(OkHttps.JSON) .setOnResponse(res -> { -// editText4.setText(res.toString()); + log.info("{}", res); + GoodsUpdateActivity.goodsUpdateActivity.finish(); }) .setOnException((IOException e) -> { // 这里处理请求异常 Log.i("kkk", "异步异常捕获:" + e.getMessage()); // editText4.setText(e.getMessage()); }) - // 请求参数设置... - .delete().getResult(); + .delete(); } /** - * 把本地所有的全部上传 + * 把本地所有的全部上传,请求不可以同步!! * * @param goodsEntities * @return */ - public HttpResult postAllToServer(List goodsEntities) { - return OkHttps.async("/goods/list") + public void postAllToServer(List goodsEntities) { + if (goodsEntities == null || goodsEntities.size() <= 0) { + return; + } + OkHttps.async("/goods/list") .bind(context) // 绑定(生命周期|Context获取) // .tag(Tags.TOKEN) // 自动添加 TOEKN // .tag(Tags.LOADING) // 自动显示加载框 @@ -219,18 +329,18 @@ public class GoodsEntityService { .bodyType(OkHttps.JSON) .setOnResponse(res -> { // editText4.setText(res.toString()); - Toast.makeText(GoodsStoreActivity.goodsStoreActivity, "同步到线上成功", Toast.LENGTH_SHORT).show(); + Toast.makeText(GoodsStoreActivity.getCurrentActivity(), "同步了" + goodsEntities.size() + "条数据", Toast.LENGTH_SHORT).show(); }) .setOnException((IOException e) -> { // 这里处理请求异常 Log.i("kkk", "异步异常捕获:" + e.getMessage()); - Toast.makeText(GoodsStoreActivity.goodsStoreActivity, "服务不在线", Toast.LENGTH_SHORT).show(); + Toast.makeText(GoodsStoreActivity.getCurrentActivity(), "服务不在线", Toast.LENGTH_SHORT).show(); // editText4.setText(e.getMessage()); }) // 请求参数设置... - .post().getResult(); + .post(); } @@ -239,43 +349,56 @@ public class GoodsEntityService { * * @return */ - public String requestGetListAll() { + public void requestGetListAll() { // 异步操作,多线程操作 - Object lock = new Object(); - - HttpResult result = OkHttps.async("/goods/list") + log.info("开始请求服务器数据"); + if (context != null) { + Log.i(Constant.TAG, "requestGetListAll: " + context); + } + OkHttps.async("/goods/list") .bind(context) // 绑定(生命周期|Context获取) // .tag(Tags.TOKEN) // 自动添加 TOEKN -// .tag(Tags.LOADING) // 自动显示加载框 + .tag(Tags.LOADING) // 自动显示加载框 // .setBodyPara(goodsEntities) .bodyType(OkHttps.JSON) .setOnResponse(res -> { - synchronized (lock) { - HttpResult.Body body1 = res.getBody().cache(); - String bodyStr = body1.toString(); - JSONObject jsonObject = JSONObject.parseObject(bodyStr); - String message = jsonObject.getString("message"); - - Toast.makeText(GoodsStoreActivity.goodsStoreActivity, message, Toast.LENGTH_SHORT).show(); + HttpResult.Body body1 = res.getBody().cache(); + String bodyStr = body1.toString(); + JSONObject jsonObject = JSONObject.parseObject(bodyStr); + String message = jsonObject.getString("message"); + Toast.makeText(GoodsStoreActivity.getCurrentActivity(), message, Toast.LENGTH_SHORT).show(); + + String data = jsonObject.getString("data"); + + List goodsEntities1 = JSONObject.parseArray(data, GoodsEntity.class); + // 查询是否存在 + if (goodsEntities1 != null) { + goodsEntities1.forEach(goodsEntity1 -> { + GoodsEntity oneByNumber = getOneByNumber(context, goodsEntity1.getNumber()); + if (oneByNumber == null) { +// 防止id冲突 + goodsEntity1.setId(null); + GoodsMapper.save(context, goodsEntity1); + } + }); + // 广播通知渲染下界面,Service通过广播刷新UI + Intent broadCastIntent = new Intent(Constant.BROADCAST_ACTION); + broadCastIntent.putExtra(Constant.MESSAGE, "数据更新完成"); + context.sendBroadcast(broadCastIntent); } + }) .setOnException((IOException e) -> { // 这里处理请求异常 Log.i("kkk", "异步异常捕获:" + e.getMessage()); - Toast.makeText(GoodsStoreActivity.goodsStoreActivity, "服务不在线", Toast.LENGTH_SHORT).show(); + Toast.makeText(GoodsStoreActivity.getCurrentActivity(), "服务不在线", Toast.LENGTH_SHORT).show(); }) // 请求参数设置... - .get().getResult(); + .get(); + log.info("请求服务器数据完成"); - synchronized (lock) { - HttpResult.Body body = result.getBody(); - if (body != null) { - return body.cache().toString(); - } - } - return new String(); } /** @@ -283,30 +406,12 @@ public class GoodsEntityService { * * @return */ - public void syncData(Context context, List goodsEntities) { - if (goodsEntities != null && goodsEntities.size() > 0) { - HttpResult httpResult = postAllToServer(goodsEntities); - } + public void syncData(List goodsEntities) { - String httpResult1 = requestGetListAll(); - if (StringUtil.hasText(httpResult1)) { - JSONObject jsonObject = JSONObject.parseObject(httpResult1); - String message = jsonObject.getString("message"); - String data = jsonObject.getString("data"); - - List goodsEntities1 = JSONObject.parseArray(data, GoodsEntity.class); - // 查询是否存在 - if (goodsEntities1 != null) { - goodsEntities1.forEach(goodsEntity1 -> { - GoodsEntity oneByNumber = getOneByNumber(context, goodsEntity1.getNumber()); - if (oneByNumber == null) { -// 防止id冲突 - goodsEntity1.setId(null); - save(context, goodsEntity1); - } - }); - } + if (goodsEntities != null && goodsEntities.size() > 0) { + log.info("推送本地数据到服务器"); + postAllToServer(goodsEntities); } - + requestGetListAll(); } } diff --git a/app/src/main/java/com/hxy/manager/service/MainService.java b/app/src/main/java/com/hxy/manager/service/MainService.java index a9a197159bf525062e15c559beead71d3273df49..7ece2caa65c5cdfab19a55fbe830b556b9140bcc 100755 --- a/app/src/main/java/com/hxy/manager/service/MainService.java +++ b/app/src/main/java/com/hxy/manager/service/MainService.java @@ -8,35 +8,95 @@ package com.hxy.manager.service; import android.app.Service; import android.content.Intent; import android.os.Binder; +import android.os.Bundle; import android.os.IBinder; +import android.util.Log; +import android.widget.Toast; + +import com.hxy.manager.util.Constant; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Created by 傲寒宏志 on 2018/1/3. */ public class MainService extends Service { + Logger log = LoggerFactory.getLogger(SyncService.class); //实现一个INBinder接口 public final IBinder myBinder = new LocalBinder(); //将该接口实现为一个继承Binder得内部类的对象! public class LocalBinder extends Binder { //在内部类实现一个返回对象的方法 - + public MainService getService() { + return MainService.this; + } } - // 绑定时执行 + /** + * 首次创建服务时,系统将调用此方法来执行一次性设置程序(在调用 onStartCommand() 或 onBind() 之前)。 + * 如果服务已在运行,则不会调用此方法。该方法只被调用一次 + */ public void onCreate() { super.onCreate(); } - // 重写onBind方法 + /** + * 重写onBind方法 + * + * @param intent + * @return + */ @Override public IBinder onBind(Intent intent) { + // Toast.makeText(this,"本地绑定:SyncService",Toast.LENGTH_SHORT).show(); return myBinder; } - //调用时执行 - public void sync() { + @Override + public boolean onUnbind(Intent intent) { + // Toast.makeText(this,"取消本地绑定:SyncService",Toast.LENGTH_SHORT).show(); + return false; + } + + /** + * 每次通过startService()方法启动Service时都会被回调。 + * + * @param intent + * @param flags + * @param startId + * @return + */ + @Override + public int onStartCommand(Intent intent, int flags, int startId) { + + Bundle extras = intent.getExtras(); + String msg = extras.getString("msg"); + log.info("服务处理消息==>{}", msg); +// try { +// Thread.sleep(10000); +// } catch (InterruptedException e) { +// e.printStackTrace(); +// } + // Service通过广播刷新UI + Intent broadCastIntent = new Intent(Constant.BROADCAST_ACTION); + broadCastIntent.putExtra(Constant.MESSAGE, "数据更新完成"); + sendBroadcast(broadCastIntent); + + return super.onStartCommand(intent, flags, startId); + } + /** + * 服务销毁时的回调 + */ + @Override + public void onDestroy() { + super.onDestroy(); + log.info("SyncService服务已经停止"); + Log.i(Constant.TAG, "SyncService服务已经停止"); + Toast.makeText(this, "SyncService服务已经停止", Toast.LENGTH_SHORT).show(); } + } diff --git a/app/src/main/java/com/hxy/manager/service/MyNotificationListenerService.java b/app/src/main/java/com/hxy/manager/service/MyNotificationListenerService.java new file mode 100644 index 0000000000000000000000000000000000000000..efb537ba0ff94dddb99de17dbf6136f31570f8a6 --- /dev/null +++ b/app/src/main/java/com/hxy/manager/service/MyNotificationListenerService.java @@ -0,0 +1,75 @@ +package com.hxy.manager.service; + +import android.app.Notification; +import android.app.PendingIntent; +import android.os.Bundle; +import android.service.notification.NotificationListenerService; +import android.service.notification.StatusBarNotification; + +import com.hxy.manager.request.NotificationRequest; +import com.hxy.manager.util.StringUtil; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * https://blog.csdn.net/Lemon_husky/article/details/102914881 + *

+ * https://juejin.cn/post/6844903669121417230 + */ +public class MyNotificationListenerService extends NotificationListenerService { + + Logger log = LoggerFactory.getLogger(MyNotificationListenerService.class); + + public static final String QQ = "com.tencent.mobileqq"; + public static final String TIM = "com.tencent.tim"; + public static final String WX = "com.tencent.mm"; + public static final String MMS = "com.android.mms"; + + @Override + public void onListenerConnected() { + //当连接成功时调用,一般在开启监听后会回调一次该方法 + log.info("当连接成功时调用,一般在开启监听后会回调一次该方法"); + } + + @Override + public void onNotificationPosted(StatusBarNotification sbn) { + Bundle extras = sbn.getNotification().extras; + String pachageName = sbn.getPackageName(); + String title = extras.getString(Notification.EXTRA_TITLE); //通知title + String content = extras.getString(Notification.EXTRA_TEXT); //通知内容 + if (StringUtil.isEmpty(content) && sbn.getNotification().tickerText != null) { + content = sbn.getNotification().tickerText.toString(); + } + PendingIntent pendingIntent = sbn.getNotification().contentIntent; //获取通知的PendingIntent + if (!StringUtil.isEmpty(content)) { + int length = content.length(); + if (content.endsWith("...") && length > 150) { + log.error("{},{}={},长度{}", pachageName, title, content, length); + } else { + // TIM的消息最多支持1024个长度。 + log.info("{},{}={},长度{}", pachageName, title, content, length); + } + if (TIM.equalsIgnoreCase(pachageName)) { + // 筛选出来需要处理的群名, + if (title.contains("极兔") && content.contains("JT")) { + NotificationRequest.put(this, content); + } + } + } + } + + + @Override + public void onNotificationRemoved(StatusBarNotification sbn) { + //当移除一条消息的时候回调,sbn是被移除的消息 + Bundle extras = sbn.getNotification().extras; + String title = extras.getString(Notification.EXTRA_TITLE); //通知title + String content = extras.getString(Notification.EXTRA_TEXT); //通知内容 +// int smallIconId = extras.getInt(Notification.EXTRA_SMALL_ICON); //通知小图标id +// Bitmap largeIcon = extras.getParcelable(Notification.EXTRA_LARGE_ICON); //通知的大图标,注意和获取小图标的区别 + PendingIntent pendingIntent = sbn.getNotification().contentIntent; //获取通知的PendingIntent +// log.info("{}={}", title, content); +// log.info("当移除一条消息的时候回调,sbn是被移除的消息"); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/hxy/manager/service/NianHuoCustomerService.java b/app/src/main/java/com/hxy/manager/service/NianHuoCustomerService.java new file mode 100644 index 0000000000000000000000000000000000000000..d8070ac12f9f38f2bf2ec21eecbb0bac3e212872 --- /dev/null +++ b/app/src/main/java/com/hxy/manager/service/NianHuoCustomerService.java @@ -0,0 +1,48 @@ +package com.hxy.manager.service; + +import android.content.Context; +import android.util.Log; + +import com.ejlchina.okhttps.HttpResult; +import com.ejlchina.okhttps.OkHttps; +import com.hxy.manager.entity.NianHuoCustomerEntity; +import com.hxy.manager.util.Tags; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +public class NianHuoCustomerService { + /** + * 新增推送到服务器 + * + * @param context + * @param nianHuoCustomerEntity + * @return + */ + public static HttpResult postToServer(Context context, NianHuoCustomerEntity nianHuoCustomerEntity) { + + Map map= new HashMap(); + map.put("name",nianHuoCustomerEntity.getName()); + map.put("address",nianHuoCustomerEntity.getAddress()); + + return OkHttps.async("/customer-create") + .bind(context) // 绑定(生命周期|Context获取) +// .tag(Tags.TOKEN) // 自动添加 TOEKN + .tag(Tags.LOADING) // 自动显示加载框 + .addUrlPara(map) + .bodyType(OkHttps.JSON) + .setOnResponse(res -> { +// editText4.setText(res.toString()); + }) + .setOnException((IOException e) -> { + // 这里处理请求异常 + Log.i("kkk", "异步异常捕获:" + e.getMessage()); +// editText4.setText(e.getMessage()); + }) + // 请求参数设置... + .get().getResult(); + + } + +} diff --git a/app/src/main/java/com/hxy/manager/service/SyncIntentService.java b/app/src/main/java/com/hxy/manager/service/SyncIntentService.java new file mode 100644 index 0000000000000000000000000000000000000000..f8d670e9326ad0cd9a79fb61af72350216f96984 --- /dev/null +++ b/app/src/main/java/com/hxy/manager/service/SyncIntentService.java @@ -0,0 +1,49 @@ +package com.hxy.manager.service; + +import android.app.IntentService; +import android.content.Intent; + +import androidx.annotation.Nullable; + +import com.hxy.manager.activity.goods.GoodsStoreActivity; +import com.hxy.manager.entity.GoodsEntity; +import com.hxy.manager.util.Constant; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.List; + +public class SyncIntentService extends IntentService { + + Logger log = LoggerFactory.getLogger(SyncIntentService.class); + + + public SyncIntentService() { + super("子线程名字"); + } + + @Override + protected void onHandleIntent(@Nullable Intent intent) { + // 查询本地数据库数据 + List goodsEntities = GoodsEntityService.listAll(SyncIntentService.this); + + // 发送到服务器 + GoodsEntityService goodsEntityService = new GoodsEntityService(GoodsStoreActivity.goodsStoreActivity); + goodsEntityService.syncData(goodsEntities); + +// try { +// Thread.sleep(10000); +// } catch (InterruptedException e) { +// e.printStackTrace(); +// } + + log.info("向服务器请求数据"); + + // Service通过广播刷新UI + Intent broadCastIntent = new Intent(Constant.BROADCAST_ACTION); + broadCastIntent.putExtra(Constant.MESSAGE, "数据更新完成"); + sendBroadcast(broadCastIntent); + + } +} diff --git a/app/src/main/java/com/hxy/manager/service/SyncService.java b/app/src/main/java/com/hxy/manager/service/SyncService.java index 1f1e59658af56d4fd5d57b9eb24c61985c859328..a9cbdde381b6b69edf13fa88d4da271e366d35e5 100755 --- a/app/src/main/java/com/hxy/manager/service/SyncService.java +++ b/app/src/main/java/com/hxy/manager/service/SyncService.java @@ -1,24 +1,34 @@ package com.hxy.manager.service; + +/** + * Created by 傲寒宏志 on 2018/1/4. + */ + import android.app.Service; import android.content.Intent; -import android.content.SharedPreferences; import android.os.Binder; import android.os.IBinder; import android.util.Log; +import android.widget.Toast; +import com.hxy.manager.activity.goods.GoodsStoreActivity; import com.hxy.manager.entity.GoodsEntity; import com.hxy.manager.util.Constant; -import com.hxy.manager.util.StringUtil; -import java.util.List; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import java.util.List; +/** + * Created by 傲寒宏志 on 2018/1/3. + */ public class SyncService extends Service { - final String host = "182.254.227.30";//服务器地址 - final String port = "10086"; - final String version = "1.17.9"; + Logger log = LoggerFactory.getLogger(SyncService.class); + + //实现一个INBinder接口 public final IBinder myBinder = new LocalBinder(); @@ -34,16 +44,8 @@ public class SyncService extends Service { * 绑定时执行 */ public void onCreate() { + log.info("SyncService的onCreate初始化"); super.onCreate(); - // Toast.makeText(this,"Service已启动",Toast.LENGTH_SHORT).show(); - //读取shareperf - SharedPreferences pref = getSharedPreferences("com.hxy.manager_preferences", MODE_PRIVATE); - Log.i("kkk", "pref" + pref); - String host2 = pref.getString("ServerUrl", host); - int port2 = Integer.parseInt(pref.getString("ServerPort", port)); -// 用于提示当前service的接口 -// Toast.makeText(getApplicationContext(), host2+":"+port2, Toast.LENGTH_SHORT).show(); - Log.i("kkk", host2 + port2); } /** @@ -54,42 +56,39 @@ public class SyncService extends Service { */ @Override public IBinder onBind(Intent intent) { + log.info("SyncService的onBind初始化"); // Toast.makeText(this,"本地绑定:SyncService",Toast.LENGTH_SHORT).show(); return myBinder; } @Override public boolean onUnbind(Intent intent) { + log.info("SyncService的onUnbind取消本地绑定"); // Toast.makeText(this,"取消本地绑定:SyncService",Toast.LENGTH_SHORT).show(); return false; } - public void uploadData() { - new Thread(new Runnable() { - @Override - public void run() { - - //查询本地数据库数据 - List goodsEntities = GoodsEntityService.listAll(SyncService.this); - if (goodsEntities!=null){ - for (GoodsEntity goodsEntity : goodsEntities) { - if (goodsEntity!=null&& StringUtil.hasText(goodsEntity.getName())){ - Log.i("kkk", goodsEntity.getName()); - } - } - } - -// 发送到服务器 - - GoodsEntityService goodsEntityService = new GoodsEntityService(SyncService.this); - goodsEntityService.syncData(SyncService.this, goodsEntities); - + @Override + public int onStartCommand(Intent intent, int flags, int startId) { + log.info("SyncService的onStartCommand"); + + // 查询本地数据库数据 + List goodsEntities = GoodsEntityService.listAll(SyncService.this); + log.info("数据库查询结束"); + // 发送到服务器 + GoodsEntityService goodsEntityService = new GoodsEntityService(GoodsStoreActivity.goodsStoreActivity); + goodsEntityService.syncData(goodsEntities); + + log.info("SyncService的onStartCommand同步完后"); + return super.onStartCommand(intent, flags, startId); + } - Intent intent = new Intent(Constant.BROADCAST_ACTION); - intent.putExtra(Constant.MESSAGE, "同步完成"); - sendBroadcast(intent); - } - }).start(); + @Override + public void onDestroy() { + super.onDestroy(); + log.info("SyncService服务已经停止"); + Log.i(Constant.TAG, "SyncService服务已经停止"); + Toast.makeText(this, "SyncService服务已经停止", Toast.LENGTH_SHORT).show(); } } diff --git a/app/src/main/java/com/hxy/manager/service/TodayEntityService.java b/app/src/main/java/com/hxy/manager/service/TodayEntityService.java new file mode 100644 index 0000000000000000000000000000000000000000..c0fe87d7cf8b4a0977cd2d5c6a3599ac77593067 --- /dev/null +++ b/app/src/main/java/com/hxy/manager/service/TodayEntityService.java @@ -0,0 +1,129 @@ +package com.hxy.manager.service; + +import android.content.Context; +import android.util.Log; +import android.widget.Toast; + +import com.alibaba.fastjson.JSONObject; +import com.ejlchina.okhttps.HttpResult; +import com.ejlchina.okhttps.OkHttps; +import com.hxy.manager.activity.goods.GoodsStoreActivity; +import com.hxy.manager.entity.GoodsEntity; +import com.hxy.manager.entity.TodayPriceEntity; +import com.hxy.manager.util.StringUtil; +import com.hxy.manager.util.Tags; + +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class TodayEntityService { + /** + * 新增推送到服务器 + * + * @param context + * @param todayPriceEntity + * @return + */ + public static HttpResult postToServer(Context context, TodayPriceEntity todayPriceEntity) { + + Map map= new HashMap(); + map.put("name",todayPriceEntity.getName()); + map.put("price",todayPriceEntity.getPrice()); + + return OkHttps.async("/fruit-create") + .bind(context) // 绑定(生命周期|Context获取) +// .tag(Tags.TOKEN) // 自动添加 TOEKN + .tag(Tags.LOADING) // 自动显示加载框 + .addUrlPara(map) + .bodyType(OkHttps.JSON) + .setOnResponse(res -> { +// editText4.setText(res.toString()); + }) + .setOnException((IOException e) -> { + // 这里处理请求异常 + Log.i("kkk", "异步异常捕获:" + e.getMessage()); +// editText4.setText(e.getMessage()); + }) + // 请求参数设置... + .get().getResult(); + + } + + /** + * 请求服务器下载数据 + * + * @return + */ + public String requestGetListAll(Context context) { +// 异步操作,多线程操作 + Object lock = new Object(); + + HttpResult result = OkHttps.async("/goods/list") + .bind(context) // 绑定(生命周期|Context获取) +// .tag(Tags.TOKEN) // 自动添加 TOEKN +// .tag(Tags.LOADING) // 自动显示加载框 +// .setBodyPara(goodsEntities) + .bodyType(OkHttps.JSON) + .setOnResponse(res -> { + synchronized (lock) { + HttpResult.Body body1 = res.getBody().cache(); + String bodyStr = body1.toString(); + JSONObject jsonObject = JSONObject.parseObject(bodyStr); + String message = jsonObject.getString("message"); + + Toast.makeText(GoodsStoreActivity.getCurrentActivity(), message, Toast.LENGTH_SHORT).show(); + } + + }) + .setOnException((IOException e) -> { + // 这里处理请求异常 + Log.i("kkk", "异步异常捕获:" + e.getMessage()); + Toast.makeText(GoodsStoreActivity.getCurrentActivity(), "服务不在线", Toast.LENGTH_SHORT).show(); + }) + // 请求参数设置... + .get().getResult(); + + + synchronized (lock) { + HttpResult.Body body = result.getBody(); + if (body != null) { + return body.cache().toString(); + } + } + return new String(); + } + + /** + * 和服务器同步数据 + * + * @return + */ + public void syncData(Context context, List goodsEntities) { + if (goodsEntities != null && goodsEntities.size() > 0) { +// HttpResult httpResult = postAllToServer(goodsEntities); + } + + String httpResult1 = requestGetListAll(context); + if (StringUtil.hasText(httpResult1)) { + JSONObject jsonObject = JSONObject.parseObject(httpResult1); + String message = jsonObject.getString("message"); + String data = jsonObject.getString("data"); + + List goodsEntities1 = JSONObject.parseArray(data, GoodsEntity.class); + // 查询是否存在 + if (goodsEntities1 != null) { + goodsEntities1.forEach(goodsEntity1 -> { +// GoodsEntity oneByNumber = getOneByNumber(context, goodsEntity1.getNumber()); +// if (oneByNumber == null) { +//// 防止id冲突 +// goodsEntity1.setId(null); +// GoodsMapper.save(context, goodsEntity1); +// } + }); + } + } + + } +} diff --git a/app/src/main/java/com/hxy/manager/util/Constant.java b/app/src/main/java/com/hxy/manager/util/Constant.java index cc84110ff09cc0b4ef5d1b9e18580db4b7063488..9a94f359cf1d73d63522e7378b2162e6fa16c6cf 100644 --- a/app/src/main/java/com/hxy/manager/util/Constant.java +++ b/app/src/main/java/com/hxy/manager/util/Constant.java @@ -1,10 +1,13 @@ package com.hxy.manager.util; public class Constant { + public static final String SQLITE_DATABASE = "shop.db"; public static final int RGB_RED = 0xFFFF0000; public static final String SCAN_CODE = "scanCode"; public static final String BROADCAST_ACTION = "com.gdp2852.demo.service.broadcast"; public static final String MESSAGE = "msg"; + public static final int STATUS_CODE = 200; + public static final String TAG = "kkk"; } diff --git a/app/src/main/java/com/hxy/manager/util/FileUtil.java b/app/src/main/java/com/hxy/manager/util/FileUtil.java new file mode 100644 index 0000000000000000000000000000000000000000..bec8a11e6b25a6f47206f9e48cea48f2cd7c8a71 --- /dev/null +++ b/app/src/main/java/com/hxy/manager/util/FileUtil.java @@ -0,0 +1,33 @@ +package com.hxy.manager.util; + +import android.content.Context; +import android.net.Uri; +import android.os.Build; + +import androidx.core.content.FileProvider; + +import java.io.File; + +public class FileUtil { + /** + * 根据文件获取Uri + * + * @param context + * @param file + * @param packageName + * @return + */ + public static Uri getUriForFile(Context context, File file, String packageName) { + String FILE_PROVIDER_AUTH = packageName + ".fileprovider"; + Uri fileUri = null; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {//24 android7 + fileUri = FileProvider.getUriForFile(context, FILE_PROVIDER_AUTH, file); + } else { +// if (!hasExternalStorage()) +// chmodFile(file);//没有SD卡,需要更改文件权限 + //file.setReadable(true,false); + fileUri = Uri.fromFile(file); + } + return fileUri; + } +} diff --git a/app/src/main/java/com/hxy/manager/util/OkHttpsConfig.java b/app/src/main/java/com/hxy/manager/util/OkHttpsConfig.java index 8c477d52f0ba0d6b3abef0ed9c20c2300bcd6377..389dad53b6af0cfc1a9453224ed24d264146bc47 100644 --- a/app/src/main/java/com/hxy/manager/util/OkHttpsConfig.java +++ b/app/src/main/java/com/hxy/manager/util/OkHttpsConfig.java @@ -2,11 +2,8 @@ package com.hxy.manager.util; import android.app.ProgressDialog; import android.content.Context; -import android.content.Intent; -import android.content.SharedPreferences; import android.os.Handler; import android.os.Looper; -import android.util.Log; import android.widget.Toast; import androidx.fragment.app.Fragment; @@ -19,33 +16,12 @@ import com.ejlchina.okhttps.Config; import com.ejlchina.okhttps.HTTP; import com.ejlchina.okhttps.HttpResult; import com.ejlchina.okhttps.HttpTask; -import com.ejlchina.okhttps.Mapper; -import com.ejlchina.okhttps.OnCallback; import com.hxy.manager.App; -import com.hxy.manager.activity.IndexActivity; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.security.KeyManagementException; -import java.security.NoSuchAlgorithmException; -import java.security.SecureRandom; -import java.security.cert.CertificateException; -import java.security.cert.X509Certificate; import java.util.concurrent.atomic.AtomicInteger; -import javax.net.ssl.HostnameVerifier; -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLSession; -import javax.net.ssl.SSLSocketFactory; -import javax.net.ssl.TrustManager; -import javax.net.ssl.X509TrustManager; - public class OkHttpsConfig implements Config { - Logger log = LoggerFactory.getLogger(OkHttpsConfig.class); - - // 绑定到主线程的 Handler private Handler mainHandler = new Handler(Looper.getMainLooper()); private ProgressDialog loading = null; @@ -54,47 +30,7 @@ public class OkHttpsConfig implements Config { @Override public void with(HTTP.Builder builder) { - X509TrustManager myTrustManager = new X509TrustManager() { - - @Override - public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException { - } - - @Override - public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException { - } - - @Override - public X509Certificate[] getAcceptedIssuers() { - return new X509Certificate[0]; - } - }; - - HostnameVerifier myHostnameVerifier = new HostnameVerifier() { - @Override - public boolean verify(String hostname, SSLSession session) { - return true; - } - }; - - SSLContext sslCtx = null; - try { - sslCtx = SSLContext.getInstance("TLS"); - } catch (NoSuchAlgorithmException e) { - e.printStackTrace(); - } - try { - sslCtx.init(null, new TrustManager[]{myTrustManager}, new SecureRandom()); - } catch (KeyManagementException e) { - e.printStackTrace(); - } - - SSLSocketFactory mySSLSocketFactory = sslCtx.getSocketFactory(); - - builder.config(b -> { - b.sslSocketFactory(mySSLSocketFactory, myTrustManager); - b.hostnameVerifier(myHostnameVerifier); - }).baseUrl(Urls.BASE_URL) // 配置 BaseURL + builder.baseUrl(Urls.BASE_URL) // 配置 BaseURL // 如果默认请求体是JSON,则开启,否则默认为表单 //.bodyType("json") @@ -105,11 +41,15 @@ public class OkHttpsConfig implements Config { // 加载框预处理(在 TOKEN 处理之前) .addPreprocessor(chain -> { HttpTask task = chain.getTask(); - // 根据标签判断是否显示加载框 - if (task.isTagged(Tags.LOADING)) { - showLoading(context(task)); - } - chain.proceed(); + Object bound = task.getBound(); + mainHandler.post(()->{ + task.bind(new BoundWrapper(task,bound)); + // 根据标签判断是否显示加载框 + if (task.isTagged(Tags.LOADING)) { + showLoading(context(task)); + } + chain.proceed(); + }); }) // 实现生命周期绑定 @@ -128,21 +68,21 @@ public class OkHttpsConfig implements Config { chain.proceed(); return; } - Context ctx = context(task); - requestTokenAndRefreshIfExpired(ctx, chain.getHttp(), - (String token) -> { - if (token != null) { - // 添加 Token 头信息,名字需要和后端商定 - task.addHeader("Access-Token", token); - } else if (ctx != null) { - // 若没有得到 Token, 则跳转登录页面 - ctx.startActivity(new Intent(ctx, IndexActivity.class)); - } else { - Log.e("OkHttps", "没有 Context 无法跳转登录页面!"); - } - // 无论如何,这行代码一定要执行到,不然后续接口会一直在排队中 - chain.proceed(); - }); +// Context ctx = context(task); +// requestTokenAndRefreshIfExpired(ctx, chain.getHttp(), +// (String token) -> { +// if (token != null) { +// // 添加 Token 头信息,名字需要和后端商定 +// task.addHeader("Access-Token", token); +// } else if (ctx != null) { +// // 若没有得到 Token, 则跳转登录页面 +// ctx.startActivity(new Intent(ctx, LoginActivity.class)); +// } else { +// Log.e("OkHttps", "没有 Context 无法跳转登录页面!"); +// } +// // 无论如何,这行代码一定要执行到,不然后续接口会一直在排队中 +// chain.proceed(); +// }); }) // 错误码统一处理 @@ -153,7 +93,7 @@ public class OkHttpsConfig implements Config { // 这里演示的是 HTTP 状态码的处理,如果有自定义的 code, 也可以进行深层次的判断 return true; // 继续接口的业务处理 } - // 向用户展示接口的错误信息 + // 向用户展示接口的错误信息(视情况是否需要放到主线程执行) showMsgToUser(task, result.getBody().toString()); return false; // 阻断 }) @@ -162,9 +102,10 @@ public class OkHttpsConfig implements Config { .completeListener((HttpTask task, HttpResult.State state) -> { Object bound = task.getBound(); if (bound instanceof BoundWrapper) { - ((BoundWrapper) bound).unbind(); + // 放到主线程执行 + mainHandler.post(() -> ((BoundWrapper) bound).unbind()); } - // 网络错误统一处理 + // 网络错误统一处理(视情况判断是否需要放到主线程上执行) switch (state) { case TIMEOUT: hideLoading(); @@ -176,8 +117,6 @@ public class OkHttpsConfig implements Config { break; case EXCEPTION: hideLoading(); - Log.e("kkk", state.toString()); - log.error("\n====>{}", state); showMsgToUser(task, "接口请求异常: " + task.getUrl()); break; } @@ -189,14 +128,13 @@ public class OkHttpsConfig implements Config { } - // 显示加载框 + // 显示加载框,注意这里的Content不可以是Service,必须是Activity private void showLoading(Context ctx) { if (loading == null) { // 这里就用 ProgressDialog 来演示了,当然可以替换成你喜爱的加载框 loading = new ProgressDialog(ctx); loading.setMessage("正在加载,请稍等..."); - } // 增加加载框显示计数 loadings.incrementAndGet(); @@ -267,70 +205,12 @@ public class OkHttpsConfig implements Config { Context ctx = context(task); if (ctx != null) { // 这里就简单用 Toast 示例一下,有更高级的实现可以替换 - Looper.prepare(); - Toast.makeText(ctx, message, Toast.LENGTH_LONG).show(); - Looper.loop(); + mainHandler.post(() -> { + Toast.makeText(ctx, message, Toast.LENGTH_LONG).show(); + }); +// Looper.prepare(); +// Toast.makeText(ctx, message, Toast.LENGTH_LONG).show(); +// Looper.loop(); } } - - /** - * 获取TOKEN,若过期则刷新(代码中的字符串可以替换为常量) - **/ - private void requestTokenAndRefreshIfExpired(Context ctx, HTTP http, - OnCallback callback) { - if (ctx == null) { - callback.on(null); - return; - } - // 这里演示使用 Preference 存储,也可以使用数据库存储 - SharedPreferences token = ctx.getSharedPreferences("token", - Context.MODE_PRIVATE); - long now = System.currentTimeMillis(); - // 刷新令牌 - String refreshToken = token.getString("refreshToken", null); - // 判断有效期可以提前 60 秒,以防在接下来的网络延迟中过期了 - if (token.getLong("refreshTokenExpiresAt", 0) < now + 60000 - || refreshToken == null) { - // 刷新令牌已过期,说明长时间未使用,需要重新登录 - callback.on(null); - return; - } - // 访问令牌 - String accessToken = token.getString("accessToken", null); - if (token.getLong("accessTokenExpiresAt", 0) > now + 60000 - && accessToken != null) { - // 访问令牌未过期,则回调令牌 - callback.on(accessToken); - return; - } - // 访问令牌已过期,刷新令牌未过期,则调接口刷新当前令牌 - http.async(Urls.TOKEN_REFRESH) - .skipPreproc() // 跳过所有预处理器 - .addBodyPara("refreshToken", refreshToken) - .setOnResponse(res -> { - if (!res.isSuccessful()) { - callback.on(null); - return; - } - Mapper mapper = res.getBody().toMapper(); - String newRefreshToken = mapper.getString("refreshToken"); - String newAccessToken = mapper.getString("accessToken"); - int refreshTokenExpiresIn = mapper.getInt("refreshTokenExpiresIn"); - int accessTokenExpiresIn = mapper.getInt("accessTokenExpiresIn"); - // 因为发生了请求,当前时间已经变化,所有重新获取时间 - long now2 = System.currentTimeMillis(); - // 保存到 SharedPreferences - token.edit() - .putString("refreshToken", newRefreshToken) - .putString("accessToken", newAccessToken) - .putLong("refreshTokenExpiresAt", refreshTokenExpiresIn * 1000 + now2) - .putLong("accessTokenExpiresAt", accessTokenExpiresIn * 1000 + now2) - .commit(); - // 回调令牌 - callback.on(newAccessToken); - }) - .setOnException(e -> callback.on(null)) - .post(); - } - } \ No newline at end of file diff --git a/app/src/main/java/com/hxy/manager/util/StringUtil.java b/app/src/main/java/com/hxy/manager/util/StringUtil.java index 9edb77736ea2c18219e22a774cbfcac0c92cb2f3..a262926d5fcc909f89e16856c46c1385359ed3e2 100644 --- a/app/src/main/java/com/hxy/manager/util/StringUtil.java +++ b/app/src/main/java/com/hxy/manager/util/StringUtil.java @@ -1,12 +1,11 @@ package com.hxy.manager.util; -import lombok.extern.slf4j.Slf4j; -import okio.Okio; - import java.io.IOException; import java.io.InputStream; import java.nio.charset.Charset; +import okio.Okio; + /** * @author eric * @description 禁止使用其他的StringUtils,如果这个类里面没有,那么可以将其他的StringUtils的方法复制过来。 diff --git a/app/src/main/java/com/hxy/manager/util/Urls.java b/app/src/main/java/com/hxy/manager/util/Urls.java index 7c28cea6b2737f423fa89fdc673fbd1584575e21..eb55ed61c98b92b16aa690682188be505db25d32 100644 --- a/app/src/main/java/com/hxy/manager/util/Urls.java +++ b/app/src/main/java/com/hxy/manager/util/Urls.java @@ -5,9 +5,12 @@ public class Urls { /** * BaseUrl 还可以根据 build.gradle 的配置来取 * 打出不同环境的包,自动使用不同的 BaseUrl,这里便不再示例 + *

+ * 服务器的配置信息 */ -// public static final String BASE_URL = "http://192.168.0.107:7070"; - public static final String BASE_URL = "https://easyprint.vip:7070"; + public static final String BASE_URL = "http://192.168.0.125:7070"; + // 走nginx +// public static final String BASE_URL = "https://scan.cupb.top"; /** * 当 Token 快过期时,调用该接口来刷新 Token diff --git a/app/src/main/java/com/hxy/manager/zxing/camera/CameraManager.java b/app/src/main/java/com/hxy/manager/zxing/camera/CameraManager.java index 92c926ee2b188818a357887fcd76e5119ce7ce7b..a78232a2665d58307c3192fab7ad7ce63a107497 100755 --- a/app/src/main/java/com/hxy/manager/zxing/camera/CameraManager.java +++ b/app/src/main/java/com/hxy/manager/zxing/camera/CameraManager.java @@ -24,7 +24,6 @@ import android.os.Handler; import android.util.Log; import android.view.SurfaceHolder; - import com.hxy.manager.zxing.camera.open.OpenCameraInterface; import java.io.IOException; diff --git a/app/src/main/java/com/hxy/manager/zxing/decode/DecodeHandler.java b/app/src/main/java/com/hxy/manager/zxing/decode/DecodeHandler.java index 1753d0ea318c1d0d2b96b522c6ebf1709461102f..b528bc27ebc70c5735bddc2e14ac678fe4c007fc 100755 --- a/app/src/main/java/com/hxy/manager/zxing/decode/DecodeHandler.java +++ b/app/src/main/java/com/hxy/manager/zxing/decode/DecodeHandler.java @@ -24,9 +24,6 @@ import android.os.Handler; import android.os.Looper; import android.os.Message; - -import com.hxy.manager.R; -import com.hxy.manager.activity.CaptureActivity; import com.google.zxing.BinaryBitmap; import com.google.zxing.DecodeHintType; import com.google.zxing.MultiFormatReader; @@ -34,6 +31,8 @@ import com.google.zxing.PlanarYUVLuminanceSource; import com.google.zxing.ReaderException; import com.google.zxing.Result; import com.google.zxing.common.HybridBinarizer; +import com.hxy.manager.R; +import com.hxy.manager.activity.CaptureActivity; import java.io.ByteArrayOutputStream; import java.util.Map; diff --git a/app/src/main/java/com/hxy/manager/zxing/decode/DecodeThread.java b/app/src/main/java/com/hxy/manager/zxing/decode/DecodeThread.java index e9af6ce2096f957b0a4e7eecd859a3165a68c426..ccc51e45d20ae6c329cfcbaf9091b36bec62f37e 100755 --- a/app/src/main/java/com/hxy/manager/zxing/decode/DecodeThread.java +++ b/app/src/main/java/com/hxy/manager/zxing/decode/DecodeThread.java @@ -15,12 +15,13 @@ */ package com.hxy.manager.zxing.decode; + import android.os.Handler; import android.os.Looper; -import com.hxy.manager.activity.CaptureActivity; import com.google.zxing.BarcodeFormat; import com.google.zxing.DecodeHintType; +import com.hxy.manager.activity.CaptureActivity; import java.util.ArrayList; import java.util.Collection; diff --git a/app/src/main/java/com/hxy/manager/zxing/encoding/EncodingUtils.java b/app/src/main/java/com/hxy/manager/zxing/encoding/EncodingUtils.java index d6df95f7eb5acf550b9b2a00d330d6c7aa342e61..7e1edf5741e1facb3689e299136416f5b75b2e33 100755 --- a/app/src/main/java/com/hxy/manager/zxing/encoding/EncodingUtils.java +++ b/app/src/main/java/com/hxy/manager/zxing/encoding/EncodingUtils.java @@ -1,15 +1,16 @@ package com.hxy.manager.zxing.encoding; - import android.graphics.Bitmap; import android.graphics.Canvas; + import com.google.zxing.BarcodeFormat; import com.google.zxing.EncodeHintType; import com.google.zxing.WriterException; import com.google.zxing.common.BitMatrix; import com.google.zxing.qrcode.QRCodeWriter; import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; + import java.util.HashMap; import java.util.Map; diff --git a/app/src/main/java/com/hxy/manager/zxing/utils/BeepManager.java b/app/src/main/java/com/hxy/manager/zxing/utils/BeepManager.java index 5dcab229b7da6af3c82c896f83c73e030adc2df6..9e8971038db1b257752be9abdf868f32b36e41ba 100755 --- a/app/src/main/java/com/hxy/manager/zxing/utils/BeepManager.java +++ b/app/src/main/java/com/hxy/manager/zxing/utils/BeepManager.java @@ -26,7 +26,6 @@ import android.os.Vibrator; import android.preference.PreferenceManager; import android.util.Log; - import com.hxy.manager.R; import java.io.Closeable; diff --git a/app/src/main/java/com/hxy/manager/zxing/utils/CaptureActivityHandler.java b/app/src/main/java/com/hxy/manager/zxing/utils/CaptureActivityHandler.java index 27eb28fc87c2f30e39e72b1772ea5cf3bee24110..91c43cf9a6cbf1cb0e70ad527ca631c19603e7e6 100755 --- a/app/src/main/java/com/hxy/manager/zxing/utils/CaptureActivityHandler.java +++ b/app/src/main/java/com/hxy/manager/zxing/utils/CaptureActivityHandler.java @@ -23,12 +23,11 @@ import android.os.Bundle; import android.os.Handler; import android.os.Message; +import com.google.zxing.Result; import com.hxy.manager.R; import com.hxy.manager.activity.CaptureActivity; -import com.hxy.manager.zxing.*; import com.hxy.manager.zxing.camera.CameraManager; import com.hxy.manager.zxing.decode.DecodeThread; -import com.google.zxing.Result; /** diff --git a/app/src/main/res/drawable-v24/shape_video_bg.xml b/app/src/main/res/drawable-v24/shape_video_bg.xml new file mode 100644 index 0000000000000000000000000000000000000000..24220fd727ebf6c9931fda74a738bdcc1894d440 --- /dev/null +++ b/app/src/main/res/drawable-v24/shape_video_bg.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_shadow.xml b/app/src/main/res/drawable/bg_shadow.xml new file mode 100644 index 0000000000000000000000000000000000000000..e48db0dc722c1503d19d17a155c16b067bc75ada --- /dev/null +++ b/app/src/main/res/drawable/bg_shadow.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_launcher.png b/app/src/main/res/drawable/ic_launcher.png index 72dc34fc24e7b72afd576c633c78b8b42ed7eea8..1752278b90c72b18a205bc8581ba0c6e988af57a 100644 Binary files a/app/src/main/res/drawable/ic_launcher.png and b/app/src/main/res/drawable/ic_launcher.png differ diff --git a/app/src/main/res/drawable/ic_launcher2.png b/app/src/main/res/drawable/ic_launcher2.png new file mode 100644 index 0000000000000000000000000000000000000000..72dc34fc24e7b72afd576c633c78b8b42ed7eea8 Binary files /dev/null and b/app/src/main/res/drawable/ic_launcher2.png differ diff --git a/app/src/main/res/drawable/layer_list.xml b/app/src/main/res/drawable/layer_list.xml new file mode 100644 index 0000000000000000000000000000000000000000..518fcd16b0ece50707a6dd2d3a73e14a1ad3b5cd --- /dev/null +++ b/app/src/main/res/drawable/layer_list.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/timer_list_selector.xml b/app/src/main/res/drawable/timer_list_selector.xml new file mode 100644 index 0000000000000000000000000000000000000000..51726ebaadfdaeb29993e5b8de1661be7063d4b3 --- /dev/null +++ b/app/src/main/res/drawable/timer_list_selector.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml deleted file mode 100644 index 6a27e916e1278f1b6a18ad586d23bfd216499009..0000000000000000000000000000000000000000 --- a/app/src/main/res/layout/activity_main.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/add.xml b/app/src/main/res/layout/add.xml index 32dbc8607bb8d6c0096a9f3feff1ead9f49dae37..8faab20a9a03d36a6bcd4edd2ee536e346e9ed61 100755 --- a/app/src/main/res/layout/add.xml +++ b/app/src/main/res/layout/add.xml @@ -1,290 +1,181 @@ - - - - - - - - - - - - - - -