コード例 #1
0
  @Override
  void init() {
    back = (ImageView) findViewById(R.id.imageview_back);
    slife = (ImageView) findViewById(R.id.imageview_meituan);
    listview = (ListView) findViewById(R.id.listview_data);
    nodata = (TextView) findViewById(R.id.textview_nodata);
    button_new = (Button) findViewById(R.id.button_new);

    back.setOnClickListener(this);
    slife.setOnClickListener(this);
    button_new.setOnClickListener(this);

    AppContext appContext = (AppContext) getApplicationContext();
    User user = appContext.getUser();
    String username = user.getUsername();

    listview.setOnItemLongClickListener(this);

    RequestConstant nrc = new RequestConstant();
    nrc.setType(HttpRequests.HttpRequestType.POST);

    RequestConstant.requestUrl = UrlConstant.ADDRESSURL;
    RequestConstant.context = this;
    Map<String, Object> map = new HashMap<String, Object>();
    map.put("username", username);
    RequestConstant.map = map;
    getServer(
        new Netcallback() {

          @Override
          public void preccess(Object res, boolean flag) {
            if (res != null) {
              AddressParser parser = new AddressParser();
              addresses = parser.getAddress((String) res);
              if (addresses.size() > 0) {
                adapter = new AddressAdapter(AddressManageActivity.this, addresses);
                listview.setAdapter(adapter);
                nodata.setVisibility(View.GONE);
                listview.setVisibility(View.VISIBLE);
              }
            }
          }
        },
        nrc);
  }
コード例 #2
0
    public void run() {
      String res = null;
      if (NetUtil.isCheckNet(getApplicationContext())) {
        if (nrc.getType() == HttpRequests.HttpRequestType.POST) { // Post请求
          res = NetUtil.httpPost(nrc);
        } else if (nrc.getType() == HttpRequests.HttpRequestType.GET) { // get请求
          res = NetUtil.httpGet(nrc);
        }
        Message message = Message.obtain();
        message.obj = res;
        message.what = SUCCESS;
        handler.sendMessage(message);

      } else {
        Message message = Message.obtain();
        message.what = ERROR;
        handler.sendMessage(message);
      }
    }