Search in sources :

Example 1 with GridViewAdapter

use of fr.free.nrw.commons.category.GridViewAdapter in project apps-android-commons by commons-app.

the class BookmarkPicturesFragment method setAdapter.

/**
 * Initializes the adapter with a list of Media objects
 * @param mediaList List of new Media to be displayed
 */
private void setAdapter(List<Media> mediaList) {
    gridAdapter = new GridViewAdapter(this.getContext(), R.layout.layout_category_images, mediaList);
    gridView.setAdapter(gridAdapter);
}
Also used : GridViewAdapter(fr.free.nrw.commons.category.GridViewAdapter)

Example 2 with GridViewAdapter

use of fr.free.nrw.commons.category.GridViewAdapter 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)

Aggregations

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