@@ -8,18 +8,23 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.Toast;

import com.example.myotive.codemash_common.BaseApplication;
import com.example.myotive.codemash_common.network.CodeMashAPI;
import com.example.myotive.codemash_common.network.models.Speaker;
import com.example.myotive.codemash_common.ui.SpeakerAdapter;
import com.example.myotive.strangerstreamsdemo.R;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import rx.Observable;
import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.functions.Func1;
import rx.schedulers.Schedulers;
import timber.log.Timber;

@@ -29,9 +34,9 @@ public static RxJavaBasicsFragment newInstance() {
return new RxJavaBasicsFragment();
}

private Button btnJust, btnFrom, btnMap, btnNetworkCall;

private CodeMashAPI codeMashAPI;
private RecyclerView speakerRecyclerView;
private SpeakerAdapter speakerAdapter;

@Override
public void onAttach(Context context) {
@@ -43,40 +48,102 @@ public void onAttach(Context context) {
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {

View view = inflater.inflate(R.layout.fragment_codemash, container, false);

speakerAdapter = new SpeakerAdapter(getContext(), Collections.<Speaker>emptyList());
View view = inflater.inflate(R.layout.fragment_rxbasic, container, false);

speakerRecyclerView = (RecyclerView)view.findViewById(R.id.rv_speakers);
speakerRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
speakerRecyclerView.setAdapter(speakerAdapter);
SetupUI(view);

return view;
}

@Override
public void onResume() {
super.onResume();

codeMashAPI
.GetSpeakers()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Subscriber<List<Speaker>>() {
@Override
public void onCompleted() {

}

@Override
public void onError(Throwable e) {
Timber.e(e);
}

@Override
public void onNext(List<Speaker> speakers) {
speakerAdapter.swap(speakers);
}
});
private void SetupUI(View view) {

btnJust = (Button)view.findViewById(R.id.button_just);
btnJust.setOnClickListener(v -> {
Observable.just(1)
.subscribe(new Subscriber<Integer>() {
@Override
public void onCompleted() {

}

@Override
public void onError(Throwable e) {

}

@Override
public void onNext(Integer i) {
Toast.makeText(getContext(), String.valueOf(i), Toast.LENGTH_SHORT).show();
}
});
});

btnFrom = (Button)view.findViewById(R.id.button_from);
btnFrom.setOnClickListener(v -> {
Observable.from(Arrays.asList(1, 2, 3, 4))
.subscribe(new Subscriber<Integer>() {
@Override
public void onCompleted() {

}

@Override
public void onError(Throwable e) {

}

@Override
public void onNext(Integer i) {
Toast.makeText(getContext(), String.valueOf(i), Toast.LENGTH_SHORT).show();
}
});
});

btnMap = (Button)view.findViewById(R.id.button_map);
btnMap.setOnClickListener(v -> {

Observable.just("Eleven", "Mike", "Dustin", "Will", "Lucas")
.map(s -> s.length())
.subscribe(new Subscriber<Integer>() {
@Override
public void onCompleted() {

}

@Override
public void onError(Throwable e) {

}

@Override
public void onNext(Integer i) {
Toast.makeText(getContext(), String.valueOf(i), Toast.LENGTH_SHORT).show();
}
});


});

btnNetworkCall = (Button)view.findViewById(R.id.button_network_call);
btnNetworkCall.setOnClickListener(v -> {
codeMashAPI
.GetSpeakers()
.subscribe(new Subscriber<List<Speaker>>() {
@Override
public void onCompleted() {

}

@Override
public void onError(Throwable e) {
Toast.makeText(getContext(), "ERROR: Could not make network call on main thread", Toast.LENGTH_SHORT).show();
}

@Override
public void onNext(List<Speaker> speakers) {
Toast.makeText(getContext(), "Speaker List Count: " + speakers.size(), Toast.LENGTH_SHORT).show();
}
});
});
}
}
@@ -8,33 +8,39 @@
android:clickable="true"
android:focusableInTouchMode="true">

<android.support.design.widget.CoordinatorLayout
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<!-- <android.support.design.widget.CoordinatorLayout
android:id="@+id/overview_coordinator_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
android:theme="@style/AppTheme.AppBarOverlay">-->

<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:titleTextColor="@android:color/white"
app:layout_scrollFlags="scroll|snap"
app:popupTheme="@style/AppTheme.PopupOverlay" />

</android.support.design.widget.AppBarLayout>
<!-- </android.support.design.widget.AppBarLayout>-->

<FrameLayout
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent" />

</android.support.design.widget.CoordinatorLayout>

<!--</android.support.design.widget.CoordinatorLayout>-->
</LinearLayout>
<android.support.design.widget.NavigationView
android:id="@+id/navigationView"
app:headerLayout="@layout/nav_header"
@@ -3,8 +3,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="?attr/actionBarSize">
android:layout_height="match_parent">

<LinearLayout
android:layout_width="match_parent"
@@ -1,6 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">

<Button
android:id="@+id/button_just"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Observable.Just(1)"/>

<Button
android:id="@+id/button_from"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Observable.from()"/>

<Button
android:id="@+id/button_map"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Observable.map()"/>

<Button
android:id="@+id/button_network_call"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Call CodeMash API"/>


</LinearLayout>
@@ -1,16 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<group android:id="@+id/group_feature"
android:checkableBehavior="single">
<item android:id="@+id/navdrawer_item_dnd"
android:checked="true"
android:title="D &amp; D Search"/>
<group android:checkableBehavior="single">
<item android:id="@+id/navdrawer_item_rxjava"
android:title="RxJava Basics"/>

</group>
<group android:id="@+id/group_settings"
android:checkableBehavior="single">
<group android:checkableBehavior="single">
<item android:id="@+id/navdrawer_item_codemash"
android:title="Code Mash"/>

</group>
<group android:checkableBehavior="single">
<item android:id="@+id/navdrawer_item_dnd"
android:title="D &amp; D Search"/>

</group>
</menu>
@@ -7,6 +7,7 @@ buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath "io.realm:realm-gradle-plugin:2.0.2"
classpath 'me.tatarka:gradle-retrolambda:3.4.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
@@ -0,0 +1,21 @@
/* Style definition file generated by highlight 3.32, http://www.andre-simon.de/ */

/* Highlighting theme: Kwrite Editor */

body.hl { background-color:#e0eaee; }
pre.hl { color:#000000; background-color:#e0eaee; font-size:10pt; font-family:'Courier New',monospace;}
.hl.num { color:#b07e00; }
.hl.esc { color:#ff00ff; }
.hl.str { color:#bf0303; }
.hl.pps { color:#818100; }
.hl.slc { color:#838183; font-style:italic; }
.hl.com { color:#838183; font-style:italic; }
.hl.ppc { color:#008200; }
.hl.opt { color:#000000; }
.hl.ipl { color:#0057ae; }
.hl.lin { color:#555555; }
.hl.kwa { color:#000000; font-weight:bold; }
.hl.kwb { color:#0057ae; }
.hl.kwc { color:#000000; font-weight:bold; }
.hl.kwd { color:#010181; }

13 rtf
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Source file</title>
<link rel="stylesheet" type="text/css" href="highlight.css">
</head>
<body class="hl">
<pre class="hl">
</pre>
</body>
</html>
<!--HTML generated by highlight 3.32, http://www.andre-simon.de/-->