2.调整程序初始化位置,先询问获取权限,在初始化数据库 3.调整料仓按钮大小、选择菜谱按钮大小tags/old_version_1
@@ -1,12 +1,16 @@ | |||
package com.bonait.bnframework; | |||
import android.Manifest; | |||
import android.annotation.SuppressLint; | |||
import android.app.Activity; | |||
import android.app.Application; | |||
import android.content.Context; | |||
import android.content.pm.PackageManager; | |||
import android.util.Log; | |||
import androidx.core.content.ContextCompat; | |||
import com.bonait.bnframework.business.ConfigData; | |||
import com.bonait.bnframework.common.constant.ConfigName; | |||
import com.bonait.bnframework.common.constant.DataBus; | |||
@@ -55,6 +59,7 @@ import java.util.concurrent.TimeUnit; | |||
import java.util.logging.Level; | |||
import okhttp3.OkHttpClient; | |||
import pub.devrel.easypermissions.EasyPermissions; | |||
/** | |||
* Created by FYF on 2019/3/19. | |||
@@ -72,232 +77,7 @@ public class MainApplication extends Application { | |||
public void onCreate() { | |||
super.onCreate(); | |||
context = getApplicationContext(); | |||
//0.全局异常捕获,保存为SD卡本级目录 crash | |||
CrashHandler.getInstance().init(this); | |||
//1.设置程序active,初始化Main函数进程,初始化消息日志 | |||
InitMsgLog(); | |||
ConfigName.getInstance().dishesCon = this; | |||
//2.初始化SD卡,数据库DB | |||
SdCart.getInstance().initSD(); | |||
//4.初始化Main,并且增加本地图片库 | |||
ConfigData.getInstance().AddImage(context); | |||
// activity生命周期管理 | |||
ActivityLifecycleManager.get().init(this); | |||
// QMUI 框架初始化 | |||
QMUISwipeBackActivityManager.init(this); | |||
// LitePal 数据库初始化 | |||
LitePal.initialize(this); | |||
// 全局配置OkGo | |||
initOkGo(); | |||
// 配置sharedPreferences | |||
PreferenceUtils.initPreference(this, AppUtils.getAppName(this), Activity.MODE_PRIVATE); | |||
// 初始化通知栏消息渠道 | |||
MainNotification.initNotificationChannel(this); | |||
// 内存泄漏检测 | |||
initLeakCanary(false); | |||
// Log日志打印框架 | |||
initLogCat(); | |||
// SmartShow Toast框架,暂时不用,先使用ToastUtils工具类的 | |||
//SmartShow.init(this); | |||
//初始化DB数据 | |||
InitDBdata(); | |||
DataBus.getInstance().GetLc();//获取料仓数据 | |||
ConfigData.getInstance().LoadingCloud();//加载云端数据 | |||
} | |||
//========================================================================// | |||
/** | |||
* 初始化数据库数据(默认数据) | |||
*/ | |||
public void InitDBdata() { | |||
//1.没有用户数据 默认写一个admin | |||
if (QueryDB.GetUserALL().size() <= 0) { | |||
BPA_USER user = new BPA_USER(); | |||
user.id = "20230415-fyf"; | |||
user.name = "管理员"; | |||
user.account = "admin"; | |||
user.pass = "123456"; | |||
user.deviceID = ConfigName.getInstance().DeviceId; | |||
user.userID = "20230415-fyf"; | |||
user.exp = "管理员"; | |||
QueryDB.AddUser(user); | |||
//10个料仓 | |||
if (QueryDB.GetSilosALL().size() == 0) { | |||
for (int i = 0; i < 5; i++) { | |||
BPA_SILOS silo = new BPA_SILOS(); | |||
silo.id = java.util.UUID.randomUUID().toString(); | |||
silo.num = i + 1; | |||
silo.thrsoleValue=ConfigName.getInstance().SiloAlarmThreshold; | |||
silo.warningValue=ConfigName.getInstance().SiloFeedThreshold; | |||
BPA_SILOSANDMATERIAL sm = new BPA_SILOSANDMATERIAL(); | |||
sm.silosID = silo.id; | |||
sm.materialID = ""; | |||
QueryDB.AddSilos(silo); | |||
QueryDB.AddSilosAndMaterial(sm); | |||
} | |||
} | |||
} | |||
if(QueryDB.GetPlcaddressALL().size()<=0) | |||
{ | |||
ConfigData.getInstance().RevertPLCProcess(); | |||
} | |||
} | |||
/** | |||
* 删除表-重新生成新表 | |||
*/ | |||
public void DBdelete() | |||
{ | |||
DBHelper.getInstance(this).DeleteCreateTables(BPA_CLOUDDATA.class,null); | |||
DBHelper.getInstance(this).DeleteCreateTables(BPA_PLCADDRESS.class,null); | |||
} | |||
/** | |||
* 初始化消息日志接收打印 | |||
*/ | |||
public void InitMsgLog(){ | |||
MessageLog.MsgNotify = new IMessageLogNotify() { | |||
@Override | |||
public void ErrorMsg(String msg) { | |||
Log.e("Error", msg); | |||
} | |||
@Override | |||
public void InfoMsg(String msg) { | |||
Log.i("Info", msg); | |||
} | |||
@Override | |||
public void WarnMsg(String msg) { | |||
Log.w("Warn", msg); | |||
} | |||
@Override | |||
public void UserMsg(UserLogEnum type, String msg) { | |||
BPA_LOG log = new BPA_LOG(); | |||
log.userID = ConfigName.getInstance().user.userID; | |||
switch (type.toString()) | |||
{ | |||
case "登录日志":log.type=1; | |||
break; | |||
case "角色操作日志":log.type=2; | |||
break; | |||
case "数据接收":log.type=3; | |||
break; | |||
case "上传日志":log.type=4; | |||
break; | |||
case "订单处理日志":log.type=5; | |||
break; | |||
} | |||
log.text = msg; | |||
QueryDB.Addlog(log); | |||
} | |||
@Override | |||
public void AlertMsg(AlertLogEnum type, String msg) { | |||
BPA_ALERTLOG log = new BPA_ALERTLOG(); | |||
log.userID = ConfigName.getInstance().user.userID; | |||
switch (type.toString()) | |||
{ | |||
case "异常订单未制作日志":log.type=1; | |||
break; | |||
case "料仓缺料日志":log.type=2; | |||
break; | |||
case "传感器异常日志":log.type=3; | |||
break; | |||
case "其他":log.type=4; | |||
break; | |||
} | |||
log.text = msg; | |||
QueryDB.AddAlertlog(log); | |||
} | |||
}; | |||
} | |||
/** | |||
* 内存泄漏检测,根据flag来判断要不要初始化 | |||
*/ | |||
private void initLeakCanary(boolean flag) { | |||
if (flag) { | |||
// leak 内存检测注册 | |||
// if (LeakCanary.isInAnalyzerProcess(this)) { | |||
// return; | |||
// } | |||
// LeakCanary.install(this); | |||
} | |||
ConfigName.getInstance().app = this; | |||
} | |||
/** | |||
* 初始化log日志框架 | |||
*/ | |||
private void initLogCat() { | |||
FormatStrategy formatStrategy = PrettyFormatStrategy.newBuilder() | |||
.showThreadInfo(false) // (可选)是否显示线程信息。 默认值为true | |||
.methodCount(2) // (可选)要显示的方法行数。 默认2 | |||
.build(); | |||
Logger.addLogAdapter(new AndroidLogAdapter(formatStrategy) { | |||
@Override | |||
public boolean isLoggable(int priority, String tag) { | |||
return BuildConfig.DEBUG; | |||
} | |||
}); | |||
} | |||
/** | |||
* 配置OkGo | |||
*/ | |||
private void initOkGo() { | |||
//---------这里给出的是示例代码,告诉你可以这么传,实际使用的时候,根据需要传,不需要就不传-------------// | |||
/*HttpHeaders headers = new HttpHeaders(); | |||
headers.put("commonHeaderKey1", "commonHeaderValue1"); //header不支持中文,不允许有特殊字符 | |||
headers.put("commonHeaderKey2", "commonHeaderValue2"); | |||
HttpParams params = new HttpParams(); | |||
params.put("commonParamsKey1", "commonParamsValue1"); //param支持中文,直接传,不要自己编码 | |||
params.put("commonParamsKey2", "这里支持中文参数");*/ | |||
//----------------------------------------------------------------------------------------// | |||
OkHttpClient.Builder builder = new OkHttpClient.Builder(); | |||
//log相关 | |||
HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor("OkGo"); | |||
//log打印级别,决定了log显示的详细程度 | |||
loggingInterceptor.setPrintLevel(HttpLoggingInterceptor.Level.BODY); | |||
//log颜色级别,决定了log在控制台显示的颜色 | |||
loggingInterceptor.setColorLevel(Level.INFO); | |||
//添加OkGo默认debug日志 | |||
builder.addInterceptor(loggingInterceptor); | |||
//-------------------------配置超时时间,默认60000ms,60s------------------------------// | |||
//OkGo.DEFAULT_MILLISECONDS | |||
//全局的连接超时时间 | |||
builder.connectTimeout(Constants.CONNECT_TIME_OUT, TimeUnit.MILLISECONDS); | |||
//全局的读取超时时间 | |||
builder.readTimeout(Constants.CONNECT_TIME_OUT, TimeUnit.MILLISECONDS); | |||
//全局的写入超时时间 | |||
builder.writeTimeout(OkGo.DEFAULT_MILLISECONDS, TimeUnit.MILLISECONDS); | |||
OkGo.getInstance().init(this) //必须调用初始化 | |||
.setOkHttpClient(builder.build()) //建议设置OkHttpClient,不设置将使用默认的 | |||
.setCacheMode(CacheMode.NO_CACHE) //全局统一缓存模式,默认不使用缓存,可以不传 | |||
.setCacheTime(CacheEntity.CACHE_NEVER_EXPIRE) //全局统一缓存时间,默认永不过期,可以不传 | |||
.setRetryCount(3); //全局统一超时重连次数,默认为三次,那么最差的情况会请求4次(一次原始请求,三次重连请求),不需要可以设置为0 | |||
//.addCommonParams(params); //全局公共参数 | |||
} | |||
} |
@@ -0,0 +1,276 @@ | |||
package com.bonait.bnframework.business; | |||
import android.app.Activity; | |||
import android.app.Application; | |||
import android.util.Log; | |||
import com.bonait.bnframework.BuildConfig; | |||
import com.bonait.bnframework.common.constant.ConfigName; | |||
import com.bonait.bnframework.common.constant.Constants; | |||
import com.bonait.bnframework.common.constant.DataBus; | |||
import com.bonait.bnframework.common.db.QueryDB; | |||
import com.bonait.bnframework.common.db.file.DBHelper; | |||
import com.bonait.bnframework.common.db.mode.BPA_ALERTLOG; | |||
import com.bonait.bnframework.common.db.mode.BPA_CLOUDDATA; | |||
import com.bonait.bnframework.common.db.mode.BPA_LOG; | |||
import com.bonait.bnframework.common.db.mode.BPA_PLCADDRESS; | |||
import com.bonait.bnframework.common.db.mode.BPA_SILOS; | |||
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.helper.CrashHandler; | |||
import com.bonait.bnframework.common.helper.I.IMessageLogNotify; | |||
import com.bonait.bnframework.common.helper.MessageLog; | |||
import com.bonait.bnframework.common.helper.SdCart; | |||
import com.bonait.bnframework.common.notification.MainNotification; | |||
import com.bonait.bnframework.common.utils.AppUtils; | |||
import com.bonait.bnframework.common.utils.PreferenceUtils; | |||
import com.bonait.bnframework.manager.ActivityLifecycleManager; | |||
import com.lzy.okgo.OkGo; | |||
import com.lzy.okgo.cache.CacheEntity; | |||
import com.lzy.okgo.cache.CacheMode; | |||
import com.lzy.okgo.interceptor.HttpLoggingInterceptor; | |||
import com.orhanobut.logger.AndroidLogAdapter; | |||
import com.orhanobut.logger.FormatStrategy; | |||
import com.orhanobut.logger.Logger; | |||
import com.orhanobut.logger.PrettyFormatStrategy; | |||
import com.qmuiteam.qmui.arch.QMUISwipeBackActivityManager; | |||
import org.litepal.LitePal; | |||
import java.util.concurrent.TimeUnit; | |||
import java.util.logging.Level; | |||
import okhttp3.OkHttpClient; | |||
public class MainInit { | |||
/** | |||
* 初始化 | |||
* @param app | |||
*/ | |||
public static void Init(Application app) | |||
{ | |||
//0.全局异常捕获,保存为SD卡本级目录 crash | |||
CrashHandler.getInstance().init(app); | |||
//1.设置程序active,初始化Main函数进程,初始化消息日志 | |||
InitMsgLog(); | |||
//2.初始化SD卡,数据库DB | |||
SdCart.getInstance().initSD(); | |||
//4.初始化Main,并且增加本地图片库 | |||
ConfigData.getInstance().AddImage(app); | |||
// activity生命周期管理 | |||
ActivityLifecycleManager.get().init(app); | |||
// QMUI 框架初始化 | |||
QMUISwipeBackActivityManager.init(app); | |||
// LitePal 数据库初始化 | |||
LitePal.initialize(app); | |||
// 全局配置OkGo | |||
initOkGo(app); | |||
// 配置sharedPreferences | |||
PreferenceUtils.initPreference(app, AppUtils.getAppName(app), Activity.MODE_PRIVATE); | |||
// 初始化通知栏消息渠道 | |||
MainNotification.initNotificationChannel(app); | |||
// 内存泄漏检测 | |||
initLeakCanary(false); | |||
// Log日志打印框架 | |||
initLogCat(); | |||
// SmartShow Toast框架,暂时不用,先使用ToastUtils工具类的 | |||
//SmartShow.init(this); | |||
//初始化DB数据 | |||
InitDBdata(); | |||
DataBus.getInstance().GetLc();//获取料仓数据 | |||
ConfigData.getInstance().LoadingCloud();//加载云端数据 | |||
} | |||
//========================================================================// | |||
/** | |||
* 初始化数据库数据(默认数据) | |||
*/ | |||
public static void InitDBdata() { | |||
//1.没有用户数据 默认写一个admin | |||
if (QueryDB.GetUserALL().size() <= 0) { | |||
BPA_USER user = new BPA_USER(); | |||
user.id = "20230415-fyf"; | |||
user.name = "管理员"; | |||
user.account = "admin"; | |||
user.pass = "123456"; | |||
user.deviceID = ConfigName.getInstance().DeviceId; | |||
user.userID = "20230415-fyf"; | |||
user.exp = "管理员"; | |||
QueryDB.AddUser(user); | |||
//10个料仓 | |||
if (QueryDB.GetSilosALL().size() == 0) { | |||
for (int i = 0; i < 5; i++) { | |||
BPA_SILOS silo = new BPA_SILOS(); | |||
silo.id = java.util.UUID.randomUUID().toString(); | |||
silo.num = i + 1; | |||
silo.thrsoleValue=ConfigName.getInstance().SiloAlarmThreshold; | |||
silo.warningValue=ConfigName.getInstance().SiloFeedThreshold; | |||
BPA_SILOSANDMATERIAL sm = new BPA_SILOSANDMATERIAL(); | |||
sm.silosID = silo.id; | |||
sm.materialID = ""; | |||
QueryDB.AddSilos(silo); | |||
QueryDB.AddSilosAndMaterial(sm); | |||
} | |||
} | |||
} | |||
if(QueryDB.GetPlcaddressALL().size()<=0) | |||
{ | |||
ConfigData.getInstance().RevertPLCProcess(); | |||
} | |||
} | |||
/** | |||
* 删除表-重新生成新表 | |||
*/ | |||
public static void DBdelete() | |||
{ | |||
// DBHelper.getInstance(this).DeleteCreateTables(BPA_CLOUDDATA.class,null); | |||
// DBHelper.getInstance(this).DeleteCreateTables(BPA_PLCADDRESS.class,null); | |||
} | |||
/** | |||
* 初始化消息日志接收打印 | |||
*/ | |||
public static void InitMsgLog(){ | |||
MessageLog.MsgNotify = new IMessageLogNotify() { | |||
@Override | |||
public void ErrorMsg(String msg) { | |||
Log.e("Error", msg); | |||
} | |||
@Override | |||
public void InfoMsg(String msg) { | |||
Log.i("Info", msg); | |||
} | |||
@Override | |||
public void WarnMsg(String msg) { | |||
Log.w("Warn", msg); | |||
} | |||
@Override | |||
public void UserMsg(UserLogEnum type, String msg) { | |||
BPA_LOG log = new BPA_LOG(); | |||
log.userID = ConfigName.getInstance().user.userID; | |||
switch (type.toString()) | |||
{ | |||
case "登录日志":log.type=1; | |||
break; | |||
case "角色操作日志":log.type=2; | |||
break; | |||
case "数据接收":log.type=3; | |||
break; | |||
case "上传日志":log.type=4; | |||
break; | |||
case "订单处理日志":log.type=5; | |||
break; | |||
} | |||
log.text = msg; | |||
QueryDB.Addlog(log); | |||
} | |||
@Override | |||
public void AlertMsg(AlertLogEnum type, String msg) { | |||
BPA_ALERTLOG log = new BPA_ALERTLOG(); | |||
log.userID = ConfigName.getInstance().user.userID; | |||
switch (type.toString()) | |||
{ | |||
case "异常订单未制作日志":log.type=1; | |||
break; | |||
case "料仓缺料日志":log.type=2; | |||
break; | |||
case "传感器异常日志":log.type=3; | |||
break; | |||
case "其他":log.type=4; | |||
break; | |||
} | |||
log.text = msg; | |||
QueryDB.AddAlertlog(log); | |||
} | |||
}; | |||
} | |||
/** | |||
* 内存泄漏检测,根据flag来判断要不要初始化 | |||
*/ | |||
private static void initLeakCanary(boolean flag) { | |||
if (flag) { | |||
// leak 内存检测注册 | |||
// if (LeakCanary.isInAnalyzerProcess(this)) { | |||
// return; | |||
// } | |||
// LeakCanary.install(this); | |||
} | |||
} | |||
/** | |||
* 初始化log日志框架 | |||
*/ | |||
private static void initLogCat() { | |||
FormatStrategy formatStrategy = PrettyFormatStrategy.newBuilder() | |||
.showThreadInfo(false) // (可选)是否显示线程信息。 默认值为true | |||
.methodCount(2) // (可选)要显示的方法行数。 默认2 | |||
.build(); | |||
Logger.addLogAdapter(new AndroidLogAdapter(formatStrategy) { | |||
@Override | |||
public boolean isLoggable(int priority, String tag) { | |||
return BuildConfig.DEBUG; | |||
} | |||
}); | |||
} | |||
/** | |||
* 配置OkGo | |||
*/ | |||
private static void initOkGo(Application app) { | |||
//---------这里给出的是示例代码,告诉你可以这么传,实际使用的时候,根据需要传,不需要就不传-------------// | |||
/*HttpHeaders headers = new HttpHeaders(); | |||
headers.put("commonHeaderKey1", "commonHeaderValue1"); //header不支持中文,不允许有特殊字符 | |||
headers.put("commonHeaderKey2", "commonHeaderValue2"); | |||
HttpParams params = new HttpParams(); | |||
params.put("commonParamsKey1", "commonParamsValue1"); //param支持中文,直接传,不要自己编码 | |||
params.put("commonParamsKey2", "这里支持中文参数");*/ | |||
//----------------------------------------------------------------------------------------// | |||
OkHttpClient.Builder builder = new OkHttpClient.Builder(); | |||
//log相关 | |||
HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor("OkGo"); | |||
//log打印级别,决定了log显示的详细程度 | |||
loggingInterceptor.setPrintLevel(HttpLoggingInterceptor.Level.BODY); | |||
//log颜色级别,决定了log在控制台显示的颜色 | |||
loggingInterceptor.setColorLevel(Level.INFO); | |||
//添加OkGo默认debug日志 | |||
builder.addInterceptor(loggingInterceptor); | |||
//-------------------------配置超时时间,默认60000ms,60s------------------------------// | |||
//OkGo.DEFAULT_MILLISECONDS | |||
//全局的连接超时时间 | |||
builder.connectTimeout(Constants.CONNECT_TIME_OUT, TimeUnit.MILLISECONDS); | |||
//全局的读取超时时间 | |||
builder.readTimeout(Constants.CONNECT_TIME_OUT, TimeUnit.MILLISECONDS); | |||
//全局的写入超时时间 | |||
builder.writeTimeout(OkGo.DEFAULT_MILLISECONDS, TimeUnit.MILLISECONDS); | |||
OkGo.getInstance().init(app) //必须调用初始化 | |||
.setOkHttpClient(builder.build()) //建议设置OkHttpClient,不设置将使用默认的 | |||
.setCacheMode(CacheMode.NO_CACHE) //全局统一缓存模式,默认不使用缓存,可以不传 | |||
.setCacheTime(CacheEntity.CACHE_NEVER_EXPIRE) //全局统一缓存时间,默认永不过期,可以不传 | |||
.setRetryCount(3); //全局统一超时重连次数,默认为三次,那么最差的情况会请求4次(一次原始请求,三次重连请求),不需要可以设置为0 | |||
//.addCommonParams(params); //全局公共参数 | |||
} | |||
} |
@@ -1,5 +1,6 @@ | |||
package com.bonait.bnframework.common.constant; | |||
import android.app.Application; | |||
import android.content.Context; | |||
import com.bonait.bnframework.R; | |||
@@ -44,6 +45,7 @@ public class ConfigName { | |||
//region 程序进入界面 | |||
public Context dishesCon; | |||
public Context Home; | |||
public Application app; | |||
//endregion | |||
//region SD卡路径设置 | |||
@@ -9,6 +9,7 @@ import android.view.LayoutInflater; | |||
import android.view.View; | |||
import android.view.ViewGroup; | |||
import android.widget.ImageView; | |||
import android.widget.LinearLayout; | |||
import com.bonait.bnframework.R; | |||
import com.bonait.bnframework.common.constant.DataBus; | |||
@@ -63,16 +64,25 @@ public class lc_adapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { | |||
myViewHolder.add.setOnClickListener(new View.OnClickListener() { | |||
@Override | |||
public void onClick(View view) { | |||
//按钮点击 | |||
String title = "料仓操作提示!"; | |||
String message = "请问客官确定要将["+lcModes.get(position).materialName+"]加满吗?"; | |||
AlertDialogUtils.showDialog(context, title, message, new QMUIDialogAction.ActionListener() { | |||
@Override | |||
public void onClick(QMUIDialog dialog, int index) { | |||
DataBus.getInstance().TopUp(position); | |||
dialog.dismiss(); | |||
} | |||
}); | |||
show_jm(position); | |||
} | |||
}); | |||
myViewHolder.m_click_layout.setOnClickListener(new View.OnClickListener() { | |||
@Override | |||
public void onClick(View view) { | |||
show_jm(position); | |||
} | |||
}); | |||
myViewHolder.name.setOnClickListener(new View.OnClickListener() { | |||
@Override | |||
public void onClick(View view) { | |||
show_jm(position); | |||
} | |||
}); | |||
myViewHolder.type.setOnClickListener(new View.OnClickListener() { | |||
@Override | |||
public void onClick(View view) { | |||
show_jm(position); | |||
} | |||
}); | |||
} | |||
@@ -81,6 +91,24 @@ public class lc_adapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { | |||
} | |||
} | |||
/** | |||
* 料仓加满 | |||
* @param index | |||
*/ | |||
public void show_jm(int index) | |||
{ | |||
//按钮点击 | |||
String title = "料仓操作提示!"; | |||
String message = "请问客官确定要将["+lcModes.get(index).materialName+"]加满吗?"; | |||
AlertDialogUtils.showDialog(context, title, message, new QMUIDialogAction.ActionListener() { | |||
@Override | |||
public void onClick(QMUIDialog dialog, int index) { | |||
DataBus.getInstance().TopUp(index); | |||
dialog.dismiss(); | |||
} | |||
}); | |||
} | |||
private Activity findActivity(@NonNull Context context) { | |||
if (context instanceof Activity) { | |||
return (Activity) context; | |||
@@ -122,12 +150,16 @@ public class lc_adapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { | |||
QMUILinkTextView type;//物料类型 | |||
QMUILinkTextView name;//物料名称 | |||
QMUILinkTextView bfb;//料仓余量百分比 | |||
LinearLayout m_click_layout; | |||
public MyLCViewHolder(View view) { | |||
super(view); | |||
add=view.findViewById(R.id.add); | |||
type=view.findViewById(R.id.type); | |||
name=view.findViewById(R.id.name); | |||
bfb=view.findViewById(R.id.bfb); | |||
m_click_layout=view.findViewById(R.id.m_click_layout); | |||
} | |||
} | |||
} |
@@ -18,6 +18,8 @@ import com.bonait.bnframework.common.db.mode.BPA_PLCADDRESS; | |||
import com.bonait.bnframework.modules.home.fragment.mode.fragment_plc; | |||
import com.bonait.bnframework.modules.home.fragment.mode.fragment_plc_control; | |||
import com.orhanobut.logger.Logger; | |||
import com.qmuiteam.qmui.widget.QMUILoadingView; | |||
import com.qmuiteam.qmui.widget.dialog.QMUITipDialog; | |||
import java.util.ArrayList; | |||
@@ -31,6 +33,10 @@ public class SystemCsControlFragment extends BaseFragment { | |||
private Context context; | |||
@BindView(R.id.plcview) | |||
LinearLayout plcview;//工序子集 | |||
@BindView(R.id.load_view) | |||
QMUILoadingView load_view;//工序子集 | |||
@Override | |||
protected View onCreateView() { | |||
View root = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_system_cs_control, null); | |||
@@ -49,6 +55,7 @@ public class SystemCsControlFragment extends BaseFragment { | |||
* 初始化 | |||
*/ | |||
public void Init() { | |||
load_view.setVisibility(View.VISIBLE); | |||
plcview.removeAllViews(); | |||
ArrayList<BPA_PLCADDRESS> arrayList = QueryDB.GetPlcaddressALL(); | |||
new Thread(new Runnable() { | |||
@@ -66,7 +73,8 @@ public class SystemCsControlFragment extends BaseFragment { | |||
plcview.addView(gongxu); | |||
} | |||
} catch (Exception e) { | |||
}finally { | |||
load_view.setVisibility(View.INVISIBLE); | |||
} | |||
} | |||
}); | |||
@@ -29,8 +29,10 @@ import com.bonait.bnframework.common.utils.ToastUtils; | |||
import com.bonait.bnframework.modules.home.fragment.mode.fragment_gx; | |||
import com.bonait.bnframework.modules.home.fragment.mode.fragment_plc; | |||
import com.orhanobut.logger.Logger; | |||
import com.qmuiteam.qmui.widget.QMUILoadingView; | |||
import com.qmuiteam.qmui.widget.dialog.QMUIDialog; | |||
import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction; | |||
import com.qmuiteam.qmui.widget.dialog.QMUITipDialog; | |||
import java.util.ArrayList; | |||
@@ -41,9 +43,9 @@ import butterknife.OnClick; | |||
public class SystemCsPLCFragment extends BaseFragment { | |||
@BindView(R.id.plcview) | |||
LinearLayout plcview;//工序子集 | |||
private Context context; | |||
@BindView(R.id.load_view) | |||
QMUILoadingView load_view;//工序子集 | |||
@Override | |||
protected View onCreateView() { | |||
View root = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_system_cs_plc, null); | |||
@@ -63,8 +65,12 @@ public class SystemCsPLCFragment extends BaseFragment { | |||
* 初始化 | |||
*/ | |||
public void Init() { | |||
plcview.removeAllViews(); | |||
ArrayList<BPA_PLCADDRESS> arrayList = QueryDB.GetPlcaddressALL(); | |||
load_view.setVisibility(View.VISIBLE); | |||
// QMUITipDialog loadingDialog = new QMUITipDialog.Builder(getActivity()) | |||
// .setIconType(QMUITipDialog.Builder.ICON_TYPE_LOADING) | |||
// .setTipWord("正在加载...") | |||
// .create(); | |||
// loadingDialog.show(); | |||
new Thread(new Runnable() { | |||
@Override | |||
public void run() { | |||
@@ -75,12 +81,14 @@ public class SystemCsPLCFragment extends BaseFragment { | |||
@Override | |||
public void run() { | |||
try { | |||
ArrayList<BPA_PLCADDRESS> arrayList = QueryDB.GetPlcaddressALL(); | |||
for (BPA_PLCADDRESS item : arrayList) { | |||
fragment_plc gongxu = new fragment_plc(context, null, item); | |||
plcview.addView(gongxu); | |||
} | |||
} catch (Exception e) { | |||
}finally { | |||
load_view.setVisibility(View.INVISIBLE); | |||
} | |||
} | |||
}); | |||
@@ -112,6 +120,7 @@ public class SystemCsPLCFragment extends BaseFragment { | |||
AlertDialogUtils.showDialog(context, title, message, new QMUIDialogAction.ActionListener() { | |||
@Override | |||
public void onClick(QMUIDialog dialog, int index) { | |||
load_view.setVisibility(View.VISIBLE); | |||
ConfigData.getInstance().RevertPLCProcess(); | |||
Init(); | |||
ToastUtils.info("初始化成功!"); | |||
@@ -38,8 +38,8 @@ public class SystemDeviceinFragment extends BaseFragment { | |||
EditText edittext6; | |||
@BindView(R.id.edittext7) | |||
EditText edittext7; | |||
@BindView(R.id.image) | |||
ImageView image; | |||
// @BindView(R.id.image) | |||
// ImageView image; | |||
private Context context; | |||
@Override | |||
protected View onCreateView() { | |||
@@ -71,10 +71,10 @@ public class SystemDeviceinFragment extends BaseFragment { | |||
edittext6.setText(ConfigName.getInstance().organizeMode.id); | |||
edittext7.setText(ConfigName.getInstance().organizeMode.store_Name); | |||
if(ConfigName.getInstance().organizeMode.logo!=null) | |||
{ | |||
new MyBitmapUtils().disPlay(image,ConfigName.getInstance().organizeMode.logo); | |||
} | |||
// if(ConfigName.getInstance().organizeMode.logo!=null) | |||
// { | |||
// new MyBitmapUtils().disPlay(image,ConfigName.getInstance().organizeMode.logo); | |||
// } | |||
}else | |||
{ | |||
edittext1.setText(ConfigName.getInstance().DeviceId); | |||
@@ -30,6 +30,7 @@ import com.bonait.bnframework.common.db.mode.BPA_PROCESS; | |||
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.utils.AlertDialogUtils; | |||
import com.bonait.bnframework.common.utils.NetworkUtils; | |||
import com.bonait.bnframework.common.utils.ToastUtils; | |||
import com.bonait.bnframework.modules.home.adapter.lcsz_adapter; | |||
@@ -176,8 +177,18 @@ public class SystemSeasoningsetFragment extends BaseFragment implements MyClickL | |||
} | |||
break; | |||
case R.id.huifuchuchang://恢复出 | |||
ConfigData.getInstance().RevertPLCProcess(); | |||
Initdata_gx(); | |||
String title = "温馨提示!"; | |||
String message = "客官确定要初始化PLC地址吗,小菠萝温馨提示你,此操作将会影响到实际运行哦?"; | |||
AlertDialogUtils.showDialog(context, title, message, new QMUIDialogAction.ActionListener() { | |||
@Override | |||
public void onClick(QMUIDialog dialog, int index) { | |||
ConfigData.getInstance().RevertPLCProcess(); | |||
Initdata_gx(); | |||
ToastUtils.info("恢复出厂设置成功!"); | |||
dialog.dismiss(); | |||
} | |||
}); | |||
break; | |||
} | |||
@@ -1,18 +1,26 @@ | |||
package com.bonait.bnframework.modules.welcome.activity; | |||
import android.Manifest; | |||
import android.content.Intent; | |||
import android.os.Bundle; | |||
import android.os.Handler; | |||
import androidx.annotation.NonNull; | |||
import androidx.appcompat.app.AppCompatActivity; | |||
import android.view.KeyEvent; | |||
import com.bonait.bnframework.R; | |||
import com.bonait.bnframework.business.MainInit; | |||
import com.bonait.bnframework.common.constant.ConfigName; | |||
import com.bonait.bnframework.common.constant.Constants; | |||
import com.bonait.bnframework.manager.ActivityLifecycleManager; | |||
import com.bonait.bnframework.modules.home.activity.BottomNavigation2Activity; | |||
import com.bonait.bnframework.test.TestActivity; | |||
import com.lzy.okgo.OkGo; | |||
import okhttp3.OkHttpClient; | |||
import pub.devrel.easypermissions.AfterPermissionGranted; | |||
import pub.devrel.easypermissions.EasyPermissions; | |||
public class WelcomeActivity extends AppCompatActivity { | |||
@@ -72,13 +80,40 @@ public class WelcomeActivity extends AppCompatActivity { | |||
}, 2000); | |||
} | |||
/** | |||
* 检查权限是否授权 | |||
*/ | |||
public void PermissionCheck() { | |||
String[] params = {Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.RECORD_AUDIO, Manifest.permission.CAMERA}; | |||
//String[] params = {Manifest.permission.WRITE_EXTERNAL_STORAGE}; | |||
//判断是否获取权限 | |||
if (EasyPermissions.hasPermissions(this, params)) { | |||
// 全部权限申请成功后 | |||
//1.直接进入登录界面 | |||
skipToLoginActivity(); | |||
} else { | |||
//未获取权限或拒绝权限时 | |||
EasyPermissions.requestPermissions(this, | |||
"小炒设备需要用到以下权限:\n\n1. 文件读取存储权限\n\n2. 录制视频权限\n\n3. 录制音频权限", | |||
Constants.ALL_PERMISSION, params); | |||
} | |||
} | |||
@Override | |||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { | |||
super.onRequestPermissionsResult(requestCode, permissions, grantResults); | |||
if (requestCode == Constants.ALL_PERMISSION) { | |||
//1.直接进入登录界面 | |||
skipToLoginActivity(); | |||
} | |||
} | |||
/** | |||
* 请求服务器判断token是否过期 | |||
*/ | |||
private void doPost() { | |||
//1.直接进入登录界面 | |||
skipToLoginActivity(); | |||
PermissionCheck(); | |||
// //判断是否用户修改过密码 | |||
// boolean isChangePwd = PreferenceUtils.getBoolean(SPConstants.CHANGE_PWD, false); | |||
// if (isChangePwd) { | |||
@@ -152,6 +187,8 @@ public class WelcomeActivity extends AppCompatActivity { | |||
* 跳转到登录页面 | |||
* */ | |||
private void skipToLoginActivity() { | |||
//初始化 | |||
MainInit.Init(ConfigName.getInstance().app); | |||
// 跳转到登录页面 | |||
Intent intent = new Intent(WelcomeActivity.this, LoginActivity.class); | |||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); | |||
@@ -29,6 +29,8 @@ | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" | |||
android:background="@drawable/button"/> | |||
<RelativeLayout | |||
android:padding="5dp" | |||
android:layout_width="match_parent" | |||
@@ -46,13 +46,21 @@ android:orientation="vertical"> | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content"> | |||
<ImageView | |||
android:layout_width="20dp" | |||
android:layout_height="20dp" | |||
android:src="@mipmap/stcp"/> | |||
<TextView | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:text="选择菜谱"/> | |||
android:layout_width="30dp" | |||
android:layout_height="30dp" | |||
android:src="@mipmap/stcp" | |||
android:clickable="false"/> | |||
<RelativeLayout | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent"> | |||
<TextView | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:text="选择菜谱" | |||
android:layout_centerInParent="true" | |||
android:clickable="false"/> | |||
</RelativeLayout> | |||
</LinearLayout> | |||
</RelativeLayout> | |||
</LinearLayout> | |||
@@ -5,23 +5,35 @@ | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent" | |||
tools:context=".modules.home.fragment.from.fragment.SystemCsControlFragment"> | |||
<LinearLayout | |||
<RelativeLayout | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent" | |||
android:orientation="vertical" | |||
android:background="@color/main_background"> | |||
<ScrollView | |||
android:layout_marginTop="20dp" | |||
android:layout_weight="1" | |||
android:layout_height="match_parent"> | |||
<LinearLayout | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent"> | |||
<LinearLayout | |||
android:id="@+id/plcview" | |||
android:layout_height="match_parent" | |||
android:orientation="vertical" | |||
android:background="@color/main_background"> | |||
<ScrollView | |||
android:layout_marginTop="20dp" | |||
android:layout_weight="1" | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" | |||
android:orientation="vertical"> | |||
</LinearLayout> | |||
</ScrollView> | |||
android:layout_height="match_parent"> | |||
<LinearLayout | |||
android:id="@+id/plcview" | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" | |||
android:orientation="vertical"> | |||
</LinearLayout> | |||
</ScrollView> | |||
</LinearLayout> | |||
</LinearLayout> | |||
<com.qmuiteam.qmui.widget.QMUILoadingView | |||
android:id="@+id/load_view" | |||
android:layout_width="75dp" | |||
android:layout_height="55dp" | |||
android:layout_centerInParent="true" | |||
android:color="@color/colorPrimary" | |||
android:visibility="visible" | |||
tools:ignore="MissingConstraints" /> | |||
</RelativeLayout> | |||
</com.qmuiteam.qmui.widget.QMUIWindowInsetLayout> |
@@ -5,39 +5,52 @@ | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent" | |||
tools:context=".modules.home.fragment.from.fragment.SystemCsPLCFragment"> | |||
<LinearLayout | |||
<RelativeLayout | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent" | |||
android:orientation="vertical" | |||
android:background="@color/main_background"> | |||
<ScrollView | |||
android:layout_marginTop="20dp" | |||
android:layout_weight="1" | |||
android:layout_height="match_parent"> | |||
<LinearLayout | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent"> | |||
android:layout_height="match_parent" | |||
android:orientation="vertical" | |||
android:background="@color/main_background"> | |||
<ScrollView | |||
android:layout_marginTop="20dp" | |||
android:layout_weight="1" | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent"> | |||
<LinearLayout | |||
android:id="@+id/plcview" | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" | |||
android:orientation="vertical"> | |||
</LinearLayout> | |||
</ScrollView> | |||
<LinearLayout | |||
android:id="@+id/plcview" | |||
android:layout_margin="20dp" | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" | |||
android:orientation="vertical"> | |||
android:layout_height="34dp" | |||
android:gravity="center_vertical" | |||
android:orientation="horizontal"> | |||
<Button | |||
android:id="@+id/chushihua" | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" | |||
android:background="@drawable/bg_btn_login_selected" | |||
android:text="恢复出厂设置" | |||
android:layout_weight="1" | |||
/> | |||
</LinearLayout> | |||
</ScrollView> | |||
<LinearLayout | |||
android:layout_margin="20dp" | |||
android:layout_width="match_parent" | |||
android:layout_height="34dp" | |||
android:gravity="center_vertical" | |||
android:orientation="horizontal"> | |||
<Button | |||
android:id="@+id/chushihua" | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" | |||
android:background="@drawable/bg_btn_login_selected" | |||
android:text="恢复出厂设置" | |||
android:layout_weight="1" | |||
/> | |||
</LinearLayout> | |||
</LinearLayout> | |||
<com.qmuiteam.qmui.widget.QMUILoadingView | |||
android:id="@+id/load_view" | |||
android:layout_width="75dp" | |||
android:layout_height="55dp" | |||
android:layout_centerInParent="true" | |||
android:color="@color/colorPrimary" | |||
android:visibility="visible" | |||
tools:ignore="MissingConstraints" /> | |||
</RelativeLayout> | |||
</com.qmuiteam.qmui.widget.QMUIWindowInsetLayout> |
@@ -214,25 +214,25 @@ | |||
</TableRow> | |||
<!-- Table1--> | |||
<TableRow | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_gravity="center" | |||
android:layout_margin="5dp"> | |||
<com.qmuiteam.qmui.widget.textview.QMUILinkTextView | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:gravity="right" | |||
android:text="门店LOGO:" /> | |||
<ImageView | |||
android:id="@+id/image" | |||
android:layout_width="120dp" | |||
android:layout_height="120dp" | |||
android:layout_marginLeft="5dp" | |||
android:src="@mipmap/loading3" /> | |||
</TableRow> | |||
<!-- <TableRow--> | |||
<!-- android:layout_width="wrap_content"--> | |||
<!-- android:layout_height="wrap_content"--> | |||
<!-- android:layout_gravity="center"--> | |||
<!-- android:layout_margin="5dp">--> | |||
<!-- <com.qmuiteam.qmui.widget.textview.QMUILinkTextView--> | |||
<!-- android:layout_width="wrap_content"--> | |||
<!-- android:layout_height="wrap_content"--> | |||
<!-- android:gravity="right"--> | |||
<!-- android:text="门店LOGO:" />--> | |||
<!-- <ImageView--> | |||
<!-- android:id="@+id/image"--> | |||
<!-- android:layout_width="120dp"--> | |||
<!-- android:layout_height="120dp"--> | |||
<!-- android:layout_marginLeft="5dp"--> | |||
<!-- android:src="@mipmap/loading3" />--> | |||
<!-- </TableRow>--> | |||
</TableLayout> | |||
</RelativeLayout> | |||
@@ -5,6 +5,7 @@ | |||
android:background="@drawable/common_bg_with_radius_and_border"> | |||
<LinearLayout | |||
android:id="@+id/m_click_layout" | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" | |||
android:layout_centerInParent="true" | |||
@@ -63,7 +64,7 @@ | |||
android:layout_alignParentRight="true" | |||
android:layout_marginBottom="@dimen/dp_4" | |||
android:layout_marginRight="@dimen/dp_4" | |||
android:layout_width="12dp" | |||
android:layout_height="12dp" | |||
android:layout_width="16dp" | |||
android:layout_height="16dp" | |||
android:src="@mipmap/jia"/> | |||
</RelativeLayout> |