use of org.horaapps.leafpic.animations.DepthPageTransformer in project LeafPic by HoraApps.
the class SingleMediaActivity method initUI.
private void initUI() {
setSupportActionBar(toolbar);
toolbar.bringToFront();
toolbar.setNavigationIcon(getToolbarIcon(CommunityMaterial.Icon.cmd_arrow_left));
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onBackPressed();
}
});
setRecentApp(getString(R.string.app_name));
setupSystemUI();
getWindow().getDecorView().setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
@Override
public void onSystemUiVisibilityChange(int visibility) {
if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0)
showSystemUI();
else
hideSystemUI();
}
});
adapter = new MediaPagerAdapter(getSupportFragmentManager(), getAlbum().getMedia());
adapter.setVideoOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (SP.getBoolean("set_internal_player", false)) {
Intent mpdIntent = new Intent(SingleMediaActivity.this, PlayerActivity.class).setData(getAlbum().getCurrentMedia().getUri());
startActivity(mpdIntent);
} else {
Intent intentOpenWith = new Intent(Intent.ACTION_VIEW);
intentOpenWith.setDataAndType(getAlbum().getMedia().get(mViewPager.getCurrentItem()).getUri(), getAlbum().getMedia().get(mViewPager.getCurrentItem()).getMimeType());
startActivity(intentOpenWith);
}
}
});
getSupportActionBar().setTitle((getAlbum().getCurrentMediaIndex() + 1) + " " + getString(R.string.of) + " " + getAlbum().getMedia().size());
mViewPager.setAdapter(adapter);
mViewPager.setCurrentItem(getAlbum().getCurrentMediaIndex());
mViewPager.setPageTransformer(true, new DepthPageTransformer());
mViewPager.setOffscreenPageLimit(3);
mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
getAlbum().setCurrentPhotoIndex(position);
toolbar.setTitle((position + 1) + " " + getString(R.string.of) + " " + getAlbum().getMedia().size());
invalidateOptionsMenu();
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
Display aa = ((WindowManager) getSystemService(WINDOW_SERVICE)).getDefaultDisplay();
if (aa.getRotation() == Surface.ROTATION_90) {
Configuration configuration = new Configuration();
configuration.orientation = Configuration.ORIENTATION_LANDSCAPE;
onConfigurationChanged(configuration);
}
}
use of org.horaapps.leafpic.animations.DepthPageTransformer in project LeafPic by HoraApps.
the class SingleMediaActivity method initUi.
private void initUi() {
setSupportActionBar(toolbar);
toolbar.bringToFront();
toolbar.setNavigationIcon(getToolbarIcon(GoogleMaterial.Icon.gmd_arrow_back));
toolbar.setNavigationOnClickListener(v -> onBackPressed());
setupSystemUI();
getWindow().getDecorView().setOnSystemUiVisibilityChangeListener(visibility -> {
if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0)
showSystemUI();
else
hideSystemUI();
});
updatePageTitle(position);
mViewPager.setAdapter(adapter);
mViewPager.setCurrentItem(position);
useImageMenu = isCurrentMediaImage();
mViewPager.setPageTransformer(true, AnimationUtils.getPageTransformer(new DepthPageTransformer()));
mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
SingleMediaActivity.this.position = position;
updatePageTitle(position);
// Invalidate the options menu only when we aren't using the correct menu
if (isCurrentMediaImage() == useImageMenu)
return;
supportInvalidateOptionsMenu();
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
if (((WindowManager) getSystemService(WINDOW_SERVICE)).getDefaultDisplay().getRotation() == Surface.ROTATION_90) {
Configuration configuration = new Configuration();
configuration.orientation = Configuration.ORIENTATION_LANDSCAPE;
onConfigurationChanged(configuration);
}
}
Aggregations