@@ -28,6 +28,9 @@ | |||||
android:theme="@style/AppTheme" | android:theme="@style/AppTheme" | ||||
tools:ignore="GoogleAppIndexingWarning" | tools:ignore="GoogleAppIndexingWarning" | ||||
tools:node="merge"> | tools:node="merge"> | ||||
<activity | |||||
android:name=".modules.home.fragment.from.ImageChooseActivity" | |||||
android:exported="false" /> | |||||
<activity | <activity | ||||
android:name=".modules.home.fragment.from.DiyUpdateActivity" | android:name=".modules.home.fragment.from.DiyUpdateActivity" | ||||
android:exported="false" /> | android:exported="false" /> | ||||
@@ -1,5 +1,6 @@ | |||||
package com.bonait.bnframework; | package com.bonait.bnframework; | ||||
import android.annotation.SuppressLint; | import android.annotation.SuppressLint; | ||||
import android.app.Activity; | import android.app.Activity; | ||||
import android.app.Application; | import android.app.Application; | ||||
@@ -110,6 +111,7 @@ public class MainApplication extends Application { | |||||
//初始化DB数据 | //初始化DB数据 | ||||
InitDBdata(); | InitDBdata(); | ||||
DataBus.getInstance().GetLc();//获取料仓数据 | DataBus.getInstance().GetLc();//获取料仓数据 | ||||
} | } | ||||
//========================================================================// | //========================================================================// | ||||
@@ -204,11 +204,13 @@ public class ConfigData { | |||||
BitmapFactory.Options options = new BitmapFactory.Options(); | BitmapFactory.Options options = new BitmapFactory.Options(); | ||||
options.inSampleSize=2;//宽高压缩为原来的1/2 | options.inSampleSize=2;//宽高压缩为原来的1/2 | ||||
options.inPreferredConfig=Bitmap.Config.ARGB_4444; | options.inPreferredConfig=Bitmap.Config.ARGB_4444; | ||||
Bitmap bitmap0= BitmapFactory.decodeResource(context.getResources(), R.mipmap.loading3,options); | |||||
Bitmap bitmap1= BitmapFactory.decodeResource(context.getResources(), R.mipmap.image1,options); | Bitmap bitmap1= BitmapFactory.decodeResource(context.getResources(), R.mipmap.image1,options); | ||||
Bitmap bitmap2= BitmapFactory.decodeResource(context.getResources(), R.mipmap.image2,options); | Bitmap bitmap2= BitmapFactory.decodeResource(context.getResources(), R.mipmap.image2,options); | ||||
Bitmap bitmap3= BitmapFactory.decodeResource(context.getResources(), R.mipmap.image3,options); | Bitmap bitmap3= BitmapFactory.decodeResource(context.getResources(), R.mipmap.image3,options); | ||||
Bitmap bitmap4= BitmapFactory.decodeResource(context.getResources(), R.mipmap.image4,options); | Bitmap bitmap4= BitmapFactory.decodeResource(context.getResources(), R.mipmap.image4,options); | ||||
LocalCacheUtils localCacheUtils=new LocalCacheUtils(); | LocalCacheUtils localCacheUtils=new LocalCacheUtils(); | ||||
localCacheUtils.setBitmapToLocal("image0.png",bitmap0); | |||||
localCacheUtils.setBitmapToLocal("image1.png",bitmap1); | localCacheUtils.setBitmapToLocal("image1.png",bitmap1); | ||||
localCacheUtils.setBitmapToLocal("image2.png",bitmap2); | localCacheUtils.setBitmapToLocal("image2.png",bitmap2); | ||||
localCacheUtils.setBitmapToLocal("image3.png",bitmap3); | localCacheUtils.setBitmapToLocal("image3.png",bitmap3); | ||||
@@ -5,6 +5,7 @@ import android.graphics.BitmapFactory; | |||||
import android.os.Environment; | import android.os.Environment; | ||||
import com.bonait.bnframework.common.constant.ConfigName; | import com.bonait.bnframework.common.constant.ConfigName; | ||||
import com.bonait.bnframework.common.helper.AES; | |||||
import java.io.File; | import java.io.File; | ||||
import java.io.FileInputStream; | import java.io.FileInputStream; | ||||
@@ -24,11 +25,13 @@ public class LocalCacheUtils { | |||||
public Bitmap getBitmapFromLocal(String url){ | public Bitmap getBitmapFromLocal(String url){ | ||||
String fileName = null;//把图片的url当做文件名,并进行MD5加密 | String fileName = null;//把图片的url当做文件名,并进行MD5加密 | ||||
try { | try { | ||||
fileName = MD5Encoder.encode(url); | |||||
fileName = MD5Encoder.encode(url);//AES.Encrypt(url);//MD5Encoder.encode(url); | |||||
File file=new File(CACHE_PATH,fileName); | File file=new File(CACHE_PATH,fileName); | ||||
Bitmap bitmap = BitmapFactory.decodeStream(new FileInputStream(file)); | |||||
Bitmap bitmap=null; | |||||
if(file.exists())// | |||||
{ | |||||
bitmap = BitmapFactory.decodeStream(new FileInputStream(file)); | |||||
} | |||||
return bitmap; | return bitmap; | ||||
} catch (Exception e) { | } catch (Exception e) { | ||||
e.printStackTrace(); | e.printStackTrace(); | ||||
@@ -44,7 +47,8 @@ public class LocalCacheUtils { | |||||
*/ | */ | ||||
public void setBitmapToLocal(String url,Bitmap bitmap){ | public void setBitmapToLocal(String url,Bitmap bitmap){ | ||||
try { | try { | ||||
String fileName = MD5Encoder.encode(url);//把图片的url当做文件名,并进行MD5加密 | |||||
String fileName = MD5Encoder.encode(url);;//AES.Encrypt(url);//;MD5Encoder.encode(url);//把图片的url当做文件名,并进行MD5加密 | |||||
File file=new File(CACHE_PATH,fileName); | File file=new File(CACHE_PATH,fileName); | ||||
//通过得到文件的父文件,判断父文件是否存在 | //通过得到文件的父文件,判断父文件是否存在 | ||||
@@ -3,21 +3,37 @@ package com.bonait.bnframework.common.image.utils; | |||||
import java.security.MessageDigest; | import java.security.MessageDigest; | ||||
import java.security.NoSuchAlgorithmException; | import java.security.NoSuchAlgorithmException; | ||||
/** | |||||
* Md5加密 | |||||
* 已经加密的就不在加密 | |||||
*/ | |||||
public class MD5Encoder { | public class MD5Encoder { | ||||
/** | |||||
* 加密 | |||||
* @param pwd | |||||
* @return | |||||
*/ | |||||
public static String encode(String pwd) { | public static String encode(String pwd) { | ||||
try { | try { | ||||
MessageDigest digest = MessageDigest.getInstance("MD5"); | |||||
byte[] bytes = digest.digest(pwd.getBytes()); | |||||
StringBuffer sb = new StringBuffer(); | |||||
for(int i = 0;i<bytes.length;i++){ | |||||
String s = Integer.toHexString(0xff&bytes[i]); | |||||
if(s.length()==1){ | |||||
sb.append("0"+s); | |||||
}else{ | |||||
sb.append(s); | |||||
if(pwd.contains("heiboluo|")) | |||||
{ | |||||
return pwd; | |||||
} | |||||
else | |||||
{ | |||||
MessageDigest digest = MessageDigest.getInstance("MD5"); | |||||
byte[] bytes = digest.digest(pwd.getBytes()); | |||||
StringBuffer sb = new StringBuffer(); | |||||
for(int i = 0;i<bytes.length;i++){ | |||||
String s = Integer.toHexString(0xff&bytes[i]); | |||||
if(s.length()==1){ | |||||
sb.append("0"+s); | |||||
}else{ | |||||
sb.append(s); | |||||
} | |||||
} | } | ||||
return "heiboluo|"+sb.toString(); | |||||
} | } | ||||
return sb.toString(); | |||||
} catch (NoSuchAlgorithmException e) { | } catch (NoSuchAlgorithmException e) { | ||||
return "buhuifasheng"; | return "buhuifasheng"; | ||||
} | } | ||||
@@ -0,0 +1,131 @@ | |||||
package com.bonait.bnframework.modules.home.adapter; | |||||
import android.app.Activity; | |||||
import android.content.Context; | |||||
import android.content.ContextWrapper; | |||||
import android.view.LayoutInflater; | |||||
import android.view.View; | |||||
import android.view.ViewGroup; | |||||
import android.widget.ImageView; | |||||
import android.widget.RelativeLayout; | |||||
import androidx.annotation.NonNull; | |||||
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.helper.I.MyClickListener; | |||||
import com.bonait.bnframework.common.image.MyBitmapUtils; | |||||
import com.bonait.bnframework.common.utils.AlertDialogUtils; | |||||
import com.bonait.bnframework.modules.home.fragment.mode.image_sp; | |||||
import com.qmuiteam.qmui.widget.dialog.QMUIDialog; | |||||
import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction; | |||||
import com.qmuiteam.qmui.widget.textview.QMUILinkTextView; | |||||
import java.util.ArrayList; | |||||
import java.util.List; | |||||
public class image_sp_adapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { | |||||
private final LayoutInflater mLayoutInflater; | |||||
private Context context; | |||||
List<image_sp> goods = new ArrayList<>(); | |||||
/** | |||||
* 点击事件 | |||||
*/ | |||||
public MyClickListener mListener=null; | |||||
public image_sp_adapter(Context context,List<image_sp> data) { | |||||
this.context = context; | |||||
mLayoutInflater = LayoutInflater.from(context); | |||||
goods=data; | |||||
} | |||||
@NonNull | |||||
@Override | |||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { | |||||
View inflate = mLayoutInflater.inflate(R.layout.item_image_sp, parent, false); | |||||
return new MyLCViewHolder1(inflate); | |||||
} | |||||
@Override | |||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { | |||||
try { | |||||
if (holder instanceof MyLCViewHolder1) { | |||||
MyLCViewHolder1 myViewHolder = (MyLCViewHolder1) holder; | |||||
new MyBitmapUtils().disPlay(myViewHolder.img,goods.get(position).url); | |||||
myViewHolder.img.setOnClickListener(new View.OnClickListener() { | |||||
@Override | |||||
public void onClick(View view) { | |||||
//按钮点击 | |||||
String title = "选择菜品操作提示!"; | |||||
String message = "请问客官确定要选择该图片吗?"; | |||||
AlertDialogUtils.showDialog(context, title, message, new QMUIDialogAction.ActionListener() { | |||||
@Override | |||||
public void onClick(QMUIDialog dialog, int index) { | |||||
if(mListener!=null) | |||||
{ | |||||
mListener.clickListener(view,goods.get(position)); | |||||
} | |||||
dialog.dismiss(); | |||||
} | |||||
}); | |||||
} | |||||
}); | |||||
} | |||||
} catch (Exception e) { | |||||
e.printStackTrace(); | |||||
} | |||||
} | |||||
private Activity findActivity(@NonNull Context context) { | |||||
if (context instanceof Activity) { | |||||
return (Activity) context; | |||||
} else if (context instanceof ContextWrapper) { | |||||
return findActivity(((ContextWrapper) context).getBaseContext()); | |||||
} else { | |||||
return null; | |||||
} | |||||
} | |||||
/** | |||||
* 刷新 | |||||
* | |||||
* @param | |||||
*/ | |||||
public void refresh() { | |||||
Activity activity = findActivity(context); | |||||
if (activity != null) { | |||||
activity.runOnUiThread(new Runnable() { | |||||
@Override | |||||
public void run() { | |||||
try { | |||||
notifyDataSetChanged(); | |||||
} catch (Exception e) { | |||||
} | |||||
} | |||||
}); | |||||
} | |||||
} | |||||
@Override | |||||
public int getItemCount() { | |||||
return goods.size(); | |||||
} | |||||
public static class MyLCViewHolder1 extends RecyclerView.ViewHolder { | |||||
ImageView img;//图片按钮 | |||||
public MyLCViewHolder1(View view) { | |||||
super(view); | |||||
img=view.findViewById(R.id.img); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,100 @@ | |||||
package com.bonait.bnframework.modules.home.fragment.from; | |||||
import androidx.appcompat.app.AppCompatActivity; | |||||
import androidx.appcompat.widget.SearchView; | |||||
import androidx.recyclerview.widget.RecyclerView; | |||||
import android.os.Bundle; | |||||
import android.os.Environment; | |||||
import android.view.View; | |||||
import com.bonait.bnframework.R; | |||||
import com.bonait.bnframework.common.base.BaseActivity; | |||||
import com.bonait.bnframework.common.constant.DataBus; | |||||
import com.bonait.bnframework.common.db.mode.BPA_GOODS; | |||||
import com.bonait.bnframework.common.helper.AES; | |||||
import com.bonait.bnframework.common.helper.I.MyClickListener; | |||||
import com.bonait.bnframework.common.utils.ToastUtils; | |||||
import com.bonait.bnframework.common.view.MyLayoutManager; | |||||
import com.bonait.bnframework.modules.home.adapter.image_sp_adapter; | |||||
import com.bonait.bnframework.modules.home.adapter.sp_adapter; | |||||
import com.bonait.bnframework.modules.home.fragment.mode.image_sp; | |||||
import com.qmuiteam.qmui.widget.QMUITopBar; | |||||
import java.io.File; | |||||
import java.util.ArrayList; | |||||
import java.util.List; | |||||
import butterknife.BindView; | |||||
import butterknife.ButterKnife; | |||||
public class ImageChooseActivity extends BaseActivity { | |||||
@BindView(R.id.topbar) | |||||
QMUITopBar mTopBar;//顶部标题 | |||||
@BindView(R.id.recycler_view) | |||||
RecyclerView recyclerView;//image列表 | |||||
private static final String CACHE_PATH= Environment.getExternalStorageDirectory().getAbsolutePath()+"/hblxiaochaodb/WebImage"; | |||||
List<image_sp> data =new ArrayList<>(); | |||||
@Override | |||||
protected void onCreate(Bundle savedInstanceState) { | |||||
super.onCreate(savedInstanceState); | |||||
setContentView(R.layout.activity_image_choose); | |||||
ButterKnife.bind(this); | |||||
initTopBar(); | |||||
initData(); | |||||
} | |||||
private void initTopBar() { | |||||
mTopBar.setTitle("选择图片"); | |||||
mTopBar.addLeftImageButton(R.mipmap.fanhui,R.id.topbar).setOnClickListener(new View.OnClickListener() { | |||||
@Override | |||||
public void onClick(View view) { | |||||
finish(); | |||||
} | |||||
}); | |||||
} | |||||
private void initData() { | |||||
try{ | |||||
File path = new File(CACHE_PATH);// 获得路径 | |||||
File[] files = path.listFiles();// 读取文件 | |||||
data.clear(); | |||||
for (int i = 0; i < files.length; i++) { | |||||
String fileName = files[i].getName(); | |||||
image_sp s=new image_sp(); | |||||
s.url=fileName; | |||||
data.add(s); | |||||
} | |||||
MyLayoutManager layout = new MyLayoutManager(); | |||||
layout.setAutoMeasureEnabled(true); | |||||
recyclerView.setLayoutManager(layout); | |||||
image_sp_adapter spadapter = new image_sp_adapter(this,data); | |||||
recyclerView.setAdapter(spadapter); | |||||
spadapter.mListener=new MyClickListener() { | |||||
@Override | |||||
public void clickListener(View v, Object data) { | |||||
image_sp sp=(image_sp)data; | |||||
ToastUtils.info("选择图片:"+sp.url); | |||||
finish(); | |||||
} | |||||
@Override | |||||
public void clickListenerNew(View v, int k, Object data) { | |||||
} | |||||
}; | |||||
}catch(Exception e){ | |||||
ToastUtils.info("异常信息:"+e.getMessage()); | |||||
} | |||||
} | |||||
@Override | |||||
public void onDestroy() { | |||||
super.onDestroy(); | |||||
} | |||||
@Override | |||||
protected boolean canDragBack() { | |||||
return false; | |||||
} | |||||
} |
@@ -0,0 +1,8 @@ | |||||
package com.bonait.bnframework.modules.home.fragment.mode; | |||||
/** | |||||
* 加载图片 | |||||
*/ | |||||
public class image_sp { | |||||
public String url; | |||||
} |
@@ -0,0 +1,29 @@ | |||||
<?xml version="1.0" encoding="utf-8"?> | |||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||||
xmlns:app="http://schemas.android.com/apk/res-auto" | |||||
xmlns:tools="http://schemas.android.com/tools" | |||||
android:layout_width="match_parent" | |||||
android:layout_height="match_parent" | |||||
tools:context=".modules.home.fragment.from.ImageChooseActivity" | |||||
android:orientation="vertical" | |||||
android:background="@color/app_color_blue" | |||||
android:fitsSystemWindows="true"> | |||||
<com.qmuiteam.qmui.widget.QMUITopBar | |||||
android:id="@+id/topbar" | |||||
android:layout_width="match_parent" | |||||
android:layout_height="?attr/qmui_topbar_height"/> | |||||
<ScrollView | |||||
android:layout_width="match_parent" | |||||
android:layout_height="match_parent" | |||||
android:background="@color/activity_background"> | |||||
<RelativeLayout | |||||
android:padding="5dp" | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content"> | |||||
<androidx.recyclerview.widget.RecyclerView | |||||
android:id="@+id/recycler_view" | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content"/> | |||||
</RelativeLayout> | |||||
</ScrollView> | |||||
</LinearLayout> |
@@ -0,0 +1,19 @@ | |||||
<?xml version="1.0" encoding="utf-8"?> | |||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||||
xmlns:tools="http://schemas.android.com/tools" | |||||
android:layout_width="120dp" | |||||
android:layout_height="100dp"> | |||||
<RelativeLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="match_parent" | |||||
android:layout_margin="5dp" | |||||
android:background="@drawable/common_bg_with_radius_and_border"> | |||||
<ImageView | |||||
android:id="@+id/img" | |||||
android:layout_margin="3dp" | |||||
android:layout_marginBottom="3dp" | |||||
android:layout_width="match_parent" | |||||
android:layout_height="match_parent"> | |||||
</ImageView> | |||||
</RelativeLayout> | |||||
</RelativeLayout> |