-
Notifications
You must be signed in to change notification settings - Fork 8
/
UserFragment.java
42 lines (36 loc) · 1.17 KB
/
UserFragment.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package com.testing.user.awaitility;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.testing.common.FileReader;
import com.testing.user.rx.NameRepository;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import java.io.File;
public class UserFragment extends Fragment {
private TextView textView;
@Override
public View onCreateView(
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
textView = new TextView(getActivity());
createNameRepository()
.getName()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(name -> textView.setText(name));
return textView;
}
private NameRepository createNameRepository() {
return new NameRepository(
new FileReader(
new File(getContext().getFilesDir().getAbsoluteFile() + File.separator + "test_file")));
}
@Override
public void onDestroyView() {
super.onDestroyView();
textView = null;
}
}