去除volley
This commit is contained in:
@ -15,15 +15,11 @@ import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.android.volley.Request.Method;
|
||||
import com.android.volley.Response;
|
||||
import com.android.volley.VolleyError;
|
||||
import com.android.volley.toolbox.JsonObjectRequest;
|
||||
import com.gh.base.AppController;
|
||||
import com.gh.base.BaseActivity;
|
||||
import com.gh.common.constant.Config;
|
||||
import com.gh.common.util.DialogUtils;
|
||||
import com.gh.common.util.PackageUtils;
|
||||
import com.gh.gamecenter.retrofit.JSONObjectResponse;
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
@ -33,6 +29,11 @@ import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.RequestBody;
|
||||
import rx.android.schedulers.AndroidSchedulers;
|
||||
import rx.schedulers.Schedulers;
|
||||
|
||||
/**
|
||||
* @author fang
|
||||
* @from SettingActivity
|
||||
@ -185,18 +186,22 @@ public class SuggestionActivity extends BaseActivity implements OnClickListener
|
||||
}
|
||||
|
||||
private void sendSuggestion(final Dialog dialog, String email) {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("message", et_suggest_content.getText().toString().trim());
|
||||
map.put("from", email);
|
||||
map.put("ghversion", PackageUtils.getVersion(this));
|
||||
map.put("channel", (String) PackageUtils.getMetaData(this, getPackageName(), "TD_CHANNEL_ID"));
|
||||
map.put("type", android.os.Build.MODEL);
|
||||
map.put("sdk", String.valueOf(android.os.Build.VERSION.SDK_INT));
|
||||
map.put("version", android.os.Build.VERSION.RELEASE);
|
||||
map.put("imei", ((TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE)).getDeviceId());
|
||||
JsonObjectRequest request = new JsonObjectRequest(Method.POST,
|
||||
Config.HOST + "support/suggestion", new JSONObject(map),
|
||||
new Response.Listener<JSONObject>() {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("message", et_suggest_content.getText().toString().trim());
|
||||
params.put("from", email);
|
||||
params.put("ghversion", PackageUtils.getVersion(this));
|
||||
params.put("channel", (String) PackageUtils.getMetaData(this, getPackageName(), "TD_CHANNEL_ID"));
|
||||
params.put("type", android.os.Build.MODEL);
|
||||
params.put("sdk", String.valueOf(android.os.Build.VERSION.SDK_INT));
|
||||
params.put("version", android.os.Build.VERSION.RELEASE);
|
||||
params.put("imei", ((TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE)).getDeviceId());
|
||||
|
||||
RequestBody body = RequestBody.create(MediaType.parse("application/json"),
|
||||
new JSONObject(params).toString());
|
||||
RetrofitManager.getApi().postSuggestion(body)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new JSONObjectResponse() {
|
||||
@Override
|
||||
public void onResponse(JSONObject response) {
|
||||
isShowing = false;
|
||||
@ -216,18 +221,16 @@ public class SuggestionActivity extends BaseActivity implements OnClickListener
|
||||
} else {
|
||||
toast("提交失败,请稍后尝试!");
|
||||
}
|
||||
|
||||
}
|
||||
}, new Response.ErrorListener() {
|
||||
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
public void onFailure(Throwable e) {
|
||||
isShowing = false;
|
||||
dialog.dismiss();
|
||||
|
||||
toast("提交失败,请检查网络状态");
|
||||
}
|
||||
});
|
||||
request.setShouldCache(false);
|
||||
AppController.addToRequestQueue(request);
|
||||
}
|
||||
|
||||
private boolean isEmailAddress(String email) {
|
||||
|
||||
Reference in New Issue
Block a user