Search in sources :

Example 1 with BookmarkPicturesFragment

use of fr.free.nrw.commons.bookmarks.pictures.BookmarkPicturesFragment in project apps-android-commons by commons-app.

the class BookmarkListRootFragment method backPressed.

public boolean backPressed() {
    // check mediaDetailPage fragment is not null then we check mediaDetail.is Visible or not to avoid NullPointerException
    if (mediaDetails != null) {
        if (mediaDetails.isVisible()) {
            if (mediaDetails.backButtonClicked()) {
                // mediaDetails handled the back clicked , no further action required.
                return true;
            }
            // todo add get list fragment
            ((BookmarkFragment) getParentFragment()).setupTabLayout();
            ArrayList<Integer> removed = mediaDetails.getRemovedItems();
            removeFragment(mediaDetails);
            ((BookmarkFragment) getParentFragment()).setScroll(true);
            setFragment(listFragment, mediaDetails);
            ((MainActivity) getActivity()).showTabs();
            if (listFragment instanceof BookmarkPicturesFragment) {
                GridViewAdapter adapter = ((GridViewAdapter) ((BookmarkPicturesFragment) listFragment).getAdapter());
                Iterator i = removed.iterator();
                while (i.hasNext()) {
                    adapter.remove(adapter.getItem((int) i.next()));
                }
                mediaDetails.clearRemoved();
            }
        } else {
            moveToContributionsFragment();
        }
    } else {
        moveToContributionsFragment();
    }
    // notify mediaDetails did not handled the backPressed further actions required.
    return false;
}
Also used : GridViewAdapter(fr.free.nrw.commons.category.GridViewAdapter) Iterator(java.util.Iterator) MainActivity(fr.free.nrw.commons.contributions.MainActivity) BookmarkPicturesFragment(fr.free.nrw.commons.bookmarks.pictures.BookmarkPicturesFragment)

Example 2 with BookmarkPicturesFragment

use of fr.free.nrw.commons.bookmarks.pictures.BookmarkPicturesFragment in project apps-android-commons by commons-app.

the class BookmarksPagerAdapter method requestPictureListUpdate.

/**
 * Update the pictures list for the bookmark fragment
 */
public void requestPictureListUpdate() {
    BookmarkPicturesFragment fragment = (BookmarkPicturesFragment) (((BookmarkListRootFragment) pages.get(0).getPage()).listFragment);
    fragment.onResume();
}
Also used : BookmarkPicturesFragment(fr.free.nrw.commons.bookmarks.pictures.BookmarkPicturesFragment)

Aggregations

BookmarkPicturesFragment (fr.free.nrw.commons.bookmarks.pictures.BookmarkPicturesFragment)2 GridViewAdapter (fr.free.nrw.commons.category.GridViewAdapter)1 MainActivity (fr.free.nrw.commons.contributions.MainActivity)1 Iterator (java.util.Iterator)1