use of org.horaapps.leafpic.adapters.MediaPagerAdapter 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.adapters.MediaPagerAdapter in project LeafPic by HoraApps.
the class SingleMediaActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_single_media);
ButterKnife.bind(this);
String action = getIntent().getAction();
if (action != null) {
switch(action) {
case ACTION_OPEN_ALBUM:
loadAlbum(getIntent());
break;
case ACTION_OPEN_ALBUM_LAZY:
loadAlbumsLazy(getIntent());
break;
default:
loadUri(getIntent().getData());
break;
}
}
if (savedInstanceState != null) {
mViewPager.setLocked(savedInstanceState.getBoolean(ISLOCKED_ARG, false));
}
adapter = new MediaPagerAdapter(getSupportFragmentManager(), media);
initUi();
}
Aggregations