Search in sources :

Example 76 with ViewPager

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();
}
Also used : PagerAdapter(android.support.v4.view.PagerAdapter)

Example 77 with ViewPager

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);
}
Also used : MessageBean(org.qii.weiciyuan.bean.MessageBean) TextView(android.widget.TextView) Intent(android.content.Intent) ViewPager(android.support.v4.view.ViewPager) Point(android.graphics.Point)

Example 78 with ViewPager

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();
    }
}
Also used : MessageBean(org.qii.weiciyuan.bean.MessageBean) TextView(android.widget.TextView) ViewPager(android.support.v4.view.ViewPager) TextView(android.widget.TextView) View(android.view.View)

Example 79 with ViewPager

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) {
        }
    });
}
Also used : TravelViewPagerAdapter(com.qslll.expandingpager.adapter.TravelViewPagerAdapter) ExpandingFragment(com.qslll.library.fragments.ExpandingFragment) ViewPager(android.support.v4.view.ViewPager)

Example 80 with ViewPager

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;
}
Also used : ExpandingFragment(com.qslll.library.fragments.ExpandingFragment) Fragment(android.support.v4.app.Fragment) ExpandingFragment(com.qslll.library.fragments.ExpandingFragment)

Aggregations

ViewPager (android.support.v4.view.ViewPager)235 View (android.view.View)94 PagerAdapter (android.support.v4.view.PagerAdapter)55 Fragment (android.support.v4.app.Fragment)40 TabLayout (android.support.design.widget.TabLayout)34 FragmentPagerAdapter (android.support.v4.app.FragmentPagerAdapter)34 TextView (android.widget.TextView)34 Toolbar (android.support.v7.widget.Toolbar)30 Bundle (android.os.Bundle)27 ViewGroup (android.view.ViewGroup)27 FragmentStatePagerAdapter (android.support.v4.app.FragmentStatePagerAdapter)20 ImageView (android.widget.ImageView)20 ArrayList (java.util.ArrayList)19 Intent (android.content.Intent)14 ActionBar (android.support.v7.app.ActionBar)13 RecyclerView (android.support.v7.widget.RecyclerView)10 ViewTreeObserver (android.view.ViewTreeObserver)10 AdapterView (android.widget.AdapterView)9 LinearLayout (android.widget.LinearLayout)9 UiController (android.support.test.espresso.UiController)8