Search in sources :

Example 1 with RequestError

use of labs.anton.icenet.RequestError in project IceNet by anton46.

the class JsonArrayActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    final ListView listView = (ListView) findViewById(R.id.list);
    final ProgressDialog dialog = new ProgressDialog(this);
    dialog.setMessage("Loading...");
    dialog.show();
    IceNet.connect().createRequest().get().pathUrl("/notes").fromJsonArray().mappingInto(Notes.class).execute("request_string", new RequestCallback<Notes>() {

        @Override
        public void onRequestSuccess(Notes notes) {
            dialog.dismiss();
            String[] values = new String[notes.size()];
            for (int i = 0; i < notes.size(); i++) values[i] = notes.get(i).getTitle();
            adapter = new ArrayAdapter<String>(JsonArrayActivity.this, android.R.layout.simple_list_item_1, android.R.id.text1, values);
            listView.setAdapter(adapter);
        }

        @Override
        public void onRequestError(RequestError error) {
            dialog.dismiss();
        }
    });
}
Also used : ListView(android.widget.ListView) RequestError(labs.anton.icenet.RequestError) ProgressDialog(android.app.ProgressDialog) ArrayAdapter(android.widget.ArrayAdapter)

Example 2 with RequestError

use of labs.anton.icenet.RequestError in project IceNet by anton46.

the class JsonObjectActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_json_object);
    final TextView id = (TextView) findViewById(R.id.tv_id);
    final TextView title = (TextView) findViewById(R.id.tv_title);
    final ProgressDialog dialog = new ProgressDialog(this);
    dialog.setMessage("Loading...");
    dialog.show();
    IceNet.connect().createRequest().get().pathUrl("/notes/1").fromJsonObject().mappingInto(Note.class).execute("request_string", new RequestCallback<Note>() {

        @Override
        public void onRequestSuccess(Note note) {
            dialog.dismiss();
            id.setText(note.getId());
            title.setText(note.getTitle());
        }

        @Override
        public void onRequestError(RequestError error) {
            dialog.dismiss();
        }
    });
}
Also used : RequestError(labs.anton.icenet.RequestError) TextView(android.widget.TextView) ProgressDialog(android.app.ProgressDialog)

Example 3 with RequestError

use of labs.anton.icenet.RequestError in project IceNet by anton46.

the class StringActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_string);
    final TextView result = (TextView) findViewById(R.id.tv_result);
    final ProgressDialog dialog = new ProgressDialog(this);
    dialog.setMessage("Loading...");
    dialog.show();
    IceNet.connect().createRequest().get().pathUrl("/string").fromString().execute("request_string", new RequestCallback<String>() {

        @Override
        public void onRequestSuccess(String str) {
            dialog.dismiss();
            result.setText(str);
        }

        @Override
        public void onRequestError(RequestError error) {
            dialog.dismiss();
        }
    });
}
Also used : RequestError(labs.anton.icenet.RequestError) TextView(android.widget.TextView) ProgressDialog(android.app.ProgressDialog)

Aggregations

ProgressDialog (android.app.ProgressDialog)3 RequestError (labs.anton.icenet.RequestError)3 TextView (android.widget.TextView)2 ArrayAdapter (android.widget.ArrayAdapter)1 ListView (android.widget.ListView)1