Commit 4cf0a0d8 authored by Donald's avatar Donald

immersive mode in single gif activity

parent 44938229
......@@ -27,6 +27,7 @@ public class PhotosPagerAdapter extends android.support.v4.view.PagerAdapter {
ArrayList<Photo> mResources;
private View.OnTouchListener onTouchListener;
private View.OnClickListener onClickListener;
public PhotosPagerAdapter(Context context, ArrayList<Photo> ph) {
mContext = context;
......@@ -34,12 +35,16 @@ public class PhotosPagerAdapter extends android.support.v4.view.PagerAdapter {
mLayoutInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
public void setOnGifClickListener(View.OnClickListener ls) {
onClickListener = ls;
}
@Override
public int getCount() {
return mResources.size();
}
public void setOnTouchListener(View.OnTouchListener ls) {
public void setOnPictureTouchListener(View.OnTouchListener ls) {
onTouchListener = ls;
}
......@@ -57,6 +62,7 @@ public class PhotosPagerAdapter extends android.support.v4.view.PagerAdapter {
itemView = mLayoutInflater.inflate(R.layout.gif_pager_layout, container, false);
ImageView picture = (ImageView) itemView.findViewById(R.id.imageView);
picture.setOnClickListener(onClickListener);
Ion.with(container.getContext())
.load(f.Path)
.intoImageView(picture);
......@@ -86,6 +92,5 @@ public class PhotosPagerAdapter extends android.support.v4.view.PagerAdapter {
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
container.removeView((View) object);
// container.removeViewAt(position);
}
}
\ No newline at end of file
......@@ -53,13 +53,20 @@ public class PhotoActivity extends AppCompatActivity {
mCustomPagerAdapter = new PhotosPagerAdapter(this, photos.photos);
mCustomPagerAdapter.setOnTouchListener(new View.OnTouchListener() {
mCustomPagerAdapter.setOnPictureTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return gestureDetector.onTouchEvent(event);
}
});
mCustomPagerAdapter.setOnGifClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
toggleSystemUI();
}
});
mViewPager = (ViewPager) findViewById(R.id.pager);
mViewPager.setAdapter(mCustomPagerAdapter);
mViewPager.setCurrentItem(photos.getCurrentPhotoIndex());
......@@ -170,14 +177,9 @@ public class PhotoActivity extends AppCompatActivity {
if (fullscreenmode)
showSystemUI();
else hideSystemUI();
}
private void hideSystemUI() {
// Set the IMMERSIVE flag.
// Set the content to appear under the system bars so that the content
// doesn't resize when the system bars hide and show.
runOnUiThread(new Runnable() {
public void run() {
getWindow().getDecorView().setSystemUiVisibility(
......@@ -189,7 +191,6 @@ public class PhotoActivity extends AppCompatActivity {
| View.SYSTEM_UI_FLAG_IMMERSIVE);
toolbar.animate().translationY(-toolbar.getHeight()).setInterpolator(new AccelerateInterpolator())
.start();
//getSupportActionBar().hide();
fullscreenmode = true;
}
});
......@@ -197,10 +198,8 @@ public class PhotoActivity extends AppCompatActivity {
}
private void showSystemUI() {
runOnUiThread(new Runnable() {
public void run() {
//getSupportActionBar().show();
toolbar.animate().translationY(getStatusBarHeight()).setInterpolator(new DecelerateInterpolator())
.start();
getWindow().getDecorView().setSystemUiVisibility(
......
......@@ -8,6 +8,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_gravity="center_vertical"
android:layout_height="match_parent"/>
</LinearLayout>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment