From 662b61b9c5f3548efe7ca63d54eab4c38545600b Mon Sep 17 00:00:00 2001 From: Zhanty Date: Tue, 17 Sep 2019 16:11:00 +0800 Subject: [PATCH] completed migrating to androidx --- lib_base/build.gradle | 34 +++++++++++-------- .../recycler/AdapterDataObserverProxy.java | 5 +-- .../adapter/recycler/DiffRecyclerAdapter.java | 15 ++++---- .../base/adapter/recycler/ItemViewBinder.kt | 4 +-- .../adapter/recycler/MultiTypeAdapter.java | 14 ++------ .../adapter/recycler/RecyclerAdapter.java | 5 +-- .../recycler/RecyclerDataManagerImpl.java | 3 +- .../base/adapter/recycler/ViewHolder.java | 5 +-- .../com/android/base/app/mvp/RxPresenter.kt | 1 - .../mvvm/{ArchViewModel.kt => RxViewModel.kt} | 2 +- .../com/android/base/app/mvvm/ViewModelEx.kt | 32 ----------------- .../java/com/android/base/kotlin/ViewEx.kt | 13 ++++--- .../java/com/android/base/rx/AutoDispose.kt | 26 +++++++------- .../android/text/RoundedBackgroundSpan.java | 2 ++ lib_cache/build.gradle | 4 +++ .../android/sdk/cache/DiskLruStorageImpl.java | 2 +- .../java/com/android/sdk/cache/Storage.java | 2 +- lib_network/build.gradle | 4 +++ .../java/com/android/sdk/net/NetContext.java | 3 +- .../java/com/android/sdk/net/NetProvider.java | 4 +-- .../sdk/net/core/HttpResultTransformer.java | 4 +-- .../net/exception/ServerErrorException.java | 3 +- .../com/android/sdk/net/kit/Consumer.java | 2 +- .../com/android/sdk/net/kit/RxResultKit.java | 3 +- .../com/android/sdk/net/kit/Selector.java | 4 +-- .../sdk/net/progress/ProgressRequestBody.java | 2 +- .../net/progress/ProgressResponseBody.java | 2 +- .../progress/RequestProgressInterceptor.java | 3 +- .../progress/ResponseProgressInterceptor.java | 3 +- .../android/sdk/net/provider/ApiHandler.java | 4 +-- 30 files changed, 92 insertions(+), 118 deletions(-) rename lib_base/src/main/java/com/android/base/app/mvvm/{ArchViewModel.kt => RxViewModel.kt} (93%) delete mode 100644 lib_base/src/main/java/com/android/base/app/mvvm/ViewModelEx.kt diff --git a/lib_base/build.gradle b/lib_base/build.gradle index 31a9d4c..1e5b37c 100644 --- a/lib_base/build.gradle +++ b/lib_base/build.gradle @@ -41,6 +41,10 @@ android { targetCompatibility JavaVersion.VERSION_1_8 } + kotlinOptions { + jvmTarget = "1.8" + } + } dependencies { @@ -52,25 +56,26 @@ dependencies { //AndroidSupport api androidLibraries.supportV4 api androidLibraries.appcompat - api androidLibraries.recyclerview + api androidLibraries.recyclerView api androidLibraries.material api androidLibraries.percentLayout api androidLibraries.constraintLayout api androidLibraries.annotation //AAC - api androidLibraries. archRuntime - api androidLibraries. archCommon - api androidLibraries. lifecycleCommon - api androidLibraries. lifecycleCommonJava8 - api androidLibraries. lifecycleRuntimeKtx - api androidLibraries. lifecycleLiveDataCore - api androidLibraries. lifecycleLiveData - api androidLibraries. lifecycleLiveKtx - api androidLibraries. lifecycleViewModel - api androidLibraries. lifecycleViewModelKtx - api androidLibraries. lifecycleExtensions - api androidLibraries. lifecycleReactiveStreams + api androidLibraries.archRuntime + api androidLibraries.archCommon + api androidLibraries.fragmentKtx + api androidLibraries.lifecycleCommon + api androidLibraries.lifecycleCommonJava8 + api androidLibraries.lifecycleRuntimeKtx + api androidLibraries.lifecycleLiveDataCore + api androidLibraries.lifecycleLiveData + api androidLibraries.lifecycleLiveKtx + api androidLibraries.lifecycleViewModel + api androidLibraries.lifecycleViewModelKtx + api androidLibraries.lifecycleExtensions + api androidLibraries.lifecycleReactiveStreams //Kotlin api kotlinLibraries.kotlinStdlib @@ -83,6 +88,8 @@ dependencies { api thirdLibraries.rxAndroid api thirdLibraries.rxBinding api thirdLibraries.autoDispose + api thirdLibraries.autoDisposeAndroid + api thirdLibraries.autoDisposeLifecycle api thirdLibraries.autoDisposeLifecycleArchcomponents /*Dagger2*/ @@ -98,7 +105,6 @@ dependencies { //Adapter api uiLibraries.multiType - api uiLibraries.multiTypeKotlin //Log api thirdLibraries.timber diff --git a/lib_base/src/main/java/com/android/base/adapter/recycler/AdapterDataObserverProxy.java b/lib_base/src/main/java/com/android/base/adapter/recycler/AdapterDataObserverProxy.java index bbdbf71..778f2b2 100644 --- a/lib_base/src/main/java/com/android/base/adapter/recycler/AdapterDataObserverProxy.java +++ b/lib_base/src/main/java/com/android/base/adapter/recycler/AdapterDataObserverProxy.java @@ -1,7 +1,8 @@ package com.android.base.adapter.recycler; -import android.support.annotation.Nullable; -import android.support.v7.widget.RecyclerView; + +import androidx.annotation.Nullable; +import androidx.recyclerview.widget.RecyclerView; /** * @see PagingWithHeader diff --git a/lib_base/src/main/java/com/android/base/adapter/recycler/DiffRecyclerAdapter.java b/lib_base/src/main/java/com/android/base/adapter/recycler/DiffRecyclerAdapter.java index 5a29991..d79da4a 100644 --- a/lib_base/src/main/java/com/android/base/adapter/recycler/DiffRecyclerAdapter.java +++ b/lib_base/src/main/java/com/android/base/adapter/recycler/DiffRecyclerAdapter.java @@ -1,13 +1,6 @@ package com.android.base.adapter.recycler; import android.content.Context; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.v7.recyclerview.extensions.AsyncDifferConfig; -import android.support.v7.recyclerview.extensions.AsyncListDiffer; -import android.support.v7.util.AdapterListUpdateCallback; -import android.support.v7.util.DiffUtil; -import android.support.v7.widget.RecyclerView; import android.view.ViewGroup; import com.android.base.adapter.DataManager; @@ -17,6 +10,14 @@ import java.util.ArrayList; import java.util.List; import java.util.concurrent.Executor; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.recyclerview.widget.AdapterListUpdateCallback; +import androidx.recyclerview.widget.AsyncDifferConfig; +import androidx.recyclerview.widget.AsyncListDiffer; +import androidx.recyclerview.widget.DiffUtil; +import androidx.recyclerview.widget.RecyclerView; + /** * RecyclerView 的适配器,注意: 只有{@link #setDataSource(List, boolean)}才能替换原有数据源的引用。 * diff --git a/lib_base/src/main/java/com/android/base/adapter/recycler/ItemViewBinder.kt b/lib_base/src/main/java/com/android/base/adapter/recycler/ItemViewBinder.kt index d67b5b1..67aca4b 100644 --- a/lib_base/src/main/java/com/android/base/adapter/recycler/ItemViewBinder.kt +++ b/lib_base/src/main/java/com/android/base/adapter/recycler/ItemViewBinder.kt @@ -1,9 +1,9 @@ package com.android.base.adapter.recycler -import android.support.v7.widget.RecyclerView import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import androidx.recyclerview.widget.RecyclerView import com.android.base.kotlin.KtViewHolder /** @@ -11,7 +11,7 @@ import com.android.base.kotlin.KtViewHolder * Email: 1169654504@qq.com * Date : 2017-09-13 15:33 */ -abstract class ItemViewBinder : me.drakeet.multitype.ItemViewBinder() { +abstract class ItemViewBinder : com.drakeet.multitype.ItemViewBinder() { protected val dataManager: MultiTypeAdapter get() = adapter as MultiTypeAdapter diff --git a/lib_base/src/main/java/com/android/base/adapter/recycler/MultiTypeAdapter.java b/lib_base/src/main/java/com/android/base/adapter/recycler/MultiTypeAdapter.java index 0ee935b..2c4bf64 100644 --- a/lib_base/src/main/java/com/android/base/adapter/recycler/MultiTypeAdapter.java +++ b/lib_base/src/main/java/com/android/base/adapter/recycler/MultiTypeAdapter.java @@ -1,19 +1,19 @@ package com.android.base.adapter.recycler; import android.content.Context; -import android.support.annotation.NonNull; import com.android.base.adapter.DataManager; import java.util.ArrayList; import java.util.List; -import me.drakeet.multitype.TypePool; +import androidx.annotation.NonNull; + /** * @see drakeet/MultiTypeAdapter */ -public class MultiTypeAdapter extends me.drakeet.multitype.MultiTypeAdapter implements DataManager { +public class MultiTypeAdapter extends com.drakeet.multitype.MultiTypeAdapter implements DataManager { private final Context mContext; @@ -43,14 +43,6 @@ public class MultiTypeAdapter extends me.drakeet.multitype.MultiTypeAdapter impl super.setItems(objects); } - public MultiTypeAdapter(Context context, @NonNull List items, @NonNull TypePool pool) { - super(items, pool); - mContext = context; - ArrayList objects = new ArrayList<>(items); - mRecyclerDataManager = new RecyclerDataManagerImpl<>(objects, this); - super.setItems(objects); - } - @SuppressWarnings("unused") public void notifyEntryChanged(Object entry) { int itemPosition = getItemPosition(entry); diff --git a/lib_base/src/main/java/com/android/base/adapter/recycler/RecyclerAdapter.java b/lib_base/src/main/java/com/android/base/adapter/recycler/RecyclerAdapter.java index b8f897c..6a3d7db 100644 --- a/lib_base/src/main/java/com/android/base/adapter/recycler/RecyclerAdapter.java +++ b/lib_base/src/main/java/com/android/base/adapter/recycler/RecyclerAdapter.java @@ -1,14 +1,15 @@ package com.android.base.adapter.recycler; import android.content.Context; -import android.support.annotation.NonNull; -import android.support.v7.widget.RecyclerView; import android.view.ViewGroup; import com.android.base.adapter.DataManager; import java.util.List; +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + /** * RecyclerView 的适配器 * 注意: 只有setDataSource才能替换原有数据源的引用。 diff --git a/lib_base/src/main/java/com/android/base/adapter/recycler/RecyclerDataManagerImpl.java b/lib_base/src/main/java/com/android/base/adapter/recycler/RecyclerDataManagerImpl.java index e923ec4..5b2b675 100644 --- a/lib_base/src/main/java/com/android/base/adapter/recycler/RecyclerDataManagerImpl.java +++ b/lib_base/src/main/java/com/android/base/adapter/recycler/RecyclerDataManagerImpl.java @@ -1,6 +1,5 @@ package com.android.base.adapter.recycler; -import android.support.v7.widget.RecyclerView; import com.android.base.adapter.DataManager; import com.android.base.utils.common.Checker; @@ -8,6 +7,8 @@ import com.android.base.utils.common.Checker; import java.util.ArrayList; import java.util.List; +import androidx.recyclerview.widget.RecyclerView; + final class RecyclerDataManagerImpl implements DataManager { diff --git a/lib_base/src/main/java/com/android/base/adapter/recycler/ViewHolder.java b/lib_base/src/main/java/com/android/base/adapter/recycler/ViewHolder.java index 67f135f..0f2bae3 100644 --- a/lib_base/src/main/java/com/android/base/adapter/recycler/ViewHolder.java +++ b/lib_base/src/main/java/com/android/base/adapter/recycler/ViewHolder.java @@ -1,10 +1,11 @@ package com.android.base.adapter.recycler; import android.content.Context; -import android.support.annotation.IdRes; -import android.support.v7.widget.RecyclerView; import android.view.View; +import androidx.annotation.IdRes; +import androidx.recyclerview.widget.RecyclerView; + public class ViewHolder extends RecyclerView.ViewHolder { diff --git a/lib_base/src/main/java/com/android/base/app/mvp/RxPresenter.kt b/lib_base/src/main/java/com/android/base/app/mvp/RxPresenter.kt index e5e19b5..aa5b16b 100644 --- a/lib_base/src/main/java/com/android/base/app/mvp/RxPresenter.kt +++ b/lib_base/src/main/java/com/android/base/app/mvp/RxPresenter.kt @@ -1,6 +1,5 @@ package com.android.base.app.mvp -import android.support.annotation.CallSuper import androidx.annotation.CallSuper import com.android.base.rx.AutoDisposeLifecycleScopeProviderEx import com.uber.autodispose.lifecycle.CorrespondingEventsFunction diff --git a/lib_base/src/main/java/com/android/base/app/mvvm/ArchViewModel.kt b/lib_base/src/main/java/com/android/base/app/mvvm/RxViewModel.kt similarity index 93% rename from lib_base/src/main/java/com/android/base/app/mvvm/ArchViewModel.kt rename to lib_base/src/main/java/com/android/base/app/mvvm/RxViewModel.kt index 3eb9120..0aa6398 100644 --- a/lib_base/src/main/java/com/android/base/app/mvvm/ArchViewModel.kt +++ b/lib_base/src/main/java/com/android/base/app/mvvm/RxViewModel.kt @@ -18,7 +18,7 @@ import io.reactivex.subjects.BehaviorSubject * Email: 1169654504@qq.com * Date : 2017-04-18 16:25 */ -abstract class ArchViewModel : ViewModel(), AutoDisposeLifecycleScopeProviderEx { +abstract class RxViewModel : ViewModel(), AutoDisposeLifecycleScopeProviderEx { private val archLifecycleSubject = BehaviorSubject.createDefault(ViewModelEvent.CREATED) diff --git a/lib_base/src/main/java/com/android/base/app/mvvm/ViewModelEx.kt b/lib_base/src/main/java/com/android/base/app/mvvm/ViewModelEx.kt deleted file mode 100644 index 60270d9..0000000 --- a/lib_base/src/main/java/com/android/base/app/mvvm/ViewModelEx.kt +++ /dev/null @@ -1,32 +0,0 @@ -package com.android.base.app.mvvm - -import android.arch.lifecycle.ViewModel -import android.arch.lifecycle.ViewModelProvider -import android.arch.lifecycle.ViewModelProviders -import androidx.fragment.app.Fragment -import android.support.v4.app.FragmentActivity - -inline fun Fragment.getViewModel(factory: ViewModelProvider.Factory? = null): VM { - return if (factory == null) { - ViewModelProviders.of(this)[VM::class.java] - } else { - ViewModelProviders.of(this, factory)[VM::class.java] - } -} - -inline fun Fragment.getViewModelFromActivity(factory: ViewModelProvider.Factory? = null): VM { - val activity = this.activity ?: throw IllegalStateException("fragment is not attach to activity") - return if (factory == null) { - ViewModelProviders.of(activity)[VM::class.java] - } else { - ViewModelProviders.of(activity, factory)[VM::class.java] - } -} - -inline fun FragmentActivity.getViewModel(factory: ViewModelProvider.Factory? = null): VM { - return if (factory == null) { - ViewModelProviders.of(this)[VM::class.java] - } else { - ViewModelProviders.of(this, factory)[VM::class.java] - } -} \ No newline at end of file diff --git a/lib_base/src/main/java/com/android/base/kotlin/ViewEx.kt b/lib_base/src/main/java/com/android/base/kotlin/ViewEx.kt index 948529a..5d16678 100644 --- a/lib_base/src/main/java/com/android/base/kotlin/ViewEx.kt +++ b/lib_base/src/main/java/com/android/base/kotlin/ViewEx.kt @@ -1,22 +1,21 @@ package com.android.base.kotlin import android.graphics.drawable.Drawable - -import androidx.fragment.app.Fragment import android.view.View import android.view.View.FOCUS_DOWN import android.view.View.FOCUS_UP import android.view.ViewGroup import android.view.ViewTreeObserver import android.widget.ScrollView -import androidx.annotation.* +import androidx.annotation.ColorRes +import androidx.annotation.DrawableRes import androidx.core.content.ContextCompat import androidx.core.view.ViewCompat import androidx.core.widget.NestedScrollView import com.android.base.rx.subscribeIgnoreError import com.android.base.utils.android.ViewUtils import com.android.base.utils.android.compat.AndroidVersion.atLeast -import com.jakewharton.rxbinding2.view.RxView +import com.jakewharton.rxbinding3.view.clicks import io.reactivex.Observable import io.reactivex.android.schedulers.AndroidSchedulers import java.util.concurrent.TimeUnit @@ -144,12 +143,12 @@ fun View.onDebouncedClick(milliseconds: Long, onClick: (View) -> Unit) { .subscribeIgnoreError { onClick(this) } } -fun View.onClickObservable(): Observable { +fun View.onClickObservable(): Observable { return onClickObservable(500) } -fun View.onClickObservable(milliseconds: Long): Observable { - return RxView.clicks(this) +fun View.onClickObservable(milliseconds: Long): Observable { + return clicks() .throttleFirst(milliseconds, TimeUnit.MILLISECONDS) .observeOn(AndroidSchedulers.mainThread()) } diff --git a/lib_base/src/main/java/com/android/base/rx/AutoDispose.kt b/lib_base/src/main/java/com/android/base/rx/AutoDispose.kt index e73c3a7..c996d09 100644 --- a/lib_base/src/main/java/com/android/base/rx/AutoDispose.kt +++ b/lib_base/src/main/java/com/android/base/rx/AutoDispose.kt @@ -21,23 +21,23 @@ import timber.log.Timber interface AutoDisposeLifecycleScopeProviderEx : LifecycleScopeProvider { fun Flowable.autoDispose(): FlowableSubscribeProxy { - return this.`as`(autoDisposable(this@AutoDisposeLifecycleScopeProviderEx)) + return autoDisposable(this@AutoDisposeLifecycleScopeProviderEx) } fun Observable.autoDispose(): ObservableSubscribeProxy { - return this.`as`(autoDisposable(this@AutoDisposeLifecycleScopeProviderEx)) + return autoDisposable(this@AutoDisposeLifecycleScopeProviderEx) } fun Completable.autoDispose(): CompletableSubscribeProxy { - return this.`as`(autoDisposable(this@AutoDisposeLifecycleScopeProviderEx)) + return autoDisposable(this@AutoDisposeLifecycleScopeProviderEx) } fun Maybe.autoDispose(): MaybeSubscribeProxy { - return this.`as`(autoDisposable(this@AutoDisposeLifecycleScopeProviderEx)) + return autoDisposable(this@AutoDisposeLifecycleScopeProviderEx) } fun Single.autoDispose(): SingleSubscribeProxy { - return this.`as`(autoDisposable(this@AutoDisposeLifecycleScopeProviderEx)) + return autoDisposable(this@AutoDisposeLifecycleScopeProviderEx) } } @@ -87,19 +87,19 @@ interface AutoDisposeLifecycleOwnerEx : LifecycleOwner { } fun Flowable.bindLifecycle(lifecycleOwner: LifecycleOwner): FlowableSubscribeProxy { - return this.`as`(autoDisposable(AndroidLifecycleScopeProvider.from(lifecycleOwner))) + return autoDisposable(AndroidLifecycleScopeProvider.from(lifecycleOwner)) } fun Flowable.bindLifecycle(lifecycleOwner: LifecycleOwner, event: Lifecycle.Event): FlowableSubscribeProxy { - return this.`as`(autoDisposable(AndroidLifecycleScopeProvider.from(lifecycleOwner, event))) + return autoDisposable(AndroidLifecycleScopeProvider.from(lifecycleOwner, event)) } fun Observable.bindLifecycle(lifecycleOwner: LifecycleOwner): ObservableSubscribeProxy { - return this.`as`(autoDisposable(AndroidLifecycleScopeProvider.from(lifecycleOwner))) + return autoDisposable(AndroidLifecycleScopeProvider.from(lifecycleOwner)) } fun Observable.bindLifecycle(lifecycleOwner: LifecycleOwner, event: Lifecycle.Event): ObservableSubscribeProxy { - return this.`as`(autoDisposable(AndroidLifecycleScopeProvider.from(lifecycleOwner, event))) + return autoDisposable(AndroidLifecycleScopeProvider.from(lifecycleOwner, event)) } fun Completable.bindLifecycle(lifecycleOwner: LifecycleOwner): CompletableSubscribeProxy { @@ -111,19 +111,19 @@ fun Completable.bindLifecycle(lifecycleOwner: LifecycleOwner, event: Lifecycle.E } fun Maybe.bindLifecycle(lifecycleOwner: LifecycleOwner): MaybeSubscribeProxy { - return this.`as`(autoDisposable(AndroidLifecycleScopeProvider.from(lifecycleOwner))) + return autoDisposable(AndroidLifecycleScopeProvider.from(lifecycleOwner)) } fun Maybe.bindLifecycle(lifecycleOwner: LifecycleOwner, event: Lifecycle.Event): MaybeSubscribeProxy { - return this.`as`(autoDisposable(AndroidLifecycleScopeProvider.from(lifecycleOwner, event))) + return autoDisposable(AndroidLifecycleScopeProvider.from(lifecycleOwner, event)) } fun Single.bindLifecycle(lifecycleOwner: LifecycleOwner): SingleSubscribeProxy { - return this.`as`(autoDisposable(AndroidLifecycleScopeProvider.from(lifecycleOwner))) + return autoDisposable(AndroidLifecycleScopeProvider.from(lifecycleOwner)) } fun Single.bindLifecycle(lifecycleOwner: LifecycleOwner, event: Lifecycle.Event): SingleSubscribeProxy { - return this.`as`(autoDisposable(AndroidLifecycleScopeProvider.from(lifecycleOwner, event))) + return autoDisposable(AndroidLifecycleScopeProvider.from(lifecycleOwner, event)) } fun ObservableSubscribeProxy.subscribed(): Disposable = this.subscribe(RxKit.logResultHandler(), RxKit.logErrorHandler()) diff --git a/lib_base/src/main/java/com/android/base/utils/android/text/RoundedBackgroundSpan.java b/lib_base/src/main/java/com/android/base/utils/android/text/RoundedBackgroundSpan.java index d56bf70..2ec23a4 100644 --- a/lib_base/src/main/java/com/android/base/utils/android/text/RoundedBackgroundSpan.java +++ b/lib_base/src/main/java/com/android/base/utils/android/text/RoundedBackgroundSpan.java @@ -5,6 +5,8 @@ import android.graphics.Paint; import android.graphics.RectF; import android.text.style.ReplacementSpan; +import androidx.annotation.NonNull; + /** * 圆角背景Span */ diff --git a/lib_cache/build.gradle b/lib_cache/build.gradle index 75feab0..835c549 100644 --- a/lib_cache/build.gradle +++ b/lib_cache/build.gradle @@ -23,6 +23,10 @@ android { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } + kotlinOptions { + jvmTarget = "1.8" + } + } dependencies { diff --git a/lib_cache/src/main/java/com/android/sdk/cache/DiskLruStorageImpl.java b/lib_cache/src/main/java/com/android/sdk/cache/DiskLruStorageImpl.java index dfcae41..81cc8c5 100644 --- a/lib_cache/src/main/java/com/android/sdk/cache/DiskLruStorageImpl.java +++ b/lib_cache/src/main/java/com/android/sdk/cache/DiskLruStorageImpl.java @@ -1,7 +1,6 @@ package com.android.sdk.cache; import android.content.Context; -import android.support.annotation.NonNull; import android.text.TextUtils; import com.github.dmstocking.optional.java.util.Optional; @@ -10,6 +9,7 @@ import java.io.File; import java.io.IOException; import java.lang.reflect.Type; +import androidx.annotation.NonNull; import io.reactivex.Flowable; @SuppressWarnings("WeakerAccess,unused") diff --git a/lib_cache/src/main/java/com/android/sdk/cache/Storage.java b/lib_cache/src/main/java/com/android/sdk/cache/Storage.java index 474db9f..da4d195 100644 --- a/lib_cache/src/main/java/com/android/sdk/cache/Storage.java +++ b/lib_cache/src/main/java/com/android/sdk/cache/Storage.java @@ -1,11 +1,11 @@ package com.android.sdk.cache; -import android.support.annotation.Nullable; import com.github.dmstocking.optional.java.util.Optional; import java.lang.reflect.Type; +import androidx.annotation.Nullable; import io.reactivex.Flowable; /** diff --git a/lib_network/build.gradle b/lib_network/build.gradle index 1f29c89..02eda63 100644 --- a/lib_network/build.gradle +++ b/lib_network/build.gradle @@ -19,6 +19,10 @@ android { targetCompatibility JavaVersion.VERSION_1_8 } + kotlinOptions { + jvmTarget = "1.8" + } + buildTypes { release { minifyEnabled false diff --git a/lib_network/src/main/java/com/android/sdk/net/NetContext.java b/lib_network/src/main/java/com/android/sdk/net/NetContext.java index 472fa10..01c4155 100644 --- a/lib_network/src/main/java/com/android/sdk/net/NetContext.java +++ b/lib_network/src/main/java/com/android/sdk/net/NetContext.java @@ -1,7 +1,5 @@ package com.android.sdk.net; -import android.support.annotation.NonNull; - import com.android.sdk.net.core.ExceptionFactory; import com.android.sdk.net.provider.ApiHandler; import com.android.sdk.net.provider.ErrorDataAdapter; @@ -12,6 +10,7 @@ import com.android.sdk.net.provider.PostTransformer; import com.android.sdk.net.service.ServiceFactory; import com.android.sdk.net.service.ServiceHelper; +import androidx.annotation.NonNull; import okhttp3.OkHttpClient; /** diff --git a/lib_network/src/main/java/com/android/sdk/net/NetProvider.java b/lib_network/src/main/java/com/android/sdk/net/NetProvider.java index ce1c8df..b42a5f0 100644 --- a/lib_network/src/main/java/com/android/sdk/net/NetProvider.java +++ b/lib_network/src/main/java/com/android/sdk/net/NetProvider.java @@ -1,7 +1,5 @@ package com.android.sdk.net; -import android.support.annotation.NonNull; - import com.android.sdk.net.core.ExceptionFactory; import com.android.sdk.net.provider.ApiHandler; import com.android.sdk.net.provider.ErrorDataAdapter; @@ -10,6 +8,8 @@ import com.android.sdk.net.provider.HttpConfig; import com.android.sdk.net.provider.NetworkChecker; import com.android.sdk.net.provider.PostTransformer; +import androidx.annotation.NonNull; + public interface NetProvider { boolean isConnected(); diff --git a/lib_network/src/main/java/com/android/sdk/net/core/HttpResultTransformer.java b/lib_network/src/main/java/com/android/sdk/net/core/HttpResultTransformer.java index 97dd2f3..91f31c3 100644 --- a/lib_network/src/main/java/com/android/sdk/net/core/HttpResultTransformer.java +++ b/lib_network/src/main/java/com/android/sdk/net/core/HttpResultTransformer.java @@ -1,7 +1,5 @@ package com.android.sdk.net.core; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; import com.android.sdk.net.NetContext; import com.android.sdk.net.exception.ApiErrorException; @@ -12,6 +10,8 @@ import com.android.sdk.net.provider.PostTransformer; import org.reactivestreams.Publisher; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import io.reactivex.Flowable; import io.reactivex.FlowableTransformer; import io.reactivex.Observable; diff --git a/lib_network/src/main/java/com/android/sdk/net/exception/ServerErrorException.java b/lib_network/src/main/java/com/android/sdk/net/exception/ServerErrorException.java index f9eedf0..87a8a29 100644 --- a/lib_network/src/main/java/com/android/sdk/net/exception/ServerErrorException.java +++ b/lib_network/src/main/java/com/android/sdk/net/exception/ServerErrorException.java @@ -1,6 +1,5 @@ package com.android.sdk.net.exception; - -import android.support.annotation.NonNull; +import androidx.annotation.NonNull; /** * 表示服务器异常 diff --git a/lib_network/src/main/java/com/android/sdk/net/kit/Consumer.java b/lib_network/src/main/java/com/android/sdk/net/kit/Consumer.java index 549cc7b..778a00f 100644 --- a/lib_network/src/main/java/com/android/sdk/net/kit/Consumer.java +++ b/lib_network/src/main/java/com/android/sdk/net/kit/Consumer.java @@ -1,6 +1,6 @@ package com.android.sdk.net.kit; -import android.support.annotation.Nullable; +import androidx.annotation.Nullable; /** * @author Ztiany diff --git a/lib_network/src/main/java/com/android/sdk/net/kit/RxResultKit.java b/lib_network/src/main/java/com/android/sdk/net/kit/RxResultKit.java index de3ea3f..0f276dd 100644 --- a/lib_network/src/main/java/com/android/sdk/net/kit/RxResultKit.java +++ b/lib_network/src/main/java/com/android/sdk/net/kit/RxResultKit.java @@ -1,7 +1,5 @@ package com.android.sdk.net.kit; -import android.support.annotation.NonNull; - import com.android.sdk.net.NetContext; import com.android.sdk.net.exception.ApiErrorException; import com.android.sdk.net.exception.NetworkErrorException; @@ -11,6 +9,7 @@ import org.reactivestreams.Publisher; import java.io.IOException; +import androidx.annotation.NonNull; import io.reactivex.Flowable; import io.reactivex.flowables.ConnectableFlowable; import io.reactivex.functions.Function; diff --git a/lib_network/src/main/java/com/android/sdk/net/kit/Selector.java b/lib_network/src/main/java/com/android/sdk/net/kit/Selector.java index 4b0f089..979bde6 100644 --- a/lib_network/src/main/java/com/android/sdk/net/kit/Selector.java +++ b/lib_network/src/main/java/com/android/sdk/net/kit/Selector.java @@ -1,7 +1,7 @@ package com.android.sdk.net.kit; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; public interface Selector { diff --git a/lib_network/src/main/java/com/android/sdk/net/progress/ProgressRequestBody.java b/lib_network/src/main/java/com/android/sdk/net/progress/ProgressRequestBody.java index a4e72db..a23ef9a 100644 --- a/lib_network/src/main/java/com/android/sdk/net/progress/ProgressRequestBody.java +++ b/lib_network/src/main/java/com/android/sdk/net/progress/ProgressRequestBody.java @@ -1,10 +1,10 @@ package com.android.sdk.net.progress; import android.os.SystemClock; -import android.support.annotation.NonNull; import java.io.IOException; +import androidx.annotation.NonNull; import okhttp3.MediaType; import okhttp3.RequestBody; import okio.Buffer; diff --git a/lib_network/src/main/java/com/android/sdk/net/progress/ProgressResponseBody.java b/lib_network/src/main/java/com/android/sdk/net/progress/ProgressResponseBody.java index a147d49..5fda7ba 100644 --- a/lib_network/src/main/java/com/android/sdk/net/progress/ProgressResponseBody.java +++ b/lib_network/src/main/java/com/android/sdk/net/progress/ProgressResponseBody.java @@ -1,10 +1,10 @@ package com.android.sdk.net.progress; import android.os.SystemClock; -import android.support.annotation.NonNull; import java.io.IOException; +import androidx.annotation.NonNull; import okhttp3.MediaType; import okhttp3.ResponseBody; import okio.Buffer; diff --git a/lib_network/src/main/java/com/android/sdk/net/progress/RequestProgressInterceptor.java b/lib_network/src/main/java/com/android/sdk/net/progress/RequestProgressInterceptor.java index d3475cf..8a18dd5 100644 --- a/lib_network/src/main/java/com/android/sdk/net/progress/RequestProgressInterceptor.java +++ b/lib_network/src/main/java/com/android/sdk/net/progress/RequestProgressInterceptor.java @@ -1,9 +1,8 @@ package com.android.sdk.net.progress; -import android.support.annotation.NonNull; - import java.io.IOException; +import androidx.annotation.NonNull; import okhttp3.Interceptor; import okhttp3.Request; import okhttp3.Response; diff --git a/lib_network/src/main/java/com/android/sdk/net/progress/ResponseProgressInterceptor.java b/lib_network/src/main/java/com/android/sdk/net/progress/ResponseProgressInterceptor.java index c369ddf..6033960 100644 --- a/lib_network/src/main/java/com/android/sdk/net/progress/ResponseProgressInterceptor.java +++ b/lib_network/src/main/java/com/android/sdk/net/progress/ResponseProgressInterceptor.java @@ -1,9 +1,8 @@ package com.android.sdk.net.progress; -import android.support.annotation.NonNull; - import java.io.IOException; +import androidx.annotation.NonNull; import okhttp3.Interceptor; import okhttp3.Response; diff --git a/lib_network/src/main/java/com/android/sdk/net/provider/ApiHandler.java b/lib_network/src/main/java/com/android/sdk/net/provider/ApiHandler.java index 4ba05b6..7603e91 100644 --- a/lib_network/src/main/java/com/android/sdk/net/provider/ApiHandler.java +++ b/lib_network/src/main/java/com/android/sdk/net/provider/ApiHandler.java @@ -1,9 +1,9 @@ package com.android.sdk.net.provider; -import android.support.annotation.NonNull; - import com.android.sdk.net.core.Result; +import androidx.annotation.NonNull; + /** * @author Ztiany * Email: ztiany3@gmail.com