use an overriden ViewPager to fix IllegalArgumentException
This commit is contained in:
parent
3983428d5f
commit
e8da1424ad
|
@ -0,0 +1,37 @@
|
||||||
|
package gallery.simplemobiletools.com;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.support.v4.view.ViewPager;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.view.MotionEvent;
|
||||||
|
|
||||||
|
public class MyViewPager extends ViewPager {
|
||||||
|
|
||||||
|
public MyViewPager(Context context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MyViewPager(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
||||||
|
try {
|
||||||
|
return super.onInterceptTouchEvent(ev);
|
||||||
|
} catch (IllegalArgumentException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onTouchEvent(MotionEvent ev) {
|
||||||
|
try {
|
||||||
|
return super.onTouchEvent(ev);
|
||||||
|
} catch (IllegalArgumentException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,7 +4,6 @@ import android.database.Cursor;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.provider.MediaStore;
|
import android.provider.MediaStore;
|
||||||
import android.support.v4.view.ViewPager;
|
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -12,6 +11,7 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import gallery.simplemobiletools.com.Constants;
|
import gallery.simplemobiletools.com.Constants;
|
||||||
|
import gallery.simplemobiletools.com.MyViewPager;
|
||||||
import gallery.simplemobiletools.com.R;
|
import gallery.simplemobiletools.com.R;
|
||||||
import gallery.simplemobiletools.com.adapters.MyPagerAdapter;
|
import gallery.simplemobiletools.com.adapters.MyPagerAdapter;
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ public class ViewPagerActivity extends AppCompatActivity {
|
||||||
setContentView(R.layout.activity_photo);
|
setContentView(R.layout.activity_photo);
|
||||||
|
|
||||||
pos = 0;
|
pos = 0;
|
||||||
final ViewPager pager = (ViewPager) findViewById(R.id.view_pager);
|
final MyViewPager pager = (MyViewPager) findViewById(R.id.view_pager);
|
||||||
final MyPagerAdapter adapter = new MyPagerAdapter(this, getPhotos());
|
final MyPagerAdapter adapter = new MyPagerAdapter(this, getPhotos());
|
||||||
pager.setAdapter(adapter);
|
pager.setAdapter(adapter);
|
||||||
pager.setCurrentItem(pos);
|
pager.setCurrentItem(pos);
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@android:color/black">
|
android:background="@android:color/black">
|
||||||
|
|
||||||
<android.support.v4.view.ViewPager
|
<gallery.simplemobiletools.com.MyViewPager
|
||||||
android:id="@+id/view_pager"
|
android:id="@+id/view_pager"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"/>
|
android:layout_height="match_parent"/>
|
||||||
|
|
Loading…
Reference in New Issue