Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated compile & target sdk version, dependencies, gradle and other #53

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 28
buildToolsVersion "28.0.2"
compileSdkVersion 30

defaultConfig {
applicationId "com.rxjava2.android.samples"
minSdkVersion 16
targetSdkVersion 28
targetSdkVersion 30
versionCode 1
versionName "1.0"
}
Expand All @@ -25,17 +24,21 @@ android {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
androidTestImplementation 'androidx.test:rules:1.1.0-alpha4'
implementation 'androidx.appcompat:appcompat:1.0.0-rc02'
implementation 'androidx.recyclerview:recyclerview:1.0.0-rc02'

// AndroidX
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.recyclerview:recyclerview:1.2.0'

// RxJava2 Dependencies
implementation 'io.reactivex.rxjava2:rxjava:2.2.2'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
implementation 'io.reactivex.rxjava2:rxjava:2.2.9'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'

// FastAndroidNetworking Dependency
implementation 'com.amitshekhar.android:rx2-android-networking:1.0.2'

// Testing
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
androidTestImplementation 'androidx.test:runner:1.4.0-alpha06'
androidTestImplementation 'androidx.test:rules:1.4.0-alpha06'
}
19 changes: 8 additions & 11 deletions app/src/main/java/com/rxjava2/android/samples/MyApplication.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.rxjava2.android.samples;

import android.annotation.SuppressLint;
import android.app.Application;

import com.rxjava2.android.samples.model.Events;
Expand All @@ -8,7 +9,6 @@
import java.util.concurrent.TimeUnit;

import io.reactivex.Observable;
import io.reactivex.functions.Consumer;

/**
* Created by threshold on 2017/1/12.
Expand All @@ -17,26 +17,23 @@
public class MyApplication extends Application {

public static final String TAG = "MyApplication";
private RxBus bus;
private RxBus rxBus;

@Override
public void onCreate() {
super.onCreate();
bus = new RxBus();
rxBus = new RxBus();
}

public RxBus bus() {
return bus;
public RxBus getRxBus() {
return rxBus;
}

@SuppressLint("CheckResult")
public void sendAutoEvent() {
//noinspection ResultOfMethodCallIgnored
Observable.timer(2, TimeUnit.SECONDS)
.subscribe(new Consumer<Long>() {
@Override
public void accept(Long aLong) {
bus.send(new Events.AutoEvent());
}
});
.subscribe(aLong -> rxBus.send(new Events.AutoEvent()));
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.rxjava2.android.samples.model;

import androidx.annotation.NonNull;

/**
* Created by amitshekhar on 27/08/16.
*/
Expand All @@ -8,6 +10,7 @@ public class ApiUser {
public String firstname;
public String lastname;

@NonNull
@Override
public String toString() {
return "ApiUser{" +
Expand Down
10 changes: 1 addition & 9 deletions app/src/main/java/com/rxjava2/android/samples/model/Car.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package com.rxjava2.android.samples.model;

import java.util.concurrent.Callable;

import io.reactivex.Observable;
import io.reactivex.ObservableSource;

/**
* Created by amitshekhar on 30/08/16.
Expand All @@ -17,12 +14,7 @@ public void setBrand(String brand) {
}

public Observable<String> brandDeferObservable() {
return Observable.defer(new Callable<ObservableSource<? extends String>>() {
@Override
public ObservableSource<? extends String> call() {
return Observable.just(brand);
}
});
return Observable.defer(() -> Observable.just(brand));
}

}
3 changes: 3 additions & 0 deletions app/src/main/java/com/rxjava2/android/samples/model/User.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.rxjava2.android.samples.model;

import androidx.annotation.NonNull;

/**
* Created by amitshekhar on 27/08/16.
*/
Expand All @@ -18,6 +20,7 @@ public User(ApiUser apiUser) {
this.lastname = apiUser.lastname;
}

@NonNull
@Override
public String toString() {
return "User{" +
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.rxjava2.android.samples.model;

import androidx.annotation.NonNull;

/**
* Created by amitshekhar on 04/02/17.
*/
Expand All @@ -10,6 +12,7 @@ public class UserDetail {
public String firstname;
public String lastname;

@NonNull
@Override
public String toString() {
return "UserDetail{" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import android.os.Bundle;
import android.view.View;

import androidx.appcompat.app.AppCompatActivity;

import com.rxjava2.android.samples.R;
import com.rxjava2.android.samples.ui.operators.AsyncSubjectExampleActivity;
import com.rxjava2.android.samples.ui.operators.BehaviorSubjectExampleActivity;
Expand Down Expand Up @@ -39,8 +41,6 @@
import com.rxjava2.android.samples.ui.operators.WindowExampleActivity;
import com.rxjava2.android.samples.ui.operators.ZipExampleActivity;

import androidx.appcompat.app.AppCompatActivity;

public class OperatorsActivity extends AppCompatActivity {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import android.os.Bundle;
import android.view.View;

import androidx.appcompat.app.AppCompatActivity;

import com.rxjava2.android.samples.MyApplication;
import com.rxjava2.android.samples.R;
import com.rxjava2.android.samples.ui.cache.CacheExampleActivity;
Expand All @@ -13,8 +15,6 @@
import com.rxjava2.android.samples.ui.rxbus.RxBusActivity;
import com.rxjava2.android.samples.ui.search.SearchActivity;

import androidx.appcompat.app.AppCompatActivity;

public class SelectionActivity extends AppCompatActivity {

@Override
Expand All @@ -36,7 +36,6 @@ public void startCacheActivity(View view) {
}

public void startRxBusActivity(View view) {
((MyApplication) getApplication()).sendAutoEvent();
startActivity(new Intent(SelectionActivity.this, RxBusActivity.class));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;

import com.rxjava2.android.samples.R;
import com.rxjava2.android.samples.ui.cache.model.Data;
import com.rxjava2.android.samples.ui.cache.source.DataSource;
Expand All @@ -14,7 +16,6 @@
import com.rxjava2.android.samples.ui.cache.source.NetworkDataSource;
import com.rxjava2.android.samples.utils.AppConstant;

import androidx.appcompat.app.AppCompatActivity;
import io.reactivex.Observable;
import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
Expand All @@ -32,15 +33,10 @@ public class CacheExampleActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_example);
btn = (Button) findViewById(R.id.btn);
textView = (TextView) findViewById(R.id.textView);
btn = findViewById(R.id.btn);
textView = findViewById(R.id.textView);

btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
doSomeWork();
}
});
btn.setOnClickListener(view -> doSomeWork());

dataSource = new DataSource(new MemoryDataSource(), new DiskDataSource(), new NetworkDataSource());
}
Expand All @@ -63,19 +59,19 @@ private Observer<Data> getObserver() {
return new Observer<Data>() {

@Override
public void onSubscribe(Disposable d) {
public void onSubscribe(@NonNull Disposable d) {
Log.d(TAG, " onSubscribe : " + d.isDisposed());
}

@Override
public void onNext(Data data) {
public void onNext(@NonNull Data data) {
textView.append(" onNext : " + data.source);
textView.append(AppConstant.LINE_SEPARATOR);
Log.d(TAG, " onNext : " + data.source);
}

@Override
public void onError(Throwable e) {
public void onError(@NonNull Throwable e) {
textView.append(" onError : " + e.getMessage());
textView.append(AppConstant.LINE_SEPARATOR);
Log.d(TAG, " onError : " + e.getMessage());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package com.rxjava2.android.samples.ui.cache.model;

import androidx.annotation.NonNull;

public class Data {

public String source;

@SuppressWarnings("CloneDoesntDeclareCloneNotSupportedException")
@NonNull
@SuppressWarnings({"MethodDoesntCallSuperMethod"})
@Override
public Data clone() {
return new Data();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ public Observable<Data> getDataFromMemory() {
}

public Observable<Data> getDataFromDisk() {
return diskDataSource.getData().doOnNext(data ->
memoryDataSource.cacheInMemory(data)
return diskDataSource.getData().doOnNext(memoryDataSource::cacheInMemory
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@

import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;

import com.rxjava2.android.samples.R;

import androidx.appcompat.app.AppCompatActivity;
import io.reactivex.Flowable;
import io.reactivex.Observable;

public class ComposeOperatorExampleActivity extends AppCompatActivity {

private RxSchedulers schedulers = new RxSchedulers();
private final RxSchedulers schedulers = new RxSchedulers();

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -21,11 +22,11 @@ protected void onCreate(Bundle savedInstanceState) {
Compose for reusable code.
*/
Observable.just(1, 2, 3, 4, 5)
.compose(schedulers.<Integer>applyObservableAsync())
.compose(schedulers.applyObservableAsync())
.subscribe(/* */);

Flowable.just(1, 2, 3, 4, 5)
.compose(schedulers.<Integer>applyFlowableAsysnc())
.compose(schedulers.applyFlowableAsysnc())
.subscribe(/* */);

}
Expand Down
Loading