diff --git a/android/src/com/mapswithme/maps/base/BaseAsyncOperationFragment.java b/android/src/com/mapswithme/maps/base/BaseAsyncOperationFragment.java index 531416bf93..526ea591d7 100644 --- a/android/src/com/mapswithme/maps/base/BaseAsyncOperationFragment.java +++ b/android/src/com/mapswithme/maps/base/BaseAsyncOperationFragment.java @@ -1,6 +1,5 @@ package com.mapswithme.maps.base; -import android.os.Bundle; import android.support.annotation.StringRes; import android.support.v4.app.DialogFragment; import android.support.v4.app.FragmentManager; @@ -12,6 +11,7 @@ public abstract class BaseAsyncOperationFragment extends BaseMwmFragment { private static final String PROGRESS_DIALOG_TAG = "base_progress_dialog"; + @SuppressWarnings("NullableProblems") protected void showProgress() { int resId = getProgressDialogTitle(); @@ -29,6 +29,7 @@ public abstract class BaseAsyncOperationFragment extends BaseMwmFragment return R.string.downloading; } + @SuppressWarnings("NullableProblems") protected void hideProgress() { FragmentManager fm = getFragmentManager(); diff --git a/android/src/com/mapswithme/maps/base/BaseAuthFragment.java b/android/src/com/mapswithme/maps/base/BaseAuthFragment.java index 5afde4c870..e42e3c8eb2 100644 --- a/android/src/com/mapswithme/maps/base/BaseAuthFragment.java +++ b/android/src/com/mapswithme/maps/base/BaseAuthFragment.java @@ -1,6 +1,5 @@ package com.mapswithme.maps.base; -import android.content.Context; import android.content.Intent; import android.support.annotation.CallSuper; import android.support.annotation.NonNull; @@ -8,8 +7,14 @@ import android.support.annotation.Nullable; import com.mapswithme.maps.auth.Authorizer; import com.mapswithme.maps.auth.TargetFragmentCallback; +import com.mapswithme.maps.base.BaseMwmToolbarFragment; -public abstract class BaseAuthFragment extends BaseAsyncOperationFragment +/** + * A base toolbar fragment which is responsible for the authorization flow, + * starting from the getting an auth token from a social network and passing it to the core + * to get user authorized for the MapsMe server (Passport). + */ +public abstract class BaseAuthFragment extends BaseMwmToolbarFragment implements Authorizer.Callback, TargetFragmentCallback { @NonNull @@ -22,17 +27,17 @@ public abstract class BaseAuthFragment extends BaseAsyncOperationFragment @Override @CallSuper - public void onAttach(Context context) + public void onStart() { - super.onAttach(context); + super.onStart(); mAuthorizer.attach(this); } @Override @CallSuper - public void onDestroyView() + public void onStop() { - super.onDestroyView(); + super.onStop(); mAuthorizer.detach(); } diff --git a/android/src/com/mapswithme/maps/auth/BaseAuthFragment.java b/android/src/com/mapswithme/maps/base/BaseToolbarAuthFragment.java similarity index 62% rename from android/src/com/mapswithme/maps/auth/BaseAuthFragment.java rename to android/src/com/mapswithme/maps/base/BaseToolbarAuthFragment.java index 7f05645d51..7ea26b43f5 100644 --- a/android/src/com/mapswithme/maps/auth/BaseAuthFragment.java +++ b/android/src/com/mapswithme/maps/base/BaseToolbarAuthFragment.java @@ -1,18 +1,15 @@ -package com.mapswithme.maps.auth; +package com.mapswithme.maps.base; +import android.content.Context; import android.content.Intent; import android.support.annotation.CallSuper; import android.support.annotation.NonNull; import android.support.annotation.Nullable; -import com.mapswithme.maps.base.BaseMwmToolbarFragment; +import com.mapswithme.maps.auth.Authorizer; +import com.mapswithme.maps.auth.TargetFragmentCallback; -/** - * A base toolbar fragment which is responsible for the authorization flow, - * starting from the getting an auth token from a social network and passing it to the core - * to get user authorized for the MapsMe server (Passport). - */ -public abstract class BaseAuthFragment extends BaseMwmToolbarFragment +public abstract class BaseToolbarAuthFragment extends BaseAsyncOperationFragment implements Authorizer.Callback, TargetFragmentCallback { @NonNull @@ -25,17 +22,17 @@ public abstract class BaseAuthFragment extends BaseMwmToolbarFragment @Override @CallSuper - public void onStart() + public void onAttach(Context context) { - super.onStart(); + super.onAttach(context); mAuthorizer.attach(this); } @Override @CallSuper - public void onStop() + public void onDestroyView() { - super.onStop(); + super.onDestroyView(); mAuthorizer.detach(); } diff --git a/android/src/com/mapswithme/maps/ugc/UGCEditorFragment.java b/android/src/com/mapswithme/maps/ugc/UGCEditorFragment.java index 6bcd8949da..3cb1703eca 100644 --- a/android/src/com/mapswithme/maps/ugc/UGCEditorFragment.java +++ b/android/src/com/mapswithme/maps/ugc/UGCEditorFragment.java @@ -12,7 +12,7 @@ import android.widget.EditText; import com.mapswithme.maps.Framework; import com.mapswithme.maps.R; -import com.mapswithme.maps.auth.BaseAuthFragment; +import com.mapswithme.maps.base.BaseAuthFragment; import com.mapswithme.maps.background.Notifier; import com.mapswithme.maps.bookmarks.data.FeatureId; import com.mapswithme.maps.metrics.UserActionsLogger; diff --git a/android/src/com/mapswithme/maps/ugc/routes/SendLinkPlaceholderFragment.java b/android/src/com/mapswithme/maps/ugc/routes/SendLinkPlaceholderFragment.java index 15b6009cef..2afe9eacba 100644 --- a/android/src/com/mapswithme/maps/ugc/routes/SendLinkPlaceholderFragment.java +++ b/android/src/com/mapswithme/maps/ugc/routes/SendLinkPlaceholderFragment.java @@ -9,7 +9,7 @@ import android.view.View; import android.view.ViewGroup; import com.mapswithme.maps.R; -import com.mapswithme.maps.base.BaseAuthFragment; +import com.mapswithme.maps.base.BaseToolbarAuthFragment; import com.mapswithme.maps.bookmarks.data.BookmarkCategory; import com.mapswithme.maps.bookmarks.data.BookmarkManager; import com.mapswithme.maps.bookmarks.data.CatalogCustomProperty; @@ -21,7 +21,7 @@ import com.mapswithme.util.statistics.Statistics; import java.util.List; import java.util.Objects; -public class SendLinkPlaceholderFragment extends BaseAuthFragment implements BookmarkManager.BookmarksCatalogListener +public class SendLinkPlaceholderFragment extends BaseToolbarAuthFragment implements BookmarkManager.BookmarksCatalogListener { public static final String EXTRA_CATEGORY = "bookmarks_category"; private static final String BODY_STRINGS_SEPARATOR = "\n\n"; @@ -43,6 +43,7 @@ public class SendLinkPlaceholderFragment extends BaseAuthFragment implements Boo mCategory = Objects.requireNonNull(args.getParcelable(EXTRA_CATEGORY)); } + @SuppressWarnings("NullableProblems") @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @@ -95,18 +96,13 @@ public class SendLinkPlaceholderFragment extends BaseAuthFragment implements Boo if (uploadResult == BookmarkManager.UploadResult.UPLOAD_RESULT_SUCCESS) onUploadSucceeded(); else if (uploadResult == BookmarkManager.UploadResult.UPLOAD_RESULT_AUTH_ERROR) - onAuthError(); + authorize(); else onUploadFailed(); hideProgress(); } - private void onAuthError() - { - authorize(); - } - private void onUploadFailed() { /* FIXME text*/ diff --git a/android/src/com/mapswithme/maps/ugc/routes/UgcSharingOptionsFragment.java b/android/src/com/mapswithme/maps/ugc/routes/UgcSharingOptionsFragment.java index 677f03e3fd..4da1732cd2 100644 --- a/android/src/com/mapswithme/maps/ugc/routes/UgcSharingOptionsFragment.java +++ b/android/src/com/mapswithme/maps/ugc/routes/UgcSharingOptionsFragment.java @@ -18,7 +18,7 @@ import android.widget.Toast; import com.mapswithme.maps.Framework; import com.mapswithme.maps.R; -import com.mapswithme.maps.auth.BaseAuthFragment; +import com.mapswithme.maps.base.BaseAuthFragment; import com.mapswithme.maps.base.FinishActivityToolbarController; import com.mapswithme.maps.bookmarks.data.AbstractCategoriesSnapshot; import com.mapswithme.maps.bookmarks.data.BookmarkCategory;