Dmitry Donskoy 2019-01-30 13:21:10 +03:00 committed by Aleksandr Zatsepin
parent e2cad930c9
commit fa75730e48
6 changed files with 28 additions and 29 deletions

View file

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

View file

@ -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 <b>authorization flow</b>,
* 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();
}

View file

@ -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 <b>authorization flow</b>,
* 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();
}

View file

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

View file

@ -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*/

View file

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