Skip to content

Instantly share code, notes, and snippets.

@akari0624
Last active January 2, 2018 07:49
Show Gist options
  • Save akari0624/58be5d906f82cdc01383 to your computer and use it in GitHub Desktop.
Save akari0624/58be5d906f82cdc01383 to your computer and use it in GitHub Desktop.
after to retrieving data from DataBase by the withOutAsyncTask( )..... then use RXAndroid to parse them to the UI
subscription = Observable.just(fetchDataHttpCall())
.map(new Func1<String, List<GRO_VO>>() {
@Override
public List<GRO_VO> call(String jsonIn) {
Gson gson = new Gson();
Type listType = new TypeToken<List<GRO_VO>>() {
}.getType();
return gson.fromJson(jsonIn, listType);
}
})
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Action1<List<GRO_VO>>() {
@Override
public void call(List<GRO_VO> groVoList) {
Log.d("RX", ".subscribe");
recyclerView.setAdapter(new EventJoinAdapter(groVoList));
}
});
public String fetchDataHttpCall() {
String GroURL = theURL.URL + "GroupServlet";
String mem_noMy1 = "6";
Log.d(TAG, "GroURL=" + GroURL);
String jsonIn = "";
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("action", "getEventOthersHostNotOver");
jsonObject.addProperty("mem_no", mem_noMy1);
try {
jsonIn = okHttpPost(GroURL, jsonObject.toString());
} catch (IOException e) {
Log.d(TAG, e.getMessage());
}
return jsonIn;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment