Android Open Source - simple-json-android-exercise Main Activity






From Project

Back to project page simple-json-android-exercise.

License

The source code is released under:

Apache License

If you think the Android project simple-json-android-exercise listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.example.simplejsonapp;
/*w w  w .j  a v a2  s .  c o  m*/
import android.app.Activity;
import android.widget.TextView;

import com.example.simplejsonapp.entity.User;
import com.example.simplejsonapp.rest.SimpleRestClient;
import com.googlecode.androidannotations.annotations.AfterViews;
import com.googlecode.androidannotations.annotations.Background;
import com.googlecode.androidannotations.annotations.EActivity;
import com.googlecode.androidannotations.annotations.UiThread;
import com.googlecode.androidannotations.annotations.ViewById;
import com.googlecode.androidannotations.annotations.rest.RestService;

@EActivity(R.layout.activity_main)
public class MainActivity extends Activity {

  @ViewById
  TextView textView1;

  @RestService
  SimpleRestClient restClient;

  @AfterViews
  void afterViews() {
    setTextView1("-");
    
    getUserNameById("testid1");
  }

  @Background
  void getUserNameById(String id) {
    User user = restClient.getUserById(id);
    setTextView1(user.toString());
  }

  @UiThread
  void setTextView1(String text) {
    textView1.setText("received : " + text);
  }

}




Java Source Code List

com.example.simplejsonapp.MainActivity.java
com.example.simplejsonapp.MainActivity_.java
com.example.simplejsonapp.entity.User.java
com.example.simplejsonapp.rest.SimpleRestClient.java
com.example.simplejsonapp.rest.SimpleRestClient_.java