コード例 #1
0
  /** 获取球队成员列表--只针对onlyTeam */
  private void executeGetTeamMemberList() {
    NetWorkManager.getInstance(mContext)
        .getTeamMember(
            onlyTeam.getUuid(),
            UserManager.getInstance(mContext).getCurrentUser().getToken(),
            new Listener<JSONArray>() {
              @SuppressWarnings("unchecked")
              @Override
              public void onResponse(JSONArray response) {
                Gson gson = new Gson();
                List<PlayerInTeam> myTeamList = null;
                try {
                  myTeamList =
                      gson.fromJson(
                          response.toString(),
                          new TypeToken<ArrayList<PlayerInTeam>>() {}.getType());
                } catch (JsonSyntaxException e) {
                  myTeamList = null;
                  e.printStackTrace();
                }
                adapter.setMemberList(myTeamList);
                listview.stopRefresh();

                // 将获取得到的球队成员列表数据放入到本地数据库中,缓存
                if (myTeamList != null && myTeamList.size() != 0) {
                  new WriteTeamMebToSqlAsyncTask().execute(myTeamList);
                }
              }
            },
            new ErrorListener() {
              @Override
              public void onErrorResponse(VolleyError error) {
                // ShowToast("获取球队成员失败:"+error.getMessage());
                listview.stopRefresh();
                if (!NetWorkManager.getInstance(mContext).isNetConnected()) {
                  ShowToast("当前网络不可用");
                } else if (error.networkResponse == null) {
                  ShowToast("获取球队成员失败");
                } else if (error.networkResponse.statusCode == 401) {
                  ErrorCodeUtil.ErrorCode401(mContext);
                } else if (error.networkResponse.statusCode == 404) {
                  ShowToast("球队找不到");
                }
              }
            });
  }
コード例 #2
0
  private void getPlayerUidByAccountName(String accountName) {
    dialog = new ProgressDialog(mContext);
    dialog.show();
    NetWorkManager.getInstance(mContext)
        .getPlayerByAccountName(
            UserManager.getInstance(mContext).getCurrentUser().getToken(),
            accountName,
            new Listener<JSONObject>() {
              @Override
              public void onResponse(JSONObject response) {
                // TODO Auto-generated method stub
                dialog.dismiss();
                Player player = null;
                Gson gson = new Gson();
                player = gson.fromJson(response.toString(), new TypeToken<Player>() {}.getType());
                if (player != null) {
                  playerUuid = player.getUuid();

                  Intent intent = new Intent(mContext, TeamPlayerInfo.class);
                  intent.putExtra(TeamPlayerInfo.PLAYER_UUID, playerUuid);
                  mContext.startActivity(intent);
                }
              }
            },
            new ErrorListener() {
              @Override
              public void onErrorResponse(VolleyError error) {
                // TODO Auto-generated method stub
                dialog.dismiss();
                if (!NetWorkManager.getInstance(mContext).isNetConnected()) {
                  ShowToast("当前网络不可用");
                } else if (error.networkResponse == null) {
                  // ShowToast("MessageChatAdapter-getPlayerUidByAccountName-服务器连接错误");
                } else if (error.networkResponse.statusCode == 401) {
                  ErrorCodeUtil.ErrorCode401(mContext);
                } else if (error.networkResponse.statusCode == 404) {
                  // ShowToast("球员找不到");
                }
              }
            });
  }