completed migrating to androidx

androidx
Zhanty 5 years ago
parent 897c9ad332
commit 662b61b9c5
  1. 34
      lib_base/build.gradle
  2. 5
      lib_base/src/main/java/com/android/base/adapter/recycler/AdapterDataObserverProxy.java
  3. 15
      lib_base/src/main/java/com/android/base/adapter/recycler/DiffRecyclerAdapter.java
  4. 4
      lib_base/src/main/java/com/android/base/adapter/recycler/ItemViewBinder.kt
  5. 14
      lib_base/src/main/java/com/android/base/adapter/recycler/MultiTypeAdapter.java
  6. 5
      lib_base/src/main/java/com/android/base/adapter/recycler/RecyclerAdapter.java
  7. 3
      lib_base/src/main/java/com/android/base/adapter/recycler/RecyclerDataManagerImpl.java
  8. 5
      lib_base/src/main/java/com/android/base/adapter/recycler/ViewHolder.java
  9. 1
      lib_base/src/main/java/com/android/base/app/mvp/RxPresenter.kt
  10. 2
      lib_base/src/main/java/com/android/base/app/mvvm/RxViewModel.kt
  11. 32
      lib_base/src/main/java/com/android/base/app/mvvm/ViewModelEx.kt
  12. 13
      lib_base/src/main/java/com/android/base/kotlin/ViewEx.kt
  13. 26
      lib_base/src/main/java/com/android/base/rx/AutoDispose.kt
  14. 2
      lib_base/src/main/java/com/android/base/utils/android/text/RoundedBackgroundSpan.java
  15. 4
      lib_cache/build.gradle
  16. 2
      lib_cache/src/main/java/com/android/sdk/cache/DiskLruStorageImpl.java
  17. 2
      lib_cache/src/main/java/com/android/sdk/cache/Storage.java
  18. 4
      lib_network/build.gradle
  19. 3
      lib_network/src/main/java/com/android/sdk/net/NetContext.java
  20. 4
      lib_network/src/main/java/com/android/sdk/net/NetProvider.java
  21. 4
      lib_network/src/main/java/com/android/sdk/net/core/HttpResultTransformer.java
  22. 3
      lib_network/src/main/java/com/android/sdk/net/exception/ServerErrorException.java
  23. 2
      lib_network/src/main/java/com/android/sdk/net/kit/Consumer.java
  24. 3
      lib_network/src/main/java/com/android/sdk/net/kit/RxResultKit.java
  25. 4
      lib_network/src/main/java/com/android/sdk/net/kit/Selector.java
  26. 2
      lib_network/src/main/java/com/android/sdk/net/progress/ProgressRequestBody.java
  27. 2
      lib_network/src/main/java/com/android/sdk/net/progress/ProgressResponseBody.java
  28. 3
      lib_network/src/main/java/com/android/sdk/net/progress/RequestProgressInterceptor.java
  29. 3
      lib_network/src/main/java/com/android/sdk/net/progress/ResponseProgressInterceptor.java
  30. 4
      lib_network/src/main/java/com/android/sdk/net/provider/ApiHandler.java

@ -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

@ -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 <a href='http://www.cezcb.com/2018/08/24/PagingWithHeader/'>PagingWithHeader</a>

@ -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)}才能替换原有数据源的引用
*

@ -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<T, VH : RecyclerView.ViewHolder> : me.drakeet.multitype.ItemViewBinder<T, VH>() {
abstract class ItemViewBinder<T, VH : RecyclerView.ViewHolder> : com.drakeet.multitype.ItemViewBinder<T, VH>() {
protected val dataManager: MultiTypeAdapter
get() = adapter as MultiTypeAdapter

@ -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 <a href='https://github.com/drakeet/MultiType'>drakeet/MultiTypeAdapter</a>
*/
public class MultiTypeAdapter extends me.drakeet.multitype.MultiTypeAdapter implements DataManager<Object> {
public class MultiTypeAdapter extends com.drakeet.multitype.MultiTypeAdapter implements DataManager<Object> {
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<Object> objects = new ArrayList<>(items);
mRecyclerDataManager = new RecyclerDataManagerImpl<>(objects, this);
super.setItems(objects);
}
@SuppressWarnings("unused")
public void notifyEntryChanged(Object entry) {
int itemPosition = getItemPosition(entry);

@ -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才能替换原有数据源的引用

@ -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<T> implements DataManager<T> {

@ -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 {

@ -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

@ -18,7 +18,7 @@ import io.reactivex.subjects.BehaviorSubject
* Email: 1169654504@qq.com
* Date : 2017-04-18 16:25
*/
abstract class ArchViewModel : ViewModel(), AutoDisposeLifecycleScopeProviderEx<ArchViewModel.ViewModelEvent> {
abstract class RxViewModel : ViewModel(), AutoDisposeLifecycleScopeProviderEx<RxViewModel.ViewModelEvent> {
private val archLifecycleSubject = BehaviorSubject.createDefault(ViewModelEvent.CREATED)

@ -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 <reified VM : ViewModel> 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 <reified VM : ViewModel> 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 <reified VM : ViewModel> 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]
}
}

@ -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<Any> {
fun View.onClickObservable(): Observable<Unit> {
return onClickObservable(500)
}
fun View.onClickObservable(milliseconds: Long): Observable<Any> {
return RxView.clicks(this)
fun View.onClickObservable(milliseconds: Long): Observable<Unit> {
return clicks()
.throttleFirst(milliseconds, TimeUnit.MILLISECONDS)
.observeOn(AndroidSchedulers.mainThread())
}

@ -21,23 +21,23 @@ import timber.log.Timber
interface AutoDisposeLifecycleScopeProviderEx<T> : LifecycleScopeProvider<T> {
fun <T> Flowable<T>.autoDispose(): FlowableSubscribeProxy<T> {
return this.`as`(autoDisposable(this@AutoDisposeLifecycleScopeProviderEx))
return autoDisposable(this@AutoDisposeLifecycleScopeProviderEx)
}
fun <T> Observable<T>.autoDispose(): ObservableSubscribeProxy<T> {
return this.`as`(autoDisposable(this@AutoDisposeLifecycleScopeProviderEx))
return autoDisposable(this@AutoDisposeLifecycleScopeProviderEx)
}
fun Completable.autoDispose(): CompletableSubscribeProxy {
return this.`as`(autoDisposable<Any>(this@AutoDisposeLifecycleScopeProviderEx))
return autoDisposable(this@AutoDisposeLifecycleScopeProviderEx)
}
fun <T> Maybe<T>.autoDispose(): MaybeSubscribeProxy<T> {
return this.`as`(autoDisposable(this@AutoDisposeLifecycleScopeProviderEx))
return autoDisposable(this@AutoDisposeLifecycleScopeProviderEx)
}
fun <T> Single<T>.autoDispose(): SingleSubscribeProxy<T> {
return this.`as`(autoDisposable(this@AutoDisposeLifecycleScopeProviderEx))
return autoDisposable(this@AutoDisposeLifecycleScopeProviderEx)
}
}
@ -87,19 +87,19 @@ interface AutoDisposeLifecycleOwnerEx : LifecycleOwner {
}
fun <T> Flowable<T>.bindLifecycle(lifecycleOwner: LifecycleOwner): FlowableSubscribeProxy<T> {
return this.`as`(autoDisposable(AndroidLifecycleScopeProvider.from(lifecycleOwner)))
return autoDisposable(AndroidLifecycleScopeProvider.from(lifecycleOwner))
}
fun <T> Flowable<T>.bindLifecycle(lifecycleOwner: LifecycleOwner, event: Lifecycle.Event): FlowableSubscribeProxy<T> {
return this.`as`(autoDisposable(AndroidLifecycleScopeProvider.from(lifecycleOwner, event)))
return autoDisposable(AndroidLifecycleScopeProvider.from(lifecycleOwner, event))
}
fun <T> Observable<T>.bindLifecycle(lifecycleOwner: LifecycleOwner): ObservableSubscribeProxy<T> {
return this.`as`(autoDisposable(AndroidLifecycleScopeProvider.from(lifecycleOwner)))
return autoDisposable(AndroidLifecycleScopeProvider.from(lifecycleOwner))
}
fun <T> Observable<T>.bindLifecycle(lifecycleOwner: LifecycleOwner, event: Lifecycle.Event): ObservableSubscribeProxy<T> {
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 <T> Maybe<T>.bindLifecycle(lifecycleOwner: LifecycleOwner): MaybeSubscribeProxy<T> {
return this.`as`(autoDisposable(AndroidLifecycleScopeProvider.from(lifecycleOwner)))
return autoDisposable(AndroidLifecycleScopeProvider.from(lifecycleOwner))
}
fun <T> Maybe<T>.bindLifecycle(lifecycleOwner: LifecycleOwner, event: Lifecycle.Event): MaybeSubscribeProxy<T> {
return this.`as`(autoDisposable(AndroidLifecycleScopeProvider.from(lifecycleOwner, event)))
return autoDisposable(AndroidLifecycleScopeProvider.from(lifecycleOwner, event))
}
fun <T> Single<T>.bindLifecycle(lifecycleOwner: LifecycleOwner): SingleSubscribeProxy<T> {
return this.`as`(autoDisposable(AndroidLifecycleScopeProvider.from(lifecycleOwner)))
return autoDisposable(AndroidLifecycleScopeProvider.from(lifecycleOwner))
}
fun <T> Single<T>.bindLifecycle(lifecycleOwner: LifecycleOwner, event: Lifecycle.Event): SingleSubscribeProxy<T> {
return this.`as`(autoDisposable(AndroidLifecycleScopeProvider.from(lifecycleOwner, event)))
return autoDisposable(AndroidLifecycleScopeProvider.from(lifecycleOwner, event))
}
fun <T> ObservableSubscribeProxy<T>.subscribed(): Disposable = this.subscribe(RxKit.logResultHandler(), RxKit.logErrorHandler())

@ -5,6 +5,8 @@ import android.graphics.Paint;
import android.graphics.RectF;
import android.text.style.ReplacementSpan;
import androidx.annotation.NonNull;
/**
* 圆角背景Span
*/

@ -23,6 +23,10 @@ android {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
}
dependencies {

@ -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")

@ -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;
/**

@ -19,6 +19,10 @@ android {
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
buildTypes {
release {
minifyEnabled false

@ -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;
/**

@ -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();

@ -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;

@ -1,6 +1,5 @@
package com.android.sdk.net.exception;
import android.support.annotation.NonNull;
import androidx.annotation.NonNull;
/**
* 表示服务器异常

@ -1,6 +1,6 @@
package com.android.sdk.net.kit;
import android.support.annotation.Nullable;
import androidx.annotation.Nullable;
/**
* @author Ztiany

@ -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;

@ -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<T> {

@ -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;

@ -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;

@ -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;

@ -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;

@ -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

Loading…
Cancel
Save