Welcome to mirror list, hosted at ThFree Co, Russian Federation.

BookmarkCategoriesFragment.java « bookmarks « maps « mapswithme « com « src « android - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d27280696b04526cf7b6ab0235bd7926eff237c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package com.mapswithme.maps.bookmarks;

import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentManager;
import android.view.View;

import com.cocosw.bottomsheet.BottomSheet;
import com.mapswithme.maps.R;
import com.mapswithme.maps.auth.Authorizer;
import com.mapswithme.maps.auth.TargetFragmentCallback;
import com.mapswithme.maps.bookmarks.data.BookmarkCategory;
import com.mapswithme.maps.bookmarks.data.BookmarkManager;
import com.mapswithme.maps.widget.BookmarkBackupView;
import com.mapswithme.util.UiUtils;

public class BookmarkCategoriesFragment extends BaseBookmarkCategoriesFragment
    implements TargetFragmentCallback, AuthCompleteListener
{
  @Nullable
  private BookmarkBackupController mBackupController;

  @Override
  protected void onPrepareControllers(@NonNull View view)
  {
    super.onPrepareControllers(view);
    Authorizer authorizer = new Authorizer(this);
    BookmarkBackupView backupView = view.findViewById(R.id.backup);


    mBackupController = new BookmarkBackupController(requireActivity(), backupView, authorizer,
                                                     this);
  }

  @Override
  public void onStart()
  {
    super.onStart();
    if (mBackupController != null)
      mBackupController.onStart();
  }

  @Override
  protected void updateLoadingPlaceholder()
  {
    super.updateLoadingPlaceholder();
    boolean isLoading = BookmarkManager.INSTANCE.isAsyncBookmarksLoadingInProgress();
    UiUtils.showIf(!isLoading, getView(), R.id.backup, R.id.recycler);
  }

  @Override
  public void onStop()
  {
    super.onStop();
    if (mBackupController != null)
      mBackupController.onStop();
  }

  @Override
  public void onTargetFragmentResult(int resultCode, @Nullable Intent data)
  {
    if (mBackupController != null)
      mBackupController.onTargetFragmentResult(resultCode, data);
  }

  @Override
  public boolean isTargetAdded()
  {
    return isAdded();
  }

  @Override
  protected void prepareBottomMenuItems(@NonNull BottomSheet bottomSheet)
  {
    boolean isMultipleItems = getAdapter().getBookmarkCategories().size() > 1;
    setEnableForMenuItem(R.id.delete, bottomSheet, isMultipleItems);
    setEnableForMenuItem(R.id.sharing_options, bottomSheet,
                         getSelectedCategory().isSharingOptionsAllowed());
  }

  @NonNull
  @Override
  protected BookmarkCategory.Type getType()
  {
    return BookmarkCategory.Type.PRIVATE;
  }

  @Override
  public void onAuthCompleted()
  {
    FragmentManager fm = requireActivity().getSupportFragmentManager();
    BookmarkCategoriesPagerFragment pagerFragment =
        (BookmarkCategoriesPagerFragment) fm.findFragmentByTag(BookmarkCategoriesPagerFragment.class.getName());
    pagerFragment.onAuthCompleted();
  }
}