Skip to content

Instantly share code, notes, and snippets.

@jwhitehorn
Created February 12, 2014 21:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jwhitehorn/8964820 to your computer and use it in GitHub Desktop.
Save jwhitehorn/8964820 to your computer and use it in GitHub Desktop.
@Override
public void render(final String json){
try{
JSONObject jsonObj = new JSONObject(json);
Iterator<?> keys = jsonObj.keys();
while(keys.hasNext()){
final String key = (String)keys.next();
final String value = jsonObj.getString(key);
this.runOnUiThread(new Runnable() {
@Override
public void run() {
setFieldValue(key, value);
}
});
}
}catch(JSONException e){}
}
protected void setFieldValue(String key, String value){
if(key.equalsIgnoreCase("inCurrencies")){
//TODO
}else if(key.equalsIgnoreCase("outCurrencies")){
//TODO
}else if(key.equalsIgnoreCase("in_amount")){
((EditText)findViewById(R.id.unconvertedEditText)).setText(value);
}else if(key.equalsIgnoreCase("out_amount")){
((TextView)findViewById(R.id.convertedTextView)).setText(value);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment