use of android.support.v4.view.ViewPager in project JamsMusicPlayer by psaravan.
the class TabPageIndicator method setViewPager.
@Override
public void setViewPager(ViewPager view) {
if (mViewPager == view) {
return;
}
if (mViewPager != null) {
mViewPager.setOnPageChangeListener(null);
}
final PagerAdapter adapter = view.getAdapter();
if (adapter == null) {
throw new IllegalStateException("ViewPager does not have adapter instance.");
}
mViewPager = view;
view.setOnPageChangeListener(this);
notifyDataSetChanged();
}
use of android.support.v4.view.ViewPager in project weiciyuan by qii.
the class GalleryActivity method onCreate.
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.galleryactivity_layout);
animationView = (ImageView) findViewById(R.id.animation);
currentViewPositionLayout = findViewById(R.id.position_layout);
position = (TextView) findViewById(R.id.position);
TextView sum = (TextView) findViewById(R.id.sum);
// rect = ((AnimationRect) getIntent().getParcelableArrayListExtra("rect")).scaledBitmapRect;
MessageBean msg = getIntent().getParcelableExtra("msg");
ArrayList<String> tmp = msg.getThumbnailPicUrls();
for (int i = 0; i < tmp.size(); i++) {
urls.add(tmp.get(i).replace("thumbnail", "large"));
}
sum.setText(String.valueOf(urls.size()));
//jump to new gallery animation activity
if (urls.size() < 10 && ImageUtility.isThisBitmapCanRead(FileManager.getFilePathFromUrl(urls.get(0), FileLocationMethod.picture_large))) {
Intent intent = new Intent(this, GalleryAnimationActivity.class);
intent.putExtra("msg", getIntent().getParcelableExtra("msg"));
intent.putExtra("rect", getIntent().getParcelableArrayListExtra("rect"));
intent.putExtra("position", getIntent().getIntExtra("position", 0));
startActivity(intent);
overridePendingTransition(0, 0);
finish();
return;
}
pager = (ViewPager) findViewById(R.id.pager);
pager.setAdapter(new ImagePagerAdapter());
pager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
super.onPageSelected(position);
GalleryActivity.this.position.setText(String.valueOf(position + 1));
}
});
pager.setCurrentItem(getIntent().getIntExtra("position", 0));
pager.setOffscreenPageLimit(1);
pager.setPageTransformer(true, new ZoomOutPageTransformer());
pager.setPadding(0, Utility.dip2px(STATUS_BAR_HEIGHT_DP_UNIT), 0, 0);
}
use of android.support.v4.view.ViewPager in project weiciyuan by qii.
the class GalleryAnimationActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.galleryactivity_animation_layout);
rectList = getIntent().getParcelableArrayListExtra("rect");
MessageBean msg = getIntent().getParcelableExtra("msg");
ArrayList<String> tmp = msg.getThumbnailPicUrls();
for (int i = 0; i < tmp.size(); i++) {
urls.add(tmp.get(i).replace("thumbnail", "large"));
}
boolean disableHardwareLayerType = false;
for (String url : urls) {
if (url.contains(".gif")) {
disableHardwareLayerType = true;
break;
}
}
position = (TextView) findViewById(R.id.position);
initPosition = getIntent().getIntExtra("position", 0);
pager = (ViewPager) findViewById(R.id.pager);
pager.setAdapter(new ImagePagerAdapter(getSupportFragmentManager()));
final boolean finalDisableHardwareLayerType = disableHardwareLayerType;
pager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
super.onPageSelected(position);
GalleryAnimationActivity.this.position.setText(String.valueOf(position + 1));
}
@Override
public void onPageScrollStateChanged(int scrollState) {
if (scrollState != ViewPager.SCROLL_STATE_IDLE && finalDisableHardwareLayerType) {
final int childCount = pager.getChildCount();
for (int i = 0; i < childCount; i++) {
View child = pager.getChildAt(i);
if (child.getLayerType() != View.LAYER_TYPE_NONE) {
child.setLayerType(View.LAYER_TYPE_NONE, null);
}
}
}
}
});
pager.setCurrentItem(getIntent().getIntExtra("position", 0));
pager.setOffscreenPageLimit(1);
pager.setPageTransformer(true, new ZoomOutPageTransformer());
TextView sum = (TextView) findViewById(R.id.sum);
sum.setText(String.valueOf(urls.size()));
background = AnimationUtility.getAppContentView(this);
if (savedInstanceState != null) {
showBackgroundImmediately();
}
}
use of android.support.v4.view.ViewPager in project ExpandingPager by qs-lll.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
setupWindowAnimations();
TravelViewPagerAdapter adapter = new TravelViewPagerAdapter(getSupportFragmentManager());
adapter.addAll(generateTravelList());
viewPager.setAdapter(adapter);
ExpandingPagerFactory.setupViewPager(viewPager);
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
ExpandingFragment expandingFragment = ExpandingPagerFactory.getCurrentFragment(viewPager);
if (expandingFragment != null && expandingFragment.isOpenend()) {
expandingFragment.close();
}
}
@Override
public void onPageSelected(int position) {
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
}
use of android.support.v4.view.ViewPager in project ExpandingPager by qs-lll.
the class ExpandingPagerFactory method getCurrentFragment.
public static ExpandingFragment getCurrentFragment(ViewPager viewPager) {
if (viewPager.getAdapter() instanceof ExpandingViewPagerAdapter) {
ExpandingViewPagerAdapter adapter = (ExpandingViewPagerAdapter) viewPager.getAdapter();
Fragment fragment = adapter.getCurrentFragment();
if (fragment instanceof ExpandingFragment) {
return (ExpandingFragment) fragment;
}
}
return null;
}
Aggregations