Android Open Source - android-json-http Main Activity






From Project

Back to project page android-json-http.

License

The source code is released under:

Apache License

If you think the Android project android-json-http 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;
/*from   w  ww.  j a v a2 s .  c  o  m*/
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;

import com.example.constant.Result;
import com.example.response.GeocodeResBean;
import com.example.util.AccessApiUtil;
import com.open.jsonhttp.AsyncTask;
import com.open.jsonhttp.OnRequestHttpListener;
import com.open.jsonhttp.ResponseBean;

public class MainActivity extends Activity implements OnClickListener,
        OnRequestHttpListener {

    private TextView tvHelloWorld;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        tvHelloWorld = (TextView) findViewById(R.id.tvHelloWorld);
        findViewById(R.id.btnObtain).setOnClickListener(this);
    }

    AsyncTask mTaskGenCode;

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btnObtain:
                mTaskGenCode = AccessApiUtil.gencode("HK", this);
                break;

            default:
                break;
        }
    }

    @Override
    public void onSuccess(int responseKey, ResponseBean responseBean) {
        switch (responseKey) {
            case AccessApiUtil.INDEX_GEOCODE:
                if (responseBean.getStatus().equals(Result.OK)) {
                    GeocodeResBean resBean = (GeocodeResBean) responseBean;
                    tvHelloWorld.setText(resBean.toString());
                }
                break;

            default:
                break;
        }
    }

    @Override
    public void onFail(int responseKey, int code) {
        switch (responseKey) {
            case AccessApiUtil.INDEX_GEOCODE:

                break;

            default:
                break;
        }
    }

    @Override
    protected void onDestroy() {
        if (mTaskGenCode != null) {
            mTaskGenCode.interrupt();
        }
        super.onDestroy();
    }
}




Java Source Code List

com.example.App.java
com.example.MainActivity.java
com.example.constant.Request.java
com.example.constant.Result.java
com.example.constant.Url.java
com.example.request.GeocodeReqBean.java
com.example.response.GeocodeResBean.java
com.example.response.table.AddressComponent.java
com.example.response.table.GeocodeTable.java
com.example.response.table.Geometry.java
com.example.response.table.LocationRectangle.java
com.example.response.table.Location.java
com.example.util.AccessApiUtil.java
com.open.jsonhttp.AsyncTask.java
com.open.jsonhttp.HttpRequest.java
com.open.jsonhttp.HttpResCode.java
com.open.jsonhttp.OnRequestHttpListener.java
com.open.jsonhttp.RequestBeanFile.java
com.open.jsonhttp.RequestBean.java
com.open.jsonhttp.ResponseBean.java
com.open.jsonhttp.WebServiceListener.java
com.open.jsonhttp.util.NetwrokUtil.java
com.open.jsonhttp.util.ParseUtil.java
com.open.jsonhttp.util.RequestUtil.java
com.open.jsonhttp.util.StringUtil.java
com.open.jsonhttp.util.ThreadUtil.java