Exemplo n.º 1
0
  // 获取企业的类型
  public void companytypelist(final OnAsynGetListListener listener) {
    RequestParams params = new RequestParams();
    params.put("pageSize", 10000);
    params.put("thisPage", 1);
    if (NetUtil.isNetworkAvailable()) {
      HttpUtil.post(
          "api/system/companytypelist",
          true,
          params,
          new AsyncHttpResponseHandler() {
            @Override
            public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
              if (arg0 != 200) {
                listener.OnAsynRequestFail(
                    "-1", GezitechApplication.getContext().getString(R.string.data_error));
              }
              try {
                Response response = new Response(new String(arg2));
                JSONObject root = response.asJSONObject();

                if (root.getInt("state") != 1) { // 0
                  if (listener != null) listener.OnAsynRequestFail("-1", root.getString("msg"));
                  return;
                }
                JSONObject data = root.getJSONObject("data");
                JSONArray ja = data.getJSONArray("datas");
                PageList pl = new PageList();
                Companytype ct = null;
                for (int i = 0; i < ja.length(); i++) {
                  JSONObject jo = ja.getJSONObject(i);
                  ct = new Companytype(jo);
                  ct.childtype = jo.has("childtype") ? jo.getJSONArray("childtype") : null;
                  pl.add(ct);
                }

                listener.OnGetListDone(pl);

              } catch (Exception ex) {
                listener.OnAsynRequestFail(
                    "-1", GezitechApplication.getContext().getString(R.string.data_error));
              }
            }

            @Override
            public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {
              listener.OnAsynRequestFail(
                  "-1", GezitechApplication.getContext().getString(R.string.data_error));
            }

            @Override
            public void onFinish() { // 完成后调用,失败,成功,都要掉
            }
          });
    } else {
      if (listener != null) {
        listener.OnAsynRequestFail(
            "-1", GezitechApplication.getContext().getString(R.string.network_error));
      }
    }
  }
Exemplo n.º 2
0
  // 获取省市
  public void getCityAreaStreet(
      long parentId, long nationalityidVal, final OnAsynGetListListener listener) {
    RequestParams params = new RequestParams();
    params.put("parentId", parentId);
    params.put("nationalityid", nationalityidVal);
    if (NetUtil.isNetworkAvailable()) {
      HttpUtil.post(
          "api/system/getCityAreaStreet",
          true,
          params,
          new AsyncHttpResponseHandler() {
            @Override
            public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
              if (arg0 != 200) {
                listener.OnAsynRequestFail(
                    "-1", GezitechApplication.getContext().getString(R.string.data_error));
              }
              try {
                Response response = new Response(new String(arg2));
                JSONObject root = response.asJSONObject();

                if (root.getInt("state") != 1) { // 0
                  if (listener != null) listener.OnAsynRequestFail("-1", root.getString("msg"));
                  return;
                }
                JSONArray data = root.getJSONArray("data");
                PageList pl = new PageList();
                City ct = null;
                for (int i = 0; i < data.length(); i++) {
                  JSONObject jo = data.getJSONObject(i);
                  ct = new City(jo);
                  pl.add(ct);
                }

                listener.OnGetListDone(pl);

              } catch (Exception ex) {
                listener.OnAsynRequestFail(
                    "-1", GezitechApplication.getContext().getString(R.string.data_error));
              }
            }

            @Override
            public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {
              listener.OnAsynRequestFail(
                  "-1", GezitechApplication.getContext().getString(R.string.data_error));
            }

            @Override
            public void onFinish() { // 完成后调用,失败,成功,都要掉
            }
          });
    } else {
      if (listener != null) {
        listener.OnAsynRequestFail(
            "-1", GezitechApplication.getContext().getString(R.string.network_error));
      }
    }
  }
Exemplo n.º 3
0
  // 联系我们
  public void configuration(final OnAsynGetListListener listener) {
    RequestParams params = new RequestParams();
    if (NetUtil.isNetworkAvailable()) {
      HttpUtil.post(
          "api/system/configuration",
          true,
          params,
          new AsyncHttpResponseHandler() {
            @Override
            public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
              if (arg0 != 200) {
                listener.OnAsynRequestFail(
                    "-1", GezitechApplication.getContext().getString(R.string.data_error));
              }
              try {
                Response response = new Response(new String(arg2));
                JSONObject root = response.asJSONObject();
                if (root.getInt("state") != 1) { // 0
                  if (listener != null) listener.OnAsynRequestFail("-1", root.getString("msg"));
                  return;
                }
                JSONArray data = root.getJSONArray("data");
                PageList pl = new PageList();
                Configuration cg = null;
                GezitechDBHelper<Configuration> db =
                    new GezitechDBHelper<Configuration>(Configuration.class);
                for (int i = 0; i < data.length(); i++) {
                  JSONObject jo = data.getJSONObject(i);
                  cg = new Configuration(jo);
                  pl.add(cg);
                  db.update(cg);
                }

                listener.OnGetListDone(pl);

              } catch (Exception ex) {
                listener.OnAsynRequestFail(
                    "-1", GezitechApplication.getContext().getString(R.string.data_error));
              }
            }

            @Override
            public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {
              listener.OnAsynRequestFail(
                  "-1", GezitechApplication.getContext().getString(R.string.data_error));
            }

            @Override
            public void onFinish() { // 完成后调用,失败,成功,都要掉
            }
          });
    } else {
      if (listener != null) {
        listener.OnAsynRequestFail(
            "-1", GezitechApplication.getContext().getString(R.string.network_error));
      }
    }
  }
Exemplo n.º 4
0
  /*
   * 获取幻灯广告列表(暂停的广告不要返回)
   * system/advlist
   * 参数
   * city 城市
   * page 当前页、
   * pageSize 每页显示数量
   */
  public void advlist(int page, int pageSize, String city, final OnAsynGetListListener listener) {
    RequestParams params = new RequestParams();
    params.put("city", city);
    params.put("page", page);
    params.put("pageSize", pageSize);
    if (NetUtil.isNetworkAvailable()) {
      HttpUtil.post(
          "api/system/advlist",
          true,
          params,
          new AsyncHttpResponseHandler() {
            @Override
            public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
              if (arg0 != 200) {
                listener.OnAsynRequestFail(
                    "-1", GezitechApplication.getContext().getString(R.string.data_error));
              }
              try {
                Response response = new Response(new String(arg2));
                JSONObject root = response.asJSONObject();
                if (root.getInt("state") != 1) { // 0
                  if (listener != null) listener.OnAsynRequestFail("-1", root.getString("msg"));
                  return;
                }
                JSONObject data = root.getJSONObject("data");
                PageList pl = new PageList();
                Adv adv = null;
                GezitechDBHelper<Adv> advDB = new GezitechDBHelper<Adv>(Adv.class);
                if (data.has("datas") && !data.isNull("datas")) {
                  JSONArray datas = data.getJSONArray("datas");

                  PageList cachepl = getClientAdvList();
                  if (cachepl != null && cachepl.size() > 0) advDB.delete("");

                  for (int i = 0; i < datas.length(); i++) {
                    JSONObject jo = datas.getJSONObject(i);
                    adv = new Adv(jo);
                    pl.add(adv);
                    advDB.insert(adv);
                  }
                }
                listener.OnGetListDone(pl);

              } catch (Exception ex) {
                listener.OnAsynRequestFail(
                    "-1", GezitechApplication.getContext().getString(R.string.data_error));
              }
            }

            @Override
            public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {
              listener.OnAsynRequestFail(
                  "-1", GezitechApplication.getContext().getString(R.string.data_error));
            }

            @Override
            public void onFinish() { // 完成后调用,失败,成功,都要掉
            }
          });
    } else {
      if (listener != null) {
        listener.OnAsynRequestFail(
            "-1", GezitechApplication.getContext().getString(R.string.network_error));
      }
    }
  }
Exemplo n.º 5
0
  // 获取公告(新闻)列表
  public void getannouncementlist(int page, int pageSize, final OnAsynGetListListener listener) {
    RequestParams params = new RequestParams();
    params.put("page", page);
    params.put("pageSize", pageSize);
    if (NetUtil.isNetworkAvailable()) {
      HttpUtil.post(
          "api/News/getannouncementlist",
          true,
          params,
          new AsyncHttpResponseHandler() {
            @Override
            public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
              if (arg0 != 200) {
                listener.OnAsynRequestFail(
                    "-1", GezitechApplication.getContext().getString(R.string.data_error));
              }
              try {
                Response response = new Response(new String(arg2));
                JSONObject root = response.asJSONObject();
                if (root.getInt("state") != 1) { // 0
                  if (listener != null) listener.OnAsynRequestFail("-1", root.getString("msg"));
                  return;
                }
                JSONObject data = root.getJSONObject("data");
                PageList pl = new PageList();
                News news = null;
                if (data.has("datas") && !data.isNull("datas")) {
                  JSONArray datas = data.getJSONArray("datas");
                  for (int i = 0; i < datas.length(); i++) {
                    JSONObject jo = datas.getJSONObject(i);
                    news = new News();
                    news.id = jo.has("id") ? jo.getLong("id") : 0;
                    news.ctime = jo.has("ctime") ? jo.getLong("ctime") : 0;
                    news.title = jo.has("title") ? jo.getString("title") : "";
                    news.content = jo.has("content") ? jo.getString("content") : "";

                    pl.add(news);
                  }
                }
                listener.OnGetListDone(pl);

              } catch (Exception ex) {
                listener.OnAsynRequestFail(
                    "-1", GezitechApplication.getContext().getString(R.string.data_error));
              }
            }

            @Override
            public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {
              listener.OnAsynRequestFail(
                  "-1", GezitechApplication.getContext().getString(R.string.data_error));
            }

            @Override
            public void onFinish() { // 完成后调用,失败,成功,都要掉
            }
          });
    } else {
      if (listener != null) {
        listener.OnAsynRequestFail(
            "-1", GezitechApplication.getContext().getString(R.string.network_error));
      }
    }
  }