forked from organicmaps/organicmaps
[android] Fixed review notes
https://github.com/mapsme/omim/pull/11177#discussion_r300993539 https://github.com/mapsme/omim/pull/11177#discussion_r300995428 https://github.com/mapsme/omim/pull/11177#discussion_r300993539 https://github.com/mapsme/omim/pull/11177#discussion_r301045087 https://github.com/mapsme/omim/pull/11177#discussion_r301045955 https://github.com/mapsme/omim/pull/11177#discussion_r301046889
This commit is contained in:
parent
8f3db3145f
commit
3fcc3d57c5
3 changed files with 35 additions and 10 deletions
|
@ -87,7 +87,7 @@ public class BookmarkCategoriesPagerFragment extends BaseMwmFragment
|
|||
viewPager.setCurrentItem(saveAndGetInitialPage());
|
||||
tabLayout.setupWithViewPager(viewPager);
|
||||
viewPager.addOnPageChangeListener(new PageChangeListener());
|
||||
|
||||
mDelegate.onCreateView(savedInstanceState);
|
||||
return root;
|
||||
}
|
||||
|
||||
|
|
|
@ -153,6 +153,7 @@ public class BookmarksCatalogFragment extends BaseWebViewMwmFragment
|
|||
mProgressView = root.findViewById(R.id.progress);
|
||||
initWebView();
|
||||
mRetryBtn.setOnClickListener(v -> onRetryClick());
|
||||
mDelegate.onCreateView(savedInstanceState);
|
||||
return root;
|
||||
}
|
||||
|
||||
|
|
|
@ -58,14 +58,6 @@ class BookmarksDownloadFragmentDelegate implements Authorizer.Callback, Bookmark
|
|||
new CatalogListenerDecorator(mFragment));
|
||||
if (savedInstanceState != null)
|
||||
mDownloadController.onRestore(savedInstanceState);
|
||||
|
||||
checkInvalidCategories();
|
||||
}
|
||||
|
||||
private void checkInvalidCategories()
|
||||
{
|
||||
BookmarkManager.INSTANCE.addInvalidCategoriesListener(mInvalidCategoriesListener);
|
||||
BookmarkManager.INSTANCE.checkInvalidCategories();
|
||||
}
|
||||
|
||||
void onStart()
|
||||
|
@ -82,6 +74,15 @@ class BookmarksDownloadFragmentDelegate implements Authorizer.Callback, Bookmark
|
|||
mInvalidCategoriesListener.detach();
|
||||
}
|
||||
|
||||
void onCreateView(@Nullable Bundle savedInstanceState)
|
||||
{
|
||||
BookmarkManager.INSTANCE.addInvalidCategoriesListener(mInvalidCategoriesListener);
|
||||
if (savedInstanceState != null)
|
||||
return;
|
||||
|
||||
BookmarkManager.INSTANCE.checkInvalidCategories();
|
||||
}
|
||||
|
||||
void onDestroyView()
|
||||
{
|
||||
BookmarkManager.INSTANCE.removeInvalidCategoriesListener(mInvalidCategoriesListener);
|
||||
|
@ -199,6 +200,8 @@ class BookmarksDownloadFragmentDelegate implements Authorizer.Callback, Bookmark
|
|||
{
|
||||
@Nullable
|
||||
private Fragment mFrag;
|
||||
@Nullable
|
||||
private Boolean mPendingInvalidCategoriesResult;
|
||||
|
||||
public InvalidCategoriesListener(@NonNull Fragment fragment)
|
||||
{
|
||||
|
@ -209,7 +212,22 @@ class BookmarksDownloadFragmentDelegate implements Authorizer.Callback, Bookmark
|
|||
public void onCheckInvalidCategories(boolean hasInvalidCategories)
|
||||
{
|
||||
BookmarkManager.INSTANCE.removeInvalidCategoriesListener(this);
|
||||
if (mFrag == null || !hasInvalidCategories)
|
||||
|
||||
if (mFrag == null)
|
||||
{
|
||||
mPendingInvalidCategoriesResult = hasInvalidCategories;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!hasInvalidCategories)
|
||||
return;
|
||||
|
||||
showDialog();
|
||||
}
|
||||
|
||||
private void showDialog()
|
||||
{
|
||||
if (mFrag == null)
|
||||
return;
|
||||
|
||||
AlertDialog dialog = new AlertDialog.Builder()
|
||||
|
@ -225,6 +243,7 @@ class BookmarksDownloadFragmentDelegate implements Authorizer.Callback, Bookmark
|
|||
.setNegativeBtnTextColor(R.color.rating_horrible)
|
||||
.build();
|
||||
|
||||
dialog.setCancelable(false);
|
||||
dialog.setTargetFragment(mFrag, REQ_CODE_CHECK_INVALID_SUBS_DIALOG);
|
||||
dialog.show(mFrag, CHECK_INVALID_SUBS_DIALOG_TAG);
|
||||
}
|
||||
|
@ -233,6 +252,11 @@ class BookmarksDownloadFragmentDelegate implements Authorizer.Callback, Bookmark
|
|||
public void attach(@NonNull Fragment object)
|
||||
{
|
||||
mFrag = object;
|
||||
if (Boolean.TRUE.equals(mPendingInvalidCategoriesResult))
|
||||
{
|
||||
showDialog();
|
||||
mPendingInvalidCategoriesResult = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Add table
Reference in a new issue