排球请求完成错误

时间:2016-01-29 11:53:02

标签: android android-volley

我在应用程序中工作,我使用volley来调用Web服务的场景就像当我按下后退按钮即时调用finish()然后当我尝试从最近的应用程序部分打开应用程序请求时登录(应用程序在请求之前被最小化)和Log cat说下面的Request.finish是重试策略行stringRequest.setRetryPolicy(new DefaultRetryPolicy(40000 *2, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));如果还需要其他代码我将发布...任何帮助是appriciated

这是Volleyrequest.java的代码 公共课VolleyRequest {

private static VolleyRequest instance;

private ProgressDialog progressDialog;
private Gson gson;
private Map<String, Integer> urlWiseResponseCheck = null;
// host address url


public static final String HOST_URL = "Host Url";

private static final String HOST_ADDRESS_PRIVATE = HOST_URL + "private/mobile/v1/";
private static final String HOST_ADDRESS_PUBLIC = HOST_URL + "public/mobile/v1/";

/**
 * 1 == loginAuthentication
 */
public static final String CHECK_LOGIN_AUTH = HOST_ADDRESS_PUBLIC + "check-login-authentication/";
/**
 * 2 == add user
 */
public static final String ADD_USER = HOST_ADDRESS_PUBLIC + "add-user/";
/**
 * 3 == add user with picture
 */
public static final String ADD_USER_WITH_PIC = HOST_ADDRESS_PUBLIC + "add-user-with-pic/";
/**
 * 4 == get workout calorie map
 */

public static final String GET_WORKOUT_CALORIE = HOST_ADDRESS_PUBLIC + "get-workout-calorie-map/";
/**
 * 5 == add activity record
 */
public static final String ADD_ACTIVITY_RECORD = HOST_ADDRESS_PRIVATE + "add-activity-record/";

/**
 * 6 == add history pictures
 */
public static final String ADD_HISTORY_PICTURE = HOST_ADDRESS_PRIVATE + "add-history-picture/";

/**
 * 7 == update logout flag
 */
public static final String SET_LOGOUT_FLAG = HOST_ADDRESS_PRIVATE + "set-logout-flag/";

/**
 * 8 == get history by history id
 */
public static final String GET_HISTORY = HOST_ADDRESS_PRIVATE + "get-history/";

/**
 * 9 == get history by user id
 */
public static final String GET_HISTORY_BY_ID = HOST_ADDRESS_PRIVATE + "get-user-history/";
// friend request
/**
 * 10 == add friend request
 */
public static final String ADD_FRIEND_REQUEST = HOST_ADDRESS_PRIVATE + "add-friend-request-record/";

/**
 * 11 == change friend status
 */
public static final String CHANGE_STATUS = HOST_ADDRESS_PRIVATE + "change-friend-req-status/";

/**
 * 12 == change trace status
 */
public static final String CHANGE_TRACE_STATUS = HOST_ADDRESS_PRIVATE + "change-trace-status/";

/**
 * 13 == get friend with trace status
 */
public static final String GET_FRIEND_WITH_TRACE_STATUS = HOST_ADDRESS_PRIVATE + "get-friend-with-trace-status";

/**
 * 14 == get user with friend status
 */
public static final String GET_ALL_USER_WITH_STATUS = HOST_ADDRESS_PRIVATE + "get-all-friend-with-status/";
/**
 * 15 == get tracer user list
 */
public static final String GET_TRACED_USER_LIST = HOST_ADDRESS_PRIVATE + "get-all-trace-user/";
/**
 * 16 == send invitation mail
 */
public static final String SEND_MAIL = HOST_ADDRESS_PRIVATE + "send-mail/";
/**
 * 17 == add user log
 */
public static final String ADD_USER_LOG = HOST_ADDRESS_PUBLIC + "add-log-file";
/**
 * 18 == delete history
 */
public static final String DELETE_USER_HISTORY = HOST_ADDRESS_PRIVATE + "delete-user-history/";

public static final String AUTH_TOKEN_REQUEST = HOST_URL + "oauth/token";

public static final String SET_SHARE_FLAG = HOST_ADDRESS_PRIVATE + "share-user-history/";

/**
 * 20 == Get last activity
 */
public static final String GET_LAST_ACTIVITY = HOST_ADDRESS_PRIVATE + "get-last-activity/";

public static final String GET_CHALLENGE = HOST_ADDRESS_PRIVATE + "get-challenges/";

public static final String SUSPEND_CHALLENGE = HOST_ADDRESS_PRIVATE + "suspend-challenge/";

public static final String INVITE_PARTICIPANTS = HOST_ADDRESS_PRIVATE + "invite-participants/";

public static final String SAVE_CHALLENGE = HOST_ADDRESS_PRIVATE + "save-challenge/";

public static final String JOIN_CHALLENGE = HOST_ADDRESS_PRIVATE + "join-challenge/";

public static final String GET_CHALLENGE_PARTICIPANT = HOST_ADDRESS_PRIVATE + "get-challenge-participant/";

public static final String GET_PARTICIPANTS = HOST_ADDRESS_PRIVATE + "get-participants/";

public static final String REMOVE_PARTICIPANT = HOST_ADDRESS_PRIVATE + "remove-participant/";

public static final String JOIN_OPEN_CHALLENGE = HOST_ADDRESS_PRIVATE + "join-open-challenge/";

/**
 * define final constant
 */
private final int CHECK_LOGIN_AUTH_VALUE = 1;
private final int ADD_USER_VALUE = 2;
private final int ADD_USER_WITH_PIC_VALUE = 3;
private final int GET_WORKOUT_CALORIE_VALUE = 4;
private final int ADD_ACTIVITY_RECORD_VALUE = 5;
private final int ADD_HISTORY_PICTURE_VALUE = 6;
private final int SET_LOGOUT_FLAG_VALUE = 7;
private final int GET_HISTORY_VALUE = 8;
private final int GET_HISTORY_BY_ID_VALUE = 9;
private final int ADD_FRIEND_REQUEST_VALUE = 10;
private final int CHANGE_STATUS_VALUE = 11;
private final int CHANGE_TRACE_STATUS_VALUE = 12;
private final int GET_FRIEND_WITH_TRACE_STATUS_VALUE = 13;
private final int GET_ALL_USER_WITH_STATUS_VALUE = 14;
private final int GET_TRACED_USER_LIST_VALUE = 15;
private final int SEND_MAIL_VALUE = 16;
private final int ADD_USER_LOG_VALUE = 17;
private final int DELETE_USER_HISTORY_VALUE = 18;
private final int SET_SHARE_FLAG_VALUE = 19;
private final int GET_LAST_ACTIVITY_VALUE = 20;
public static final int GET_CHALLENGE_VALUE = 21;

private final int SUSPEND_CHALLENGE_VALUE = 22;
private final int INVITE_PARTICIPANTS_VALUE = 23;
public static final int JOIN_CHALLENGE_VALUE = 24;
public static final int GET_CHALLENGE_PARTICIPANT_VALUE = 25;
public static final int GET_PARTICIPANTS_VALUE = 26;
public static final int REMOVE_PARTICIPANT_VALUE = 27;
public static final int JOIN_OPEN_CHALLENGE_VALUE = 28;


private VolleyRequest() {
}

public static VolleyRequest getInstance() {
    if (instance == null) {
        instance = new VolleyRequest();
    }
    return instance;
}

/**
 * initialization Url with Map
 */

public void initializationUrlMap() {
    gson = CommonUtil.getGson();
    if (urlWiseResponseCheck == null) {
        urlWiseResponseCheck = new HashMap<String, Integer>();
        urlWiseResponseCheck.put(CHECK_LOGIN_AUTH, CHECK_LOGIN_AUTH_VALUE);
        urlWiseResponseCheck.put(ADD_USER, ADD_USER_VALUE);
        urlWiseResponseCheck.put(ADD_USER_WITH_PIC, ADD_USER_WITH_PIC_VALUE);
        urlWiseResponseCheck.put(GET_WORKOUT_CALORIE, GET_WORKOUT_CALORIE_VALUE);
        urlWiseResponseCheck.put(ADD_ACTIVITY_RECORD, ADD_ACTIVITY_RECORD_VALUE);
        urlWiseResponseCheck.put(ADD_HISTORY_PICTURE, ADD_HISTORY_PICTURE_VALUE);
        urlWiseResponseCheck.put(SET_LOGOUT_FLAG, SET_LOGOUT_FLAG_VALUE);
        urlWiseResponseCheck.put(GET_HISTORY, GET_HISTORY_VALUE);
        urlWiseResponseCheck.put(GET_HISTORY_BY_ID, GET_HISTORY_BY_ID_VALUE);
        urlWiseResponseCheck.put(ADD_FRIEND_REQUEST, ADD_FRIEND_REQUEST_VALUE);
        urlWiseResponseCheck.put(CHANGE_STATUS, CHANGE_STATUS_VALUE);
        urlWiseResponseCheck.put(CHANGE_TRACE_STATUS, CHANGE_TRACE_STATUS_VALUE);
        urlWiseResponseCheck.put(GET_FRIEND_WITH_TRACE_STATUS, GET_FRIEND_WITH_TRACE_STATUS_VALUE);
        urlWiseResponseCheck.put(GET_ALL_USER_WITH_STATUS, GET_ALL_USER_WITH_STATUS_VALUE);
        urlWiseResponseCheck.put(GET_TRACED_USER_LIST, GET_TRACED_USER_LIST_VALUE);
        urlWiseResponseCheck.put(SEND_MAIL, SEND_MAIL_VALUE);
        urlWiseResponseCheck.put(ADD_USER_LOG, ADD_USER_LOG_VALUE);
        urlWiseResponseCheck.put(DELETE_USER_HISTORY, DELETE_USER_HISTORY_VALUE);
        urlWiseResponseCheck.put(SET_SHARE_FLAG, SET_SHARE_FLAG_VALUE);
        urlWiseResponseCheck.put(GET_LAST_ACTIVITY, GET_LAST_ACTIVITY_VALUE);
        urlWiseResponseCheck.put(GET_CHALLENGE, GET_CHALLENGE_VALUE);
        urlWiseResponseCheck.put(SUSPEND_CHALLENGE, SUSPEND_CHALLENGE_VALUE);
        urlWiseResponseCheck.put(INVITE_PARTICIPANTS, INVITE_PARTICIPANTS_VALUE);
        urlWiseResponseCheck.put(JOIN_CHALLENGE, JOIN_CHALLENGE_VALUE);
        urlWiseResponseCheck.put(GET_CHALLENGE_PARTICIPANT, GET_CHALLENGE_PARTICIPANT_VALUE);
        urlWiseResponseCheck.put(GET_PARTICIPANTS, GET_PARTICIPANTS_VALUE);
        urlWiseResponseCheck.put(REMOVE_PARTICIPANT, REMOVE_PARTICIPANT_VALUE);
        urlWiseResponseCheck.put(JOIN_OPEN_CHALLENGE, JOIN_OPEN_CHALLENGE_VALUE);
    }
}

/**
 * send server request using volley
 *
 * @param url
 * @param parameterJson
 * @param object        object[0] == context variable object[1] == Object variable
 */
public void sendRequest(final String url, final String parameterJson, final Object... object) {
    if (!CommonUtil.TRY_OUT_USER || url.equals(VolleyRequest.GET_WORKOUT_CALORIE)) {
        if (CommonUtil.isNetworkAvailable((Context) object[0])) {
            if (!url.equals(VolleyRequest.GET_TRACED_USER_LIST) && !url.equals(VolleyRequest.GET_WORKOUT_CALORIE) && !url.equals(VolleyRequest.GET_LAST_ACTIVITY) && !url.equals(VolleyRequest.GET_FRIEND_WITH_TRACE_STATUS)) {
                if (progressDialog != null) {
                    if (progressDialog.isShowing()) {
                        progressDialog.dismiss();
                    }
                    progressDialog = null;
                }
                progressDialog = new ProgressDialog((Context) object[0], R.style.CustomProgressDialog);
                startProgressDialog();
            }
            StringRequest stringRequest = new StringRequest(Request.Method.POST, url, new Listener<String>() {
                @Override
                public void onResponse(String response) {
                    getResponse(response, url, parameterJson, object);
                }

            }, new ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    onError(error, url, parameterJson, object);
                }

            }) {
                @Override
                protected Map<String, String> getParams() throws AuthFailureError {
                    return getParameter(url, parameterJson, object);
                }

                @Override
                public Map<String, String> getHeaders() throws AuthFailureError {
                    if (url.equals(CHECK_LOGIN_AUTH) || url.equals(ADD_USER) || url.equals(ADD_USER_WITH_PIC) || url.equals(ADD_USER_LOG)) {
                        return CommonUtil.getHeaders((Context) object[0], false);
                    } else {// private request
                        return CommonUtil.getHeaders((Context) object[0], true);
                    }
                }
            };
            stringRequest.setRetryPolicy(new DefaultRetryPolicy(30000 *2, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));

            VolleySingleton.getInstance((Context) object[0]).addRequest(stringRequest);
        } else {
            AlertMsg.showToast((Context) object[0], "You do not have internet connection");
        }
    }
}

private void onError(VolleyError error, String url, String parameterJson, Object[] objects) {
    if (error instanceof AuthFailureError) {
        CommonUtil.EXPIRE_TIME = null;
        sendRequest(url, parameterJson, objects);
    } else {
        dismissProgressDialog();
        AlertMsg.networkAlertDialog((Context) objects[0]);
    }
}

/**
 * get response from server
 *
 * @param response
 * @param url
 * @param parameterJson
 * @param object
 */
private void getResponse(String response, String url, String parameterJson, Object... object) {
    dismissProgressDialog();
    if (response != null) {
        int value = urlWiseResponseCheck.get(url);
        switch (value) {
            case CHECK_LOGIN_AUTH_VALUE:
                UserInfo userInfo = gson.fromJson(parameterJson, UserInfo.class);
                if ((Context) object[0] instanceof SplashScreenActivity) {
                    CommonUtil.checkAuthentication((Context) object[0], response, true, userInfo.getPassword());
                } else if ((Context) object[0] instanceof LoginActivity) {
                    CommonUtil.checkAuthentication((Context) object[0], response, false, userInfo.getPassword());
                } else if ((Context) object[0] instanceof GetPushNotificarionFromParse) {
                    ((GetPushNotificarionFromParse) object[0]).getResponse(response);
                } else if ((Context) object[0] instanceof TraceUserActivity) {
                    ((TraceUserActivity) object[0]).getLoginResponse(response);
                }
                break;
            case ADD_USER_VALUE:
                UserInfo userInfo2 = gson.fromJson(parameterJson, UserInfo.class);
                if (object.length > 1 && object[1] instanceof AccountDetailFragment) {
                    ((AccountDetailFragment) object[1]).getResponse(userInfo2);
                } else if (object.length > 1 && object[1] instanceof SettingMenuActivity) {
                    ((SettingMenuActivity) object[1]).getResponse();
                } else {
                    if (userInfo2.isFirstTime()) {
                        CommonUtil.setSubscriptionFlag((Context) object[0], true);
                    }
                    CommonUtil.showMainActivity((Context) object[0], response, userInfo2.getPassword());
                }

                break;
            case GET_WORKOUT_CALORIE_VALUE:
                Type type = new TypeToken<Map<String, Map<Double, Double>>>() {
                }.getType();
                Map<String, Map<Double, Double>> workoutCalorieMap = gson.fromJson(response, type);
                CommonUtil.setWorkoutCalorieMap(workoutCalorieMap);
                break;
            case ADD_ACTIVITY_RECORD_VALUE:
                if (object[0] instanceof AddWorkoutDetails) {
                    ((AddWorkoutDetails) object[0]).finish();
                } else if (object[1] instanceof SaveActivityRecord) {
                    ((SaveActivityRecord) object[1]).getResponse(response);
                } else if (object[1] instanceof MainFragment) {
                    CommonUtil.getUserHistory().setId(response);
                }
                break;
            case SET_LOGOUT_FLAG_VALUE:
                SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences((Context) object[0]);
                SharedPreferences.Editor editor = preferences.edit();
                editor.putString(ActivityConstant.EMAIL, null);
                editor.putString(ActivityConstant.USER_PASSWORD, null);
                editor.commit();
                Intent intent = new Intent((Context) object[0], LoginActivity.class);
                intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                ((Activity) object[0]).startActivity(intent);
                ((Activity) object[0]).finish();
                break;
            case GET_HISTORY_VALUE:
                if (object[1] instanceof HistoryFragment) {
                    ((HistoryFragment) object[1]).getResponse(response);
                } else if (object[1] instanceof TotalWorkoutDetailFragment) {
                    ((TotalWorkoutDetailFragment) object[1]).getResponse(response);
                }

                break;
            case GET_HISTORY_BY_ID_VALUE:
                if ((Context) object[0] instanceof TraceUserActivity) {
                    ((TraceUserActivity) (Context) object[0]).getResponse(response);
                } else if (object.length > 1 && object[1] instanceof HistoryFragment) {
                    ((HistoryFragment) object[1]).getHistoryItem(response);
                }
                break;
            case CHANGE_STATUS_VALUE:
                if ((Context) object[0] instanceof GetPushNotificarionFromParse) {
                    ((GetPushNotificarionFromParse) object[0]).getResponse();
                } else if ((Context) object[0] instanceof PendingUserList) {
                    ((PendingUserList) object[0]).finish();
                }
                break;
            case CHANGE_TRACE_STATUS_VALUE:
                if ((Context) object[0] instanceof GetPushNotificarionFromParse) {
                    ((GetPushNotificarionFromParse) object[0]).getResponse();
                }
                break;
            case GET_FRIEND_WITH_TRACE_STATUS_VALUE:
                if (object[1] instanceof FriendFragment) {
                    ((FriendFragment) object[1]).getResponse(response);
                } else if (object[1] instanceof ShowTraceFriendActivity) {
                    ((ShowTraceFriendActivity) object[1]).getResponse(response);
                }
                break;
            case GET_ALL_USER_WITH_STATUS_VALUE:
                Type collectionType = new TypeToken<Collection<UserWithFriendStatus>>() {
                }.getType();
                List<UserWithFriendStatus> allRecordList = gson.fromJson(response, collectionType);

                if (object[0] instanceof AddFriendFromContact) {
                    ((AddFriendFromContact) object[0]).getRecordFromServer(allRecordList);
                } else if (object[0] instanceof AddFriendFromHealthWel) {
                    ((AddFriendFromHealthWel) object[0]).getRecordFromServer(allRecordList);
                } else if (object[0] instanceof PendingUserList) {
                    ((PendingUserList) object[0]).getRecordFromServer(allRecordList);
                } else if (object[0] instanceof ParticipantHw) {
                    ((ParticipantHw) object[0]).getRecordFromServer(allRecordList);

                }
                break;
            case GET_TRACED_USER_LIST_VALUE:
                if (object[1] instanceof MainFragment) {
                    ((MainFragment) object[1]).getTraceUserResponse(response);
                }
                break;
            case ADD_USER_LOG_VALUE:
                if (object[1] instanceof SplashScreenActivity) {
                    ((SplashScreenActivity) object[1]).getResponse();
                }
                // ((MainActivity) (Context) object[0]).finish();
                break;
            case DELETE_USER_HISTORY_VALUE:
                if ((Context) object[0] instanceof OverViewActivity) {
                    ((OverViewActivity) object[0]).getResponse();
                }
                break;
            case SET_SHARE_FLAG_VALUE:
                if ((Context) object[0] instanceof FacebookIntegration) {
                    ((FacebookIntegration) object[0]).getResponse();
                } else if ((Context) object[0] instanceof GooglePlusIntegration) {
                    ((GooglePlusIntegration) object[0]).getResponse();
                }
                break;
            case GET_LAST_ACTIVITY_VALUE:
                if ((Context) object[0] instanceof MainActivity) {
                    ((MainActivity) object[0]).getLastActivityResponse(response);
                }
                break;
            case GET_CHALLENGE_VALUE:
            case SUSPEND_CHALLENGE_VALUE:
            case INVITE_PARTICIPANTS_VALUE:
            case JOIN_CHALLENGE_VALUE:
            case GET_CHALLENGE_PARTICIPANT_VALUE:
            case GET_PARTICIPANTS_VALUE:
            case REMOVE_PARTICIPANT_VALUE:
            case JOIN_OPEN_CHALLENGE_VALUE:
                if (object[1] instanceof ResponseListener) {
                    ((ResponseListener) object[1]).onResponse(response, value);
                }
                break;
        }
    }
}

/**
 * getParameter VolleyRequest
 *
 * @param url
 * @param parameters
 * @param object
 * @return Map<String,String>
 */
private Map<String, String> getParameter(String url, String parameters, Object[] object) {
    Map<String, String> params = new HashMap<String, String>();
    int value = urlWiseResponseCheck.get(url);
    if (value == CHECK_LOGIN_AUTH_VALUE || value == ADD_USER_VALUE) {
        params.put(ActivityConstant.USER_JSON, parameters);
    } else if (value == SET_LOGOUT_FLAG_VALUE || value == GET_HISTORY_VALUE || value == GET_FRIEND_WITH_TRACE_STATUS_VALUE || value == GET_ALL_USER_WITH_STATUS_VALUE
            || value == GET_TRACED_USER_LIST_VALUE || value == GET_LAST_ACTIVITY_VALUE || value == GET_CHALLENGE_VALUE) {
        params.put(ActivityConstant.USER_ID, CommonUtil.getUserInfo().getId());
    } else if (value == CHANGE_STATUS_VALUE || value == CHANGE_TRACE_STATUS_VALUE) {
        params.put(ActivityConstant.FRIEND_JSON, parameters);
    } else if (value == GET_HISTORY_BY_ID_VALUE || value == DELETE_USER_HISTORY_VALUE) {
        params.put(ActivityConstant.HISTORY_ID, parameters);
    } else if (value == SET_SHARE_FLAG_VALUE) {
        params.put(ActivityConstant.HISTORY_ID, parameters);
        if ((Context) object[0] instanceof FacebookIntegration) {
            params.put(ActivityConstant.FACEBOOK_SHARE, ActivityConstant.FACEBOOK_SHARE);
        } else {
            params.put(ActivityConstant.FACEBOOK_SHARE, ActivityConstant.GOOGLE_SHARE);
        }
    } else if (value == ADD_FRIEND_REQUEST_VALUE) {
        params.put(ActivityConstant.ADD_FRIEND, parameters);
    } else if (value == ADD_USER_LOG_VALUE) {
        params.put(ActivityConstant.ADD_LOG_FILE, parameters);
    } else if (value == SEND_MAIL_VALUE) {
        if ((object[0] instanceof AddFriendFromHealthWel) || object[0] instanceof ParticipantHw) {
            UserInfo receiverUser = (UserInfo) object[1];
            String subject = ActivityConstant.FRIEND_REQUEST_SUBJECT.replace("{SENDER_NAME}", CommonUtil.getUserInfo().getFirstName());
            String body = ActivityConstant.FRIEND_REQUEST_BODY.replace("{RECEIVER_NAME}", receiverUser.getFirstName()).replace("{SENDER_NAME}", CommonUtil.getUserInfo().getFirstName());
            params.put(ActivityConstant.MAIL_TO, parameters);
            params.put(ActivityConstant.MAIL_SUBJECT, subject);
            params.put(ActivityConstant.MAIL_BODY, body);
        } else if (object[0] instanceof AddFriendFromContact) {
            if (object[1] != null) {
                UserInfo receiverUser = (UserInfo) object[1];
                String subject = ActivityConstant.FRIEND_INVITATION_SUBJECT.replace("{SENDER_NAME}", CommonUtil.getUserInfo().getFirstName());
                String body = ActivityConstant.FRIEND_REQUEST_BODY.replace("{RECEIVER_NAME}", receiverUser.getFirstName()).replace("{SENDER_NAME}", CommonUtil.getUserInfo().getFirstName());
                params.put(ActivityConstant.MAIL_TO, parameters);
                params.put(ActivityConstant.MAIL_SUBJECT, subject);
                params.put(ActivityConstant.MAIL_BODY, body);
            } else {
                UserInfo receiverUser = (UserInfo) object[1];
                String subject = ActivityConstant.FRIEND_REQUEST_SUBJECT.replace("{SENDER_NAME}", CommonUtil.getUserInfo().getFirstName());
                String body = ActivityConstant.FRIEND_REQUEST_BODY.replace("{RECEIVER_NAME}", receiverUser.getFirstName()).replace("{SENDER_NAME}", CommonUtil.getUserInfo().getFirstName());
                params.put(ActivityConstant.MAIL_TO, parameters);
                params.put(ActivityConstant.MAIL_SUBJECT, subject);
                params.put(ActivityConstant.MAIL_BODY, body);
                // TODO : friend request.
            }
        } else if (object[0] instanceof MainActivity) {
            params.put(ActivityConstant.MAIL_TO, parameters);
            String subject = ActivityConstant.ERROR_LOG_TEMPLATE.replace("{USER_ID}", CommonUtil.getUserInfo().getId());
            params.put(ActivityConstant.MAIL_SUBJECT, subject);
            params.put(ActivityConstant.MAIL_BODY, ActivityConstant.log);
        }
        dismissProgressDialog();
    } else if (value == ADD_ACTIVITY_RECORD_VALUE) {
        params.put(ActivityConstant.ACTIVITY_RECORD_JSON, parameters);
    } else if (value == SUSPEND_CHALLENGE_VALUE || value == GET_PARTICIPANTS_VALUE) {
        params.put(ActivityConstant.CHALLENGE_ID_JSON, parameters);
    } else if (value == INVITE_PARTICIPANTS_VALUE) {
        params.put(ActivityConstant.INVITE_PARTICIPANT_JSON, parameters);
    } else if (value == JOIN_CHALLENGE_VALUE) {
        params.put(ActivityConstant.CODE_JSON, (String) object[2]);
        params.put(ActivityConstant.USER_ID, CommonUtil.getUserInfo().getId());
        if (CommonUtil.isNotNull(parameters)) {
            params.put(ActivityConstant.PAYMENT_JSON, parameters);
        }
    } else if (value == GET_CHALLENGE_PARTICIPANT_VALUE) {
        params.put(ActivityConstant.CODE_JSON, parameters);
    } else if (value == REMOVE_PARTICIPANT_VALUE) {
        params.put(ActivityConstant.CHALLENGE_ID_JSON, parameters);
        params.put(ActivityConstant.PARTICIPANT_ID, (String) object[2]);
    } else if (value == JOIN_OPEN_CHALLENGE_VALUE) {
        params.put(ActivityConstant.CHALLENGE_ID_JSON, parameters);
        params.put(ActivityConstant.USER_ID, (String) object[2]);
    }
    return params;
}

/**
 * start Progress Dialog
 */
public void startProgressDialog() {
    if (progressDialog != null && !progressDialog.isShowing()) {
        progressDialog.show();
        progressDialog.setCancelable(false);
    }

}

/**
 * dismiss Progress Dialog
 */
public void dismissProgressDialog() {
    if (progressDialog != null && progressDialog.isShowing()) {
        progressDialog.dismiss();
    }
}

0 个答案:

没有答案