Last active
January 2, 2018 07:49
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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