@@ -291,7 +291,7 @@ public class ConfigData { | |||||
* @param context | * @param context | ||||
*/ | */ | ||||
public void GetOrganize(Context 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) { | 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) { | public void SyncDataInTheCloud(Context context, Handler mHandler) { | ||||
if (NetworkUtils.isNetworkConnected(context)) { | |||||
if (NetworkUtils.checkNetworkAvailable(context)) { | |||||
//region 拉取物料数据 | //region 拉取物料数据 | ||||
if (ConfigName.getInstance().organizeMode == null) { | if (ConfigName.getInstance().organizeMode == null) { | ||||
return; | return; | ||||
@@ -492,7 +492,7 @@ public class ConfigData { | |||||
* @param context | * @param context | ||||
*/ | */ | ||||
public void GetGevGood(Context context, Handler mHandler) { | public void GetGevGood(Context context, Handler mHandler) { | ||||
if (NetworkUtils.isNetworkConnected(context)) { | |||||
if (NetworkUtils.checkNetworkAvailable(context)) { | |||||
if (ConfigName.getInstance().organizeMode == null) { | if (ConfigName.getInstance().organizeMode == null) { | ||||
return; | return; | ||||
} | } | ||||
@@ -502,9 +502,12 @@ public class ConfigData { | |||||
ResAPI<List<CloudGood>> allDataResAPI = response.body(); | ResAPI<List<CloudGood>> allDataResAPI = response.body(); | ||||
if (allDataResAPI.succeeded && allDataResAPI.data != null && allDataResAPI.data.size() > 0) { | if (allDataResAPI.succeeded && allDataResAPI.data != null && allDataResAPI.data.size() > 0) { | ||||
ConfigName.getInstance().cloudGoods = allDataResAPI.data; | 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; | return; | ||||
} | } | ||||
if (NetworkUtils.isNetworkConnected(context)) { | |||||
if (NetworkUtils.checkNetworkAvailable(context)) { | |||||
if (ConfigName.getInstance().organizeMode == null) { | if (ConfigName.getInstance().organizeMode == null) { | ||||
return; | return; | ||||
} | } | ||||
@@ -614,7 +617,7 @@ public class ConfigData { | |||||
*/ | */ | ||||
public void UploadGoods(Context context, String goodid) { | public void UploadGoods(Context context, String goodid) { | ||||
try { | try { | ||||
if (NetworkUtils.isNetworkConnected(context)) { | |||||
if (NetworkUtils.checkNetworkAvailable(context)) { | |||||
if (ConfigName.getInstance().organizeMode == null && ConfigName.getInstance().cloudData != null) { | if (ConfigName.getInstance().organizeMode == null && ConfigName.getInstance().cloudData != null) { | ||||
ToastUtils.warning("无组织信息不能上传,请设置当前店铺信息!!!"); | ToastUtils.warning("无组织信息不能上传,请设置当前店铺信息!!!"); | ||||
return; | return; | ||||
@@ -794,9 +797,6 @@ public class ConfigData { | |||||
if (isSuceess) { | if (isSuceess) { | ||||
try { | try { | ||||
String str=ConfigName.getInstance().SaasAddress + ConfigName.getInstance().UpdateGoods; | String str=ConfigName.getInstance().SaasAddress + ConfigName.getInstance().UpdateGoods; | ||||
//String str="http://192.168.1.64:5001/api/CommInteface/SendGoodsInfo"; | //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) { | 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(); | ResAPI<Boolean> allDataResAPI = response.body(); | ||||
if (allDataResAPI.succeeded) { | if (allDataResAPI.succeeded) { | ||||
ToastUtils.info("上传菜品成功!!!"); | ToastUtils.info("上传菜品成功!!!"); | ||||
MessageManager.getInstance().sendMessage(MessageName.ScGood, "Good"); | |||||
MessageManager.getInstance().sendMessage(MessageName.ScGood, "GoodUpdate"); | |||||
editDialog.dismiss(); | editDialog.dismiss(); | ||||
} else { | } else { | ||||
ToastUtils.warning("上传菜品失败!!!"); | ToastUtils.warning("上传菜品失败!!!"); | ||||
@@ -10,7 +10,28 @@ import android.os.Build; | |||||
* Created by LY on 2019/1/4. | * Created by LY on 2019/1/4. | ||||
*/ | */ | ||||
public class NetworkUtils { | 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以下 | * 检测当的网络(WLAN、4G/3G/2G)状态,兼容Android 6.0以下 | ||||
* @param context Context | * @param context Context | ||||
@@ -5,6 +5,7 @@ import static com.bonait.bnframework.MainApplication.getContext; | |||||
import androidx.appcompat.app.AppCompatActivity; | import androidx.appcompat.app.AppCompatActivity; | ||||
import android.annotation.SuppressLint; | import android.annotation.SuppressLint; | ||||
import android.content.Context; | |||||
import android.content.Intent; | import android.content.Intent; | ||||
import android.os.Bundle; | 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.constant.MessageName; | ||||
import com.bonait.bnframework.common.db.QueryDB; | import com.bonait.bnframework.common.db.QueryDB; | ||||
import com.bonait.bnframework.common.db.mode.BPA_GOODS; | 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.MessageLooper; | ||||
import com.bonait.bnframework.common.message.MessageManager; | import com.bonait.bnframework.common.message.MessageManager; | ||||
import com.bonait.bnframework.common.model.mode.CloudGood; | 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.QDListSectionAdapter; | ||||
import com.bonait.bnframework.modules.home.fragment.mode.SectionHeader; | 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.SectionItem; | ||||
import com.bonait.bnframework.modules.home.fragment.mode.fragment_plc; | |||||
import com.qmuiteam.qmui.widget.QMUITopBar; | import com.qmuiteam.qmui.widget.QMUITopBar; | ||||
import com.qmuiteam.qmui.widget.section.QMUISection; | import com.qmuiteam.qmui.widget.section.QMUISection; | ||||
import com.qmuiteam.qmui.widget.section.QMUIStickySectionAdapter; | import com.qmuiteam.qmui.widget.section.QMUIStickySectionAdapter; | ||||
@@ -56,6 +59,7 @@ public class CpActivity extends BaseActivity { | |||||
setContentView(R.layout.activity_cp); | setContentView(R.layout.activity_cp); | ||||
//属性绑定 | //属性绑定 | ||||
ButterKnife.bind(this); | ButterKnife.bind(this); | ||||
context=this; | |||||
initTopBar(); | initTopBar(); | ||||
initAdapter(); | initAdapter(); | ||||
initAdapterLogicalOperation(); | initAdapterLogicalOperation(); | ||||
@@ -99,9 +103,8 @@ public class CpActivity extends BaseActivity { | |||||
mSectionLayout.setAdapter(mAdapter, true); | mSectionLayout.setAdapter(mAdapter, true); | ||||
ConfigData.getInstance().GetGevGood(this, mHandler); | ConfigData.getInstance().GetGevGood(this, mHandler); | ||||
mAdapter.setData(getList()); | mAdapter.setData(getList()); | ||||
mAdapter.refreshCustomData(); | |||||
} | } | ||||
Context context; | |||||
@SuppressLint("HandlerLeak") | @SuppressLint("HandlerLeak") | ||||
private Handler mHandler = new Handler() { | private Handler mHandler = new Handler() { | ||||
@Override | @Override | ||||
@@ -123,7 +126,7 @@ public class CpActivity extends BaseActivity { | |||||
SectionItem item = (SectionItem) msg; | SectionItem item = (SectionItem) msg; | ||||
QueryDB.DeleteGoodsid(item.getAccount()); | QueryDB.DeleteGoodsid(item.getAccount()); | ||||
QueryDB.DeleteGoodsSrecipeList(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) { | public void onMessage(Object msg) { | ||||
if (msg != null) { | if (msg != null) { | ||||
mAdapter.setData(new ArrayList<QMUISection<SectionHeader, SectionItem>>()); | mAdapter.setData(new ArrayList<QMUISection<SectionHeader, SectionItem>>()); | ||||
//mAdapter.setDataWithoutDiff(getList(),true); | |||||
mAdapter.setData(getList()); | mAdapter.setData(getList()); | ||||
} | } | ||||
} | } | ||||
@@ -143,7 +143,7 @@ public class SystemSeasoningsetFragment extends BaseFragment implements MyClickL | |||||
break; | break; | ||||
case R.id.synchronous://同步云端 | case R.id.synchronous://同步云端 | ||||
if (NetworkUtils.isNetworkConnected(context)) { | |||||
if (NetworkUtils.checkNetworkAvailable(context)) { | |||||
final QMUIDialog.EditTextDialogBuilder builder = new QMUIDialog.EditTextDialogBuilder(context); | final QMUIDialog.EditTextDialogBuilder builder = new QMUIDialog.EditTextDialogBuilder(context); | ||||
builder.setTitle("密码确认") | builder.setTitle("密码确认") | ||||
.setPlaceholder("在此输入权限密码") | .setPlaceholder("在此输入权限密码") | ||||