Commit 2be48adc by sikang

UPDATE

parent 7e856eaf
package tech.starwin; package tech.starwin;
import android.app.Activity;
import android.app.Application; import android.app.Application;
import android.content.Context; import android.content.Context;
import android.support.annotation.NonNull;
import android.view.View; import android.view.View;
import android.widget.Toast;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.FirebaseApp;
import com.google.firebase.remoteconfig.FirebaseRemoteConfig; import com.google.firebase.remoteconfig.FirebaseRemoteConfig;
import com.google.firebase.remoteconfig.FirebaseRemoteConfigSettings; import com.google.firebase.remoteconfig.FirebaseRemoteConfigSettings;
import com.scwang.smartrefresh.layout.SmartRefreshLayout; import com.scwang.smartrefresh.layout.SmartRefreshLayout;
...@@ -22,16 +16,11 @@ import com.scwang.smartrefresh.layout.footer.ClassicsFooter; ...@@ -22,16 +16,11 @@ import com.scwang.smartrefresh.layout.footer.ClassicsFooter;
import com.scwang.smartrefresh.layout.header.ClassicsHeader; import com.scwang.smartrefresh.layout.header.ClassicsHeader;
import com.tencent.bugly.crashreport.CrashReport; import com.tencent.bugly.crashreport.CrashReport;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import tech.starwin.R;
import tech.starwin.mvp.beans.InviteResult;
import tech.starwin.network.Gateway; import tech.starwin.network.Gateway;
import tech.starwin.utils.FireBaseHelper; import tech.starwin.utils.FireBaseHelper;
import tech.starwin.utils.PreferencesManager; import tech.starwin.utils.PreferencesManager;
import zendesk.core.AnonymousIdentity; import zendesk.core.AnonymousIdentity;
import zendesk.core.Identity;
import zendesk.core.Zendesk; import zendesk.core.Zendesk;
import zendesk.support.Support; import zendesk.support.Support;
...@@ -39,9 +28,13 @@ import static com.facebook.accountkit.internal.AccountKitController.getApplicati ...@@ -39,9 +28,13 @@ import static com.facebook.accountkit.internal.AccountKitController.getApplicati
/** /**
* Created by SiKang on 2018/9/30. * Created by SiKang on 2018/9/30.
* 配置 BaseLibrary
*/ */
public class LibConfig { public class LibConfig {
/**
* 存储 App Module的 BuildConfig 数据
* */
private static Context CONTEXT; private static Context CONTEXT;
public static boolean DEBUG; public static boolean DEBUG;
public static String APPLICATION_ID; public static String APPLICATION_ID;
...@@ -75,7 +68,7 @@ public class LibConfig { ...@@ -75,7 +68,7 @@ public class LibConfig {
public static Context getContext() { public static Context getContext() {
if (CONTEXT == null) if (CONTEXT == null)
throw new RuntimeException("context is null ! you must execute LibConfig.bindApplication(application) in your Appliaction"); throw new RuntimeException("context is null ! you must execute LibConfig.initLib(application) in your Appliaction");
return CONTEXT; return CONTEXT;
} }
......
...@@ -10,6 +10,7 @@ import tech.starwin.utils.LoginManager; ...@@ -10,6 +10,7 @@ import tech.starwin.utils.LoginManager;
/** /**
* Created by SiKang on 2018/9/14. * Created by SiKang on 2018/9/14.
* HTTP请求回调
*/ */
public abstract class HttpObserver<T> implements Observer<T> { public abstract class HttpObserver<T> implements Observer<T> {
private Disposable disposable; private Disposable disposable;
...@@ -76,13 +77,13 @@ public abstract class HttpObserver<T> implements Observer<T> { ...@@ -76,13 +77,13 @@ public abstract class HttpObserver<T> implements Observer<T> {
LoginManager.get().tokenInvalid(); LoginManager.get().tokenInvalid();
return true; return true;
case 403: case 403:
// TODO 短信发送失败
return true; return true;
case 409: case 409:
// TODO 版本更新
return true; return true;
case 412: case 412:
// TODO 参数缺失
return true; return true;
} }
return false; return false;
......
...@@ -6,6 +6,8 @@ import tech.starwin.utils.FireBaseHelper; ...@@ -6,6 +6,8 @@ import tech.starwin.utils.FireBaseHelper;
/** /**
* Created by SiKang on 2018/10/11. * Created by SiKang on 2018/10/11.
* 自动埋点的 OnClickListener
* 给View设置一个TAG,并使用OnEventClickListener作为 Click监听事件,每次点击会自动记录一次 FireBase Event
*/ */
public abstract class OnEventClickListener implements View.OnClickListener { public abstract class OnEventClickListener implements View.OnClickListener {
......
...@@ -4,13 +4,15 @@ import android.view.View; ...@@ -4,13 +4,15 @@ import android.view.View;
/** /**
* Created by SiKang on 2018/9/18. * Created by SiKang on 2018/9/18.
* 防抖 ClickListener
*
*/ */
public abstract class OnNoShakeClickListener extends OnEventClickListener { public abstract class OnNoShakeClickListener extends OnEventClickListener {
public int lockTime = 1500; public int lockTime = 1500;
public OnNoShakeClickListener(int milliSencons) { public OnNoShakeClickListener(int milliSencons) {
this.lockTime = milliSencons; lockTime = milliSencons;
} }
public OnNoShakeClickListener() { public OnNoShakeClickListener() {
......
...@@ -6,15 +6,28 @@ import com.trello.rxlifecycle2.android.ActivityEvent; ...@@ -6,15 +6,28 @@ import com.trello.rxlifecycle2.android.ActivityEvent;
/** /**
* Created by SiKang on 2018/9/14. * Created by SiKang on 2018/9/14.
*
*/ */
public interface IView extends LifecycleProvider<ActivityEvent> { public interface IView extends LifecycleProvider<ActivityEvent> {
/**
* 请求开始
*/
void onHttpStart(String action, boolean isShowLoading); void onHttpStart(String action, boolean isShowLoading);
/**
* 响应成功,数据正常返回
*/
void onHttpSuccess(String action, Object result); void onHttpSuccess(String action, Object result);
/**
* 请求出现错误
*/
void onHttpError(String action, String msg); void onHttpError(String action, String msg);
/**
* 请求结束
*/
void onHttpFinish(String action); void onHttpFinish(String action);
} }
...@@ -20,6 +20,7 @@ import tech.starwin.mvp.beans.ResponseErrorBody; ...@@ -20,6 +20,7 @@ import tech.starwin.mvp.beans.ResponseErrorBody;
/** /**
* Created by SiKang on 2018/9/20. * Created by SiKang on 2018/9/20.
* 和贷款业务相关的 API
*/ */
public interface LoanApi { public interface LoanApi {
/** /**
......
package tech.starwin.mvp.api; package tech.starwin.mvp.api;
import java.util.List;
import io.reactivex.Observable; import io.reactivex.Observable;
import okhttp3.MultipartBody; import okhttp3.MultipartBody;
...@@ -17,6 +16,10 @@ import tech.starwin.mvp.beans.BasicAck; ...@@ -17,6 +16,10 @@ import tech.starwin.mvp.beans.BasicAck;
import tech.starwin.mvp.beans.OcrResultBean; import tech.starwin.mvp.beans.OcrResultBean;
import tech.starwin.mvp.beans.RecordFilesResponse; import tech.starwin.mvp.beans.RecordFilesResponse;
/**
* Created by SiKang on 2018/9/14.
* 涉及上传的API
*/
public interface UploadApi { public interface UploadApi {
/** /**
* 上传照片 * 上传照片
......
...@@ -46,6 +46,7 @@ import tech.starwin.mvp.beans.YWUser; ...@@ -46,6 +46,7 @@ import tech.starwin.mvp.beans.YWUser;
/** /**
* Created by SiKang on 2018/9/14. * Created by SiKang on 2018/9/14.
* 和用户相关的API
*/ */
public interface UserApi { public interface UserApi {
......
...@@ -52,9 +52,9 @@ public class LoanPresenter extends BasePresenter<LoanApi> { ...@@ -52,9 +52,9 @@ public class LoanPresenter extends BasePresenter<LoanApi> {
/** /**
* 取消贷款 * 取消贷款
* */ */
public void cancelLoan(String action,String loanAppId){ public void cancelLoan(String action, String loanAppId) {
handleRequest(action,apiService.cancelLoan(loanAppId,LoginManager.get().getToken())); handleRequest(action, apiService.cancelLoan(loanAppId, LoginManager.get().getToken()));
} }
......
...@@ -8,6 +8,10 @@ import okhttp3.ResponseBody; ...@@ -8,6 +8,10 @@ import okhttp3.ResponseBody;
import retrofit2.Converter; import retrofit2.Converter;
import retrofit2.Retrofit; import retrofit2.Retrofit;
/**
* Created by SiKang on 2018/9/14.
* responseBody 为空时,抛出空指针
*/
public class NullOnEmptyConverterFactory extends Converter.Factory { public class NullOnEmptyConverterFactory extends Converter.Factory {
@Override @Override
......
...@@ -18,7 +18,7 @@ import retrofit2.converter.gson.GsonConverterFactory; ...@@ -18,7 +18,7 @@ import retrofit2.converter.gson.GsonConverterFactory;
*/ */
public class ServiceGenerator { public class ServiceGenerator {
private static final int TIME_OUT = 3; private static final int TIME_OUT = 5;
private static Retrofit retrofit; private static Retrofit retrofit;
private static OkHttpClient okHttpClient; private static OkHttpClient okHttpClient;
......
...@@ -5,6 +5,7 @@ import android.content.Context; ...@@ -5,6 +5,7 @@ import android.content.Context;
/** /**
* Created by SiKang on 2018/10/10. * Created by SiKang on 2018/10/10.
* 动态口令生成,在HTTP请求时,服务器用来校验身份
*/ */
public class JNISignal { public class JNISignal {
static { static {
......
...@@ -16,6 +16,7 @@ import com.google.firebase.remoteconfig.FirebaseRemoteConfig; ...@@ -16,6 +16,7 @@ import com.google.firebase.remoteconfig.FirebaseRemoteConfig;
/** /**
* Created by SiKang on 2018/10/11. * Created by SiKang on 2018/10/11.
* FireBase 功能辅助类
*/ */
public class FireBaseHelper { public class FireBaseHelper {
public static final String REST_URL = "rest_url"; public static final String REST_URL = "rest_url";
......
...@@ -33,6 +33,7 @@ import tech.starwin.R; ...@@ -33,6 +33,7 @@ import tech.starwin.R;
/** /**
* Created by SiKang on 2018/9/17. * Created by SiKang on 2018/9/17.
* 常用工具
*/ */
public class GeneralUtils { public class GeneralUtils {
......
package tech.starwin.utils; package tech.starwin.utils;
import android.content.Context;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.TextView;
import com.google.firebase.analytics.FirebaseAnalytics; import com.google.firebase.analytics.FirebaseAnalytics;
......
...@@ -21,6 +21,7 @@ import tech.starwin.utils.context_utils.IntentHolder; ...@@ -21,6 +21,7 @@ import tech.starwin.utils.context_utils.IntentHolder;
/** /**
* Created by SiKang on 2018/9/19. * Created by SiKang on 2018/9/19.
* 登录数据管理
*/ */
public class LoginManager { public class LoginManager {
public static final String TAG = "LoginManager"; public static final String TAG = "LoginManager";
......
...@@ -9,6 +9,7 @@ import okhttp3.RequestBody; ...@@ -9,6 +9,7 @@ import okhttp3.RequestBody;
/** /**
* Created by SiKang on 2018/9/28. * Created by SiKang on 2018/9/28.
* 用于创建 Retrofit 上传时的 MultipartBody类型参数
*/ */
public class MultipartBodyMaker { public class MultipartBodyMaker {
MultipartBody.Builder builder; MultipartBody.Builder builder;
...@@ -17,10 +18,17 @@ public class MultipartBodyMaker { ...@@ -17,10 +18,17 @@ public class MultipartBodyMaker {
this.builder = builder; this.builder = builder;
} }
/**
* 创建多个 不同参数类型的 MultipartBody.Part
* 参数内容使用 Builder 配置
*/
public List<MultipartBody.Part> makeParts() { public List<MultipartBody.Part> makeParts() {
return builder.build().parts(); return builder.build().parts();
} }
/**
* 创建一个只包含一个参数的 MultipartBody.Part
*/
public static MultipartBody.Part makeSimplePart(String name, File file) { public static MultipartBody.Part makeSimplePart(String name, File file) {
MediaType mediaType = MediaType.parse(FileUtils.getMimeType(file)); MediaType mediaType = MediaType.parse(FileUtils.getMimeType(file));
RequestBody requestFile = RequestBody.create(mediaType, file); RequestBody requestFile = RequestBody.create(mediaType, file);
...@@ -35,12 +43,18 @@ public class MultipartBodyMaker { ...@@ -35,12 +43,18 @@ public class MultipartBodyMaker {
.setType(MultipartBody.FORM); .setType(MultipartBody.FORM);
} }
/**
* 加入单个文件
*/
public Builder addDataPart(String name, File file) { public Builder addDataPart(String name, File file) {
RequestBody imageBody = RequestBody.create(MediaType.parse(FileUtils.getMimeType(file)), file); RequestBody imageBody = RequestBody.create(MediaType.parse(FileUtils.getMimeType(file)), file);
builder.addFormDataPart(name, file.getName(), imageBody); builder.addFormDataPart(name, file.getName(), imageBody);
return this; return this;
} }
/**
* 加入多个文件
*/
public Builder addDataPart(String name, List<File> files) { public Builder addDataPart(String name, List<File> files) {
for (File file : files) { for (File file : files) {
RequestBody imageBody = RequestBody.create(MediaType.parse(FileUtils.getMimeType(file)), file); RequestBody imageBody = RequestBody.create(MediaType.parse(FileUtils.getMimeType(file)), file);
...@@ -49,6 +63,9 @@ public class MultipartBodyMaker { ...@@ -49,6 +63,9 @@ public class MultipartBodyMaker {
return this; return this;
} }
/**
* 加入String类型参数
*/
public Builder addDataPart(String name, String value) { public Builder addDataPart(String name, String value) {
builder.addFormDataPart(name, value); builder.addFormDataPart(name, value);
return this; return this;
......
...@@ -5,6 +5,7 @@ import java.util.Map; ...@@ -5,6 +5,7 @@ import java.util.Map;
/** /**
* Created by SiKang on 2018/9/14. * Created by SiKang on 2018/9/14.
*
*/ */
public class Params { public class Params {
private Map<String, Object> params; private Map<String, Object> params;
......
...@@ -14,6 +14,7 @@ import tech.starwin.mvp.beans.UserBean; ...@@ -14,6 +14,7 @@ import tech.starwin.mvp.beans.UserBean;
/** /**
* Created by SiKang on 2018/9/18. * Created by SiKang on 2018/9/18.
* SharePreferences 管理
*/ */
public class PreferencesManager { public class PreferencesManager {
private static final String PREFERENCES_FILE_NAME = "base_info"; private static final String PREFERENCES_FILE_NAME = "base_info";
......
...@@ -8,6 +8,7 @@ import tech.starwin.mvp.IView; ...@@ -8,6 +8,7 @@ import tech.starwin.mvp.IView;
/** /**
* Created by SiKang on 2018/9/16. * Created by SiKang on 2018/9/16.
* 创建和缓存Presener实例
*/ */
public class PresenterHoler { public class PresenterHoler {
...@@ -21,7 +22,7 @@ public class PresenterHoler { ...@@ -21,7 +22,7 @@ public class PresenterHoler {
} }
/** /**
* 创建Presenter * 获取一个指定类型的Presenter实例,缓存中没有则创建一个
*/ */
public <P extends BasePresenter> P getPresenter(Class<P> clz) { public <P extends BasePresenter> P getPresenter(Class<P> clz) {
P presenter = null; P presenter = null;
......
...@@ -8,6 +8,7 @@ import android.support.v4.app.FragmentManager; ...@@ -8,6 +8,7 @@ import android.support.v4.app.FragmentManager;
/** /**
* Created by SiKang on 2018/9/21. * Created by SiKang on 2018/9/21.
* 用Callback的方式实现 OnActivityResult
*/ */
public class EasyActivityResult { public class EasyActivityResult {
private static final String TAG = "EasyActivityResult"; private static final String TAG = "EasyActivityResult";
......
...@@ -15,6 +15,7 @@ import tech.starwin.utils.GeneralUtils; ...@@ -15,6 +15,7 @@ import tech.starwin.utils.GeneralUtils;
/** /**
* Created by SiKang on 2018/9/20. * Created by SiKang on 2018/9/20.
* Fragment的启动管理
*/ */
public class FragmentLauncher { public class FragmentLauncher {
private FragmentActivity activity; private FragmentActivity activity;
......
...@@ -11,6 +11,7 @@ import tech.starwin.R; ...@@ -11,6 +11,7 @@ import tech.starwin.R;
/** /**
* Created by SiKang on 2018/9/16. * Created by SiKang on 2018/9/16.
* Intent的创建和使用
*/ */
public class IntentHolder { public class IntentHolder {
private Intent intent; private Intent intent;
......
...@@ -21,6 +21,7 @@ import io.reactivex.functions.Consumer; ...@@ -21,6 +21,7 @@ import io.reactivex.functions.Consumer;
/** /**
* Created by SiKang on 2018/9/20. * Created by SiKang on 2018/9/20.
* 权限管理
*/ */
public class PermissionsHelper { public class PermissionsHelper {
......
...@@ -7,6 +7,7 @@ import org.greenrobot.eventbus.EventBus; ...@@ -7,6 +7,7 @@ import org.greenrobot.eventbus.EventBus;
/** /**
* Created by SiKang on 2018/8/19. * Created by SiKang on 2018/8/19.
* 用来构建和发送 EventMessage
*/ */
public class EventSender { public class EventSender {
......
...@@ -25,6 +25,7 @@ import io.reactivex.functions.Consumer; ...@@ -25,6 +25,7 @@ import io.reactivex.functions.Consumer;
/** /**
* Created by SiKang on 2018/2/6. * Created by SiKang on 2018/2/6.
* 快速创建常用Dialog
*/ */
public class DialogFactory { public class DialogFactory {
......
...@@ -21,6 +21,7 @@ import tech.starwin.widget.PageStateLayout; ...@@ -21,6 +21,7 @@ import tech.starwin.widget.PageStateLayout;
/** /**
* Created by SiKang on 2018/10/12. * Created by SiKang on 2018/10/12.
* QMUI辅助类
*/ */
public class QMUIHelper { public class QMUIHelper {
......
...@@ -35,6 +35,7 @@ import tech.starwin.widget.PageStateLayout; ...@@ -35,6 +35,7 @@ import tech.starwin.widget.PageStateLayout;
/** /**
* Created by SiKang on 2018/9/14. * Created by SiKang on 2018/9/14.
* 常用UI功能
*/ */
public class UIHelper { public class UIHelper {
......
...@@ -14,6 +14,7 @@ import tech.starwin.R; ...@@ -14,6 +14,7 @@ import tech.starwin.R;
/** /**
* Created by SiKang on 2018/9/19. * Created by SiKang on 2018/9/19.
* Loading 弹窗
*/ */
public class LoadingDialog extends Dialog { public class LoadingDialog extends Dialog {
private ObjectAnimator mRotationAnimation; private ObjectAnimator mRotationAnimation;
......
...@@ -18,9 +18,10 @@ import java.util.HashMap; ...@@ -18,9 +18,10 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
/** /**
* Created by SiKang on 2018/10/12. * Created by SiKang on 2018/10/12.
* 页面状态展示 loading、错误、无数据、重新请求 等
* 通过 setCustomView() 指定一个View,在view和父布局之间,嵌套一层FrameLayout,并加入自定义的展示界面
*/ */
public class PageStateLayout extends FrameLayout { public class PageStateLayout extends FrameLayout {
private View mStateView; private View mStateView;
......
...@@ -12,6 +12,7 @@ import tech.starwin.utils.ui_utils.DialogFactory; ...@@ -12,6 +12,7 @@ import tech.starwin.utils.ui_utils.DialogFactory;
/** /**
* Created by SiKang on 2018/9/19. * Created by SiKang on 2018/9/19.
* 请求进度Dialog,用于展示Loading 或 错误信息
*/ */
public class ProgressDialog { public class ProgressDialog {
//loading dialog //loading dialog
...@@ -41,6 +42,9 @@ public class ProgressDialog { ...@@ -41,6 +42,9 @@ public class ProgressDialog {
} }
} }
/**
* 关闭loading 显示错误提示
* */
@SuppressLint("CheckResult") @SuppressLint("CheckResult")
public void showError(String msg) { public void showError(String msg) {
final Dialog errorDialog = DialogFactory.createTipDialog(context, QMUITipDialog.Builder.ICON_TYPE_FAIL, msg); final Dialog errorDialog = DialogFactory.createTipDialog(context, QMUITipDialog.Builder.ICON_TYPE_FAIL, msg);
......
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