Skip to content

Instantly share code, notes, and snippets.

Last active August 29, 2015 13:56
Show Gist options
  • Save jwhitehorn/8964842 to your computer and use it in GitHub Desktop.
Save jwhitehorn/8964842 to your computer and use it in GitHub Desktop.
package com.sample;
import com.calatrava.CalatravaPage;
import android.os.Bundle;
import android.widget.EditText;
import android.widget.TextView;
import android.view.View;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Iterator;
@CalatravaPage(name = "conversionForm")
public class ConversionForm extends com.calatrava.bridge.RegisteredActivity {
public String getFieldValue(String field){
return "USD";
}else if(field.equalsIgnoreCase("out_currency")){
return "AUD";
}else if(field.equalsIgnoreCase("in_amount")){
return ((EditText) findViewById(;
return null;
public void render(final String json){
JSONObject jsonObj = new JSONObject(json);
Iterator<?> keys = jsonObj.keys();
final String key = (String);
final String value = jsonObj.getString(key);
this.runOnUiThread(new Runnable() {
public void run() {
setFieldValue(key, value);
}catch(JSONException e){}
protected void setFieldValue(String key, String value){
}else if(key.equalsIgnoreCase("outCurrencies")){
}else if(key.equalsIgnoreCase("in_amount")){
}else if(key.equalsIgnoreCase("out_amount")){
protected String getPageName() {
return "conversionForm";
public void onCreate(Bundle savedInstanceState) {
public void convert(View v) {
this.triggerEvent("convert", new String[] {});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment