Removed RX java

This commit is contained in:
h4h13 2019-12-27 01:23:11 +05:30
parent 62726de918
commit 09c056f5ca
4 changed files with 26 additions and 60 deletions

View file

@ -120,10 +120,10 @@ dependencies {
implementation 'androidx.constraintlayout:constraintlayout:1.1.3' implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.core:core-ktx:1.1.0' implementation 'androidx.core:core-ktx:1.1.0'
implementation 'androidx.fragment:fragment:1.2.0-rc02' implementation 'androidx.fragment:fragment:1.2.0-rc04'
implementation 'androidx.recyclerview:recyclerview:1.1.0-rc01' implementation 'androidx.recyclerview:recyclerview:1.2.0-alpha01'
implementation 'com.google.android.material:material:1.2.0-alpha01' implementation 'com.google.android.material:material:1.2.0-alpha03'
implementation 'com.google.android.play:core:1.6.4' implementation 'com.google.android.play:core:1.6.4'
def retrofit_version = "2.6.2" def retrofit_version = "2.6.2"
@ -140,17 +140,12 @@ dependencies {
implementation "com.afollestad.material-dialogs:bottomsheets:$material_dialog_version" implementation "com.afollestad.material-dialogs:bottomsheets:$material_dialog_version"
implementation 'com.afollestad:material-cab:0.1.12' implementation 'com.afollestad:material-cab:0.1.12'
implementation 'com.github.bumptech.glide:glide:3.8.0' implementation 'com.github.bumptech.glide:glide:3.8.0'
implementation 'com.github.bumptech.glide:okhttp3-integration:1.5.0' implementation 'com.github.bumptech.glide:okhttp3-integration:1.5.0'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
implementation 'io.reactivex.rxjava2:rxjava:2.2.9'
implementation('com.h6ah4i.android.widget.advrecyclerview:advrecyclerview:0.11.0@aar') { implementation('com.h6ah4i.android.widget.advrecyclerview:advrecyclerview:0.11.0@aar') {
transitive = true transitive = true
} }
/*UI Library*/ /*UI Library*/
implementation 'me.zhanghai.android.materialprogressbar:library:1.6.1' implementation 'me.zhanghai.android.materialprogressbar:library:1.6.1'
@ -174,6 +169,4 @@ dependencies {
def dagger_version = "2.23.1" def dagger_version = "2.23.1"
implementation "com.google.dagger:dagger:$dagger_version" implementation "com.google.dagger:dagger:$dagger_version"
kapt "com.google.dagger:dagger-compiler:$dagger_version" kapt "com.google.dagger:dagger-compiler:$dagger_version"
} }

View file

@ -30,18 +30,17 @@ import com.afollestad.materialdialogs.LayoutMode
import com.afollestad.materialdialogs.MaterialDialog import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.bottomsheets.BottomSheet import com.afollestad.materialdialogs.bottomsheets.BottomSheet
import com.afollestad.materialdialogs.list.listItems import com.afollestad.materialdialogs.list.listItems
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.CompositeDisposable
import io.reactivex.schedulers.Schedulers
import kotlinx.android.synthetic.main.activity_user_info.* import kotlinx.android.synthetic.main.activity_user_info.*
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import java.io.File import java.io.File
import java.io.FileOutputStream import java.io.FileOutputStream
import java.io.IOException import java.io.IOException
class UserInfoActivity : AbsBaseActivity() { class UserInfoActivity : AbsBaseActivity() {
private var disposable = CompositeDisposable()
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.activity_user_info) setContentView(R.layout.activity_user_info)
@ -185,26 +184,28 @@ class UserInfoActivity : AbsBaseActivity() {
} }
private fun loadBannerFromStorage(profileImagePath: String) { private fun loadBannerFromStorage(profileImagePath: String) {
disposable.add(Compressor(this).setQuality(100) CoroutineScope(Dispatchers.IO).launch {
.setCompressFormat(Bitmap.CompressFormat.WEBP) withContext(Dispatchers.IO) {
.compressToBitmapAsFlowable(File(profileImagePath, USER_BANNER)) val bitmap = Compressor(this@UserInfoActivity).setQuality(100)
.subscribeOn(Schedulers.io()) .setCompressFormat(Bitmap.CompressFormat.WEBP)
.observeOn(AndroidSchedulers.mainThread()) .compressToBitmap(File(profileImagePath, USER_BANNER))
.subscribe({ bitmap -> bannerImage.setImageBitmap(bitmap) }, { t -> println(t) }) withContext(Dispatchers.Main) { bannerImage.setImageBitmap(bitmap) }
) }
}
} }
private fun loadImageFromStorage(path: String) { private fun loadImageFromStorage(path: String) {
disposable.add(Compressor(this) CoroutineScope(Dispatchers.IO).launch {
.setMaxHeight(300) withContext(Dispatchers.IO) {
.setMaxWidth(300) val bitmap = Compressor(this@UserInfoActivity)
.setQuality(75) .setMaxHeight(300)
.setCompressFormat(Bitmap.CompressFormat.WEBP) .setMaxWidth(300)
.compressToBitmapAsFlowable(File(path, USER_PROFILE)) .setQuality(75)
.subscribeOn(Schedulers.io()) .setCompressFormat(Bitmap.CompressFormat.WEBP)
.observeOn(AndroidSchedulers.mainThread()) .compressToBitmap(File(path, USER_PROFILE))
.subscribe({ bitmap -> userImage.setImageBitmap(bitmap) }, { t -> println(t) }) withContext(Dispatchers.Main) { userImage.setImageBitmap(bitmap) }
) }
}
} }
private fun saveToInternalStorage(bitmapImage: Bitmap, userBanner: String): String { private fun saveToInternalStorage(bitmapImage: Bitmap, userBanner: String): String {

View file

@ -30,7 +30,6 @@ import okhttp3.Interceptor;
import okhttp3.OkHttpClient; import okhttp3.OkHttpClient;
import okhttp3.Request; import okhttp3.Request;
import retrofit2.Retrofit; import retrofit2.Retrofit;
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory; import retrofit2.converter.gson.GsonConverterFactory;
@ -49,7 +48,6 @@ public class LastFMRestClient {
.baseUrl(BASE_URL) .baseUrl(BASE_URL)
.callFactory(client) .callFactory(client)
.addConverterFactory(GsonConverterFactory.create()) .addConverterFactory(GsonConverterFactory.create())
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.build(); .build();
apiService = restAdapter.create(LastFMService.class); apiService = restAdapter.create(LastFMService.class);

View file

@ -20,8 +20,6 @@ import android.graphics.Bitmap;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import io.reactivex.Flowable;
/** /**
* Created on : June 18, 2016 * Created on : June 18, 2016
* Author : zetbaitsu * Author : zetbaitsu
@ -77,28 +75,4 @@ public class Compressor {
public Bitmap compressToBitmap(File imageFile) throws IOException { public Bitmap compressToBitmap(File imageFile) throws IOException {
return ImageUtil.decodeSampledBitmapFromFile(imageFile, maxWidth, maxHeight); return ImageUtil.decodeSampledBitmapFromFile(imageFile, maxWidth, maxHeight);
} }
public Flowable<File> compressToFileAsFlowable(final File imageFile) {
return compressToFileAsFlowable(imageFile, imageFile.getName());
}
public Flowable<File> compressToFileAsFlowable(final File imageFile, final String compressedFileName) {
return Flowable.defer(() -> {
try {
return Flowable.just(compressToFile(imageFile, compressedFileName));
} catch (IOException e) {
return Flowable.error(e);
}
});
}
public Flowable<Bitmap> compressToBitmapAsFlowable(final File imageFile) {
return Flowable.defer(() -> {
try {
return Flowable.just(compressToBitmap(imageFile));
} catch (IOException e) {
return Flowable.error(e);
}
});
}
} }