diff --git a/app/src/main/java/com/simplemobiletools/gallery/activities/ViewPagerActivity.java b/app/src/main/java/com/simplemobiletools/gallery/activities/ViewPagerActivity.java index 6ecba0151..e8ed2ede8 100644 --- a/app/src/main/java/com/simplemobiletools/gallery/activities/ViewPagerActivity.java +++ b/app/src/main/java/com/simplemobiletools/gallery/activities/ViewPagerActivity.java @@ -20,11 +20,11 @@ import android.widget.EditText; import android.widget.RelativeLayout; import com.simplemobiletools.gallery.Constants; -import com.simplemobiletools.gallery.models.Medium; import com.simplemobiletools.gallery.MyViewPager; import com.simplemobiletools.gallery.R; import com.simplemobiletools.gallery.Utils; import com.simplemobiletools.gallery.adapters.MyPagerAdapter; +import com.simplemobiletools.gallery.models.Medium; import java.io.File; import java.util.ArrayList; @@ -77,7 +77,7 @@ public class ViewPagerActivity extends AppCompatActivity pager.setCurrentItem(pos); pager.addOnPageChangeListener(this); pager.setOnTouchListener(this); - pager.setPageTransformer(true, new DepthPageTransformer()); + //pager.setPageTransformer(true, new DepthPageTransformer()); getWindow().getDecorView().setOnSystemUiVisibilityChangeListener(this); updateActionbarTitle(); @@ -351,7 +351,7 @@ public class ViewPagerActivity extends AppCompatActivity public void onPageScrollStateChanged(int state) { if (state == ViewPager.SCROLL_STATE_DRAGGING) { final MyPagerAdapter adapter = (MyPagerAdapter) pager.getAdapter(); - adapter.itemDragged(); + adapter.itemDragged(pos); } } diff --git a/app/src/main/java/com/simplemobiletools/gallery/adapters/MyPagerAdapter.java b/app/src/main/java/com/simplemobiletools/gallery/adapters/MyPagerAdapter.java index c303ca59f..09aee6741 100644 --- a/app/src/main/java/com/simplemobiletools/gallery/adapters/MyPagerAdapter.java +++ b/app/src/main/java/com/simplemobiletools/gallery/adapters/MyPagerAdapter.java @@ -6,20 +6,24 @@ import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentStatePagerAdapter; import com.simplemobiletools.gallery.Constants; -import com.simplemobiletools.gallery.models.Medium; import com.simplemobiletools.gallery.fragments.PhotoFragment; import com.simplemobiletools.gallery.fragments.VideoFragment; import com.simplemobiletools.gallery.fragments.ViewPagerFragment; +import com.simplemobiletools.gallery.models.Medium; +import java.util.HashMap; import java.util.List; +import java.util.Map; public class MyPagerAdapter extends FragmentStatePagerAdapter { private List media; private ViewPagerFragment fragment; + private Map fragments; public MyPagerAdapter(FragmentManager fm, List media) { super(fm); this.media = media; + fragments = new HashMap<>(); } @Override @@ -34,7 +38,7 @@ public class MyPagerAdapter extends FragmentStatePagerAdapter { } final Medium medium = media.get(position); - Bundle bundle = new Bundle(); + final Bundle bundle = new Bundle(); bundle.putSerializable(Constants.MEDIUM, medium); if (medium.getIsVideo()) { @@ -43,13 +47,14 @@ public class MyPagerAdapter extends FragmentStatePagerAdapter { fragment = new PhotoFragment(); } + fragments.put(position, fragment); fragment.setArguments(bundle); return fragment; } - public void itemDragged() { - if (fragment != null) { - fragment.itemDragged(); + public void itemDragged(int pos) { + if (fragments.get(pos) != null) { + fragments.get(pos).itemDragged(); } } diff --git a/app/src/main/java/com/simplemobiletools/gallery/fragments/VideoFragment.java b/app/src/main/java/com/simplemobiletools/gallery/fragments/VideoFragment.java index c98da36b1..120b0db55 100644 --- a/app/src/main/java/com/simplemobiletools/gallery/fragments/VideoFragment.java +++ b/app/src/main/java/com/simplemobiletools/gallery/fragments/VideoFragment.java @@ -47,7 +47,6 @@ public class VideoFragment extends ViewPagerFragment @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View view = inflater.inflate(R.layout.pager_video_item, container, false); - ; medium = (Medium) getArguments().getSerializable(Constants.MEDIUM); if (medium == null) diff --git a/app/src/main/java/com/simplemobiletools/gallery/models/Medium.java b/app/src/main/java/com/simplemobiletools/gallery/models/Medium.java index 43d4919c4..c2af0ed68 100644 --- a/app/src/main/java/com/simplemobiletools/gallery/models/Medium.java +++ b/app/src/main/java/com/simplemobiletools/gallery/models/Medium.java @@ -19,4 +19,11 @@ public class Medium implements Serializable { public boolean getIsVideo() { return isVideo; } + + @Override + public String toString() { + return "Medium {" + + "isVideo=" + getIsVideo() + + ", path=" + getPath() + "}"; + } }