Przeglądaj źródła

1. rxjava2 + retrofit 적용 중.

aaron 8 lat temu
rodzic
commit
ef0ead8120
22 zmienionych plików z 1322 dodań i 1282 usunięć
  1. 5 0
      build.gradle
  2. 12 2
      kneet_v3/build.gradle
  3. 43 0
      kneet_v3/src/main/java/com/ntels/kneet/v3/common/http/IHttpRequest.java
  4. 5 1
      kneet_v3/src/main/java/com/ntels/kneet/v3/common/http/RetrofitClient.java
  5. 3 2
      kneet_v3/src/main/java/com/ntels/kneet/v3/common/http/service/ThingsService.java
  6. 8 9
      kneet_v3/src/main/java/com/ntels/kneet/v3/common/http/service/UserService.java
  7. 0 3
      kneet_v3/src/main/java/com/ntels/kneet/v3/common/util/Util.java
  8. 12 3
      kneet_v3/src/main/java/com/ntels/kneet/v3/common/widget/CustomActionBarActivity.java
  9. 12 4
      kneet_v3/src/main/java/com/ntels/kneet/v3/common/widget/CustomActivity.java
  10. 197 198
      kneet_v3/src/main/java/com/ntels/kneet/v3/view/Login.java
  11. 168 146
      kneet_v3/src/main/java/com/ntels/kneet/v3/view/LoginNewDevice.java
  12. 1 1
      kneet_v3/src/main/java/com/ntels/kneet/v3/view/dialog/PushDialog.java
  13. 145 377
      kneet_v3/src/main/java/com/ntels/kneet/v3/view/mainmore/Setting.java
  14. 96 67
      kneet_v3/src/main/java/com/ntels/kneet/v3/view/mainmore/SettingEmailChange.java
  15. 190 164
      kneet_v3/src/main/java/com/ntels/kneet/v3/view/mainmore/SettingNameChange.java
  16. 96 65
      kneet_v3/src/main/java/com/ntels/kneet/v3/view/mainmore/SettingPasswordChange.java
  17. 94 124
      kneet_v3/src/main/java/com/ntels/kneet/v3/view/mainmore/SettingPasswordCheck.java
  18. 1 1
      kneet_v3/src/main/java/com/ntels/kneet/v3/view/rules/FragmentRules.java
  19. 1 1
      kneet_v3/src/main/java/com/ntels/kneet/v3/view/rules/RulesThingsSelect.java
  20. 110 49
      kneet_v3/src/main/java/com/ntels/kneet/v3/view/things/FragmentThings.java
  21. 122 64
      kneet_v3/src/main/java/com/ntels/kneet/v3/view/things/ThingsDetail.java
  22. 1 1
      kneet_v3/src/main/java/com/ntels/kneet/v3/view/things/ThingsNameChange.java

+ 5 - 0
build.gradle

@@ -5,6 +5,7 @@ buildscript {
     }
     dependencies {
         classpath 'com.android.tools.build:gradle:2.2.3'
+        classpath 'me.tatarka:gradle-retrolambda:3.7.0'
     }
 }
 
@@ -13,3 +14,7 @@ allprojects {
         jcenter()
     }
 }
+
+task clean(type: Delete) {
+    delete rootProject.buildDir
+}

+ 12 - 2
kneet_v3/build.gradle

@@ -3,6 +3,7 @@
  */
 
 apply plugin: 'com.android.application'
+apply plugin: 'me.tatarka.retrolambda'
 
 android {
     compileSdkVersion 23
@@ -27,9 +28,9 @@ android {
         }
     }*/
 
-    task clean(type: Delete) {
+    /*task clean(type: Delete) {
         delete "$rootProject/kneet_v3/build/intermediates/exploded-aar"
-    }
+    }*/
 
     dexOptions {
         //preDexLibraries = false
@@ -62,6 +63,11 @@ android {
         }
     }
 
+    compileOptions {
+        sourceCompatibility JavaVersion.VERSION_1_8
+        targetCompatibility JavaVersion.VERSION_1_8
+    }
+
     buildTypes {
         debug {
             debuggable true
@@ -90,6 +96,7 @@ android {
         exclude 'META-INF/NOTICE.txt'
         exclude 'META-INF/notice.txt'
         exclude 'META-INF/ASL2.0'
+        exclude 'META-INF/rxjava.properties'
     }
 }
 
@@ -111,9 +118,12 @@ dependencies {
     compile 'com.mcxiaoke.volley:library:1.0.+'
     compile 'com.squareup.retrofit2:retrofit:2.3.0'
     compile 'com.squareup.retrofit2:converter-gson:2.3.0'
+    compile 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
     compile 'com.squareup.okhttp3:okhttp:3.8.1'
     compile 'com.squareup.okhttp3:okhttp-urlconnection:3.8.1'
     compile 'com.squareup.okhttp3:logging-interceptor:3.8.1'
     compile 'com.google.code.gson:gson:2.8.1'
+    compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
+    compile 'io.reactivex.rxjava2:rxjava:2.1.3'
     compile project(':color_picker')
 }

+ 43 - 0
kneet_v3/src/main/java/com/ntels/kneet/v3/common/http/IHttpRequest.java

@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2017. nTels.co.,ltd. to Present.
+ * All rights reserved.
+ */
+
+package com.ntels.kneet.v3.common.http;
+
+/**
+ * <pre>
+ * 1. ClassName :   IHttpRequest
+ * 2. FileName  :   IHttpRequest.java
+ * 3. Package   :   com.ntels.kneet.v3.common.http
+ * 4. Date      :   2017-09-12
+ * 5. Author    :   aaron
+ * 6. Comment   :   Initialize
+ * </pre>
+ */
+
+public interface IHttpRequest {
+    /**
+     * Http request.
+     *
+     * @param requestType Request API type
+     * @param isLoading If true dialog is show
+     */
+    void request(int requestType, boolean isLoading);
+
+    /**
+     * Http request response.
+     *
+     * @param requestType Request API type
+     * @param response response data
+     */
+    void onResponse(int requestType, Object response);
+
+    /**
+     * Http request error.
+     *
+     * @param requestType request API type
+     * @param error error data(ex> error code, error message)
+     */
+    void onError(int requestType, Object error);
+}

+ 5 - 1
kneet_v3/src/main/java/com/ntels/kneet/v3/common/http/RetrofitClient.java

@@ -18,10 +18,13 @@ import javax.net.ssl.SSLSession;
 import javax.net.ssl.TrustManager;
 import javax.net.ssl.X509TrustManager;
 
-import okhttp3.*;
+import okhttp3.Interceptor;
+import okhttp3.OkHttpClient;
+import okhttp3.Request;
 import okhttp3.Response;
 import okhttp3.logging.HttpLoggingInterceptor;
 import retrofit2.Retrofit;
+import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
 import retrofit2.converter.gson.GsonConverterFactory;
 
 /**
@@ -88,6 +91,7 @@ public class RetrofitClient {
             // Retrofit 설정.
             mInterface = new Retrofit.Builder().baseUrl(BASE_URL)
                     .client(mClient)
+                    .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                     .addConverterFactory(GsonConverterFactory.create())
                     .build();
         }

+ 3 - 2
kneet_v3/src/main/java/com/ntels/kneet/v3/common/http/service/ThingsService.java

@@ -12,6 +12,7 @@ import com.ntels.kneet.v3.model.things.DeviceDetail;
 
 import java.util.List;
 
+import io.reactivex.Observable;
 import retrofit2.Call;
 import retrofit2.http.Body;
 import retrofit2.http.GET;
@@ -40,7 +41,7 @@ public interface ThingsService {
      * </pre>
      */
     @GET("devices")
-    Call<List<Device>> devices();
+    Observable<List<Device>> devices();
 
     /**
      * <pre>
@@ -54,7 +55,7 @@ public interface ThingsService {
      * </pre>
      */
     @GET("devices/{device_id}/{node_id}")
-    Call<DeviceDetail> deviceDetail(@Path("device_id") String deviceId, @Path("node_id") String nodeId);
+    Observable<DeviceDetail> deviceDetail(@Path("device_id") String deviceId, @Path("node_id") String nodeId);
 
     /**
      * <pre>

+ 8 - 9
kneet_v3/src/main/java/com/ntels/kneet/v3/common/http/service/UserService.java

@@ -9,12 +9,11 @@ import com.google.gson.JsonObject;
 
 import com.ntels.kneet.v3.model.user.Login;
 
+import io.reactivex.Observable;
 import okhttp3.MultipartBody;
-import okhttp3.RequestBody;
-import retrofit2.Call;
+import retrofit2.Response;
 import retrofit2.http.Body;
 import retrofit2.http.GET;
-import retrofit2.http.Headers;
 import retrofit2.http.Multipart;
 import retrofit2.http.POST;
 import retrofit2.http.PUT;
@@ -46,7 +45,7 @@ public interface UserService {
      * </pre>
      */
     @POST("member/login")
-    Call<Login> login(@Body Login login);
+    Observable<Login> login(@Body Login login);
 
     /**
      * <pre>
@@ -59,7 +58,7 @@ public interface UserService {
      * </pre>
      */
     @POST("member/new_mobile_device")
-    Call<Login> newMobileDevice(@Body Login login);
+    Observable<Login> newMobileDevice(@Body Login login);
 
     /**
      * <pre>
@@ -75,7 +74,7 @@ public interface UserService {
      * </pre>
      */
     @PUT("member")
-    Call<Login> autoLogin(@Query("os_type") String osType, @Query("device_sn") String deviceSn, @Query("device_token") String deviceToken,
+    Observable<Login> autoLogin(@Query("os_type") String osType, @Query("device_sn") String deviceSn, @Query("device_token") String deviceToken,
                           @Query("device_hostname") String deviceHostName);
 
     /**
@@ -89,7 +88,7 @@ public interface UserService {
      * </pre>
      */
     @GET("member/password")
-    Call<Void> checkPassword(@Query("password") String password);
+    Observable<Response<Void>> checkPassword(@Query("password") String password);
 
     /**
      * <pre>
@@ -103,7 +102,7 @@ public interface UserService {
      * </pre>
      */
     @PUT("member/{update_field}")
-    Call<Void> memberInfoUpdate(@Path("update_field") String updateField, @Body JsonObject body);
+    Observable<Response<Void>> memberInfoUpdate(@Path("update_field") String updateField, @Body JsonObject body);
 
     /**
      * <pre>
@@ -116,5 +115,5 @@ public interface UserService {
 
     @Multipart
     @POST("member/profile_image")
-    Call<JsonObject> profileImage(@Part MultipartBody.Part requestPart);
+    Observable<JsonObject> profileImage(@Part MultipartBody.Part requestPart);
 }

+ 0 - 3
kneet_v3/src/main/java/com/ntels/kneet/v3/common/util/Util.java

@@ -7,9 +7,6 @@ package com.ntels.kneet.v3.common.util;
 import com.google.android.gms.analytics.HitBuilders;
 import com.google.android.gms.analytics.Tracker;
 
-import com.bumptech.glide.Glide;
-import com.bumptech.glide.load.engine.DiskCacheStrategy;
-import com.bumptech.glide.request.RequestOptions;
 import com.ntels.kneet.v3.R;
 import com.ntels.kneet.v3.common.AppConfig;
 import com.ntels.kneet.v3.common.Constants;

+ 12 - 3
kneet_v3/src/main/java/com/ntels/kneet/v3/common/widget/CustomActionBarActivity.java

@@ -31,6 +31,8 @@ import android.widget.ProgressBar;
 import java.util.List;
 import java.util.TimeZone;
 
+import io.reactivex.disposables.CompositeDisposable;
+
 /**
  * <pre>
  * 1. ClassName :   CustomActionBarActivity
@@ -45,6 +47,10 @@ public class CustomActionBarActivity extends AppCompatActivity {
 
     protected static final int BACK_PRESS_VALID_TIME = 2000;
 
+    public int requestType = 0;
+    public boolean isShowLoading = true;
+    public CompositeDisposable compositeDisposable = new CompositeDisposable();
+
     private AppConfig appConfig;
     private Dialog dialog;
     private String sActName = "";
@@ -170,7 +176,7 @@ public class CustomActionBarActivity extends AppCompatActivity {
     public void finish() {
 
         super.finish();
-        dialog_dismiss();
+        dismissProgress();
         String sAnimFinish = sActAnim.substring(1);
         if (sAnimFinish.equals("1")) {
             overridePendingTransition(R.anim.abc_slide_out_top, R.anim.abc_slide_out_top);
@@ -213,6 +219,9 @@ public class CustomActionBarActivity extends AppCompatActivity {
     @Override
     protected void onDestroy() {
 
+        if (null != compositeDisposable) {
+            compositeDisposable.clear();
+        }
         try {
             RecycleUtils recycleUtils = new RecycleUtils();
             recycleUtils.recursiveRecycle(getWindow().getDecorView());
@@ -257,7 +266,7 @@ public class CustomActionBarActivity extends AppCompatActivity {
     /**
      * Dialog display.
      */
-    public void dialog_show() {
+    public void showProgress() {
 
         if (dialog != null) {
             //            dialog.cancel();
@@ -289,7 +298,7 @@ public class CustomActionBarActivity extends AppCompatActivity {
     /**
      * Dialog dismiss.
      */
-    public void dialog_dismiss() {
+    public void dismissProgress() {
 
         if (dialog != null) {
             dialog.dismiss();

+ 12 - 4
kneet_v3/src/main/java/com/ntels/kneet/v3/common/widget/CustomActivity.java

@@ -26,10 +26,11 @@ import android.support.v4.content.LocalBroadcastManager;
 import android.view.ViewGroup;
 import android.widget.ProgressBar;
 
-import java.lang.reflect.Method;
 import java.util.List;
 import java.util.TimeZone;
 
+import io.reactivex.disposables.CompositeDisposable;
+
 /**
  * <pre>
  * 1. ClassName :   CustomActivity
@@ -45,6 +46,10 @@ public class CustomActivity extends Activity {
     /** Back키 두번 눌러 종료 유효시간 */
     protected static final int BACK_PRESS_VALID_TIME = 2000;
 
+    public int requestType = 0;
+    public boolean isShowLoading = true;
+    public CompositeDisposable compositeDisposable = new CompositeDisposable();
+
     private AppConfig appConfig;
     private Dialog dialog;
 
@@ -186,7 +191,7 @@ public class CustomActivity extends Activity {
     public void finish() {
 
         super.finish();
-        dialog_dismiss();
+        dismissProgress();
         String sAnimFinish = sActAnim.substring(1);
         if (sAnimFinish.equals("1")) {
             overridePendingTransition(R.anim.abc_slide_out_top, R.anim.abc_slide_out_top);
@@ -206,6 +211,9 @@ public class CustomActivity extends Activity {
     @Override
     protected void onDestroy() {
 
+        if (null != compositeDisposable) {
+            compositeDisposable.clear();
+        }
         try {
             /*RecycleUtils recycleUtils = new RecycleUtils();
             recycleUtils.recursiveRecycle(getWindow().getDecorView());*/
@@ -250,7 +258,7 @@ public class CustomActivity extends Activity {
     /**
      * Dialog display.
      */
-    public void dialog_show() {
+    public void showProgress() {
 
         if (dialog != null) {
             //            dialog.cancel();
@@ -284,7 +292,7 @@ public class CustomActivity extends Activity {
     /**
      * Dialog dismiss.
      */
-    public void dialog_dismiss() {
+    public void dismissProgress() {
 
         if (dialog != null) {
             dialog.dismiss();

+ 197 - 198
kneet_v3/src/main/java/com/ntels/kneet/v3/view/Login.java

@@ -7,13 +7,10 @@ package com.ntels.kneet.v3.view;
 import com.ntels.kneet.v3.R;
 import com.ntels.kneet.v3.common.AppConfig;
 import com.ntels.kneet.v3.common.Constants;
-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.gcm.support.KneetMessageLocalBroadCast;
-import com.ntels.kneet.v3.common.http.HttpSend;
-import com.ntels.kneet.v3.common.http.Response;
-import com.ntels.kneet.v3.common.http.RetrofitCallback;
+import com.ntels.kneet.v3.common.http.IHttpRequest;
 import com.ntels.kneet.v3.common.http.RetrofitClient;
 import com.ntels.kneet.v3.common.http.RetrofitService;
 import com.ntels.kneet.v3.common.util.Dlog;
@@ -22,8 +19,6 @@ import com.ntels.kneet.v3.common.widget.CustomActivity;
 import com.ntels.kneet.v3.view.dialog.CustomDialog;
 import com.ntels.kneet.v3.view.invitation.InvitationList;
 
-import org.json.JSONObject;
-
 import android.app.Activity;
 import android.content.Intent;
 import android.database.sqlite.SQLiteDatabase;
@@ -36,9 +31,14 @@ import android.widget.LinearLayout;
 import android.widget.Toast;
 
 import java.io.IOException;
+import java.lang.annotation.Annotation;
 
-import retrofit2.Call;
-import retrofit2.Callback;
+import io.reactivex.android.schedulers.AndroidSchedulers;
+import io.reactivex.disposables.Disposable;
+import io.reactivex.schedulers.Schedulers;
+import okhttp3.ResponseBody;
+import retrofit2.Converter;
+import retrofit2.HttpException;
 
 /**
  * <pre>
@@ -51,11 +51,11 @@ import retrofit2.Callback;
  * </pre>
  */
 public class Login extends CustomActivity implements View.OnClickListener,
-        CustomDialog.OnMsgAlterToResult {
+        CustomDialog.OnMsgAlterToResult, IHttpRequest {
 
-    private int mType = 0;
+    private static final int MSG_COM_EXCEPTION = -1;
     private static final int MSG_COM_P_MEMBER_LOGIN = 1;
-    private static final int MSG_COM_G_MEMBER = 2;
+    private static final int MSG_COM_P_MEMBER = 2;
     private static final int VIBRATION_DURATION = 100;
     private static final int FINISH_INTERVAL = 1000;
 
@@ -138,8 +138,7 @@ public class Login extends CustomActivity implements View.OnClickListener,
             mUtil.getView(mActivity, R.id.llRoot).setVisibility(View.INVISIBLE);
             mId = mAppConfig.getLogin_Id();
             mPass = "";
-            comHandler.sendMessageDelayed(comHandler.obtainMessage(MSG_COM_G_MEMBER),
-                    Constants.HANDLER_DELAY_MILLIS);
+            request(MSG_COM_P_MEMBER, true);
         } else {
             mUtil.getView(mActivity, R.id.llAutoLogin).performClick();
         }
@@ -192,8 +191,7 @@ public class Login extends CustomActivity implements View.OnClickListener,
         if (resultCode == RESULT_OK) {
             switch (requestCode) {
                 case Constants.ACT_ERROR_PAGE:
-                    comHandler.sendMessageDelayed(comHandler.obtainMessage(mType),
-                            Constants.HANDLER_DELAY_MILLIS);
+                    request(requestType, true);
                     break;
                 case Constants.ACT_JOIN:
                     //setFinish();
@@ -201,8 +199,7 @@ public class Login extends CustomActivity implements View.OnClickListener,
                 case Constants.ACT_LOGIN_NEW_DEVICE:
                     isReload = data.getBooleanExtra(Constants.EXTRA_RELOAD_FLAG, false);
                     if (isReload) {
-                        comHandler.sendMessageDelayed(comHandler.obtainMessage(MSG_COM_G_MEMBER),
-                                Constants.HANDLER_DELAY_MILLIS);
+                        request(MSG_COM_P_MEMBER, true);
                     } else {
                         setFinish();
                     }
@@ -222,8 +219,7 @@ public class Login extends CustomActivity implements View.OnClickListener,
                             Constants.ACT_LOGIN_NEW_DEVICE);
                     break;
                 case Constants.ACT_INVITATION_LIST:
-                    comHandler.sendMessageDelayed(comHandler.obtainMessage(MSG_COM_G_MEMBER),
-                            Constants.HANDLER_DELAY_MILLIS);
+                    request(MSG_COM_P_MEMBER, true);
                     break;
                 default:
                     break;
@@ -259,8 +255,7 @@ public class Login extends CustomActivity implements View.OnClickListener,
                 break;
             case Constants.MSG807:
                 if (btnResult == 1) {
-                    comHandler.sendMessageDelayed(comHandler.obtainMessage(mType),
-                            Constants.HANDLER_DELAY_MILLIS);
+                    request(requestType, isShowLoading);
                 } else {
                     setExit();
                 }
@@ -295,8 +290,7 @@ public class Login extends CustomActivity implements View.OnClickListener,
                 }
                 mUtil.setVibrator(VIBRATION_DURATION);
                 view.setEnabled(false);
-                comHandler.sendMessageDelayed(comHandler.obtainMessage(MSG_COM_P_MEMBER_LOGIN),
-                        Constants.HANDLER_DELAY_MILLIS);
+                request(MSG_COM_P_MEMBER_LOGIN, true);
                 break;
             case R.id.tvJoin:
                 mIntent = new Intent(mActivity, JoinCheck.class);
@@ -343,133 +337,172 @@ public class Login extends CustomActivity implements View.OnClickListener,
         return isCheck;
     }
 
-    Handler comHandler = new Handler(new IncomingHandlerCallBack());
+    /**
+     * <pre>
+     * 로그인 데이터 처리.
+     *
+     * @param login 로그인 데이터 {@link com.ntels.kneet.v3.model.user.Login}
+     * </pre>
+     */
+    private void processLogin(com.ntels.kneet.v3.model.user.Login login) {
+
+        //회원이미지 추가
+        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()));
+        if ("Y".equals(login.getTempPasswordYn())) {
+            mAppConfig.setLogin_Pass(mPass);
+        } else {
+            mAppConfig.setLogin_Pass("");
+        }
+        mAppConfig.setAutoLogin(mIsAutoLogin);
+        mAppConfig.setLogin(true);
 
-    class IncomingHandlerCallBack implements Handler.Callback {
+        //인증 토큰
+        mAppConfig.setAuth_Token(login.getAuthToken());
 
-        @Override
-        public boolean handleMessage(Message msg) {
+        //db 입력작업
+        SQLiteDatabase db = DatabaseOpenHelper.getInstance(mActivity).getWritableDatabase();
+        String sql = "";
+        sql = mSqlManager.qryDelLoginInfo();
+        db.execSQL(sql);
 
-            mType = msg.what;
-            switch (msg.what) {
-                case MSG_COM_P_MEMBER_LOGIN:
-                    requestLogin();
-                    break;
-                case MSG_COM_G_MEMBER:
-                    requestAutoLogin();
-                    break;
-                default:
-                    break;
-            }
-            return true;
+        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());
+
+        if (login.getInvitationsCount() > 0) {
+            Intent intent = new Intent(mActivity, InvitationList.class);
+            mUtil.callActivityForResultNoAnim(mActivity, intent,
+                    Constants.ACT_INVITATION_LIST);
+            return;
         }
+
+        setFinish();
     }
 
     /**
-     * <pre>
-     * 로그인 요청 결과 처리.
-     * @param response 요청 결과 데이터
-     * </pre>
+     * Http request.
+     *
+     * @param requestType Request API type
+     * @param isLoading   If true dialog is show
      */
-    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()));
-            if ("Y".equals(login.getTempPasswordYn())) {
-                mAppConfig.setLogin_Pass(mPass);
-            } else {
-                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());
-
-            if (login.getInvitationsCount() > 0) {
-                Intent intent = new Intent(mActivity, InvitationList.class);
-                mUtil.callActivityForResultNoAnim(mActivity, intent,
-                        Constants.ACT_INVITATION_LIST);
-                return;
-            }
+    @Override
+    public void request(int requestType, boolean isLoading) {
+        this.requestType = requestType;
+        isShowLoading = isLoading;
+        if (isLoading) {
+            showProgress();
+        }
+        switch (requestType) {
+            case MSG_COM_P_MEMBER_LOGIN:
+                compositeDisposable.add(requestLogin());
+                break;
+            case MSG_COM_P_MEMBER:
+                compositeDisposable.add(requestAutoLogin());
+                break;
+        }
+    }
 
-            setFinish();
-        } 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();
+    /**
+     * Http request response.
+     *
+     * @param requestType Request API type
+     * @param response    response data
+     */
+    @Override
+    public void onResponse(int requestType, Object response) {
+        dismissProgress();
+        switch (requestType) {
+            case MSG_COM_P_MEMBER_LOGIN:
+            case MSG_COM_P_MEMBER:
+                if (response instanceof com.ntels.kneet.v3.model.user.Login) {
+                    processLogin((com.ntels.kneet.v3.model.user.Login) response);
+                }
                 mUtil.getView(mActivity, R.id.llRoot).setVisibility(View.VISIBLE);
-                mCustomDialog.msgAlert(mActivity, Constants.MSG807);
                 mUtil.getButton(mActivity, R.id.btnLogin).setEnabled(true);
-            }
-            if ("401".equals(login.getErrCode())) {
-                mUtil.getView(mActivity, R.id.llRoot).setVisibility(View.VISIBLE);
-                mCustomDialog.msgAlert(mActivity, Constants.MSG000, login.getErrMsg());
-            } else if ("401-101".equals(login.getErrCode())) {
-                mUtil.getView(mActivity, R.id.llRoot).setVisibility(View.VISIBLE);
-                mCustomDialog.msgAlert(mActivity, Constants.MSG828, mId,
-                        R.string.MSG_TITLE_001);
-            } else if ("401-103".equals(login.getErrCode())) {
-                Intent intent = new Intent(mActivity, LoginNewDevice.class);
-                intent.putExtra(Constants.EXTRA_EMAIL_ID, mId);
-                intent.putExtra(Constants.EXTRA_NICKNAME, login.getNickname());
-                mUtil.callActivityForResult(mActivity, intent, Constants.ACT_LOGIN_NEW_DEVICE);
-            } else {
-                mUtil.getView(mActivity, R.id.llRoot).setVisibility(View.VISIBLE);
-                mCustomDialog.msgAlert(mActivity, Constants.MSG000, login.getErrMsg());
-            }
+                break;
+        }
+    }
+
+    /**
+     * Http request error.
+     *
+     * @param requestType request API type
+     * @param error       error data(ex> error code, error message)
+     */
+    @Override
+    public void onError(int requestType, Object error) {
+        dismissProgress();
+        switch (requestType) {
+            case MSG_COM_P_MEMBER_LOGIN:
+            case MSG_COM_P_MEMBER:
+                ResponseBody body = ((HttpException) error).response().errorBody();
+                Converter<ResponseBody, com.ntels.kneet.v3.model.user.Login> errorConverter =
+                        RetrofitClient.getClient().responseBodyConverter(com.ntels.kneet.v3.model.user.Login.class, new Annotation[0]);
+                com.ntels.kneet.v3.model.user.Login errorResponse = null;
+                try {
+                    errorResponse = errorConverter.convert(body);
+                } catch (IOException e) {
+                    e.printStackTrace();
+                    mUtil.getView(mActivity, R.id.llRoot).setVisibility(View.VISIBLE);
+                    mCustomDialog.msgAlert(mActivity, Constants.MSG807);
+                    mUtil.getButton(mActivity, R.id.btnLogin).setEnabled(true);
+                }
+
+                if ("401".equals(errorResponse.getErrCode())) {
+                    mUtil.getView(mActivity, R.id.llRoot).setVisibility(View.VISIBLE);
+                    mCustomDialog.msgAlert(mActivity, Constants.MSG000, errorResponse.getErrMsg());
+                } else if ("401-101".equals(errorResponse.getErrCode())) {
+                    mUtil.getView(mActivity, R.id.llRoot).setVisibility(View.VISIBLE);
+                    mCustomDialog.msgAlert(mActivity, Constants.MSG828, mId, R.string.MSG_TITLE_001);
+                } else if ("401-103".equals(errorResponse.getErrCode())) {
+                    Intent intent = new Intent(mActivity, LoginNewDevice.class);
+                    intent.putExtra(Constants.EXTRA_EMAIL_ID, mId);
+                    intent.putExtra(Constants.EXTRA_NICKNAME, errorResponse.getNickname());
+                    mUtil.callActivityForResult(mActivity, intent, Constants.ACT_LOGIN_NEW_DEVICE);
+                } else {
+                    mUtil.getView(mActivity, R.id.llRoot).setVisibility(View.VISIBLE);
+                    mCustomDialog.msgAlert(mActivity, Constants.MSG000, errorResponse.getErrMsg());
+                }
+                break;
+            case MSG_COM_EXCEPTION:
+                mCustomDialog.msgAlert(mActivity, Constants.MSG807);
+                break;
+            default:
+                mCustomDialog.msgAlert(mActivity, Constants.MSG807);
+                break;
         }
     }
 
     /**
      * 멤버 로그인 요청.
      */
-    @SuppressWarnings("unchecked")
-    private void requestLogin() {
+    private Disposable requestLogin() {
         com.ntels.kneet.v3.model.user.Login login = new com.ntels.kneet.v3.model.user.Login();
         login.setEmailId(mId);
         login.setPassword(mPass);
@@ -479,38 +512,21 @@ public class Login extends CustomActivity implements View.OnClickListener,
         login.setDeviceToken(mAppConfig.getPush_Token());
         login.setDeviceName(mUtil.getPhoneName());
         login.setDeviceHostName(mUtil.getHostName());
-        Call<com.ntels.kneet.v3.model.user.Login> loginCall = RetrofitService.getUserService().login(login);
-        loginCall.enqueue(new RetrofitCallback(this, new Callback<com.ntels.kneet.v3.model.user.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);
-                } else {
-                    mCustomDialog.msgAlert(mActivity, Constants.MSG807);
-                }
-                mUtil.getButton(mActivity, R.id.btnLogin).setEnabled(true);
-            }
 
-            /**
-             * 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();
-                mUtil.getView(mActivity, R.id.llRoot).setVisibility(View.VISIBLE);
-                mCustomDialog.msgAlert(mActivity, Constants.MSG807);
-                mUtil.getButton(mActivity, R.id.btnLogin).setEnabled(true);
-            }
-        }));
+        return RetrofitService.getUserService().login(login)
+                .subscribeOn(Schedulers.io())
+                .observeOn(AndroidSchedulers.mainThread())
+                .subscribe(loginResponse -> onResponse(MSG_COM_P_MEMBER_LOGIN, loginResponse),
+                        e -> {
+                            if (e instanceof HttpException) {
+                                onError(MSG_COM_P_MEMBER_LOGIN, e);
+                            } else {
+                                onError(MSG_COM_EXCEPTION, e);
+                            }
+                            mUtil.getView(mActivity, R.id.llRoot).setVisibility(View.VISIBLE);
+                            mUtil.getButton(mActivity, R.id.btnLogin).setEnabled(true);
+                        }
+                );
     }
 
     /**
@@ -519,40 +535,23 @@ public class Login extends CustomActivity implements View.OnClickListener,
      * (인증 토큰을 기준으로 회원의 로그인 정보를 조회하고 푸시 토큰을 등록/수정한다)
      * </pre>
      */
-    @SuppressWarnings("unchecked")
-    private void requestAutoLogin() {
-        Call<com.ntels.kneet.v3.model.user.Login> autoLoginCall = RetrofitService.getUserService().autoLogin(Constants.OS_TYPE,
-                mAppConfig.getUuid(), mAppConfig.getPush_Token(), mUtil.getHostName());
-        autoLoginCall.enqueue(new RetrofitCallback(this, new Callback<com.ntels.kneet.v3.model.user.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);
-                } else {
-                    mCustomDialog.msgAlert(mActivity, Constants.MSG807);
-                }
-                mUtil.getButton(mActivity, R.id.btnLogin).setEnabled(true);
-            }
-
-            /**
-             * 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();
-                mUtil.getView(mActivity, R.id.llRoot).setVisibility(View.VISIBLE);
-                mCustomDialog.msgAlert(mActivity, Constants.MSG807);
-                mUtil.getButton(mActivity, R.id.btnLogin).setEnabled(true);
-            }
-        }));
+    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);
+                            }
+                            mUtil.getView(mActivity, R.id.llRoot).setVisibility(View.VISIBLE);
+                            mUtil.getButton(mActivity, R.id.btnLogin).setEnabled(true);
+                        }
+                );
     }
 
     /**

+ 168 - 146
kneet_v3/src/main/java/com/ntels/kneet/v3/view/LoginNewDevice.java

@@ -9,8 +9,7 @@ import com.ntels.kneet.v3.common.AppConfig;
 import com.ntels.kneet.v3.common.Constants;
 import com.ntels.kneet.v3.common.db.DatabaseOpenHelper;
 import com.ntels.kneet.v3.common.db.SqlManager;
-import com.ntels.kneet.v3.common.http.Response;
-import com.ntels.kneet.v3.common.http.RetrofitCallback;
+import com.ntels.kneet.v3.common.http.IHttpRequest;
 import com.ntels.kneet.v3.common.http.RetrofitClient;
 import com.ntels.kneet.v3.common.http.RetrofitService;
 import com.ntels.kneet.v3.common.util.Util;
@@ -23,16 +22,20 @@ import android.app.Activity;
 import android.content.Intent;
 import android.database.sqlite.SQLiteDatabase;
 import android.os.Bundle;
-import android.os.Handler;
-import android.os.Message;
+import android.provider.Settings;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.widget.Toast;
 
 import java.io.IOException;
+import java.lang.annotation.Annotation;
 
-import retrofit2.Call;
-import retrofit2.Callback;
+import io.reactivex.android.schedulers.AndroidSchedulers;
+import io.reactivex.disposables.Disposable;
+import io.reactivex.schedulers.Schedulers;
+import okhttp3.ResponseBody;
+import retrofit2.Converter;
+import retrofit2.HttpException;
 
 /**
  * <pre>
@@ -45,8 +48,9 @@ import retrofit2.Callback;
  * </pre>
  */
 public class LoginNewDevice 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_NEW_MOBILE_DEVICE = 1;
 
     private SqlManager mSqlManager = new SqlManager();
@@ -55,7 +59,6 @@ public class LoginNewDevice extends CustomActionBarActivity implements View.OnCl
     private AppConfig mAppConfig;
     private Util mUtil = new Util();
     private CustomDialog mCustomDialog = new CustomDialog();
-    private int type = 0;
     private String emailId = "";
     private String key = "";
 
@@ -89,8 +92,7 @@ public class LoginNewDevice extends CustomActionBarActivity implements View.OnCl
                     return;
                 }
                 view.setEnabled(false);
-                comHandler.sendMessageDelayed(comHandler.obtainMessage(
-                        MSG_COM_P_MEMBER_NEW_MOBILE_DEVICE), Constants.HANDLER_DELAY_MILLIS);
+                request(MSG_COM_P_MEMBER_NEW_MOBILE_DEVICE, true);
                 break;
             default:
                 break;
@@ -122,8 +124,7 @@ public class LoginNewDevice extends CustomActionBarActivity implements View.OnCl
                 break;
             case Constants.MSG807:
                 if (btnResult == 1) {
-                    comHandler.sendMessageDelayed(comHandler.obtainMessage(type),
-                            Constants.HANDLER_DELAY_MILLIS);
+                    request(requestType, isShowLoading);
                 } else {
                     mActivity.finish();
                 }
@@ -134,7 +135,7 @@ public class LoginNewDevice extends CustomActionBarActivity implements View.OnCl
             case Constants.MSG820:
                 if (btnResult == 1) {
                     Intent intent =
-                            new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
+                            new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
                     intent.addCategory(Intent.CATEGORY_DEFAULT);
                     mUtil.callActivityForResult(mActivity, intent, Constants.ACT_GOOGLE_CHECK);
                 } else {
@@ -181,25 +182,6 @@ public class LoginNewDevice extends CustomActionBarActivity implements View.OnCl
         }
     }
 
-    Handler comHandler = new Handler(new IncomingHandlerCallBack());
-
-    class IncomingHandlerCallBack implements Handler.Callback {
-
-        @Override
-        public boolean handleMessage(Message msg) {
-
-            type = msg.what;
-            switch (msg.what) {
-                case MSG_COM_P_MEMBER_NEW_MOBILE_DEVICE:
-                    requestNewMobileDevice();
-                    break;
-                default:
-                    break;
-            }
-            return true;
-        }
-    }
-
     /**
      * 사용자 입력 필드 체크.
      *
@@ -218,6 +200,86 @@ public class LoginNewDevice extends CustomActionBarActivity implements View.OnCl
         return isCheck;
     }
 
+    /**
+     * Http request.
+     *
+     * @param requestType Request API mRequestType
+     * @param isLoading   If true dialog is show
+     */
+    @Override
+    public void request(int requestType, boolean isLoading) {
+        this.requestType = requestType;
+        isShowLoading = isLoading;
+        if (isLoading) {
+            showProgress();
+        }
+        switch (requestType) {
+            case MSG_COM_P_MEMBER_NEW_MOBILE_DEVICE:
+                compositeDisposable.add(requestNewMobileDevice());
+                break;
+        }
+    }
+
+    /**
+     * Http request response.
+     *
+     * @param requestType Request API mRequestType
+     * @param response    response data
+     */
+    @Override
+    public void onResponse(int requestType, Object response) {
+        dismissProgress();
+        switch (requestType) {
+            case MSG_COM_P_MEMBER_NEW_MOBILE_DEVICE:
+                if (response instanceof com.ntels.kneet.v3.model.user.Login) {
+                    processLogin((Login) response);
+                }
+                mUtil.getButton(mActivity, R.id.llBtn1).setEnabled(true);
+                break;
+        }
+    }
+
+    /**
+     * Http request error.
+     *
+     * @param requestType request API mRequestType
+     * @param error       error data(ex> error code, error message)
+     */
+    @Override
+    public void onError(int requestType, Object error) {
+        dismissProgress();
+        switch (requestType) {
+            case MSG_COM_P_MEMBER_NEW_MOBILE_DEVICE:
+                ResponseBody body = ((HttpException) error).response().errorBody();
+                Converter<ResponseBody, Login> errorConverter =
+                        RetrofitClient.getClient().responseBodyConverter(com.ntels.kneet.v3.model.user.Login.class, new Annotation[0]);
+                Login errorResponse = null;
+                try {
+                    errorResponse = errorConverter.convert(body);
+                } catch (IOException e) {
+                    e.printStackTrace();
+                    mCustomDialog.msgAlert(mActivity, Constants.MSG807);
+                    mUtil.getButton(mActivity, R.id.llBtn1).setEnabled(true);
+                }
+
+                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);
+                break;
+            default:
+                mCustomDialog.msgAlert(mActivity, Constants.MSG807);
+                break;
+        }
+    }
+
     /**
      * <pre>
      * 단말(장치) 인증(새로운 단말로 로그인 시 단말(장치) 인증 번호를 확인하고,
@@ -225,8 +287,7 @@ public class LoginNewDevice extends CustomActionBarActivity implements View.OnCl
      * (기존 단말(장치)을 대체할 경우의 처리도 포함))
      * </pre>
      */
-    @SuppressWarnings("unchecked")
-    private void requestNewMobileDevice() {
+    private Disposable requestNewMobileDevice() {
         Login login = new Login();
         login.setKey(key);
         login.setEmailId(emailId);
@@ -236,126 +297,87 @@ public class LoginNewDevice extends CustomActionBarActivity implements View.OnCl
         login.setDeviceToken(mAppConfig.getPush_Token());
         login.setDeviceName(mUtil.getPhoneName());
         login.setDeviceHostName(mUtil.getHostName());
-        Call<Login> newMobileDeviceCall = RetrofitService.getUserService().newMobileDevice(login);
-        newMobileDeviceCall.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<Login> call, retrofit2.Response<Login> response) {
-                if (null != response) {
-                    processLogin(response);
-                } else {
-                    mCustomDialog.msgAlert(mActivity, Constants.MSG807);
-                }
-                mUtil.getButton(mActivity, R.id.llBtn1).setEnabled(true);
-            }
 
-            /**
-             * 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<Login> call, Throwable t) {
-                t.printStackTrace();
-                mCustomDialog.msgAlert(mActivity, Constants.MSG807);
-                mUtil.getButton(mActivity, R.id.llBtn1).setEnabled(true);
-            }
-        }));
+        return RetrofitService.getUserService().newMobileDevice(login)
+                .subscribeOn(Schedulers.io())
+                .observeOn(AndroidSchedulers.mainThread())
+                .subscribe(loginResponse -> onResponse(MSG_COM_P_MEMBER_NEW_MOBILE_DEVICE, loginResponse),
+                        e -> {
+                            if (e instanceof HttpException) {
+                                onError(MSG_COM_P_MEMBER_NEW_MOBILE_DEVICE, e);
+                            } else {
+                                onError(MSG_COM_EXCEPTION, e);
+                            }
+                            mUtil.getButton(mActivity, R.id.llBtn1).setEnabled(true);
+                        }
+                );
     }
 
     /**
-     * 단말(장치) 인증(새로운 단말로 로그인 시 단말(장치) 인증 번호를 확인하고,
-     * 단말(장치)을 등록 처리 요청 결과.
+     * 로그인 데이터 처리
      *
-     * @param response 결과 data
+     * @param login 로그인 데이터 {@link Login}
      */
-    private void processLogin(retrofit2.Response<Login> response) {
-
-        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()));
-            if ("Y".equals(login.getTempPasswordYn())) {
-                String pass = "";
-                mAppConfig.setLogin_Pass(pass);
-            } else {
-                mAppConfig.setLogin_Pass("");
-            }
-            Boolean isAutoLogin = false;
-            mAppConfig.setAutoLogin(isAutoLogin);
-            mAppConfig.setLogin(true);
-
-            //인증 토큰
-            mAppConfig.setAuth_Token(login.getAuthToken());
-
-            //db 입력작업
-            SQLiteDatabase db = DatabaseOpenHelper.getInstance(mActivity).getWritableDatabase();
-            String sql = "";
-            sql = mSqlManager.qryDelLoginInfo();
-            db.execSQL(sql);
-
-            sql = "";
-            Boolean isSaveId = false;
-            sql = mSqlManager.qryInsertLoginInfo(login.getEmailId(), login.getAuthToken(), isSaveId, isAutoLogin,
-                    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());
-
-            if (login.getInvitationsCount() > 0) {
-                Intent intent = new Intent(mActivity, InvitationList.class);
-                mUtil.callActivityForResultNoAnim(mActivity, intent,
-                        Constants.ACT_INVITATION_LIST);
-                return;
-            }
-
-            setFinish();
+    private void processLogin(Login login) {
+
+        //회원이미지 추가
+        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()));
+        if ("Y".equals(login.getTempPasswordYn())) {
+            String pass = "";
+            mAppConfig.setLogin_Pass(pass);
         } else {
-            try {
-                login = (Login) RetrofitClient.getClient().responseBodyConverter(Login.class, 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());
-            }
+            mAppConfig.setLogin_Pass("");
         }
-        mUtil.getButton(mActivity, R.id.llBtn1).setEnabled(true);
+        Boolean isAutoLogin = false;
+        mAppConfig.setAutoLogin(isAutoLogin);
+        mAppConfig.setLogin(true);
+
+        //인증 토큰
+        mAppConfig.setAuth_Token(login.getAuthToken());
+
+        //db 입력작업
+        SQLiteDatabase db = DatabaseOpenHelper.getInstance(mActivity).getWritableDatabase();
+        String sql = "";
+        sql = mSqlManager.qryDelLoginInfo();
+        db.execSQL(sql);
+
+        sql = "";
+        Boolean isSaveId = false;
+        sql = mSqlManager.qryInsertLoginInfo(login.getEmailId(), login.getAuthToken(), isSaveId, isAutoLogin,
+                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());
+
+        if (login.getInvitationsCount() > 0) {
+            Intent intent = new Intent(mActivity, InvitationList.class);
+            mUtil.callActivityForResultNoAnim(mActivity, intent,
+                    Constants.ACT_INVITATION_LIST);
+            return;
+        }
+
+        setFinish();
     }
 
     /**

+ 1 - 1
kneet_v3/src/main/java/com/ntels/kneet/v3/view/dialog/PushDialog.java

@@ -464,7 +464,7 @@ public class PushDialog extends Activity implements OnDismissListener {
       type = msg.what;
       switch (msg.what) {
         case MSG_COM_G_DEVICES_WARNING_NODES:
-          //dialog_show();
+          //showProgress();
           sendGetDevicesWarningNodes();
           break;
 

+ 145 - 377
kneet_v3/src/main/java/com/ntels/kneet/v3/view/mainmore/Setting.java

@@ -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;

+ 96 - 67
kneet_v3/src/main/java/com/ntels/kneet/v3/view/mainmore/SettingEmailChange.java

@@ -9,7 +9,7 @@ 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;
-import com.ntels.kneet.v3.common.http.RetrofitCallback;
+import com.ntels.kneet.v3.common.http.IHttpRequest;
 import com.ntels.kneet.v3.common.http.RetrofitClient;
 import com.ntels.kneet.v3.common.http.RetrofitService;
 import com.ntels.kneet.v3.common.util.Util;
@@ -21,16 +21,19 @@ import android.app.Activity;
 import android.content.Intent;
 import android.content.res.Configuration;
 import android.os.Bundle;
-import android.os.Handler;
-import android.os.Message;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.widget.Toast;
 
 import java.io.IOException;
+import java.lang.annotation.Annotation;
 
-import retrofit2.Call;
-import retrofit2.Callback;
+import io.reactivex.android.schedulers.AndroidSchedulers;
+import io.reactivex.disposables.Disposable;
+import io.reactivex.schedulers.Schedulers;
+import okhttp3.ResponseBody;
+import retrofit2.Converter;
+import retrofit2.HttpException;
 
 /**
  * <pre>
@@ -43,14 +46,12 @@ import retrofit2.Callback;
  * </pre>
  */
 public class SettingEmailChange extends CustomActivity implements View.OnClickListener,
-        CustomDialog.OnMsgAlterToResult {
+        CustomDialog.OnMsgAlterToResult, IHttpRequest {
 
+    private static final int MSG_COM_EXCEPTION = -1;
     private static final int MSG_COM_P_MEMBER_MEMBER_ID_UPDATE_FIELD = 1;
     private static final String MEMBER_UPDATE_FIELD_EMAIL = "email";
 
-    /*통신 관련*/
-    private int type = 0;
-
     /*공통*/
     private Activity act;
     private AppConfig appConfig;
@@ -102,8 +103,7 @@ public class SettingEmailChange extends CustomActivity implements View.OnClickLi
                     return;
                 }
                 view.setEnabled(false);
-                comHandler.sendMessageDelayed(comHandler.obtainMessage(
-                        MSG_COM_P_MEMBER_MEMBER_ID_UPDATE_FIELD), 10);
+                request(requestType, isShowLoading);
                 break;
             case R.id.llBtn2:
                 onBackPressed();
@@ -113,75 +113,104 @@ public class SettingEmailChange extends CustomActivity implements View.OnClickLi
         }
     }
 
-    Handler comHandler = new Handler(new IncomingHandlerCallBack());
-
-    class IncomingHandlerCallBack implements Handler.Callback {
+    /**
+     * Http request.
+     *
+     * @param requestType Request API type
+     * @param isLoading   If true dialog is show
+     */
+    @Override
+    public void request(int requestType, boolean isLoading) {
+        this.requestType = requestType;
+        isShowLoading = isLoading;
+        if (isLoading) {
+            showProgress();
+        }
+        switch (requestType) {
+            case MSG_COM_P_MEMBER_MEMBER_ID_UPDATE_FIELD:
+                compositeDisposable.add(requestMemberInfoUpdate());
+                break;
+        }
+    }
 
-        @Override
-        public boolean handleMessage(Message msg) {
+    /**
+     * Http request response.
+     *
+     * @param requestType Request API type
+     * @param response    response data
+     */
+    @Override
+    public void onResponse(int requestType, Object response) {
+        dismissProgress();
+        switch (requestType) {
+            case MSG_COM_P_MEMBER_MEMBER_ID_UPDATE_FIELD:
+                util.setShowToast(act, util.getString(act, R.string.MSG844), Toast.LENGTH_SHORT);
+                intent = new Intent();
+                act.setResult(RESULT_OK, intent);
+                finish();
+                break;
+        }
+    }
 
-            type = msg.what;
-            switch (msg.what) {
-                case MSG_COM_P_MEMBER_MEMBER_ID_UPDATE_FIELD:
-                    requestMemberInfoUpdate();
-                    break;
-                default:
-                    break;
-            }
-            return true;
+    /**
+     * Http request error.
+     *
+     * @param requestType request API type
+     * @param error       error data(ex> error code, error message)
+     */
+    @Override
+    public void onError(int requestType, Object error) {
+        dismissProgress();
+        switch (requestType) {
+            case MSG_COM_P_MEMBER_MEMBER_ID_UPDATE_FIELD:
+                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();
+                    customDialog.msgAlert(act, Constants.MSG807);
+                }
+                if ("401".equals(errorResponse.getErrCode())) {
+                    customDialog.msgAlert(act, Constants.MSG998, errorResponse.getErrMsg());
+                } else if ("401-106".equals(errorResponse.getErrCode())) {
+                    customDialog.msgAlert(act, Constants.MSG997, errorResponse.getErrMsg());
+                } else {
+                    customDialog.msgAlert(act, Constants.MSG000, errorResponse.getErrMsg());
+                }
+                break;
+            case MSG_COM_EXCEPTION:
+                customDialog.msgAlert(act, Constants.MSG807);
+                break;
+            default:
+                customDialog.msgAlert(act, Constants.MSG807);
+                break;
         }
     }
 
     /**
      * 회원 이메일 수정 요청.
      */
-    @SuppressWarnings("unchecked")
-    private void requestMemberInfoUpdate() {
+    private Disposable requestMemberInfoUpdate() {
 
         JsonObject body = new JsonObject();
         body.addProperty(Constants.HTTP_new_email_id, newEmailId);
-        Call<Void> memberInfoUpdateCall = RetrofitService.getUserService().memberInfoUpdate(MEMBER_UPDATE_FIELD_EMAIL, body);
-        memberInfoUpdateCall.enqueue(new RetrofitCallback(act, new Callback<Void>() {
-            @Override
-            public void onResponse(Call<Void> call, retrofit2.Response<Void> response) {
-                if (null != response) {
-                    if (response.isSuccessful()) {
-                        util.setShowToast(act, util.getString(act, R.string.MSG844), Toast.LENGTH_SHORT);
-                        intent = new Intent();
-                        act.setResult(RESULT_OK, intent);
-                        finish();
-                    } else {
-                        BaseResponse errorResponse = null;
-                        try {
-                            errorResponse = (BaseResponse) RetrofitClient.getClient().responseBodyConverter(BaseResponse.class,
-                                    BaseResponse.class.getAnnotations()).convert(response.errorBody());
-
-                            if ("401".equals(errorResponse.getErrCode())) {
-                                customDialog.msgAlert(act, Constants.MSG998, errorResponse.getErrMsg());
-                            } else if ("401-106".equals(errorResponse.getErrCode())) {
-                                customDialog.msgAlert(act, Constants.MSG997, errorResponse.getErrMsg());
+
+        return RetrofitService.getUserService().memberInfoUpdate(MEMBER_UPDATE_FIELD_EMAIL, body)
+                .subscribeOn(Schedulers.io())
+                .observeOn(AndroidSchedulers.mainThread())
+                .subscribe(aVoid -> onResponse(MSG_COM_P_MEMBER_MEMBER_ID_UPDATE_FIELD, aVoid),
+                        e -> {
+                            if (e instanceof HttpException) {
+                                onError(MSG_COM_P_MEMBER_MEMBER_ID_UPDATE_FIELD, e);
                             } else {
-                                customDialog.msgAlert(act, Constants.MSG000, errorResponse.getErrMsg());
+                                onError(MSG_COM_EXCEPTION, e);
                             }
-                        } catch (IOException e) {
-                            e.printStackTrace();
-                            customDialog.msgAlert(act, Constants.MSG807);
+                            util.getView(act, R.id.llBtn1).setEnabled(true);
                         }
-
-                    }
-                } else {
-                    customDialog.msgAlert(act, Constants.MSG807);
-                }
-                util.getView(act, R.id.llBtn1).setEnabled(true);
-            }
-
-            @Override
-            public void onFailure(Call<Void> call, Throwable t) {
-                t.printStackTrace();
-                customDialog.msgAlert(act, Constants.MSG807);
-                util.getView(act, R.id.llBtn1).setEnabled(true);
-            }
-        }));
+                );
     }
 
     @Override
@@ -205,7 +234,7 @@ public class SettingEmailChange extends CustomActivity implements View.OnClickLi
                 break;
             case Constants.MSG807:
                 if (btnResult == 1) {
-                    comHandler.sendMessageDelayed(comHandler.obtainMessage(type), 10);
+                    request(requestType, isShowLoading);
                 }
                 break;
             default:

+ 190 - 164
kneet_v3/src/main/java/com/ntels/kneet/v3/view/mainmore/SettingNameChange.java

@@ -6,37 +6,34 @@ package com.ntels.kneet.v3.view.mainmore;
 
 import com.google.gson.JsonObject;
 
-import android.app.Activity;
-import android.content.Intent;
-import android.content.res.Configuration;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.Message;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.widget.Toast;
-
 import com.ntels.kneet.v3.R;
 import com.ntels.kneet.v3.common.AppConfig;
 import com.ntels.kneet.v3.common.Constants;
-import com.ntels.kneet.v3.common.c_interface.OnDataSendToReslut;
-import com.ntels.kneet.v3.common.http.HttpSend;
-import com.ntels.kneet.v3.common.http.Response;
-import com.ntels.kneet.v3.common.http.RetrofitCallback;
+import com.ntels.kneet.v3.common.http.IHttpRequest;
 import com.ntels.kneet.v3.common.http.RetrofitClient;
 import com.ntels.kneet.v3.common.http.RetrofitService;
-import com.ntels.kneet.v3.common.util.Dlog;
 import com.ntels.kneet.v3.common.util.Util;
 import com.ntels.kneet.v3.common.widget.CustomActivity;
 import com.ntels.kneet.v3.model.BaseResponse;
 import com.ntels.kneet.v3.view.dialog.CustomDialog;
 
-import org.json.JSONObject;
+import android.app.Activity;
+import android.content.Intent;
+import android.content.res.Configuration;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.Toast;
 
 import java.io.IOException;
+import java.lang.annotation.Annotation;
 
-import retrofit2.Call;
-import retrofit2.Callback;
+import io.reactivex.android.schedulers.AndroidSchedulers;
+import io.reactivex.disposables.Disposable;
+import io.reactivex.schedulers.Schedulers;
+import okhttp3.ResponseBody;
+import retrofit2.Converter;
+import retrofit2.HttpException;
 
 /**
  * <pre>
@@ -49,174 +46,203 @@ import retrofit2.Callback;
  * </pre>
  */
 public class SettingNameChange extends CustomActivity implements View.OnClickListener,
-    CustomDialog.OnMsgAlterToResult {
+        CustomDialog.OnMsgAlterToResult, IHttpRequest {
 
-  private static final int MSG_COM_P_MEMBER_MEMBER_ID_UPDATE_FIELD = 1;
-  private static final String MEMBER_UPDATE_FIELD_NAME = "name";
+    private static final int MSG_COM_EXCEPTION = -1;
+    private static final int MSG_COM_P_MEMBER_MEMBER_ID_UPDATE_FIELD = 1;
+    private static final String MEMBER_UPDATE_FIELD_NAME = "name";
 
-  /*통신 관련*/
-  private int type = 0;
+    /*통신 관련*/
+    private int type = 0;
 
-  /*공통*/
-  private Activity act;
-  private AppConfig appConfig;
-  private Intent intent;
-  private Util util = new Util();
-  private CustomDialog customDialog = new CustomDialog();
-  private String nickname = "";
+    /*공통*/
+    private Activity act;
+    private AppConfig appConfig;
+    private Intent intent;
+    private Util util = new Util();
+    private CustomDialog customDialog = new CustomDialog();
+    private String nickname = "";
 
-  @Override
-  public void onCreate(Bundle savedInstanceState) {
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
 
-    super.onCreate(savedInstanceState);
+        super.onCreate(savedInstanceState);
 
-    act = SettingNameChange.this;
-    appConfig = (AppConfig) act.getApplicationContext();
-    customDialog.setOnMsgAlterToResultEvent(this);
+        act = SettingNameChange.this;
+        appConfig = (AppConfig) act.getApplicationContext();
+        customDialog.setOnMsgAlterToResultEvent(this);
 
-    View viewToLoad = LayoutInflater.from(act).inflate(R.layout.setting_name_change, null);
-    this.setContentView(viewToLoad);
+        View viewToLoad = LayoutInflater.from(act).inflate(R.layout.setting_name_change, null);
+        this.setContentView(viewToLoad);
 
-    util.getView(act, R.id.llBtn1).setOnClickListener(this);
-    util.getView(act, R.id.llBtn2).setOnClickListener(this);
+        util.getView(act, R.id.llBtn1).setOnClickListener(this);
+        util.getView(act, R.id.llBtn2).setOnClickListener(this);
 
-    setDisp();
-  }
+        setDisp();
+    }
 
-  /**
-   * UI display.
-   */
-  private void setDisp() {
+    /**
+     * UI display.
+     */
+    private void setDisp() {
 
-    util.getTextView(act, R.id.edtName).setText(appConfig.getNickname());
-  }
+        util.getTextView(act, R.id.edtName).setText(appConfig.getNickname());
+    }
 
-  @Override
-  public void onConfigurationChanged(Configuration newConfig) {
+    @Override
+    public void onConfigurationChanged(Configuration newConfig) {
 
-    super.onConfigurationChanged(newConfig);
-  }
+        super.onConfigurationChanged(newConfig);
+    }
+
+    @Override
+    public void onClick(View view) {
+
+        switch (view.getId()) {
+            case R.id.llBtn1:
+                nickname = util.getEditTextVal(act, R.id.edtName);
+                if (nickname.equals("")) {
+                    util.setShowToast(act, util.getString(act, R.string.layout_join_02)
+                            + util.getString(act, R.string.MSG902), Toast.LENGTH_SHORT);
+                    return;
+                }
+                view.setEnabled(false);
+                request(MSG_COM_P_MEMBER_MEMBER_ID_UPDATE_FIELD, true);
+                break;
+            case R.id.llBtn2:
+                onBackPressed();
+                break;
+            default:
+                break;
+        }
+    }
 
-  @Override
-  public void onClick(View view) {
+    /**
+     * Http request.
+     *
+     * @param requestType Request API type
+     * @param isLoading   If true dialog is show
+     */
+    @Override
+    public void request(int requestType, boolean isLoading) {
+        this.requestType = requestType;
+        isShowLoading = isLoading;
+        if (isLoading) {
+            showProgress();
+        }
+        switch (requestType) {
+            case MSG_COM_P_MEMBER_MEMBER_ID_UPDATE_FIELD:
+                compositeDisposable.add(requestMemberInfoUpdate());
+                break;
+        }
+    }
 
-    switch (view.getId()) {
-      case R.id.llBtn1:
-        nickname = util.getEditTextVal(act, R.id.edtName);
-        if (nickname.equals("")) {
-          util.setShowToast(act, util.getString(act, R.string.layout_join_02)
-              + util.getString(act, R.string.MSG902), Toast.LENGTH_SHORT);
-          return;
+    /**
+     * Http request response.
+     *
+     * @param requestType Request API type
+     * @param response    response data
+     */
+    @Override
+    public void onResponse(int requestType, Object response) {
+        dismissProgress();
+        switch (requestType) {
+            case MSG_COM_P_MEMBER_MEMBER_ID_UPDATE_FIELD:
+                util.setShowToast(act, util.getString(act, R.string.MSG843), Toast.LENGTH_SHORT);
+                intent = new Intent();
+                act.setResult(RESULT_OK, intent);
+                finish();
+                break;
         }
-        view.setEnabled(false);
-        comHandler.sendMessageDelayed(comHandler.obtainMessage(
-            MSG_COM_P_MEMBER_MEMBER_ID_UPDATE_FIELD), 10);
-        break;
-      case R.id.llBtn2:
-        onBackPressed();
-        break;
-      default:
-        break;
     }
-  }
 
-  Handler comHandler = new Handler(new IncomingHandlerCallBack());
+    /**
+     * Http request error.
+     *
+     * @param requestType request API type
+     * @param error       error data(ex> error code, error message)
+     */
+    @Override
+    public void onError(int requestType, Object error) {
+        dismissProgress();
+        switch (requestType) {
+            case MSG_COM_P_MEMBER_MEMBER_ID_UPDATE_FIELD:
+                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();
+                    customDialog.msgAlert(act, Constants.MSG807);
+                }
+                if ("401".equals(errorResponse.getErrCode())) {
+                    customDialog.msgAlert(act, Constants.MSG998, errorResponse.getErrMsg());
+                } else if ("401-106".equals(errorResponse.getErrCode())) {
+                    customDialog.msgAlert(act, Constants.MSG997, errorResponse.getErrMsg());
+                } else {
+                    customDialog.msgAlert(act, Constants.MSG000, errorResponse.getErrMsg());
+                }
+                break;
+            case MSG_COM_EXCEPTION:
+                ((Throwable) error).printStackTrace();
+                customDialog.msgAlert(act, Constants.MSG807);
+                break;
+            default:
+                customDialog.msgAlert(act, Constants.MSG807);
+                break;
+        }
+    }
 
-  class IncomingHandlerCallBack implements Handler.Callback {
+    /**
+     * 회원 이름 수정 요청.
+     */
+    private Disposable requestMemberInfoUpdate() {
+
+        JsonObject body = new JsonObject();
+        body.addProperty(Constants.HTTP_nickname, nickname);
+        return RetrofitService.getUserService().memberInfoUpdate(MEMBER_UPDATE_FIELD_NAME, body)
+                .subscribeOn(Schedulers.io())
+                .observeOn(AndroidSchedulers.mainThread())
+                .subscribe(aVoid -> onResponse(MSG_COM_P_MEMBER_MEMBER_ID_UPDATE_FIELD, aVoid),
+                        e -> {
+                            if (e instanceof HttpException) {
+                                onError(MSG_COM_P_MEMBER_MEMBER_ID_UPDATE_FIELD, e);
+                            } else {
+                                onError(MSG_COM_EXCEPTION, e);
+                            }
+                            util.getView(act, R.id.llBtn1).setEnabled(true);
+                        }
+                );
+    }
 
     @Override
-    public boolean handleMessage(Message msg) {
-
-      type = msg.what;
-      switch (msg.what) {
-        case MSG_COM_P_MEMBER_MEMBER_ID_UPDATE_FIELD:
-          requestMemberInfoUpdate();
-          break;
-        default:
-          break;
-      }
-      return true;
+    public void onBackPressed() {
+
+        intent = new Intent();
+        act.setResult(RESULT_CANCELED, intent);
+        finish();
     }
-  }
-
-  /**
-   * 회원 이름 수정 요청.
-   */
-  @SuppressWarnings("unchecked")
-  private void requestMemberInfoUpdate() {
-
-    JsonObject body = new JsonObject();
-    body.addProperty(Constants.HTTP_nickname, nickname);
-    Call<Void> memberInfoUpdateCall = RetrofitService.getUserService().memberInfoUpdate(MEMBER_UPDATE_FIELD_NAME, body);
-    memberInfoUpdateCall.enqueue(new RetrofitCallback(act, new Callback<Void>() {
-      @Override
-      public void onResponse(Call<Void> call, retrofit2.Response<Void> response) {
-        if (null != response) {
-          if (response.isSuccessful()) {
-            util.setShowToast(act, util.getString(act, R.string.MSG843), Toast.LENGTH_SHORT);
-            intent = new Intent();
-            act.setResult(RESULT_OK, intent);
-            finish();
-          } else {
-            BaseResponse errorResponse = null;
-            try {
-              errorResponse = (BaseResponse) RetrofitClient.getClient().responseBodyConverter(BaseResponse.class,
-                      BaseResponse.class.getAnnotations()).convert(response.errorBody());
-
-              if ("401".equals(errorResponse.getErrCode())) {
-                customDialog.msgAlert(act, Constants.MSG998, errorResponse.getErrMsg());
-              } else if ("401-106".equals(errorResponse.getErrCode())) {
-                customDialog.msgAlert(act, Constants.MSG997, errorResponse.getErrMsg());
-              } else {
-                customDialog.msgAlert(act, Constants.MSG000, errorResponse.getErrMsg());
-              }
-            } catch (IOException e) {
-              e.printStackTrace();
-              customDialog.msgAlert(act, Constants.MSG807);
-            }
-
-          }
-        } else {
-          customDialog.msgAlert(act, Constants.MSG807);
-        }
-        util.getView(act, R.id.llBtn1).setEnabled(true);
-      }
-
-      @Override
-      public void onFailure(Call<Void> call, Throwable t) {
-        t.printStackTrace();
-        customDialog.msgAlert(act, Constants.MSG807);
-        util.getView(act, R.id.llBtn1).setEnabled(true);
-      }
-    }));
-  }
-
-  @Override
-  public void onBackPressed() {
-
-    intent = new Intent();
-    act.setResult(RESULT_CANCELED, intent);
-    finish();
-  }
-
-  @Override
-  public void resultCustomDialogResponse(int msgId, int btnResult) {
-
-    switch (msgId) {
-
-      case Constants.MSG998:
-        util.callApp_Start(act, "LOGOUT");
-        break;
-      case Constants.MSG997:
-        util.callApp_Start(act, "HOME_RELOAD");
-        break;
-      case Constants.MSG807:
-        if (btnResult == 1) {
-          comHandler.sendMessageDelayed(comHandler.obtainMessage(type), 10);
+
+    @Override
+    public void resultCustomDialogResponse(int msgId, int btnResult) {
+
+        switch (msgId) {
+
+            case Constants.MSG998:
+                util.callApp_Start(act, "LOGOUT");
+                break;
+            case Constants.MSG997:
+                util.callApp_Start(act, "HOME_RELOAD");
+                break;
+            case Constants.MSG807:
+                if (btnResult == 1) {
+                    request(requestType, isShowLoading);
+                }
+                break;
+            default:
+                break;
         }
-        break;
-      default:
-        break;
     }
-  }
 }

+ 96 - 65
kneet_v3/src/main/java/com/ntels/kneet/v3/view/mainmore/SettingPasswordChange.java

@@ -7,9 +7,8 @@ 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;
-import com.ntels.kneet.v3.common.http.RetrofitCallback;
+import com.ntels.kneet.v3.common.http.IHttpRequest;
 import com.ntels.kneet.v3.common.http.RetrofitClient;
 import com.ntels.kneet.v3.common.http.RetrofitService;
 import com.ntels.kneet.v3.common.util.Util;
@@ -21,16 +20,19 @@ import android.app.Activity;
 import android.content.Intent;
 import android.content.res.Configuration;
 import android.os.Bundle;
-import android.os.Handler;
-import android.os.Message;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.widget.Toast;
 
 import java.io.IOException;
+import java.lang.annotation.Annotation;
 
-import retrofit2.Call;
-import retrofit2.Callback;
+import io.reactivex.android.schedulers.AndroidSchedulers;
+import io.reactivex.disposables.Disposable;
+import io.reactivex.schedulers.Schedulers;
+import okhttp3.ResponseBody;
+import retrofit2.Converter;
+import retrofit2.HttpException;
 
 /**
  * <pre>
@@ -43,8 +45,9 @@ import retrofit2.Callback;
  * </pre>
  */
 public class SettingPasswordChange extends CustomActivity implements View.OnClickListener,
-        CustomDialog.OnMsgAlterToResult {
+        CustomDialog.OnMsgAlterToResult, IHttpRequest {
 
+    private static final int MSG_COM_EXCEPTION = -1;
     private static final int MSG_COM_P_MEMBER_MEMBER_ID_UPDATE_FIELD = 1;
     private static final String MEMBER_UPDATE_FIELD_PASSWORD = "password";
 
@@ -102,8 +105,7 @@ public class SettingPasswordChange extends CustomActivity implements View.OnClic
                     return;
                 }
                 view.setEnabled(false);
-                comHandler.sendMessageDelayed(comHandler.obtainMessage(
-                        MSG_COM_P_MEMBER_MEMBER_ID_UPDATE_FIELD), 10);
+                request(MSG_COM_P_MEMBER_MEMBER_ID_UPDATE_FIELD, true);
                 break;
             case R.id.llBtn2:
                 onBackPressed();
@@ -113,77 +115,106 @@ public class SettingPasswordChange extends CustomActivity implements View.OnClic
         }
     }
 
-    Handler comHandler = new Handler(new IncomingHandlerCallBack());
-
-    class IncomingHandlerCallBack implements Handler.Callback {
+    /**
+     * Http request.
+     *
+     * @param requestType Request API type
+     * @param isLoading   If true dialog is show
+     */
+    @Override
+    public void request(int requestType, boolean isLoading) {
+        this.requestType = requestType;
+        isShowLoading = isLoading;
+        if (isLoading) {
+            showProgress();
+        }
+        switch (requestType) {
+            case MSG_COM_P_MEMBER_MEMBER_ID_UPDATE_FIELD:
+                compositeDisposable.add(requestMemberInfoUpdate());
+                break;
+        }
+    }
 
-        @Override
-        public boolean handleMessage(Message msg) {
+    /**
+     * Http request response.
+     *
+     * @param requestType Request API type
+     * @param response    response data
+     */
+    @Override
+    public void onResponse(int requestType, Object response) {
+        dismissProgress();
+        switch (requestType) {
+            case MSG_COM_P_MEMBER_MEMBER_ID_UPDATE_FIELD:
+                util.setShowToast(act, util.getString(act, R.string.MSG849), Toast.LENGTH_SHORT);
+                intent = new Intent();
+                act.setResult(RESULT_OK, intent);
+                finish();
+                break;
+        }
+    }
 
-            type = msg.what;
-            switch (msg.what) {
-                case MSG_COM_P_MEMBER_MEMBER_ID_UPDATE_FIELD:
-                    requestMemberInfoUpdate();
-                    break;
-                default:
-                    break;
-            }
-            return true;
+    /**
+     * Http request error.
+     *
+     * @param requestType request API type
+     * @param error       error data(ex> error code, error message)
+     */
+    @Override
+    public void onError(int requestType, Object error) {
+        dismissProgress();
+        switch (requestType) {
+            case MSG_COM_P_MEMBER_MEMBER_ID_UPDATE_FIELD:
+                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();
+                    customDialog.msgAlert(act, Constants.MSG807);
+                }
+                if ("401".equals(errorResponse.getErrCode())) {
+                    customDialog.msgAlert(act, Constants.MSG998, errorResponse.getErrMsg());
+                } else if ("401-106".equals(errorResponse.getErrCode())) {
+                    customDialog.msgAlert(act, Constants.MSG997, errorResponse.getErrMsg());
+                } else {
+                    customDialog.msgAlert(act, Constants.MSG000, errorResponse.getErrMsg());
+                }
+                break;
+            case MSG_COM_EXCEPTION:
+                customDialog.msgAlert(act, Constants.MSG807);
+                break;
+            default:
+                customDialog.msgAlert(act, Constants.MSG807);
+                break;
         }
     }
 
     /**
      * 회원 비밀번호 수정 요청.
      */
-    @SuppressWarnings("unchecked")
-    private void requestMemberInfoUpdate() {
+    private Disposable requestMemberInfoUpdate() {
 
         JsonObject body = new JsonObject();
         body.addProperty(Constants.HTTP_old_password, oldPassword);
         body.addProperty(Constants.HTTP_new_password, newPassword);
         body.addProperty(Constants.HTTP_confirm_password, confirmPassword);
-        Call<Void> memberInfoUpdateCall = RetrofitService.getUserService().memberInfoUpdate(MEMBER_UPDATE_FIELD_PASSWORD, body);
-        memberInfoUpdateCall.enqueue(new RetrofitCallback(act, new Callback<Void>() {
-            @Override
-            public void onResponse(Call<Void> call, retrofit2.Response<Void> response) {
-                if (null != response) {
-                    if (response.isSuccessful()) {
-                        util.setShowToast(act, util.getString(act, R.string.MSG849), Toast.LENGTH_SHORT);
-                        intent = new Intent();
-                        act.setResult(RESULT_OK, intent);
-                        finish();
-                    } else {
-                        BaseResponse errorResponse = null;
-                        try {
-                            errorResponse = (BaseResponse) RetrofitClient.getClient().responseBodyConverter(BaseResponse.class,
-                                    BaseResponse.class.getAnnotations()).convert(response.errorBody());
-
-                            if ("401".equals(errorResponse.getErrCode())) {
-                                customDialog.msgAlert(act, Constants.MSG998, errorResponse.getErrMsg());
-                            } else if ("401-106".equals(errorResponse.getErrCode())) {
-                                customDialog.msgAlert(act, Constants.MSG997, errorResponse.getErrMsg());
+
+        return RetrofitService.getUserService().memberInfoUpdate(MEMBER_UPDATE_FIELD_PASSWORD, body)
+                .subscribeOn(Schedulers.io())
+                .observeOn(AndroidSchedulers.mainThread())
+                .subscribe(aVoid -> onResponse(MSG_COM_P_MEMBER_MEMBER_ID_UPDATE_FIELD, aVoid),
+                        e -> {
+                            if (e instanceof HttpException) {
+                                onError(MSG_COM_P_MEMBER_MEMBER_ID_UPDATE_FIELD, e);
                             } else {
-                                customDialog.msgAlert(act, Constants.MSG000, errorResponse.getErrMsg());
+                                onError(MSG_COM_EXCEPTION, e);
                             }
-                        } catch (IOException e) {
-                            e.printStackTrace();
-                            customDialog.msgAlert(act, Constants.MSG807);
+                            util.getView(act, R.id.llBtn1).setEnabled(true);
                         }
-
-                    }
-                } else {
-                    customDialog.msgAlert(act, Constants.MSG807);
-                }
-                util.getView(act, R.id.llBtn1).setEnabled(true);
-            }
-
-            @Override
-            public void onFailure(Call<Void> call, Throwable t) {
-                t.printStackTrace();
-                customDialog.msgAlert(act, Constants.MSG807);
-                util.getView(act, R.id.llBtn1).setEnabled(true);
-            }
-        }));
+                );
     }
 
     @Override
@@ -207,7 +238,7 @@ public class SettingPasswordChange extends CustomActivity implements View.OnClic
                 break;
             case Constants.MSG807:
                 if (btnResult == 1) {
-                    comHandler.sendMessageDelayed(comHandler.obtainMessage(type), 10);
+                    request(requestType, isShowLoading);
                 }
                 break;
             default:

+ 94 - 124
kneet_v3/src/main/java/com/ntels/kneet/v3/view/mainmore/SettingPasswordCheck.java

@@ -7,7 +7,7 @@ package com.ntels.kneet.v3.view.mainmore;
 import com.ntels.kneet.v3.R;
 import com.ntels.kneet.v3.common.AppConfig;
 import com.ntels.kneet.v3.common.Constants;
-import com.ntels.kneet.v3.common.http.RetrofitCallback;
+import com.ntels.kneet.v3.common.http.IHttpRequest;
 import com.ntels.kneet.v3.common.http.RetrofitClient;
 import com.ntels.kneet.v3.common.http.RetrofitService;
 import com.ntels.kneet.v3.common.util.Util;
@@ -19,16 +19,18 @@ import android.app.Activity;
 import android.content.Intent;
 import android.content.res.Configuration;
 import android.os.Bundle;
-import android.os.Handler;
-import android.os.Message;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.widget.Toast;
 
 import java.io.IOException;
+import java.lang.annotation.Annotation;
 
-import retrofit2.Call;
-import retrofit2.Callback;
+import io.reactivex.android.schedulers.AndroidSchedulers;
+import io.reactivex.schedulers.Schedulers;
+import okhttp3.ResponseBody;
+import retrofit2.Converter;
+import retrofit2.HttpException;
 
 /**
  * <pre>
@@ -41,13 +43,11 @@ import retrofit2.Callback;
  * </pre>
  */
 public class SettingPasswordCheck extends CustomActivity implements View.OnClickListener,
-        CustomDialog.OnMsgAlterToResult {
+        CustomDialog.OnMsgAlterToResult, IHttpRequest {
 
+    private static final int MSG_COM_EXCEPTION = -1;
     private static final int MSG_COM_G_MEMBER_MEMBER_ID = 1;
 
-    /*통신 관련*/
-    private int tag = 0;
-
     /*공통*/
     private Activity act;
     private AppConfig appConfig;
@@ -98,7 +98,7 @@ public class SettingPasswordCheck extends CustomActivity implements View.OnClick
                 }
 
                 view.setEnabled(false);
-                comHandler.sendMessageDelayed(comHandler.obtainMessage(MSG_COM_G_MEMBER_MEMBER_ID), 10);
+                request(MSG_COM_G_MEMBER_MEMBER_ID, true);
                 break;
             case R.id.llBtn2:
                 onBackPressed();
@@ -108,135 +108,105 @@ public class SettingPasswordCheck extends CustomActivity implements View.OnClick
         }
     }
 
-    Handler comHandler = new Handler(new IncomingHandlerCallBack());
-
-    class IncomingHandlerCallBack implements Handler.Callback {
-
-        @Override
-        public boolean handleMessage(Message msg) {
-
-            tag = msg.what;
-            switch (msg.what) {
-                case MSG_COM_G_MEMBER_MEMBER_ID:
-                    requestCheckPassword();
-                    break;
-                default:
-                    break;
-            }
-            return true;
-        }
-    }
-
     /**
-     * (기존)비밀번호 확인(비밀번호 정보를 확인한다) 요청.
+     * Http request.
+     *
+     * @param requestType Request API type
+     * @param isLoading   If true dialog is show
      */
-    @SuppressWarnings("unchecked")
-    private void requestCheckPassword() {
-        Call<Void> checkPasswordCall = RetrofitService.getUserService().checkPassword(oldPassword);
-        checkPasswordCall.enqueue(new RetrofitCallback(act, new Callback<Void>() {
-            @Override
-            public void onResponse(Call<Void> call, retrofit2.Response<Void> response) {
-                if (null != response) {
-                    if (response.isSuccessful()) {
-                        if ("1".equals(callType)) {
-                            intent = new Intent(act, SettingPasswordChange.class);
-                            intent.putExtra(Constants.EXTRA_PASSWORD, oldPassword);
-                            util.callActivityForResultNoAnim(act, intent, Constants.ACT_SETTING_PASSWORD_CHANGE);
-                        }
-                    } else {
-                        BaseResponse errorResponse;
-                        try {
-                            errorResponse = (BaseResponse) RetrofitClient.getClient().responseBodyConverter(BaseResponse.class,
-                                    BaseResponse.class.getAnnotations()).convert(response.errorBody());
-
-                            if ("401".equals(errorResponse.getErrCode())) {
-                                customDialog.msgAlert(act, Constants.MSG998, errorResponse.getErrMsg());
-                            } else if ("401-106".equals(errorResponse.getErrCode())) {
-                                customDialog.msgAlert(act, Constants.MSG997, errorResponse.getErrMsg());
-                            } else {
-                                customDialog.msgAlert(act, Constants.MSG000, errorResponse.getErrMsg());
-                            }
-                        } catch (IOException e) {
-                            e.printStackTrace();
-                            customDialog.msgAlert(act, Constants.MSG807);
-                        }
-
-                    }
-                } else {
-                    customDialog.msgAlert(act, Constants.MSG807);
-                }
-                util.getView(act, R.id.llBtn1).setEnabled(true);
-            }
-
-            @Override
-            public void onFailure(Call<Void> call, Throwable t) {
-                t.printStackTrace();
-                customDialog.msgAlert(act, Constants.MSG807);
-                util.getView(act, R.id.llBtn1).setEnabled(true);
-            }
-        }));
+    @Override
+    public void request(int requestType, boolean isLoading) {
+        this.requestType = requestType;
+        isShowLoading = isLoading;
+        if (isLoading) {
+            showProgress();
+        }
+        switch (requestType) {
+            case MSG_COM_G_MEMBER_MEMBER_ID:
+                requestCheckPassword();
+                break;
+        }
     }
 
     /**
-     * (기존)비밀번호 확인(비밀번호 정보를 확인한다) 요청.
+     * Http request response.
+     *
+     * @param requestType Request API type
+     * @param response    response data
      */
-    /*private void sendGetMemberPassword() {
-
-        try {
-            HttpSend httpSend = new HttpSend(act);
-            httpSend.setOnDataSendToReslutEvent(new OnDataSendToReslut() {
-                @Override
-                public void resultResponse(Response result) {
-
-                    resultGetMemberPassword(result);
+    @Override
+    public void onResponse(int requestType, Object response) {
+        dismissProgress();
+        switch (requestType) {
+            case MSG_COM_G_MEMBER_MEMBER_ID:
+                if ("1".equals(callType)) {
+                    intent = new Intent(act, SettingPasswordChange.class);
+                    intent.putExtra(Constants.EXTRA_PASSWORD, oldPassword);
+                    util.callActivityForResultNoAnim(act, intent, Constants.ACT_SETTING_PASSWORD_CHANGE);
                 }
-            });
-
-            //공통 변수 입력
-            httpSend.G_member_member_id(appConfig.getLogin_Member_Id(), oldPassword);
-        } catch (Exception ex) {
-            ex.printStackTrace();
+                util.getView(act, R.id.llBtn1).setEnabled(true);
+                break;
         }
-    }*/
+    }
 
     /**
-     * {@link #sendGetMemberPassword()} 요청 결과.
+     * Http request error.
      *
-     * @param response 결과 data
+     * @param requestType request API type
+     * @param error       error data(ex> error code, error message)
      */
-    /*private void resultGetMemberPassword(Response response) {
-
-        try {
-            if (response.getStatusCode() == 200) {
-                if (callType.equals("1")) {
-                    intent = new Intent(act, SettingPasswordChange.class);
-                    intent.putExtra(Constants.EXTRA_PASSWORD, oldPassword);
-                    util.callActivityForResultNoAnim(act, intent, Constants.ACT_SETTING_PASSWORD_CHANGE);
+    @Override
+    public void onError(int requestType, Object error) {
+        dismissProgress();
+        switch (requestType) {
+            case MSG_COM_G_MEMBER_MEMBER_ID:
+                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();
+                    customDialog.msgAlert(act, Constants.MSG807);
                 }
-            } else {
-                JSONObject joResult = new JSONObject(response.getContent());
-                Dlog.v(joResult.toString());
-                String errorCode = util.null2string(joResult.get(Constants.HTTP_err_code));
-                String errorMsg = util.null2string(joResult.get(Constants.HTTP_err_msg));
-
-                if (errorCode.equals("401")) {
-                    customDialog.msgAlert(act, Constants.MSG998, errorMsg);
-                } else if (errorCode.equals("401-106")) {
-                    customDialog.msgAlert(act, Constants.MSG997, errorMsg);
+                if ("401".equals(errorResponse.getErrCode())) {
+                    customDialog.msgAlert(act, Constants.MSG998, errorResponse.getErrMsg());
+                } else if ("401-106".equals(errorResponse.getErrCode())) {
+                    customDialog.msgAlert(act, Constants.MSG997, errorResponse.getErrMsg());
                 } else {
-                    customDialog.msgAlert(act, Constants.MSG000, errorMsg);
+                    customDialog.msgAlert(act, Constants.MSG000, errorResponse.getErrMsg());
                 }
-            }
-        } catch (Exception ex) {
-            ex.printStackTrace();
-            customDialog.msgAlert(act, Constants.MSG807);
-        }
-        try {
-            util.getView(act, R.id.llBtn1).setEnabled(true);
-        } catch (Exception ex) {
-            ex.printStackTrace();
+                break;
+            case MSG_COM_EXCEPTION:
+                customDialog.msgAlert(act, Constants.MSG807);
+                break;
+            default:
+                customDialog.msgAlert(act, Constants.MSG807);
+                break;
         }
-    }*/
+    }
+
+    /**
+     * (기존)비밀번호 확인(비밀번호 정보를 확인한다) 요청.
+     */
+    @SuppressWarnings("unchecked")
+    private void requestCheckPassword() {
+        RetrofitService.getUserService().checkPassword(oldPassword)
+                .subscribeOn(Schedulers.io())
+                .observeOn(AndroidSchedulers.mainThread())
+                .subscribe(
+                        aVoid -> onResponse(MSG_COM_G_MEMBER_MEMBER_ID, aVoid),
+                        e -> {
+                            if (e instanceof HttpException) {
+                                onError(MSG_COM_G_MEMBER_MEMBER_ID, e);
+                            } else {
+                                onError(MSG_COM_EXCEPTION, e);
+                            }
+                            util.getView(act, R.id.llBtn1).setEnabled(true);
+                        }
+                );
+    }
 
     @Override
     public void onBackPressed() {
@@ -293,7 +263,7 @@ public class SettingPasswordCheck extends CustomActivity implements View.OnClick
                 break;
             case Constants.MSG807:
                 if (btnResult == 1) {
-                    comHandler.sendMessageDelayed(comHandler.obtainMessage(tag), 10);
+                    request(requestType, isShowLoading);
                 }
                 break;
             default:

+ 1 - 1
kneet_v3/src/main/java/com/ntels/kneet/v3/view/rules/FragmentRules.java

@@ -484,7 +484,7 @@ public class FragmentRules extends Fragment implements View.OnClickListener,
           sendDeleteRule();
           break;
         case MSG_COM_P_RULES_HOMEGRP_RULE_ID_STATUS:
-          //dialog_show();
+          //showProgress();
           sendPutRuleStatus();
           break;
 

+ 1 - 1
kneet_v3/src/main/java/com/ntels/kneet/v3/view/rules/RulesThingsSelect.java

@@ -464,7 +464,7 @@ public class RulesThingsSelect extends CustomActivity implements View.OnClickLis
       type = msg.what;
       switch (msg.what) {
         case MSG_COM_G_RULES_ITEM_DEVICES_ITEM_TYPE_CODE:
-          //dialog_show();
+          //showProgress();
           sendGetActionDevices();
           break;
 

+ 110 - 49
kneet_v3/src/main/java/com/ntels/kneet/v3/view/things/FragmentThings.java

@@ -13,8 +13,8 @@ import com.ntels.kneet.v3.common.c_interface.ListInterface;
 import com.ntels.kneet.v3.common.c_interface.MainInterface;
 import com.ntels.kneet.v3.common.c_interface.OnDataSendToReslut;
 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;
@@ -25,6 +25,7 @@ import com.ntels.kneet.v3.common.websocket.OnWebSocketResponse;
 import com.ntels.kneet.v3.common.websocket.WebSocketService;
 import com.ntels.kneet.v3.model.BaseResponse;
 import com.ntels.kneet.v3.model.things.Device;
+import com.ntels.kneet.v3.view.Main;
 import com.ntels.kneet.v3.view.dialog.CustomDialog;
 import com.ntels.kneet.v3.view.dialog.DialogCustomList;
 
@@ -55,14 +56,19 @@ import android.view.ViewGroup;
 import android.widget.Toast;
 
 import java.io.IOException;
+import java.lang.annotation.Annotation;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 
+import io.reactivex.android.schedulers.AndroidSchedulers;
+import io.reactivex.disposables.Disposable;
+import io.reactivex.schedulers.Schedulers;
 import jp.wasabeef.recyclerview.adapters.AlphaInAnimationAdapter;
 import jp.wasabeef.recyclerview.adapters.ScaleInAnimationAdapter;
-import retrofit2.Call;
-import retrofit2.Callback;
+import okhttp3.ResponseBody;
+import retrofit2.Converter;
+import retrofit2.HttpException;
 
 /**
  * <pre>
@@ -75,8 +81,7 @@ import retrofit2.Callback;
  * </pre>
  */
 public class FragmentThings extends Fragment implements View.OnClickListener,
-        CustomDialog.OnMsgAlterToResult,
-        ListInterface {
+        CustomDialog.OnMsgAlterToResult, ListInterface, IHttpRequest {
     private static final String TAG = FragmentThings.class.getSimpleName();
 
     /*툴바 관련*/
@@ -86,6 +91,7 @@ public class FragmentThings extends Fragment implements View.OnClickListener,
 //    private ArrayList<HashMap<String, Object>> alTotalList = new ArrayList<HashMap<String, Object>>();
     private List<Device> mDeviceList = new ArrayList<>();
     private int type = 0;
+    private static final int MSG_COM_EXCEPTION = -1;
     private static final int MSG_COM_G_DEVICES = 1;
     private static final int MSG_COM_WS_NODE_COMMAND = 2;
     private static final int MSG_COM_WS_NODE_RELOAD = 3;
@@ -871,55 +877,109 @@ public class FragmentThings extends Fragment implements View.OnClickListener,
     }
 
     /**
-     * 장치 리스트 조회(회원의 장치 목록을 조회한다.)
+     * Http request.
+     *
+     * @param requestType Request API type
+     * @param isLoading   If true dialog is show
      */
-    @SuppressWarnings("unchecked")
-    private void requestDevices() {
-        Call<List<Device>> devicesCall = RetrofitService.getThingsService().devices();
-        devicesCall.enqueue(new RetrofitCallback(act, new Callback<List<Device>>() {
-            @Override
-            public void onResponse(Call<List<Device>> call, retrofit2.Response<List<Device>> response) {
-                loading = false;
-                if (null != response) {
-                    if (response.isSuccessful()) {
-                        mDeviceList.clear();
-                        mDeviceList.addAll(response.body());
-                        util.getTextView(toolbar, R.id.tvToolbarTitle2).setText("");
-                        if (mDeviceList.size() > 0) {
-                            util.getTextView(toolbar, R.id.tvToolbarTitle2).setText(mDeviceList.size() + "");
-                            setHomeHubStateAll();
-                        }
-                    } else {
-                        BaseResponse errorResponse = null;
-                        try {
-                            errorResponse = (BaseResponse) RetrofitClient.getClient().responseBodyConverter(BaseResponse.class,
-                                    BaseResponse.class.getAnnotations()).convert(response.errorBody());
-                        } catch (IOException e) {
-                            e.printStackTrace();
-                            customDialog.msgAlert(act, Constants.MSG807);
-                        }
-                        if ("401".equals(errorResponse.getErrCode())) {
-                            customDialog.msgAlert(act, Constants.MSG998, errorResponse.getErrMsg());
-                        } else if ("401-106".equals(errorResponse.getErrCode())) {
-                            customDialog.msgAlert(act, Constants.MSG997, errorResponse.getErrMsg());
-                        } else {
-                            customDialog.msgAlert(act, Constants.MSG000, errorResponse.getErrMsg());
-                        }
+    @Override
+    public void request(int requestType, boolean isLoading) {
+        ((Main) getActivity()).requestType = requestType;
+        ((Main) getActivity()).isShowLoading = isLoading;
+        if (isLoading) {
+            ((Main) getActivity()).showProgress();
+        }
+        switch (requestType) {
+            case MSG_COM_G_DEVICES:
+                ((Main) getActivity()).compositeDisposable.add(requestDevices());
+                break;
+        }
+
+    }
+
+    /**
+     * Http request response.
+     *
+     * @param requestType Request API type
+     * @param response    response data
+     */
+    @Override
+    public void onResponse(int requestType, Object response) {
+        ((Main) getActivity()).dismissProgress();
+        switch (requestType) {
+            case MSG_COM_G_DEVICES:
+                if (response instanceof List) {
+                    mDeviceList.clear();
+                    mDeviceList.addAll((List<Device>) response);
+                    util.getTextView(toolbar, R.id.tvToolbarTitle2).setText("");
+                    if (mDeviceList.size() > 0) {
+                        util.getTextView(toolbar, R.id.tvToolbarTitle2).setText(mDeviceList.size() + "");
+                        setHomeHubStateAll();
                     }
-                } else {
-                    customDialog.msgAlert(act, Constants.MSG807);
                 }
+                loading = false;
                 swipeRefreshLayout.setRefreshing(false);
-            }
+                break;
+        }
+    }
 
-            @Override
-            public void onFailure(Call<List<Device>> call, Throwable t) {
-                t.printStackTrace();
-                loading = false;
+    /**
+     * Http request error.
+     *
+     * @param requestType request API type
+     * @param error       error data(ex> error code, error message)
+     */
+    @Override
+    public void onError(int requestType, Object error) {
+        ((Main) getActivity()).dismissProgress();
+        loading = false;
+        swipeRefreshLayout.setRefreshing(false);
+        switch (requestType) {
+            case MSG_COM_G_DEVICES:
+                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();
+                    customDialog.msgAlert(act, Constants.MSG807);
+                }
+                if ("401".equals(errorResponse.getErrCode())) {
+                    customDialog.msgAlert(act, Constants.MSG998, errorResponse.getErrMsg());
+                } else if ("401-106".equals(errorResponse.getErrCode())) {
+                    customDialog.msgAlert(act, Constants.MSG997, errorResponse.getErrMsg());
+                } else {
+                    customDialog.msgAlert(act, Constants.MSG000, errorResponse.getErrMsg());
+                }
+                break;
+            case MSG_COM_EXCEPTION:
                 customDialog.msgAlert(act, Constants.MSG807);
-                swipeRefreshLayout.setRefreshing(false);
-            }
-        }, !swipeRefreshLayout.isRefreshing()));
+                break;
+            default:
+                customDialog.msgAlert(act, Constants.MSG807);
+                break;
+        }
+    }
+
+    /**
+     * 장치 리스트 조회(회원의 장치 목록을 조회한다.)
+     */
+    private Disposable requestDevices() {
+
+        return RetrofitService.getThingsService().devices()
+                .subscribeOn(Schedulers.io())
+                .observeOn(AndroidSchedulers.mainThread())
+                .subscribe(devices -> onResponse(MSG_COM_G_DEVICES, devices),
+                        e -> {
+                            if (e instanceof HttpException) {
+                                onError(MSG_COM_G_DEVICES, e);
+                            } else {
+                                onError(MSG_COM_EXCEPTION, e);
+                            }
+                        }
+                );
     }
 
     /**
@@ -1172,7 +1232,8 @@ public class FragmentThings extends Fragment implements View.OnClickListener,
 
         loading = true;
         if (setHomeHubStateList()) {
-            comHandler.sendMessageDelayed(comHandler.obtainMessage(MSG_COM_G_DEVICES), Constants.HANDLER_DELAY_MILLIS);
+//            comHandler.sendMessageDelayed(comHandler.obtainMessage(MSG_COM_G_DEVICES), Constants.HANDLER_DELAY_MILLIS);
+            request(MSG_COM_G_DEVICES, !swipeRefreshLayout.isRefreshing());
         }
     }
 

+ 122 - 64
kneet_v3/src/main/java/com/ntels/kneet/v3/view/things/ThingsDetail.java

@@ -8,6 +8,7 @@ import com.ntels.kneet.v3.R;
 import com.ntels.kneet.v3.common.AppConfig;
 import com.ntels.kneet.v3.common.Constants;
 import com.ntels.kneet.v3.common.c_interface.ListInterface;
+import com.ntels.kneet.v3.common.http.IHttpRequest;
 import com.ntels.kneet.v3.common.http.RetrofitCallback;
 import com.ntels.kneet.v3.common.http.RetrofitClient;
 import com.ntels.kneet.v3.common.http.RetrofitService;
@@ -49,12 +50,19 @@ import android.widget.LinearLayout;
 import android.widget.Toast;
 
 import java.io.IOException;
+import java.lang.annotation.Annotation;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 
+import io.reactivex.android.schedulers.AndroidSchedulers;
+import io.reactivex.disposables.Disposable;
+import io.reactivex.schedulers.Schedulers;
+import okhttp3.ResponseBody;
 import retrofit2.Call;
 import retrofit2.Callback;
+import retrofit2.Converter;
+import retrofit2.HttpException;
 
 /**
  * <pre>
@@ -66,10 +74,12 @@ import retrofit2.Callback;
  * 6. Comment   :   Initialize
  * </pre>
  */
-public class ThingsDetail extends CustomActionBarActivity implements View.OnClickListener, CustomDialog.OnMsgAlterToResult, ListInterface {
+public class ThingsDetail extends CustomActionBarActivity implements View.OnClickListener, CustomDialog.OnMsgAlterToResult,
+        ListInterface, IHttpRequest {
 
     private static final String TAG = ThingsDetail.class.getSimpleName();
 
+    private static final int MSG_COM_EXCEPTION = -1;
     private static final int MSG_COM_G_DEVICES_DEVICE_ID = 1;
     private static final int MSG_COM_WS_NODE_COMMAND = 2;
 
@@ -439,7 +449,8 @@ public class ThingsDetail extends CustomActionBarActivity implements View.OnClic
 
                 if (!mIsLoading) {
                     mIsLoading = true;
-                    comHandler.sendMessageDelayed(comHandler.obtainMessage(MSG_COM_G_DEVICES_DEVICE_ID), 10);
+//                    comHandler.sendMessageDelayed(comHandler.obtainMessage(MSG_COM_G_DEVICES_DEVICE_ID), 10);
+                    request(MSG_COM_G_DEVICES_DEVICE_ID, !mSwipeRefreshLayout.isRefreshing());
                 }
             }
         });
@@ -494,7 +505,8 @@ public class ThingsDetail extends CustomActionBarActivity implements View.OnClic
 
         setHomeHubStateTitle();
         if (setHomeHubStateList()) {
-            comHandler.sendMessageDelayed(comHandler.obtainMessage(MSG_COM_G_DEVICES_DEVICE_ID), 10);
+//            comHandler.sendMessageDelayed(comHandler.obtainMessage(MSG_COM_G_DEVICES_DEVICE_ID), 10);
+            request(MSG_COM_G_DEVICES_DEVICE_ID, !mSwipeRefreshLayout.isRefreshing());
         }
     }
 
@@ -543,71 +555,115 @@ public class ThingsDetail extends CustomActionBarActivity implements View.OnClic
     }
 
     /**
-     * 장치 상세조회(해당 장치의 상세 정보를 조회한다. (장치가 보유한 모든 커맨드 클래스 리스트를 보여준다)) 요청.
+     * Http request.
+     *
+     * @param requestType Request API type
+     * @param isLoading   If true dialog is show
      */
-    @SuppressWarnings("unchecked")
-    private void requestDeviceDetail() {
-        Call<DeviceDetail> deviceDetailCall = RetrofitService.getThingsService().deviceDetail(mDeviceId, mNodeId);
-        deviceDetailCall.enqueue(new RetrofitCallback(mActivity, new Callback<DeviceDetail>() {
-            @Override
-            public void onResponse(Call<DeviceDetail> call, retrofit2.Response<DeviceDetail> response) {
-                if (null != response) {
-                    if (response.isSuccessful()) {
-                        DeviceDetail deviceDetail = response.body();
-
-                        util.getImageView(mActivity, R.id.ivThingsIcon).setImageResource(util.getImageId(
-                                mActivity, "img_" + deviceDetail.getDeviceclassTypeId() + "_rule"));
-                        util.getTextView(mActivity, R.id.tvThingsName).setText(deviceDetail.getDeviceName());
-
-                        mTotalList.clear();
-                        mTotalList.addAll(deviceDetail.getCmdclsList());
-                        LogUtil.i(TAG, "cmdclsList : " + mTotalList.toString());
-                        if (mTotalList.size() > 0) {
-                            for (CommandClass cc : mTotalList) {
-                                cc.setDeviceId(deviceDetail.getDeviceId());
-                                cc.setNodeId(deviceDetail.getNodeId());
-                                cc.setDeviceMfId(deviceDetail.getDeviceMfId());
-                                cc.setOnlineState(deviceDetail.getOnlineState());
-                                cc.setDeviceName(deviceDetail.getDeviceName());
-                                LogUtil.i(TAG, "cc : " + cc.toString());
-                            }
-                        }
+    @Override
+    public void request(int requestType, boolean isLoading) {
+        this.requestType = requestType;
+        isShowLoading = isLoading;
+        if (isLoading) {
+            showProgress();
+        }
+        switch (requestType) {
+            case MSG_COM_G_DEVICES_DEVICE_ID:
+                compositeDisposable.add(requestDeviceDetail());
+                break;
+        }
+    }
 
-                        //disp node
-                        setNodeDisp();
-                        mIsLoading = false;
-                        setHomeHubStateAll();
-                        mSwipeRefreshLayout.setRefreshing(false);
-                    } else {
-                        BaseResponse errorResponse = null;
-                        try {
-                            errorResponse = (BaseResponse) RetrofitClient.getClient().responseBodyConverter(BaseResponse.class,
-                                    BaseResponse.class.getAnnotations()).convert(response.errorBody());
-                        } catch (IOException e) {
-                            e.printStackTrace();
-                            customDialog.msgAlert(mActivity, Constants.MSG807);
-                        }
-                        if ("401".equals(errorResponse.getErrCode())) {
-                            customDialog.msgAlert(mActivity, Constants.MSG998, errorResponse.getErrMsg());
-                        } else if ("401-106".equals(errorResponse.getErrCode())) {
-                            customDialog.msgAlert(mActivity, Constants.MSG997, errorResponse.getErrMsg());
-                        } else {
-                            customDialog.msgAlert(mActivity, Constants.MSG000, errorResponse.getErrMsg());
-                        }
+    /**
+     * Http request response.
+     *
+     * @param requestType Request API type
+     * @param response    response data
+     */
+    @Override
+    public void onResponse(int requestType, Object response) {
+        dismissProgress();
+        switch (requestType) {
+            case MSG_COM_G_DEVICES_DEVICE_ID:
+                DeviceDetail deviceDetail = (DeviceDetail) response;
+
+                util.getImageView(mActivity, R.id.ivThingsIcon).setImageResource(util.getImageId(
+                        mActivity, "img_" + deviceDetail.getDeviceclassTypeId() + "_rule"));
+                util.getTextView(mActivity, R.id.tvThingsName).setText(deviceDetail.getDeviceName());
+
+                mTotalList.clear();
+                mTotalList.addAll(deviceDetail.getCmdclsList());
+                LogUtil.i(TAG, "cmdclsList : " + mTotalList.toString());
+                if (mTotalList.size() > 0) {
+                    for (CommandClass cc : mTotalList) {
+                        cc.setDeviceId(deviceDetail.getDeviceId());
+                        cc.setNodeId(deviceDetail.getNodeId());
+                        cc.setDeviceMfId(deviceDetail.getDeviceMfId());
+                        cc.setOnlineState(deviceDetail.getOnlineState());
+                        cc.setDeviceName(deviceDetail.getDeviceName());
+                        LogUtil.i(TAG, "cc : " + cc.toString());
                     }
-                } else {
-                    customDialog.msgAlert(mActivity, Constants.MSG807);
                 }
+
+                //disp node
+                setNodeDisp();
+                mIsLoading = false;
+                setHomeHubStateAll();
                 mSwipeRefreshLayout.setRefreshing(false);
-            }
+                break;
+        }
+    }
 
-            @Override
-            public void onFailure(Call<DeviceDetail> call, Throwable t) {
-                t.printStackTrace();
+    /**
+     * Http request error.
+     *
+     * @param requestType request API type
+     * @param error       error data(ex> error code, error message)
+     */
+    @Override
+    public void onError(int requestType, Object error) {
+        dismissProgress();
+        mSwipeRefreshLayout.setRefreshing(false);
+        switch (requestType) {
+            case MSG_COM_G_DEVICES_DEVICE_ID:
+                ResponseBody body = ((HttpException) error).response().errorBody();
+                Converter<ResponseBody, BaseResponse> errorConverter =
+                        RetrofitClient.getClient().responseBodyConverter(BaseResponse.class, new Annotation[0]);
+                BaseResponse errorResponse = null;
+
+                if ("401".equals(errorResponse.getErrCode())) {
+                    customDialog.msgAlert(mActivity, Constants.MSG998, errorResponse.getErrMsg());
+                } else if ("401-106".equals(errorResponse.getErrCode())) {
+                    customDialog.msgAlert(mActivity, Constants.MSG997, errorResponse.getErrMsg());
+                } else {
+                    customDialog.msgAlert(mActivity, Constants.MSG000, errorResponse.getErrMsg());
+                }
+                break;
+            case MSG_COM_EXCEPTION:
                 customDialog.msgAlert(mActivity, Constants.MSG807);
-                mSwipeRefreshLayout.setRefreshing(false);
-            }
-        }, !mSwipeRefreshLayout.isRefreshing()));
+                break;
+            default:
+                customDialog.msgAlert(mActivity, Constants.MSG807);
+                break;
+        }
+    }
+
+    /**
+     * 장치 상세조회(해당 장치의 상세 정보를 조회한다. (장치가 보유한 모든 커맨드 클래스 리스트를 보여준다)) 요청.
+     */
+    private Disposable requestDeviceDetail() {
+        return RetrofitService.getThingsService().deviceDetail(mDeviceId, mNodeId)
+                .subscribeOn(Schedulers.io())
+                .observeOn(AndroidSchedulers.mainThread())
+                .subscribe(deviceDetail -> onResponse(MSG_COM_G_DEVICES_DEVICE_ID, deviceDetail),
+                        e -> {
+                            if (e instanceof HttpException) {
+                                onError(MSG_COM_G_DEVICES_DEVICE_ID, e);
+                            } else {
+                                onError(MSG_COM_EXCEPTION, e);
+                            }
+                        }
+                );
     }
 
     @Override
@@ -666,8 +722,9 @@ public class ThingsDetail extends CustomActionBarActivity implements View.OnClic
                         case 5:
                             break;
                         case 6:
-                            comHandler.sendMessageDelayed(comHandler.obtainMessage(MSG_COM_G_DEVICES_DEVICE_ID),
-                                    Constants.HANDLER_DELAY_MILLIS);
+//                            comHandler.sendMessageDelayed(comHandler.obtainMessage(MSG_COM_G_DEVICES_DEVICE_ID),
+//                                    Constants.HANDLER_DELAY_MILLIS);
+                            request(MSG_COM_G_DEVICES_DEVICE_ID, !mSwipeRefreshLayout.isRefreshing());
                             break;
                         case 7:
                             break;
@@ -726,7 +783,8 @@ public class ThingsDetail extends CustomActionBarActivity implements View.OnClic
             switch (requestCode) {
                 case Constants.ACT_THINGS_NAME_CHANGE:
                     mIsReloadFinish = true;
-                    comHandler.sendMessageDelayed(comHandler.obtainMessage(MSG_COM_G_DEVICES_DEVICE_ID), 10);
+//                    comHandler.sendMessageDelayed(comHandler.obtainMessage(MSG_COM_G_DEVICES_DEVICE_ID), 10);
+                    request(MSG_COM_G_DEVICES_DEVICE_ID, !mSwipeRefreshLayout.isRefreshing());
                     break;
                 default:
                     break;

+ 1 - 1
kneet_v3/src/main/java/com/ntels/kneet/v3/view/things/ThingsNameChange.java

@@ -277,7 +277,7 @@ public class ThingsNameChange extends CustomActivity implements View.OnClickList
             mType = msg.what;
             switch (msg.what) {
                 case MSG_COM_P_DEVICES_PROPERTY_DEVICE_ID:
-                    //dialog_show();
+                    //showProgress();
                     requestDeviceNameChange();
                     break;