Commit 9427843b by Wyh

Merge branch 'dev' into wyh_local

parents 9df2778e 1a951bc8
......@@ -4,9 +4,11 @@ buildscript {
ext.kotlin_version = '1.4.21'
repositories {
// 添加阿里云 maven 地址
maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter' }
// jcenter()
google()
jcenter()
mavenCentral()
}
dependencies {
......@@ -37,6 +39,11 @@ buildscript {
allprojects {
repositories {
// 添加阿里云 maven 地址
maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter' }
// jcenter()
google()
jcenter()
mavenLocal()
......@@ -50,8 +57,6 @@ allprojects {
maven {url 'https://storage.googleapis.com/r8-releases/raw'}
//阿里云仓库
maven { url "http://maven.aliyun.com/nexus/content/repositories/releases" }
maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter' }
maven { url 'http://maven.aliyun.com/nexus/content/repositories/google' }
maven { url 'http://maven.aliyun.com/nexus/content/repositories/gradle-plugin' }
}
......
......@@ -41,8 +41,7 @@ import com.gingersoft.gsa.cloud.common.constans.ExpandConstant;
import com.gingersoft.gsa.cloud.common.core.restaurant.RestaurantInfoManager;
import com.gingersoft.gsa.cloud.common.core.restaurant.utils.RestaurantExpandInfoUtils;
import com.gingersoft.gsa.cloud.common.logan.LoganManager;
import com.gingersoft.gsa.cloud.common.service.DataNotificationService;
import com.gingersoft.gsa.cloud.common.utils.log.LogUtil;
import com.gingersoft.gsa.cloud.common.service.ICommandService;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.gsa.cloud.common.utils.toast.ToastUtils;
import com.gingersoft.gsa.cloud.ui.utils.AppDialog;
......@@ -204,7 +203,7 @@ public class ColdChainMainActivity extends BaseFragmentActivity<ColdChainMainPre
private void initService() {
//開啟websocket
Intent intent = new Intent(getApplicationContext(), DataNotificationService.class);
Intent intent = new Intent(getApplicationContext(), ICommandService.class);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
startForegroundService(intent);
} else {
......@@ -219,13 +218,13 @@ public class ColdChainMainActivity extends BaseFragmentActivity<ColdChainMainPre
registerReceiver(clearHeartBroadcastReceiver, intentFilter);
}
private DataNotificationService.MyBind bind = null;
private ICommandService.MyBind bind = null;
private long lastMsgTime = 0;
private ServiceConnection serviceConnection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
bind = (DataNotificationService.MyBind) service;
bind = (ICommandService.MyBind) service;
if (bind != null) {
bind.setOnPostCallBack(type -> {
// -1斷開連接,\n-2:消息傳輸錯誤,\n0:連接消息,\n1:登錄通知,\n2:登出通知,\n3:外賣送單通知,\n4:自取送單通知,\n5:歷史訂單通知,\n6:修改訂單狀態通知,\n7:支付成功通知"
......
......@@ -28,7 +28,7 @@
</intent-filter>
</activity>
<service android:name="com.gingersoft.gsa.cloud.common.service.DataNotificationService" />
<service android:name="com.gingersoft.gsa.cloud.common.service.ICommandService" />
<meta-data
android:name="com.gingersoft.gsa.cloud.common.config.globalconfig.GlobalConfiguration"
......
......@@ -7,7 +7,7 @@ import com.billy.cc.core.component.CCResult;
import com.billy.cc.core.component.CCUtil;
import com.billy.cc.core.component.IComponent;
import com.gingersoft.gsa.cloud.component.ComponentName;
import com.gingersoft.gsa.cloud.common.service.DataNotificationService;
import com.gingersoft.gsa.cloud.common.service.ICommandService;
import com.gingersoft.gsa.delivery_pick_mode.data.network.ServiceCreator;
import com.gingersoft.gsa.delivery_pick_mode.mvp.ui.activity.PrjQueryActivity;
import com.gingersoft.gsa.delivery_pick_mode.mvp.ui.activity.SendOrderActivity;
......@@ -52,7 +52,7 @@ public class DeliveryPickComponent implements IComponent {
CC.sendCCResult(cc.getCallId(), CCResult.success());
break;
case "closeHeart":
Intent intent = new Intent(cc.getContext(), DataNotificationService.class);
Intent intent = new Intent(cc.getContext(), ICommandService.class);
cc.getContext().stopService(intent);
break;
case "historyActivity":
......
......@@ -22,7 +22,7 @@ import com.gingersoft.gsa.cloud.common.core.delivery.OrderDetails.Companion.veri
import com.gingersoft.gsa.cloud.common.core.restaurant.RestaurantInfoManager
import com.gingersoft.gsa.cloud.common.core.user.UserContext
import com.gingersoft.gsa.cloud.common.logan.LoganManager
import com.gingersoft.gsa.cloud.common.service.DataNotificationService
import com.gingersoft.gsa.cloud.common.service.ICommandService
import com.gingersoft.gsa.cloud.common.utils.gson.GsonUtils
import com.gingersoft.gsa.cloud.common.utils.okhttpUtils.OkHttp3Utils
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil
......@@ -549,8 +549,8 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
}, { e ->
listener.invoke(getMsgBean(0, "", false))
e.printStackTrace()
DataNotificationService.loginfo.append("錯誤信息111:" + e.message + " LOCALIZEDMESSAGE:" + e.localizedMessage + e.cause)
DataNotificationService.loginfo.append("\n")
ICommandService.loginfo.append("錯誤信息111:" + e.message + " LOCALIZEDMESSAGE:" + e.localizedMessage + e.cause)
ICommandService.loginfo.append("\n")
})
}
......@@ -690,12 +690,12 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
//添加PRJ
//單獨包起來,哪怕這接口報錯也不要影響到正常的邏輯
repository.addPrj(dataBean.Order_ID.toString(), restaurantId.toString(), ids.toString())
DataNotificationService.loginfo.append("添加PRJ:orderId:" + dataBean.Order_ID.toString() + "restaurantId:" + restaurantId + "orderDetailsIds:" + ids.toString())
DataNotificationService.loginfo.append("\n")
ICommandService.loginfo.append("添加PRJ:orderId:" + dataBean.Order_ID.toString() + "restaurantId:" + restaurantId + "orderDetailsIds:" + ids.toString())
ICommandService.loginfo.append("\n")
}, {
it.printStackTrace()
DataNotificationService.loginfo.append("錯誤信息222:" + it.message + " LOCALIZEDMESSAGE:" + it.localizedMessage + it.cause)
DataNotificationService.loginfo.append("\n")
ICommandService.loginfo.append("錯誤信息222:" + it.message + " LOCALIZEDMESSAGE:" + it.localizedMessage + it.cause)
ICommandService.loginfo.append("\n")
})
}
if (isPrintBill) {
......
......@@ -28,7 +28,7 @@ import com.gingersoft.gsa.cloud.common.constans.FunctionManagerConstants
import com.gingersoft.gsa.cloud.common.core.restaurant.RestaurantInfoManager
import com.gingersoft.gsa.cloud.common.core.restaurant.utils.RestaurantExpandInfoUtils
import com.gingersoft.gsa.cloud.common.function.FunctionManager
import com.gingersoft.gsa.cloud.common.service.DataNotificationService
import com.gingersoft.gsa.cloud.common.service.ICommandService
import com.gingersoft.gsa.cloud.common.service.PostCallBack
import com.gingersoft.gsa.cloud.common.utils.other.SPUtils
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil
......@@ -79,7 +79,7 @@ class DeliveryOrderMainActivity : BaseActivity<IPresenter>(), View.OnClickListen
private var layoutHeight: Float = 0F
private var btnHeight: Float = 0F
var bind: DataNotificationService.MyBind? = null
var bind: ICommandService.MyBind? = null
//最後一次長連接過來的消息類型
var lastMsgType: Int = 0
......@@ -392,7 +392,7 @@ class DeliveryOrderMainActivity : BaseActivity<IPresenter>(), View.OnClickListen
*/
private fun initWebSocket() {
//開啟webSocket
val service = Intent(applicationContext, DataNotificationService::class.java)
val service = Intent(applicationContext, ICommandService::class.java)
val notification: NotificationManagerCompat = NotificationManagerCompat.from(this)
if (!notification.areNotificationsEnabled()) {
//未開啟通知權限
......@@ -444,7 +444,7 @@ class DeliveryOrderMainActivity : BaseActivity<IPresenter>(), View.OnClickListen
private var serviceConnection = object : ServiceConnection {
override fun onServiceConnected(name: ComponentName, service: IBinder) {
bind = service as DataNotificationService.MyBind
bind = service as ICommandService.MyBind
bind?.let { it ->
it.setOnPostCallBack(object : PostCallBack {
override fun callBack(type: Int) {
......
......@@ -3,7 +3,7 @@ package com.gingersoft.gsa.delivery_pick_mode.ui.activity;
import android.os.Bundle;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import com.gingersoft.gsa.cloud.common.service.DataNotificationService;
import com.gingersoft.gsa.cloud.common.service.ICommandService;
import com.gingersoft.gsa.delivery_pick_mode.R;
public class LogActivity extends AppCompatActivity {
......@@ -14,13 +14,13 @@ public class LogActivity extends AppCompatActivity {
setContentView(R.layout.activity_log);
loadInfo();
findViewById(R.id.btn_clear_log).setOnClickListener(v -> {
DataNotificationService.loginfo.setLength(0);
ICommandService.loginfo.setLength(0);
loadInfo();
});
findViewById(R.id.btn_back).setOnClickListener(v ->finish());
}
private void loadInfo() {
((TextView) findViewById(R.id.tv_log)).setText(DataNotificationService.loginfo.toString());
((TextView) findViewById(R.id.tv_log)).setText(ICommandService.loginfo.toString());
}
}
......@@ -76,6 +76,7 @@ import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers;
import me.jessyan.rxerrorhandler.core.RxErrorHandler;
import me.jessyan.rxerrorhandler.handler.ErrorHandleSubscriber;
import me.jessyan.rxerrorhandler.handler.RetryWithDelay;
/**
......@@ -207,6 +208,7 @@ public class DownloadPresenter extends BasePresenter<DownloadContract.Model, Dow
private void downDataRequest(Observable observable, int downIndex) {
observable
.subscribeOn(Schedulers.io())
.retryWhen(new RetryWithDelay(5, 2))
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
......
......@@ -69,11 +69,11 @@ public class DataDownLoadAdapter extends DefaultAdapter<DataDownLoadState> {
pb_progress.setVisibility(View.GONE);
break;
case 1:
iv_state.setImageDrawable(mContext.getResources().getDrawable(R.drawable.ic_down_load_download));
iv_state.setImageDrawable(mContext.getResources().getDrawable(R.drawable.ic_down_load_download2));
pb_progress.setVisibility(View.VISIBLE);
break;
case 2:
iv_state.setImageDrawable(mContext.getResources().getDrawable(R.drawable.ic_down_load_success));
iv_state.setImageDrawable(mContext.getResources().getDrawable(R.drawable.ic_down_load_success2));
pb_progress.setVisibility(View.GONE);
break;
}
......
package com.gingersoft.gsa.cloud.login.mvp.ui.activity.mvp.ui.activity;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
......@@ -14,8 +15,10 @@ import android.view.Window;
import android.view.WindowManager;
import android.widget.CheckBox;
import android.widget.ImageView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.gingersoft.gsa.cloud.common.core.login.LoginBean;
import com.gingersoft.gsa.cloud.common.core.user.UserConstans;
import com.gingersoft.gsa.cloud.common.utils.encryption.Aes;
......@@ -30,6 +33,9 @@ import com.gingersoft.gsa.cloud.login.mvp.contract.LoginInterfaceImpl;
import com.gingersoft.gsa.cloud.login.mvp.presenter.LoginPresenter;
import com.gingersoft.gsa.cloud.ui.widget.dialog.LoadingDialog;
import com.google.android.material.textfield.TextInputEditText;
import com.gyf.immersionbar.BarHide;
import com.gyf.immersionbar.ImmersionBar;
import com.gyf.immersionbar.OnKeyboardListener;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.integration.AppManager;
import com.jess.arms.utils.ArmsUtils;
......@@ -44,8 +50,11 @@ import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
import javax.inject.Inject;
import butterknife.BindView;
import butterknife.OnClick;
import me.jessyan.autosize.utils.LogUtils;
import static com.jess.arms.utils.Preconditions.checkNotNull;
......@@ -111,10 +120,17 @@ public class LoginActivity extends LoginInterfaceImpl<LoginPresenter> implements
return true;
}
@SuppressLint("ResourceType")
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
StatusBarUtil.setColor(this,Color.parseColor("#E7F2FF"));
ImmersionBar.with(this)
.statusBarColor("#E7F2FF") //状态栏颜色,不写默认透明色
.statusBarDarkFont(true) //原理:如果当前设备支持状态栏字体变色,会设置状态栏字体为黑色,如果当前设备不支持
.fitsSystemWindows(true)
// .fullScreen(true)
.init();
}
@Override
......@@ -122,7 +138,7 @@ public class LoginActivity extends LoginInterfaceImpl<LoginPresenter> implements
((ImageView) findViewById(R.id.iv_top_bg)).setAdjustViewBounds(true);
mPresenter.requestExternalStoragePermission();
//顯示記住的登錄名
if (!Objects.equals(SPUtils.get( UserConstans.LOGIN_USERNAME, ""), "")) {
if (!Objects.equals(SPUtils.get(UserConstans.LOGIN_USERNAME, ""), "")) {
edAccount.setText("" + SPUtils.get(UserConstans.LOGIN_USERNAME, ""));
mRbRememberPwd.setChecked(true);
}
......
......@@ -21,12 +21,14 @@ import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.viewpager2.widget.ViewPager2;
import com.billy.cc.core.component.CC;
import com.gingersoft.gsa.cloud.common.bean.BaseResult;
import com.gingersoft.gsa.cloud.common.bean.BaseResultOld;
import com.gingersoft.gsa.cloud.common.core.login.LoginBean;
import com.gingersoft.gsa.cloud.common.core.restaurant.RestaurantInfoManager;
import com.gingersoft.gsa.cloud.common.core.user.UserConstans;
import com.gingersoft.gsa.cloud.common.core.user.UserContext;
import com.gingersoft.gsa.cloud.common.core.user.state.LoginedState;
import com.gingersoft.gsa.cloud.common.utils.encryption.Aes;
import com.gingersoft.gsa.cloud.common.utils.other.SPUtils;
import com.gingersoft.gsa.cloud.login.R;
......@@ -39,6 +41,7 @@ import com.gingersoft.gsa.cloud.login.mvp.contract.WelcomeContract;
import com.gingersoft.gsa.cloud.login.mvp.presenter.WelcomePresenter;
import com.gingersoft.gsa.cloud.login.mvp.ui.adapter.GuideAdapter;
import com.gingersoft.gsa.cloud.ui.widget.Indicator.UIndicator;
import com.gyf.immersionbar.ImmersionBar;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;
import com.jess.arms.utils.StatusBarUtil;
......@@ -86,7 +89,7 @@ public class WelcomeActivity extends LoginInterfaceImpl<WelcomePresenter> implem
@Override
public int getStatusBarColor() {
return ArmsUtils.getColor(this,R.color.theme_white_color);
return ArmsUtils.getColor(this, R.color.theme_white_color);
}
@Override
......@@ -97,7 +100,12 @@ public class WelcomeActivity extends LoginInterfaceImpl<WelcomePresenter> implem
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
StatusBarUtil.setColor(this,ArmsUtils.getColor(mContext,R.color.theme_white_color));
ImmersionBar.with(this)
.statusBarColor(R.color.theme_white_color) //状态栏颜色,不写默认透明色
.statusBarDarkFont(true) //原理:如果当前设备支持状态栏字体变色,会设置状态栏字体为黑色,如果当前设备不支持
.fitsSystemWindows(true)
// .fullScreen(true)
.init();
}
@Override
......@@ -126,11 +134,22 @@ public class WelcomeActivity extends LoginInterfaceImpl<WelcomePresenter> implem
} else {
boolean isLogin = (boolean) SPUtils.get(UserConstans.AUTO_LOGIN, false);
if (isLogin) {
if (!TextUtils.isEmpty(UserContext.newInstance().getLoginToken()) && RestaurantInfoManager.newInstance().getRestaurantId() != 0) {
//自動登陸
String pwd = Aes.aesDecrypt((String) SPUtils.get(UserConstans.LOGIN_PASSWORD, ""));
mPresenter.login(SPUtils.get(UserConstans.LOGIN_USERNAME, "") + "", pwd);
UserContext.newInstance().setState(new LoginedState());
int restaurantId = RestaurantInfoManager.newInstance().getRestaurantId();
if (restaurantId != 0) {
//已经选择过餐厅 直接进入
jumpDownloadActivity();
return;
}
//调整选择餐厅页面
Intent intent = new Intent(mContext, ChooseRestaurantActivity.class);
Class clazz = getClass();
intent.putExtra("form", clazz.getName());
launchActivity(intent);
} else {
startActivity(new Intent(mContext, LoginActivity.class));
}
......@@ -145,9 +164,21 @@ public class WelcomeActivity extends LoginInterfaceImpl<WelcomePresenter> implem
}
});
guideBeanList.add(new GuideBean("多終端雲同步,輕鬆管理所有", "為您搭建優良高效管理平台", getResources().getDrawable(R.mipmap.pic_guide_one)));
guideBeanList.add(new GuideBean("數據分析可視化", "數據統計一目了然,直觀看到數據變化趨勢", getResources().getDrawable(R.mipmap.pic_guide_two)));
guideBeanList.add(new GuideBean("多種點餐方式", "提供方便快捷的點餐服務,減低落錯單機會", getResources().getDrawable(R.mipmap.pic_guide_three)));
guideBeanList.add(new
GuideBean("多終端雲同步,輕鬆管理所有", "為您搭建優良高效管理平台", getResources().
getDrawable(R.mipmap.pic_guide_one)));
guideBeanList.add(new
GuideBean("數據分析可視化", "數據統計一目了然,直觀看到數據變化趨勢", getResources().
getDrawable(R.mipmap.pic_guide_two)));
guideBeanList.add(new
GuideBean("多種點餐方式", "提供方便快捷的點餐服務,減低落錯單機會", getResources().
getDrawable(R.mipmap.pic_guide_three)));
GuideAdapter adapter = new GuideAdapter(mContext, guideBeanList);
mVpGuide.setAdapter(adapter);
//设置一个缩放动画
......@@ -156,6 +187,15 @@ public class WelcomeActivity extends LoginInterfaceImpl<WelcomePresenter> implem
@Override
public void onPageSelected(int position) {
super.onPageSelected(position);
ImmersionBar.with(WelcomeActivity.this)
.statusBarColor(R.color.theme_color) //状态栏颜色,不写默认透明色
.statusBarDarkFont(true) //原理:如果当前设备支持状态栏字体变色,会设置状态栏字体为黑色,如果当前设备不支持
.fitsSystemWindows(true)
.keyboardEnable(true)
.navigationBarColor(R.color.red)
.init();
updateUI(position);
if (++position == guideBeanList.size() && mTvExperience.getVisibility() != View.VISIBLE) {
//當前選中最後一個page,顯示進入按鈕
......
......@@ -4,10 +4,16 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="@dimen/dp_30"
android:background="@color/theme_white_color"/>
<RelativeLayout
android:id="@+id/content_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="@dimen/dp_30"
android:background="@color/theme_white_color">
<TextView
......
......@@ -12,6 +12,11 @@
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="@dimen/dp_50"
android:background="#E7F2FF"/>
<ImageView
android:id="@+id/iv_top_bg"
android:layout_width="match_parent"
......
......@@ -20,8 +20,8 @@
<activity android:name=".mvp.ui.activity.menu.ShellActivity" />
<activity
android:name=".mvp.ui.activity.menu.FoodMenuManageActivity"
android:launchMode="singleTask"
android:alwaysRetainTaskState="true" />
android:alwaysRetainTaskState="true"
android:launchMode="singleTask" />
<activity android:name=".mvp.ui.activity.ExpandListActivity" />
<activity android:name=".mvp.ui.activity.RestaurantQrCodeActivity" />
<activity android:name=".mvp.ui.activity.LanguageActivity" />
......
......@@ -12,6 +12,7 @@ import com.gingersoft.gsa.cloud.common.logan.LoganManager;
import com.gingersoft.gsa.cloud.component.ComponentAction;
import com.gingersoft.gsa.cloud.component.ComponentName;
import com.gingersoft.gsa.cloud.common.function.FModule;
import com.gingersoft.gsa.cloud.main.mvp.ui.activity.MainActivity;
import com.gingersoft.gsa.cloud.main.mvp.ui.activity.NewMainActivity;
import com.gingersoft.gsa.cloud.main.mvp.ui.activity.SettlementReportActivity;
import com.gingersoft.gsa.cloud.main.mvp.ui.activity.menu.FoodMenuManageActivity;
......
package com.gingersoft.gsa.cloud.main.di.component;
import dagger.BindsInstance;
import dagger.Component;
import com.jess.arms.di.component.AppComponent;
import com.gingersoft.gsa.cloud.main.di.module.ReportListModule;
import com.gingersoft.gsa.cloud.main.mvp.contract.ReportListContract;
import com.gingersoft.gsa.cloud.main.mvp.ui.fragment.ReportListFragment;
import com.jess.arms.di.scope.FragmentScope;
/**
* ================================================
* Description:
* <p>
* Created by MVPArmsTemplate on 03/27/2021 12:07
* <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
* <a href="https://github.com/JessYanCoding">Follow me</a>
* <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
* <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
* <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
* ================================================
*/
@FragmentScope
@Component(modules = ReportListModule.class, dependencies = AppComponent.class)
public interface ReportListComponent {
void inject(ReportListFragment fragment);
@Component.Builder
interface Builder {
@BindsInstance
ReportListComponent.Builder view(ReportListContract.View view);
ReportListComponent.Builder appComponent(AppComponent appComponent);
ReportListComponent build();
}
}
\ No newline at end of file
package com.gingersoft.gsa.cloud.main.di.module;
import com.jess.arms.di.scope.ActivityScope;
import dagger.Binds;
import dagger.Module;
import dagger.Provides;
import com.gingersoft.gsa.cloud.main.mvp.contract.ReportListContract;
import com.gingersoft.gsa.cloud.main.mvp.model.ReportListModel;
/**
* ================================================
* Description:
* <p>
* Created by MVPArmsTemplate on 03/27/2021 12:07
* <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
* <a href="https://github.com/JessYanCoding">Follow me</a>
* <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
* <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
* <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
* ================================================
*/
@Module
public abstract class ReportListModule {
@Binds
abstract ReportListContract.Model bindReportListModel(ReportListModel model);
}
\ No newline at end of file
package com.gingersoft.gsa.cloud.main.mvp.contract;
import com.gingersoft.gsa.cloud.common.bean.BaseResult;
import com.gingersoft.gsa.cloud.main.mvp.model.bean.CheckVersionRequest;
import com.gingersoft.gsa.cloud.main.mvp.model.bean.HomeTurnoverBean;
import com.gingersoft.gsa.cloud.main.mvp.model.bean.MainBusinessBean;
import com.jess.arms.mvp.IView;
import com.jess.arms.mvp.IModel;
import com.tbruyelle.rxpermissions2.RxPermissions;
import java.util.Map;
......@@ -26,7 +29,9 @@ import okhttp3.RequestBody;
public interface HomeContract {
//对于经常使用的关于UI的方法可以定义到IView中,如显示隐藏进度条,和显示文字消息
interface View extends IView {
void loadBusinessInfo(Map<String, HomeTurnoverBean.DataBean> data);
void loginOut();
RxPermissions getRxPermissions();
}
//Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
......@@ -34,5 +39,17 @@ public interface HomeContract {
Observable<MainBusinessBean> getRestaurantReport(RequestBody requestBody);
Observable<String> getRestaurantFunList(String restaurantId);
Observable<BaseResult> syncRestaurantExtendedConfiguration(int restaurantId);
Observable<CheckVersionRequest> checkAppVersion(String version);
Observable<Object> loginOut(RequestBody requestBody);
Observable<Object> clearHeartbeat(RequestBody requestBody);
Observable<BaseResult> addSettlementOperation();
Observable<BaseResult> updateSettlementOperation(RequestBody requestBody);
}
}
package com.gingersoft.gsa.cloud.main.mvp.contract;
import com.jess.arms.mvp.IView;
import com.jess.arms.mvp.IModel;
/**
* ================================================
* Description:
* <p>
* Created by MVPArmsTemplate on 03/27/2021 12:07
* <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
* <a href="https://github.com/JessYanCoding">Follow me</a>
* <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
* <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
* <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
* ================================================
*/
public interface ReportListContract {
//对于经常使用的关于UI的方法可以定义到IView中,如显示隐藏进度条,和显示文字消息
interface View extends IView {
}
//Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
interface Model extends IModel{
}
}
......@@ -2,9 +2,12 @@ package com.gingersoft.gsa.cloud.main.mvp.model;
import android.app.Application;
import com.gingersoft.gsa.cloud.common.bean.BaseResult;
import com.gingersoft.gsa.cloud.main.mvp.contract.HomeContract;
import com.gingersoft.gsa.cloud.main.mvp.model.bean.CheckVersionRequest;
import com.gingersoft.gsa.cloud.main.mvp.model.bean.MainBusinessBean;
import com.gingersoft.gsa.cloud.main.mvp.model.service.MainReportService;
import com.gingersoft.gsa.cloud.main.mvp.model.service.MainService;
import com.google.gson.Gson;
import com.jess.arms.di.scope.FragmentScope;
import com.jess.arms.integration.IRepositoryManager;
......@@ -60,4 +63,40 @@ public class HomeModel extends BaseModel implements HomeContract.Model {
return mRepositoryManager.obtainRetrofitService(MainReportService.class)
.getRestaurantFunList(restaurantId);
}
@Override
public Observable<BaseResult> syncRestaurantExtendedConfiguration(int restaurantId) {
return mRepositoryManager.obtainRetrofitService(MainService.class)
.syncRestaurantExtendedConfiguration(restaurantId);
}
@Override
public Observable<CheckVersionRequest> checkAppVersion(String version) {
return mRepositoryManager.obtainRetrofitService(MainService.class)
.checkAppVersion(version);
}
@Override
public Observable<Object> loginOut(RequestBody requestBody) {
return mRepositoryManager.obtainRetrofitService(MainService.class)
.loginOut(requestBody);
}
@Override
public Observable<Object> clearHeartbeat(RequestBody requestBody) {
return mRepositoryManager.obtainRetrofitService(MainService.class)
.clearHeartbeat(requestBody);
}
@Override
public Observable<BaseResult> addSettlementOperation() {
return mRepositoryManager.obtainRetrofitService(MainService.class)
.addSettlementOperation();
}
@Override
public Observable<BaseResult> updateSettlementOperation(RequestBody requestBody) {
return mRepositoryManager.obtainRetrofitService(MainService.class)
.updateSettlementOperation(requestBody);
}
}
\ No newline at end of file
package com.gingersoft.gsa.cloud.main.mvp.model;
import android.app.Application;
import com.google.gson.Gson;
import com.jess.arms.di.scope.FragmentScope;
import com.jess.arms.integration.IRepositoryManager;
import com.jess.arms.mvp.BaseModel;
import com.jess.arms.di.scope.ActivityScope;
import javax.inject.Inject;
import com.gingersoft.gsa.cloud.main.mvp.contract.ReportListContract;
/**
* ================================================
* Description:
* <p>
* Created by MVPArmsTemplate on 03/27/2021 12:07
* <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
* <a href="https://github.com/JessYanCoding">Follow me</a>
* <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
* <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
* <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
* ================================================
*/
@FragmentScope
public class ReportListModel extends BaseModel implements ReportListContract.Model{
@Inject
Gson mGson;
@Inject
Application mApplication;
@Inject
public ReportListModel(IRepositoryManager repositoryManager) {
super(repositoryManager);
}
@Override
public void onDestroy() {
super.onDestroy();
this.mGson = null;
this.mApplication = null;
}
}
\ No newline at end of file
package com.gingersoft.gsa.cloud.main.mvp.model.bean;
import android.graphics.drawable.Drawable;
import lombok.Data;
/**
* @作者: bin
* @創建時間: 2021-03-27 16:48
* @更新時間: 2021-03-27 16:48
* @描述:
*/
@Data
public class ReportListItem {
private Drawable reportDrawable;
private String reportName;
private String reportUrl;
public ReportListItem(Drawable reportDrawable, String reportName, String reportUrl) {
this.reportDrawable = reportDrawable;
this.reportName = reportName;
this.reportUrl = reportUrl;
}
}
package com.gingersoft.gsa.cloud.main.mvp.presenter;
import android.app.Application;
import android.content.Intent;
import android.net.Uri;
import android.text.TextUtils;
import com.billy.cc.core.component.CC;
import com.gingersoft.gsa.cloud.common.bean.BaseResult;
import com.gingersoft.gsa.cloud.common.constans.HttpsConstans;
import com.gingersoft.gsa.cloud.common.core.restaurant.RestaurantInfoManager;
import com.gingersoft.gsa.cloud.common.utils.gson.GsonUtils;
import com.gingersoft.gsa.cloud.common.utils.time.TimeUtils;
import com.gingersoft.gsa.cloud.common.webview.WebviewHelper;
import com.gingersoft.gsa.cloud.component.ComponentName;
import com.gingersoft.gsa.cloud.main.mvp.contract.HomeContract;
import com.gingersoft.gsa.cloud.main.mvp.model.bean.CheckVersionRequest;
import com.gingersoft.gsa.cloud.main.mvp.model.bean.MainBusinessBean;
import com.gingersoft.gsa.cloud.main.mvp.ui.activity.MainActivity;
import com.gingersoft.gsa.cloud.main.mvp.ui.activity.NewMainActivity;
import com.gingersoft.gsa.cloud.main.mvp.ui.fragment.HomeFragment;
import com.gingersoft.gsa.cloud.pay.pos.OnPosActionListener;
import com.gingersoft.gsa.cloud.pay.pos.PosPay;
import com.gingersoft.gsa.cloud.pay.pos.hywebpos.bean.response.pos.HywebPosResponse;
import com.jess.arms.di.scope.FragmentScope;
import com.jess.arms.http.imageloader.ImageLoader;
import com.jess.arms.integration.AppManager;
import com.jess.arms.mvp.BasePresenter;
import com.jess.arms.utils.DeviceUtils;
import com.jess.arms.utils.RxLifecycleUtils;
import javax.inject.Inject;
......@@ -22,6 +39,9 @@ import me.jessyan.rxerrorhandler.core.RxErrorHandler;
import me.jessyan.rxerrorhandler.handler.ErrorHandleSubscriber;
import okhttp3.FormBody;
import okhttp3.RequestBody;
import util.UpdateAppUtils;
import static com.jess.arms.utils.ArmsUtils.startActivity;
/**
......@@ -47,9 +67,13 @@ public class HomePresenter extends BasePresenter<HomeContract.Model, HomeContrac
@Inject
AppManager mAppManager;
private MainActivity IActivity;
@Inject
public HomePresenter(HomeContract.Model model, HomeContract.View rootView) {
super(model, rootView);
HomeFragment homeFragment = (HomeFragment) rootView;;
this.IActivity = (MainActivity) homeFragment.getActivity();
}
@Override
......@@ -120,4 +144,245 @@ public class HomePresenter extends BasePresenter<HomeContract.Model, HomeContrac
});
}
public void syncRestaurantExtendedConfiguration() {
mModel.syncRestaurantExtendedConfiguration(RestaurantInfoManager.newInstance().getRestaurantId())
.subscribeOn(Schedulers.io())
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.subscribe(new ErrorHandleSubscriber<BaseResult>(mErrorHandler) {
@Override
public void onNext(@NonNull BaseResult result) {
if (result != null) {
} else {
}
}
});
}
public void checkAppVersion() {
// RequestBody requestBody = new FormBody.Builder()
// .add("version", )
// .add("type", "2")
// .build();
mModel.checkAppVersion(DeviceUtils.getVersionName(mApplication) + "|" + DeviceUtils.getVersionCode(mApplication))
.subscribeOn(Schedulers.io())
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.subscribe(new ErrorHandleSubscriber<CheckVersionRequest>(mErrorHandler) {
@Override
public void onNext(@NonNull CheckVersionRequest info) {
if (info != null) {
/**
* 操作类型:
* 1、不提示更新
* 2、提示更新可选择更新
* 3、强行更新
* 4、跳转goole play下载app 没安装goole play就用webview打开goole网页下载
* 5、跳转goole play下载app 没安装goole play就用浏览器打开goole网页下载
*/
int operate = info.getOperate();
if (operate == 2 || operate == 3 || operate == 4 || operate == 5) {
String updatePath = info.getUpdatePath();
if (!TextUtils.isEmpty(updatePath) && !updatePath.equals("null")) {
updateAPK(operate, updatePath);
} else {
if (operate == 3) {
mAppManager.appExit();
}
}
}
} else {
}
}
});
}
public void loginOut() {
RequestBody requestBody = new FormBody.Builder()
.add("type", "2")
.build();
clearHeartbeat();
mModel.loginOut(requestBody)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(null))
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> mRootView.hideLoading())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.subscribe(new ErrorHandleSubscriber<Object>(mErrorHandler) {
@Override
public void onNext(@NonNull Object info) {
mRootView.loginOut();
}
@Override
public void onError(Throwable t) {
super.onError(t);
mRootView.loginOut();
}
});
}
public void addSettlementOperation(int restaurantId) {
RequestBody requestBody = new FormBody.Builder()
.add("restaurantId", String.valueOf(restaurantId))
.build();
mModel.addSettlementOperation()
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading("調起POS清機中..."))
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> mRootView.hideLoading())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.subscribe(new ErrorHandleSubscriber<BaseResult>(mErrorHandler) {
@Override
public void onNext(@NonNull BaseResult info) {
if (info != null && info.isSuccess()) {
if (info.getData() != null) {
PosPay.settlement(IActivity, IActivity, new OnPosActionListener() {
@Override
public void onPosSuccess(HywebPosResponse response) {
mRootView.showMessage("清機成功!");
updateSettlementOperation(restaurantId, GsonUtils.GsonString(response), 1);
}
@Override
public void onPosException(Exception e) {
mRootView.showMessage("清機Exception :" + e.getMessage());
updateSettlementOperation(restaurantId, e.getMessage(), 0);
}
@Override
public void onPosInvalid(String e) {
mRootView.showMessage(e);
updateSettlementOperation(restaurantId, e, 2);
}
@Override
public void onUpdateStatusSuccess(HywebPosResponse response) {
}
@Override
public void onUpdateStatusError(Throwable e) {
}
});
}
} else {
mRootView.showMessage("調起POS清機失敗");
}
}
@Override
public void onError(Throwable t) {
super.onError(t);
mRootView.showMessage("調起POS清機失敗: " + t.getMessage());
}
});
}
public void updateSettlementOperation(int restaurantId, String content, int status) {
RequestBody requestBody = new FormBody.Builder()
.add("restaurantId", String.valueOf(restaurantId))
.add("content", content)
.add("status", String.valueOf(status))
.build();
mModel.updateSettlementOperation(requestBody)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(null))
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> mRootView.hideLoading())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.subscribe(new ErrorHandleSubscriber<BaseResult>(mErrorHandler) {
@Override
public void onNext(@NonNull BaseResult info) {
if (info != null && info.isSuccess()) {
mRootView.showMessage("更新清機狀態成功");
} else {
mRootView.showMessage("更新清機狀態無效");
}
}
@Override
public void onError(Throwable t) {
super.onError(t);
mRootView.showMessage("更新清機狀態失敗: " + t.getMessage());
}
});
}
public void clearHeartbeat() {
RequestBody requestBody = new FormBody.Builder()
.add("restaurantId", RestaurantInfoManager.newInstance().getRestaurantId() + "")
.build();
//關閉心跳
CC.obtainBuilder(ComponentName.COMPONENT_DELIVERYPICK)
.setActionName("closeHeart")
.build()
.call();
mModel.clearHeartbeat(requestBody)
.subscribeOn(Schedulers.io())
.subscribe(new ErrorHandleSubscriber<Object>(mErrorHandler) {
@Override
public void onNext(@NonNull Object info) {
}
});
}
public void updateAPK(int type, String downApkURL) {
if (type == 4 || type == 5) {
if (type == 4) {
try {
DeviceUtils.launchAppDetail(IActivity, mApplication.getPackageName(), "com.android.vending");
} catch (Exception e) {
//跳转goole play下载app
CC.obtainBuilder(ComponentName.COMPONENT_WEBVIEW)
.setActionName("openWebActivity")
.addParam(WebviewHelper.TYPE_KEY, downApkURL)
.addParam(WebviewHelper.URL_KEY, WebviewHelper.RIGHT_TYPE_REFRESH)
.addParam(WebviewHelper.RIGHT_IMG_TYPE, WebviewHelper.RIGHT_TYPE_REFRESH)
.build()
.callAsyncCallbackOnMainThread((cc, result) -> {
});
}
} else {
try {
DeviceUtils.launchAppDetail(IActivity, mApplication.getPackageName(), "com.android.vending");
} catch (Exception e) {
Intent intent = new Intent();
intent.setAction("android.intent.action.VIEW");
Uri content_url = Uri.parse(downApkURL);
intent.setData(content_url);
startActivity(intent);
}
}
return;
}
boolean isForce = false;
if (type == 3 || type == 5) {
isForce = true;
}
UpdateAppUtils.from(IActivity)
.checkBy(UpdateAppUtils.DOWNLOAD_BY_APP) //更新检测方式,默认为VersionCode
// .serverVersionCode(DeviceUtils.getVersionCode(mApplication))
// .serverVersionName(DeviceUtils.getVersionName(mApplication))
.apkPath(downApkURL)
.showNotification(false) //是否显示下载进度到通知栏,默认为true
// .updateInfo("發現新版本,點擊下載更新") //更新日志信息 String
.downloadBy(UpdateAppUtils.DOWNLOAD_BY_APP) //下载方式:app下载、手机浏览器下载(DOWNLOAD_BY_BROWSER)。默认app下载
.isForce(isForce) //是否强制更新,默认false 强制更新情况下用户不同意更新则不能使用app
.update();
}
}
package com.gingersoft.gsa.cloud.main.mvp.presenter;
import android.app.Application;
import com.jess.arms.di.scope.FragmentScope;
import com.jess.arms.integration.AppManager;
import com.jess.arms.di.scope.ActivityScope;
import com.jess.arms.mvp.BasePresenter;
import com.jess.arms.http.imageloader.ImageLoader;
import me.jessyan.rxerrorhandler.core.RxErrorHandler;
import javax.inject.Inject;
import com.gingersoft.gsa.cloud.main.mvp.contract.ReportListContract;
/**
* ================================================
* Description:
* <p>
* Created by MVPArmsTemplate on 03/27/2021 12:07
* <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
* <a href="https://github.com/JessYanCoding">Follow me</a>
* <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
* <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
* <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
* ================================================
*/
@FragmentScope
public class ReportListPresenter extends BasePresenter<ReportListContract.Model, ReportListContract.View> {
@Inject
RxErrorHandler mErrorHandler;
@Inject
Application mApplication;
@Inject
ImageLoader mImageLoader;
@Inject
AppManager mAppManager;
@Inject
public ReportListPresenter (ReportListContract.Model model, ReportListContract.View rootView) {
super(model, rootView);
}
@Override
public void onDestroy() {
super.onDestroy();
this.mErrorHandler = null;
this.mAppManager = null;
this.mImageLoader = null;
this.mApplication = null;
}
}
......@@ -12,6 +12,7 @@ import com.gingersoft.gsa.cloud.main.mvp.contract.MainContract;
import com.gingersoft.gsa.cloud.main.mvp.presenter.MainPresenter;
import com.gingersoft.gsa.cloud.main.mvp.ui.fragment.HomeFragment;
import com.gingersoft.gsa.cloud.main.mvp.ui.fragment.MyFragment;
import com.gingersoft.gsa.cloud.main.mvp.ui.fragment.ReportListFragment;
import com.jess.arms.base.BaseFragmentActivity;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;
......@@ -26,6 +27,8 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ReportFragment;
import butterknife.BindView;
import static com.jess.arms.utils.Preconditions.checkNotNull;
......@@ -83,7 +86,7 @@ public class MainActivity extends BaseFragmentActivity<MainPresenter> implements
case 0:
return HomeFragment.newInstance();
case 1:
// return ReportFragment.newInstance();
return ReportListFragment.newInstance();
case 2:
default:
return MyFragment.newInstance();
......@@ -204,7 +207,6 @@ public class MainActivity extends BaseFragmentActivity<MainPresenter> implements
private long mExitTime;
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
......
......@@ -4,12 +4,9 @@ import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.os.Build;
import android.os.Bundle;
import android.os.IBinder;
import android.os.Message;
import android.text.TextUtils;
import android.util.SparseArray;
......@@ -38,7 +35,7 @@ import com.gingersoft.gsa.cloud.common.function.FunctionManager;
import com.gingersoft.gsa.cloud.common.function.jump.ActivityJumpBean;
import com.gingersoft.gsa.cloud.common.function.jump.ActivityJumpStrategy;
import com.gingersoft.gsa.cloud.common.logan.LoganManager;
import com.gingersoft.gsa.cloud.common.service.DataNotificationService;
import com.gingersoft.gsa.cloud.common.service.IServiceManager;
import com.gingersoft.gsa.cloud.common.utils.AppDevices;
import com.gingersoft.gsa.cloud.common.utils.JsonUtils;
import com.gingersoft.gsa.cloud.common.utils.StytemUtils;
......@@ -218,25 +215,8 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl
}
private void initService() {
// boolean deliveryOrderServiceRunning = StytemUtils.isServiceRunning("com.gingersoft.gsa.cloud.common.service.DataNotificationService", this);
// if (!deliveryOrderServiceRunning) {
// Intent service = new Intent(GsaCloudApplication.getAppContext(), DataNotificationService.class);
// service.putExtra(DataNotificationService.CONNECTION_TYPE, DataNotificationService.mCurrConnectionType);
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// startForegroundService(service);
// } else {
// startService(service);
// }
// }
boolean prjServiceRunning = StytemUtils.isServiceRunning("com.joe.print.mvp.print.service.PrjService", this);
if (!prjServiceRunning) {
//開啟Prj打印服務
CC.obtainBuilder(ComponentName.COMPONENT_PRINT)
.setActionName("openPrintService")
.build()
.call();
}
IServiceManager.startICommandService(GsaCloudApplication.getAppContext());
IServiceManager.startPrjService(GsaCloudApplication.getAppContext());
}
/**
......@@ -247,17 +227,17 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl
List<MainSideMenuBean> mainSideMenuBeans = new ArrayList<>();
if (BuildConfig.DEBUG) {
mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_setting, "複製Token"));
// mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_setting, "複製Token"));
// mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_setting, "查看日誌"));
// mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_setting, "廚房單原圖"));
mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_mall_center, "商城中心"));
// mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_mall_center, "商城中心"));
mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_about_us, "關於我們"));
mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_password, "修改密碼"));
mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_setting, "設置"));
mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_setting, "查看日誌"));
// mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_setting, "設置"));
// mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_setting, "查看日誌"));
mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_setting, "切換環境"));
}
mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_setting, "上傳日誌"));
// mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_setting, "上傳日誌"));
mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_settlement_report, "清機"));
if (AppDevices.isHywebPos()) {
mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_settlement_report, "N5清機"));
......
package com.gingersoft.gsa.cloud.main.mvp.ui.adapter;
import android.graphics.drawable.Drawable;
import android.widget.TextView;
import androidx.annotation.Nullable;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.gingersoft.gsa.cloud.main.R;
import com.gingersoft.gsa.cloud.main.mvp.model.bean.ReportListItem;
import com.gingersoft.gsa.cloud.main.mvp.model.bean.ReportListItem;
import java.util.List;
public class ReportListAdapter extends BaseQuickAdapter<ReportListItem, BaseViewHolder> {
public ReportListAdapter(@Nullable List<ReportListItem> data) {
super(R.layout.item_main_report, data);
}
@Override
protected void convert(BaseViewHolder helper, ReportListItem item) {
TextView tv_report_item = helper.findView(R.id.tv_report_item);
tv_report_item.setText(item.getReportName());
tv_report_item.setCompoundDrawables(item.getReportDrawable(),null,null,null);
}
}
package com.gingersoft.gsa.cloud.main.mvp.ui.fragment;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.util.SparseArray;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.FragmentManager;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.billy.cc.core.component.CC;
import com.gingersoft.gsa.cloud.app.GsaCloudApplication;
import com.gingersoft.gsa.cloud.common.constans.AppConstans;
import com.gingersoft.gsa.cloud.common.constans.ResultConstans;
import com.gingersoft.gsa.cloud.common.core.restaurant.RestaurantInfoManager;
import com.gingersoft.gsa.cloud.common.utils.time.TimeUtils;
import com.gingersoft.gsa.cloud.common.core.restaurant.bean.BrandsBean;
import com.gingersoft.gsa.cloud.common.core.restaurant.utils.RestaurantInfoUtils;
import com.gingersoft.gsa.cloud.common.core.user.UserContext;
import com.gingersoft.gsa.cloud.common.function.FunctionManager;
import com.gingersoft.gsa.cloud.common.function.jump.ActivityJumpBean;
import com.gingersoft.gsa.cloud.common.function.jump.ActivityJumpStrategy;
import com.gingersoft.gsa.cloud.common.leaks.WeakHandler;
import com.gingersoft.gsa.cloud.common.logan.LoganManager;
import com.gingersoft.gsa.cloud.common.service.ICommandService;
import com.gingersoft.gsa.cloud.common.utils.AppDevices;
import com.gingersoft.gsa.cloud.common.utils.JsonUtils;
import com.gingersoft.gsa.cloud.common.utils.StytemUtils;
import com.gingersoft.gsa.cloud.common.utils.encryption.Aes;
import com.gingersoft.gsa.cloud.common.utils.other.SPUtils;
import com.gingersoft.gsa.cloud.common.utils.toast.ToastUtils;
import com.gingersoft.gsa.cloud.component.ComponentName;
import com.gingersoft.gsa.cloud.database.bean.Function;
import com.gingersoft.gsa.cloud.main.BuildConfig;
import com.gingersoft.gsa.cloud.main.ComponentMain;
import com.gingersoft.gsa.cloud.main.R;
import com.gingersoft.gsa.cloud.main.R2;
import com.gingersoft.gsa.cloud.main.di.component.DaggerHomeComponent;
import com.gingersoft.gsa.cloud.main.mvp.contract.HomeContract;
import com.gingersoft.gsa.cloud.main.mvp.model.bean.HomeTurnoverBean;
import com.gingersoft.gsa.cloud.main.mvp.model.bean.MainSideMenuBean;
import com.gingersoft.gsa.cloud.main.mvp.presenter.HomePresenter;
import com.gingersoft.gsa.cloud.main.mvp.ui.adapter.HomeFunctionAdapter;
import com.gingersoft.gsa.cloud.main.mvp.ui.activity.ExpandListActivity;
import com.gingersoft.gsa.cloud.main.mvp.ui.activity.LookLogActivity;
import com.gingersoft.gsa.cloud.main.mvp.ui.activity.RestaurantQrCodeActivity;
import com.gingersoft.gsa.cloud.main.mvp.ui.activity.SettlementActivity;
import com.gingersoft.gsa.cloud.main.mvp.ui.activity.menu.FoodMenuManageActivity;
import com.gingersoft.gsa.cloud.main.mvp.ui.adapter.MainOrderingAdapter;
import com.gingersoft.gsa.cloud.main.mvp.ui.adapter.MainSideMenuAdapter;
import com.gingersoft.gsa.cloud.main.mvp.ui.view.SlidingMenu;
import com.gingersoft.gsa.cloud.ui.bean.view.SectionHeader;
import com.gingersoft.gsa.cloud.ui.bean.view.SectionNormalItem;
import com.gingersoft.gsa.cloud.ui.widget.dialog.CommonTipDialog;
import com.gingersoft.gsa.cloud.ui.widget.dialog.LoadingDialog;
import com.gyf.immersionbar.ImmersionBar;
import com.jess.arms.base.BaseFragment;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;
import com.qmuiteam.qmui.widget.QMUITopBarLayout;
import com.jess.arms.utils.DeviceUtils;
import com.lihang.ShadowLayout;
import com.qmuiteam.qmui.widget.section.QMUISection;
import com.qmuiteam.qmui.widget.section.QMUIStickySectionAdapter;
import com.qmuiteam.qmui.widget.section.QMUIStickySectionLayout;
import java.text.SimpleDateFormat;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.tbruyelle.rxpermissions2.RxPermissions;
import org.simple.eventbus.EventBus;
import org.simple.eventbus.Subscriber;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.List;
import butterknife.BindView;
import butterknife.BindViews;
import butterknife.OnClick;
import static com.jess.arms.utils.Preconditions.checkNotNull;
......@@ -55,30 +104,54 @@ import static com.jess.arms.utils.Preconditions.checkNotNull;
* ================================================
* 首頁
*/
public class HomeFragment extends BaseFragment<HomePresenter> implements HomeContract.View, View.OnClickListener {
@BindView(R2.id.main_home_bar)
QMUITopBarLayout mTopBar;
@BindView(R2.id.tv_main_home_today_turnover)
TextView tvTurnover;
@BindView(R2.id.tv_main_home_cutoff_time)
TextView tvCutoff;
@BindView(R2.id.tv_main_home_total_amount_project)
TextView tvProjectTotalAmount;
@BindView(R2.id.tv_main_home_consumers_number)
TextView tvConsumersNum;
@BindView(R2.id.tv_main_home_bill_number)
TextView tvBillNum;
@BindView(R2.id.section_layout)
QMUIStickySectionLayout mSectionLayout;
private RecyclerView.LayoutManager mLayoutManager;
private HomeFunctionAdapter mAdapter;
private String[] title = new String[]{"點餐", "管理", "員工"};
private Map<String, String[]> function = new HashMap<>();
public class HomeFragment extends BaseFragment<HomePresenter> implements HomeContract.View, View.OnClickListener , Handler.Callback{
@BindView(R2.id.rv_side_menu)
RecyclerView mRvSideMenu;
@BindView(R2.id.rv_ordering_meals)
RecyclerView rvOrdering;//點餐
@BindView(R2.id.rv_management)
RecyclerView rvManagement;//管理
@BindView(R2.id.rv_staff_management)
RecyclerView rvStaffManagement;//員工管理
// @BindView(R2.id.drawer_layout)
// DrawerLayout drawerLayout;
@BindView(R2.id.slideMenu)
SlidingMenu slideMenu;
@BindView(R2.id.layout_ordering_meals)
ShadowLayout sl_order;
@BindView(R2.id.ll_management)
LinearLayout ll_management;
@BindView(R2.id.ll_staff_management)
LinearLayout ll_staff_management;
@BindView(R2.id.tv_restaurant_name)
TextView tvRestaurantName;
@BindView(R2.id.tv_username)
TextView tvUserName;
@BindView(R2.id.tv_store_name)
TextView tvStoreName;
@BindView(R2.id.tv_version_name)
TextView tv_version_name;
@BindView(R2.id.qm_refresh)
SmartRefreshLayout refresh;
@BindViews({R2.id.tv_function_name1, R2.id.tv_function_name2, R2.id.tv_function_name3})
TextView[] mTvFunctionNames;
// @XFunctionViews(value = FunctionMain.ORDER_GROUP, filterParent = false)
// private List<Function> mOrderingMeals = new ArrayList<>();
// @XFunctionViews(value = FunctionMain.MANAGER_GROUP, filterParent = false)
// private List<Function> mManagement = new ArrayList<>();
// @XFunctionViews(value = FunctionMain.EMPLOYEE_GROUP, filterParent = false)
// private List<Function> mStaffManagement = new ArrayList<>();
// private Map<Function, ActivityJumpStrategy> mActivityJumpStrategy = new HashMap<>();
private MainTopFragment mainTopFragment;
private RxPermissions mRxPermissions;
private ArrayList<QMUISection<SectionHeader, SectionNormalItem>> list;
public static HomeFragment newInstance() {
......@@ -88,6 +161,7 @@ public class HomeFragment extends BaseFragment<HomePresenter> implements HomeCon
@Override
public void setupFragmentComponent(@NonNull AppComponent appComponent) {
mRxPermissions = new RxPermissions(_mActivity);
DaggerHomeComponent //如找不到该类,请编译一下项目
.builder()
.appComponent(appComponent)
......@@ -102,109 +176,375 @@ public class HomeFragment extends BaseFragment<HomePresenter> implements HomeCon
}
@Override
public boolean handleMessage(@NonNull Message msg) {
return false;
}
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mPresenter.checkAppVersion();
mPresenter.syncRestaurantExtendedConfiguration();
WeakHandler weakHandler = new WeakHandler(this);
weakHandler.sendEmptyMessage(0);
}
@Override
public void initData(@Nullable Bundle savedInstanceState) {
mPresenter.getRestaurantReport(RestaurantInfoManager.newInstance().getRestaurantId() + "");
// mPresenter.getRestaurantFunList("26");
initTopBar();
initStickyLayout();
tvCutoff.setText(TimeUtils.getCurrentTimeInString(new SimpleDateFormat("MM.dd HH:mm")));
ImmersionBar.with(_mActivity).titleBar(R.id.cl_title_layout).init();
ImmersionBar.with(_mActivity).titleBar(R.id.side_layout).navigationBarAlpha(1).init();
//初始化側邊欄菜單項
initSideMenu();
FragmentManager fragmentManager = _mActivity.getSupportFragmentManager();
mainTopFragment = (MainTopFragment) fragmentManager.findFragmentById(R.id.main_top_fragment);
// mainTopFragment.setHomeFragment(this);
tvStoreName.setText(RestaurantInfoManager.newInstance().getRestaurantName());
refresh.setOnRefreshListener(refreshLayout -> {
// if (mainTopFragment != null) {
// Message msg = new Message();
// msg.what = 0;
// mainTopFragment.setData(msg);
// }
EventBus.getDefault().post(true,"onRefreshReport");
});
refresh.setEnableLoadMore(false);
// initFuncationData();
updateTitleInfo();
//側滑顯示或關閉時,修改背景圓角
GradientDrawable drawable = new GradientDrawable();
drawable.setColor(ContextCompat.getColor(mContext, R.color.theme_bg_color));
slideMenu.setOnOpenChangedListenter(isOpen -> {
if (isOpen) {
drawable.setCornerRadii(new float[]{0f, 0f, getResources().getDimension(R.dimen.main_page_radius), getResources().getDimension(R.dimen.main_page_radius), 0f, 0f, getResources().getDimension(R.dimen.main_page_radius), getResources().getDimension(R.dimen.main_page_radius)});
} else {
drawable.setCornerRadius(0);
}
refresh.setBackground(drawable);
});
}
private void initTopBar() {
View refreshView = View.inflate(mContext, R.layout.main_home_title_img, null);
refreshView.setOnClickListener(this);
ImageView refresh = refreshView.findViewById(R.id.main_home_title_iv);
refresh.setImageResource(R.drawable.ic_main_home_refresh);
mTopBar.addLeftView(refreshView, R.id.main_home_refresh);
mTopBar.setTitle("店鋪名稱");
View msgView = View.inflate(mContext, R.layout.main_home_title_img, null);
msgView.setOnClickListener(this);
ImageView msg = msgView.findViewById(R.id.main_home_title_iv);
msg.setImageResource(R.drawable.selector_msg);
mTopBar.addRightView(msgView, R.id.main_home_msg);
// mTopBar.addRightImageButton(R.drawable.selector_msg, R.id.main_home_msg).setOnClickListener(this);
@Subscriber(tag = "onFinishRefresh")
private void onFinishRefresh(boolean state){
refresh.finishRefresh();
}
@Override
public void onResume() {
super.onResume();
initService();
initFuncationData();
if (((int) SPUtils.get("isFormal", 0)) != 0) {
tv_version_name.setText("v_" + DeviceUtils.getVersionName(_mActivity) + "\u3000Beta");
} else {
tv_version_name.setText("v_" + DeviceUtils.getVersionName(_mActivity));
}
}
@Override
public void onStart() {
super.onStart();
updateTitleInfo();
}
private void initService() {
boolean deliveryOrderServiceRunning = StytemUtils.isServiceRunning("com.gingersoft.gsa.cloud.common.service.ICommandService", _mActivity);
if (!deliveryOrderServiceRunning) {
Intent service = new Intent(GsaCloudApplication.getAppContext(), ICommandService.class);
service.putExtra(ICommandService.CONNECTION_TYPE, ICommandService.mCurrConnectionType);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
mContext.startForegroundService(service);
} else {
mContext.startService(service);
}
}
boolean prjServiceRunning = StytemUtils.isServiceRunning("com.joe.print.mvp.print.service.PrjService", _mActivity);
if (!prjServiceRunning) {
//開啟Prj打印服務
CC.obtainBuilder(ComponentName.COMPONENT_PRINT)
.setActionName("openPrintService")
.build()
.call();
}
}
/**
* 初始化功能列表
* 初始化側邊欄菜單項
*/
private void initStickyLayout() {
mLayoutManager = createLayoutManager();
mSectionLayout.setLayoutManager(mLayoutManager);
mAdapter = new HomeFunctionAdapter();
mAdapter.setCallback(new QMUIStickySectionAdapter.Callback<SectionHeader, SectionNormalItem>() {
@Override
public void loadMore(QMUISection<SectionHeader, SectionNormalItem> section, boolean loadMoreBefore) {
private void initSideMenu() {
mRvSideMenu.setLayoutManager(new LinearLayoutManager(mContext));
List<MainSideMenuBean> mainSideMenuBeans = new ArrayList<>();
if (BuildConfig.DEBUG) {
mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_setting, "複製Token"));
// mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_setting, "查看日誌"));
// mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_setting, "廚房單原圖"));
mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_mall_center, "商城中心"));
mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_about_us, "關於我們"));
mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_password, "修改密碼"));
mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_setting, "設置"));
mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_setting, "查看日誌"));
mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_setting, "切換環境"));
}
mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_setting, "上傳日誌"));
mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_settlement_report, "清機"));
if (AppDevices.isHywebPos()) {
mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_settlement_report, "N5清機"));
}
MainSideMenuAdapter adapter = new MainSideMenuAdapter(mainSideMenuBeans);
mRvSideMenu.setAdapter(adapter);
adapter.setOnItemClickListener((adapter1, view, position) -> {
String functionName = mainSideMenuBeans.get(position).getFunctionName();
LoganManager.w_home(TAG, LoganManager.EVENT_CLICK + functionName);
switch (functionName) {
case "切換環境":
//切換環境
CC.obtainBuilder(ComponentName.COMPONENT_LOGIN)
.setActionName("switchServer")
.build()
.call();
// finish();
break;
case "複製Token":
String token;
int memberId = UserContext.newInstance().getMemberId();
String loginToken = UserContext.newInstance().getLoginToken();
token = Aes.aesEncrypt("9_" + memberId + "_" + System.currentTimeMillis() + "_" + loginToken);
token = token.replaceAll("\r|\n", "");
ClipboardManager cm = (ClipboardManager) _mActivity.getSystemService(Context.CLIPBOARD_SERVICE);
ClipData label = ClipData.newPlainText("Label", token);
cm.setPrimaryClip(label);
ToastUtils.show(mContext, "已複製");
break;
case "清機": {
Intent intent = new Intent(_mActivity, SettlementActivity.class);
intent.putExtra(SettlementActivity.SETTLEMENT_TYPE_TAG, SettlementActivity.SETTLEMENT_TYPE_NOMAL);
startActivity(intent);
}
break;
case "N5清機": {
Intent intent = new Intent(_mActivity, SettlementActivity.class);
intent.putExtra(SettlementActivity.SETTLEMENT_TYPE_TAG, SettlementActivity.SETTLEMENT_TYPE_HYWEB_POS);
startActivity(intent);
}
break;
case "查看日誌":
launchActivity(new Intent(mContext, LookLogActivity.class));
break;
case "上傳日誌":
LoganManager.uploadLog(mContext, true);
break;
case "廚房單原圖":
break;
}
});
}
@Override
public void onItemClick(QMUIStickySectionAdapter.ViewHolder holder, int position) {
if (holder instanceof HomeFunctionAdapter.ViewHolder) {
HomeFunctionAdapter.ViewHolder viewHolder = (HomeFunctionAdapter.ViewHolder) holder;
if (viewHolder.getTvFun().getText() != null) {
switch (viewHolder.getTvFun().getText().toString()) {
case "餐檯模式":
CC.obtainBuilder(ComponentName.COMPONENT_TABLE)
.setActionName("showTableActivity")
.build()
.call();
break;
case "打印管理":
CC.obtainBuilder(ComponentName.COMPONENT_PRINT)
.setActionName("showPrintActivity")
.build()
.call();
break;
}
}
private void initFuncationData() {
List<Function> functions = new ArrayList<>();
List<Function> orderFunctions = FunctionManager.getDefault().getFunctionByResModule(_mActivity, ComponentMain.main.class, ComponentMain.main.order, "order");
if (orderFunctions.size() > 0) {
functions.addAll(orderFunctions);
sl_order.setVisibility(View.VISIBLE);
} else {
sl_order.setVisibility(View.INVISIBLE);
}
List<Function> managerFuncations = FunctionManager.getDefault().getFunctionByResModule(_mActivity, ComponentMain.main.class, ComponentMain.main.manager, "manager");
managerFuncations.add(new Function(171, 163, 5, "配置列表", R.drawable.ic_expand_list, 0));
// managerFuncations.add(new Function(171, 163, 5, "廚房打印查詢", R.drawable.ic_kitchen_print_query, 0));
// managerFuncations.add(new Function(171, 163, 5, "餐牌管理", R.drawable.ic_food_menu_manger, 0));
// managerFuncations.add(new Function(171, 163, 5, "採購", R.drawable.ic_purchase, 0));
if (managerFuncations.size() > 0) {
functions.addAll(managerFuncations);
ll_management.setVisibility(View.VISIBLE);
} else {
ll_management.setVisibility(View.GONE);
}
List<Function> employeeFuncations = FunctionManager.getDefault().getFunctionByResModule(_mActivity, ComponentMain.main.class, ComponentMain.main.employee, "employee");
if (employeeFuncations.size() > 0) {
functions.addAll(employeeFuncations);
ll_staff_management.setVisibility(View.VISIBLE);
} else {
ll_staff_management.setVisibility(View.GONE);
}
// }
//將功能列表數據分組
SparseArray<String> parents = new SparseArray<>(3);
SparseArray<List<Function>> funMap = new SparseArray<>();
for (Function function : functions) {
if (function.getParentId() == 0) {
//父模塊
parents.put(function.getId(), function.getResName());
} else {
if (funMap.get(function.getParentId()) == null) {
List<Function> functionList = new ArrayList<>();
functionList.add(function);
funMap.put(function.getParentId(), functionList);
} else {
//點擊的頭部,折疊
funMap.get(function.getParentId()).add(function);
}
}
}
if (orderFunctions.size() > 0) {
initAdapter(parents, funMap, 0, R.layout.main_home_funcation_item, rvOrdering, 4);
}
if (managerFuncations.size() > 0) {
initAdapter(parents, funMap, 1, R.layout.main_home_management_funcation_item, rvManagement, 5);
}
if (employeeFuncations.size() > 0) {
initAdapter(parents, funMap, 2, R.layout.main_home_management_funcation_item, rvStaffManagement, 4);
}
}
@Override
public boolean onItemLongClick(QMUIStickySectionAdapter.ViewHolder holder, int position) {
return false;
}
});
function.put(title[0], new String[]{"餐檯模式", "外送模式", "外賣模式", "預點餐模式", "快速收款"});
function.put(title[1], new String[]{"餐牌管理", "選項管理", "餐桌管理", "打印管理", "時段管理", "支付管理", "折扣管理", "員工管理"});
function.put(title[2], new String[]{"權限管理", "操作記錄"});
private void initAdapter(SparseArray<String> parents, SparseArray<List<Function>> funMap, int i, int p, RecyclerView rvOrdering, int i2) {
if (funMap.size() > i && parents.size() > i) {
mTvFunctionNames[i].setText(parents.get(parents.keyAt(i)));
List<Function> mOrderingMeals = funMap.get(parents.keyAt(i));
MainOrderingAdapter adapter = new MainOrderingAdapter(p, mOrderingMeals);
rvOrdering.setLayoutManager(new GridLayoutManager(mContext, i2) {
@Override
public boolean canScrollVertically() {
return false;
}
});
adapter.setOnItemClickListener((adapter1, view, position) -> {
// clickFunction(mActivityJumpStrategy.get(mOrderingMeals.get(position)), );
functionClick(mOrderingMeals.get(position).getResName(), mOrderingMeals.get(position).getStatus());
});
rvOrdering.setAdapter(adapter);
// for (int j = 0; j < funMap.size(); j++) {
// List<Function> functionGroups = funMap.get(funMap.keyAt(j));
// for (Function function : functionGroups) {
// mActivityJumpStrategy.put(function, new IntentJumpStrategy());
// }
// }
mSectionLayout.setAdapter(mAdapter, true);
list = new ArrayList<>();
}
}
for (int i = 0; i < function.size(); i++) {
list.add(createSection(title[i]));
private void clickFunction(ActivityJumpStrategy jumpStrategy, ActivityJumpBean jumpBean) {
jumpStrategy.actionToJumpPage(_mActivity, jumpBean);
}
private void functionClick(String name, int status) {
LoganManager.w_home(TAG, LoganManager.EVENT_CLICK + name);
switch (name.trim()) {
case "餐檯模式":
CC.obtainBuilder(ComponentName.COMPONENT_TABLE)
.setActionName("showTableActivity")
.build()
.call();
break;
case "打印管理":
CC.obtainBuilder(ComponentName.COMPONENT_PRINT)
.setActionName("showPrintActivity")
.build()
.call();
break;
case "賬單管理":
CC.obtainBuilder(ComponentName.COMPONENT_TABLE)
.setActionName("showOrderCenterActivity")
.build()
.call();
break;
case "外送/自取":
CC.obtainBuilder(ComponentName.COMPONENT_DELIVERYPICK)
.setActionName("orderActivity")
.build()
.call();
break;
case "沽清管理":
CC.obtainBuilder(ComponentName.COMPONENT_TABLE)
.setActionName("showSoldoutCtrlActivity")
.build()
.call();
break;
case "餐檯管理":
CC.obtainBuilder(ComponentName.COMPONENT_MANAGER)
.setActionName("showTableManageActivity")
.build()
.call();
break;
case "冷鏈接單":
case "凍鏈接單":
CC.obtainBuilder("Component.ColdChain")
.setActionName("Component.ColdChain")
.build()
.call();
break;
case "二維碼":
launchActivity(new Intent(mContext, RestaurantQrCodeActivity.class));
break;
case "配置列表":
launchActivity(new Intent(mContext, ExpandListActivity.class));
break;
case "廚房打印查詢":
case "廚房單查詢":
CC.obtainBuilder(ComponentName.COMPONENT_DELIVERYPICK)
.setActionName("PrjQueryActivity")
.build()
.call();
break;
case "餐牌管理":
launchActivity(new Intent(mContext, FoodMenuManageActivity.class));
break;
case "採購":
CC.obtainBuilder(ComponentName.COMPONENT_SUPPLYCHAIN)
.setActionName(AppConstans.SUPPLY_CHAIN_MAIN_ACTION)
.build()
.call();
break;
default:
break;
}
mAdapter.setData(list);
}
private QMUISection<SectionHeader, SectionNormalItem> createSection(String title) {
SectionHeader header = new SectionHeader(title);
ArrayList<SectionNormalItem> contents = new ArrayList<>();
for (int i = 0; i < Objects.requireNonNull(function.get(title)).length; i++) {
contents.add(new SectionNormalItem(R.drawable.ic_dining_table, Objects.requireNonNull(function.get(title))[i]));
private void updateTitleInfo() {
String restaurantName = RestaurantInfoManager.newInstance().getRestaurantName();
String memberName = UserContext.newInstance().getMemberName();
if (!TextUtils.isEmpty(restaurantName)) {
if (RestaurantInfoUtils.getRestaurantSize(_mActivity) > 1) {
//顯示下拉圖標
Drawable drawable = getResources().getDrawable(R.drawable.ic_dropdown_white);
drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
tvRestaurantName.setCompoundDrawables(null, null, drawable, null);
}
tvRestaurantName.setText(restaurantName);
}
tvStoreName.setText(restaurantName);
if (!TextUtils.isEmpty(memberName)) {
tvUserName.setText(memberName);
}
// QMUISection<SectionHeader, SectionNormalItem> section = new QMUISection<>(header, contents, false);
// if test load more, you can open the code
// section.setExistAfterDataToLoad(true);
// section.setExistBeforeDataToLoad(true);
return new QMUISection<>(header, contents, false);
}
private RecyclerView.LayoutManager createLayoutManager() {
final GridLayoutManager layoutManager = new GridLayoutManager(getContext(), 4);
layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int i) {
return mAdapter.getItemIndex(i) < 0 ? layoutManager.getSpanCount() : 1;
private void showChooseRestaurantDialog() {
String brandRestaurantInfos = RestaurantInfoManager.getBrandRestaurantInfos();
if (!TextUtils.isEmpty(brandRestaurantInfos)) {
List<BrandsBean.BrandsData> brandsBeans = JsonUtils.parseArray(brandRestaurantInfos, BrandsBean.BrandsData.class);
if (brandsBeans != null && brandsBeans.size() > 0) {
CC.obtainBuilder(ComponentName.COMPONENT_LOGIN)
.setActionName("ChooseRestaurant")
.build()
.call();
}
});
return layoutManager;
}
}
@Override
......@@ -236,31 +576,53 @@ public class HomeFragment extends BaseFragment<HomePresenter> implements HomeCon
ArmsUtils.startActivity(intent);
}
@Override
public void killMyself() {
_mActivity.finish();
}
@OnClick({R2.id.layout_login_out, R2.id.iv_personal_center, R2.id.tv_restaurant_name})
@Override
public void onClick(View v) {
if (v.getId() == R.id.main_home_refresh) {
//刷新
v.startAnimation(AnimationUtils.loadAnimation(mContext, R.anim.rotate_center));
} else if (v.getId() == R.id.main_home_msg) {
//消息
if (v.getId() == R.id.layout_login_out) {
//登出
CommonTipDialog.showDoubtDialog(_mActivity, "退出登錄?", HomePresenter.class, mPresenter, "loginOut", null, null);
} else if (v.getId() == R.id.iv_personal_center) {
slideMenu.toggle();
} else if (v.getId() == R.id.tv_restaurant_name) {
showChooseRestaurantDialog();
}
}
@Override
public void loadBusinessInfo(Map<String, HomeTurnoverBean.DataBean> data) {
HomeTurnoverBean.DataBean bean = data.get(TimeUtils.getCurrentTimeInString(TimeUtils.DATE_FORMAT_DATE));//TimeUtils.getCurrentTimeInString(TimeUtils.DATE_FORMAT_DATE)
if (bean != null) {
tvTurnover.setText(bean.getBusiness_amount());
tvProjectTotalAmount.setText(bean.getSales());
tvConsumersNum.setText(bean.getPeople());
tvBillNum.setText(bean.getNumber_bill());
public void loginOut() {
UserContext.newInstance().logOut();
killMyself();
}
@Override
public RxPermissions getRxPermissions() {
return mRxPermissions;
}
@Override
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == ResultConstans.DOWNLOAD_PAGE_BACK) {
initFuncationData();
}
}
// @Override
// public void loadBusinessInfo(Map<String, HomeTurnoverBean.DataBean> data) {
//// HomeTurnoverBean.DataBean bean = data.get(TimeUtils.getCurrentTimeInString(TimeUtils.DATE_FORMAT_DATE));//TimeUtils.getCurrentTimeInString(TimeUtils.DATE_FORMAT_DATE)
//// if (bean != null) {
//// tvTurnover.setText(bean.getBusiness_amount());
//// tvProjectTotalAmount.setText(bean.getSales());
//// tvConsumersNum.setText(bean.getPeople());
//// tvBillNum.setText(bean.getNumber_bill());
//// }
// }
}
......@@ -24,6 +24,7 @@ import com.gingersoft.gsa.cloud.main.mvp.contract.MainTopContract;
import com.gingersoft.gsa.cloud.main.mvp.model.bean.MainBusinessBean;
import com.gingersoft.gsa.cloud.main.mvp.model.bean.MainOrderInfoChartBean;
import com.gingersoft.gsa.cloud.main.mvp.presenter.MainTopPresenter;
import com.gingersoft.gsa.cloud.main.mvp.ui.activity.MainActivity;
import com.gingersoft.gsa.cloud.main.mvp.ui.activity.NewMainActivity;
import com.gingersoft.gsa.cloud.main.mvp.ui.activity.ReportActivity;
import com.gingersoft.gsa.cloud.ui.AAChartCoreLib.AAChartConfiger.AAChartModel;
......@@ -38,6 +39,9 @@ import com.jess.arms.base.BaseFragment;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;
import org.simple.eventbus.EventBus;
import org.simple.eventbus.Subscriber;
import java.util.List;
import java.util.Map;
......@@ -95,6 +99,8 @@ public class MainTopFragment extends BaseFragment<MainTopPresenter> implements M
@BindView(R2.id.tv_bill_trend)
TextView tvBillTrend;//賬單數量較昨日上漲或下跌數量
private HomeFragment homeFragment;
public static MainTopFragment newInstance() {
MainTopFragment fragment = new MainTopFragment();
return fragment;
......@@ -186,6 +192,11 @@ public class MainTopFragment extends BaseFragment<MainTopPresenter> implements M
}
}
@Subscriber(tag = "onRefreshReport")
private void onRefreshReport(boolean state){
getInfo();
}
@Override
public void showLoading(String message) {
if (message != null)
......@@ -334,7 +345,8 @@ public class MainTopFragment extends BaseFragment<MainTopPresenter> implements M
@Override
public void loadChart(List<MainOrderInfoChartBean.DataBean> dataBeans) {
((NewMainActivity)_mActivity).onFinishRefresh();//結束刷新
// homeFragment.onFinishRefresh();//結束刷新
EventBus.getDefault().post(true,"onFinishRefresh");
Object[] todayData = new Object[24];//今天的數據
Object[] yesterdayData = new Object[24];//昨天的數據
......@@ -400,4 +412,8 @@ public class MainTopFragment extends BaseFragment<MainTopPresenter> implements M
startActivity(new Intent(mContext, ReportActivity.class));
}
}
public void setHomeFragment(HomeFragment homeFragment) {
this.homeFragment = homeFragment;
}
}
......@@ -6,6 +6,7 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.gingersoft.gsa.cloud.common.utils.gson.GsonUtils;
import com.gingersoft.gsa.cloud.common.utils.toast.ToastUtils;
import com.gingersoft.gsa.cloud.main.R;
import com.gingersoft.gsa.cloud.main.R2;
......@@ -63,7 +64,6 @@ public class MyFragment extends BaseFragment<MyPresenter> implements MyContract.
@Override
public void initData(@Nullable Bundle savedInstanceState) {
}
......
package com.gingersoft.gsa.cloud.main.mvp.ui.fragment;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.RecyclerView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.OnItemClickListener;
import com.gingersoft.gsa.cloud.common.webview.WebviewHelper;
import com.gingersoft.gsa.cloud.main.R;
import com.gingersoft.gsa.cloud.main.R2;
import com.gingersoft.gsa.cloud.main.di.component.DaggerReportListComponent;
import com.gingersoft.gsa.cloud.main.mvp.contract.ReportListContract;
import com.gingersoft.gsa.cloud.main.mvp.model.bean.ReportListItem;
import com.gingersoft.gsa.cloud.main.mvp.presenter.ReportListPresenter;
import com.gingersoft.gsa.cloud.main.mvp.ui.adapter.ReportListAdapter;
import com.jess.arms.base.BaseFragment;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;
import com.qmuiteam.qmui.widget.QMUITopBar;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import static com.jess.arms.utils.Preconditions.checkNotNull;
/**
* ================================================
* Description:
* <p>
* Created by MVPArmsTemplate on 03/27/2021 12:07
* <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
* <a href="https://github.com/JessYanCoding">Follow me</a>
* <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
* <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
* <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
* ================================================
*/
public class ReportListFragment extends BaseFragment<ReportListPresenter> implements ReportListContract.View {
@BindView(R2.id.topBar)
QMUITopBar topBar;
@BindView(R2.id.recycler_report)
RecyclerView recyclerReport;
private ReportListAdapter mReportListAdapter;
public static ReportListFragment newInstance() {
ReportListFragment fragment = new ReportListFragment();
return fragment;
}
@Override
public void setupFragmentComponent(@NonNull AppComponent appComponent) {
DaggerReportListComponent //如找不到该类,请编译一下项目
.builder()
.appComponent(appComponent)
.view(this)
.build()
.inject(this);
}
@Override
public View initView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_report_list, container, false);
}
@Override
public void initData(@Nullable Bundle savedInstanceState) {
topBar.setBackgroundColor(ContextCompat.getColor(mContext, R.color.theme_color));
topBar.addLeftBackImageButton().setVisibility(View.GONE);
topBar.setTitle("报表");
Drawable drawable = getResources().getDrawable(R.drawable.ic_line);
drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
List<ReportListItem> reportListItems = new ArrayList<>(5);
reportListItems.add(new ReportListItem(drawable,"食品销售排行","https://wyn.ricepon.com/reports/view/eea52d08-cad6-4afe-bb09-2e8349b81f5f?display=pageless&size=fitwidth&parampanel=top&dp=%7B%22userId%22%3A%5B%22340%22%5D%2C%22%E5%B7%B2%E6%9C%89%E5%93%81%E7%89%8C%22%3A%5B%22-1%22%5D%2C%22%E5%B7%B2%E6%9C%89%E9%A4%90%E5%BB%B3%22%3A%5B%22-1%22%5D%2C%22%E5%93%81%E7%89%8C%22%3A%5B%221%22%5D%2C%22%E9%A4%90%E5%BB%B3%22%3A%5B%2226%22%5D%2C%22%E6%8E%92%E5%BA%8F%E9%A1%9E%E5%9E%8B%22%3A%5B%221%22%5D%2C%22%E9%96%8B%E5%A7%8B%E6%97%A5%E6%9C%9F%22%3A%5B%222021-01-31T16%3A00%3A00.000Z%22%5D%2C%22%E7%B5%90%E6%9D%9F%E6%97%A5%E6%9C%9F%22%3A%5B%222021-03-23T16%3A00%3A00.000Z%22%5D%7D&theme=default&lng=zh-TW&token=5c80dba856cd9ef65b55aa487571d101ef11bdbd1256de11b862845a99ca8d01"));
reportListItems.add(new ReportListItem(drawable,"营业报表","https://wyn.ricepon.com/reports/view/eea52d08-cad6-4afe-bb09-2e8349b81f5f?display=pageless&size=fitwidth&parampanel=top&dp=%7B%22userId%22%3A%5B%22340%22%5D%2C%22%E5%B7%B2%E6%9C%89%E5%93%81%E7%89%8C%22%3A%5B%22-1%22%5D%2C%22%E5%B7%B2%E6%9C%89%E9%A4%90%E5%BB%B3%22%3A%5B%22-1%22%5D%2C%22%E5%93%81%E7%89%8C%22%3A%5B%221%22%5D%2C%22%E9%A4%90%E5%BB%B3%22%3A%5B%2226%22%5D%2C%22%E6%8E%92%E5%BA%8F%E9%A1%9E%E5%9E%8B%22%3A%5B%221%22%5D%2C%22%E9%96%8B%E5%A7%8B%E6%97%A5%E6%9C%9F%22%3A%5B%222021-01-31T16%3A00%3A00.000Z%22%5D%2C%22%E7%B5%90%E6%9D%9F%E6%97%A5%E6%9C%9F%22%3A%5B%222021-03-23T16%3A00%3A00.000Z%22%5D%7D&theme=default&lng=zh-TW&token=5c80dba856cd9ef65b55aa487571d101ef11bdbd1256de11b862845a99ca8d01"));
reportListItems.add(new ReportListItem(drawable,"订单报表","https://wyn.ricepon.com/reports/view/eea52d08-cad6-4afe-bb09-2e8349b81f5f?display=pageless&size=fitwidth&parampanel=top&dp=%7B%22userId%22%3A%5B%22340%22%5D%2C%22%E5%B7%B2%E6%9C%89%E5%93%81%E7%89%8C%22%3A%5B%22-1%22%5D%2C%22%E5%B7%B2%E6%9C%89%E9%A4%90%E5%BB%B3%22%3A%5B%22-1%22%5D%2C%22%E5%93%81%E7%89%8C%22%3A%5B%221%22%5D%2C%22%E9%A4%90%E5%BB%B3%22%3A%5B%2226%22%5D%2C%22%E6%8E%92%E5%BA%8F%E9%A1%9E%E5%9E%8B%22%3A%5B%221%22%5D%2C%22%E9%96%8B%E5%A7%8B%E6%97%A5%E6%9C%9F%22%3A%5B%222021-01-31T16%3A00%3A00.000Z%22%5D%2C%22%E7%B5%90%E6%9D%9F%E6%97%A5%E6%9C%9F%22%3A%5B%222021-03-23T16%3A00%3A00.000Z%22%5D%7D&theme=default&lng=zh-TW&token=5c80dba856cd9ef65b55aa487571d101ef11bdbd1256de11b862845a99ca8d01"));
mReportListAdapter = new ReportListAdapter(reportListItems);
recyclerReport.setAdapter(mReportListAdapter);
mReportListAdapter.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {
WebviewHelper.openWebview(reportListItems.get(position).getReportUrl());
}
});
}
@Override
public void setData(@Nullable Object data) {
}
@Override
public void showLoading(String message) {
}
@Override
public void hideLoading() {
}
@Override
public void showMessage(@NonNull String message) {
checkNotNull(message);
ArmsUtils.snackbarText(message);
}
@Override
public void launchActivity(@NonNull Intent intent) {
checkNotNull(intent);
ArmsUtils.startActivity(intent);
}
@Override
public void killMyself() {
_mActivity.finish();
}
}
<?xml version="1.0" encoding="utf-8"?>
<!--<androidx.recyclerview.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"-->
<!-- xmlns:tools="http://schemas.android.com/tools"-->
<!-- android:id="@+id/recycler_report"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="match_parent"-->
<!-- android:orientation="vertical">-->
<!--</androidx.recyclerview.widget.RecyclerView>-->
<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"
android:descendantFocusability="afterDescendants"
android:orientation="vertical">
<com.qmuiteam.qmui.widget.QMUITopBar
android:id="@+id/topBar"
android:layout_width="match_parent"
android:layout_height="@dimen/pickerview_topbar_height"
android:fitsSystemWindows="true"
app:qmui_topbar_text_btn_color_state_list="@color/theme_white_color"
app:qmui_topbar_title_color="@color/theme_white_color" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_report"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tv_report_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="营业报表"
android:textSize="@dimen/sp_16"
android:textColor="@color/theme_text_color"
android:drawableLeft="@drawable/ic_line">
</TextView>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<com.qmuiteam.qmui.widget.QMUIWindowInsetLayout xmlns:android="http://schemas.android.com/apk/res/android"
<com.gingersoft.gsa.cloud.main.mvp.ui.view.SlidingMenu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/slideMenu"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/qmui_config_color_white">
android:background="@drawable/shape_main_bg">
<LinearLayout
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical">
<!-- 標題欄-->
<com.qmuiteam.qmui.widget.QMUITopBarLayout
android:id="@+id/main_home_bar"
android:descendantFocusability="blocksDescendants"
android:orientation="horizontal">
<!-- 側邊欄內容-->
<LinearLayout
android:id="@+id/side_layout"
android:layout_width="match_parent"
android:layout_height="@dimen/head_height"
android:fitsSystemWindows="true" />
<!-- 營業額-->
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/main_home_business_info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_20"
android:layout_marginBottom="@dimen/dp_20"
android:paddingLeft="@dimen/dp_18"
android:paddingRight="@dimen/dp_18">
android:layout_height="match_parent"
android:layout_gravity="start"
android:gravity="center_horizontal"
android:orientation="vertical">
<TextView
android:id="@+id/tv_main_home_today_turnover_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/turnover_today"
android:textColor="@color/normal_color"
android:textSize="@dimen/sp_16"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
android:layout_marginTop="@dimen/dp_15"
android:text="個人中心"
android:textColor="@color/white"
android:textSize="@dimen/dp_17" />
<ImageView
android:layout_width="@dimen/dp_76"
android:layout_height="@dimen/dp_76"
android:layout_marginTop="@dimen/dp_14"
android:src="@drawable/ic_header" />
<TextView
android:id="@+id/tv_main_home_today_turnover"
android:id="@+id/tv_username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0"
android:textColor="@color/normal_color"
android:textSize="@dimen/sp_20"
app:layout_constraintBottom_toBottomOf="@id/tv_main_home_cutoff_text"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_main_home_today_turnover_text" />
android:layout_marginTop="@dimen/dp_6"
android:text="NAME"
android:textColor="@color/white"
android:textSize="@dimen/dp_20" />
<TextView
android:id="@+id/tv_main_home_cutoff_text"
android:id="@+id/tv_store_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:text="@string/cutoff"
android:textColor="@color/normal_color"
android:textSize="@dimen/sp_12"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_main_home_today_turnover_text" />
android:text="店鋪名稱"
android:textColor="@color/white"
android:textSize="@dimen/dp_20" />
<TextView
android:id="@+id/tv_main_home_cutoff_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/normal_color"
android:textSize="@dimen/sp_12"
app:layout_constraintLeft_toRightOf="@id/tv_main_home_cutoff_text"
app:layout_constraintBottom_toBottomOf="@id/tv_main_home_cutoff_text"
app:layout_constraintTop_toTopOf="@id/tv_main_home_cutoff_text" />
<View
android:id="@+id/line_main_home_turnover"
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_side_menu"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_1"
android:layout_marginTop="@dimen/dp_15"
android:background="@color/line_color"
app:layout_constraintTop_toBottomOf="@id/tv_main_home_cutoff_text" />
android:layout_height="0dp"
android:layout_marginTop="@dimen/dp_20"
android:layout_marginBottom="@dimen/dp_20"
android:layout_weight="1"
android:visibility="visible" />
<TextView
android:id="@+id/tv_main_home_total_amount_project_text"
android:layout_width="0dp"
<LinearLayout
android:id="@+id/layout_login_out"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_15"
android:gravity="center"
android:text="@string/total_amount_of_project"
android:textColor="@color/normal_color"
android:textSize="@dimen/sp_16"
app:layout_constraintHorizontal_weight="1"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@id/tv_main_home_consumers_number_text"
app:layout_constraintTop_toBottomOf="@id/line_main_home_turnover" />
android:layout_marginBottom="@dimen/dp_45"
android:gravity="center_vertical|bottom"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_main_home_consumers_number_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/number_of_consumers"
android:textColor="@color/normal_color"
android:textSize="@dimen/sp_16"
app:layout_constraintHorizontal_weight="1"
app:layout_constraintLeft_toRightOf="@id/tv_main_home_total_amount_project_text"
app:layout_constraintRight_toLeftOf="@id/tv_main_home_bill_number_text"
app:layout_constraintTop_toTopOf="@id/tv_main_home_total_amount_project_text" />
<ImageView
android:layout_width="@dimen/dp_29"
android:layout_height="@dimen/dp_27"
android:layout_marginLeft="@dimen/dp_18"
android:src="@drawable/ic_loginout" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_6"
android:text="登出"
android:textColor="@color/white"
android:textSize="@dimen/dp_17" />
</LinearLayout>
<TextView
android:id="@+id/tv_main_home_bill_number_text"
android:layout_width="0dp"
android:id="@+id/tv_version_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/bill_number"
android:textColor="@color/normal_color"
android:textSize="@dimen/sp_16"
app:layout_constraintHorizontal_weight="1"
app:layout_constraintLeft_toRightOf="@id/tv_main_home_consumers_number_text"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_main_home_total_amount_project_text" />
android:layout_marginLeft="@dimen/dp_18"
android:layout_marginBottom="@dimen/dp_35"
android:gravity="center_vertical|bottom"
android:text=""
android:textColor="@color/white"
android:textSize="@dimen/sp_14" />
</LinearLayout>
<!-- 主頁內容-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/tv_main_home_total_amount_project"
android:layout_width="wrap_content"
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl_title_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_5"
android:text="0"
android:textColor="@color/normal_color"
android:textSize="@dimen/sp_14"
app:layout_constraintLeft_toLeftOf="@id/tv_main_home_total_amount_project_text"
app:layout_constraintRight_toRightOf="@id/tv_main_home_total_amount_project_text"
app:layout_constraintTop_toBottomOf="@id/tv_main_home_total_amount_project_text" />
android:background="@drawable/shape_main_title_bg"
android:paddingLeft="@dimen/dp_20"
android:paddingTop="@dimen/dp_7"
android:paddingRight="@dimen/dp_12"
android:paddingBottom="@dimen/dp_7"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="@+id/iv_personal_center"
android:layout_width="@dimen/dp_37"
android:layout_height="@dimen/dp_37"
android:src="@drawable/ic_my"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tv_main_home_consumers_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0"
android:textColor="@color/normal_color"
android:textSize="@dimen/sp_14"
app:layout_constraintLeft_toLeftOf="@id/tv_main_home_consumers_number_text"
app:layout_constraintRight_toRightOf="@id/tv_main_home_consumers_number_text"
app:layout_constraintTop_toBottomOf="@id/tv_main_home_consumers_number_text"
app:layout_constraintTop_toTopOf="@id/tv_main_home_total_amount_project" />
<TextView
android:id="@+id/tv_restaurant_name"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:text="店鋪名稱"
android:textColor="@color/white"
android:textSize="@dimen/dp_18"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tv_main_home_bill_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0"
android:textColor="@color/normal_color"
android:textSize="@dimen/sp_14"
app:layout_constraintLeft_toLeftOf="@id/tv_main_home_bill_number_text"
app:layout_constraintRight_toRightOf="@id/tv_main_home_bill_number_text"
app:layout_constraintTop_toBottomOf="@id/tv_main_home_bill_number_text"
app:layout_constraintTop_toTopOf="@id/tv_main_home_total_amount_project" />
</androidx.constraintlayout.widget.ConstraintLayout>
<!-- 功能列表-->
<com.qmuiteam.qmui.widget.section.QMUIStickySectionLayout
android:id="@+id/section_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<ImageView
android:layout_width="@dimen/dp_24"
android:layout_height="@dimen/dp_26"
android:src="@drawable/ic_msg"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<com.scwang.smartrefresh.layout.SmartRefreshLayout
android:id="@+id/qm_refresh"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/shape_main_bottom_corners_bg">
<com.gingersoft.gsa.cloud.ui.view.MyScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:paddingBottom="@dimen/dp_10"
android:layout_height="wrap_content">
<fragment
android:id="@+id/main_top_fragment"
android:name="com.gingersoft.gsa.cloud.main.mvp.ui.fragment.MainTopFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<com.lihang.ShadowLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/layout_ordering_meals"
android:layout_marginLeft="@dimen/dp_13"
android:layout_marginTop="@dimen/dp_10"
android:layout_marginRight="@dimen/dp_13"
app:hl_cornerRadius="@dimen/dp_4"
app:hl_shadowBackColor="@color/white"
app:hl_shadowLimit="@dimen/dp_0">
<!--管理-->
<LinearLayout
android:id="@+id/layout_management"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="@dimen/dp_16">
<LinearLayout
android:id="@+id/ll_management"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
</com.qmuiteam.qmui.widget.QMUIWindowInsetLayout>
\ No newline at end of file
<TextView
android:id="@+id/tv_function_name2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_15"
android:textColor="#181818"
android:textSize="@dimen/dp_14" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_management"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/main_recyclerview_marginLeft"
android:layout_marginTop="@dimen/dp_20"
android:layout_marginRight="@dimen/main_recyclerview_marginRight" />
<View
android:layout_width="match_parent"
android:layout_height="@dimen/dp_1"
android:background="#F0F0F0"
android:visibility="gone"/>
</LinearLayout>
<!-- 員工管理-->
<LinearLayout
android:id="@+id/ll_staff_management"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/tv_function_name3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_15"
android:layout_marginTop="@dimen/dp_20"
android:visibility="visible"
android:textColor="#181818"
android:textSize="@dimen/dp_14" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_staff_management"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="visible"
android:layout_marginLeft="@dimen/main_recyclerview_marginLeft"
android:layout_marginTop="@dimen/dp_10"
android:layout_marginRight="@dimen/main_recyclerview_marginRight" />
</LinearLayout>
</LinearLayout>
</com.lihang.ShadowLayout>
<!-- 點餐模塊-->
<com.lihang.ShadowLayout
android:id="@+id/layout_ordering_meals"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/main_top_fragment"
android:layout_marginLeft="@dimen/dp_10"
android:layout_marginRight="@dimen/dp_10"
app:hl_cornerRadius="@dimen/dp_4"
app:hl_dy="@dimen/main_shadow_dy"
android:visibility="visible"
app:hl_shadowBackColor="@color/white"
app:hl_shadowColor="@color/shadow_color"
app:hl_shadowLimit="@dimen/main_shadow_limit">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="@dimen/dp_15"
android:paddingBottom="@dimen/dp_20">
<TextView
android:id="@+id/tv_function_name1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_22"
android:textColor="#181818"
android:textSize="@dimen/dp_17" />
<View
android:layout_width="match_parent"
android:layout_height="@dimen/dp_1"
android:layout_marginTop="@dimen/dp_11"
android:background="#F0F0F0" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_ordering_meals"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/main_recyclerview_marginLeft"
android:layout_marginTop="@dimen/dp_10"
android:layout_marginRight="@dimen/main_recyclerview_marginRight" />
</LinearLayout>
</com.lihang.ShadowLayout>
</RelativeLayout>
</com.gingersoft.gsa.cloud.ui.view.MyScrollView>
</com.scwang.smartrefresh.layout.SmartRefreshLayout>
</LinearLayout>
</LinearLayout>
</com.gingersoft.gsa.cloud.main.mvp.ui.view.SlidingMenu>
\ No newline at end of file
......@@ -103,6 +103,14 @@ public class ComponentTable implements IComponent {
case "getInfo":
getInfo(cc);
break;
case "getTables": {
AppManager appManager = ArmsUtils.obtainAppComponentFromContext(context).appManager();
TableActivity tableActivity = (TableActivity) appManager.findActivity(TableActivity.class);
if (null != tableActivity) {
tableActivity.getTables(false, null);
}
break;
}
case ComponentAction.Table.INT_ORDER:
//初始化堂食賬單類
DoshokuOrder.getInstance().initialization();
......@@ -125,7 +133,6 @@ public class ComponentTable implements IComponent {
}
private void lifecycleFragmentDoubleText(CC cc) {
// LifecycleFragment lifecycleFragment = cc.getParamItem("fragment");
// if (lifecycleFragment != null) {
......
package com.gingersoft.gsa.cloud.table.di.module;
import android.content.Context;
import dagger.Binds;
import dagger.Module;
import dagger.Provides;
import okhttp3.OkHttpClient;
import com.gingersoft.gsa.cloud.database.bean.Food;
import com.gingersoft.gsa.cloud.table.mvp.contract.TableContract;
import com.gingersoft.gsa.cloud.table.mvp.model.TableModel;
import com.gingersoft.gsa.cloud.table.mvp.ui.adapter.meal.FoodAdapter;
import com.jess.arms.di.scope.ActivityScope;
import java.util.ArrayList;
import java.util.List;
/**
......@@ -24,4 +34,16 @@ public abstract class TableModule {
@Binds
abstract TableContract.Model bindTableModel(TableModel model);
@ActivityScope
@Provides
static List<Food> provideFoodList() {
return new ArrayList<>();
}
@ActivityScope
@Provides
static FoodAdapter provideFoodAdapter(Context context, List<Food> foodList, int fromType) {
return new FoodAdapter(context, foodList, fromType);
}
}
\ No newline at end of file
......@@ -75,7 +75,7 @@ public interface TableContract {
List<Modifier> queryDB_ModifierList(long fid, int mode);
Observable<TableBean> getTables(int restaurantId);
Observable<TableBean> getTables(int restaurantId, boolean update);
Observable<BaseResult> getTable(int tableId, String tableNumber);
......@@ -93,7 +93,7 @@ public interface TableContract {
Observable<BaseResult> splitTable(int tableId);
Observable<BaseResult> getFoodSummarys(int restaurantId,boolean isDefault, byte businessType);
Observable<BaseResult> getFoodSummarys(int restaurantId,boolean isDefault, byte businessType, boolean update);
Observable<BaseResult> addScan(RequestBody requestBody);
}
......
......@@ -10,6 +10,7 @@ import com.gingersoft.gsa.cloud.database.utils.FoodDaoUtils;
import com.gingersoft.gsa.cloud.database.utils.ModifierDaoUtils;
import com.gingersoft.gsa.cloud.table.mvp.contract.TableContract;
import com.gingersoft.gsa.cloud.table.mvp.model.bean.response.BaseOrderResponse;
import com.gingersoft.gsa.cloud.table.mvp.model.cache.TableCache;
import com.gingersoft.gsa.cloud.table.mvp.model.service.OrderService;
import com.gingersoft.gsa.cloud.table.mvp.model.service.TableService;
import com.google.gson.Gson;
......@@ -22,6 +23,10 @@ import java.util.List;
import javax.inject.Inject;
import io.reactivex.Observable;
import io.reactivex.ObservableSource;
import io.reactivex.functions.Function;
import io.rx_cache2.DynamicKey;
import io.rx_cache2.EvictDynamicKey;
import okhttp3.RequestBody;
......@@ -71,11 +76,22 @@ public class TableModel extends BaseModel implements TableContract.Model {
}
@Override
public Observable<TableBean> getTables(int restaurantId) {
return mRepositoryManager.obtainRetrofitService(TableService.class)
public Observable<TableBean> getTables(int restaurantId, boolean update) {
return mRepositoryManager
.obtainRetrofitService(TableService.class)
.getTables(restaurantId);
// return Observable.just(mRepositoryManager
// .obtainRetrofitService(TableService.class)
// .getTables(restaurantId))
// .flatMap((Function<Observable<TableBean>, ObservableSource<TableBean>>) listObservable ->
// mRepositoryManager.obtainCacheService(TableCache.class)
// .getTables(listObservable,
// new DynamicKey(1),
// new EvictDynamicKey(update))
// .map(listReply -> listReply.getData()));
}
@Override
public Observable<BaseResult> getTable(int tableId, String tableNumber) {
return mRepositoryManager.obtainRetrofitService(TableService.class)
......@@ -125,9 +141,20 @@ public class TableModel extends BaseModel implements TableContract.Model {
}
@Override
public Observable<BaseResult> getFoodSummarys(int restaurantId, boolean isDefault, byte businessType) {
return mRepositoryManager.obtainRetrofitService(TableService.class)
public Observable<BaseResult> getFoodSummarys(int restaurantId, boolean isDefault, byte businessType, boolean update) {
return mRepositoryManager
.obtainRetrofitService(TableService.class)
.getFoodSummarys(restaurantId, isDefault, businessType);
// return Observable.just(mRepositoryManager
// .obtainRetrofitService(TableService.class)
// .getFoodSummarys(restaurantId, isDefault, businessType))
// .flatMap((Function<Observable<BaseResult>, ObservableSource<BaseResult>>) listObservable -> mRepositoryManager.obtainCacheService(TableCache.class)
// .getFoodSummarys(listObservable,
// new DynamicKey(1),
// new EvictDynamicKey(update))
// .map(listReply -> listReply.getData()));
}
@Override
......
package com.gingersoft.gsa.cloud.table.mvp.model.cache;
import com.gingersoft.gsa.cloud.common.bean.BaseResult;
import com.gingersoft.gsa.cloud.common.core.table.TableBean;
import java.util.concurrent.TimeUnit;
import io.reactivex.Observable;
import io.rx_cache2.DynamicKey;
import io.rx_cache2.EvictProvider;
import io.rx_cache2.LifeCache;
import io.rx_cache2.Reply;
/**
* @作者: bin
* @創建時間: 2021-03-26 11:06
* @更新時間: 2021-03-26 11:06
* @描述:
*/
public interface TableCache {
@LifeCache(duration = 2, timeUnit = TimeUnit.MINUTES)
Observable<Reply<TableBean>> getTables(Observable<TableBean> tables, DynamicKey idLastUserQueried, EvictProvider evictProvider);
@LifeCache(duration = 2, timeUnit = TimeUnit.MINUTES)
Observable<Reply<BaseResult>> getFoodSummarys(Observable<BaseResult> foodSummarys, DynamicKey idLastUserQueried, EvictProvider evictProvider);
}
package com.gingersoft.gsa.cloud.table.mvp.model.utils;
import android.text.TextUtils;
import android.util.ArrayMap;
import com.gingersoft.gsa.cloud.database.bean.ComboItem;
import com.gingersoft.gsa.cloud.database.bean.Discount;
......@@ -27,17 +28,18 @@ public class MealConditionFilterUtils {
* @return
*/
public static List<Food> foodConditionFilter(List<Food> foodList, int summary) {
if (foodList.size() == 0) {
return foodList;
}
List<Food> newFoodList = new ArrayList<>();
if (foodList == null || foodList.size() > 0) {
String strSummary = String.valueOf(summary);
for (Food food : foodList) {
String foodSummary = food.getFoodSummary();
if (!TextUtils.isEmpty(foodSummary)) {
String[] summarys = foodSummary.split(",");
for (String item : summarys) {
if (item.equals(strSummary)) {
newFoodList.add(food);
}
String strSummary = String.valueOf(summary);
for (Food food : foodList) {
String foodSummary = food.getFoodSummary();
if (!TextUtils.isEmpty(foodSummary)) {
String[] summarys = foodSummary.split(",");
for (String item : summarys) {
if (item.equals(strSummary)) {
newFoodList.add(food);
}
}
}
......@@ -53,17 +55,18 @@ public class MealConditionFilterUtils {
* @return
*/
public static List<ComboItem> comboConditionFilter(List<ComboItem> comboItemList, int summary) {
if (comboItemList.size() == 0) {
return comboItemList;
}
List<ComboItem> newComboItemList = new ArrayList<>();
if (newComboItemList == null || newComboItemList.size() > 0) {
String strSummary = String.valueOf(summary);
for (ComboItem comboItem : comboItemList) {
String foodSummary = comboItem.getFoodSummary();
if (!TextUtils.isEmpty(foodSummary)) {
String[] summarys = foodSummary.split(",");
for (String item : summarys) {
if (item.equals(strSummary)) {
newComboItemList.add(comboItem);
}
String strSummary = String.valueOf(summary);
for (ComboItem comboItem : comboItemList) {
String foodSummary = comboItem.getFoodSummary();
if (!TextUtils.isEmpty(foodSummary)) {
String[] summarys = foodSummary.split(",");
for (String item : summarys) {
if (item.equals(strSummary)) {
newComboItemList.add(comboItem);
}
}
}
......@@ -80,10 +83,13 @@ public class MealConditionFilterUtils {
* @return
*/
public static List<Discount> discountConditionFilter(List<Discount> discountList, byte discountScope, byte placeOrderType) {
if (discountList.size() == 0) {
return discountList;
}
String strScope = String.valueOf(discountScope);
String strType = String.valueOf(placeOrderType);
Map<String, Discount> newDiscountMaps = new HashMap<>();
Map<String, Discount> newDiscountMaps = new ArrayMap<>();
for (Discount discount : discountList) {
newDiscountMaps.put(discount.getId() + "-" + discount.getDiscountType() + "-" + discount.getPlaceOrderType(), discount);
}
......
......@@ -108,12 +108,16 @@ public class MealStandPresenter extends BaseOrderPresenter<MealStandContract.Mod
ImageLoader mImageLoader;
@Inject
AppManager mAppManager;
// @Inject
FoodAdapter mFoodAdapter;
// @Inject
List<Food> mFoodList;
private MealStandActivity IActivity;
private CancelFoodDialog mCancelFoodDialog;
private FoodAdapter mFoodAdapter;
private ComboAdapter mComboAdapter;
private ModifierAdapter mModifierAdapter;
private DiscountAdapter mDiscountAdapter;
......@@ -124,7 +128,7 @@ public class MealStandPresenter extends BaseOrderPresenter<MealStandContract.Mod
/**
* 當前食品組下食品
*/
private List<Food> mFoodList = new ArrayList<>();
// private List<Food> mFoodList = new ArrayList<>();
/**
* 套餐细项数据
......
......@@ -7,6 +7,9 @@ import android.graphics.Region;
import android.text.TextUtils;
import android.view.View;
import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.OnLifecycleEvent;
import com.gingersoft.gsa.cloud.app.GsaCloudApplication;
import com.gingersoft.gsa.cloud.common.bean.BaseResult;
import com.gingersoft.gsa.cloud.common.constans.FoodSummaryConstans;
......@@ -59,6 +62,7 @@ import com.jess.arms.di.scope.ActivityScope;
import com.jess.arms.http.imageloader.ImageLoader;
import com.jess.arms.integration.AppManager;
import com.jess.arms.mvp.BasePresenter;
import com.jess.arms.utils.DeviceUtils;
import com.jess.arms.utils.RxLifecycleUtils;
import com.qmuiteam.qmui.widget.dialog.QMUIDialog;
import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction;
......@@ -83,6 +87,7 @@ import io.reactivex.schedulers.Schedulers;
import lombok.Data;
import me.jessyan.rxerrorhandler.core.RxErrorHandler;
import me.jessyan.rxerrorhandler.handler.ErrorHandleSubscriber;
import me.jessyan.rxerrorhandler.handler.RetryWithDelay;
import okhttp3.FormBody;
import okhttp3.RequestBody;
......@@ -135,7 +140,7 @@ public class TablePresenter extends BasePresenter<TableContract.Model, TableCont
private List<Function> mBottomFunctionList = new ArrayList<>(5);
private TableAction mTableAction;
private List<TableAction> mTableActions = new ArrayList<>(5);
private List<TableAction> mTableActions = new ArrayList<>(8);
/**
* 当前区域ID
......@@ -174,6 +179,11 @@ public class TablePresenter extends BasePresenter<TableContract.Model, TableCont
}
}
// @OnLifecycleEvent(Lifecycle.Event.ON_CREATE)
// void onCreate() {
// XFunctionManager.inJect(this, FunctionTable.class);
// startTablePolling();
// }
@Inject
public TablePresenter(TableContract.Model model, TableContract.View rootView) {
......@@ -183,6 +193,19 @@ public class TablePresenter extends BasePresenter<TableContract.Model, TableCont
startTablePolling();
}
@Override
public void onDestroy() {
super.onDestroy();
this.mErrorHandler = null;
this.mAppManager = null;
this.mImageLoader = null;
this.mApplication = null;
for (TableAction action : mTableActions) {
action.destroy();
}
stopTablePolling();
}
private void initTableActions(Activity context, List<Function> functions) {
for (Function function : functions) {
if (function.getResUrl().endsWith("init")) {
......@@ -201,17 +224,73 @@ public class TablePresenter extends BasePresenter<TableContract.Model, TableCont
}
}
@Override
public void onDestroy() {
super.onDestroy();
this.mErrorHandler = null;
this.mAppManager = null;
this.mImageLoader = null;
this.mApplication = null;
for (TableAction action : mTableActions) {
action.destroy();
/**
* 執行餐檯操作
*/
public boolean doTableAction(TableBean.DataBean dataBean) {
if (mTableAction != null) {
mTableAction.setActionListener(new TableAction.OnActionListener() {
@Override
public void setOperatContentText(String content) {
mRootView.setTableActionContentText(content);
}
@Override
public void resetTable(TableBean.DataBean tableBean) {
LoganManager.w_tableMode(TAG, mTableAction.getActionTitle() + " tableName=" + tableBean.getTableName());
initTable(tableBean.getId(), tableBean.getTableNumber(), true);
}
@Override
public void resetSkyTable(TableBean.DataBean tableBean) {
LoganManager.w_tableMode(TAG, mTableAction.getActionTitle() + " tableName=" + tableBean.getTableName());
if (tableBean.getScanId() == null) {
mRootView.showMessage(tableBean.getTableName() + "不是skyorder檯");
return;
}
resetSkyorder(tableBean.getId(), String.valueOf(tableBean.getScanId()));
}
@Override
public void moveTable(TableBean.DataBean tableBean) {
LoganManager.w_tableMode(TAG, mTableAction.getActionTitle() + " tableName=" + tableBean.getTableName());
// if (dataBean.getId() == tableBean.getId()) {
// CommonTipDialog.showSurpisedDialog(IActivity, "相同檯不能轉移", null, null, null, null, null);
// return;
// }
getTableToMove(tableBean);
}
@Override
public void splitTableAction(TableBean.DataBean tableBean) {
LoganManager.w_tableMode(TAG, mTableAction.getActionTitle() + " tableName=" + tableBean.getTableName());
splitTable(tableBean);
}
@Override
public void printSkyorderSuccess() {
initTableActionParameter();
mRootView.canceTableAction();
IActivity.initSkyorderModeState();
}
@Override
public void showSplitTableDialogAction() {
showSplitTableDialog(dataBean.getId());
}
@Override
public void cancel() {
initTableActionParameter();
mRootView.canceTableAction();
}
});
mTableAction.action(dataBean);
return true;
}
stopTablePolling();
return false;
}
public void initBottomFunction() {
......@@ -271,8 +350,14 @@ public class TablePresenter extends BasePresenter<TableContract.Model, TableCont
public void getTables(boolean show, RefreshLayout refreshLayout) {
int restaurantId = RestaurantInfoManager.newInstance().getRestaurantId() != 0 ? RestaurantInfoManager.newInstance().getRestaurantId() : 26;
mModel.getTables(restaurantId)
//是否驱逐缓存,为ture即不使用缓存
boolean isEvictCache = false;
if (DeviceUtils.netIsConnected(mApplication)) {
isEvictCache = true;
}
mModel.getTables(restaurantId, isEvictCache)
.subscribeOn(Schedulers.io())
// .retryWhen(new RetryWithDelay(3, 2))
.doOnSubscribe(disposable -> {
if (show && refreshLayout == null) {
mRootView.showLoading(null);
......@@ -818,8 +903,14 @@ public class TablePresenter extends BasePresenter<TableContract.Model, TableCont
public void getFoodSummarys(OnNetworkCallbackListener networkCallBackListener) {
int restaurantId = RestaurantInfoManager.newInstance().getRestaurantId();
byte businessType = FoodSummary.BUSINESS_TYPE_SKYORDER;
mModel.getFoodSummarys(restaurantId, false, businessType)
//是否驱逐缓存,为ture即不使用缓存
boolean isEvictCache = true;
if (!DeviceUtils.netIsConnected(mApplication)) {
isEvictCache = false;
}
mModel.getFoodSummarys(restaurantId, false, businessType, isEvictCache)
.subscribeOn(Schedulers.io())
// .retryWhen(new RetryWithDelay(3, 2))
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
......@@ -941,75 +1032,6 @@ public class TablePresenter extends BasePresenter<TableContract.Model, TableCont
}
/**
* 執行餐檯操作
*/
public boolean doTableAction(TableBean.DataBean dataBean) {
if (mTableAction != null) {
mTableAction.setActionListener(new TableAction.OnActionListener() {
@Override
public void setOperatContentText(String content) {
mRootView.setTableActionContentText(content);
}
@Override
public void resetTable(TableBean.DataBean tableBean) {
LoganManager.w_tableMode(TAG, mTableAction.getActionTitle() + " tableName=" + tableBean.getTableName());
initTable(tableBean.getId(), tableBean.getTableNumber(), true);
}
@Override
public void resetSkyTable(TableBean.DataBean tableBean) {
LoganManager.w_tableMode(TAG, mTableAction.getActionTitle() + " tableName=" + tableBean.getTableName());
if (tableBean.getScanId() == null) {
mRootView.showMessage(tableBean.getTableName() + "不是skyorder檯");
return;
}
resetSkyorder(tableBean.getId(), String.valueOf(tableBean.getScanId()));
}
@Override
public void moveTable(TableBean.DataBean tableBean) {
LoganManager.w_tableMode(TAG, mTableAction.getActionTitle() + " tableName=" + tableBean.getTableName());
// if (dataBean.getId() == tableBean.getId()) {
// CommonTipDialog.showSurpisedDialog(IActivity, "相同檯不能轉移", null, null, null, null, null);
// return;
// }
getTableToMove(tableBean);
}
@Override
public void splitTableAction(TableBean.DataBean tableBean) {
LoganManager.w_tableMode(TAG, mTableAction.getActionTitle() + " tableName=" + tableBean.getTableName());
splitTable(tableBean);
}
@Override
public void printSkyorderSuccess() {
initTableActionParameter();
mRootView.canceTableAction();
IActivity.initSkyorderModeState();
}
@Override
public void showSplitTableDialogAction() {
showSplitTableDialog(dataBean.getId());
}
@Override
public void cancel() {
initTableActionParameter();
mRootView.canceTableAction();
}
});
mTableAction.action(dataBean);
return true;
}
return false;
}
/**
* 初始化操作參數
*/
public void initTableActionParameter() {
......
......@@ -23,9 +23,11 @@ import androidx.recyclerview.widget.RecyclerView;
import androidx.viewpager.widget.ViewPager;
import com.billy.cc.core.component.CC;
import com.gingersoft.gsa.cloud.app.GsaCloudApplication;
import com.gingersoft.gsa.cloud.common.constans.GoldConstants;
import com.gingersoft.gsa.cloud.common.core.table.TableBean;
import com.gingersoft.gsa.cloud.common.logan.LoganManager;
import com.gingersoft.gsa.cloud.common.service.IServiceManager;
import com.gingersoft.gsa.cloud.common.utils.log.LogUtil;
import com.gingersoft.gsa.cloud.component.ComponentName;
import com.gingersoft.gsa.cloud.table.R;
......@@ -216,8 +218,9 @@ public class TableActivity extends BaseFragmentActivity<TablePresenter> implemen
@Override
public void onClick(View v) {
LoganManager.w_tableMode(TAG, "手動刷新餐檯數據");
launchActivity(new Intent(mContext, CoordinatorlayoutActivity.class));
// getTables(true, null);
// launchActivity(new Intent(mContext, CoordinatorlayoutActivity.class));
getTables(true, null);
IServiceManager.startICommandService(GsaCloudApplication.getAppContext());
}
});
rightButton2.setOnClickListener(new View.OnClickListener() {
......
......@@ -43,6 +43,7 @@ import com.jess.arms.utils.PermissionUtil;
import com.jess.arms.utils.Preconditions;
import com.qmuiteam.qmui.alpha.QMUIAlphaImageButton;
import com.qmuiteam.qmui.widget.QMUITopBar;
import com.qmuiteam.qmui.widget.webview.QMUIWebView;
import com.tbruyelle.rxpermissions2.RxPermissions;
import java.util.List;
......@@ -66,7 +67,7 @@ public class WebActivity extends BaseActivity<BasePresenter> implements IView {
@BindView(R2.id.topbar)
QMUITopBar mTopBar;
@BindView(R2.id.web_view)
WebView mWebView;
QMUIWebView mWebView;
@BindView(R2.id.progress_bar)
WebViewProgressBar mProgressBar;
@BindView(R2.id.progress_bar1)
......
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<com.qmuiteam.qmui.widget.webview.QMUIWebViewContainer xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<WebView
<com.qmuiteam.qmui.widget.webview.QMUIWebView
android:id="@+id/web_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
......@@ -31,4 +31,4 @@
android:textColor="@color/theme_hint_color"
android:textSize="@dimen/font_normal2"
android:visibility="invisible" />
</FrameLayout>
\ No newline at end of file
</com.qmuiteam.qmui.widget.webview.QMUIWebViewContainer>
\ No newline at end of file
......@@ -76,7 +76,7 @@ dependencies {
exclude module: 'rxjava'
exclude module: 'dagger'
}
implementation(rootProject.ext.dependencies["rxcache-jolyglot-gson"]) {
api(rootProject.ext.dependencies["rxcache-jolyglot-gson"]) {
exclude module: 'gson'
}
api(rootProject.ext.dependencies["rxlifecycle2"]) {
......
......@@ -97,19 +97,22 @@ public class RepositoryManager implements IRepositoryManager {
/**
* 根据传入的 Class 获取对应的 RxCache service
*
* @param cache
* @param cacheClass
* @param <T>
* @return
*/
@Override
public synchronized <T> T obtainCacheService(Class<T> cache) {
if (mCacheServiceCache == null)
public synchronized <T> T obtainCacheService(Class<T> cacheClass) {
Preconditions.checkNotNull(cacheClass, "cacheClass == null");
if (mCacheServiceCache == null) {
mCacheServiceCache = mCachefactory.build(CacheType.CACHE_SERVICE_CACHE);
Preconditions.checkNotNull(mCacheServiceCache, "Cannot return null from a Cache.Factory#build(int) method");
T cacheService = (T) mCacheServiceCache.get(cache.getCanonicalName());
}
Preconditions.checkNotNull(mCacheServiceCache,
"Cannot return null from a Cache.Factory#build(int) method");
T cacheService = (T) mCacheServiceCache.get(cacheClass.getCanonicalName());
if (cacheService == null) {
cacheService = mRxCache.get().using(cache);
mCacheServiceCache.put(cache.getCanonicalName(), cacheService);
cacheService = mRxCache.get().using(cacheClass);
mCacheServiceCache.put(cacheClass.getCanonicalName(), cacheService);
}
return cacheService;
}
......@@ -119,7 +122,7 @@ public class RepositoryManager implements IRepositoryManager {
*/
@Override
public void clearAllCache() {
mRxCache.get().evictAll();
mRxCache.get().evictAll().subscribe();
}
@Override
......
......@@ -33,7 +33,7 @@
android:name="design_height_in_dp"
android:value="640"/>
<service
android:name="com.gingersoft.gsa.cloud.common.service.DataNotificationService"
android:name="com.gingersoft.gsa.cloud.common.service.ICommandService"
android:enabled="true" />
</application>
</manifest>
......@@ -50,7 +50,10 @@ import com.gingersoft.gsa.cloud.database.DaoManager;
import com.hyweb.n5.lib.exception.NoInitPrinterException;
import com.hyweb.n5.lib.util.PrinterUtil;
import com.jess.arms.base.BaseApplication;
import com.jess.arms.utils.DeviceUtils;
import com.kingja.loadsir.core.LoadSir;
import com.qmuiteam.qmui.util.QMUIDeviceHelper;
import com.qmuiteam.qmui.util.QMUIDisplayHelper;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.footer.ClassicsFooter;
import com.scwang.smartrefresh.layout.header.ClassicsHeader;
......@@ -195,7 +198,7 @@ public class GsaCloudApplication extends BaseApplication {
* 初始化滴滴開發,測試輔助工具哆啦A夢
*/
private void initDoraemonKit() {
DoraemonKit.install(getAppContext(), DoraemonKitConfig.PRODUCE_ID);
// DoraemonKit.install(getAppContext(), DoraemonKitConfig.PRODUCE_ID);
}
/**
......@@ -462,6 +465,9 @@ public class GsaCloudApplication extends BaseApplication {
//当然, 在 APP 内您必须使用 sp 来作为字体的单位, 否则此功能无效, 不设置或将此值设为 0 则取消此功能
// .setPrivateFontScale(0.8f)
//解决已高度基准适配时底部有空隙的问题
// .setScreenHeight((QMUIDisplayHelper.getScreenHeight(this)))
//屏幕适配监听器
.setOnAdaptListener(new onAdaptListener() {
@Override
......
......@@ -2,7 +2,6 @@ package com.gingersoft.gsa.cloud.common.config.globalconfig;
import android.app.Application;
import android.content.Context;
import com.gingersoft.gsa.cloud.common.config.globalconfig.applyOptions.MyGlobalHttpHandler;
import com.gingersoft.gsa.cloud.common.config.globalconfig.applyOptions.MyGsonConfiguration;
import com.gingersoft.gsa.cloud.common.config.globalconfig.applyOptions.MyOkhttpConfiguration;
......
......@@ -8,10 +8,12 @@ import android.text.TextUtils;
import com.gingersoft.gsa.cloud.common.core.user.UserContext;
import com.gingersoft.gsa.cloud.common.R;
import com.gingersoft.gsa.cloud.app.GsaCloudApplication;
import com.gingersoft.gsa.cloud.common.utils.MoneyUtil;
import com.gingersoft.gsa.cloud.common.utils.toast.ToastUtils;
import com.gingersoft.gsa.cloud.common.logan.LoganManager;
import com.google.gson.JsonIOException;
import com.google.gson.JsonParseException;
import com.jess.arms.integration.AppManager;
import com.jess.arms.utils.ArmsUtils;
import com.qmuiteam.qmui.widget.dialog.QMUIDialog;
import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction;
......@@ -21,6 +23,10 @@ import org.json.JSONException;
import java.net.SocketTimeoutException;
import java.net.UnknownHostException;
import javax.inject.Inject;
import me.jessyan.autosize.AutoSizeConfig;
import me.jessyan.autosize.utils.AutoSizeUtils;
import me.jessyan.rxerrorhandler.handler.listener.ResponseErrorListener;
import retrofit2.HttpException;
import timber.log.Timber;
......@@ -30,8 +36,15 @@ public class MyResponseErrorListener implements ResponseErrorListener {
private final String TAG = getClass().getSimpleName();
// private AppManager mAppManager;
private boolean showloggedDialog = false;
// public MyResponseErrorListener(Context context) {
// mAppManager = ArmsUtils.obtainAppComponentFromContext(context)
// .appManager();
// }
@Override
public void handleResponseError(Context context, Throwable t) {
/* 用来提供处理所有错误的监听rxjava必要要使用ErrorHandleSubscriber(默认实现Subscriber的onError方法),此监听才生效 */
......@@ -51,7 +64,7 @@ public class MyResponseErrorListener implements ResponseErrorListener {
// ArmsUtils.snackbarText(msg);
// LogUtil.d("handleResponseError: " + t.getMessage());
LoganManager.w_code(TAG,"請求錯誤: "+t.getMessage());
LoganManager.w_code(TAG, "請求錯誤: " + t.getMessage());
if (!TextUtils.isEmpty(msg)) {
ToastUtils.show(context, msg);
......@@ -69,6 +82,7 @@ public class MyResponseErrorListener implements ResponseErrorListener {
} else if (httpException.code() == 307) {
msg = ArmsUtils.getString(context, R.string.response_error_request_was_redirected_to_another_page);
} else if (httpException.code() == 401) {
// Activity activity = mAppManager.getCurrentActivity();
Activity activity = GsaCloudApplication.getAppContext().getCurrentActivity();
// if (!showloggedDialog && activity != null) {
if (activity != null) {
......
......@@ -3,17 +3,28 @@ package com.gingersoft.gsa.cloud.common.config.globalconfig.applyOptions;
import android.content.Context;
import com.jess.arms.di.module.ClientModule;
import com.jess.arms.utils.DataHelper;
import java.io.File;
import io.rx_cache2.internal.RxCache;
import io.victoralbertos.jolyglot.GsonSpeaker;
public class MyRxCacheConfiguration implements ClientModule.RxCacheConfiguration {
@Override
public RxCache configRxCache(Context context, RxCache.Builder builder) {
// 当数据无法加载时,使用过期数据
builder.useExpiredDataIfLoaderNotAvailable(true);
// builder.useExpiredDataIfLoaderNotAvailable(true);
// 想自定义 RxCache 的缓存文件夹或者解析方式, 如改成 fastjson, 请 return rxCacheBuilder.persistence(cacheDirectory, new FastJsonSpeaker());
// 否则请 return null;
return null;
// return null;
// 当数据无法加载时,使用过期数据
return builder.useExpiredDataIfLoaderNotAvailable(true)
.persistence(provideRxCacheDirectory(context.getFilesDir()), new GsonSpeaker());
}
private File provideRxCacheDirectory(File cacheDir) {
File cacheDirectory = new File(cacheDir, "RxCache");
return DataHelper.makeDirs(cacheDirectory);
}
}
......@@ -10,6 +10,7 @@ import com.jess.arms.utils.DeviceUtils;
import java.io.IOException;
import okhttp3.CacheControl;
import okhttp3.Headers;
import okhttp3.Interceptor;
import okhttp3.Request;
......@@ -23,6 +24,8 @@ public class HeadersInterceptor implements Interceptor {
@Override
public Response intercept(Chain chain) throws IOException {
Request originalRequest = chain.request();
//有网的时候读接口上的@Headers里的配置,你可以在这里进行统一的设置
String cacheControl = originalRequest.cacheControl().toString();
Headers.Builder builder = new Headers.Builder();
builder.set("mobileVersion", android.os.Build.VERSION.RELEASE);
......
package com.gingersoft.gsa.cloud.common.leaks;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import java.lang.ref.WeakReference;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
/**
* @作者: bin
* @創建時間: 2021-03-27 17:57
* @更新時間: 2021-03-27 17:57
* @描述:可以避免內存洩漏的Handler
*/
public class WeakHandler {
private final Handler.Callback mCallback; // hard reference to Callback. We need to keep callback in memory
private final ExecHandler mExec;
private Lock mLock = new ReentrantLock();
@SuppressWarnings("ConstantConditions")
@VisibleForTesting
final ChainedRef mRunnables = new ChainedRef(mLock, null);
/**
* Default constructor associates this handler with the {@link Looper} for the
* current thread.
*
* If this thread does not have a looper, this handler won't be able to receive messages
* so an exception is thrown.
*/
public WeakHandler() {
mCallback = null;
mExec = new ExecHandler();
}
/**
* Constructor associates this handler with the {@link Looper} for the
* current thread and takes a callback interface in which you can handle
* messages.
*
* If this thread does not have a looper, this handler won't be able to receive messages
* so an exception is thrown.
*
* @param callback The callback interface in which to handle messages, or null.
*/
public WeakHandler(@Nullable Handler.Callback callback) {
mCallback = callback; // Hard referencing body
mExec = new ExecHandler(new WeakReference<>(callback)); // Weak referencing inside ExecHandler
}
/**
* Use the provided {@link Looper} instead of the default one.
*
* @param looper The looper, must not be null.
*/
public WeakHandler(@NonNull Looper looper) {
mCallback = null;
mExec = new ExecHandler(looper);
}
/**
* Use the provided {@link Looper} instead of the default one and take a callback
* interface in which to handle messages.
*
* @param looper The looper, must not be null.
* @param callback The callback interface in which to handle messages, or null.
*/
public WeakHandler(@NonNull Looper looper, @NonNull Handler.Callback callback) {
mCallback = callback;
mExec = new ExecHandler(looper, new WeakReference<>(callback));
}
/**
* Causes the Runnable r to be added to the message queue.
* The runnable will be run on the thread to which this handler is
* attached.
*
* @param r The Runnable that will be executed.
*
* @return Returns true if the Runnable was successfully placed in to the
* message queue. Returns false on failure, usually because the
* looper processing the message queue is exiting.
*/
public final boolean post(@NonNull Runnable r) {
return mExec.post(wrapRunnable(r));
}
/**
* Causes the Runnable r to be added to the message queue, to be run
* at a specific time given by <var>uptimeMillis</var>.
* <b>The time-base is {@link android.os.SystemClock#uptimeMillis}.</b>
* The runnable will be run on the thread to which this handler is attached.
*
* @param r The Runnable that will be executed.
* @param uptimeMillis The absolute time at which the callback should run,
* using the {@link android.os.SystemClock#uptimeMillis} time-base.
*
* @return Returns true if the Runnable was successfully placed in to the
* message queue. Returns false on failure, usually because the
* looper processing the message queue is exiting. Note that a
* result of true does not mean the Runnable will be processed -- if
* the looper is quit before the delivery time of the message
* occurs then the message will be dropped.
*/
public final boolean postAtTime(@NonNull Runnable r, long uptimeMillis) {
return mExec.postAtTime(wrapRunnable(r), uptimeMillis);
}
/**
* Causes the Runnable r to be added to the message queue, to be run
* at a specific time given by <var>uptimeMillis</var>.
* <b>The time-base is {@link android.os.SystemClock#uptimeMillis}.</b>
* The runnable will be run on the thread to which this handler is attached.
*
* @param r The Runnable that will be executed.
* @param uptimeMillis The absolute time at which the callback should run,
* using the {@link android.os.SystemClock#uptimeMillis} time-base.
*
* @return Returns true if the Runnable was successfully placed in to the
* message queue. Returns false on failure, usually because the
* looper processing the message queue is exiting. Note that a
* result of true does not mean the Runnable will be processed -- if
* the looper is quit before the delivery time of the message
* occurs then the message will be dropped.
*
* @see android.os.SystemClock#uptimeMillis
*/
public final boolean postAtTime(Runnable r, Object token, long uptimeMillis) {
return mExec.postAtTime(wrapRunnable(r), token, uptimeMillis);
}
/**
* Causes the Runnable r to be added to the message queue, to be run
* after the specified amount of time elapses.
* The runnable will be run on the thread to which this handler
* is attached.
*
* @param r The Runnable that will be executed.
* @param delayMillis The delay (in milliseconds) until the Runnable
* will be executed.
*
* @return Returns true if the Runnable was successfully placed in to the
* message queue. Returns false on failure, usually because the
* looper processing the message queue is exiting. Note that a
* result of true does not mean the Runnable will be processed --
* if the looper is quit before the delivery time of the message
* occurs then the message will be dropped.
*/
public final boolean postDelayed(Runnable r, long delayMillis) {
return mExec.postDelayed(wrapRunnable(r), delayMillis);
}
/**
* Posts a message to an object that implements Runnable.
* Causes the Runnable r to executed on the next iteration through the
* message queue. The runnable will be run on the thread to which this
* handler is attached.
* <b>This method is only for use in very special circumstances -- it
* can easily starve the message queue, cause ordering problems, or have
* other unexpected side-effects.</b>
*
* @param r The Runnable that will be executed.
*
* @return Returns true if the message was successfully placed in to the
* message queue. Returns false on failure, usually because the
* looper processing the message queue is exiting.
*/
public final boolean postAtFrontOfQueue(Runnable r) {
return mExec.postAtFrontOfQueue(wrapRunnable(r));
}
/**
* Remove any pending posts of Runnable r that are in the message queue.
*/
public final void removeCallbacks(Runnable r) {
final WeakRunnable runnable = mRunnables.remove(r);
if (runnable != null) {
mExec.removeCallbacks(runnable);
}
}
/**
* Remove any pending posts of Runnable <var>r</var> with Object
* <var>token</var> that are in the message queue. If <var>token</var> is null,
* all callbacks will be removed.
*/
public final void removeCallbacks(Runnable r, Object token) {
final WeakRunnable runnable = mRunnables.remove(r);
if (runnable != null) {
mExec.removeCallbacks(runnable, token);
}
}
/**
* Pushes a message onto the end of the message queue after all pending messages
* before the current time. It will be received in callback,
* in the thread attached to this handler.
*
* @return Returns true if the message was successfully placed in to the
* message queue. Returns false on failure, usually because the
* looper processing the message queue is exiting.
*/
public final boolean sendMessage(Message msg) {
return mExec.sendMessage(msg);
}
/**
* Sends a Message containing only the what value.
*
* @return Returns true if the message was successfully placed in to the
* message queue. Returns false on failure, usually because the
* looper processing the message queue is exiting.
*/
public final boolean sendEmptyMessage(int what) {
return mExec.sendEmptyMessage(what);
}
/**
* Sends a Message containing only the what value, to be delivered
* after the specified amount of time elapses.
* @see #sendMessageDelayed(android.os.Message, long)
*
* @return Returns true if the message was successfully placed in to the
* message queue. Returns false on failure, usually because the
* looper processing the message queue is exiting.
*/
public final boolean sendEmptyMessageDelayed(int what, long delayMillis) {
return mExec.sendEmptyMessageDelayed(what, delayMillis);
}
/**
* Sends a Message containing only the what value, to be delivered
* at a specific time.
* @see #sendMessageAtTime(android.os.Message, long)
*
* @return Returns true if the message was successfully placed in to the
* message queue. Returns false on failure, usually because the
* looper processing the message queue is exiting.
*/
public final boolean sendEmptyMessageAtTime(int what, long uptimeMillis) {
return mExec.sendEmptyMessageAtTime(what, uptimeMillis);
}
/**
* Enqueue a message into the message queue after all pending messages
* before (current time + delayMillis). You will receive it in
* callback, in the thread attached to this handler.
*
* @return Returns true if the message was successfully placed in to the
* message queue. Returns false on failure, usually because the
* looper processing the message queue is exiting. Note that a
* result of true does not mean the message will be processed -- if
* the looper is quit before the delivery time of the message
* occurs then the message will be dropped.
*/
public final boolean sendMessageDelayed(Message msg, long delayMillis) {
return mExec.sendMessageDelayed(msg, delayMillis);
}
/**
* Enqueue a message into the message queue after all pending messages
* before the absolute time (in milliseconds) <var>uptimeMillis</var>.
* <b>The time-base is {@link android.os.SystemClock#uptimeMillis}.</b>
* You will receive it in callback, in the thread attached
* to this handler.
*
* @param uptimeMillis The absolute time at which the message should be
* delivered, using the
* {@link android.os.SystemClock#uptimeMillis} time-base.
*
* @return Returns true if the message was successfully placed in to the
* message queue. Returns false on failure, usually because the
* looper processing the message queue is exiting. Note that a
* result of true does not mean the message will be processed -- if
* the looper is quit before the delivery time of the message
* occurs then the message will be dropped.
*/
public boolean sendMessageAtTime(Message msg, long uptimeMillis) {
return mExec.sendMessageAtTime(msg, uptimeMillis);
}
/**
* Enqueue a message at the front of the message queue, to be processed on
* the next iteration of the message loop. You will receive it in
* callback, in the thread attached to this handler.
* <b>This method is only for use in very special circumstances -- it
* can easily starve the message queue, cause ordering problems, or have
* other unexpected side-effects.</b>
*
* @return Returns true if the message was successfully placed in to the
* message queue. Returns false on failure, usually because the
* looper processing the message queue is exiting.
*/
public final boolean sendMessageAtFrontOfQueue(Message msg) {
return mExec.sendMessageAtFrontOfQueue(msg);
}
/**
* Remove any pending posts of messages with code 'what' that are in the
* message queue.
*/
public final void removeMessages(int what) {
mExec.removeMessages(what);
}
/**
* Remove any pending posts of messages with code 'what' and whose obj is
* 'object' that are in the message queue. If <var>object</var> is null,
* all messages will be removed.
*/
public final void removeMessages(int what, Object object) {
mExec.removeMessages(what, object);
}
/**
* Remove any pending posts of callbacks and sent messages whose
* <var>obj</var> is <var>token</var>. If <var>token</var> is null,
* all callbacks and messages will be removed.
*/
public final void removeCallbacksAndMessages(Object token) {
mExec.removeCallbacksAndMessages(token);
}
/**
* Check if there are any pending posts of messages with code 'what' in
* the message queue.
*/
public final boolean hasMessages(int what) {
return mExec.hasMessages(what);
}
/**
* Check if there are any pending posts of messages with code 'what' and
* whose obj is 'object' in the message queue.
*/
public final boolean hasMessages(int what, Object object) {
return mExec.hasMessages(what, object);
}
public final Looper getLooper() {
return mExec.getLooper();
}
private WeakRunnable wrapRunnable(@NonNull Runnable r) {
//noinspection ConstantConditions
if (r == null) {
throw new NullPointerException("Runnable can't be null");
}
final ChainedRef hardRef = new ChainedRef(mLock, r);
mRunnables.insertAfter(hardRef);
return hardRef.wrapper;
}
private static class ExecHandler extends Handler {
private final WeakReference<Handler.Callback> mCallback;
ExecHandler() {
mCallback = null;
}
ExecHandler(WeakReference<Handler.Callback> callback) {
mCallback = callback;
}
ExecHandler(Looper looper) {
super(looper);
mCallback = null;
}
ExecHandler(Looper looper, WeakReference<Handler.Callback> callback) {
super(looper);
mCallback = callback;
}
@Override
public void handleMessage(@NonNull Message msg) {
if (mCallback == null) {
return;
}
final Handler.Callback callback = mCallback.get();
if (callback == null) { // Already disposed
return;
}
callback.handleMessage(msg);
}
}
static class WeakRunnable implements Runnable {
private final WeakReference<Runnable> mDelegate;
private final WeakReference<ChainedRef> mReference;
WeakRunnable(WeakReference<Runnable> delegate, WeakReference<ChainedRef> reference) {
mDelegate = delegate;
mReference = reference;
}
@Override
public void run() {
final Runnable delegate = mDelegate.get();
final ChainedRef reference = mReference.get();
if (reference != null) {
reference.remove();
}
if (delegate != null) {
delegate.run();
}
}
}
static class ChainedRef {
@Nullable
ChainedRef next;
@Nullable
ChainedRef prev;
@NonNull
final Runnable runnable;
@NonNull
final WeakRunnable wrapper;
@NonNull
Lock lock;
public ChainedRef(@NonNull Lock lock, @NonNull Runnable r) {
this.runnable = r;
this.lock = lock;
this.wrapper = new WeakRunnable(new WeakReference<>(r), new WeakReference<>(this));
}
public WeakRunnable remove() {
lock.lock();
try {
if (prev != null) {
prev.next = next;
}
if (next != null) {
next.prev = prev;
}
prev = null;
next = null;
} finally {
lock.unlock();
}
return wrapper;
}
public void insertAfter(@NonNull ChainedRef candidate) {
lock.lock();
try {
if (this.next != null) {
this.next.prev = candidate;
}
candidate.next = this.next;
this.next = candidate;
candidate.prev = this;
} finally {
lock.unlock();
}
}
@Nullable
public WeakRunnable remove(Runnable obj) {
lock.lock();
try {
ChainedRef curr = this.next; // Skipping head
while (curr != null) {
if (curr.runnable == obj) { // We do comparison exactly how Handler does inside
return curr.remove();
}
curr = curr.next;
}
} finally {
lock.unlock();
}
return null;
}
}
}
......@@ -40,7 +40,7 @@ import org.json.JSONObject
import java.util.*
import java.util.concurrent.TimeUnit
class DataNotificationService : Service() {
class ICommandService : Service() {
private val TAG = "heart"
......@@ -48,7 +48,7 @@ class DataNotificationService : Service() {
* 心跳检测时间
*/
private val HEART_BEAT_RATE = (30 * 1000).toLong()//每隔30秒进行一次对长连接的心跳检测
private val WEBSOCKET_HOST_AND_PORT = "${HttpsConstans.ROOT_URL}/ricepon-websocket/js/webSocketServer"//可替换为自己的主机名和端口号
private val WEBSOCKET_HOST_AND_PORT = "${HttpsConstans.ROOT_URL}/ricepon-websocket/android/webSocketServer"//可替换为自己的主机名和端口号
private var mWebSocket: WebSocket? = null
var client: OkHttpClient? = null
......@@ -68,15 +68,15 @@ class DataNotificationService : Service() {
/**
* prj數據
*/
private var PRJ_DATA = 10
private val PRJ_DATA = 10
/**
* prj數據
*/
private var TABLE_DATA = 11
private val TABLE_DATA = 11
private var NOMAL_NOTIFITY_ID = 456
private var DELIVETY_NOTIFITY_ID = 123
private val NOMAL_NOTIFITY_ID = 456
private val DELIVETY_NOTIFITY_ID = 123
companion object {
@kotlin.jvm.JvmField
......@@ -84,27 +84,25 @@ class DataNotificationService : Service() {
@kotlin.jvm.JvmField
var CONNECTION_TYPE = "connection_type"
val CONNECTION_TYPE = "connection_type"
/**
* 开启外送接单长连
*/
@kotlin.jvm.JvmField
var OPEN_DELIVET_ORDER_CONNECTION = 2
val OPEN_DELIVET_ORDER_CONNECTION = 2
/**
* 开启数据接收长连(prj,餐台数据)
*/
@kotlin.jvm.JvmField
var OPEN_OTHER_CONNECTION = 1
val OPEN_OTHER_CONNECTION = 1
/**
* 当前连接类型
*/
@kotlin.jvm.JvmField
var mCurrConnectionType = OPEN_OTHER_CONNECTION
}
override fun onBind(intent: Intent?): IBinder? {
......@@ -242,7 +240,7 @@ class DataNotificationService : Service() {
}
fun setOnPostCallBack(postCallBack: PostCallBack?) {
this@DataNotificationService.postCallBack = postCallBack
this@ICommandService.postCallBack = postCallBack
}
fun execute(block: (isShow: Boolean) -> Unit) {
......@@ -282,7 +280,7 @@ class DataNotificationService : Service() {
it.newWebSocket(request, object : WebSocketListener() {
override fun onOpen(webSocket: WebSocket, response: Response) {//开启长连接成功的回调
super.onOpen(webSocket, response)
if (!this@DataNotificationService.isDestroy) {
if (!this@ICommandService.isDestroy) {
mWebSocket = webSocket
send(mCurrConnectionType)
putTimeLog("連接成功")
......@@ -323,7 +321,10 @@ class DataNotificationService : Service() {
.build()
.call()
} else if (type == TABLE_DATA) {
CC.obtainBuilder(ComponentName.COMPONENT_TABLE)
.setActionName("getTables")
.build()
.call()
}
}
......@@ -351,7 +352,7 @@ class DataNotificationService : Service() {
override fun onFailure(webSocket: WebSocket, t: Throwable, response: Response?) {//长连接连接失败的回调
super.onFailure(webSocket, t, response)
Log.e(TAG, "onFailure " + t.message)
if (!this@DataNotificationService.isDestroy) {
if (!this@ICommandService.isDestroy) {
//連接斷開,定時五秒,如果未重連,播放提示音
delayFun({
initSoundPool(R.raw.raw_disconnect)
......@@ -364,7 +365,6 @@ class DataNotificationService : Service() {
webSocket.cancel()
it.dispatcher().cancelAll()
}
}
})
it.dispatcher().executorService().shutdown()
......@@ -375,7 +375,7 @@ class DataNotificationService : Service() {
fun send(currConnectionType: Int) {
// val token = "weixin_" + RestaurantInfoManager.newInstance().restaurantId + "_" + UserContext.newInstance().memberId + "_" + getRandomString(24)
val token = "weixin_" + RestaurantInfoManager.newInstance().restaurantId + "_" + getRandomString(24)
LoganManager.w_code(TAG, "token=" + token);
LoganManager.w_code(TAG, "token=" + token)
if (mWebSocket != null) {
mWebSocket?.send(Gson().toJson(MsgBean(1, getConnectiontype(), token)))
}
......@@ -474,7 +474,7 @@ class DataNotificationService : Service() {
loginfo.append(":")
loginfo.append(content)
loginfo.append("\n")
LoganManager.w_network(TAG + " -> " + content);
LoganManager.w_network(TAG + " -> " + content)
}
var mIntervalDisposable: Disposable? = null
......
package com.gingersoft.gsa.cloud.common.service;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import com.billy.cc.core.component.CC;
import com.gingersoft.gsa.cloud.app.GsaCloudApplication;
import com.gingersoft.gsa.cloud.common.logan.LoganManager;
import com.gingersoft.gsa.cloud.common.utils.StytemUtils;
import com.gingersoft.gsa.cloud.component.ComponentName;
/**
* @作者: bin
* @創建時間: 2021-03-31 10:21
* @更新時間: 2021-03-31 10:21
* @描述:
*/
public class IServiceManager {
public static final String TAG = IServiceManager.class.getSimpleName();
public static void startICommandService(Context context) {
boolean deliveryOrderServiceRunning = StytemUtils.isServiceRunning("com.gingersoft.gsa.cloud.common.service.ICommandService", context);
if (!deliveryOrderServiceRunning) {
Intent service = new Intent(GsaCloudApplication.getAppContext(), ICommandService.class);
service.putExtra(ICommandService.CONNECTION_TYPE, ICommandService.mCurrConnectionType);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
context.startForegroundService(service);
} else {
context.startService(service);
}
LoganManager.w_tableMode(TAG, "启动->ICommandService");
}
}
public static void startPrjService(Context context) {
boolean prjServiceRunning = StytemUtils.isServiceRunning("com.joe.print.mvp.print.service.PrjService", context);
if (!prjServiceRunning) {
//開啟Prj打印服務
CC.obtainBuilder(ComponentName.COMPONENT_PRINT)
.setActionName("openPrintService")
.build()
.call();
LoganManager.w_tableMode(TAG, "启动->PrjService");
}
}
}
package com.gingersoft.gsa.cloud.common.webview;
import com.billy.cc.core.component.CC;
import com.billy.cc.core.component.CCResult;
import com.billy.cc.core.component.IComponentCallback;
import com.gingersoft.gsa.cloud.common.constans.PrintConstans;
import com.gingersoft.gsa.cloud.common.logan.LoganManager;
import com.gingersoft.gsa.cloud.component.ComponentName;
/**
* @作者: bin
* @創建時間: 2020-12-18 19:26
......@@ -19,4 +26,12 @@ public class WebviewHelper {
public static final int RIGHT_TYPE_SHARE = 201;
public static final int RIGHT_TYPE_REFRESH = 202;
public static final void openWebview(String url){
CC.obtainBuilder(ComponentName.COMPONENT_WEBVIEW)
.setActionName("openWebActivity")
.addParam(WebviewHelper.URL_KEY, url)
.build()
.call();
}
}
......@@ -8,6 +8,9 @@ import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.Property;
import org.greenrobot.greendao.annotation.Transient;
import java.util.concurrent.TimeUnit;
import io.reactivex.Observable;
import lombok.Data;
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment