Add this in your build.gradle
implementation 'com.mindorks.scheduler:rxps:0.1.0'
getObservable()
public class PaginationActivity extends AppCompatActivity { | |
// removed for brevity.. | |
private PublishProcessor<Integer> paginator = PublishProcessor.create(); | |
private ProgressBar progressBar; | |
private boolean loading = false; | |
private int pageNumber = 1; | |
private final int VISIBLE_THRESHOLD = 1; | |
private int lastVisibleItem, totalItemCount; |
public class PaginationAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { | |
List<String> items = new ArrayList<>(); | |
public PaginationAdapter() { | |
} | |
void addItems(List<String> items) { | |
this.items.addAll(items); |
public class PaginationActivity extends AppCompatActivity { | |
/** | |
* Simulation of network data | |
*/ | |
private Single<List<String>> dataFromNetwork(final int page) { | |
return Single.just(true) | |
.delay(2, TimeUnit.SECONDS) | |
.map(value -> { | |
List<String> items = new ArrayList<>(); | |
for (int i = 1; i <= 10; i++) { |
getUserObservable() | |
.flatMap(new Function<ApiUser, ObservableSource<UserDetail>>() { | |
@Override | |
public ObservableSource<UserDetail> apply(ApiUser apiUser) throws Exception { | |
return getUserDetailObservable(apiUser); | |
} | |
}) | |
.subscribeOn(Schedulers.io()) | |
.observeOn(AndroidSchedulers.mainThread()) | |
.subscribe(getObserver()); |
getUserObservable() | |
.map(new Function<ApiUser, User>() { | |
@Override | |
public User apply(ApiUser apiUser) throws Exception { | |
// here we get the ApiUser from the server | |
User user = new User(apiUser); | |
// then by converting it into the user, we are returning | |
return user; | |
} | |
}) |
RxSearchObservable.fromView(searchView) | |
.debounce(300, TimeUnit.MILLISECONDS) | |
.filter(new Predicate<String>() { | |
@Override | |
public boolean test(String text) throws Exception { | |
if (text.isEmpty()) { | |
return false; | |
} else { | |
return true; | |
} |
public class RxSearchObservable { | |
public static Observable<String> fromView(SearchView searchView) { | |
final PublishSubject<String> subject = PublishSubject.create(); | |
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { | |
@Override | |
public boolean onQueryTextSubmit(String s) { | |
subject.onComplete(); |
from __future__ import print_function | |
import shutil | |
import os.path | |
import tensorflow as tf | |
from tensorflow.examples.tutorials.mnist import input_data | |
EXPORT_DIR = './model' | |
if os.path.exists(EXPORT_DIR): | |
shutil.rmtree(EXPORT_DIR) |