From 3d7a82125cf380fed6301d015da2f1e0c9f5f8ce Mon Sep 17 00:00:00 2001 From: yimiao Date: Mon, 2 Aug 2021 10:54:52 +0800 Subject: [PATCH] =?UTF-8?q?desc:=E6=8F=90=E4=BE=9B=E7=BD=91=E7=BB=9C?= =?UTF-8?q?=E8=AF=B7=E6=B1=82=E7=9A=84=E6=8A=BD=E8=B1=A1=E7=B1=BB=20author?= =?UTF-8?q?:wangyimiao?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/commonlibtest/DemoActivity.java | 24 ++++--------------- .../commonlibtest/manager/CollectionLoader.kt | 2 +- .../commonlibtest/manager/InternetLoader.kt | 2 +- .../commonlibtest/manager/LoginLoader.kt | 2 +- .../com/common/commonlib/net/BaseObserve.kt | 1 + .../common/commonlib/net/RequestCallBack.kt | 13 ---------- .../common/commonlib/net/RequestManager.kt | 4 ++-- .../net/callback/RequestResultCallBack.kt | 19 +++++++++++++++ .../commonlib/view/CommonTitleView.java | 8 +++++-- .../com/common/commonlib/view/MikeView.java | 6 +++++ .../commonlib/view/SlideRecyclerView.java | 6 ++--- .../commonlib/view/activity/BaseActivity.java | 6 +++++ .../activity/PermissionCompatActivity.java | 3 +++ commonLib/src/main/res/values/dimens.xml | 1 + 14 files changed, 55 insertions(+), 42 deletions(-) delete mode 100644 commonLib/src/main/java/com/common/commonlib/net/RequestCallBack.kt create mode 100644 commonLib/src/main/java/com/common/commonlib/net/callback/RequestResultCallBack.kt diff --git a/app/src/main/java/com/common/commonlibtest/DemoActivity.java b/app/src/main/java/com/common/commonlibtest/DemoActivity.java index 5a80bcf..cabe3f1 100644 --- a/app/src/main/java/com/common/commonlibtest/DemoActivity.java +++ b/app/src/main/java/com/common/commonlibtest/DemoActivity.java @@ -8,7 +8,8 @@ import com.common.commonlib.image.config.GlideHolderConfig; import com.common.commonlib.image.config.GlideTransitionConfig; import com.common.commonlib.image.loader.ImageLoader; import com.common.commonlib.log.Logger; -import com.common.commonlib.net.RequestCallBack; +import com.common.commonlib.net.callback.RequestNoResultCallBack; +import com.common.commonlib.net.callback.RequestResultCallBack; import com.common.commonlib.net.interceptor.RequestHeadInterceptor; import com.common.commonlib.net.interceptor.ResponseHeadInterceptor; import com.common.commonlib.utils.BaseUtils; @@ -53,7 +54,7 @@ public class DemoActivity extends AppCompatActivity { binding.tv.setOnClickListener(l -> { InternetLoader loader = new InternetLoader(); - loader.getHomeArticles(0, new RequestCallBack() { + loader.getHomeArticles(0, new RequestResultCallBack() { @Override public void onResult(ArticlesResponse result) { Logger.INSTANCE.d(TAG, result.getData().toString()); @@ -63,11 +64,6 @@ public class DemoActivity extends AppCompatActivity { public void onError(@Nullable String error) { Logger.INSTANCE.d(TAG, "onError"); } - - @Override - public void onComplete() { - Logger.INSTANCE.d(TAG, "onComplete"); - } }); }); @@ -79,12 +75,7 @@ public class DemoActivity extends AppCompatActivity { builder.addHeadParams("Cookie", "loginUserName_wanandroid_com=wang11;token_pass_wanandroid_com=6fbec4fe15d69af8b4531171798f3926;loginUserName=wang11;token_pass=6fbec4fe15d69af8b4531171798f3926"); interceptors.add(builder.build()); CollectionLoader loader = new CollectionLoader(interceptors); - loader.getCollections(0, new RequestCallBack() { - @Override - public void onResult(CollectionResponse result) { - Logger.INSTANCE.d(TAG, "onResult"); - } - + loader.getCollections(0, new RequestNoResultCallBack() { @Override public void onError(@Nullable String error) { Logger.INSTANCE.d(TAG, "onError"); @@ -103,12 +94,7 @@ public class DemoActivity extends AppCompatActivity { Headers headers = response.headers(); List cookies = headers.values("Set-Cookie"); })); - new LoginLoader(interceptors).login("wang11", "wang456852", new RequestCallBack() { - @Override - public void onResult(LoginResponse result) { - Logger.INSTANCE.d(TAG, "onResult"); - } - + new LoginLoader(interceptors).login("wang11", "wang456852", new RequestNoResultCallBack() { @Override public void onError(@Nullable String error) { Logger.INSTANCE.e(TAG, "onError"); diff --git a/app/src/main/java/com/common/commonlibtest/manager/CollectionLoader.kt b/app/src/main/java/com/common/commonlibtest/manager/CollectionLoader.kt index 746eb53..d40764c 100644 --- a/app/src/main/java/com/common/commonlibtest/manager/CollectionLoader.kt +++ b/app/src/main/java/com/common/commonlibtest/manager/CollectionLoader.kt @@ -1,7 +1,7 @@ package com.common.commonlibtest.manager import com.common.commonlib.net.BaseObserve -import com.common.commonlib.net.RequestCallBack +import com.common.commonlib.net.callback.RequestCallBack import com.common.commonlibtest.bean.CollectionResponse import io.reactivex.rxjava3.core.Observable import okhttp3.Interceptor diff --git a/app/src/main/java/com/common/commonlibtest/manager/InternetLoader.kt b/app/src/main/java/com/common/commonlibtest/manager/InternetLoader.kt index 593cfab..5d7a9e2 100644 --- a/app/src/main/java/com/common/commonlibtest/manager/InternetLoader.kt +++ b/app/src/main/java/com/common/commonlibtest/manager/InternetLoader.kt @@ -1,7 +1,7 @@ package com.common.commonlibtest.manager -import com.common.commonlib.net.RequestCallBack import com.common.commonlib.net.BaseObserve +import com.common.commonlib.net.callback.RequestCallBack import com.common.commonlibtest.bean.ArticlesResponse import io.reactivex.rxjava3.core.Observable import retrofit2.http.GET diff --git a/app/src/main/java/com/common/commonlibtest/manager/LoginLoader.kt b/app/src/main/java/com/common/commonlibtest/manager/LoginLoader.kt index c005bcf..3fc01cd 100644 --- a/app/src/main/java/com/common/commonlibtest/manager/LoginLoader.kt +++ b/app/src/main/java/com/common/commonlibtest/manager/LoginLoader.kt @@ -1,7 +1,7 @@ package com.common.commonlibtest.manager import com.common.commonlib.net.BaseObserve -import com.common.commonlib.net.RequestCallBack +import com.common.commonlib.net.callback.RequestCallBack import com.common.commonlibtest.bean.LoginResponse import io.reactivex.rxjava3.core.Observable import okhttp3.Interceptor diff --git a/commonLib/src/main/java/com/common/commonlib/net/BaseObserve.kt b/commonLib/src/main/java/com/common/commonlib/net/BaseObserve.kt index 59bc5a2..1f78ff8 100644 --- a/commonLib/src/main/java/com/common/commonlib/net/BaseObserve.kt +++ b/commonLib/src/main/java/com/common/commonlib/net/BaseObserve.kt @@ -2,6 +2,7 @@ package com.common.commonlib.net import android.net.ParseException import android.util.Log +import com.common.commonlib.net.callback.RequestCallBack import com.google.gson.JsonParseException import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers import io.reactivex.rxjava3.core.Observable diff --git a/commonLib/src/main/java/com/common/commonlib/net/RequestCallBack.kt b/commonLib/src/main/java/com/common/commonlib/net/RequestCallBack.kt deleted file mode 100644 index dd8adc6..0000000 --- a/commonLib/src/main/java/com/common/commonlib/net/RequestCallBack.kt +++ /dev/null @@ -1,13 +0,0 @@ -package com.common.commonlib.net - -/** - * 请求回调 - * - * @author wangym - * @since 2021/7/28 - */ -interface RequestCallBack { - fun onResult(result: T) - fun onError(error: String?) - fun onComplete() -} \ No newline at end of file diff --git a/commonLib/src/main/java/com/common/commonlib/net/RequestManager.kt b/commonLib/src/main/java/com/common/commonlib/net/RequestManager.kt index c248517..44727bc 100644 --- a/commonLib/src/main/java/com/common/commonlib/net/RequestManager.kt +++ b/commonLib/src/main/java/com/common/commonlib/net/RequestManager.kt @@ -17,12 +17,12 @@ import java.util.concurrent.TimeUnit */ object RequestManager { /** - * 默认超时时间 + * 默认超时时间(s) */ private const val defaultTimeOut: Long = 5 /** - * 默认读取超时时间 + * 默认读取超时时间(s) */ private const val defaultReadTimeOut: Long = 10 diff --git a/commonLib/src/main/java/com/common/commonlib/net/callback/RequestResultCallBack.kt b/commonLib/src/main/java/com/common/commonlib/net/callback/RequestResultCallBack.kt new file mode 100644 index 0000000..7aac15c --- /dev/null +++ b/commonLib/src/main/java/com/common/commonlib/net/callback/RequestResultCallBack.kt @@ -0,0 +1,19 @@ +package com.common.commonlib.net.callback + +import com.common.commonlib.log.Logger + +/** + * 不需要关注onComplete的请求回调 + * + * @author wangym + * @since 2021/8/2 + */ +abstract class RequestResultCallBack : RequestCallBack { + abstract override fun onResult(result: T) + + abstract override fun onError(error: String?) + + override fun onComplete() { + Logger.d("RequestResultCallBack: onComplete") + } +} \ No newline at end of file diff --git a/commonLib/src/main/java/com/common/commonlib/view/CommonTitleView.java b/commonLib/src/main/java/com/common/commonlib/view/CommonTitleView.java index 07c4373..05f5441 100644 --- a/commonLib/src/main/java/com/common/commonlib/view/CommonTitleView.java +++ b/commonLib/src/main/java/com/common/commonlib/view/CommonTitleView.java @@ -10,11 +10,15 @@ import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.TextView; -import androidx.navigation.Navigation; - import com.common.commonlib.R; import com.common.commonlib.utils.DisplayUtils; +/** + * 通用标题栏 + * + * @author miracle + * @since 2021/8/2 + */ public class CommonTitleView extends FrameLayout implements View.OnClickListener { private Context mContext; private ImageView ivLeft; diff --git a/commonLib/src/main/java/com/common/commonlib/view/MikeView.java b/commonLib/src/main/java/com/common/commonlib/view/MikeView.java index 638f522..4324164 100644 --- a/commonLib/src/main/java/com/common/commonlib/view/MikeView.java +++ b/commonLib/src/main/java/com/common/commonlib/view/MikeView.java @@ -16,6 +16,12 @@ import androidx.annotation.Nullable; import com.common.commonlib.R; +/** + * mic自定义View + * + * @author miracle + * @since 2021/8/2 + */ public class MikeView extends View { //进度条格数 private final int COUNT = 16; diff --git a/commonLib/src/main/java/com/common/commonlib/view/SlideRecyclerView.java b/commonLib/src/main/java/com/common/commonlib/view/SlideRecyclerView.java index 88c1865..d4562e6 100644 --- a/commonLib/src/main/java/com/common/commonlib/view/SlideRecyclerView.java +++ b/commonLib/src/main/java/com/common/commonlib/view/SlideRecyclerView.java @@ -16,10 +16,10 @@ import androidx.recyclerview.widget.RecyclerView; /** * 支持侧滑删除的RecyclerView - *

- * Created by DavidChen on 2018/5/29. + * + * @author wangym + * @since 2021/8/2 */ - public class SlideRecyclerView extends RecyclerView { private static final String TAG = "SlideRecyclerView"; private static final int INVALID_POSITION = -1; // 触摸到的点不在子View范围内 diff --git a/commonLib/src/main/java/com/common/commonlib/view/activity/BaseActivity.java b/commonLib/src/main/java/com/common/commonlib/view/activity/BaseActivity.java index 2233bd8..88659cb 100644 --- a/commonLib/src/main/java/com/common/commonlib/view/activity/BaseActivity.java +++ b/commonLib/src/main/java/com/common/commonlib/view/activity/BaseActivity.java @@ -9,6 +9,12 @@ import androidx.appcompat.app.AppCompatActivity; import com.common.commonlib.R; +/** + * 基础activity + * + * @author miracle + * @since 2021/8/2 + */ public class BaseActivity extends AppCompatActivity { @Override diff --git a/commonLib/src/main/java/com/common/commonlib/view/activity/PermissionCompatActivity.java b/commonLib/src/main/java/com/common/commonlib/view/activity/PermissionCompatActivity.java index d5e71d3..1f21c2c 100644 --- a/commonLib/src/main/java/com/common/commonlib/view/activity/PermissionCompatActivity.java +++ b/commonLib/src/main/java/com/common/commonlib/view/activity/PermissionCompatActivity.java @@ -28,6 +28,9 @@ import java.util.List; * 权限申请Activity * 继承与此Activity,调用requestPermission()方法,即可快速实现权限动态申请功能 * 默认基于系统的的弹窗样式申请权限 + * + * @author miracle + * @since 2021/8/2 */ public class PermissionCompatActivity extends AppCompatActivity { private static final String TAG = "PermissionCompatActivity"; diff --git a/commonLib/src/main/res/values/dimens.xml b/commonLib/src/main/res/values/dimens.xml index e980670..d16c0b6 100644 --- a/commonLib/src/main/res/values/dimens.xml +++ b/commonLib/src/main/res/values/dimens.xml @@ -32,6 +32,7 @@ 40dp 42dp 46dp + 60dp 65dp 70dp 72dp