|
|
@@ -4,8 +4,6 @@
|
|
|
|
|
|
package com.ntels.kneet.v3.view.mainmore;
|
|
|
|
|
|
-import com.google.gson.JsonObject;
|
|
|
-
|
|
|
import com.ntels.kneet.v3.R;
|
|
|
import com.ntels.kneet.v3.common.AppConfig;
|
|
|
import com.ntels.kneet.v3.common.Constants;
|
|
|
@@ -13,8 +11,8 @@ import com.ntels.kneet.v3.common.c_interface.OnDataSendToReslut;
|
|
|
import com.ntels.kneet.v3.common.db.DatabaseOpenHelper;
|
|
|
import com.ntels.kneet.v3.common.db.SqlManager;
|
|
|
import com.ntels.kneet.v3.common.http.HttpSend;
|
|
|
+import com.ntels.kneet.v3.common.http.IHttpRequest;
|
|
|
import com.ntels.kneet.v3.common.http.Response;
|
|
|
-import com.ntels.kneet.v3.common.http.RetrofitCallback;
|
|
|
import com.ntels.kneet.v3.common.http.RetrofitClient;
|
|
|
import com.ntels.kneet.v3.common.http.RetrofitService;
|
|
|
import com.ntels.kneet.v3.common.util.Dlog;
|
|
|
@@ -26,6 +24,7 @@ import com.ntels.kneet.v3.view.HomeStart;
|
|
|
import com.ntels.kneet.v3.view.ImageSelect;
|
|
|
import com.ntels.kneet.v3.view.dialog.CustomDialog;
|
|
|
|
|
|
+import org.json.JSONException;
|
|
|
import org.json.JSONObject;
|
|
|
|
|
|
import android.app.Activity;
|
|
|
@@ -44,16 +43,22 @@ import android.widget.Toast;
|
|
|
|
|
|
import java.io.File;
|
|
|
import java.io.IOException;
|
|
|
+import java.lang.annotation.Annotation;
|
|
|
|
|
|
+import io.reactivex.android.schedulers.AndroidSchedulers;
|
|
|
+import io.reactivex.disposables.Disposable;
|
|
|
+import io.reactivex.schedulers.Schedulers;
|
|
|
import okhttp3.MediaType;
|
|
|
import okhttp3.MultipartBody;
|
|
|
import okhttp3.RequestBody;
|
|
|
-import retrofit2.Call;
|
|
|
-import retrofit2.Callback;
|
|
|
+import okhttp3.ResponseBody;
|
|
|
+import retrofit2.Converter;
|
|
|
+import retrofit2.HttpException;
|
|
|
|
|
|
public class Setting extends CustomActionBarActivity implements View.OnClickListener,
|
|
|
- CustomDialog.OnMsgAlterToResult {
|
|
|
+ CustomDialog.OnMsgAlterToResult, IHttpRequest {
|
|
|
|
|
|
+ private static final int MSG_COM_EXCEPTION = -1;
|
|
|
private static final int MSG_COM_P_MEMBER_PROFILE_IMAGE = 1;
|
|
|
private static final int MSG_COM_P_MEMBER = 2;
|
|
|
private static final int MSG_COM_P_MEMBER_PUSH_NOTI = 3;
|
|
|
@@ -64,9 +69,6 @@ public class Setting extends CustomActionBarActivity implements View.OnClickList
|
|
|
private static final int ALRAM_RULE_ON = 3;
|
|
|
private static final int ALRAM_RULE_OFF = 4;
|
|
|
|
|
|
- /*통신 관련*/
|
|
|
- private int type = 0;
|
|
|
-
|
|
|
/*공통*/
|
|
|
private Activity mActivity;
|
|
|
private AppConfig mAppConfig;
|
|
|
@@ -133,12 +135,12 @@ public class Setting extends CustomActionBarActivity implements View.OnClickList
|
|
|
|
|
|
if (!mIsLoading) {
|
|
|
mIsLoading = true;
|
|
|
- comHandler.sendMessageDelayed(comHandler.obtainMessage(MSG_COM_P_MEMBER), 10);
|
|
|
+ request(MSG_COM_P_MEMBER, !mSwipeRefreshLayout.isRefreshing());
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
setDisp();
|
|
|
- comHandler.sendMessageDelayed(comHandler.obtainMessage(MSG_COM_P_MEMBER), 10);
|
|
|
+ request(MSG_COM_P_MEMBER, !mSwipeRefreshLayout.isRefreshing());
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -324,7 +326,7 @@ public class Setting extends CustomActionBarActivity implements View.OnClickList
|
|
|
@Override
|
|
|
public boolean handleMessage(Message msg) {
|
|
|
|
|
|
- type = msg.what;
|
|
|
+ requestType = msg.what;
|
|
|
switch (msg.what) {
|
|
|
case MSG_COM_P_MEMBER:
|
|
|
requestAutoLogin();
|
|
|
@@ -414,364 +416,164 @@ public class Setting extends CustomActionBarActivity implements View.OnClickList
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 멤버 이미지 변경(멤버의 프로필 이미지를 수정) 요청.
|
|
|
- */
|
|
|
- @SuppressWarnings("unchecked")
|
|
|
- private void requestProfileImage() {
|
|
|
- File profileImage = new File(mFileName);
|
|
|
- RequestBody requestFile = RequestBody.create(MediaType.parse("image/*"), profileImage);
|
|
|
- MultipartBody.Part part = MultipartBody.Part.createFormData(Constants.HTTP_image_file, profileImage.getName(), requestFile);
|
|
|
- Call<JsonObject> profileImageCall = RetrofitService.getUserService().profileImage(part);
|
|
|
- profileImageCall.enqueue(new RetrofitCallback(mActivity, new Callback<JsonObject>() {
|
|
|
- @Override
|
|
|
- public void onResponse(Call<JsonObject> call, retrofit2.Response<JsonObject> response) {
|
|
|
- if (null != response) {
|
|
|
- JsonObject jsonResponse = response.body();
|
|
|
- if (response.isSuccessful()) {
|
|
|
- mFileName = mUtil.null2string(jsonResponse.get(Constants.HTTP_image_file_name));
|
|
|
- mUtil.setRefreshImage(mActivity, mFileName, R.id.ivMemberIcon);
|
|
|
- } else {
|
|
|
- BaseResponse errorResponse = null;
|
|
|
- try {
|
|
|
- errorResponse = (BaseResponse) RetrofitClient.getClient().responseBodyConverter(BaseResponse.class,
|
|
|
- BaseResponse.class.getAnnotations()).convert(response.errorBody());
|
|
|
-
|
|
|
- if ("401".equals(errorResponse.getErrCode())) {
|
|
|
- mCustomDialog.msgAlert(mActivity, Constants.MSG998, errorResponse.getErrMsg());
|
|
|
- } else if ("401-106".equals(errorResponse.getErrCode())) {
|
|
|
- mCustomDialog.msgAlert(mActivity, Constants.MSG997, errorResponse.getErrMsg());
|
|
|
- } else {
|
|
|
- mCustomDialog.msgAlert(mActivity, Constants.MSG000, errorResponse.getErrMsg());
|
|
|
- }
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
- mCustomDialog.msgAlert(mActivity, Constants.MSG807);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- } else {
|
|
|
- mCustomDialog.msgAlert(mActivity, Constants.MSG807);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onFailure(Call<JsonObject> call, Throwable t) {
|
|
|
- t.printStackTrace();
|
|
|
- mCustomDialog.msgAlert(mActivity, Constants.MSG807);
|
|
|
- }
|
|
|
- }));
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 멤버 이미지 변경(멤버의 프로필 이미지를 수정) 요청.
|
|
|
- */
|
|
|
- private void sendPostMemberProfileImage() {
|
|
|
-
|
|
|
- try {
|
|
|
- HttpSend httpSend = new HttpSend(mActivity);
|
|
|
- httpSend.setOnDataSendToReslutEvent(new OnDataSendToReslut() {
|
|
|
- @Override
|
|
|
- public void resultResponse(Response result) {
|
|
|
-
|
|
|
- resultPostMemberProfileImage(result);
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- //공통 변수 입력
|
|
|
- httpSend.P_member_profile_image(Constants.HTTP_image_file, mFileName);
|
|
|
- } catch (Exception ex) {
|
|
|
- ex.printStackTrace();
|
|
|
+ @Override
|
|
|
+ public void request(int requestType, boolean isLoading) {
|
|
|
+ this.requestType = requestType;
|
|
|
+ isShowLoading = isLoading;
|
|
|
+ if (isLoading) {
|
|
|
+ showProgress();
|
|
|
+ }
|
|
|
+ switch (requestType) {
|
|
|
+ case MSG_COM_P_MEMBER_PROFILE_IMAGE:
|
|
|
+ compositeDisposable.add(requestProfileImage());
|
|
|
+ break;
|
|
|
+ case MSG_COM_P_MEMBER:
|
|
|
+ compositeDisposable.add(requestAutoLogin());
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * {@link #sendPostMemberProfileImage()} 요청 결과.
|
|
|
- *
|
|
|
- * @param response 결과 data
|
|
|
- */
|
|
|
- private void resultPostMemberProfileImage(Response response) {
|
|
|
-
|
|
|
- try {
|
|
|
- if (response.getStatusCode() == 200) {
|
|
|
- JSONObject joResult = new JSONObject(response.getContent());
|
|
|
- Dlog.v(joResult.toString());
|
|
|
-
|
|
|
- //회원 번호
|
|
|
- mFileName = mUtil.null2string(joResult.get(Constants.HTTP_image_file_name));
|
|
|
-// mUtil.setRefreshImage(mActivity, mFileName, R.id.ivMemberIcon);
|
|
|
- mUtil.setRefreshImage(mActivity, mFileName, mUtil.getImageView(mActivity, R.id.ivMemberIcon));
|
|
|
- } else {
|
|
|
- JSONObject joResult = new JSONObject(response.getContent());
|
|
|
- Dlog.v(joResult.toString());
|
|
|
- String errorCode = mUtil.null2string(joResult.get(Constants.HTTP_err_code));
|
|
|
- String errorMsg = mUtil.null2string(joResult.get(Constants.HTTP_err_msg));
|
|
|
-
|
|
|
- if (errorCode.equals("401")) {
|
|
|
- mCustomDialog.msgAlert(mActivity, Constants.MSG998, errorMsg);
|
|
|
- } else if (errorCode.equals("401-106")) {
|
|
|
- mCustomDialog.msgAlert(mActivity, Constants.MSG997, errorMsg);
|
|
|
- } else {
|
|
|
- mCustomDialog.msgAlert(mActivity, Constants.MSG000, errorMsg);
|
|
|
+ @Override
|
|
|
+ public void onResponse(int requestType, Object response) {
|
|
|
+ dismissProgress();
|
|
|
+ switch (requestType) {
|
|
|
+ case MSG_COM_P_MEMBER_PROFILE_IMAGE:
|
|
|
+ if (response instanceof JSONObject) {
|
|
|
+ JSONObject jsonResponse = (JSONObject) response;
|
|
|
+ try {
|
|
|
+ mFileName = mUtil.null2string(jsonResponse.get(Constants.HTTP_image_file_name));
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ mUtil.setRefreshImage(mActivity, mFileName, R.id.ivMemberIcon);
|
|
|
}
|
|
|
- }
|
|
|
- } catch (Exception ex) {
|
|
|
- ex.printStackTrace();
|
|
|
- mCustomDialog.msgAlert(mActivity, Constants.MSG807);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * <pre>
|
|
|
- * 멤버 자동 로그인 요청.
|
|
|
- * (인증 토큰을 기준으로 회원의 로그인 정보를 조회하고 푸시 토큰을 등록/수정한다)
|
|
|
- * </pre>
|
|
|
- */
|
|
|
- @SuppressWarnings("unchecked")
|
|
|
- private void requestAutoLogin() {
|
|
|
- Call<Login> autoLoginCall = RetrofitService.getUserService().autoLogin(Constants.OS_TYPE,
|
|
|
- mAppConfig.getUuid(), mAppConfig.getPush_Token(), mUtil.getHostName());
|
|
|
- autoLoginCall.enqueue(new RetrofitCallback(this, new Callback<Login>() {
|
|
|
-
|
|
|
- /**
|
|
|
- * Invoked for a received HTTP response.
|
|
|
- * <p>
|
|
|
- * Note: An HTTP response may still indicate an application-level failure such as a 404 or 500.
|
|
|
- * Call {@link Response#isSuccessful()} to determine if the response indicates success.
|
|
|
- */
|
|
|
- @Override
|
|
|
- public void onResponse(Call<com.ntels.kneet.v3.model.user.Login> call, retrofit2.Response<com.ntels.kneet.v3.model.user
|
|
|
- .Login> response) {
|
|
|
- if (null != response) {
|
|
|
- processLogin(response);
|
|
|
+ break;
|
|
|
+ case MSG_COM_P_MEMBER:
|
|
|
+ if (response instanceof Login) {
|
|
|
+ processLogin((Login) response);
|
|
|
mIsLoading = false;
|
|
|
mSwipeRefreshLayout.setRefreshing(false);
|
|
|
setDisp();
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onError(int requestType, Object error) {
|
|
|
+ dismissProgress();
|
|
|
+ switch (requestType) {
|
|
|
+ case MSG_COM_P_MEMBER_PROFILE_IMAGE:
|
|
|
+ case MSG_COM_P_MEMBER:
|
|
|
+ ResponseBody body = ((HttpException) error).response().errorBody();
|
|
|
+ Converter<ResponseBody, BaseResponse> errorConverter =
|
|
|
+ RetrofitClient.getClient().responseBodyConverter(BaseResponse.class, new Annotation[0]);
|
|
|
+ BaseResponse errorResponse = null;
|
|
|
+ try {
|
|
|
+ errorResponse = errorConverter.convert(body);
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
mCustomDialog.msgAlert(mActivity, Constants.MSG807);
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- /**
|
|
|
- * Invoked when a network exception occurred talking to the server or when an unexpected
|
|
|
- * exception occurred creating the request or processing the response.
|
|
|
- */
|
|
|
- @Override
|
|
|
- public void onFailure(Call<com.ntels.kneet.v3.model.user.Login> call, Throwable t) {
|
|
|
- t.printStackTrace();
|
|
|
+ if ("401".equals(errorResponse.getErrCode())) {
|
|
|
+ mCustomDialog.msgAlert(mActivity, Constants.MSG998, errorResponse.getErrMsg());
|
|
|
+ } else if ("401-106".equals(errorResponse.getErrCode())) {
|
|
|
+ mCustomDialog.msgAlert(mActivity, Constants.MSG997, errorResponse.getErrMsg());
|
|
|
+ } else {
|
|
|
+ mCustomDialog.msgAlert(mActivity, Constants.MSG000, errorResponse.getErrMsg());
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case MSG_COM_EXCEPTION:
|
|
|
mCustomDialog.msgAlert(mActivity, Constants.MSG807);
|
|
|
- }
|
|
|
- }, !mSwipeRefreshLayout.isRefreshing()));
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ mCustomDialog.msgAlert(mActivity, Constants.MSG807);
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
- * <pre>
|
|
|
- * 로그인 요청 결과 처리.
|
|
|
- * @param response 요청 결과 데이터
|
|
|
- * </pre>
|
|
|
+ * 멤버 이미지 변경(멤버의 프로필 이미지를 수정) 요청.
|
|
|
*/
|
|
|
- private void processLogin(retrofit2.Response<com.ntels.kneet.v3.model.user.Login> response) {
|
|
|
-
|
|
|
- com.ntels.kneet.v3.model.user.Login login = null;
|
|
|
-
|
|
|
- if (response.isSuccessful()) {
|
|
|
- login = response.body();
|
|
|
- //회원이미지 추가
|
|
|
- mAppConfig.setMy_Image_Url(login.getImageFileName());
|
|
|
- //회원명
|
|
|
- mAppConfig.setNickname(login.getNickname());
|
|
|
- // 임시비밀번호 로그인 여부
|
|
|
- mAppConfig.setTemp_Password_Yn(login.getTempPasswordYn());
|
|
|
- mAppConfig.setInvitations_Count(mUtil.null2string(login.getInvitationsCount()));
|
|
|
- mAppConfig.setSelect_Homegrp_Id(mUtil.null2string(login.getHomegrpId()));
|
|
|
- mAppConfig.setSelect_Homegrp_Icon(login.getHomegrpImageFileName());
|
|
|
- mAppConfig.setSelect_Homegrp_Name(login.getHomegrpName());
|
|
|
- mAppConfig.setSelect_Homegrp_Grade_Code(login.getGradeCode());
|
|
|
- mAppConfig.setSelect_Homegrp_Homehub_Device_Id(login.getHomehubDeviceId());
|
|
|
- mAppConfig.setsSelect_Homegrp_Homehub_Device_Key(login.getHomehubDeviceKey());
|
|
|
- mAppConfig.setsSelect_Homegrp_Homehub_Conn_State(login.getDeviceConn());
|
|
|
- mAppConfig.setsSelect_Homegrp_Homehub_Dongle_State(login.getDeviceOnline());
|
|
|
- mAppConfig.setsSelect_Servicehub_App_Id(login.getServicehubApplicationId());
|
|
|
- mAppConfig.setsSelect_Homegrp_Homehub_Dongle_Online_Last_Datetime(login.getDeviceOnlineLastDatetime());
|
|
|
- //회원 번호
|
|
|
- mAppConfig.setLogin_Member_Id(mUtil.null2string(login.getMemberId()));
|
|
|
- //이메일 ID
|
|
|
- mAppConfig.setLogin_Id(mUtil.null2string(login.getEmailId()));
|
|
|
- mAppConfig.setLogin_Pass("");
|
|
|
- mAppConfig.setAutoLogin(mIsAutoLogin);
|
|
|
- mAppConfig.setLogin(true);
|
|
|
-
|
|
|
- //인증 토큰
|
|
|
- mAppConfig.setAuth_Token(login.getAuthToken());
|
|
|
-
|
|
|
- //db 입력작업
|
|
|
- SQLiteDatabase db = DatabaseOpenHelper.getInstance(mActivity).getWritableDatabase();
|
|
|
- String sql = "";
|
|
|
- sql = mSqlManager.qryDelLoginInfo();
|
|
|
- db.execSQL(sql);
|
|
|
-
|
|
|
- sql = "";
|
|
|
- Dlog.v("mIsAutoLogin =" + mIsAutoLogin);
|
|
|
- Boolean isSaveId = false;
|
|
|
- sql = mSqlManager.qryInsertLoginInfo(login.getEmailId(), login.getAuthToken(), isSaveId, mIsAutoLogin,
|
|
|
- mAppConfig.getManualNotView(), mAppConfig.getPush());
|
|
|
- db.execSQL(sql);
|
|
|
- db.close();
|
|
|
-
|
|
|
- mAppConfig.setPush_Type_Mode_Chg_Yn(login.getPushTypeModeChgYn());
|
|
|
- mAppConfig.setPush_Type_Prsnc_Chg_Yn(login.getPushTypePrsncChgYn());
|
|
|
+ private Disposable requestProfileImage() {
|
|
|
+ File profileImage = new File(mFileName);
|
|
|
+ RequestBody requestFile = RequestBody.create(MediaType.parse("image/*"), profileImage);
|
|
|
+ MultipartBody.Part part = MultipartBody.Part.createFormData(Constants.HTTP_image_file, profileImage.getName(), requestFile);
|
|
|
|
|
|
- } else {
|
|
|
- try {
|
|
|
- login = (com.ntels.kneet.v3.model.user.Login) RetrofitClient.getClient()
|
|
|
- .responseBodyConverter(com.ntels.kneet.v3.model.user.Login.class,
|
|
|
- com.ntels.kneet.v3.model.user.Login.class.getAnnotations())
|
|
|
- .convert(response.errorBody());
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
- mCustomDialog.msgAlert(mActivity, Constants.MSG807);
|
|
|
- }
|
|
|
- if ("401".equals(login.getErrCode())) {
|
|
|
- mCustomDialog.msgAlert(mActivity, Constants.MSG998, login.getErrMsg());
|
|
|
- } else if ("401-106".equals(login.getErrCode())) {
|
|
|
- mCustomDialog.msgAlert(mActivity, Constants.MSG997, login.getErrMsg());
|
|
|
- } else {
|
|
|
- mCustomDialog.msgAlert(mActivity, Constants.MSG000, login.getErrMsg());
|
|
|
- }
|
|
|
- }
|
|
|
+ return RetrofitService.getUserService().profileImage(part)
|
|
|
+ .subscribeOn(Schedulers.io())
|
|
|
+ .observeOn(AndroidSchedulers.mainThread())
|
|
|
+ .subscribe(jsonObject -> onResponse(MSG_COM_P_MEMBER_PROFILE_IMAGE, jsonObject),
|
|
|
+ e -> {
|
|
|
+ if (e instanceof HttpException) {
|
|
|
+ onError(MSG_COM_P_MEMBER_PROFILE_IMAGE, e);
|
|
|
+ } else {
|
|
|
+ onError(MSG_COM_EXCEPTION, e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* <pre>
|
|
|
- * 회원 로그인 정보 조회 및 푸시 토큰 등록/수정 요청.
|
|
|
+ * 멤버 자동 로그인 요청.
|
|
|
* (인증 토큰을 기준으로 회원의 로그인 정보를 조회하고 푸시 토큰을 등록/수정한다)
|
|
|
* </pre>
|
|
|
*/
|
|
|
- /*private void sendPutMember() {
|
|
|
-
|
|
|
- try {
|
|
|
- HttpSend httpSend = new HttpSend(mActivity, !mSwipeRefreshLayout.isRefreshing());
|
|
|
- httpSend.setOnDataSendToReslutEvent(new OnDataSendToReslut() {
|
|
|
- @Override
|
|
|
- public void resultResponse(Response result) {
|
|
|
-
|
|
|
- resultPutMember(result);
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- //공통 변수 입력
|
|
|
- httpSend.P_member(mAppConfig.getUuid(), mAppConfig.getPush_Token(),
|
|
|
- Constants.OS_TYPE, mUtil.getHostName());
|
|
|
- } catch (Exception ex) {
|
|
|
- ex.printStackTrace();
|
|
|
+ private Disposable requestAutoLogin() {
|
|
|
+
|
|
|
+ return RetrofitService.getUserService().autoLogin(Constants.OS_TYPE, mAppConfig.getUuid(), mAppConfig.getPush_Token(),
|
|
|
+ mUtil.getHostName())
|
|
|
+ .subscribeOn(Schedulers.io())
|
|
|
+ .observeOn(AndroidSchedulers.mainThread())
|
|
|
+ .subscribe(login -> onResponse(MSG_COM_P_MEMBER, login),
|
|
|
+ e -> {
|
|
|
+ if (e instanceof HttpException) {
|
|
|
+ onError(MSG_COM_P_MEMBER, e);
|
|
|
+ } else {
|
|
|
+ onError(MSG_COM_EXCEPTION, e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ );
|
|
|
}
|
|
|
- }*/
|
|
|
|
|
|
/**
|
|
|
- * {@link #sendPutMember()} 요청 결과.
|
|
|
- *
|
|
|
- * @param response 결과 data
|
|
|
+ * <pre>
|
|
|
+ * 로그인 데이터 처리.
|
|
|
+ * @param login 로그인 데이터 {@link Login}
|
|
|
+ * </pre>
|
|
|
*/
|
|
|
- /*private void resultPutMember(Response response) {
|
|
|
-
|
|
|
- try {
|
|
|
- if (response.getStatusCode() == 200) {
|
|
|
-
|
|
|
- JSONObject joResult = new JSONObject(response.getContent());
|
|
|
- Dlog.v(joResult.toString());
|
|
|
+ private void processLogin(Login login) {
|
|
|
|
|
|
//회원이미지 추가
|
|
|
- String imageFileName = "";
|
|
|
- if (joResult.has(Constants.HTTP_image_file_name)) {
|
|
|
- imageFileName = mUtil.null2string(joResult.get(Constants.HTTP_image_file_name));
|
|
|
- mAppConfig.setMy_Image_Url(imageFileName);
|
|
|
- }
|
|
|
+ mAppConfig.setMy_Image_Url(login.getImageFileName());
|
|
|
//회원명
|
|
|
- String nickname = "";
|
|
|
- if (joResult.has(Constants.HTTP_nickname)) {
|
|
|
- nickname = mUtil.null2string(joResult.get(Constants.HTTP_nickname));
|
|
|
- mAppConfig.setNickname(nickname);
|
|
|
- }
|
|
|
-
|
|
|
- mNewEmailId = "";
|
|
|
- if (joResult.has(Constants.HTTP_new_email_id)) {
|
|
|
- mNewEmailId = mUtil.null2string(joResult.get(Constants.HTTP_new_email_id));
|
|
|
- }
|
|
|
-
|
|
|
- String tempPasswordYn = "";
|
|
|
- if (joResult.has(Constants.HTTP_temp_password_yn)) {
|
|
|
- tempPasswordYn = mUtil.null2string(joResult.get(Constants.HTTP_temp_password_yn));
|
|
|
- }
|
|
|
- mAppConfig.setTemp_Password_Yn(tempPasswordYn);
|
|
|
-
|
|
|
- String invitationsCount = "";
|
|
|
- if (joResult.has(Constants.HTTP_invitations_count)) {
|
|
|
- invitationsCount = mUtil.null2string(joResult.get(Constants.HTTP_invitations_count));
|
|
|
- }
|
|
|
-
|
|
|
- String homegrpId = "";
|
|
|
- if (joResult.has(Constants.HTTP_homegrp_id)) {
|
|
|
- homegrpId = mUtil.null2string(joResult.get(Constants.HTTP_homegrp_id));
|
|
|
- }
|
|
|
-
|
|
|
- String homegrpImageFileName = "";
|
|
|
- if (joResult.has(Constants.HTTP_homegrp_image_file_name)) {
|
|
|
- homegrpImageFileName = mUtil.null2string(
|
|
|
- joResult.get(Constants.HTTP_homegrp_image_file_name));
|
|
|
- }
|
|
|
-
|
|
|
- String homegrpName = "";
|
|
|
- if (joResult.has(Constants.HTTP_homegrp_name)) {
|
|
|
- homegrpName = mUtil.null2string(joResult.get(Constants.HTTP_homegrp_name));
|
|
|
- }
|
|
|
-
|
|
|
- String gradeCode = "";
|
|
|
- if (joResult.has(Constants.HTTP_grade_code)) {
|
|
|
- gradeCode = mUtil.null2string(joResult.get(Constants.HTTP_grade_code));
|
|
|
- }
|
|
|
-
|
|
|
- String homehubDeviceId = "";
|
|
|
- if (joResult.has(Constants.HTTP_homehub_device_id)) {
|
|
|
- homehubDeviceId = mUtil.null2string(joResult.get(Constants.HTTP_homehub_device_id));
|
|
|
- }
|
|
|
-
|
|
|
- String homehubConnState = "";
|
|
|
- if (joResult.has(Constants.HTTP_device_conn)) {
|
|
|
- homehubConnState = mUtil.null2string(joResult.get(Constants.HTTP_device_conn));
|
|
|
- }
|
|
|
-
|
|
|
- String homehubDongleState = "";
|
|
|
- if (joResult.has(Constants.HTTP_device_online)) {
|
|
|
- homehubDongleState = mUtil.null2string(joResult.get(Constants.HTTP_device_online));
|
|
|
- }
|
|
|
-
|
|
|
- String servicehubApplicationId = "";
|
|
|
- if (joResult.has(Constants.HTTP_servicehub_app_id)) {
|
|
|
- servicehubApplicationId = mUtil.null2string(
|
|
|
- joResult.get(Constants.HTTP_servicehub_app_id));
|
|
|
- }
|
|
|
-
|
|
|
- String deviceOnlineLastDatetime = "";
|
|
|
- if (joResult.has(Constants.HTTP_device_online_last_datetime)) {
|
|
|
- deviceOnlineLastDatetime = mUtil.null2string(
|
|
|
- joResult.get(Constants.HTTP_device_online_last_datetime));
|
|
|
- }
|
|
|
-
|
|
|
+ mAppConfig.setNickname(login.getNickname());
|
|
|
+ // 임시비밀번호 로그인 여부
|
|
|
+ mAppConfig.setTemp_Password_Yn(login.getTempPasswordYn());
|
|
|
+ mAppConfig.setInvitations_Count(mUtil.null2string(login.getInvitationsCount()));
|
|
|
+ mAppConfig.setSelect_Homegrp_Id(mUtil.null2string(login.getHomegrpId()));
|
|
|
+ mAppConfig.setSelect_Homegrp_Icon(login.getHomegrpImageFileName());
|
|
|
+ mAppConfig.setSelect_Homegrp_Name(login.getHomegrpName());
|
|
|
+ mAppConfig.setSelect_Homegrp_Grade_Code(login.getGradeCode());
|
|
|
+ mAppConfig.setSelect_Homegrp_Homehub_Device_Id(login.getHomehubDeviceId());
|
|
|
+ mAppConfig.setsSelect_Homegrp_Homehub_Device_Key(login.getHomehubDeviceKey());
|
|
|
+ mAppConfig.setsSelect_Homegrp_Homehub_Conn_State(login.getDeviceConn());
|
|
|
+ mAppConfig.setsSelect_Homegrp_Homehub_Dongle_State(login.getDeviceOnline());
|
|
|
+ mAppConfig.setsSelect_Servicehub_App_Id(login.getServicehubApplicationId());
|
|
|
+ mAppConfig.setsSelect_Homegrp_Homehub_Dongle_Online_Last_Datetime(login.getDeviceOnlineLastDatetime());
|
|
|
//회원 번호
|
|
|
- String memberId = mUtil.null2string(joResult.get(Constants.HTTP_member_id));
|
|
|
- mAppConfig.setLogin_Member_Id(memberId);
|
|
|
+ mAppConfig.setLogin_Member_Id(mUtil.null2string(login.getMemberId()));
|
|
|
//이메일 ID
|
|
|
- String emailId = mUtil.null2string(joResult.get(Constants.HTTP_email_id));
|
|
|
- mAppConfig.setLogin_Id(emailId);
|
|
|
+ mAppConfig.setLogin_Id(mUtil.null2string(login.getEmailId()));
|
|
|
mAppConfig.setLogin_Pass("");
|
|
|
- Dlog.v("mIsAutoLogin =" + mIsAutoLogin);
|
|
|
mAppConfig.setAutoLogin(mIsAutoLogin);
|
|
|
mAppConfig.setLogin(true);
|
|
|
|
|
|
//인증 토큰
|
|
|
- String authToken = mUtil.null2string(joResult.get(Constants.HTTP_auth_token));
|
|
|
- //공통 변수 입력
|
|
|
- mAppConfig.setAuth_Token(authToken);
|
|
|
+ mAppConfig.setAuth_Token(login.getAuthToken());
|
|
|
|
|
|
//db 입력작업
|
|
|
SQLiteDatabase db = DatabaseOpenHelper.getInstance(mActivity).getWritableDatabase();
|
|
|
@@ -779,51 +581,18 @@ public class Setting extends CustomActionBarActivity implements View.OnClickList
|
|
|
sql = mSqlManager.qryDelLoginInfo();
|
|
|
db.execSQL(sql);
|
|
|
|
|
|
+ sql = "";
|
|
|
Dlog.v("mIsAutoLogin =" + mIsAutoLogin);
|
|
|
- sql = mSqlManager.qryInsertLoginInfo(emailId, authToken, mIsSaveId, mIsAutoLogin,
|
|
|
- mAppConfig.getManualNotView(), mAppConfig.getPush());
|
|
|
+ Boolean isSaveId = false;
|
|
|
+ sql = mSqlManager.qryInsertLoginInfo(login.getEmailId(), login.getAuthToken(), isSaveId, mIsAutoLogin,
|
|
|
+ mAppConfig.getManualNotView(), mAppConfig.getPush());
|
|
|
db.execSQL(sql);
|
|
|
db.close();
|
|
|
|
|
|
- String pushTypeModeChgYn = mUtil.null2string(
|
|
|
- joResult.get(Constants.HTTP_push_type_mode_chg_yn));
|
|
|
- mAppConfig.setPush_Type_Mode_Chg_Yn(pushTypeModeChgYn);
|
|
|
- String pushTypePrsncChgYn = mUtil.null2string(
|
|
|
- joResult.get(Constants.HTTP_push_type_prsnc_chg_yn));
|
|
|
- mAppConfig.setPush_Type_Prsnc_Chg_Yn(pushTypePrsncChgYn);
|
|
|
- mAppConfig.setInvitations_Count(invitationsCount);
|
|
|
- mAppConfig.setSelect_Homegrp_Id(homegrpId);
|
|
|
- mAppConfig.setSelect_Homegrp_Icon(homegrpImageFileName);
|
|
|
- mAppConfig.setSelect_Homegrp_Name(homegrpName);
|
|
|
- mAppConfig.setSelect_Homegrp_Grade_Code(gradeCode);
|
|
|
- mAppConfig.setSelect_Homegrp_Homehub_Device_Id(homehubDeviceId);
|
|
|
- mAppConfig.setsSelect_Homegrp_Homehub_Conn_State(homehubConnState);
|
|
|
- mAppConfig.setsSelect_Homegrp_Homehub_Dongle_State(homehubDongleState);
|
|
|
- mAppConfig.setsSelect_Servicehub_App_Id(servicehubApplicationId);
|
|
|
- mAppConfig.setsSelect_Homegrp_Homehub_Dongle_Online_Last_Datetime(deviceOnlineLastDatetime);
|
|
|
-
|
|
|
- mIsLoading = false;
|
|
|
- mSwipeRefreshLayout.setRefreshing(false);
|
|
|
- setDisp();
|
|
|
- } else {
|
|
|
- JSONObject joResult = new JSONObject(response.getContent());
|
|
|
- Dlog.v(joResult.toString());
|
|
|
- String errorCode = mUtil.null2string(joResult.get(Constants.HTTP_err_code));
|
|
|
- String errorMsg = mUtil.null2string(joResult.get(Constants.HTTP_err_msg));
|
|
|
-
|
|
|
- if (errorCode.equals("401")) {
|
|
|
- mCustomDialog.msgAlert(mActivity, Constants.MSG998, errorMsg);
|
|
|
- } else if (errorCode.equals("401-106")) {
|
|
|
- mCustomDialog.msgAlert(mActivity, Constants.MSG997, errorMsg);
|
|
|
- } else {
|
|
|
- mCustomDialog.msgAlert(mActivity, Constants.MSG000, errorMsg);
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (Exception ex) {
|
|
|
- ex.printStackTrace();
|
|
|
- mCustomDialog.msgAlert(mActivity, Constants.MSG807);
|
|
|
+ mAppConfig.setPush_Type_Mode_Chg_Yn(login.getPushTypeModeChgYn());
|
|
|
+ mAppConfig.setPush_Type_Prsnc_Chg_Yn(login.getPushTypePrsncChgYn());
|
|
|
}
|
|
|
- }*/
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 계정을 삭제해 회원 탈퇴를 처리한다.
|
|
|
@@ -906,7 +675,7 @@ public class Setting extends CustomActionBarActivity implements View.OnClickList
|
|
|
break;
|
|
|
case Constants.MSG807:
|
|
|
if (btnResult == 1) {
|
|
|
- comHandler.sendMessageDelayed(comHandler.obtainMessage(type), 10);
|
|
|
+ request(requestType, isShowLoading);
|
|
|
}
|
|
|
break;
|
|
|
case Constants.MSG910:
|
|
|
@@ -939,12 +708,11 @@ public class Setting extends CustomActionBarActivity implements View.OnClickList
|
|
|
case Constants.ACT_SETTING_PASSWORD_CHK:
|
|
|
case Constants.ACT_SETTING_NAME_CHANGE:
|
|
|
case Constants.ACT_SETTING_EMAIL_CHANGE:
|
|
|
- comHandler.sendMessageDelayed(comHandler.obtainMessage(MSG_COM_P_MEMBER), 10);
|
|
|
+ request(MSG_COM_P_MEMBER, !mSwipeRefreshLayout.isRefreshing());
|
|
|
break;
|
|
|
case Constants.ACT_IMAGE_SELECT:
|
|
|
mFileName = mUtil.null2string(data.getStringExtra(Constants.EXTRA_IMAGE_FILE_NAME));
|
|
|
- comHandler.sendMessageDelayed(comHandler.obtainMessage(
|
|
|
- MSG_COM_P_MEMBER_PROFILE_IMAGE), 10);
|
|
|
+ request(MSG_COM_P_MEMBER_PROFILE_IMAGE, true);
|
|
|
break;
|
|
|
default:
|
|
|
break;
|