Skip to content

Commit 63ddd0e

Browse files
author
Kaushik Gopal
committed
fix: clean up text for demo
1 parent db1a1fe commit 63ddd0e

3 files changed

Lines changed: 34 additions & 8 deletions

File tree

app/src/main/java/com/morihacky/android/rxjava/SubjectDebounceSearchEmitterFragment.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import android.widget.ListView;
1414
import butterknife.ButterKnife;
1515
import butterknife.InjectView;
16+
import butterknife.OnClick;
1617
import java.util.ArrayList;
1718
import java.util.List;
1819
import java.util.concurrent.TimeUnit;
@@ -73,8 +74,15 @@ public View onCreateView(LayoutInflater inflater,
7374
return layout;
7475
}
7576

77+
@OnClick(R.id.clr_subject_debounce)
78+
public void onClearLog() {
79+
_logs = new ArrayList<>();
80+
_adapter.clear();
81+
}
82+
7683
@Override
7784
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
85+
7886
super.onActivityCreated(savedInstanceState);
7987
_setupLogger();
8088

@@ -105,7 +113,7 @@ public void onError(Throwable e) {
105113

106114
@Override
107115
public void onNext(OnTextChangeEvent onTextChangeEvent) {
108-
_log(format("onNext You searched for %s", onTextChangeEvent.text().toString()));
116+
_log(format("Searching for %s", onTextChangeEvent.text().toString()));
109117
}
110118
};
111119
}

app/src/main/res/layout/fragment_subject_debounce.xml

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,31 @@
1515
android:text="@string/msg_demo_subject"
1616
/>
1717

18-
<EditText
19-
android:id="@+id/input_txt_subject_debounce"
18+
<LinearLayout
19+
android:orientation="horizontal"
2020
android:layout_height="wrap_content"
2121
android:layout_width="match_parent"
22-
android:textSize="16sp"
23-
android:hint="Enter some search text"
24-
/>
22+
>
23+
24+
<EditText
25+
android:id="@+id/input_txt_subject_debounce"
26+
android:layout_weight="7"
27+
android:layout_height="match_parent"
28+
android:layout_width="0dp"
29+
android:inputType="textNoSuggestions"
30+
android:textSize="16sp"
31+
android:hint="Enter some search text"
32+
/>
33+
34+
<ImageButton
35+
android:id="@+id/clr_subject_debounce"
36+
android:layout_weight="1"
37+
android:layout_height="wrap_content"
38+
android:layout_width="0dp"
39+
android:src="@android:drawable/ic_menu_close_clear_cancel"
40+
/>
41+
42+
</LinearLayout>
2543

2644
<ListView
2745
android:id="@+id/list_threading_log"

app/src/main/res/values/strings.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020

2121
<string name="msg_demo_concurrency_schedulers">This is a demo of how long running operations can be offloaded to a background thread. After the operation is done, we resume back on the main thread. All using RxJava! \n\n To really see this shine. Hit the button multiple times and see how the button click which is a ui operation is never blocked because the long operation only runs in the background</string>
2222
<string name="msg_demo_buffer">This is a demo of how events can be accumulated using the "buffer" operation. Tap the button below repetitively and you will notice in the logs that button taps are collected over a span of 2s and printed below.</string>
23-
<string name="msg_demo_subject">As you type in the input box, it will not shoot out log messages at every single input character change, but rather only pick the lastly emitted event (i.e. input) and log that. \n\nThis is the debounce/throttleWithTimeout method in RxJava.</string>
23+
<string name="msg_demo_subject">As you type in the input box, it will not shoot out log messages at every single input character change, but rather only pick the last one.</string>
2424
<string name="msg_demo_timeout">This is a demo of terminating events, that take too long to process. Events in this demo should timeout in 3 seconds. Button 1 is an event that takes 2s to process, and Button 2 is a n event that takes 5s to process. Hit Button 2, and see in the logs that it\'s been cancelled, while this is not the case for Button 1.</string>
2525
<string name="msg_demo_retrofit">Retrofit from Square is a super easy networking helper library. It works really well with RxJava and these are examples taken from Jake Wharton\'s talk at Netflix (see README). Really the only interesting bits here are in the code and logs.</string>
2626
<string name="msg_demo_retrofit_async_task_death">This shows how you can replace an AsyncTask with RxJava. The interesting parts are in the code.</string>
27-
<string name="msg_demo_doublebinding">Watch how the result gloriously auto-updates based on your changing inputs. Using a technique like this, you could achieve the two-way binding in Angular Js, or more efficiently use a pattern like the Presentation View Model.</string>
27+
<string name="msg_demo_doublebinding">Watch how the result gloriously auto-updates <ba></ba>sed on your changing inputs. Using a technique like this, you could achieve the two-way binding in Angular Js, or more efficiently use a pattern like the Presentation View Model.</string>
2828
<string name="msg_demo_polling">This is demo of polling or making a call repeatedly with RxJava. \n\nSimple polling: Notice in the logs how a network call (simulated) is repeatedly made in the background.</string>
2929
<string name="msg_demo_rxbus_1">Tap on the below button and RxBus will listen to the events</string>
3030
<string name="msg_demo_form_comb_latest">Monitor the state of multiple observables with the combineLatest operator. The submit button uses combineLatest to monitor validity of each of the 3 inputs. Only after the 3 inputs contain valid inputs will the submit button be enabled</string>

0 commit comments

Comments
 (0)