From 17ad24cd4acfae549a591fdd180ec1e9bbc2e686 Mon Sep 17 00:00:00 2001 From: liup <1454939542@qq.com> Date: Mon, 20 May 2024 11:15:38 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BD=BF=E7=94=A8glide=E5=8A=A0=E8=BD=BD?= =?UTF-8?q?=E5=9B=BE=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 7 + .../bnframework/common/glide/GlideUtil.java | 115 +++++++++++++ .../common/glide/MyAppGlideModule.java | 50 ++++++ .../transform/FitXYRoundRadiusTransform.java | 95 +++++++++++ .../glide/transform/GlideBorderTransform.java | 67 ++++++++ .../glide/transform/GlideRoundTransform.java | 64 ++++++++ .../glide/transform/RoundRadiusTransform.java | 85 ++++++++++ .../transform/TransformationFitXYUtils.java | 155 ++++++++++++++++++ .../common/view/AddGoodDialog.java | 7 +- .../home/adapter/image_sp_adapter.java | 4 +- .../modules/home/adapter/newgood_adapter.java | 4 +- .../home/adapter/newmakegood_adapter.java | 4 +- .../home/fragment/mode/GoodInformation.java | 10 +- .../home/fragment/mode/add_good_control.java | 10 +- .../res/layout/datatab/layout/pfsx_item.xml | 4 +- 15 files changed, 668 insertions(+), 13 deletions(-) create mode 100644 app/src/main/java/com/bonait/bnframework/common/glide/GlideUtil.java create mode 100644 app/src/main/java/com/bonait/bnframework/common/glide/MyAppGlideModule.java create mode 100644 app/src/main/java/com/bonait/bnframework/common/glide/transform/FitXYRoundRadiusTransform.java create mode 100644 app/src/main/java/com/bonait/bnframework/common/glide/transform/GlideBorderTransform.java create mode 100644 app/src/main/java/com/bonait/bnframework/common/glide/transform/GlideRoundTransform.java create mode 100644 app/src/main/java/com/bonait/bnframework/common/glide/transform/RoundRadiusTransform.java create mode 100644 app/src/main/java/com/bonait/bnframework/common/glide/transform/TransformationFitXYUtils.java diff --git a/app/build.gradle b/app/build.gradle index cf87aa6e..a232d07f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -181,4 +181,11 @@ dependencies { //腾讯bugly //sdk地址 https://bugly.qq.com/docs/user-guide/instruction-manual-android/?v=1.0.0 implementation 'com.tencent.bugly:crashreport:latest.release' //其中latest.release指代最新Bugly SDK版本号,也可以指定明确的版本号,例如4.0.3 + + api 'org.greenrobot:eventbus:3.1.1' + + api 'com.github.bumptech.glide:glide:4.16.0' + annotationProcessor 'com.github.bumptech.glide:compiler:4.16.0' + api "com.github.bumptech.glide:okhttp3-integration:4.16.0" + api 'pl.droidsonroids.gif:android-gif-drawable:1.2.19' } diff --git a/app/src/main/java/com/bonait/bnframework/common/glide/GlideUtil.java b/app/src/main/java/com/bonait/bnframework/common/glide/GlideUtil.java new file mode 100644 index 00000000..88702fd9 --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/common/glide/GlideUtil.java @@ -0,0 +1,115 @@ +package com.bonait.bnframework.common.glide; + +import android.content.Context; +import android.graphics.drawable.Drawable; +import android.view.View; +import android.widget.ImageView; + +import androidx.annotation.Nullable; + +import com.bonait.bnframework.common.glide.transform.FitXYRoundRadiusTransform; +import com.bumptech.glide.load.DataSource; +import com.bumptech.glide.load.engine.GlideException; +import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions; +import com.bumptech.glide.request.RequestListener; +import com.bumptech.glide.request.RequestOptions; +import com.bumptech.glide.request.target.Target; + +/** + * @author: liup + * @description: + * @date: 2024/5/8 16:45. + */ +public class GlideUtil { + + private static final int CROSS_FADE_DURATION = 100; + + private GlideUtil() { + throw new AssertionError(); + } + +// public static String exchangeUrl(String path){ +// String result=path; +// if(!TextUtils.isEmpty(PATH_PRE)&&!TextUtils.isEmpty(path)) { +// if(!path.contains("http:")&&!path.contains("https:")){ +// if(path.contains(".png")||path.contains(".jpg")||path.contains(".jpeg")||path.contains(".gif")){ +// if(TEST) { +// result = PATH_PRE + path.replace("images", "modules"); +// }else{ +// result = PATH_PRE + path; +// } +// if(first){ +// LogUtils.d("GlideUtil exchangeUrl result:"+result); +// first=false; +// } +// } +// } +// } +//// LogUtils.i("GlideUtil exchangeUrl"+result); +// return result; +// } + + public static void showImage(Context context, String path, ImageView imageView,int placeId) { + if (context == null||path==null) { + return; + } + GlideApp.with(context) + .load(path) + .addListener(new RequestListener() { + @Override + public boolean onLoadFailed(@Nullable GlideException e, Object model, + Target target, boolean isFirstResource) { + return false; + } + + @Override + public boolean onResourceReady(Drawable resource, Object model, + Target target, DataSource dataSource, + boolean isFirstResource) { + if (imageView == null) { + return false; + } + imageView.setBackground(null); + return false; + } + }) + .placeholder(placeId) + .transition(DrawableTransitionOptions.withCrossFade(CROSS_FADE_DURATION)) + .into(imageView); + } + + public static void showImageWithRadius(Context context, String path, ImageView imageView,int placeId,int radius) { + if (context == null||path==null) { + return; + } + setType(imageView); + GlideApp.with(context) + .load(path) + .addListener(new RequestListener() { + @Override + public boolean onLoadFailed(@Nullable GlideException e, Object model, + Target target, boolean isFirstResource) { + return false; + } + + @Override + public boolean onResourceReady(Drawable resource, Object model, + Target target, DataSource dataSource, + boolean isFirstResource) { + if (imageView == null) { + return false; + } + imageView.setBackground(null); + return false; + } + }) + .transition(DrawableTransitionOptions.withCrossFade(CROSS_FADE_DURATION)) +// .apply(RequestOptions.bitmapTransform(new RoundedCorners(RADIUS))) + .apply(new RequestOptions().transform(new FitXYRoundRadiusTransform(radius))) + .into(imageView); + } + + private static void setType(ImageView imageView){//硬件加速 + imageView.setLayerType(View.LAYER_TYPE_HARDWARE,null); + } +} diff --git a/app/src/main/java/com/bonait/bnframework/common/glide/MyAppGlideModule.java b/app/src/main/java/com/bonait/bnframework/common/glide/MyAppGlideModule.java new file mode 100644 index 00000000..6edb048e --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/common/glide/MyAppGlideModule.java @@ -0,0 +1,50 @@ +package com.bonait.bnframework.common.glide; + +import android.content.Context; +import android.util.Log; + +import androidx.annotation.NonNull; + +import com.bumptech.glide.GlideBuilder; +import com.bumptech.glide.annotation.GlideModule; +import com.bumptech.glide.load.engine.bitmap_recycle.LruBitmapPool; +import com.bumptech.glide.load.engine.cache.InternalCacheDiskCacheFactory; +import com.bumptech.glide.load.engine.cache.LruResourceCache; +import com.bumptech.glide.load.engine.cache.MemorySizeCalculator; +import com.bumptech.glide.module.AppGlideModule; + +/** + * Glide模块 + * + * @author song.zheng@androidmov.com + */ +@GlideModule +public final class MyAppGlideModule extends AppGlideModule { + + @Override + public boolean isManifestParsingEnabled() { + return false; + } + + @Override + public void applyOptions(@NonNull Context context, @NonNull GlideBuilder builder) { + builder.setLogLevel(Log.WARN); + int cacheSize100MegaBytes = 104857600; + //应用私有目录 + builder.setDiskCache( + new InternalCacheDiskCacheFactory(context, cacheSize100MegaBytes) + ); + + MemorySizeCalculator calculator = new MemorySizeCalculator.Builder(context) + .setMemoryCacheScreens(2) + .build(); + int defaultMemoryCacheSize = calculator.getMemoryCacheSize(); + int defaultBitmapPoolSize = calculator.getBitmapPoolSize(); + + int customMemoryCacheSize = (int) (1.2 * defaultMemoryCacheSize); + int customBitmapPoolSize = (int) (1.2 * defaultBitmapPoolSize); + + builder.setMemoryCache( new LruResourceCache( customMemoryCacheSize )); + builder.setBitmapPool(new LruBitmapPool( customBitmapPoolSize )); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/bonait/bnframework/common/glide/transform/FitXYRoundRadiusTransform.java b/app/src/main/java/com/bonait/bnframework/common/glide/transform/FitXYRoundRadiusTransform.java new file mode 100644 index 00000000..7defac5f --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/common/glide/transform/FitXYRoundRadiusTransform.java @@ -0,0 +1,95 @@ +package com.bonait.bnframework.common.glide.transform; + +import android.graphics.Bitmap; + +import androidx.annotation.NonNull; + +import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool; +import com.bumptech.glide.load.resource.bitmap.BitmapTransformation; +import com.bumptech.glide.util.Util; + +import java.nio.ByteBuffer; +import java.security.MessageDigest; + +/** + * @author: wx + * @date: 2023/1/29 + */ +public class FitXYRoundRadiusTransform extends BitmapTransformation { + + // 此处用实际类的完整路径 + private static final String ID = "com.amt.module_common.util.image.FitXYRoundRadiusTransform"; + private static final byte[] ID_BYTES = ID.getBytes(CHARSET); + + private final int roundingRadius; + + private boolean isLeftTop = true; + private boolean isRightTop = true; + private boolean isLeftBottom = true; + private boolean isRightBottom = true; + + + public FitXYRoundRadiusTransform(int roundingRadius) { + this.roundingRadius = roundingRadius; + } + + public FitXYRoundRadiusTransform(int roundingRadius, boolean leftTop, boolean rightTop, boolean leftBottom, boolean rightBottom) { + this.roundingRadius = roundingRadius; + setNeedCorner(leftTop, rightTop, leftBottom, rightBottom); + } + + /** + * 需要设置圆角的部分 + * + * @param leftTop 左上角 + * @param rightTop 右上角 + * @param leftBottom 左下角 + * @param rightBottom 右下角 + */ + public void setNeedCorner(boolean leftTop, boolean rightTop, boolean leftBottom, boolean rightBottom) { + isLeftTop = leftTop; + isRightTop = rightTop; + isLeftBottom = leftBottom; + isRightBottom = rightBottom; + } + + @Override + protected Bitmap transform(@NonNull BitmapPool pool, @NonNull Bitmap toTransform, int outWidth, int outHeight) { + + Bitmap bitmap = TransformationFitXYUtils.fitXY(pool, toTransform, outWidth, outHeight); + + return TransformationFitXYUtils.roundCrop(pool, bitmap, + isLeftTop ? roundingRadius : 0, + isRightTop ? roundingRadius : 0, + isRightBottom ? roundingRadius : 0, + isLeftBottom ? roundingRadius : 0); + } + + + @Override + public boolean equals(Object o) { + if (o instanceof FitXYRoundRadiusTransform) { + FitXYRoundRadiusTransform other = (FitXYRoundRadiusTransform) o; + return roundingRadius == other.roundingRadius; + } + return false; + } + + @Override + public int hashCode() { + return Util.hashCode(ID.hashCode(), Util.hashCode(roundingRadius)); + } + + @Override + public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) { + messageDigest.update(ID_BYTES); + + byte[] radiusData = ByteBuffer.allocate(4).putInt(roundingRadius).array(); + messageDigest.update(radiusData); + } + + + + + +} diff --git a/app/src/main/java/com/bonait/bnframework/common/glide/transform/GlideBorderTransform.java b/app/src/main/java/com/bonait/bnframework/common/glide/transform/GlideBorderTransform.java new file mode 100644 index 00000000..9b521c62 --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/common/glide/transform/GlideBorderTransform.java @@ -0,0 +1,67 @@ +package com.bonait.bnframework.common.glide.transform; + +import android.graphics.Bitmap; +import android.graphics.BitmapShader; +import android.graphics.Canvas; +import android.graphics.Paint; +import android.graphics.RectF; + +import androidx.annotation.NonNull; + +import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool; +import com.bumptech.glide.load.resource.bitmap.BitmapTransformation; +import com.bumptech.glide.load.resource.bitmap.TransformationUtils; + +import java.security.MessageDigest; + +/** + * Glide边框转换 + * + * @author song.zheng@androidmov.com + */ +public class GlideBorderTransform extends BitmapTransformation { + private final float borderWidth; + private final int borderColor; + + public GlideBorderTransform(float borderWidth, int borderColor) { + super(); + this.borderWidth = borderWidth; + this.borderColor = borderColor; + } + + @Override + protected Bitmap transform(@NonNull BitmapPool pool, @NonNull Bitmap toTransform, int outWidth, + int outHeight) { + Bitmap bitmap = TransformationUtils.centerCrop(pool, toTransform, outWidth, outHeight); + return border(pool, bitmap); + } + + private Bitmap border(BitmapPool pool, Bitmap source) { + if (source == null) { + return null; + } + Bitmap result = pool.get(source.getWidth(), source.getHeight(), Bitmap.Config.ARGB_8888); + Canvas canvas = new Canvas(result); + Paint paint = new Paint(); + paint.setShader(new BitmapShader(source, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP)); + paint.setAntiAlias(true); + RectF rectF = new RectF(0f, 0f, source.getWidth(), source.getHeight()); + canvas.drawRect(rectF, paint); + paint.reset(); + paint.setStyle(Paint.Style.STROKE); + paint.setStrokeWidth(borderWidth); + paint.setColor(borderColor); + paint.setAntiAlias(true); + canvas.drawRect(rectF, paint); + return result; + } + + public String getId() { + return getClass().getName() + Math.round(borderWidth); + } + + @Override + public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) { + + } +} diff --git a/app/src/main/java/com/bonait/bnframework/common/glide/transform/GlideRoundTransform.java b/app/src/main/java/com/bonait/bnframework/common/glide/transform/GlideRoundTransform.java new file mode 100644 index 00000000..715ab8c1 --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/common/glide/transform/GlideRoundTransform.java @@ -0,0 +1,64 @@ +package com.bonait.bnframework.common.glide.transform; + +import android.content.Context; +import android.graphics.Bitmap; +import android.graphics.BitmapShader; +import android.graphics.Canvas; +import android.graphics.Paint; +import android.graphics.RectF; + +import androidx.annotation.NonNull; + +import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool; +import com.bumptech.glide.load.resource.bitmap.BitmapTransformation; +import com.bumptech.glide.load.resource.bitmap.TransformationUtils; + +import java.security.MessageDigest; + +/** + * Glide圆角转换 + * + * @author song.zheng@androidmov.com + */ +public class GlideRoundTransform extends BitmapTransformation { + private static float radius = 0f; + + public GlideRoundTransform(Context context) { + this(context, 8); + } + + public GlideRoundTransform(Context context, int px) { + super(); + radius = px; + } + + @Override + protected Bitmap transform(@NonNull BitmapPool pool, @NonNull Bitmap toTransform, int outWidth, + int outHeight) { + Bitmap bitmap = TransformationUtils.centerCrop(pool, toTransform, outWidth, outHeight); + return roundCrop(pool, bitmap); + } + + private static Bitmap roundCrop(BitmapPool pool, Bitmap source) { + if (source == null) { + return null; + } + Bitmap result = pool.get(source.getWidth(), source.getHeight(), Bitmap.Config.ARGB_8888); + Canvas canvas = new Canvas(result); + Paint paint = new Paint(); + paint.setShader(new BitmapShader(source, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP)); + paint.setAntiAlias(true); + RectF rectF = new RectF(0f, 0f, source.getWidth(), source.getHeight()); + canvas.drawRoundRect(rectF, radius, radius, paint); + return result; + } + + public String getId() { + return getClass().getName() + Math.round(radius); + } + + @Override + public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) { + + } +} diff --git a/app/src/main/java/com/bonait/bnframework/common/glide/transform/RoundRadiusTransform.java b/app/src/main/java/com/bonait/bnframework/common/glide/transform/RoundRadiusTransform.java new file mode 100644 index 00000000..60141bb9 --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/common/glide/transform/RoundRadiusTransform.java @@ -0,0 +1,85 @@ +package com.bonait.bnframework.common.glide.transform; + +import android.graphics.Bitmap; + +import androidx.annotation.NonNull; + +import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool; +import com.bumptech.glide.load.resource.bitmap.BitmapTransformation; +import com.bumptech.glide.load.resource.bitmap.TransformationUtils; +import com.bumptech.glide.util.Util; + +import java.nio.ByteBuffer; +import java.security.MessageDigest; + +/** + * @author: wx + * @date: 2023/1/29 + */ +public class RoundRadiusTransform extends BitmapTransformation { + + // 此处用实际类的完整路径 + private static final String ID = "com.amt.module_common.util.image.RoundRadiusTransform"; + private static final byte[] ID_BYTES = ID.getBytes(CHARSET); + + private final int roundingRadius; + + private boolean isLeftTop, isRightTop, isLeftBottom, isRightBottom; + + private static RoundRadiusTransform mInstance; + + public RoundRadiusTransform(int roundingRadius) { + this.roundingRadius = roundingRadius; + } + public RoundRadiusTransform(int roundingRadius,boolean leftTop, boolean rightTop, boolean leftBottom, boolean rightBottom) { + this.roundingRadius = roundingRadius; + setNeedCorner(leftTop, rightTop, leftBottom, rightBottom); + } + + /** + * 需要设置圆角的部分 + * + * @param leftTop 左上角 + * @param rightTop 右上角 + * @param leftBottom 左下角 + * @param rightBottom 右下角 + */ + public void setNeedCorner(boolean leftTop, boolean rightTop, boolean leftBottom, boolean rightBottom) { + isLeftTop = leftTop; + isRightTop = rightTop; + isLeftBottom = leftBottom; + isRightBottom = rightBottom; + } + + @Override + protected Bitmap transform(@NonNull BitmapPool pool, @NonNull Bitmap toTransform, int outWidth, int outHeight) { + return TransformationUtils.roundedCorners(pool, toTransform, + isLeftTop ? roundingRadius : 0, + isRightTop ? roundingRadius : 0, + isRightBottom ? roundingRadius : 0, + isLeftBottom ? roundingRadius : 0); + } + + + @Override + public boolean equals(Object o) { + if (o instanceof RoundRadiusTransform) { + RoundRadiusTransform other = (RoundRadiusTransform) o; + return roundingRadius == other.roundingRadius; + } + return false; + } + + @Override + public int hashCode() { + return Util.hashCode(ID.hashCode(), Util.hashCode(roundingRadius)); + } + + @Override + public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) { + messageDigest.update(ID_BYTES); + + byte[] radiusData = ByteBuffer.allocate(4).putInt(roundingRadius).array(); + messageDigest.update(radiusData); + } +} diff --git a/app/src/main/java/com/bonait/bnframework/common/glide/transform/TransformationFitXYUtils.java b/app/src/main/java/com/bonait/bnframework/common/glide/transform/TransformationFitXYUtils.java new file mode 100644 index 00000000..e9442506 --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/common/glide/transform/TransformationFitXYUtils.java @@ -0,0 +1,155 @@ +package com.bonait.bnframework.common.glide.transform; + +import android.graphics.Bitmap; +import android.graphics.BitmapShader; +import android.graphics.Canvas; +import android.graphics.Matrix; +import android.graphics.Paint; +import android.graphics.Path; +import android.graphics.RectF; + +import androidx.annotation.NonNull; + +import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool; +import com.bumptech.glide.load.resource.bitmap.TransformationUtils; +import com.bumptech.glide.util.Synthetic; + +import java.util.concurrent.TimeUnit; +import java.util.concurrent.locks.Condition; +import java.util.concurrent.locks.Lock; + +/** + * @author Nov + * @date 23.7.11 + */ +public class TransformationFitXYUtils { + private static final Lock BITMAP_DRAWABLE_LOCK = + new NoLock(); + + @NonNull + private static Bitmap.Config getNonNullConfig(@NonNull Bitmap bitmap) { + return bitmap.getConfig() != null ? bitmap.getConfig() : Bitmap.Config.ARGB_8888; + } + + private static void applyMatrix( + @NonNull Bitmap inBitmap, @NonNull Bitmap targetBitmap, Matrix matrix) { + BITMAP_DRAWABLE_LOCK.lock(); + try { + Canvas canvas = new Canvas(targetBitmap); + canvas.drawBitmap(inBitmap, matrix, DEFAULT_PAINT); + clear(canvas); + } finally { + BITMAP_DRAWABLE_LOCK.unlock(); + } + } + + public static final int PAINT_FLAGS = Paint.DITHER_FLAG | Paint.FILTER_BITMAP_FLAG; + private static final Paint DEFAULT_PAINT = new Paint(PAINT_FLAGS); + + private static final class NoLock implements Lock { + + @Synthetic + NoLock() { + } + + @Override + public void lock() { + // do nothing + } + + @Override + public void lockInterruptibly() throws InterruptedException { + // do nothing + } + + @Override + public boolean tryLock() { + return true; + } + + @Override + public boolean tryLock(long time, @NonNull TimeUnit unit) throws InterruptedException { + return true; + } + + @Override + public void unlock() { + // do nothing + } + + @NonNull + @Override + public Condition newCondition() { + throw new UnsupportedOperationException("Should not be called"); + } + } + + private static void clear(Canvas canvas) { + canvas.setBitmap(null); + } + + + public static Bitmap fitXY( + @NonNull BitmapPool pool, @NonNull Bitmap inBitmap, int width, int height) { + + if (inBitmap.getWidth() == width && inBitmap.getHeight() == height) { + return inBitmap; + } + final float widthPercentage = width / (float) inBitmap.getWidth(); + final float heightPercentage = height / (float) inBitmap.getHeight(); + int targetWidth = (int) (widthPercentage * inBitmap.getWidth()); + int targetHeight = (int) (heightPercentage * inBitmap.getHeight()); + + Bitmap.Config config = getNonNullConfig(inBitmap); + Bitmap toReuse = pool.get(targetWidth, targetHeight, config); + TransformationUtils.setAlpha(inBitmap, toReuse); + Matrix matrix = new Matrix(); + matrix.setScale(widthPercentage, heightPercentage); + applyMatrix(inBitmap, toReuse, matrix); + return toReuse; + } + + public static Bitmap roundCrop(BitmapPool pool, + Bitmap source, + float topLeft, + float topRight, + float bottomRight, + float bottomLeft) { + if (source == null) return null; + + Bitmap result = pool.get(source.getWidth(), source.getHeight(), Bitmap.Config.ARGB_8888); + if (result == null) { + result = Bitmap.createBitmap(source.getWidth(), source.getHeight(), Bitmap.Config.ARGB_8888); + } + BitmapShader shader = + new BitmapShader(source, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP); + + Paint paint = new Paint(); + paint.setShader(shader); + paint.setAntiAlias(true); + RectF rect = new RectF(0f, 0f, source.getWidth(), source.getHeight()); + BITMAP_DRAWABLE_LOCK.lock(); + try { + Canvas canvas = new Canvas(result); + Path path = new Path(); + path.addRoundRect( + rect, + new float[]{ + topLeft, + topLeft, + topRight, + topRight, + bottomRight, + bottomRight, + bottomLeft, + bottomLeft + }, + Path.Direction.CW); + canvas.drawPath(path, paint); + clear(canvas); + } finally { + BITMAP_DRAWABLE_LOCK.unlock(); + } + return result; + } +} diff --git a/app/src/main/java/com/bonait/bnframework/common/view/AddGoodDialog.java b/app/src/main/java/com/bonait/bnframework/common/view/AddGoodDialog.java index cc3414e6..aea02fc1 100644 --- a/app/src/main/java/com/bonait/bnframework/common/view/AddGoodDialog.java +++ b/app/src/main/java/com/bonait/bnframework/common/view/AddGoodDialog.java @@ -29,6 +29,7 @@ import com.bonait.bnframework.common.db.mode.BPA_GOODS; import com.bonait.bnframework.common.db.mode.BPA_GOODSTYPE; import com.bonait.bnframework.common.db.mode.BPA_MATERIAL; import com.bonait.bnframework.common.db.res.ResMaterilas; +import com.bonait.bnframework.common.glide.GlideUtil; import com.bonait.bnframework.common.image.MyBitmapUtils; import com.bonait.bnframework.common.message.MessageLooper; import com.bonait.bnframework.common.message.MessageManager; @@ -198,7 +199,8 @@ public class AddGoodDialog extends Dialog { public void onMessage(Object msg) { if (msg != null) { url=(String) msg; - new MyBitmapUtils().disPlay(cpfm,url); + GlideUtil.showImage(cpfm.getContext(),url,cpfm,R.mipmap.loading3); +// new MyBitmapUtils().disPlay(cpfm,url); } } }); @@ -286,7 +288,8 @@ public class AddGoodDialog extends Dialog { { edittext.setText(Data.name); edittext1.setText(Data.foreignKeyRe); - new MyBitmapUtils().disPlay(cpfm,Data.url); +// new MyBitmapUtils().disPlay(cpfm,Data.url); + GlideUtil.showImage(cpfm.getContext(),url,cpfm,R.mipmap.loading3); int index=0; for (Map.Entry entry : map_fl.entrySet()) { String key = entry.getKey(); diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/adapter/image_sp_adapter.java b/app/src/main/java/com/bonait/bnframework/modules/home/adapter/image_sp_adapter.java index b33303af..cd672cec 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/adapter/image_sp_adapter.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/adapter/image_sp_adapter.java @@ -15,6 +15,7 @@ import androidx.recyclerview.widget.RecyclerView; import com.bonait.bnframework.R; import com.bonait.bnframework.common.constant.DataBus; import com.bonait.bnframework.common.db.mode.BPA_GOODS; +import com.bonait.bnframework.common.glide.GlideUtil; import com.bonait.bnframework.common.helper.I.MyClickListener; import com.bonait.bnframework.common.image.MyBitmapUtils; import com.bonait.bnframework.common.utils.AlertDialogUtils; @@ -70,7 +71,8 @@ public class image_sp_adapter extends RecyclerView.Adapter entry : map_fl.entrySet()) { @@ -358,7 +360,8 @@ public class GoodInformation extends LinearLayout implements MyClickListener { } else { edittext.setText(""); edittext1.setText(""); - new MyBitmapUtils().disPlay(cpfm, ""); +// new MyBitmapUtils().disPlay(cpfm, ""); + GlideUtil.showImage(cpfm.getContext(),"",cpfm,R.mipmap.loading3); url = ""; } @@ -644,7 +647,8 @@ public class GoodInformation extends LinearLayout implements MyClickListener { public void onMessage(Object msg) { if (msg != null) { url = (String) msg; - new MyBitmapUtils().disPlay(cpfm, url); +// new MyBitmapUtils().disPlay(cpfm, url); + GlideUtil.showImage(cpfm.getContext(),url,cpfm,R.mipmap.loading3); } } }); diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_good_control.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_good_control.java index 574d0bf9..391f1fe9 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_good_control.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_good_control.java @@ -23,6 +23,7 @@ import com.bonait.bnframework.common.db.mode.BPA_GOODS; import com.bonait.bnframework.common.db.mode.BPA_GOODSTYPE; import com.bonait.bnframework.common.db.mode.BPA_MATERIAL; import com.bonait.bnframework.common.db.res.ResMaterilas; +import com.bonait.bnframework.common.glide.GlideUtil; import com.bonait.bnframework.common.helper.I.MyClickListener; import com.bonait.bnframework.common.image.MyBitmapUtils; import com.bonait.bnframework.common.message.MessageLooper; @@ -221,7 +222,8 @@ public class add_good_control extends LinearLayout { public void onMessage(Object msg) { if (msg != null) { url=(String) msg; - new MyBitmapUtils().disPlay(cpfm,url); +// new MyBitmapUtils().disPlay(cpfm,url); + GlideUtil.showImage(cpfm.getContext(),url,cpfm,R.mipmap.loading3); } } }); @@ -315,7 +317,8 @@ public class add_good_control extends LinearLayout { { edittext.setText(Data.name); edittext1.setText(Data.foreignKeyRe); - new MyBitmapUtils().disPlay(cpfm,Data.url); +// new MyBitmapUtils().disPlay(cpfm,Data.url); + GlideUtil.showImage(cpfm.getContext(),url,cpfm,R.mipmap.loading3); url=Data.url; int index=0; for (Map.Entry entry : map_fl.entrySet()) { @@ -331,7 +334,8 @@ public class add_good_control extends LinearLayout { { edittext.setText(""); edittext1.setText(""); - new MyBitmapUtils().disPlay(cpfm,""); +// new MyBitmapUtils().disPlay(cpfm,""); + GlideUtil.showImage(cpfm.getContext(),"",cpfm,R.mipmap.loading3); url=""; } diff --git a/app/src/main/res/layout/datatab/layout/pfsx_item.xml b/app/src/main/res/layout/datatab/layout/pfsx_item.xml index 8b43684a..b7f6b54c 100644 --- a/app/src/main/res/layout/datatab/layout/pfsx_item.xml +++ b/app/src/main/res/layout/datatab/layout/pfsx_item.xml @@ -22,8 +22,8 @@ android:layout_alignParentRight="true" android:layout_marginRight="@dimen/dp_10" android:text="回锅" - android:textAlignment="textEnd" - android:textSize="19dp" /> + android:gravity="center" + android:textSize="18sp" /> From c375fbf7af6b4690df04887edfc9e13817fb2cd6 Mon Sep 17 00:00:00 2001 From: liup <1454939542@qq.com> Date: Tue, 21 May 2024 09:55:50 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=86=85=E5=AD=98=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/deploymentTargetSelector.xml | 8 + app/build.gradle | 2 +- .../bonait/bnframework/HBL/API/APIHelper.java | 36 ++ .../bnframework/HttpModel/APIService.java | 15 +- .../bonait/bnframework/MainApplication.java | 15 + .../bonait/bnframework/common/db/QueryDB.java | 8 +- .../bnframework/common/db/mode/BPA_GOODS.java | 16 + .../adapter/FilePickerShowAdapter.java | 4 +- .../common/linktab/good/GoodLeftAdapter.java | 11 +- .../home/adapter/loadinggood_adapter.java | 9 + .../home/adapter/newmakegood_adapter.java | 13 +- .../home/fragment/MakeGoodFragment.java | 295 ++++++++------- .../fragment/from/GoodPeiFangActivity.java | 23 +- .../fragment/from/ImageSourceActivity.java | 4 + .../home/fragment/from/JcsjglActivity.java | 1 + .../home/fragment/from/LogActivity.java | 13 + .../home/fragment/from/OrderListActivity.java | 14 +- .../fragment/from/PlcControlActivity.java | 1 + .../home/fragment/from/RealTimeActivity.java | 10 +- .../from/SalesStatisticsActivity.java | 10 + .../home/fragment/from/SilosNewActivity.java | 10 +- .../from/SystemParameterActivity.java | 11 + .../from/fragment/Jcsjgl_sxgl_fragment.java | 355 ++++++++++-------- .../from/fragment/Jcsjgl_wl_fragment.java | 135 ++++--- .../home/fragment/mode/add_good_control.java | 14 + .../home/fragment/mode/add_pf_control.java | 71 +++- .../fragment/mode/add_pf_home_control.java | 85 +++-- .../mode/add_yijian_controlextends.java | 12 + .../home/fragment/mode/silos_jiaoyan.java | 17 +- .../welcome/activity/WelcomeActivity.java | 3 + .../main/res/layout/activity_silos_new.xml | 2 + .../res/layout/item/layout/newmakegood.xml | 2 +- 32 files changed, 785 insertions(+), 440 deletions(-) diff --git a/.idea/deploymentTargetSelector.xml b/.idea/deploymentTargetSelector.xml index b268ef36..2e0aa93f 100644 --- a/.idea/deploymentTargetSelector.xml +++ b/.idea/deploymentTargetSelector.xml @@ -4,6 +4,14 @@ diff --git a/app/build.gradle b/app/build.gradle index a232d07f..b1926780 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -133,7 +133,7 @@ dependencies { //leak 内存泄漏检测 - debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.0-alpha-3' +// debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.0-alpha-3' //Modbus implementation 'com.github.licheedev:Modbus4Android:2.0.2' diff --git a/app/src/main/java/com/bonait/bnframework/HBL/API/APIHelper.java b/app/src/main/java/com/bonait/bnframework/HBL/API/APIHelper.java index 4ba0180c..7af51227 100644 --- a/app/src/main/java/com/bonait/bnframework/HBL/API/APIHelper.java +++ b/app/src/main/java/com/bonait/bnframework/HBL/API/APIHelper.java @@ -588,6 +588,42 @@ public class APIHelper { }).start(); } + public static OperateResultT GetT(String path, Map params, TypeReference> defaultValue) { + try { + String ResponseAdd = BuildUrlWithParams(path,params);//请求地址和参数 + URL url = new URL(ResponseAdd); + HttpURLConnection Connection = (HttpURLConnection) url.openConnection(); + Connection.setRequestMethod("GET"); + Connection.setConnectTimeout(3000); + Connection.setReadTimeout(3000); + int responseCode = Connection.getResponseCode(); + if (responseCode == Connection.HTTP_OK) { + InputStream inputStream = Connection.getInputStream(); + ByteArrayOutputStream arrayOutputStream = new ByteArrayOutputStream(); + byte[] bytes = new byte[1024]; + int length = 0; + while ((length = inputStream.read(bytes)) != -1) { + arrayOutputStream.write(bytes, 0, length); + arrayOutputStream.flush();//强制释放缓冲区 + } + String s = arrayOutputStream.toString(); + APIResultT res = JSON.parseObject(s,defaultValue); + if(res!=null && res.succeeded.toUpperCase().equals("TRUE")){ + return OperateResultT.CreateSuccess(res.data); + }else { + return OperateResultT.CreateFailed("内容解析失败"); + } + } else { + MessageLog.ShowError("get 请求失败"); + return OperateResultT.CreateFailed("get 请求失败"); + } + } catch (Exception e) { + MessageLog.ShowError(e); + return OperateResultT.CreateFailed("POST 请求异常"); + } + } + + /** * 请求参数拼接 * @param Url 请求地址 diff --git a/app/src/main/java/com/bonait/bnframework/HttpModel/APIService.java b/app/src/main/java/com/bonait/bnframework/HttpModel/APIService.java index 1c2ff3e5..ed5fa8d5 100644 --- a/app/src/main/java/com/bonait/bnframework/HttpModel/APIService.java +++ b/app/src/main/java/com/bonait/bnframework/HttpModel/APIService.java @@ -12,7 +12,10 @@ import com.bonait.bnframework.common.db.mode.BPA_GOODSTYPE; import com.bonait.bnframework.common.db.mode.BPA_MATERIAL; import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; import java.util.Optional; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicReference; @@ -33,16 +36,20 @@ public class APIService { } private static void GetGoodsInfo(){ - String url = "http://192.168.1.50:5007/api/goods/Getdevicegoods?deviceId=1a2a1d72-752f-44cf-87f8-ec9fe4ea15b8"; - APIHelper.PostT(url,null,null,new TypeReference>>(){}).OnSource(s->{ + String url = "https://cfv.black-pa.com/api/goods/getbyidgoods?deviceId=03192d70-bd37-40b2-8c03-2721c236e8f2"; +// String url = "http://192.168.1.50:5007/api/goods/Getdevicegoods?deviceId=1a2a1d72-752f-44cf-87f8-ec9fe4ea15b8"; + + APIHelper.GetT(url,null,new TypeReference>>(){}).OnSource(s->{ deviceGoodInfo=s.Content; UpdateLocalGoodsInfo(); }); } private static void GetMaterialInfo(){ - String url = "http://192.168.1.50:5006/api/ExternalPlatform/Material/GetMaterialPageList"; - String key ="962a5892-0f7f-47b4-a1ec-925bd7914a6d"; + String url = "https://cfv.black-pa.com/api/ExternalPlatform/Material/GetMaterialPageList"; +// String url = "http://192.168.1.50:5006/api/ExternalPlatform/Material/GetMaterialPageList"; + String key ="2c39bc05-25c2-46c4-b5c6-dba349058492"; +// String key ="962a5892-0f7f-47b4-a1ec-925bd7914a6d"; APIHelper.PostT(url,new MaterialRequestPar(1,100),key,new TypeReference>(){}).OnSource(s->{ materialModels=s.Content; UpdateLocalMaterial(); diff --git a/app/src/main/java/com/bonait/bnframework/MainApplication.java b/app/src/main/java/com/bonait/bnframework/MainApplication.java index a362081a..96385354 100644 --- a/app/src/main/java/com/bonait/bnframework/MainApplication.java +++ b/app/src/main/java/com/bonait/bnframework/MainApplication.java @@ -12,6 +12,7 @@ import android.util.Log; import androidx.core.content.ContextCompat; +import com.apkfuns.logutils.LogUtils; import com.bonait.bnframework.business.ConfigData; import com.bonait.bnframework.common.constant.ConfigName; import com.bonait.bnframework.common.constant.DataBus; @@ -29,6 +30,7 @@ import com.bonait.bnframework.common.db.mode.BPA_SILOSANDMATERIAL; import com.bonait.bnframework.common.db.mode.BPA_USER; import com.bonait.bnframework.common.db.res.AlertLogEnum; import com.bonait.bnframework.common.db.res.UserLogEnum; +import com.bonait.bnframework.common.glide.GlideApp; import com.bonait.bnframework.common.helper.CrashHandler; import com.bonait.bnframework.common.helper.I.IMessageLogNotify; import com.bonait.bnframework.common.helper.MessageLog; @@ -92,6 +94,13 @@ public class MainApplication extends Application { } } + @Override + public void onLowMemory() { + LogUtils.d("MainApplication onLowMemory"); + super.onLowMemory(); + GlideApp.get(this).clearMemory(); + } + /** * 腾讯bugly 异常检测上班 */ @@ -136,4 +145,10 @@ public class MainApplication extends Application { } return null; } + + @Override + protected void attachBaseContext(Context base) { + super.attachBaseContext(base); +// MultiDex.install(this); + } } diff --git a/app/src/main/java/com/bonait/bnframework/common/db/QueryDB.java b/app/src/main/java/com/bonait/bnframework/common/db/QueryDB.java index 472d8d72..a1d22970 100644 --- a/app/src/main/java/com/bonait/bnframework/common/db/QueryDB.java +++ b/app/src/main/java/com/bonait/bnframework/common/db/QueryDB.java @@ -3583,10 +3583,10 @@ public class QueryDB { data = new BPA_SILOS_CALIBRATE(); //私有 ((BPA_SILOS_CALIBRATE) data).name = cursor.getString((int) cursor.getColumnIndex("name")); - ((BPA_SILOS_CALIBRATE) data).inputWightMin = cursor.getInt((int) cursor.getColumnIndex("inputWightMin")); - ((BPA_SILOS_CALIBRATE) data).inputWightMax = cursor.getInt((int) cursor.getColumnIndex("inputWightMax")); - ((BPA_SILOS_CALIBRATE) data).outputTimeMin = cursor.getInt((int) cursor.getColumnIndex("outputTimeMin")); - ((BPA_SILOS_CALIBRATE) data).outputTimeMax = cursor.getInt((int) cursor.getColumnIndex("outputTimeMax")); + ((BPA_SILOS_CALIBRATE) data).inputWightMin = cursor.getFloat((int) cursor.getColumnIndex("inputWightMin")); + ((BPA_SILOS_CALIBRATE) data).inputWightMax = cursor.getFloat((int) cursor.getColumnIndex("inputWightMax")); + ((BPA_SILOS_CALIBRATE) data).outputTimeMin = cursor.getFloat((int) cursor.getColumnIndex("outputTimeMin")); + ((BPA_SILOS_CALIBRATE) data).outputTimeMax = cursor.getFloat((int) cursor.getColumnIndex("outputTimeMax")); ((BPA_SILOS_CALIBRATE) data).num = cursor.getInt((int) cursor.getColumnIndex("num")); break; } diff --git a/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_GOODS.java b/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_GOODS.java index 5958de95..1a3ae230 100644 --- a/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_GOODS.java +++ b/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_GOODS.java @@ -25,4 +25,20 @@ public class BPA_GOODS extends ModeBase { public String materialids; //外键集合 public String foreignKeyRe;//商品外键id + + @Override + public String toString() { + return "BPA_GOODS{" + + "name='" + name + '\'' + + ", url='" + url + '\'' + + ", sort=" + sort + + ", status=" + status + + ", maketime=" + maketime + + ", issc=" + issc + + ", gyid='" + gyid + '\'' + + ", goodtype='" + goodtype + '\'' + + ", materialids='" + materialids + '\'' + + ", foreignKeyRe='" + foreignKeyRe + '\'' + + '}'; + } } diff --git a/app/src/main/java/com/bonait/bnframework/common/filepicker/adapter/FilePickerShowAdapter.java b/app/src/main/java/com/bonait/bnframework/common/filepicker/adapter/FilePickerShowAdapter.java index 80c83626..b26edb47 100644 --- a/app/src/main/java/com/bonait/bnframework/common/filepicker/adapter/FilePickerShowAdapter.java +++ b/app/src/main/java/com/bonait/bnframework/common/filepicker/adapter/FilePickerShowAdapter.java @@ -32,7 +32,6 @@ import java.util.ArrayList; public class FilePickerShowAdapter extends RecyclerView.Adapter { private final LayoutInflater mLayoutInflater; - private Context mContext; private ArrayList mDataList; private OnDeleteListener mOnDeleteListener; private OnFileItemClickListener mOnItemClickListener; @@ -46,7 +45,6 @@ public class FilePickerShowAdapter extends RecyclerView.Adapter dataList) { - mContext = context; mLayoutInflater = LayoutInflater.from(context); mDataList = dataList; } @@ -67,7 +65,7 @@ public class FilePickerShowAdapter extends RecyclerView.Adapter public List Fdata; public Resources resources; public LinearLayoutManager Manager; + private CallBack callBack; - public GoodLeftAdapter(@LayoutRes int layoutResId, @Nullable List data, Resources _resources, LinearLayoutManager _manager) { + public GoodLeftAdapter(@LayoutRes int layoutResId, @Nullable List data, Resources _resources, LinearLayoutManager _manager,CallBack callBack) { super(layoutResId, data); resources = _resources; Fdata = data; Manager = _manager; + this.callBack =callBack; } @Override @@ -117,6 +119,9 @@ public class GoodLeftAdapter extends BaseQuickAdapter public void onClick(QMUIDialog dialog, int index) { Detele(index_d); dialog.dismiss(); + if(callBack!=null){ + callBack.delete(); + } } }); } @@ -146,4 +151,8 @@ public class GoodLeftAdapter extends BaseQuickAdapter Fdata.get(position).isChoose = true; notifyDataSetChanged(); } + + public interface CallBack{ + void delete(); + } } diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/adapter/loadinggood_adapter.java b/app/src/main/java/com/bonait/bnframework/modules/home/adapter/loadinggood_adapter.java index 6bc8b18e..5eacdb8b 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/adapter/loadinggood_adapter.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/adapter/loadinggood_adapter.java @@ -56,6 +56,15 @@ public class loadinggood_adapter extends RecyclerView.Adapter=60) //12秒执行一次 - { - ArrayList lcModes = DataBus.getInstance().ResGetLc(); - String title=""; - for (lcMode item:lcModes) + while (true && !destroy) { + if(mHandler!=null){ + try { + mHandler.sendEmptyMessage(0); + if(time>=60) //12秒执行一次 { - //lcMode.warningValue >= lcMode.silosmargin - //总量大于0 绑定了物料 告警值设置了 告警大于余量 告警 - if(item.siloszl>0 && !item.materialId.isEmpty() && item.warningValue>0 && item.warningValue >= item.silosmargin) + ArrayList lcModes = DataBus.getInstance().ResGetLc(); + String title=""; + for (lcMode item:lcModes) { - title+="料仓"+item.num+"-"+item.materialName+"|"; + //lcMode.warningValue >= lcMode.silosmargin + //总量大于0 绑定了物料 告警值设置了 告警大于余量 告警 + if(item.siloszl>0 && !item.materialId.isEmpty() && item.warningValue>0 && item.warningValue >= item.silosmargin) + { + title+="料仓"+item.num+"-"+item.materialName+"|"; + } } - } - if(!title.isEmpty()) - { - String finalTitle = title; - activity.runOnUiThread(new Runnable() { - @Override - public void run() { - //0.6 --- 0.9 - CookieHelper.Show(activity, finalTitle +"-余量提示","料仓余量不足,请及时补料!若程序预警错误,请及时手动补充原料后,在料仓界面点击《补充原料》"); - } - }); - } + if(!title.isEmpty()) + { + String finalTitle = title; + activity.runOnUiThread(new Runnable() { + @Override + public void run() { + //0.6 --- 0.9 + CookieHelper.Show(activity, finalTitle +"-余量提示","料仓余量不足,请及时补料!若程序预警错误,请及时手动补充原料后,在料仓界面点击《补充原料》"); + } + }); + } - time=0; + time=0; + } + Thread.sleep(200); + time++; + } catch (Exception ex) { + ToastUtils.error("异常信息:" + ex.getMessage()); } - Thread.sleep(200); - time++; - } catch (Exception ex) { - ToastUtils.error("异常信息:" + ex.getMessage()); } } } @@ -676,106 +695,106 @@ public class MakeGoodFragment extends BaseFragment { ExecuteTheRecipe.OnScanTheCodeInformationT = new IRunT() { @Override public void Run(String msg2) { - - activity.runOnUiThread(new Runnable() { - @Override - public void run() { - String msg = msg2; + if(activity!=null){ + activity.runOnUiThread(new Runnable() { + @Override + public void run() { + String msg = msg2; // if(ConfigName.TEST){ // msg = " |03cb1364-8b85-446a-b00b-d3657de1a19f| | "; // } - if ((msg != null) && (((String) msg).length() > 2) && ((String) msg).contains("|")) { - //拿到扫码数据 - //例如 ORD001|P0003|A001,M002,T001|2 - // OR001|A001|2,22|1 - - String[] res = ((String) msg).split("[|]"); - if (res.length >= 4) { - String orderid = res[0];//ORD001 - String goodid = res[1];//P0003 商品id - String ggid = res[2];//A001,M002,T001 配方ids - - String ggids = "";//规格id集合 - String names = ""; - - if (QueryDB.GetOrderthirdPartyIDIs(orderid)) { - message = "已有订单,重复扫码!"; - mHandler.sendEmptyMessage(1); - return; - } - int num = 1; - try { - num = Integer.parseInt(res[3]); - for (String item : ggid.split("[,]")) { - for (ResGoodProperty k : DataBus.getInstance().bpa_goodproperties) { - if (k.child != null && k.child.size() > 0) { - for (ResGoodProperty chd : k.child) { - if (chd.foreignKeyRe != null && !chd.foreignKeyRe.isEmpty() && chd.foreignKeyRe.equals(item)) { - ggids += chd.id + ","; - names += "/" + chd.name; + if ((msg != null) && (((String) msg).length() > 2) && ((String) msg).contains("|")) { + //拿到扫码数据 + //例如 ORD001|P0003|A001,M002,T001|2 + // OR001|A001|2,22|1 + + String[] res = ((String) msg).split("[|]"); + if (res.length >= 4) { + String orderid = res[0];//ORD001 + String goodid = res[1];//P0003 商品id + String ggid = res[2];//A001,M002,T001 配方ids + + String ggids = "";//规格id集合 + String names = ""; + + if (QueryDB.GetOrderthirdPartyIDIs(orderid)) { + message = "已有订单,重复扫码!"; + mHandler.sendEmptyMessage(1); + return; + } + int num = 1; + try { + num = Integer.parseInt(res[3]); + for (String item : ggid.split("[,]")) { + for (ResGoodProperty k : DataBus.getInstance().bpa_goodproperties) { + if (k.child != null && k.child.size() > 0) { + for (ResGoodProperty chd : k.child) { + if (chd.foreignKeyRe != null && !chd.foreignKeyRe.isEmpty() && chd.foreignKeyRe.equals(item)) { + ggids += chd.id + ","; + names += "/" + chd.name; + } } } - } + } } - } - if (!ggids.isEmpty()) { - ggids = ggids.substring(0, ggids.length() - 1); + if (!ggids.isEmpty()) { + ggids = ggids.substring(0, ggids.length() - 1); + } + } catch (Exception ex) { } - } catch (Exception ex) { - } - BPA_GOODS good = QueryDB.GetGoodsforeignKeyId(goodid); - ConfigName.getInstance(); + BPA_GOODS good = QueryDB.GetGoodsforeignKeyId(goodid); + ConfigName.getInstance(); // if(ConfigName.TEST){ // good = QueryDB.GetGoodsId(goodid); // } - if (good == null) { - message = "没有查询到该商品!"; - mHandler.sendEmptyMessage(1); - } else { - BPA_GOODSRECIPENAME goodsrecipename = QueryDB.GetGoodsRecipeNameDesignId(ggids, good.id); - if (goodsrecipename != null) { - BPA_ORDER order = new BPA_ORDER(); - order.thirdPartyID = orderid; - order.status = 0; - order.deviceID = ConfigName.getInstance().DeviceId; - order.userID = ConfigName.getInstance().user.userID; - QueryDB.AddOrder(order); - - for (int mm = 0; mm < num; mm++) { - BPA_SUBORDER suborder = new BPA_SUBORDER(); - suborder.deviceID = ConfigName.getInstance().DeviceId; - suborder.userID = ConfigName.getInstance().user.userID; - suborder.orderID = order.id; - suborder.goodsID = good.id; - suborder.recipeID = goodsrecipename.id; - suborder.number = 1; - suborder.status = 0; - suborder.exp = names; - QueryDB.AddSubOrder(suborder); - DataBus.getInstance().AddGoodsMake(suborder); - } - message = "加入订单队列成功!"; - mHandler.sendEmptyMessage(2); - } else { - message = "没有查询到该商品配方信息!"; + if (good == null) { + message = "没有查询到该商品!"; mHandler.sendEmptyMessage(1); + } else { + BPA_GOODSRECIPENAME goodsrecipename = QueryDB.GetGoodsRecipeNameDesignId(ggids, good.id); + if (goodsrecipename != null) { + BPA_ORDER order = new BPA_ORDER(); + order.thirdPartyID = orderid; + order.status = 0; + order.deviceID = ConfigName.getInstance().DeviceId; + order.userID = ConfigName.getInstance().user.userID; + QueryDB.AddOrder(order); + + for (int mm = 0; mm < num; mm++) { + BPA_SUBORDER suborder = new BPA_SUBORDER(); + suborder.deviceID = ConfigName.getInstance().DeviceId; + suborder.userID = ConfigName.getInstance().user.userID; + suborder.orderID = order.id; + suborder.goodsID = good.id; + suborder.recipeID = goodsrecipename.id; + suborder.number = 1; + suborder.status = 0; + suborder.exp = names; + QueryDB.AddSubOrder(suborder); + DataBus.getInstance().AddGoodsMake(suborder); + } + message = "加入订单队列成功!"; + mHandler.sendEmptyMessage(2); + } else { + message = "没有查询到该商品配方信息!"; + mHandler.sendEmptyMessage(1); + } } - } + } else { + message = "没有查询到该商品!"; + mHandler.sendEmptyMessage(1); + } } else { - message = "没有查询到该商品!"; + message = "服务器异常,请稍后重试!"; mHandler.sendEmptyMessage(1); } - } else { - message = "服务器异常,请稍后重试!"; - mHandler.sendEmptyMessage(1); } - } - }); - + }); + } } }; @@ -830,10 +849,24 @@ public class MakeGoodFragment extends BaseFragment { public void onDestroy() { super.onDestroy(); Logger.d("第一页销毁"); - + destroy = true; + isResume = false; + myClickListener = null; + Fdata.clear(); + Fdata = null; + datatab_paiduishangping.setAdapter(null); rv_right.setAdapter(null); + if(DataBus.getInstance().loadinggoodAdapter!=null){ + DataBus.getInstance().loadinggoodAdapter.destroy(); + } Glide.get(getContext()).clearMemory(); + ExecuteTheRecipe.OnScanTheCodeInformationT = null; MessageManager.getInstance().unRegisterMessageReceiver(getActivity()); + if(mHandler!=null){ + mHandler.removeCallbacksAndMessages(null); + mHandler = null; + } + activity = null; } /** diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/GoodPeiFangActivity.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/GoodPeiFangActivity.java index 93138ce9..1aa04a23 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/GoodPeiFangActivity.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/GoodPeiFangActivity.java @@ -293,6 +293,8 @@ public class GoodPeiFangActivity extends BaseActivity { */ ArrayList bpa_goodproperties = new ArrayList<>(); public List Fdata = new ArrayList<>(); + private GoodLeftAdapter leftAdapter; + private GoodRightAdapter rightAdapter; /** * 初始化数据 @@ -338,8 +340,15 @@ public class GoodPeiFangActivity extends BaseActivity { } LinearLayoutManager manager = (LinearLayoutManager) rv_right.getLayoutManager(); - GoodLeftAdapter leftAdapter = new GoodLeftAdapter(R.layout.item_left_good, Fdata, getResources(), manager); - GoodRightAdapter rightAdapter = new GoodRightAdapter(R.layout.item_right_lc, Fdata, getResources()); + leftAdapter = new GoodLeftAdapter(R.layout.item_left_good, Fdata, getResources(), manager, new GoodLeftAdapter.CallBack() { + @Override + public void delete() { + if(rightAdapter!=null){ + rightAdapter.notifyDataSetChanged(); + } + } + }); + rightAdapter = new GoodRightAdapter(R.layout.item_right_lc, Fdata, getResources()); rv_left.setAdapter(leftAdapter); rv_right.setAdapter(rightAdapter); @@ -422,10 +431,20 @@ public class GoodPeiFangActivity extends BaseActivity { public void onDestroy() { add_pf.destroy(); add_good.destroy(); + add_pf_home.destroy(); super.onDestroy(); + add_good.mListener = null; + add_pf_home.mListener = null; + add_pf.mListener = null; + goodstypes.clear(); + goodstypes = null; + rv_right.setAdapter(null); + rv_left.setAdapter(null); Glide.get(this).clearMemory(); MessageManager.getInstance().unRegisterMessageReceiver(this); + context = null; + activity = null; } @Override diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/ImageSourceActivity.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/ImageSourceActivity.java index 6c7ad47a..31c0cac2 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/ImageSourceActivity.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/ImageSourceActivity.java @@ -181,6 +181,10 @@ public class ImageSourceActivity extends BaseActivity { @Override public void onDestroy() { super.onDestroy(); + yx_files.clear(); + yx_files = null; + mRecyclerView.setAdapter(null); + rl_yx_file.setAdapter(null); } @Override diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/JcsjglActivity.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/JcsjglActivity.java index d041b49d..de4c2e54 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/JcsjglActivity.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/JcsjglActivity.java @@ -109,6 +109,7 @@ public class JcsjglActivity extends BaseActivity { @Override public void onDestroy() { super.onDestroy(); + viewpager_wl.setAdapter(null); } @Override diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/LogActivity.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/LogActivity.java index a0ac3662..fe4386d5 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/LogActivity.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/LogActivity.java @@ -238,6 +238,19 @@ public class LogActivity extends BaseActivity { @Override public void onDestroy() { super.onDestroy(); + bpa_logs.clear(); + bpa_logs = null; + if(adapter!=null){ + adapter.clear(); + adapter = null; + } + + datatab.setAdapter(null); + rzlx.setAdapter(null); + datatab = null; + lx_map.clear(); + lx_map = null; + context = null; } @Override diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/OrderListActivity.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/OrderListActivity.java index bd25440d..56467545 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/OrderListActivity.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/OrderListActivity.java @@ -95,7 +95,8 @@ public class OrderListActivity extends BaseActivity { Spinner rzlx; Map lx_map = new LinkedHashMap<>(); //endregion - private Context context;private ViewGroup view; + private Context context; + private ViewGroup view; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -234,6 +235,17 @@ public class OrderListActivity extends BaseActivity { @Override public void onDestroy() { super.onDestroy(); + if(adapter!=null){ + adapter.clear(); + adapter = null; + } + + subOrders.clear(); + subOrders = null; + lx_map.clear(); + lx_map = null; + context = null; + } @Override diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/PlcControlActivity.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/PlcControlActivity.java index d6e25259..98d363f2 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/PlcControlActivity.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/PlcControlActivity.java @@ -96,6 +96,7 @@ public class PlcControlActivity extends BaseActivity { @Override public void onDestroy() { super.onDestroy(); + viewpager_wl.setAdapter(null); } @Override diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/RealTimeActivity.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/RealTimeActivity.java index 7394d397..800f231e 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/RealTimeActivity.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/RealTimeActivity.java @@ -42,14 +42,12 @@ public class RealTimeActivity extends BaseActivity { QMUITopBarLayout mTopBar; @BindView(R.id.recycler_view) RecyclerView recycler_view; - private Context context; Activity activity=null; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_realtime); ButterKnife.bind(this); - context=getContext(); activity=this; initTopBar(); initFragment(); @@ -250,6 +248,14 @@ public class RealTimeActivity extends BaseActivity { @Override public void onDestroy() { super.onDestroy(); + if(adapter != null){ + adapter.statusModes.clear(); + adapter.statusModes = null; + adapter.activity = null; + adapter = null; + } + recycler_view.setAdapter(null); + activity = null; } @Override diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/SalesStatisticsActivity.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/SalesStatisticsActivity.java index 1671123d..7f561b18 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/SalesStatisticsActivity.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/SalesStatisticsActivity.java @@ -236,6 +236,16 @@ public class SalesStatisticsActivity extends BaseActivity { @Override public void onDestroy() { super.onDestroy(); + subOrders.clear(); + subOrders = null; + subOrdersStatic.clear(); + subOrdersStatic = null; + if(adapter!=null){ + adapter.clear(); + adapter = null; + } + + context = null; } @Override diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/SilosNewActivity.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/SilosNewActivity.java index e9045b4b..333c3abc 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/SilosNewActivity.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/SilosNewActivity.java @@ -162,7 +162,7 @@ public class SilosNewActivity extends BaseActivity { @Override public void clickListenerNew(View v, int k, Object data) { if (k == 0) { - silos_jz.close(); + silos_jz.destroy(); } } }; @@ -228,8 +228,14 @@ public class SilosNewActivity extends BaseActivity { @Override public void onDestroy() { super.onDestroy(); - silos_jz.close(); MessageManager.getInstance().unRegisterMessageReceiver(this); + silos_jz.destroy(); + add_yijian.destroy(); + add_yijian.mListener = null; + add_silos.mListener = null; + silos_jz.mListener = null; + activity = null; + context = null; } @Override diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/SystemParameterActivity.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/SystemParameterActivity.java index 6f629363..05eb0731 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/SystemParameterActivity.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/SystemParameterActivity.java @@ -213,6 +213,17 @@ public class SystemParameterActivity extends BaseActivity { @Override public void onDestroy() { super.onDestroy(); + environment.setAdapter(null); + versionselection.setAdapter(null); + editTextLists.clear(); + editTextLists = null; + material_map.clear(); + material_map = null; + material_map_vis.clear(); + material_map_vis = null; + bpa_systemsets.clear(); + bpa_systemsets = null; + context= null; } @Override diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/Jcsjgl_sxgl_fragment.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/Jcsjgl_sxgl_fragment.java index a942f3a6..97be49d1 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/Jcsjgl_sxgl_fragment.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/Jcsjgl_sxgl_fragment.java @@ -36,7 +36,7 @@ import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; -public class Jcsjgl_sxgl_fragment extends BaseFragment implements MyClickListener { +public class Jcsjgl_sxgl_fragment extends BaseFragment {// implements MyClickListener @BindView(R.id.datatab_sx) ListView datatab_sx; @@ -126,194 +126,206 @@ public class Jcsjgl_sxgl_fragment extends BaseFragment implements MyClickListene } } - /** - * 点击事件 - * - * @param v - * @param data - */ - @Override - public void clickListener(View v, Object data) { - switch (v.getId()) { - case R.id.name://修改属性名称按钮 - final QMUIDialog.EditTextDialogBuilder builder = new QMUIDialog.EditTextDialogBuilder(context); - builder.setTitle("属性名称") - .setPlaceholder("在此输入属性名称") - .setDefaultText(((BPA_GOODPROPERTY) data).name) - .setInputType(InputType.TYPE_CLASS_TEXT) - .addAction("取消", new QMUIDialogAction.ActionListener() { - @Override - public void onClick(QMUIDialog dialog, int index) { - dialog.dismiss(); - } - }) - .addAction("确定", new QMUIDialogAction.ActionListener() { - @Override - public void onClick(QMUIDialog dialog, int index) { - CharSequence text = builder.getEditText().getText(); - if (text != null && text.length() > 0) { - if (QueryDB.GetGoodsPropertyIs(text.toString())) { - ToastUtils.info("属性名称重复,请重新输入后重试!"); - return; - } - QueryDB.UpdateGoodsPropertyName(((BPA_GOODPROPERTY) data).id, text.toString()); - Initdata_sx(); + private MyClickListener listener = new MyClickListener() { + @Override + public void clickListener(View v, Object data) { + switch (v.getId()) { + case R.id.name://修改属性名称按钮 + final QMUIDialog.EditTextDialogBuilder builder = new QMUIDialog.EditTextDialogBuilder(context); + builder.setTitle("属性名称") + .setPlaceholder("在此输入属性名称") + .setDefaultText(((BPA_GOODPROPERTY) data).name) + .setInputType(InputType.TYPE_CLASS_TEXT) + .addAction("取消", new QMUIDialogAction.ActionListener() { + @Override + public void onClick(QMUIDialog dialog, int index) { dialog.dismiss(); - } else { - //请填入昵称 - ToastUtils.info("属性名称不能为空!"); } - } - }) - .show(); - break; - case R.id.sort: - final QMUIDialog.EditTextDialogBuilder builder1 = new QMUIDialog.EditTextDialogBuilder(context); - builder1.setTitle("排序") - .setPlaceholder("在此输入排序") - .setDefaultText(((BPA_GOODPROPERTY) data).sort+"") - .setInputType(InputType.TYPE_CLASS_NUMBER) - .addAction("取消", new QMUIDialogAction.ActionListener() { - @Override - public void onClick(QMUIDialog dialog, int index) { - dialog.dismiss(); - } - }) - .addAction("确定", new QMUIDialogAction.ActionListener() { - @Override - public void onClick(QMUIDialog dialog, int index) { - CharSequence text = builder1.getEditText().getText(); - if (text != null && text.length() > 0) { - QueryDB.UpdateGoodsPropertySort(((BPA_GOODPROPERTY) data).id, Integer.parseInt(text.toString())); - Initdata_sx(); + }) + .addAction("确定", new QMUIDialogAction.ActionListener() { + @Override + public void onClick(QMUIDialog dialog, int index) { + CharSequence text = builder.getEditText().getText(); + if (text != null && text.length() > 0) { + if (QueryDB.GetGoodsPropertyIs(text.toString())) { + ToastUtils.info("属性名称重复,请重新输入后重试!"); + return; + } + QueryDB.UpdateGoodsPropertyName(((BPA_GOODPROPERTY) data).id, text.toString()); + Initdata_sx(); + dialog.dismiss(); + } else { + //请填入昵称 + ToastUtils.info("属性名称不能为空!"); + } + } + }) + .show(); + break; + case R.id.sort: + final QMUIDialog.EditTextDialogBuilder builder1 = new QMUIDialog.EditTextDialogBuilder(context); + builder1.setTitle("排序") + .setPlaceholder("在此输入排序") + .setDefaultText(((BPA_GOODPROPERTY) data).sort+"") + .setInputType(InputType.TYPE_CLASS_NUMBER) + .addAction("取消", new QMUIDialogAction.ActionListener() { + @Override + public void onClick(QMUIDialog dialog, int index) { dialog.dismiss(); - } else { - //请填入昵称 - ToastUtils.info("排序不能为空!"); } - } - }) - .show(); - break; - case R.id.typeS: - ArrayList keys=new ArrayList(); - String[] items = itemstypes.keySet().toArray(new String[itemstypes.keySet().size()]); + }) + .addAction("确定", new QMUIDialogAction.ActionListener() { + @Override + public void onClick(QMUIDialog dialog, int index) { + CharSequence text = builder1.getEditText().getText(); + if (text != null && text.length() > 0) { + QueryDB.UpdateGoodsPropertySort(((BPA_GOODPROPERTY) data).id, Integer.parseInt(text.toString())); + Initdata_sx(); + dialog.dismiss(); + } else { + //请填入昵称 + ToastUtils.info("排序不能为空!"); + } + } + }) + .show(); + break; + case R.id.typeS: + ArrayList keys=new ArrayList(); + String[] items = itemstypes.keySet().toArray(new String[itemstypes.keySet().size()]); - if(((BPA_GOODPROPERTY) data).GoodsTypeId!=null && !((BPA_GOODPROPERTY) data).GoodsTypeId.isEmpty()) - { - for (int i=0;i ddd=QueryDB.GetGoodsPropertyALL(((BPA_GOODPROPERTY) data).id); - for (BPA_GOODPROPERTY item:ddd) - { - QueryDB.DeleteGoodsProperty(item); + dialog.dismiss(); } - QueryDB.DeleteGoodsProperty((BPA_GOODPROPERTY) data); - Initdata_sx(); - ToastUtils.info("删除成功"); - dialog.dismiss(); - } - }); + }); + builder3.show(); + break; + case R.id.button_item://删除按钮 + String title = "温馨提示!"; + String message = "客官确定要删除属性【"+((BPA_GOODPROPERTY) data).name+"】吗?"; + AlertDialogUtils.showDialog(context, title, message, new QMUIDialogAction.ActionListener() { + @Override + public void onClick(QMUIDialog dialog, int index) { + ArrayList ddd=QueryDB.GetGoodsPropertyALL(((BPA_GOODPROPERTY) data).id); + for (BPA_GOODPROPERTY item:ddd) + { + QueryDB.DeleteGoodsProperty(item); + } + QueryDB.DeleteGoodsProperty((BPA_GOODPROPERTY) data); + Initdata_sx(); + ToastUtils.info("删除成功"); + dialog.dismiss(); + } + }); - break; - case R.id.button_add://增加子属性 - BPA_GOODPROPERTY sx=(BPA_GOODPROPERTY) data; - BPA_GOODPROPERTY bpa_goodproperty = new BPA_GOODPROPERTY(); - bpa_goodproperty.name = "子属性示例"; - bpa_goodproperty.foreignKeyRe = ""; - bpa_goodproperty.parentid = sx.id; - bpa_goodproperty.sort=0; - bpa_goodproperty.deviceID = ConfigName.getInstance().DeviceId; - bpa_goodproperty.userID = ConfigName.getInstance().user.userID; - QueryDB.AddGoodsProperty(bpa_goodproperty); - ToastUtils.info("新增成功"); - Initdata_sx(); - break; + break; + case R.id.button_add://增加子属性 + BPA_GOODPROPERTY sx=(BPA_GOODPROPERTY) data; + BPA_GOODPROPERTY bpa_goodproperty = new BPA_GOODPROPERTY(); + bpa_goodproperty.name = "子属性示例"; + bpa_goodproperty.foreignKeyRe = ""; + bpa_goodproperty.parentid = sx.id; + bpa_goodproperty.sort=0; + bpa_goodproperty.deviceID = ConfigName.getInstance().DeviceId; + bpa_goodproperty.userID = ConfigName.getInstance().user.userID; + QueryDB.AddGoodsProperty(bpa_goodproperty); + ToastUtils.info("新增成功"); + Initdata_sx(); + break; - case R.id.save_text://保存属性 - QueryDB.UpdateGoodsProperty((BPA_GOODPROPERTY) data); - ToastUtils.info("保存成功"); - Initdata_sx(); - break; - case R.id.delete_text://删除 - String title1 = "温馨提示!"; - String message1 = "客官确定要删除属性【"+((BPA_GOODPROPERTY) data).name+"】吗?"; - AlertDialogUtils.showDialog(context, title1, message1, new QMUIDialogAction.ActionListener() { - @Override - public void onClick(QMUIDialog dialog, int index) { - QueryDB.DeleteGoodsProperty((BPA_GOODPROPERTY) data); - Initdata_sx(); - ToastUtils.info("删除成功"); - dialog.dismiss(); - } - }); - break; + case R.id.save_text://保存属性 + QueryDB.UpdateGoodsProperty((BPA_GOODPROPERTY) data); + ToastUtils.info("保存成功"); + Initdata_sx(); + break; + case R.id.delete_text://删除 + String title1 = "温馨提示!"; + String message1 = "客官确定要删除属性【"+((BPA_GOODPROPERTY) data).name+"】吗?"; + AlertDialogUtils.showDialog(context, title1, message1, new QMUIDialogAction.ActionListener() { + @Override + public void onClick(QMUIDialog dialog, int index) { + QueryDB.DeleteGoodsProperty((BPA_GOODPROPERTY) data); + Initdata_sx(); + ToastUtils.info("删除成功"); + dialog.dismiss(); + } + }); + break; + } } - } - @Override - public void clickListenerNew(View v, int k, Object data) { + @Override + public void clickListenerNew(View v, int k, Object data) { - } + } + }; + +// /** +// * 点击事件 +// * +// * @param v +// * @param data +// */ +// @Override +// public void clickListener(View v, Object data) { +// +// } +// +// @Override +// public void clickListenerNew(View v, int k, Object data) { +// +// } //region 数据加载 /** * 初始化数据加载 @@ -322,7 +334,7 @@ public class Jcsjgl_sxgl_fragment extends BaseFragment implements MyClickListene try { bpa_goodproperties = QueryDB.GetGoodsPropertyALL("0"); - sx_adapter adapter = new sx_adapter(context, R.layout.sx_item, bpa_goodproperties, bpa_goodstypes,this); + sx_adapter adapter = new sx_adapter(context, R.layout.sx_item, bpa_goodproperties, bpa_goodstypes,listener); datatab_sx.setAdapter(adapter); } catch (Exception e) { @@ -334,6 +346,15 @@ public class Jcsjgl_sxgl_fragment extends BaseFragment implements MyClickListene public void onDestroy() { super.onDestroy(); Logger.d("我的fragment销毁"); + bpa_goodproperties.clear(); + bpa_goodproperties = null; + bpa_goodstypes.clear(); + bpa_goodstypes = null; + itemstypes.clear(); + itemstypes = null; + listener = null; + datatab_sx.setAdapter(null); + context = null; } /** diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/Jcsjgl_wl_fragment.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/Jcsjgl_wl_fragment.java index 7289709d..7d162ec6 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/Jcsjgl_wl_fragment.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/Jcsjgl_wl_fragment.java @@ -30,6 +30,7 @@ import com.bonait.bnframework.common.db.mode.BPA_MATERIAL; import com.bonait.bnframework.common.db.mode.BPA_SILOSANDMATERIAL; import com.bonait.bnframework.common.db.res.lcMode; import com.bonait.bnframework.common.helper.I.MyClickListener; +import com.bonait.bnframework.common.helper.MY; import com.bonait.bnframework.common.utils.AlertDialogUtils; import com.bonait.bnframework.common.utils.NetworkUtils; import com.bonait.bnframework.common.utils.ToastUtils; @@ -47,7 +48,7 @@ import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; -public class Jcsjgl_wl_fragment extends BaseFragment implements MyClickListener { +public class Jcsjgl_wl_fragment extends BaseFragment {// implements MyClickListener @BindView(R.id.add_wl) Button add_wl; @BindView(R.id.datatab_wl) @@ -175,7 +176,7 @@ public class Jcsjgl_wl_fragment extends BaseFragment implements MyClickListener public void Initdata_wl() { try { bpa_materials = QueryDB.GetMaterialALL(); - wl_adapter adapter = new wl_adapter(context, R.layout.wl_item, bpa_materials, this); + wl_adapter adapter = new wl_adapter(context, R.layout.wl_item, bpa_materials, listener); datatab_wl.setAdapter(adapter); } catch (Exception e) { @@ -190,6 +191,9 @@ public class Jcsjgl_wl_fragment extends BaseFragment implements MyClickListener // DataBus.getInstance().mListener.clickListenerNew(this.getView(), 0, ""); // } Logger.d("我的fragment销毁"); + listener = null; + datatab_wl.setAdapter(null); + context = null; } /** @@ -206,68 +210,79 @@ public class Jcsjgl_wl_fragment extends BaseFragment implements MyClickListener return false; } - /** - * 点击事件 - * - * @param v - * @param data - */ - @Override - public void clickListener(View v, Object data) { - switch (v.getId()) { - case R.id.name://修改物料名称按钮 - case R.id.button_update://修改物料名称按钮 - final QMUIDialog.EditTextDialogBuilder builder = new QMUIDialog.EditTextDialogBuilder(context); - builder.setTitle("物料名称") - .setPlaceholder("在此输入物料名称") - .setDefaultText(((BPA_MATERIAL) data).name) - .setInputType(InputType.TYPE_CLASS_TEXT) - .addAction("取消", new QMUIDialogAction.ActionListener() { - @Override - public void onClick(QMUIDialog dialog, int index) { - dialog.dismiss(); - } - }) - .addAction("确定", new QMUIDialogAction.ActionListener() { - @Override - public void onClick(QMUIDialog dialog, int index) { - CharSequence text = builder.getEditText().getText(); - if (text != null && text.length() > 0) { - if (QueryDB.GetMaterialIs(text.toString())) { - ToastUtils.info("物料名称重复,请重新输入后重试!"); - return; - } - QueryDB.UpdateMaterialName(((BPA_MATERIAL) data).id, text.toString()); - Initdata_wl(); - ToastUtils.info("修改成功"); + private MyClickListener listener = new MyClickListener() { + @Override + public void clickListener(View v, Object data) { + switch (v.getId()) { + case R.id.name://修改物料名称按钮 + case R.id.button_update://修改物料名称按钮 + final QMUIDialog.EditTextDialogBuilder builder = new QMUIDialog.EditTextDialogBuilder(context); + builder.setTitle("物料名称") + .setPlaceholder("在此输入物料名称") + .setDefaultText(((BPA_MATERIAL) data).name) + .setInputType(InputType.TYPE_CLASS_TEXT) + .addAction("取消", new QMUIDialogAction.ActionListener() { + @Override + public void onClick(QMUIDialog dialog, int index) { dialog.dismiss(); - } else { - //请填入昵称 - ToastUtils.info("物料名称不能为空!"); } - } - }) - .show(); - break; - case R.id.button_item://删除按钮 - String title = "温馨提示!"; - String message = "客官确定要删除物料【"+((BPA_MATERIAL) data).name+"】吗?"; - AlertDialogUtils.showDialog(context, title, message, new QMUIDialogAction.ActionListener() { - @Override - public void onClick(QMUIDialog dialog, int index) { - QueryDB.DeleteMaterial((BPA_MATERIAL) data); - Initdata_wl(); - ToastUtils.info("删除成功"); - dialog.dismiss(); - } - }); - break; + }) + .addAction("确定", new QMUIDialogAction.ActionListener() { + @Override + public void onClick(QMUIDialog dialog, int index) { + CharSequence text = builder.getEditText().getText(); + if (text != null && text.length() > 0) { + if (QueryDB.GetMaterialIs(text.toString())) { + ToastUtils.info("物料名称重复,请重新输入后重试!"); + return; + } + QueryDB.UpdateMaterialName(((BPA_MATERIAL) data).id, text.toString()); + Initdata_wl(); + ToastUtils.info("修改成功"); + dialog.dismiss(); + } else { + //请填入昵称 + ToastUtils.info("物料名称不能为空!"); + } + } + }) + .show(); + break; + case R.id.button_item://删除按钮 + String title = "温馨提示!"; + String message = "客官确定要删除物料【"+((BPA_MATERIAL) data).name+"】吗?"; + AlertDialogUtils.showDialog(context, title, message, new QMUIDialogAction.ActionListener() { + @Override + public void onClick(QMUIDialog dialog, int index) { + QueryDB.DeleteMaterial((BPA_MATERIAL) data); + Initdata_wl(); + ToastUtils.info("删除成功"); + dialog.dismiss(); + } + }); + break; + } } - } - @Override - public void clickListenerNew(View v, int k, Object data) { + @Override + public void clickListenerNew(View v, int k, Object data) { - } + } + }; +// /** +// * 点击事件 +// * +// * @param v +// * @param data +// */ +// @Override +// public void clickListener(View v, Object data) { +// +// } +// +// @Override +// public void clickListenerNew(View v, int k, Object data) { +// +// } } \ No newline at end of file diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_good_control.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_good_control.java index 391f1fe9..1cbaeda1 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_good_control.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_good_control.java @@ -231,6 +231,20 @@ public class add_good_control extends LinearLayout { public void destroy(){ MessageManager.getInstance().unRegisterMessageReceiver(activity_ma); + Data = null; + mListener = null; + Types.clear(); + Types = null; + resMaterilas.clear(); + resMaterilas = null; + map_fl.clear(); + map_fl = null; + yesStr = null; + url = null; + if(recycler_view_wl!=null){ + recycler_view_wl.setAdapter(null); + } + activity_ma = null; } public String ids=""; diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_pf_control.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_pf_control.java index dd9a92bb..60605f3d 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_pf_control.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_pf_control.java @@ -47,7 +47,7 @@ import java.util.ArrayList; import butterknife.BindView; import butterknife.ButterKnife; -public class add_pf_control extends LinearLayout implements MyClickListener { +public class add_pf_control extends LinearLayout {// implements MyClickListener @BindView(R.id.peifang_queren) @@ -202,7 +202,7 @@ public class add_pf_control extends LinearLayout implements MyClickListener { { DataBus.getInstance().Recipe=new ArrayList<>(); } - adapter4= new xxpf_adapter(getContext(), R.layout.xxpf_item, DataBus.getInstance().Recipe,this); + adapter4= new xxpf_adapter(getContext(), R.layout.xxpf_item, DataBus.getInstance().Recipe,listener); datatab_pf.setAdapter(adapter4); } @@ -322,6 +322,25 @@ public class add_pf_control extends LinearLayout implements MyClickListener { if (activity != null) { MessageManager.getInstance().unRegisterMessageReceiver(activity); } + listener = null; + resMaterilas.clear(); + bpa_goodproperties.clear(); + resMaterilas = null; + bpa_goodproperties = null; + if(adapter4!=null){ + adapter4.clear(); + adapter4 = null; + } + + mListener = null; + if(datatab_sx!=null){ + datatab_sx.setAdapter(null); + datatab_pf.setAdapter(null); + } + + acontext = null; + pfname = null; + ggids = null; } /** @@ -453,27 +472,39 @@ public class add_pf_control extends LinearLayout implements MyClickListener { return true; } + private MyClickListener listener = new MyClickListener() { + @Override + public void clickListener(View v, Object data) { + switch (v.getId()) { + case R.id.name://点击 修改 - /** - * 点击事件 - * - * @param v - * @param data - */ - @Override - public void clickListener(View v, Object data) { - switch (v.getId()) { - case R.id.name://点击 修改 - - break; - case R.id.button_item://删除按钮 + break; + case R.id.button_item://删除按钮 - break; + break; + } } - } - @Override - public void clickListenerNew(View v, int k, Object data) { + @Override + public void clickListenerNew(View v, int k, Object data) { - } + } + }; + + +// /** +// * 点击事件 +// * +// * @param v +// * @param data +// */ +// @Override +// public void clickListener(View v, Object data) { +// +// } +// +// @Override +// public void clickListenerNew(View v, int k, Object data) { +// +// } } diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_pf_home_control.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_pf_home_control.java index 7142875f..572c3dca 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_pf_home_control.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_pf_home_control.java @@ -32,7 +32,7 @@ import java.util.ArrayList; import butterknife.BindView; import butterknife.ButterKnife; -public class add_pf_home_control extends LinearLayout implements MyClickListener { +public class add_pf_home_control extends LinearLayout {//implements MyClickListener @BindView(R.id.title) TextView title; @@ -120,46 +120,65 @@ public class add_pf_home_control extends LinearLayout implements MyClickListene { //根据商品查询配方 ArrayList goodsrecipenames=QueryDB.GetGoodsRecipeNameGoodId(good.id); - goodpf_apapter adapter = new goodpf_apapter(getContext(), R.layout.wl_item, goodsrecipenames, this); + goodpf_apapter adapter = new goodpf_apapter(getContext(), R.layout.wl_item, goodsrecipenames, listener); datatab_pf.setAdapter(adapter); } } + private MyClickListener listener = new MyClickListener() { + @Override + public void clickListener(View v, Object data) { + switch (v.getId()) { + case R.id.button_update://点击 修改 + SelectData =(BPA_GOODSRECIPENAME)data; + if (mListener != null) { + mListener.clickListenerNew(v,2,good); + } + break; + case R.id.button_item://删除按钮 + + ArrayList re= QueryDB.GetGoodsSreciperecipeList(((BPA_GOODSRECIPENAME) data).id); + for(ResGoodsRecipe item:re) + { + QueryDB.DeleteGoodsSrecipe(item); + } + QueryDB.DeleteGoodsRecipeName((BPA_GOODSRECIPENAME) data); + Initdata_pf(); + ToastUtils.info("删除成功"); + break; + } + } + @Override + public void clickListenerNew(View v, int k, Object data) { - public BPA_GOODSRECIPENAME SelectData; - /** - * 点击事件 - * - * @param v - * @param data - */ - @Override - public void clickListener(View v, Object data) { - switch (v.getId()) { - case R.id.button_update://点击 修改 - SelectData =(BPA_GOODSRECIPENAME)data; - if (mListener != null) { - mListener.clickListenerNew(v,2,good); - } - break; - case R.id.button_item://删除按钮 - - ArrayList re= QueryDB.GetGoodsSreciperecipeList(((BPA_GOODSRECIPENAME) data).id); - for(ResGoodsRecipe item:re) - { - QueryDB.DeleteGoodsSrecipe(item); - } - QueryDB.DeleteGoodsRecipeName((BPA_GOODSRECIPENAME) data); - Initdata_pf(); - ToastUtils.info("删除成功"); - break; } - } - - @Override - public void clickListenerNew(View v, int k, Object data) { + }; + public BPA_GOODSRECIPENAME SelectData; +// /** +// * 点击事件 +// * +// * @param v +// * @param data +// */ +// @Override +// public void clickListener(View v, Object data) { +// +// } +// +// @Override +// public void clickListenerNew(View v, int k, Object data) { +// +// } + + public void destroy(){ + datatab_pf.setAdapter(null); + datatab_pf = null; + good = null; + SelectData = null; + mListener = null; + listener = null; } } diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_yijian_controlextends.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_yijian_controlextends.java index 565c05de..8cd19922 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_yijian_controlextends.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_yijian_controlextends.java @@ -393,4 +393,16 @@ public class add_yijian_controlextends extends LinearLayout { } //endregion + public void destroy(){ + if(mHandler!=null){ + mHandler.removeCallbacksAndMessages(null); + mHandler = null; + } + siloslist.clear(); + siloslist = null; + mListener = null; + map_fl.clear(); + map_fl = null; + editsp_fl = null; + } } \ No newline at end of file diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/silos_jiaoyan.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/silos_jiaoyan.java index 7885cb2c..ba396bf2 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/silos_jiaoyan.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/silos_jiaoyan.java @@ -16,6 +16,7 @@ import android.widget.TextView; import androidx.annotation.Nullable; import androidx.fragment.app.FragmentManager; +import com.apkfuns.logutils.LogUtils; import com.bonait.bnframework.HBL.Dialog.AlertDialogButton; import com.bonait.bnframework.HBL.Dialog.DialogManager; import com.bonait.bnframework.HBL.Dialog.WaitDialog; @@ -141,8 +142,9 @@ public class silos_jiaoyan extends LinearLayout { BPA_SILOS_CALIBRATE res = QueryDB.GetSilosCalibrateByNum(lcMode.num); if(res!=null){ - min_time.setText(String.valueOf(res.outputTimeMin)); - max_time.setText(String.valueOf(res.outputTimeMax)); + LogUtils.d(" BPA_SILOS_CALIBRATE res.outputTimeMin="+res.toString()); + min_time.setText(res.outputTimeMin+""); + max_time.setText(res.outputTimeMax+""); min_weight.setText(res.inputWightMin+""); max_weight.setText(res.inputWightMax+""); }else{ @@ -241,7 +243,14 @@ public class silos_jiaoyan extends LinearLayout { private TimerTask timerTask; public void show(){ - close(); + if(timer!=null){ + timer.cancel(); + timer = null; + } + if(timerTask!=null){ + timerTask.cancel(); + timerTask = null; + } setVisibility(VISIBLE); timer = new Timer(); timerTask = new TimerTask() { @@ -256,7 +265,7 @@ public class silos_jiaoyan extends LinearLayout { timer.schedule(timerTask,500,500); } - public void close(){ + public void destroy(){ setVisibility(GONE); if(mHandler!=null){ mHandler.removeCallbacksAndMessages(null); diff --git a/app/src/main/java/com/bonait/bnframework/modules/welcome/activity/WelcomeActivity.java b/app/src/main/java/com/bonait/bnframework/modules/welcome/activity/WelcomeActivity.java index 943e23f3..249a3162 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/welcome/activity/WelcomeActivity.java +++ b/app/src/main/java/com/bonait/bnframework/modules/welcome/activity/WelcomeActivity.java @@ -16,6 +16,7 @@ import com.bonait.bnframework.business.MainInit; import com.bonait.bnframework.common.base.BaseActivity; import com.bonait.bnframework.common.constant.ConfigName; import com.bonait.bnframework.common.constant.Constants; +import com.bonait.bnframework.common.utils.DisplayManager; import com.bonait.bnframework.common.utils.ScreenUtils; import com.bonait.bnframework.manager.ActivityLifecycleManager; import com.lzy.okgo.OkGo; @@ -40,6 +41,8 @@ public class WelcomeActivity extends BaseActivity { super.onCreate(savedInstanceState); setContentView(R.layout.activity_welcome); initWelcome(); + DisplayManager.setReferenceMaxWidthHeight(800, 1208); + DisplayManager.updateDisplayInfo(this); } private void initWelcome() { diff --git a/app/src/main/res/layout/activity_silos_new.xml b/app/src/main/res/layout/activity_silos_new.xml index 06645ea6..b6e7746a 100644 --- a/app/src/main/res/layout/activity_silos_new.xml +++ b/app/src/main/res/layout/activity_silos_new.xml @@ -118,6 +118,7 @@ android:layout_height="100dp" app:imagesrc="@mipmap/silos1" android:tag="一键满管" + android:visibility="gone" />