2 files added
4 files deleted
21 files modified
| | |
| | | */ |
| | | public abstract class BaseActivity<VB extends ViewBinding,VM extends BaseViewModel> extends AppCompatActivity { |
| | | |
| | | protected VB mBinding; |
| | | protected VM mViewModel; |
| | | //viewbind |
| | | protected VB mBinding; |
| | | //viewmodel |
| | | protected VM mViewModel; |
| | | protected String TAG ; |
| | | //文件读取权限 |
| | | public final String[] FILE_PERMISSIONS = new String []{Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE}; |
| | | //夹带摄像头权限 |
| | | public final String[] CAMERA_PERMISSIONS = new String[]{ FILE_PERMISSIONS[0],FILE_PERMISSIONS[1], Manifest.permission.CAMERA}; |
| | | //夹带录音权限 |
| | | public final String[] CAMERA_RECORD_PERMISSIONS = new String[]{ FILE_PERMISSIONS[0],FILE_PERMISSIONS[1], Manifest.permission.CAMERA,Manifest.permission.RECORD_AUDIO}; |
| | | |
| | | public static final String PARAMS_TITLE = "title"; |
| | |
| | | RESULT_CODE_SUCESS = 4046/*成功*/, |
| | | RESULT_CODE_CANCEL = 4043/*取消*/; |
| | | protected Context mContext; |
| | | //标题栏 |
| | | protected TitleBarView titleBarView; |
| | | |
| | | |
| | |
| | | protected void onCreate(@Nullable Bundle savedInstanceState) { |
| | | super.onCreate(savedInstanceState); |
| | | // get genericity "B" |
| | | setStatusBarBgColor(R.color.white); |
| | | setStatusBarTextColor(true); |
| | | setStatusBarBgColor(R.color.white);//白色状态栏 |
| | | setStatusBarTextColor(true);//状态栏文本黑色 |
| | | final ParameterizedType type = (ParameterizedType) this.getClass().getGenericSuperclass(); |
| | | try { |
| | | //实例化泛型类 |
| | | Class<VB> entityClass = (Class<VB>) type.getActualTypeArguments()[0]; |
| | | Method method = entityClass.getMethod("inflate", LayoutInflater.class);//get method from name "inflate"; |
| | | mBinding = (VB) method.invoke(entityClass,getLayoutInflater());//execute method to create a objct of viewbind; |
| | |
| | | } catch (Exception e) { |
| | | } |
| | | TAG = this.getClass().getSimpleName(); |
| | | initViews(); |
| | | initViews();//初始化UI |
| | | mViewModel.onCreate(this); |
| | | loadData(); |
| | | loadData();//加载数据 |
| | | } |
| | | |
| | | public abstract void initViews(); |
| | | |
| | | public abstract void loadData(); |
| | | |
| | | /** |
| | | * 是否为空 |
| | | * @param object |
| | | * @return |
| | | */ |
| | | public boolean isNull(Object object){ |
| | | return object == null || object.toString().trim().equals("") || object.equals("null"); |
| | | } |
| | | |
| | | /** |
| | | * 设置标题 |
| | | * @param text |
| | | */ |
| | | protected void setTitle(String text){ |
| | | titleBarView.setTitleText(text); |
| | | } |
| | | |
| | | protected void onTitleLeftClick(){ |
| | | onBackKeyDown(); |
| | | } |
| | | |
| | | /** |
| | | * 标题栏右侧文本 |
| | | * @param text |
| | | */ |
| | | protected void setTitleRight(String text){ |
| | | titleBarView.setRightText(text); |
| | | titleBarView.setRightDra(null); |
| | | } |
| | | |
| | | /** |
| | | * 标题栏右侧图片 |
| | | * @param drawable |
| | | */ |
| | | protected void setTitleRight(Drawable drawable){ |
| | | titleBarView.setRightText(null); |
| | | titleBarView.setRightDra(drawable); |
| | |
| | | |
| | | AlertDialog dialog; |
| | | /** |
| | | * 显示弹框 |
| | | * @param title |
| | | * @param msg |
| | | * @param resPonse |
| | | * 显示输入框弹框 |
| | | * @param title 标题 |
| | | * @param msg 消息 |
| | | * @param resPonse 回调 |
| | | */ |
| | | public void showDialog(String title,String msg,ResPonse resPonse){ |
| | | showDialog(title,msg,"确认","取消",resPonse); |
| | | } |
| | | |
| | | /** |
| | | * 显示输入框弹框 |
| | | * @param title 标题 |
| | | * @param msg 消息 |
| | | * @param hint 默认消息文本 |
| | | * @param resPonse 回调 |
| | | */ |
| | | public void showInputDialog(String title,String msg,String hint,ResPonse resPonse){ |
| | | showInputDialog(title,msg,hint,"确认","取消",resPonse); |
| | | } |
| | | |
| | | /** |
| | | * 显示输入框弹框 |
| | | * @param title 标题 |
| | | * @param msg 消息 |
| | | * @param hint 默认消息文本 |
| | | * @param btnOk 确认按钮文本 |
| | | * @param btnCancel 取消按钮文本 |
| | | * @param resPonse 回调 |
| | | */ |
| | | public void showInputDialog(String title, String msg, String hint,String btnOk,String btnCancel,final ResPonse resPonse){ |
| | | showDialog(title,msg,hint,btnOk,btnCancel,resPonse,true); |
| | | } |
| | | |
| | | /** |
| | | * 显示弹框 |
| | | * @param title |
| | | * @param msg |
| | | * @param btnOk |
| | | * @param btnCancel |
| | | * @param resPonse |
| | | * @param title 标题 |
| | | * @param msg 消息 |
| | | * @param btnOk 确认按钮文本 |
| | | * @param btnCancel 取消按钮文本 |
| | | * @param resPonse 回调 |
| | | */ |
| | | public void showDialog(String title, String msg, String btnOk,String btnCancel,final ResPonse resPonse){ |
| | | showDialog(title,msg,null,btnOk,btnCancel,resPonse,false); |
| | | } |
| | | |
| | | /** |
| | | * 显示弹框 |
| | | * @param title 标题 |
| | | * @param msg 消息 |
| | | * @param hint 默认消息文本 |
| | | * @param btnOk 确认按钮文本 |
| | | * @param btnCancel 取消按钮文本 |
| | | * @param resPonse 回调 |
| | | * @param isEdit 是否为输入框 |
| | | */ |
| | | private void showDialog(String title, String msg, String hint,String btnOk,String btnCancel,final ResPonse resPonse,boolean isEdit){ |
| | | |
| | | AlertDialog.Builder builder = new AlertDialog.Builder(this,R.style.TransparentDialog); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * viewmodel 工厂创建实例 |
| | | * @return |
| | | */ |
| | | public ViewModelProvider.Factory getViewModelFactory(){ |
| | | return ViewModelFactory.getInstance(); |
| | | } |
| | | |
| | | /** |
| | | * 透明状态栏 |
| | | * @param isBlack 是否为黑色文本 |
| | | */ |
| | | public void setStatusBarTransparent(boolean isBlack){ |
| | | //透明状态栏 |
| | | getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); |
| | | //透明导航栏 |
| | | getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); |
| | | |
| | | setStatusBarTextColor(isBlack); |
| | | final ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) titleBarView.getLayoutParams(); |
| | | layoutParams.topMargin = layoutParams.topMargin+getStatusBarHeight(); |
| | |
| | | return storePath + File.separator +fileName; |
| | | } |
| | | |
| | | |
| | | protected boolean onBackKeyDown() { |
| | | onBackPressed(); |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * 拨打电话(直接拨打电话) |
| | | * @param phoneNum 电话号码 |
| | |
| | | }); |
| | | } |
| | | |
| | | |
| | | //=========================================== |
| | | //以下为preferences操作 |
| | | public boolean getBooleanUserPrefrence(String key){ |
| | | return PreferencesUtils.getBoolean(this,key,false,PreferencesUtils.USER); |
| | | } |
| | | |
| | | public boolean getBooleanProjectPrefrence(String key){ |
| | | return PreferencesUtils.getBoolean(this,key,false,PreferencesUtils.PROJECT); |
| | | } |
New file |
| | |
| | | package com.runt.open.mvvm.base.activities; |
| | | |
| | | import androidx.fragment.app.FragmentManager; |
| | | import androidx.fragment.app.FragmentTransaction; |
| | | import androidx.viewbinding.ViewBinding; |
| | | |
| | | import com.runt.open.mvvm.R; |
| | | import com.runt.open.mvvm.base.fragments.BaseFragment; |
| | | import com.runt.open.mvvm.base.model.BaseViewModel; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 带有fragment切换的activity |
| | | * 继承此类,有效优化代码22行 |
| | | * 试用于加载各种fragment需求的activity |
| | | * Created by Runt (qingingrunt2010@qq.com) on 2022/8/13. |
| | | */ |
| | | public class BaseFragmentActivity <VB extends ViewBinding,VM extends BaseViewModel> |
| | | extends BaseActivity<VB,VM>{ |
| | | |
| | | |
| | | List<BaseFragment> fragments = new ArrayList<>(); |
| | | |
| | | /** |
| | | * 切换界面 要显示的fragnemt |
| | | * @param fragment |
| | | */ |
| | | protected void showFragment(BaseFragment fragment){ |
| | | showFragment(fragments.indexOf(fragment)); |
| | | } |
| | | |
| | | /** |
| | | * 切换界面 要显示的fragnemt |
| | | * @param position |
| | | */ |
| | | protected void showFragment(int position){ |
| | | if(position>fragments.size()-1|| position < 0){ |
| | | showToast("当前fragment不在队列中"); |
| | | return; |
| | | } |
| | | FragmentManager fragmentManager = getSupportFragmentManager(); |
| | | FragmentTransaction transaction = fragmentManager.beginTransaction(); |
| | | for(int i = 0 ; i < fragments.size() ; i ++){ |
| | | if(i != position){ |
| | | transaction.hide(fragments.get(i)); |
| | | } |
| | | } |
| | | transaction.show(fragments.get(position)); |
| | | transaction.commit(); |
| | | } |
| | | |
| | | /** |
| | | * 添加fragment |
| | | * @param fragment |
| | | */ |
| | | protected void addAndShowFragment(BaseFragment fragment){ |
| | | if(fragments.contains(fragment)){ |
| | | showFragment(fragment); |
| | | return; |
| | | } |
| | | FragmentManager fragmentManager = getSupportFragmentManager(); |
| | | FragmentTransaction transaction = fragmentManager.beginTransaction(); |
| | | for(int i = 0 ; i < fragments.size() ; i ++){ |
| | | transaction.hide(fragments.get(i)); |
| | | } |
| | | transaction.add(R.id.framelayout,fragment).commit(); |
| | | fragments.add(fragment); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 带有tablayout activity封装(带有viewpager的视图父类) |
| | | * 继承此类,有效优化代码13行 |
| | | * 项目中有过多含有viewpager的activity可调用,其他情况下不建议使用,优化代码量不佳 |
| | | * Created by Administrator on 2021/11/4 0004. |
| | | */ |
| | | @Deprecated |
| | | public abstract class BaseTabActivity<B extends ViewBinding,VM extends BaseViewModel> extends BaseActivity<B,VM> { |
| | | |
| | | TabLayout tabLayout; |
| | |
| | | new TabLayoutMediator(tabLayout, viewPager2, (tab, position) -> tab.setText(tabTitles.get(position))).attach(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * tablayout 标题列表 |
| | | * @return |
| | | */ |
| | | protected abstract List<String> initTabTitles(); |
| | | |
| | | /** |
| | | * 初始化fragment列表 |
| | | * @return |
| | | */ |
| | | protected abstract List<BaseFragment> initFragments(); |
| | | |
| | | protected List<String> getTabTitles(){ |
| | |
| | | package com.runt.open.mvvm.base.activities; |
| | | |
| | | import android.view.MotionEvent; |
| | | import android.view.View; |
| | | |
| | | import androidx.annotation.NonNull; |
| | | import androidx.lifecycle.Observer; |
| | | import androidx.recyclerview.widget.LinearLayoutManager; |
| | |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 含有上拉刷新的Activity |
| | | * 继承此类,有效优化代码60行 |
| | | * 试用于 有下拉刷新,上拉加载等分页需求的界面 |
| | | * Created by Administrator on 2021/11/4 0004. |
| | | */ |
| | | public abstract class LoadPageActivity<VB extends ViewBinding,VM extends LoadPageViewModel,A extends BaseAdapter,RESULT> |
| | |
| | | //适配器 |
| | | protected A adapter; |
| | | |
| | | protected abstract String initTitle(); |
| | | protected String initTitle(){return null;} |
| | | |
| | | @Override |
| | | public void initViews() { |
| | | setTitle(initTitle()); |
| | | if(initTitle() != null) { |
| | | setTitle(initTitle()); |
| | | } |
| | | try { |
| | | Class<A> entityClass = (Class<A>) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[2]; |
| | | this.adapter = entityClass.newInstance();//实例化泛型 |
| | |
| | | |
| | | /** |
| | | * Created by Administrator on 2021/10/27 0027. |
| | | * T 数据类型 |
| | | * V 适配器视图 |
| | | * DATA 数据类型 |
| | | * VB 适配器视图 |
| | | */ |
| | | public abstract class BaseAdapter<DATA, VB extends ViewBinding> extends RecyclerView.Adapter<RecyclerView.ViewHolder> { |
| | | |
| | |
| | | @Override |
| | | public ViewBindHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { |
| | | if(viewType == 1 ){ |
| | | // get genericity "B" |
| | | try { |
| | | //实例化viewbind |
| | | Class<VB> entityClass = (Class<VB>) ((ParameterizedType) this.getClass().getGenericSuperclass()).getActualTypeArguments()[1]; |
| | | /*for(Method method: entityClass.getMethods()){ |
| | | StringBuilder sb = new StringBuilder(); |
| | | for(Class type : method.getParameterTypes()){ |
| | | sb.append(type.getSimpleName()+","); |
| | | } |
| | | Log.e("BaseAdapter",String.format("method:%s,return:%s,param:%s",method.getName(),method.getReturnType().getSimpleName(),sb.toString())); |
| | | }*/ |
| | | Method method = entityClass.getMethod("inflate", LayoutInflater.class,ViewGroup.class,boolean.class);//get method from name "inflate"; |
| | | VB vBind = (VB) method.invoke(entityClass,LayoutInflater.from(parent.getContext()),parent,false);//execute method to create a objct of viewbind; |
| | | return new ViewBindHolder(vBind); |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | //加载空数据 |
| | | return new ViewBindHolder( LayoutNullBinding.inflate( LayoutInflater.from(parent.getContext()), parent, false ) ); |
| | | } |
| | | |
| | |
| | | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) { |
| | | // get genericity "B" |
| | | try { |
| | | //实例化viewbind,viewmodel |
| | | final ParameterizedType type = (ParameterizedType) this.getClass().getGenericSuperclass(); |
| | | Class<VB> entityClass = (Class<VB>) type.getActualTypeArguments()[0]; |
| | | Method method = entityClass.getMethod("inflate", LayoutInflater.class,ViewGroup.class,boolean.class);//get method from name "inflate"; |
| | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | //加载UI |
| | | initViews(); |
| | | return mBinding.getRoot(); |
| | | } |
| | |
| | | loadData(); |
| | | } |
| | | |
| | | /** |
| | | * 该方法内调用getActivity()为空,需要在loadData()中使用 |
| | | */ |
| | | public abstract void initViews(); |
| | | |
| | | public abstract void loadData(); |
| | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 带有tablayout fragment封装 |
| | | * 带有tablayout fragment封装(带有viewpager的视图父类) |
| | | * 继承此类,有效优化代码13行 |
| | | * 项目中有过多含有viewpager的fragment可调用,其他情况下不建议使用,优化代码量不佳 |
| | | * Created by Administrator on 2021/11/3 0003. |
| | | */ |
| | | @Deprecated |
| | | public abstract class BaseTabFragment<B extends ViewBinding,VM extends BaseViewModel> extends BaseFragment<B,VM> { |
| | | |
| | | TabLayout tabLayout; |
| | |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 分页fragment 封装 |
| | | * 含有上拉刷新的分页fragment |
| | | * 继承此类,有效优化代码60行 |
| | | * 试用于 有下拉刷新,上拉加载等分页需求的界面 |
| | | * Created by Administrator on 2021/11/3 0003. |
| | | */ |
| | | public abstract class LoadPageFragment<VB extends ViewBinding,VM extends LoadPageViewModel,A extends BaseAdapter,RESULT> extends BaseFragment<VB,VM> implements OnRefreshLoadMoreListener { |
| | |
| | | this.mActivity = activity; |
| | | } |
| | | |
| | | /** |
| | | * 获取用户信息 |
| | | */ |
| | | public void getUserBean(){ |
| | | httpObserverOn(commonApi.getUserBean(), new HttpObserver<UserBean>() { |
| | | @Override |
| | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 检查更新 |
| | | * @param showTip |
| | | */ |
| | | public void checkUpdate(boolean showTip){ |
| | | Observable<HttpApiResult<Results.ApkVersion>> appUpdate = commonApi.getAppUpdate(); |
| | | HttpObserver<Results.ApkVersion> observer = new HttpObserver<Results.ApkVersion>(mActivity) { |
| | |
| | | |
| | | |
| | | /** |
| | | * 网络请求观察 |
| | | * 网络请求观察(加载框) |
| | | * @param observable |
| | | * @param <T> |
| | | * @return |
| | |
| | | |
| | | /** |
| | | * 数据请求 |
| | | */ |
| | | /** |
| | | * 数据请求 |
| | | * @param page 页数 |
| | | * @param param 请求参数 |
| | | */ |
| | |
| | | |
| | | public MutableLiveData getLiveFailed() { |
| | | return liveFailed; |
| | | } |
| | | |
| | | public class PageHttpObserver extends HttpObserver<PageResult<D>> { |
| | | @Override |
| | | protected void onSuccess(PageResult<D> data) { |
| | | liveData.postValue(data.rows); |
| | | } |
| | | |
| | | @Override |
| | | protected void onFailed(HttpApiResult httpResult) { |
| | | mActivity.showToast(httpResult.msg); |
| | | liveFailed.postValue(1); |
| | | } |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.runt.open.mvvm.retrofit.Interceptor; |
| | | |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.runt.open.mvvm.MyApplication; |
| | | import com.runt.open.mvvm.data.PhoneDevice; |
| | | import com.runt.open.mvvm.ui.login.UserBean; |
| | | import com.runt.open.mvvm.util.DeviceUtil; |
| | | |
| | | import java.io.IOException; |
| | | |
| | | import okhttp3.Interceptor; |
| | | import okhttp3.Request; |
| | | import okhttp3.Response; |
| | | |
| | | /** |
| | | * My father is Object, ites purpose of 添加header拦截器 |
| | | * |
| | | * @purpose Created by Runt (qingingrunt2010@qq.com) on 2021-10-8. |
| | | */ |
| | | public class AddHeadersInterceptor implements Interceptor { |
| | | |
| | | @Override |
| | | public Response intercept(Chain chain) throws IOException { |
| | | return chain.proceed(addHeaders(chain.request())); |
| | | } |
| | | |
| | | protected Request addHeaders(Request request){ |
| | | Request.Builder requestBuild = request.newBuilder() |
| | | .addHeader("device", new Gson().toJson(PhoneDevice.getDevice())) |
| | | .addHeader("appVersion", DeviceUtil.getAppVersionName(MyApplication.getApplication())) |
| | | .addHeader("os", DeviceUtil.isHarmonyOS()? "harmony" : "android"); |
| | | if(UserBean.getUser() != null){ |
| | | requestBuild.addHeader("token", UserBean.getUser().getToken()); |
| | | } |
| | | return requestBuild.build().newBuilder().build(); |
| | | } |
| | | |
| | | } |
| | |
| | | * @purpose Created by Runt (qingingrunt2010@qq.com) on 2020-10-21. |
| | | */ |
| | | |
| | | public class HttpLoggingInterceptor extends EncryptInterceptor { |
| | | public class HttpLoggingInterceptor extends AddHeadersInterceptor { |
| | | |
| | | final String TAG = "HttpLogging"; |
| | | |
| | |
| | | try { |
| | | logArrays.addAll(getRequestLog(request)); |
| | | int position = logArrays.size() +2; |
| | | //request = encryptRequest(request);//加密 |
| | | response = chain.proceed(request); |
| | | logArrays.addAll(getResponseLog(response)); |
| | | NetWorkCost netWorkCost = NetWorkListenear.workCostMap.get(hashCode); |
| | |
| | | return response; |
| | | } |
| | | |
| | | /** |
| | | * 请求数据信息 |
| | | * @param request |
| | | * @return |
| | | */ |
| | | private ArrayList<String> getRequestLog(Request request) throws IOException, JSONException { |
| | | RequestBody requestBody = request.body(); |
| | | ArrayList<String> logArrays = new ArrayList<>(); |
| | |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 返回的数据信息 |
| | | * @param response |
| | | * @return |
| | | * @throws IOException |
| | | * @throws JSONException |
| | | */ |
| | | private ArrayList<String> getResponseLog(Response response) throws IOException, JSONException { |
| | | ArrayList<String> logArrays = new ArrayList<>(); |
| | | ResponseBody responseBody = response.body(); |
| | |
| | | import com.runt.open.mvvm.data.PageResult; |
| | | import com.runt.open.mvvm.data.Results; |
| | | import com.runt.open.mvvm.ui.login.UserBean; |
| | | import io.reactivex.Observable; |
| | | import okhttp3.MultipartBody; |
| | | import retrofit2.http.*; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import io.reactivex.Observable; |
| | | import okhttp3.MultipartBody; |
| | | import retrofit2.http.Field; |
| | | import retrofit2.http.FieldMap; |
| | | import retrofit2.http.FormUrlEncoded; |
| | | import retrofit2.http.GET; |
| | | import retrofit2.http.Multipart; |
| | | import retrofit2.http.POST; |
| | | import retrofit2.http.Part; |
| | | import retrofit2.http.Query; |
| | | import retrofit2.http.QueryMap; |
| | | import retrofit2.http.Url; |
| | | |
| | | /** |
| | | * My father is Object, ites purpose of 常用接口 |
| | | * |
| | | * @purpose Created by Runt (qingingrunt2010@qq.com) on 2021-7-21. |
| | | */ |
| | | |
| | | public interface CommonApiCenter { |
| | | |
| | | @GET |
| | |
| | | |
| | | |
| | | import com.runt.open.mvvm.BuildConfig; |
| | | import com.runt.open.mvvm.retrofit.Interceptor.EncryptInterceptor; |
| | | import com.runt.open.mvvm.retrofit.Interceptor.AddHeadersInterceptor; |
| | | import com.runt.open.mvvm.retrofit.Interceptor.HttpLoggingInterceptor; |
| | | import com.runt.open.mvvm.retrofit.api.CommonApiCenter; |
| | | import com.runt.open.mvvm.retrofit.converter.GsonConverterFactory; |
| | |
| | | CommonApiCenter commonApi;//常用接口 |
| | | |
| | | OkHttpClient.Builder builder = new OkHttpClient.Builder() |
| | | .addInterceptor(new EncryptInterceptor()); |
| | | .addInterceptor(new AddHeadersInterceptor()); |
| | | OkHttpClient.Builder logBuilder = new OkHttpClient.Builder() |
| | | .addInterceptor(new HttpLoggingInterceptor());//log打印拦截器 |
| | | |
| | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 日历 |
| | | * @purpose Created by Runt (qingingrunt2010@qq.com) on 2019-3-26. |
| | | */ |
| | | public class CalendarAdapter extends BaseAdapter<Results.Mycalendar, ItemCalendarDayBinding> { |
| | |
| | | import com.runt.open.mvvm.util.HandleDate; |
| | | |
| | | /** |
| | | * 金币记录 |
| | | * @purpose Created by Runt (qingingrunt2010@qq.com) on 2020-10-29. |
| | | */ |
| | | public class CoinTransAdapter extends BaseAdapter<Results.CustomCoin, ItemCoinReportBinding> { |
| | |
| | | import com.runt.open.mvvm.util.HandleDate; |
| | | |
| | | /** |
| | | * My father is Object, ites purpose of |
| | | * |
| | | * 资讯记录 |
| | | * @purpose Created by Runt (qingingrunt2010@qq.com) on 2020-8-21. |
| | | */ |
| | | |
| | | public class MsgAdapter extends BaseAdapter<Results.Message, ItemMsgBinding> { |
| | | |
| | | @Override |
| | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 数字键盘 |
| | | * @purpose Created by Runt (qingingrunt2010@qq.com) on 2020-10-30. |
| | | */ |
| | | public class NumAdapter extends BaseAdapter<String, ItemNumBinding> { |
| | |
| | | showDialog("设置支付密码", "当前账号还没有设置支付密码", "设置", "取消", new ResPonse() { |
| | | @Override |
| | | public void doSuccess(Object obj) { |
| | | //startActivity(new Intent(mContext, PaypassActivity.class).putExtra("type", 1));//去设置密码 |
| | | startActivity(new Intent(mContext, PaypassActivity.class).putExtra("type", 1));//去设置密码 |
| | | } |
| | | }); |
| | | } |
| | |
| | | import com.runt.open.mvvm.ui.paypass.PaypassActivity; |
| | | |
| | | /** |
| | | * 提现 |
| | | * @purpose Created by Runt (qingingrunt2010@qq.com) on 2020-10-30. |
| | | */ |
| | | public class WithDrawActivity extends BaseActivity<ActivityWithdrawBinding, CoinViewModel> { |
| | |
| | | loginApi = RetrofitUtils.getInstance().getRetrofit(LoginApiCenter.class); |
| | | } |
| | | |
| | | MutableLiveData<Results.StringApiResult> resetResult = new MutableLiveData<>(); |
| | | MutableLiveData<Results.StringApiResult> registerResult = new MutableLiveData<>(); |
| | | HttpObserver<UserBean> logginObserver; |
| | | |
| | |
| | | httpObserverOnLoading(loginApi.register(phone, sms, pass), new HttpObserver<Results.StringApiResult>(){ |
| | | @Override |
| | | protected void onSuccess(Results.StringApiResult data) { |
| | | resetResult.setValue(data); |
| | | registerResult.setValue(data); |
| | | } |
| | | }); |
| | | } |
| | |
| | | import com.runt.open.mvvm.base.activities.BaseActivity; |
| | | import com.runt.open.mvvm.base.adapter.FragmentAdapter; |
| | | import com.runt.open.mvvm.base.fragments.BaseFragment; |
| | | import com.runt.open.mvvm.base.model.ImpViewModel; |
| | | import com.runt.open.mvvm.data.PhoneDevice; |
| | | import com.runt.open.mvvm.databinding.ActivityMainBinding; |
| | | import com.runt.open.mvvm.listener.CustomClickListener; |
| | |
| | | |
| | | import java.util.Arrays; |
| | | |
| | | public class MainActivity extends BaseActivity<ActivityMainBinding, MainViewModel> { |
| | | public class MainActivity extends BaseActivity<ActivityMainBinding, ImpViewModel> { |
| | | |
| | | private BaseFragment[] fragments = {new PageFragments.HomeFragment(),new ServiceFragment(),new MineFragment()} ; |
| | | ActivityResultLauncher<Intent> loginLaunch = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> { |
| | |
| | | */ |
| | | public class SignInViewModel extends BaseViewModel { |
| | | |
| | | |
| | | |
| | | public void signIn(HttpObserver<String> observer){ |
| | | httpObserverOn(commonApi.signIn(),observer); |
| | | } |