浏览代码

[메인][New] 비회원도 설정 허용 확인 2

hyodong.min 6 年之前
父节点
当前提交
5a63f7e87d

+ 17 - 14
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/main/MainModel.java

@@ -312,27 +312,30 @@ public class MainModel extends CoinModel {
    * @return
    */
   public boolean isLocationServiceEnabled() {
-    // 비회원은 항상 허용
-    return SuperModel.getInstance().getPreferences().isLocationServiceEnabled() || isJoined() == false;
+    // 회원/비회원 구분없이 확인 및 설정
+    return SuperModel.getInstance().getPreferences().isLocationServiceEnabled();
   }
 
   public void setLocationServiceEnabled(boolean isEnabled) {
     setLocationServiceEnabledInternal(isEnabled);
 
-    MemberPushAgreeRequestBean bean = getPushBean("", "", APIData.valueOf(isEnabled));
+    if (isJoined()) {
+      // 회원만 api 통신
+      MemberPushAgreeRequestBean bean = getPushBean("", "", APIData.valueOf(isEnabled));
 
-    disposablePush = new APIMemberPushUpdateModule().call(bean, new APIModuleListener<LifeplusAPIBean>(waiterCaller) {
-      @Override
-      public void onApiSuccess(LifeplusAPIBean resultBean) {
-        onResult(new Event.Builder(Event.RESULT).bool(isEnabled).integer(SettingViewHolder.SWITCH_LOCATION).build());
-      }
+      disposablePush = new APIMemberPushUpdateModule().call(bean, new APIModuleListener<LifeplusAPIBean>(waiterCaller) {
+        @Override
+        public void onApiSuccess(LifeplusAPIBean resultBean) {
+          onResult(new Event.Builder(Event.RESULT).bool(isEnabled).integer(SettingViewHolder.SWITCH_LOCATION).build());
+        }
 
-      @Override
-      public void onApiError(String errorMessage, APIError error) {
-        setLocationServiceEnabledInternal(!isEnabled);
-        onResult(new Event.Builder(Event.ERROR).integer(SettingViewHolder.SWITCH_LOCATION).bool(isEnabled).string(errorMessage).build());
-      }
-    });
+        @Override
+        public void onApiError(String errorMessage, APIError error) {
+          setLocationServiceEnabledInternal(!isEnabled);
+          onResult(new Event.Builder(Event.ERROR).integer(SettingViewHolder.SWITCH_LOCATION).bool(isEnabled).string(errorMessage).build());
+        }
+      });
+    }
   }
 
   protected void setLocationServiceEnabledInternal(boolean isEnabled) {

+ 8 - 7
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/main/MainPresenter.java

@@ -150,7 +150,7 @@ public class MainPresenter extends Presenter<MainModel, IMainView> {
 
       if (model.canAccessDeviceLocating()) {
         // 사용자 설정 했으면 진행
-        requestLocationPermissions();
+        requestPermissionsAndLoadWeather();
       }
       else {
         // 설정 안했으면 팝업 열기
@@ -212,7 +212,7 @@ public class MainPresenter extends Presenter<MainModel, IMainView> {
         }
         else if (event.getInteger() == SettingViewHolder.SWITCH_LOCATION) {
           ToastProvider.showLocation();
-          requestLocationPermissions();
+          requestPermissionsAndLoadWeather();
         }
         break;
       case Event.ERROR:
@@ -277,7 +277,7 @@ public class MainPresenter extends Presenter<MainModel, IMainView> {
         //날씨영역 클릭
         if (model.hasAllWeatherPermission() == false) {
           // 권한이 없을 때만 실행
-          requestLocationPermissions();
+          requestPermissionsAndLoadWeather();
         }
 
         break;
@@ -354,17 +354,18 @@ public class MainPresenter extends Presenter<MainModel, IMainView> {
     }
   }
 
-  private void requestLocationPermissions() {
+  private void requestPermissionsAndLoadWeather() {
 
     // 설정 동의 -> api 호출
     // 퍼미션 동의 -> 퍼미션 창으로
     // 기기 위치 정보 사용 -> 안드로이드 설정 -> 높은 정확도(gps, network 모두 사용) 설정 후 돌아옴
 
     // 사용 동의 체크
-    if (model.isLocationServiceEnabled()) {
+    if (model.isLocationServiceEnabled() == false) {
       // 위치 동의 팝업
       showLocationDialog(R.string.main_location_agree_no, R.string.main_location_agree_yes, R.string.main_location_agree, () -> {
         model.setLocationServiceEnabled(true);
+        requestPermissionsAndLoadWeather();
       });
       return;
     }
@@ -384,7 +385,7 @@ public class MainPresenter extends Presenter<MainModel, IMainView> {
     renderWeatherButton();
 
     // 모든 권한, 동의 획득
-    Log.i("APP# MainPresenter | requestLocationPermissions", "|" + "모든 권한 획득");
+    Log.i("APP# MainPresenter | requestPermissionsAndLoadWeather", "|" + "모든 권한 획득");
     model.loadWeatherWithLocation();
   }
 
@@ -452,7 +453,7 @@ public class MainPresenter extends Presenter<MainModel, IMainView> {
 
       if (granted) {
         // 모두 허용
-        requestLocationPermissions();
+        requestPermissionsAndLoadWeather();
       }
       else {
         // permission denied -> nothing