Search in sources :

Example 1 with MediaDetailPagerFragment

use of fr.free.nrw.commons.media.MediaDetailPagerFragment in project apps-android-commons by commons-app.

the class ExploreListRootFragment method onMediaClicked.

@Override
public void onMediaClicked(int position) {
    container.setVisibility(View.VISIBLE);
    ((ExploreFragment) getParentFragment()).tabLayout.setVisibility(View.GONE);
    mediaDetails = new MediaDetailPagerFragment(false, true);
    ((ExploreFragment) getParentFragment()).setScroll(false);
    setFragment(mediaDetails, listFragment);
    mediaDetails.showImage(position);
}
Also used : MediaDetailPagerFragment(fr.free.nrw.commons.media.MediaDetailPagerFragment)

Example 2 with MediaDetailPagerFragment

use of fr.free.nrw.commons.media.MediaDetailPagerFragment in project apps-android-commons by commons-app.

the class SearchActivity method onMediaClicked.

/**
 * Open media detail pager fragment on click of image in search results
 * @param index item index that should be opened
 */
@Override
public void onMediaClicked(int index) {
    ViewUtil.hideKeyboard(this.findViewById(R.id.searchBox));
    tabLayout.setVisibility(View.GONE);
    viewPager.setVisibility(View.GONE);
    mediaContainer.setVisibility(View.VISIBLE);
    // to remove searchview when mediaDetails fragment open
    searchView.setVisibility(View.GONE);
    if (mediaDetails == null || !mediaDetails.isVisible()) {
        // set isFeaturedImage true for featured images, to include author field on media detail
        mediaDetails = new MediaDetailPagerFragment(false, true);
        FragmentManager supportFragmentManager = getSupportFragmentManager();
        supportFragmentManager.beginTransaction().hide(supportFragmentManager.getFragments().get(supportFragmentManager.getBackStackEntryCount())).add(R.id.mediaContainer, mediaDetails).addToBackStack(null).commit();
        // Reason for using hide, add instead of replace is to maintain scroll position after
        // coming back to the search activity. See https://github.com/commons-app/apps-android-commons/issues/1631
        // https://stackoverflow.com/questions/11353075/how-can-i-maintain-fragment-state-when-added-to-the-back-stack/19022550#19022550
        supportFragmentManager.executePendingTransactions();
    }
    mediaDetails.showImage(index);
}
Also used : FragmentManager(androidx.fragment.app.FragmentManager) MediaDetailPagerFragment(fr.free.nrw.commons.media.MediaDetailPagerFragment)

Example 3 with MediaDetailPagerFragment

use of fr.free.nrw.commons.media.MediaDetailPagerFragment in project apps-android-commons by commons-app.

the class WikidataItemDetailsActivity method onMediaClicked.

/**
 * Shows media detail fragment when user clicks on any image in the list
 */
@Override
public void onMediaClicked(int position) {
    tabLayout.setVisibility(View.GONE);
    viewPager.setVisibility(View.GONE);
    mediaContainer.setVisibility(View.VISIBLE);
    if (mediaDetailPagerFragment == null || !mediaDetailPagerFragment.isVisible()) {
        // set isFeaturedImage true for featured images, to include author field on media detail
        mediaDetailPagerFragment = new MediaDetailPagerFragment(false, true);
        FragmentManager supportFragmentManager = getSupportFragmentManager();
        supportFragmentManager.beginTransaction().replace(R.id.mediaContainer, mediaDetailPagerFragment).addToBackStack(null).commit();
        supportFragmentManager.executePendingTransactions();
    }
    mediaDetailPagerFragment.showImage(position);
}
Also used : FragmentManager(androidx.fragment.app.FragmentManager) MediaDetailPagerFragment(fr.free.nrw.commons.media.MediaDetailPagerFragment)

Example 4 with MediaDetailPagerFragment

use of fr.free.nrw.commons.media.MediaDetailPagerFragment in project apps-android-commons by commons-app.

the class ContributionsFragment method showDetail.

/**
 * Replace whatever is in the current contributionsFragmentContainer view with
 * mediaDetailPagerFragment, and preserve previous state in back stack. Called when user selects a
 * contribution.
 */
@Override
public void showDetail(int position, boolean isWikipediaButtonDisplayed) {
    if (mediaDetailPagerFragment == null || !mediaDetailPagerFragment.isVisible()) {
        mediaDetailPagerFragment = new MediaDetailPagerFragment();
        showMediaDetailPagerFragment();
    }
    mediaDetailPagerFragment.showImage(position, isWikipediaButtonDisplayed);
}
Also used : MediaDetailPagerFragment(fr.free.nrw.commons.media.MediaDetailPagerFragment)

Example 5 with MediaDetailPagerFragment

use of fr.free.nrw.commons.media.MediaDetailPagerFragment in project apps-android-commons by commons-app.

the class MultipleShareActivity method showDetail.

private void showDetail(int i) {
    if (mediaDetails == null || !mediaDetails.isVisible()) {
        mediaDetails = new MediaDetailPagerFragment(true);
        getSupportFragmentManager().beginTransaction().replace(R.id.uploadsFragmentContainer, mediaDetails).addToBackStack(null).commit();
        getSupportFragmentManager().executePendingTransactions();
    }
    mediaDetails.showImage(i);
}
Also used : MediaDetailPagerFragment(fr.free.nrw.commons.media.MediaDetailPagerFragment)

Aggregations

MediaDetailPagerFragment (fr.free.nrw.commons.media.MediaDetailPagerFragment)10 FragmentManager (androidx.fragment.app.FragmentManager)3