Skip to content

Instantly share code, notes, and snippets.

View bangarharshit's full-sized avatar

Harshit Bangar bangarharshit

  • Twitter
View GitHub Profile
import rx.Observable;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
/**
* Created by harshitbangar on 19/08/16.
package com.drawers.myapplication;
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Point;
import android.os.Build;
import android.util.AttributeSet;
import android.view.Display;
import android.view.View;
import android.view.ViewGroup;
onView(withId(R.id.my_view))
onView(allOf(withId(R.id.my_view), withText("Hello!")))
onView(allOf(withId(R.id.my_view), not(withText("Unwanted"))))
ConnectableObservable<String> remoteUserIdObservable =
mUserClient
.login()
.map(this::checkNonNull)
.doOnNext(this::logIn)
.map(UserModel::_id);
Observable<String> outputObservable = Observable
.concat(mSessionManager.getUserIdAsObservable(), remoteUserIdObservable);
public Observable<String> getUserIdAsObservable() {
public static void main(String[] args) throws InterruptedException {
TestSubscriber<Integer> testSubscriber = TestSubscriber.create(5); // For testing backpressure
TestObserver<Integer> testObserver = TestObserver.create(); // For testing observable.
Flowable<Integer> integerFlowable = getListOfStudentsFlowable();
Observable<Integer> observable = getListOfStudents();
observable.subscribe(testObserver);
integerFlowable.subscribe(testSubscriber);
testObserver.assertValueCount(100);
testSubscriber.assertValueCount(5);
}
public class MainActivity extends AppCompatActivity {
private Router router;
@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ViewGroup container = (ViewGroup)findViewById(R.id.controller_container);
router = Conductor.attachRouter(this, container, savedInstanceState);
import com.harshitbangar.mvpconductor.BaseController;
public class HomeController extends BaseController<HomeView> {
@Override
protected HomeView createView(@NonNull LayoutInflater inflater, @NonNull ViewGroup container) {
return (HomeView) inflater.inflate(R.layout.home, container, false);
}
public void backPress() {
import com.harshitbangar.mvpconductor.BaseView;
class HomeView extends BaseView<HomeController> {
public HomeView(Context context) {
super(context);
inflate(context, R.layout.home, this);
Toolbar toolbar = findView(R.id.toolbar);
toolbar.setNavigationOnClickListener(new OnClickListener() {
@Override public void onClick(View v) {
getController().backPress();
<?xml version="1.0" encoding="utf-8"?>
<com.harshitbangar.conductormvp.HomeView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
Observable.just(1)
.to(AutoDispose.with(RxLifecycleInterop.from(lifecycleProvider)).forObservable())
.subscribe(...)