Commit 3e3bdd2e by 宁斌

添加reportFragment

parent 2ea685ea
...@@ -76,6 +76,7 @@ import io.reactivex.functions.Consumer; ...@@ -76,6 +76,7 @@ import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers; import io.reactivex.schedulers.Schedulers;
import me.jessyan.rxerrorhandler.core.RxErrorHandler; import me.jessyan.rxerrorhandler.core.RxErrorHandler;
import me.jessyan.rxerrorhandler.handler.ErrorHandleSubscriber; import me.jessyan.rxerrorhandler.handler.ErrorHandleSubscriber;
import me.jessyan.rxerrorhandler.handler.RetryWithDelay;
/** /**
...@@ -207,6 +208,7 @@ public class DownloadPresenter extends BasePresenter<DownloadContract.Model, Dow ...@@ -207,6 +208,7 @@ public class DownloadPresenter extends BasePresenter<DownloadContract.Model, Dow
private void downDataRequest(Observable observable, int downIndex) { private void downDataRequest(Observable observable, int downIndex) {
observable observable
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.retryWhen(new RetryWithDelay(5, 2))
.subscribeOn(AndroidSchedulers.mainThread()) .subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView)) .compose(RxLifecycleUtils.bindToLifecycle(mRootView))
......
...@@ -69,11 +69,11 @@ public class DataDownLoadAdapter extends DefaultAdapter<DataDownLoadState> { ...@@ -69,11 +69,11 @@ public class DataDownLoadAdapter extends DefaultAdapter<DataDownLoadState> {
pb_progress.setVisibility(View.GONE); pb_progress.setVisibility(View.GONE);
break; break;
case 1: 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); pb_progress.setVisibility(View.VISIBLE);
break; break;
case 2: 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); pb_progress.setVisibility(View.GONE);
break; break;
} }
......
package com.gingersoft.gsa.cloud.login.mvp.ui.activity.mvp.ui.activity; package com.gingersoft.gsa.cloud.login.mvp.ui.activity.mvp.ui.activity;
import android.annotation.SuppressLint;
import android.app.Activity; import android.app.Activity;
import android.content.Intent; import android.content.Intent;
import android.graphics.Color; import android.graphics.Color;
...@@ -14,8 +15,10 @@ import android.view.Window; ...@@ -14,8 +15,10 @@ import android.view.Window;
import android.view.WindowManager; import android.view.WindowManager;
import android.widget.CheckBox; import android.widget.CheckBox;
import android.widget.ImageView; import android.widget.ImageView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import com.gingersoft.gsa.cloud.common.core.login.LoginBean; import com.gingersoft.gsa.cloud.common.core.login.LoginBean;
import com.gingersoft.gsa.cloud.common.core.user.UserConstans; import com.gingersoft.gsa.cloud.common.core.user.UserConstans;
import com.gingersoft.gsa.cloud.common.utils.encryption.Aes; import com.gingersoft.gsa.cloud.common.utils.encryption.Aes;
...@@ -30,6 +33,7 @@ import com.gingersoft.gsa.cloud.login.mvp.contract.LoginInterfaceImpl; ...@@ -30,6 +33,7 @@ import com.gingersoft.gsa.cloud.login.mvp.contract.LoginInterfaceImpl;
import com.gingersoft.gsa.cloud.login.mvp.presenter.LoginPresenter; import com.gingersoft.gsa.cloud.login.mvp.presenter.LoginPresenter;
import com.gingersoft.gsa.cloud.ui.widget.dialog.LoadingDialog; import com.gingersoft.gsa.cloud.ui.widget.dialog.LoadingDialog;
import com.google.android.material.textfield.TextInputEditText; import com.google.android.material.textfield.TextInputEditText;
import com.gyf.immersionbar.ImmersionBar;
import com.jess.arms.di.component.AppComponent; import com.jess.arms.di.component.AppComponent;
import com.jess.arms.integration.AppManager; import com.jess.arms.integration.AppManager;
import com.jess.arms.utils.ArmsUtils; import com.jess.arms.utils.ArmsUtils;
...@@ -44,8 +48,10 @@ import java.util.Objects; ...@@ -44,8 +48,10 @@ import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import javax.inject.Inject; import javax.inject.Inject;
import butterknife.BindView; import butterknife.BindView;
import butterknife.OnClick; import butterknife.OnClick;
import static com.jess.arms.utils.Preconditions.checkNotNull; import static com.jess.arms.utils.Preconditions.checkNotNull;
...@@ -111,10 +117,12 @@ public class LoginActivity extends LoginInterfaceImpl<LoginPresenter> implements ...@@ -111,10 +117,12 @@ public class LoginActivity extends LoginInterfaceImpl<LoginPresenter> implements
return true; return true;
} }
@SuppressLint("ResourceType")
@Override @Override
protected void onCreate(@Nullable Bundle savedInstanceState) { protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
StatusBarUtil.setColor(this,Color.parseColor("#E7F2FF")); // StatusBarUtil.setColor(this,Color.parseColor("#E7F2FF"));
// StatusBarUtil.setColor(this,ArmsUtils.getColor(mContext,R.color.trans));
} }
@Override @Override
...@@ -122,7 +130,7 @@ public class LoginActivity extends LoginInterfaceImpl<LoginPresenter> implements ...@@ -122,7 +130,7 @@ public class LoginActivity extends LoginInterfaceImpl<LoginPresenter> implements
((ImageView) findViewById(R.id.iv_top_bg)).setAdjustViewBounds(true); ((ImageView) findViewById(R.id.iv_top_bg)).setAdjustViewBounds(true);
mPresenter.requestExternalStoragePermission(); 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, "")); edAccount.setText("" + SPUtils.get(UserConstans.LOGIN_USERNAME, ""));
mRbRememberPwd.setChecked(true); mRbRememberPwd.setChecked(true);
} }
......
...@@ -21,12 +21,14 @@ import androidx.annotation.Nullable; ...@@ -21,12 +21,14 @@ import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.ConstraintLayout; import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.viewpager2.widget.ViewPager2; 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.BaseResult;
import com.gingersoft.gsa.cloud.common.bean.BaseResultOld; import com.gingersoft.gsa.cloud.common.bean.BaseResultOld;
import com.gingersoft.gsa.cloud.common.core.login.LoginBean; 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.restaurant.RestaurantInfoManager;
import com.gingersoft.gsa.cloud.common.core.user.UserConstans; 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.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.encryption.Aes;
import com.gingersoft.gsa.cloud.common.utils.other.SPUtils; import com.gingersoft.gsa.cloud.common.utils.other.SPUtils;
import com.gingersoft.gsa.cloud.login.R; import com.gingersoft.gsa.cloud.login.R;
...@@ -39,6 +41,7 @@ import com.gingersoft.gsa.cloud.login.mvp.contract.WelcomeContract; ...@@ -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.presenter.WelcomePresenter;
import com.gingersoft.gsa.cloud.login.mvp.ui.adapter.GuideAdapter; import com.gingersoft.gsa.cloud.login.mvp.ui.adapter.GuideAdapter;
import com.gingersoft.gsa.cloud.ui.widget.Indicator.UIndicator; 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.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils; import com.jess.arms.utils.ArmsUtils;
import com.jess.arms.utils.StatusBarUtil; import com.jess.arms.utils.StatusBarUtil;
...@@ -86,7 +89,7 @@ public class WelcomeActivity extends LoginInterfaceImpl<WelcomePresenter> implem ...@@ -86,7 +89,7 @@ public class WelcomeActivity extends LoginInterfaceImpl<WelcomePresenter> implem
@Override @Override
public int getStatusBarColor() { public int getStatusBarColor() {
return ArmsUtils.getColor(this,R.color.theme_white_color); return ArmsUtils.getColor(this, R.color.theme_white_color);
} }
@Override @Override
...@@ -97,7 +100,9 @@ public class WelcomeActivity extends LoginInterfaceImpl<WelcomePresenter> implem ...@@ -97,7 +100,9 @@ public class WelcomeActivity extends LoginInterfaceImpl<WelcomePresenter> implem
@Override @Override
protected void onCreate(@Nullable Bundle savedInstanceState) { protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
StatusBarUtil.setColor(this,ArmsUtils.getColor(mContext,R.color.theme_white_color)); // StatusBarUtil.setColor(this,ArmsUtils.getColor(mContext,R.color.trans));
ImmersionBar.with(this)
.barColor(R.color.theme_white_color).init();
} }
@Override @Override
...@@ -126,11 +131,22 @@ public class WelcomeActivity extends LoginInterfaceImpl<WelcomePresenter> implem ...@@ -126,11 +131,22 @@ public class WelcomeActivity extends LoginInterfaceImpl<WelcomePresenter> implem
} else { } else {
boolean isLogin = (boolean) SPUtils.get(UserConstans.AUTO_LOGIN, false); boolean isLogin = (boolean) SPUtils.get(UserConstans.AUTO_LOGIN, false);
if (isLogin) { if (isLogin) {
if (!TextUtils.isEmpty(UserContext.newInstance().getLoginToken()) && RestaurantInfoManager.newInstance().getRestaurantId() != 0) { if (!TextUtils.isEmpty(UserContext.newInstance().getLoginToken()) && RestaurantInfoManager.newInstance().getRestaurantId() != 0) {
//自動登陸 //自動登陸
String pwd = Aes.aesDecrypt((String) SPUtils.get(UserConstans.LOGIN_PASSWORD, "")); UserContext.newInstance().setState(new LoginedState());
mPresenter.login(SPUtils.get(UserConstans.LOGIN_USERNAME, "") + "", pwd);
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 { } else {
startActivity(new Intent(mContext, LoginActivity.class)); startActivity(new Intent(mContext, LoginActivity.class));
} }
...@@ -145,9 +161,21 @@ public class WelcomeActivity extends LoginInterfaceImpl<WelcomePresenter> implem ...@@ -145,9 +161,21 @@ public class WelcomeActivity extends LoginInterfaceImpl<WelcomePresenter> implem
} }
}); });
guideBeanList.add(new GuideBean("多終端雲同步,輕鬆管理所有", "為您搭建優良高效管理平台", getResources().getDrawable(R.mipmap.pic_guide_one))); guideBeanList.add(new
guideBeanList.add(new GuideBean("數據分析可視化", "數據統計一目了然,直觀看到數據變化趨勢", getResources().getDrawable(R.mipmap.pic_guide_two)));
guideBeanList.add(new GuideBean("多種點餐方式", "提供方便快捷的點餐服務,減低落錯單機會", getResources().getDrawable(R.mipmap.pic_guide_three))); 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); GuideAdapter adapter = new GuideAdapter(mContext, guideBeanList);
mVpGuide.setAdapter(adapter); mVpGuide.setAdapter(adapter);
//设置一个缩放动画 //设置一个缩放动画
...@@ -156,6 +184,9 @@ public class WelcomeActivity extends LoginInterfaceImpl<WelcomePresenter> implem ...@@ -156,6 +184,9 @@ public class WelcomeActivity extends LoginInterfaceImpl<WelcomePresenter> implem
@Override @Override
public void onPageSelected(int position) { public void onPageSelected(int position) {
super.onPageSelected(position); super.onPageSelected(position);
ImmersionBar.with(WelcomeActivity.this).barColor(R.color.theme_color).init();
updateUI(position); updateUI(position);
if (++position == guideBeanList.size() && mTvExperience.getVisibility() != View.VISIBLE) { if (++position == guideBeanList.size() && mTvExperience.getVisibility() != View.VISIBLE) {
//當前選中最後一個page,顯示進入按鈕 //當前選中最後一個page,顯示進入按鈕
......
...@@ -5,7 +5,8 @@ ...@@ -5,7 +5,8 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/theme_white_color" android:background="@color/theme_white_color"
android:orientation="vertical" android:orientation="vertical"
android:fitsSystemWindows="true"> android:fitsSystemWindows="true"
android:layout_marginTop="@dimen/dp_30">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
......
...@@ -20,8 +20,8 @@ ...@@ -20,8 +20,8 @@
<activity android:name=".mvp.ui.activity.menu.ShellActivity" /> <activity android:name=".mvp.ui.activity.menu.ShellActivity" />
<activity <activity
android:name=".mvp.ui.activity.menu.FoodMenuManageActivity" 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.ExpandListActivity" />
<activity android:name=".mvp.ui.activity.RestaurantQrCodeActivity" /> <activity android:name=".mvp.ui.activity.RestaurantQrCodeActivity" />
<activity android:name=".mvp.ui.activity.LanguageActivity" /> <activity android:name=".mvp.ui.activity.LanguageActivity" />
......
...@@ -12,6 +12,7 @@ import com.gingersoft.gsa.cloud.common.logan.LoganManager; ...@@ -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.ComponentAction;
import com.gingersoft.gsa.cloud.component.ComponentName; import com.gingersoft.gsa.cloud.component.ComponentName;
import com.gingersoft.gsa.cloud.common.function.FModule; 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.NewMainActivity;
import com.gingersoft.gsa.cloud.main.mvp.ui.activity.SettlementReportActivity; import com.gingersoft.gsa.cloud.main.mvp.ui.activity.SettlementReportActivity;
import com.gingersoft.gsa.cloud.main.mvp.ui.activity.menu.FoodMenuManageActivity; import com.gingersoft.gsa.cloud.main.mvp.ui.activity.menu.FoodMenuManageActivity;
...@@ -131,7 +132,7 @@ public class ComponentMain implements IComponent { ...@@ -131,7 +132,7 @@ public class ComponentMain implements IComponent {
} }
private void openActivity(CC cc) { private void openActivity(CC cc) {
Intent intent = new Intent(cc.getContext(), NewMainActivity.class); Intent intent = new Intent(cc.getContext(), MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
cc.getContext().startActivity(intent); cc.getContext().startActivity(intent);
// CCUtil.createNavigateIntent(cc, NewMainActivity.class); // CCUtil.createNavigateIntent(cc, NewMainActivity.class);
......
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; 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.HomeTurnoverBean;
import com.gingersoft.gsa.cloud.main.mvp.model.bean.MainBusinessBean; import com.gingersoft.gsa.cloud.main.mvp.model.bean.MainBusinessBean;
import com.jess.arms.mvp.IView; import com.jess.arms.mvp.IView;
import com.jess.arms.mvp.IModel; import com.jess.arms.mvp.IModel;
import com.tbruyelle.rxpermissions2.RxPermissions;
import java.util.Map; import java.util.Map;
...@@ -26,7 +29,9 @@ import okhttp3.RequestBody; ...@@ -26,7 +29,9 @@ import okhttp3.RequestBody;
public interface HomeContract { public interface HomeContract {
//对于经常使用的关于UI的方法可以定义到IView中,如显示隐藏进度条,和显示文字消息 //对于经常使用的关于UI的方法可以定义到IView中,如显示隐藏进度条,和显示文字消息
interface View extends IView { interface View extends IView {
void loadBusinessInfo(Map<String, HomeTurnoverBean.DataBean> data); void loginOut();
RxPermissions getRxPermissions();
} }
//Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存 //Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
...@@ -34,5 +39,17 @@ public interface HomeContract { ...@@ -34,5 +39,17 @@ public interface HomeContract {
Observable<MainBusinessBean> getRestaurantReport(RequestBody requestBody); Observable<MainBusinessBean> getRestaurantReport(RequestBody requestBody);
Observable<String> getRestaurantFunList(String restaurantId); 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; ...@@ -2,9 +2,12 @@ package com.gingersoft.gsa.cloud.main.mvp.model;
import android.app.Application; 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.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.bean.MainBusinessBean;
import com.gingersoft.gsa.cloud.main.mvp.model.service.MainReportService; 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.google.gson.Gson;
import com.jess.arms.di.scope.FragmentScope; import com.jess.arms.di.scope.FragmentScope;
import com.jess.arms.integration.IRepositoryManager; import com.jess.arms.integration.IRepositoryManager;
...@@ -60,4 +63,40 @@ public class HomeModel extends BaseModel implements HomeContract.Model { ...@@ -60,4 +63,40 @@ public class HomeModel extends BaseModel implements HomeContract.Model {
return mRepositoryManager.obtainRetrofitService(MainReportService.class) return mRepositoryManager.obtainRetrofitService(MainReportService.class)
.getRestaurantFunList(restaurantId); .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 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; ...@@ -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.presenter.MainPresenter;
import com.gingersoft.gsa.cloud.main.mvp.ui.fragment.HomeFragment; 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.MyFragment;
import com.gingersoft.gsa.cloud.main.mvp.ui.fragment.ReportListFragment;
import com.jess.arms.base.BaseFragmentActivity; import com.jess.arms.base.BaseFragmentActivity;
import com.jess.arms.di.component.AppComponent; import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils; import com.jess.arms.utils.ArmsUtils;
...@@ -26,6 +27,8 @@ import androidx.annotation.NonNull; ...@@ -26,6 +27,8 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.lifecycle.ReportFragment;
import butterknife.BindView; import butterknife.BindView;
import static com.jess.arms.utils.Preconditions.checkNotNull; import static com.jess.arms.utils.Preconditions.checkNotNull;
...@@ -83,7 +86,7 @@ public class MainActivity extends BaseFragmentActivity<MainPresenter> implements ...@@ -83,7 +86,7 @@ public class MainActivity extends BaseFragmentActivity<MainPresenter> implements
case 0: case 0:
return HomeFragment.newInstance(); return HomeFragment.newInstance();
case 1: case 1:
// return ReportFragment.newInstance(); return ReportListFragment.newInstance();
case 2: case 2:
default: default:
return MyFragment.newInstance(); return MyFragment.newInstance();
...@@ -204,7 +207,6 @@ public class MainActivity extends BaseFragmentActivity<MainPresenter> implements ...@@ -204,7 +207,6 @@ public class MainActivity extends BaseFragmentActivity<MainPresenter> implements
private long mExitTime; private long mExitTime;
@Override @Override
public boolean onKeyDown(int keyCode, KeyEvent event) { public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) { if (keyCode == KeyEvent.KEYCODE_BACK) {
......
...@@ -218,16 +218,16 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl ...@@ -218,16 +218,16 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl
} }
private void initService() { private void initService() {
// boolean deliveryOrderServiceRunning = StytemUtils.isServiceRunning("com.gingersoft.gsa.cloud.common.service.DataNotificationService", this); boolean deliveryOrderServiceRunning = StytemUtils.isServiceRunning("com.gingersoft.gsa.cloud.common.service.DataNotificationService", this);
// if (!deliveryOrderServiceRunning) { if (!deliveryOrderServiceRunning) {
// Intent service = new Intent(GsaCloudApplication.getAppContext(), DataNotificationService.class); Intent service = new Intent(GsaCloudApplication.getAppContext(), DataNotificationService.class);
// service.putExtra(DataNotificationService.CONNECTION_TYPE, DataNotificationService.mCurrConnectionType); service.putExtra(DataNotificationService.CONNECTION_TYPE, DataNotificationService.mCurrConnectionType);
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// startForegroundService(service); startForegroundService(service);
// } else { } else {
// startService(service); startService(service);
// } }
// } }
boolean prjServiceRunning = StytemUtils.isServiceRunning("com.joe.print.mvp.print.service.PrjService", this); boolean prjServiceRunning = StytemUtils.isServiceRunning("com.joe.print.mvp.print.service.PrjService", this);
if (!prjServiceRunning) { if (!prjServiceRunning) {
//開啟Prj打印服務 //開啟Prj打印服務
......
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);
}
}
...@@ -24,6 +24,7 @@ import com.gingersoft.gsa.cloud.main.mvp.contract.MainTopContract; ...@@ -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.MainBusinessBean;
import com.gingersoft.gsa.cloud.main.mvp.model.bean.MainOrderInfoChartBean; 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.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.NewMainActivity;
import com.gingersoft.gsa.cloud.main.mvp.ui.activity.ReportActivity; import com.gingersoft.gsa.cloud.main.mvp.ui.activity.ReportActivity;
import com.gingersoft.gsa.cloud.ui.AAChartCoreLib.AAChartConfiger.AAChartModel; import com.gingersoft.gsa.cloud.ui.AAChartCoreLib.AAChartConfiger.AAChartModel;
...@@ -38,6 +39,9 @@ import com.jess.arms.base.BaseFragment; ...@@ -38,6 +39,9 @@ import com.jess.arms.base.BaseFragment;
import com.jess.arms.di.component.AppComponent; import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils; import com.jess.arms.utils.ArmsUtils;
import org.simple.eventbus.EventBus;
import org.simple.eventbus.Subscriber;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -95,6 +99,8 @@ public class MainTopFragment extends BaseFragment<MainTopPresenter> implements M ...@@ -95,6 +99,8 @@ public class MainTopFragment extends BaseFragment<MainTopPresenter> implements M
@BindView(R2.id.tv_bill_trend) @BindView(R2.id.tv_bill_trend)
TextView tvBillTrend;//賬單數量較昨日上漲或下跌數量 TextView tvBillTrend;//賬單數量較昨日上漲或下跌數量
private HomeFragment homeFragment;
public static MainTopFragment newInstance() { public static MainTopFragment newInstance() {
MainTopFragment fragment = new MainTopFragment(); MainTopFragment fragment = new MainTopFragment();
return fragment; return fragment;
...@@ -186,6 +192,11 @@ public class MainTopFragment extends BaseFragment<MainTopPresenter> implements M ...@@ -186,6 +192,11 @@ public class MainTopFragment extends BaseFragment<MainTopPresenter> implements M
} }
} }
@Subscriber(tag = "onRefreshReport")
private void onRefreshReport(boolean state){
getInfo();
}
@Override @Override
public void showLoading(String message) { public void showLoading(String message) {
if (message != null) if (message != null)
...@@ -334,7 +345,8 @@ public class MainTopFragment extends BaseFragment<MainTopPresenter> implements M ...@@ -334,7 +345,8 @@ public class MainTopFragment extends BaseFragment<MainTopPresenter> implements M
@Override @Override
public void loadChart(List<MainOrderInfoChartBean.DataBean> dataBeans) { public void loadChart(List<MainOrderInfoChartBean.DataBean> dataBeans) {
((NewMainActivity)_mActivity).onFinishRefresh();//結束刷新 // homeFragment.onFinishRefresh();//結束刷新
EventBus.getDefault().post(true,"onFinishRefresh");
Object[] todayData = new Object[24];//今天的數據 Object[] todayData = new Object[24];//今天的數據
Object[] yesterdayData = new Object[24];//昨天的數據 Object[] yesterdayData = new Object[24];//昨天的數據
...@@ -400,4 +412,8 @@ public class MainTopFragment extends BaseFragment<MainTopPresenter> implements M ...@@ -400,4 +412,8 @@ public class MainTopFragment extends BaseFragment<MainTopPresenter> implements M
startActivity(new Intent(mContext, ReportActivity.class)); startActivity(new Intent(mContext, ReportActivity.class));
} }
} }
public void setHomeFragment(HomeFragment homeFragment) {
this.homeFragment = homeFragment;
}
} }
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
...@@ -103,6 +103,14 @@ public class ComponentTable implements IComponent { ...@@ -103,6 +103,14 @@ public class ComponentTable implements IComponent {
case "getInfo": case "getInfo":
getInfo(cc); getInfo(cc);
break; 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: case ComponentAction.Table.INT_ORDER:
//初始化堂食賬單類 //初始化堂食賬單類
DoshokuOrder.getInstance().initialization(); DoshokuOrder.getInstance().initialization();
...@@ -125,7 +133,6 @@ public class ComponentTable implements IComponent { ...@@ -125,7 +133,6 @@ public class ComponentTable implements IComponent {
} }
private void lifecycleFragmentDoubleText(CC cc) { private void lifecycleFragmentDoubleText(CC cc) {
// LifecycleFragment lifecycleFragment = cc.getParamItem("fragment"); // LifecycleFragment lifecycleFragment = cc.getParamItem("fragment");
// if (lifecycleFragment != null) { // if (lifecycleFragment != null) {
......
...@@ -75,7 +75,7 @@ public interface TableContract { ...@@ -75,7 +75,7 @@ public interface TableContract {
List<Modifier> queryDB_ModifierList(long fid, int mode); 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); Observable<BaseResult> getTable(int tableId, String tableNumber);
...@@ -93,7 +93,7 @@ public interface TableContract { ...@@ -93,7 +93,7 @@ public interface TableContract {
Observable<BaseResult> splitTable(int tableId); 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); Observable<BaseResult> addScan(RequestBody requestBody);
} }
......
...@@ -10,6 +10,7 @@ import com.gingersoft.gsa.cloud.database.utils.FoodDaoUtils; ...@@ -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.database.utils.ModifierDaoUtils;
import com.gingersoft.gsa.cloud.table.mvp.contract.TableContract; 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.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.OrderService;
import com.gingersoft.gsa.cloud.table.mvp.model.service.TableService; import com.gingersoft.gsa.cloud.table.mvp.model.service.TableService;
import com.google.gson.Gson; import com.google.gson.Gson;
...@@ -22,6 +23,10 @@ import java.util.List; ...@@ -22,6 +23,10 @@ import java.util.List;
import javax.inject.Inject; import javax.inject.Inject;
import io.reactivex.Observable; 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; import okhttp3.RequestBody;
...@@ -71,11 +76,22 @@ public class TableModel extends BaseModel implements TableContract.Model { ...@@ -71,11 +76,22 @@ public class TableModel extends BaseModel implements TableContract.Model {
} }
@Override @Override
public Observable<TableBean> getTables(int restaurantId) { public Observable<TableBean> getTables(int restaurantId, boolean update) {
return mRepositoryManager.obtainRetrofitService(TableService.class) // return mRepositoryManager
.getTables(restaurantId); // .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 @Override
public Observable<BaseResult> getTable(int tableId, String tableNumber) { public Observable<BaseResult> getTable(int tableId, String tableNumber) {
return mRepositoryManager.obtainRetrofitService(TableService.class) return mRepositoryManager.obtainRetrofitService(TableService.class)
...@@ -125,9 +141,16 @@ public class TableModel extends BaseModel implements TableContract.Model { ...@@ -125,9 +141,16 @@ public class TableModel extends BaseModel implements TableContract.Model {
} }
@Override @Override
public Observable<BaseResult> getFoodSummarys(int restaurantId, boolean isDefault, byte businessType) { public Observable<BaseResult> getFoodSummarys(int restaurantId, boolean isDefault, byte businessType, boolean update) {
return mRepositoryManager.obtainRetrofitService(TableService.class) return Observable.just(mRepositoryManager
.getFoodSummarys(restaurantId, isDefault, businessType); .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 @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);
}
...@@ -7,6 +7,9 @@ import android.graphics.Region; ...@@ -7,6 +7,9 @@ import android.graphics.Region;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.View; import android.view.View;
import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.OnLifecycleEvent;
import com.gingersoft.gsa.cloud.app.GsaCloudApplication; import com.gingersoft.gsa.cloud.app.GsaCloudApplication;
import com.gingersoft.gsa.cloud.common.bean.BaseResult; import com.gingersoft.gsa.cloud.common.bean.BaseResult;
import com.gingersoft.gsa.cloud.common.constans.FoodSummaryConstans; import com.gingersoft.gsa.cloud.common.constans.FoodSummaryConstans;
...@@ -59,6 +62,7 @@ import com.jess.arms.di.scope.ActivityScope; ...@@ -59,6 +62,7 @@ import com.jess.arms.di.scope.ActivityScope;
import com.jess.arms.http.imageloader.ImageLoader; import com.jess.arms.http.imageloader.ImageLoader;
import com.jess.arms.integration.AppManager; import com.jess.arms.integration.AppManager;
import com.jess.arms.mvp.BasePresenter; import com.jess.arms.mvp.BasePresenter;
import com.jess.arms.utils.DeviceUtils;
import com.jess.arms.utils.RxLifecycleUtils; import com.jess.arms.utils.RxLifecycleUtils;
import com.qmuiteam.qmui.widget.dialog.QMUIDialog; import com.qmuiteam.qmui.widget.dialog.QMUIDialog;
import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction; import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction;
...@@ -83,6 +87,7 @@ import io.reactivex.schedulers.Schedulers; ...@@ -83,6 +87,7 @@ import io.reactivex.schedulers.Schedulers;
import lombok.Data; import lombok.Data;
import me.jessyan.rxerrorhandler.core.RxErrorHandler; import me.jessyan.rxerrorhandler.core.RxErrorHandler;
import me.jessyan.rxerrorhandler.handler.ErrorHandleSubscriber; import me.jessyan.rxerrorhandler.handler.ErrorHandleSubscriber;
import me.jessyan.rxerrorhandler.handler.RetryWithDelay;
import okhttp3.FormBody; import okhttp3.FormBody;
import okhttp3.RequestBody; import okhttp3.RequestBody;
...@@ -174,6 +179,11 @@ public class TablePresenter extends BasePresenter<TableContract.Model, TableCont ...@@ -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 @Inject
public TablePresenter(TableContract.Model model, TableContract.View rootView) { public TablePresenter(TableContract.Model model, TableContract.View rootView) {
...@@ -271,8 +281,14 @@ public class TablePresenter extends BasePresenter<TableContract.Model, TableCont ...@@ -271,8 +281,14 @@ public class TablePresenter extends BasePresenter<TableContract.Model, TableCont
public void getTables(boolean show, RefreshLayout refreshLayout) { public void getTables(boolean show, RefreshLayout refreshLayout) {
int restaurantId = RestaurantInfoManager.newInstance().getRestaurantId() != 0 ? RestaurantInfoManager.newInstance().getRestaurantId() : 26; 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()) .subscribeOn(Schedulers.io())
// .retryWhen(new RetryWithDelay(3, 2))
.doOnSubscribe(disposable -> { .doOnSubscribe(disposable -> {
if (show && refreshLayout == null) { if (show && refreshLayout == null) {
mRootView.showLoading(null); mRootView.showLoading(null);
...@@ -818,8 +834,14 @@ public class TablePresenter extends BasePresenter<TableContract.Model, TableCont ...@@ -818,8 +834,14 @@ public class TablePresenter extends BasePresenter<TableContract.Model, TableCont
public void getFoodSummarys(OnNetworkCallbackListener networkCallBackListener) { public void getFoodSummarys(OnNetworkCallbackListener networkCallBackListener) {
int restaurantId = RestaurantInfoManager.newInstance().getRestaurantId(); int restaurantId = RestaurantInfoManager.newInstance().getRestaurantId();
byte businessType = FoodSummary.BUSINESS_TYPE_SKYORDER; 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()) .subscribeOn(Schedulers.io())
// .retryWhen(new RetryWithDelay(3, 2))
.subscribeOn(AndroidSchedulers.mainThread()) .subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView)) .compose(RxLifecycleUtils.bindToLifecycle(mRootView))
......
...@@ -43,6 +43,7 @@ import com.jess.arms.utils.PermissionUtil; ...@@ -43,6 +43,7 @@ import com.jess.arms.utils.PermissionUtil;
import com.jess.arms.utils.Preconditions; import com.jess.arms.utils.Preconditions;
import com.qmuiteam.qmui.alpha.QMUIAlphaImageButton; import com.qmuiteam.qmui.alpha.QMUIAlphaImageButton;
import com.qmuiteam.qmui.widget.QMUITopBar; import com.qmuiteam.qmui.widget.QMUITopBar;
import com.qmuiteam.qmui.widget.webview.QMUIWebView;
import com.tbruyelle.rxpermissions2.RxPermissions; import com.tbruyelle.rxpermissions2.RxPermissions;
import java.util.List; import java.util.List;
...@@ -66,7 +67,7 @@ public class WebActivity extends BaseActivity<BasePresenter> implements IView { ...@@ -66,7 +67,7 @@ public class WebActivity extends BaseActivity<BasePresenter> implements IView {
@BindView(R2.id.topbar) @BindView(R2.id.topbar)
QMUITopBar mTopBar; QMUITopBar mTopBar;
@BindView(R2.id.web_view) @BindView(R2.id.web_view)
WebView mWebView; QMUIWebView mWebView;
@BindView(R2.id.progress_bar) @BindView(R2.id.progress_bar)
WebViewProgressBar mProgressBar; WebViewProgressBar mProgressBar;
@BindView(R2.id.progress_bar1) @BindView(R2.id.progress_bar1)
......
<?xml version="1.0" encoding="utf-8"?> <?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" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<WebView <com.qmuiteam.qmui.widget.webview.QMUIWebView
android:id="@+id/web_view" android:id="@+id/web_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" /> android:layout_height="match_parent" />
...@@ -31,4 +31,4 @@ ...@@ -31,4 +31,4 @@
android:textColor="@color/theme_hint_color" android:textColor="@color/theme_hint_color"
android:textSize="@dimen/font_normal2" android:textSize="@dimen/font_normal2"
android:visibility="invisible" /> android:visibility="invisible" />
</FrameLayout> </com.qmuiteam.qmui.widget.webview.QMUIWebViewContainer>
\ No newline at end of file \ No newline at end of file
...@@ -76,7 +76,7 @@ dependencies { ...@@ -76,7 +76,7 @@ dependencies {
exclude module: 'rxjava' exclude module: 'rxjava'
exclude module: 'dagger' exclude module: 'dagger'
} }
implementation(rootProject.ext.dependencies["rxcache-jolyglot-gson"]) { api(rootProject.ext.dependencies["rxcache-jolyglot-gson"]) {
exclude module: 'gson' exclude module: 'gson'
} }
api(rootProject.ext.dependencies["rxlifecycle2"]) { api(rootProject.ext.dependencies["rxlifecycle2"]) {
......
...@@ -97,19 +97,22 @@ public class RepositoryManager implements IRepositoryManager { ...@@ -97,19 +97,22 @@ public class RepositoryManager implements IRepositoryManager {
/** /**
* 根据传入的 Class 获取对应的 RxCache service * 根据传入的 Class 获取对应的 RxCache service
* *
* @param cache * @param cacheClass
* @param <T> * @param <T>
* @return * @return
*/ */
@Override @Override
public synchronized <T> T obtainCacheService(Class<T> cache) { public synchronized <T> T obtainCacheService(Class<T> cacheClass) {
if (mCacheServiceCache == null) Preconditions.checkNotNull(cacheClass, "cacheClass == null");
if (mCacheServiceCache == null) {
mCacheServiceCache = mCachefactory.build(CacheType.CACHE_SERVICE_CACHE); 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) { if (cacheService == null) {
cacheService = mRxCache.get().using(cache); cacheService = mRxCache.get().using(cacheClass);
mCacheServiceCache.put(cache.getCanonicalName(), cacheService); mCacheServiceCache.put(cacheClass.getCanonicalName(), cacheService);
} }
return cacheService; return cacheService;
} }
...@@ -119,7 +122,7 @@ public class RepositoryManager implements IRepositoryManager { ...@@ -119,7 +122,7 @@ public class RepositoryManager implements IRepositoryManager {
*/ */
@Override @Override
public void clearAllCache() { public void clearAllCache() {
mRxCache.get().evictAll(); mRxCache.get().evictAll().subscribe();
} }
@Override @Override
......
...@@ -195,7 +195,7 @@ public class GsaCloudApplication extends BaseApplication { ...@@ -195,7 +195,7 @@ public class GsaCloudApplication extends BaseApplication {
* 初始化滴滴開發,測試輔助工具哆啦A夢 * 初始化滴滴開發,測試輔助工具哆啦A夢
*/ */
private void initDoraemonKit() { private void initDoraemonKit() {
DoraemonKit.install(getAppContext(), DoraemonKitConfig.PRODUCE_ID); // DoraemonKit.install(getAppContext(), DoraemonKitConfig.PRODUCE_ID);
} }
/** /**
......
...@@ -2,7 +2,6 @@ package com.gingersoft.gsa.cloud.common.config.globalconfig; ...@@ -2,7 +2,6 @@ package com.gingersoft.gsa.cloud.common.config.globalconfig;
import android.app.Application; import android.app.Application;
import android.content.Context; import android.content.Context;
import com.gingersoft.gsa.cloud.common.config.globalconfig.applyOptions.MyGlobalHttpHandler; 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.MyGsonConfiguration;
import com.gingersoft.gsa.cloud.common.config.globalconfig.applyOptions.MyOkhttpConfiguration; import com.gingersoft.gsa.cloud.common.config.globalconfig.applyOptions.MyOkhttpConfiguration;
......
...@@ -3,17 +3,28 @@ package com.gingersoft.gsa.cloud.common.config.globalconfig.applyOptions; ...@@ -3,17 +3,28 @@ package com.gingersoft.gsa.cloud.common.config.globalconfig.applyOptions;
import android.content.Context; import android.content.Context;
import com.jess.arms.di.module.ClientModule; 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.rx_cache2.internal.RxCache;
import io.victoralbertos.jolyglot.GsonSpeaker;
public class MyRxCacheConfiguration implements ClientModule.RxCacheConfiguration { public class MyRxCacheConfiguration implements ClientModule.RxCacheConfiguration {
@Override @Override
public RxCache configRxCache(Context context, RxCache.Builder builder) { public RxCache configRxCache(Context context, RxCache.Builder builder) {
// 当数据无法加载时,使用过期数据 // builder.useExpiredDataIfLoaderNotAvailable(true);
builder.useExpiredDataIfLoaderNotAvailable(true);
// 想自定义 RxCache 的缓存文件夹或者解析方式, 如改成 fastjson, 请 return rxCacheBuilder.persistence(cacheDirectory, new FastJsonSpeaker()); // 想自定义 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; ...@@ -10,6 +10,7 @@ import com.jess.arms.utils.DeviceUtils;
import java.io.IOException; import java.io.IOException;
import okhttp3.CacheControl;
import okhttp3.Headers; import okhttp3.Headers;
import okhttp3.Interceptor; import okhttp3.Interceptor;
import okhttp3.Request; import okhttp3.Request;
...@@ -23,6 +24,8 @@ public class HeadersInterceptor implements Interceptor { ...@@ -23,6 +24,8 @@ public class HeadersInterceptor implements Interceptor {
@Override @Override
public Response intercept(Chain chain) throws IOException { public Response intercept(Chain chain) throws IOException {
Request originalRequest = chain.request(); Request originalRequest = chain.request();
//有网的时候读接口上的@Headers里的配置,你可以在这里进行统一的设置
String cacheControl = originalRequest.cacheControl().toString();
Headers.Builder builder = new Headers.Builder(); Headers.Builder builder = new Headers.Builder();
builder.set("mobileVersion", android.os.Build.VERSION.RELEASE); builder.set("mobileVersion", android.os.Build.VERSION.RELEASE);
......
...@@ -48,7 +48,7 @@ class DataNotificationService : Service() { ...@@ -48,7 +48,7 @@ class DataNotificationService : Service() {
* 心跳检测时间 * 心跳检测时间
*/ */
private val HEART_BEAT_RATE = (30 * 1000).toLong()//每隔30秒进行一次对长连接的心跳检测 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 private var mWebSocket: WebSocket? = null
var client: OkHttpClient? = null var client: OkHttpClient? = null
...@@ -323,7 +323,10 @@ class DataNotificationService : Service() { ...@@ -323,7 +323,10 @@ class DataNotificationService : Service() {
.build() .build()
.call() .call()
} else if (type == TABLE_DATA) { } else if (type == TABLE_DATA) {
CC.obtainBuilder(ComponentName.COMPONENT_TABLE)
.setActionName("getTables")
.build()
.call()
} }
} }
...@@ -364,7 +367,6 @@ class DataNotificationService : Service() { ...@@ -364,7 +367,6 @@ class DataNotificationService : Service() {
webSocket.cancel() webSocket.cancel()
it.dispatcher().cancelAll() it.dispatcher().cancelAll()
} }
} }
}) })
it.dispatcher().executorService().shutdown() it.dispatcher().executorService().shutdown()
...@@ -375,7 +377,7 @@ class DataNotificationService : Service() { ...@@ -375,7 +377,7 @@ class DataNotificationService : Service() {
fun send(currConnectionType: Int) { fun send(currConnectionType: Int) {
// val token = "weixin_" + RestaurantInfoManager.newInstance().restaurantId + "_" + UserContext.newInstance().memberId + "_" + getRandomString(24) // val token = "weixin_" + RestaurantInfoManager.newInstance().restaurantId + "_" + UserContext.newInstance().memberId + "_" + getRandomString(24)
val token = "weixin_" + RestaurantInfoManager.newInstance().restaurantId + "_" + 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) { if (mWebSocket != null) {
mWebSocket?.send(Gson().toJson(MsgBean(1, getConnectiontype(), token))) mWebSocket?.send(Gson().toJson(MsgBean(1, getConnectiontype(), token)))
} }
...@@ -474,7 +476,7 @@ class DataNotificationService : Service() { ...@@ -474,7 +476,7 @@ class DataNotificationService : Service() {
loginfo.append(":") loginfo.append(":")
loginfo.append(content) loginfo.append(content)
loginfo.append("\n") loginfo.append("\n")
LoganManager.w_network(TAG + " -> " + content); LoganManager.w_network(TAG + " -> " + content)
} }
var mIntervalDisposable: Disposable? = null var mIntervalDisposable: Disposable? = null
......
package com.gingersoft.gsa.cloud.common.webview; 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 * @作者: bin
* @創建時間: 2020-12-18 19:26 * @創建時間: 2020-12-18 19:26
...@@ -19,4 +26,12 @@ public class WebviewHelper { ...@@ -19,4 +26,12 @@ public class WebviewHelper {
public static final int RIGHT_TYPE_SHARE = 201; public static final int RIGHT_TYPE_SHARE = 201;
public static final int RIGHT_TYPE_REFRESH = 202; 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();
}
} }
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