Explorar el Código

增加文件上传2

tags/old_version_1
fyf hace 1 año
padre
commit
79f367d66e
Se han modificado 4 ficheros con 41 adiciones y 18 borrados
  1. +12
    -12
      app/src/main/java/com/bonait/bnframework/business/ConfigData.java
  2. +22
    -1
      app/src/main/java/com/bonait/bnframework/common/utils/NetworkUtils.java
  3. +6
    -4
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/CpActivity.java
  4. +1
    -1
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/SystemSeasoningsetFragment.java

+ 12
- 12
app/src/main/java/com/bonait/bnframework/business/ConfigData.java Ver fichero

@@ -291,7 +291,7 @@ public class ConfigData {
* @param context
*/
public void GetOrganize(Context context) {
if (NetworkUtils.isNetworkConnected(context)) {
if (NetworkUtils.checkNetworkAvailable(context)) {

//获取店铺信息
OkGo.<ResAPI<OrganizeMode>>get(ConfigName.getInstance().SaasAddress + ConfigName.getInstance().GetStore + ConfigName.getInstance().ClientAutoKey).tag(context).execute(new JsonDialogCallback<ResAPI<OrganizeMode>>(context) {
@@ -325,7 +325,7 @@ public class ConfigData {
* 同步云端数据
*/
public void SyncDataInTheCloud(Context context, Handler mHandler) {
if (NetworkUtils.isNetworkConnected(context)) {
if (NetworkUtils.checkNetworkAvailable(context)) {
//region 拉取物料数据
if (ConfigName.getInstance().organizeMode == null) {
return;
@@ -492,7 +492,7 @@ public class ConfigData {
* @param context
*/
public void GetGevGood(Context context, Handler mHandler) {
if (NetworkUtils.isNetworkConnected(context)) {
if (NetworkUtils.checkNetworkAvailable(context)) {
if (ConfigName.getInstance().organizeMode == null) {
return;
}
@@ -502,9 +502,12 @@ public class ConfigData {
ResAPI<List<CloudGood>> allDataResAPI = response.body();
if (allDataResAPI.succeeded && allDataResAPI.data != null && allDataResAPI.data.size() > 0) {
ConfigName.getInstance().cloudGoods = allDataResAPI.data;
Message msg = new Message();
msg.obj = "MSG_REFRESH";
mHandler.sendMessage(msg);
if(mHandler!=null)
{
Message msg = new Message();
msg.obj = "MSG_REFRESH";
mHandler.sendMessage(msg);
}
}
}
});
@@ -525,7 +528,7 @@ public class ConfigData {
return;
}

if (NetworkUtils.isNetworkConnected(context)) {
if (NetworkUtils.checkNetworkAvailable(context)) {
if (ConfigName.getInstance().organizeMode == null) {
return;
}
@@ -614,7 +617,7 @@ public class ConfigData {
*/
public void UploadGoods(Context context, String goodid) {
try {
if (NetworkUtils.isNetworkConnected(context)) {
if (NetworkUtils.checkNetworkAvailable(context)) {
if (ConfigName.getInstance().organizeMode == null && ConfigName.getInstance().cloudData != null) {
ToastUtils.warning("无组织信息不能上传,请设置当前店铺信息!!!");
return;
@@ -794,9 +797,6 @@ public class ConfigData {

if (isSuceess) {
try {



String str=ConfigName.getInstance().SaasAddress + ConfigName.getInstance().UpdateGoods;
//String str="http://192.168.1.64:5001/api/CommInteface/SendGoodsInfo";
OkGo.<ResAPI<Boolean>>post(str).tag(context).upRequestBody(RequestBody.create(MediaType.parse("application/json; charset=utf-8"), new Gson().toJson(update))).headers(new HttpHeaders("TenantId", ConfigName.getInstance().organizeMode.companyId)).execute(new JsonDialogCallback<ResAPI<Boolean>>(context) {
@@ -805,7 +805,7 @@ public class ConfigData {
ResAPI<Boolean> allDataResAPI = response.body();
if (allDataResAPI.succeeded) {
ToastUtils.info("上传菜品成功!!!");
MessageManager.getInstance().sendMessage(MessageName.ScGood, "Good");
MessageManager.getInstance().sendMessage(MessageName.ScGood, "GoodUpdate");
editDialog.dismiss();
} else {
ToastUtils.warning("上传菜品失败!!!");


+ 22
- 1
app/src/main/java/com/bonait/bnframework/common/utils/NetworkUtils.java Ver fichero

@@ -10,7 +10,28 @@ import android.os.Build;
* Created by LY on 2019/1/4.
*/
public class NetworkUtils {

//判断网络连接是否可用(返回true表示网络可用,false为不可用)
public static boolean checkNetworkAvailable(Context context) {
//获取手机所有链接管理对象(包括对Wi-Fi,net等连接的管理)
ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
if (manager == null) {
return false;
} else {
//获取NetworkInfo对象
NetworkInfo[] info = manager.getAllNetworkInfo();
if (info != null && info.length > 0) {
for (int i = 0; i < info.length; i++) {
System.out.println(i + "状态" + info[i].getState());
System.out.println(i + "类型" + info[i].getTypeName());
// 判断当前网络状态是否为连接状态
if (info[i].getState() == NetworkInfo.State.CONNECTED) {
return true;
}
}
}
}
return false;
}
/**
* 检测当的网络(WLAN、4G/3G/2G)状态,兼容Android 6.0以下
* @param context Context


+ 6
- 4
app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/CpActivity.java Ver fichero

@@ -5,6 +5,7 @@ import static com.bonait.bnframework.MainApplication.getContext;
import androidx.appcompat.app.AppCompatActivity;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

@@ -22,6 +23,7 @@ import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.constant.MessageName;
import com.bonait.bnframework.common.db.QueryDB;
import com.bonait.bnframework.common.db.mode.BPA_GOODS;
import com.bonait.bnframework.common.db.mode.BPA_PLCADDRESS;
import com.bonait.bnframework.common.message.MessageLooper;
import com.bonait.bnframework.common.message.MessageManager;
import com.bonait.bnframework.common.model.mode.CloudGood;
@@ -29,6 +31,7 @@ import com.bonait.bnframework.common.utils.ToastUtils;
import com.bonait.bnframework.modules.home.fragment.mode.QDListSectionAdapter;
import com.bonait.bnframework.modules.home.fragment.mode.SectionHeader;
import com.bonait.bnframework.modules.home.fragment.mode.SectionItem;
import com.bonait.bnframework.modules.home.fragment.mode.fragment_plc;
import com.qmuiteam.qmui.widget.QMUITopBar;
import com.qmuiteam.qmui.widget.section.QMUISection;
import com.qmuiteam.qmui.widget.section.QMUIStickySectionAdapter;
@@ -56,6 +59,7 @@ public class CpActivity extends BaseActivity {
setContentView(R.layout.activity_cp);
//属性绑定
ButterKnife.bind(this);
context=this;
initTopBar();
initAdapter();
initAdapterLogicalOperation();
@@ -99,9 +103,8 @@ public class CpActivity extends BaseActivity {
mSectionLayout.setAdapter(mAdapter, true);
ConfigData.getInstance().GetGevGood(this, mHandler);
mAdapter.setData(getList());
mAdapter.refreshCustomData();
}
Context context;
@SuppressLint("HandlerLeak")
private Handler mHandler = new Handler() {
@Override
@@ -123,7 +126,7 @@ public class CpActivity extends BaseActivity {
SectionItem item = (SectionItem) msg;
QueryDB.DeleteGoodsid(item.getAccount());
QueryDB.DeleteGoodsSrecipeList(item.getAccount());
mAdapter.setDataWithoutDiff(getList(),true);
mAdapter.setDataWithoutDiff(getList(), true);
}
}
});
@@ -136,7 +139,6 @@ public class CpActivity extends BaseActivity {
public void onMessage(Object msg) {
if (msg != null) {
mAdapter.setData(new ArrayList<QMUISection<SectionHeader, SectionItem>>());
//mAdapter.setDataWithoutDiff(getList(),true);
mAdapter.setData(getList());
}
}


+ 1
- 1
app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/SystemSeasoningsetFragment.java Ver fichero

@@ -143,7 +143,7 @@ public class SystemSeasoningsetFragment extends BaseFragment implements MyClickL
break;
case R.id.synchronous://同步云端

if (NetworkUtils.isNetworkConnected(context)) {
if (NetworkUtils.checkNetworkAvailable(context)) {
final QMUIDialog.EditTextDialogBuilder builder = new QMUIDialog.EditTextDialogBuilder(context);
builder.setTitle("密码确认")
.setPlaceholder("在此输入权限密码")


Cargando…
Cancelar
Guardar