Java Code Examples for android.support.v4.view.ViewPager

The following examples show how to use android.support.v4.view.ViewPager. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: letv   Source File: HomeFragment.java    License: Apache License 2.0 6 votes vote down vote up
private void findView() {
    this.myViewPager = (ViewPager) this.mRootView.findViewById(R.id.channel_detail_viewpager);
    this.mTabPageIndicator = (ChannelTabPageIndicator) this.mRootView.findViewById(R.id.channel_detail_indicator);
    this.mChannelWallIcon = (RelativeLayout) this.mRootView.findViewById(R.id.channel_wall_icon);
    this.mViewshadow = this.mRootView.findViewById(R.id.channel_wall_shadow);
    this.mChannelWallIcon.setOnClickListener(new OnClickListener(this) {
        final /* synthetic */ HomeFragment this$0;

        {
            if (HotFix.PREVENT_VERIFY) {
                System.out.println(VerifyLoad.class);
            }
            this.this$0 = this$0;
        }

        public void onClick(View v) {
            this.this$0.startChannelWallActivity();
        }
    });
    this.myViewPager.setOnTouchListener(this.onTouchListener);
    this.mRootView.setOnTouchListener(this.onTouchListener);
    this.mRootView.loading(false);
    this.mViewshadow.bringToFront();
}
 
Example 2
Source Project: HollyViewPager   Source File: HollyViewPager.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    addView(LayoutInflater.from(getContext()).inflate(R.layout.holly_view_pager, this, false));

    viewPager = (ViewPager) findViewById(R.id.bfp_viewPager);
    headerScroll = (HorizontalScrollView) findViewById(R.id.bfp_headerScroll);
    headerLayout = (ViewGroup) findViewById(R.id.bfp_headerLayout);

    {
        ViewGroup.LayoutParams layoutParams = headerLayout.getLayoutParams();
        layoutParams.height = this.settings.headerHeightPx;
        headerLayout.setLayoutParams(layoutParams);
    }

    animator = new HollyViewPagerAnimator(this);
}
 
Example 3
Source Project: IdealMedia   Source File: PlayerAdapter.java    License: Apache License 2.0 6 votes vote down vote up
public TrackViewHolder(View view) {
    super(view);

    index = (CircularProgressButton) view.findViewById(R.id.cell_index);
    artist = (TextView) view.findViewById(R.id.cell_artist);
    title = (TextView) view.findViewById(R.id.cell_title);
    duration = (TextView) view.findViewById(R.id.cell_duration);
    textSearchAuthor = (TextView) view.findViewById(R.id.textSearchAuthor);
    actionSetRingtone = view.findViewById(R.id.actionSetRingtone);
    actionShare = view.findViewById(R.id.actionShare);
    actionSearchArtist = view.findViewById(R.id.actionSearchAuthor);
    actionDownload = view.findViewById(R.id.actionDownload);
    actionToPlaylist = view.findViewById(R.id.actionToPlaylist);
    actionFromPlaylist = view.findViewById(R.id.actionFromPlaylist);
    artwork = (ImageView) view.findViewById(R.id.cell_artwork);
    downloadProgress = (CircularProgressButton) view.findViewById(R.id.track_cell_progress_download);

    viewPager = (ViewPager) view.findViewById(R.id.viewPager);
    mainView = viewPager.findViewById(R.id.item_page_0);
}
 
Example 4
Source Project: barterli_android   Source File: AboutUsPagerFragment.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                Bundle savedInstanceState) {
    init(container, savedInstanceState);
    setHasOptionsMenu(true);
    setActionBarTitle(getString(R.string.Aboutus_fragment_title));
    final View view = inflater
                    .inflate(R.layout.fragment_aboutus_pager, container, false);
    mTitles= new ArrayList<String>(Arrays.asList(getResources().getStringArray(R.array.aboutus_fragment_titles)));

    mAboutUsPager = (ViewPager) view.findViewById(R.id.pager_aboutus);

    mAdapter = new AboutUsPageAdapter(getChildFragmentManager(), mTitles);

    mAboutUsPager.setAdapter(mAdapter);

    mIndicator = (TitlePageIndicator) view
                    .findViewById(R.id.aboutUsTitlesIndicator);
    mIndicator.setOnPageChangeListener(this);
    mIndicator.setViewPager(mAboutUsPager);
    onPageSelected(0);
    return view;
}
 
Example 5
Source Project: Huochexing12306   Source File: UnderlinePageIndicator.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void setViewPager(ViewPager viewPager) {
    if (mViewPager == viewPager) {
        return;
    }
    if (mViewPager != null) {
        //Clear us from the old pager.
        mViewPager.setOnPageChangeListener(null);
    }
    if (viewPager.getAdapter() == null) {
        throw new IllegalStateException("ViewPager does not have adapter instance.");
    }
    mViewPager = viewPager;
    mViewPager.setOnPageChangeListener(this);
    invalidate();
    post(new Runnable() {
        @Override public void run() {
            if (mFades) {
                post(mFadeRunnable);
            }
        }
    });
}
 
Example 6
public CommentsTimeLinePagerAdapter(CommentsTimeLineFragment fragment, ViewPager viewPager, FragmentManager fm,
                                    SparseArray<Fragment> fragmentList) {
    super(fm);
    this.fragmentList = fragmentList;
    fragmentList.append(CommentsTimeLineFragment.COMMENTS_TO_ME_CHILD_POSITION,
            fragment.getCommentsToMeTimeLineFragment());
    fragmentList.append(CommentsTimeLineFragment.COMMENTS_BY_ME_CHILD_POSITION,
            fragment.getCommentsByMeTimeLineFragment());
    FragmentTransaction transaction = fragment.getChildFragmentManager().beginTransaction();
    if (!fragmentList.get(CommentsTimeLineFragment.COMMENTS_TO_ME_CHILD_POSITION).isAdded())
        transaction.add(viewPager.getId(), fragmentList.get(CommentsTimeLineFragment.COMMENTS_TO_ME_CHILD_POSITION),
                CommentsToMeTimeLineFragment.class.getName());
    if (!fragmentList.get(CommentsTimeLineFragment.COMMENTS_BY_ME_CHILD_POSITION).isAdded())
        transaction.add(viewPager.getId(), fragmentList.get(CommentsTimeLineFragment.COMMENTS_BY_ME_CHILD_POSITION),
                CommentsByMeTimeLineFragment.class.getName());
    if (!transaction.isEmpty()) {
        transaction.commit();
        fragment.getChildFragmentManager().executePendingTransactions();
    }
}
 
Example 7
Source Project: V.FlyoutTest   Source File: ActionBarTabsPager.java    License: MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mViewPager = new ViewPager(this);
    mViewPager.setId(R.id.pager);
    setContentView(mViewPager);

    final ActionBar bar = getActionBar();
    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    bar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE);

    mTabsAdapter = new TabsAdapter(this, mViewPager);
    mTabsAdapter.addTab(bar.newTab().setText("Simple"),
            CountingFragment.class, null);
    mTabsAdapter.addTab(bar.newTab().setText("List"),
            FragmentPagerSupport.ArrayListFragment.class, null);
    mTabsAdapter.addTab(bar.newTab().setText("Cursor"),
            CursorFragment.class, null);

    if (savedInstanceState != null) {
        bar.setSelectedNavigationItem(savedInstanceState.getInt("tab", 0));
    }
}
 
Example 8
Source Project: FlycoPageIndicator   Source File: RoundCornerIndicaor.java    License: MIT License 6 votes vote down vote up
@Override
public void setViewPager(ViewPager vp, int realCount) {
    if (isValid(vp)) {
        this.vp = vp;
        this.count = realCount;
        vp.removeOnPageChangeListener(this);
        vp.addOnPageChangeListener(this);

        unselectDrawables.clear();
        unselectRects.clear();
        for (int i = 0; i < count; i++) {
            unselectDrawables.add(new GradientDrawable());
            unselectRects.add(new Rect());
        }

        invalidate();
    }
}
 
Example 9
Source Project: XBanner   Source File: XBannerViewPager.java    License: Apache License 2.0 6 votes vote down vote up
private float getXVelocity() {
    float xVelocity = 0;
    Class viewpagerClass = ViewPager.class;
    try {
        Field velocityTrackerField = viewpagerClass.getDeclaredField("mVelocityTracker");
        velocityTrackerField.setAccessible(true);
        VelocityTracker velocityTracker = (VelocityTracker) velocityTrackerField.get(this);

        Field activePointerIdField = viewpagerClass.getDeclaredField("mActivePointerId");
        activePointerIdField.setAccessible(true);

        Field maximumVelocityField = viewpagerClass.getDeclaredField("mMaximumVelocity");
        maximumVelocityField.setAccessible(true);
        int maximumVelocity = maximumVelocityField.getInt(this);

        velocityTracker.computeCurrentVelocity(1000, maximumVelocity);
        xVelocity = VelocityTrackerCompat.getXVelocity(velocityTracker, activePointerIdField.getInt(this));
    } catch (Exception ignored) {
    }
    return xVelocity;
}
 
Example 10
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
    mCurrentPage = position;
    mPositionOffset = positionOffset;
    if (mFades) {
        if (positionOffsetPixels > 0) {
            removeCallbacks(mFadeRunnable);
            mPaint.setAlpha(0xFF);
        } else if (mScrollState != ViewPager.SCROLL_STATE_DRAGGING) {
            postDelayed(mFadeRunnable, mFadeDelay);
        }
    }
    invalidate();

    if (mListener != null) {
        mListener.onPageScrolled(position, positionOffset, positionOffsetPixels);
    }
}
 
Example 11
Source Project: BigApp_Discuz_Android   Source File: MainBottomTabLayout.java    License: Apache License 2.0 6 votes vote down vote up
private void setViewPager(ViewPager viewPager) {
        removeAllViews();
        mViewPager = viewPager;
        if (viewPager != null && viewPager.getAdapter() != null) {
            viewPager.setOnPageChangeListener(new InternalViewPagerListener());
            initTabLayout();
            viewPager.setCurrentItem(0);

//            for (int i : justBottonPosition) {
//                tabItemsNoJustButtonPosition.remove(i);
//                viewPagerAllPosition.add(i, i);
//            }
            for (int i = 0; i < justBottonPosition.size(); i++) {
                int j = justBottonPosition.get(i);
                tabItemsNoJustButtonPosition.remove(j - i);
                viewPagerAllPosition.add(j, j);
            }
        }
    }
 
Example 12
Source Project: iMoney   Source File: UnderlinePageIndicator.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
    mCurrentPage = position;
    mPositionOffset = positionOffset;
    if (mFades) {
        if (positionOffsetPixels > 0) {
            removeCallbacks(mFadeRunnable);
            mPaint.setAlpha(0xFF);
        } else if (mScrollState != ViewPager.SCROLL_STATE_DRAGGING) {
            postDelayed(mFadeRunnable, mFadeDelay);
        }
    }
    invalidate();

    if (mListener != null) {
        mListener.onPageScrolled(position, positionOffset, positionOffsetPixels);
    }
}
 
Example 13
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_downloads);

    initToolBar();

    SupportedDownloads.KernelContent content = new SupportedDownloads.KernelContent(getIntent().getStringExtra(JSON_INTENT));
    getSupportActionBar().setTitle(Utils.htmlFrom(content.getName()).toString());

    final ViewPager viewPager = findViewById(R.id.viewpager);

    LinkedHashMap<String, Fragment> items = new LinkedHashMap<>();

    List<SupportedDownloads.KernelContent.Feature> features = content.getFeatures();
    List<SupportedDownloads.KernelContent.Download> downloads = content.getDownloads();

    if (content.getShortDescription() != null && content.getLongDescription() != null) {
        items.put(getString(R.string.about), AboutFragment.newInstance(content));
    }

    if (features.size() > 0) {
        items.put(getString(R.string.features), FeaturesFragment.newInstance(features));
    }

    if (downloads.size() > 0) {
        items.put(getString(R.string.downloads), DownloadKernelFragment.newInstance(downloads));
    }

    viewPager.setOffscreenPageLimit(items.size());
    PagerAdapter pagerAdapter = new PagerAdapter(getSupportFragmentManager(), items);
    viewPager.setAdapter(pagerAdapter);

    TabLayout tabLayout = findViewById(R.id.tablayout);
    tabLayout.setupWithViewPager(viewPager);

    viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
}
 
Example 14
Source Project: PagerSlidingTabStrip   Source File: PagerSlidingTabStrip.java    License: Apache License 2.0 5 votes vote down vote up
public void setViewPager(ViewPager pager) {
    this.pager = pager;

    if (pager.getAdapter() == null) {
        throw new IllegalStateException("ViewPager does not have adapter instance.");
    }

    pager.setOnPageChangeListener(pageListener);

    notifyDataSetChanged();
}
 
Example 15
Source Project: ParallaxViewPagers   Source File: MainActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState)
  {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  final ViewPager viewPager=(ViewPager)findViewById(R.id.viewPager);
  final ViewPager viewPager2=(ViewPager)findViewById(R.id.viewPager2);
  viewPager.setAdapter(new MyPagerAdapter());
  viewPager2.setAdapter(new MyPagerAdapter());
  /**the current master viewPager*/
  AtomicReference<ViewPager> masterRef=new AtomicReference<>();
  viewPager.addOnPageChangeListener(new ParallaxOnPageChangeListener(viewPager,viewPager2,masterRef));
  viewPager2.addOnPageChangeListener(new ParallaxOnPageChangeListener(viewPager2,viewPager,masterRef));
  }
 
Example 16
Source Project: views-widgets-samples   Source File: SlidingTabLayout.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onPageSelected(int position) {
    if (mScrollState == ViewPager.SCROLL_STATE_IDLE) {
        mTabStrip.onViewPagerPageChanged(position, 0f);
        scrollToTab(position, 0);
    }

    if (mViewPagerPageChangeListener != null) {
        mViewPagerPageChangeListener.onPageSelected(position);
    }
}
 
Example 17
Source Project: LLApp   Source File: MusicActivity.java    License: Apache License 2.0 5 votes vote down vote up
protected void onInitView() {
        setTitle("西西音乐");
        Help.initSystemBar(this, StaticValue.color);//这个对所有的都适合
        Toolbar toolbar = (Toolbar)findViewById(R.id.toolbar1);
        toolbar.setBackgroundColor(StaticValue.color);
        setSupportActionBar(toolbar);
        toolbar.setTitleTextColor(Color.WHITE);//设置ToolBar的titl颜色
        toolbar.setNavigationIcon(R.mipmap.abc_ic_ab_back_mtrl_am_alpha);//必须放在setSupportActionBar后才有用,否则没有,设置返回图标
//        toolbar.setNavigationOnClickListener(back_btn);//添加按键监听
        toolbar.setNavigationOnClickListener(v -> {
            if (mSearchAutoComplete.isShown()) {
                try {
                    mSearchAutoComplete.setText("");
                    Method method = mSearchView.getClass().getDeclaredMethod("onCloseClicked");
                    method.setAccessible(true);
                    method.invoke(mSearchView);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            } else {
                finish();
            }
        });

        mSectionsPagerAdapter = new MySectionsPagerAdapter(getSupportFragmentManager());

        // Set up the ViewPager with the sections adapter.
        mViewPager = (ViewPager)findViewById(R.id.container);
        mViewPager.setAdapter(mSectionsPagerAdapter);

        TabLayout tabLayout = (TabLayout)findViewById(R.id.tabs);
        tabLayout.setTabTextColors(R.color.black,StaticValue.color);
        tabLayout.setSelectedTabIndicatorColor(StaticValue.color);
        tabLayout.setupWithViewPager(mViewPager);

        FloatingActionButton fab = (FloatingActionButton)findViewById(R.id.fab);
        MDTintUtil.setTint(fab, StaticValue.color);
        fab.setOnClickListener(view -> Snackbar.make(view,"敬请期待", Snackbar.LENGTH_LONG)
                        .setAction("Action",null).show());
    }
 
Example 18
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mTabTitle = findViewById(R.id.tab_title);

    //Setup viewpager and FeedFragmentAdapter
    ViewPager viewPager = findViewById(R.id.vp);
    FeedFragmentAdapter fragmentAdapter = new FeedFragmentAdapter(getSupportFragmentManager());
    viewPager.setAdapter(fragmentAdapter);

    TabLayout tabLayout = findViewById(R.id.main_tab_layout);
    tabLayout.setupWithViewPager(viewPager);


    viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
    tabLayout.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(viewPager));

    tabLayout.getTabAt(0).setIcon(tabSelectedIcon[0]);
    for (int i = 1; i < 4; i++) {
        tabLayout.getTabAt(i).setIcon(tabUnselectedIcon[i]);
    }

    tabLayout.addOnTabSelectedListener(this);

    mDrawerLayout = findViewById(R.id.drawer_layout);

    ImageView profileImage = findViewById(R.id.user_profile_image);
    Picasso.get()
            .load(R.drawable.twitter_profile_image)
            .transform(new CropCircleTransformation())
            .into(profileImage);
}
 
Example 19
public void initViews(){
    viewPager = (ViewPager)findViewById(R.id.Result_Combination_Viewpager);
    typeOneText = (TextView)findViewById(R.id.Result_Combination_TypeOne_TextView);
    typeTwoText = (TextView)findViewById(R.id.Result_Combination_TypeTwo_TextView);
    cursorImageView = (ImageView)findViewById(R.id.Result_Combination_Cursor_ImageView);

    shareMenu = (FloatingActionMenu)findViewById(R.id.combination_menu);
    share2friendButton = (FloatingActionButton)findViewById(R.id.combination_menu_item1);
    share2timelineButton = (FloatingActionButton)findViewById(R.id.combination_menu_item2);
}
 
Example 20
Source Project: LiveGiftLayout   Source File: GiftPanelControl.java    License: Apache License 2.0 5 votes vote down vote up
/**
     * @param context
     * @param viewPager    竖屏礼物面板的ViewPager
     * @param recyclerView 横屏礼物面板的RecycleView
     * @param dotsLayout   竖屏礼物面板的小圆点父布局
     */
    public GiftPanelControl(Context context, ViewPager viewPager, RecyclerView recyclerView, LinearLayout dotsLayout) {
        mContext = context;
        inflater = (LayoutInflater) context.getSystemService(LAYOUT_INFLATER_SERVICE);
        mViewpager = viewPager;
        mRecyclerView = recyclerView;
        mDotsLayout = dotsLayout;
//        init();
    }
 
Example 21
Source Project: ImageLoader   Source File: ImageMediaCenterUtil.java    License: Apache License 2.0 5 votes vote down vote up
private static void showFileInfo(ViewPager viewPager, List<String> urls, final Context context) {
    int position = viewPager.getCurrentItem();
    String url = urls.get(position);

    ImageLoader.getActualLoader().getFileFromDiskCache(url, new FileGetter() {
        @Override
        public void onSuccess(File file, int width, int height) {
            String text = file.getAbsolutePath();
            text += "\n" + MyUtil.formatFileSize(file.length());
            text += "\nw"+ width+"x"+height +"\n";
            text += MyUtil.printExif(file.getAbsolutePath());

            View view = View.inflate(context,R.layout.html,null);
            TextView textView = view.findViewById(R.id.tv_html);
            textView.setText(text);
            new AlertDialog.Builder(context)
                    .setView(view)
                    .create().show();
        }

        @Override
        public void onFail(Throwable e) {
            e.printStackTrace();

        }
    });





}
 
Example 22
Source Project: FlowHelper   Source File: BaseAction.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 设置 viewpager
 *
 */
public BaseAction setViewPager(final ViewPager viewPager) {
    mViewPager = viewPager;
    viewPager.addOnPageChangeListener(null);
    viewPager.addOnPageChangeListener(this);
    return this;

}
 
Example 23
Source Project: Expense-Tracker-App   Source File: ExpensesContainerFragment.java    License: MIT License 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_expenses_container, container, false);
    vpExpensesContainer = (ViewPager)rootView.findViewById(R.id.vp_expenses);
    return rootView;
}
 
Example 24
Source Project: ReadMark   Source File: BannerView.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 设置适配器
 * @param adapter
 */
public void setAdapter(BannerDataAdapter adapter) {
    mAdapter = adapter;
    //设置的适配器后才能设置圆点
    initDotIndicator();
    mBannerPageView.setAdapter(adapter);
    mBannerPageView.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener(){
        @Override
        public void onPageSelected(int position) {
            pageSelected(position);
        }
    });
    String firstDesc = mAdapter.getBannerDesc(0);
    mBannerDesc.setText(firstDesc);
}
 
Example 25
Source Project: JPTabBar   Source File: MainActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mTabbar = (JPTabBar) findViewById(tabbar);
        mPager = (ViewPager) findViewById(R.id.view_pager);
//        mTabbar.setTitles("asd","页面二","页面三","页面四").setNormalIcons(R.mipmap.tab1_normal,R.mipmap.tab2_normal,R.mipmap.tab3_normal,R.mipmap.tab4_normal)
//                .setSelectedIcons(R.mipmap.tab1_selected,R.mipmap.tab2_selected,R.mipmap.tab3_selected,R.mipmap.tab4_selected).generate();
        mTabbar.setTabTypeFace("fonts/Jaden.ttf");
        mTab1 = new Tab1Pager();
        mTab2 = new Tab2Pager();
        mTab3 = new Tab3Pager();
        mTab4 = new Tab4Pager();
        mTabbar.setGradientEnable(true);
        mTabbar.setPageAnimateEnable(true);
        mTabbar.setTabListener(this);
        list.add(mTab1);
        list.add(mTab2);
        list.add(mTab3);
        list.add(mTab4);

        mPager.setAdapter(new Adapter(getSupportFragmentManager(),list));
        mTabbar.setContainer(mPager);
        //设置Badge消失的代理
        mTabbar.setDismissListener(this);
        mTabbar.setTabListener(this);
        if(mTabbar.getMiddleView()!=null)
        mTabbar.getMiddleView().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(MainActivity.this,"中间点击",Toast.LENGTH_SHORT).show();;
            }
        });
    }
 
Example 26
@Override
public void onPageSelected(int position) {
    if (mCurrState == ViewPager.SCROLL_STATE_IDLE) {
        if (mCallback != null) {
            mCallback.onTransitionToIdle();
        }
    }
}
 
Example 27
Source Project: EmojiReactionView   Source File: MainActivity.java    License: MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    setupViewPager((ViewPager) findViewById(R.id.viewpager));

    tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager((ViewPager) findViewById(R.id.viewpager));

    setupTabIcons();
}
 
Example 28
Source Project: BubblePagerIndicator   Source File: BubblePageIndicator.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onPageSelected(final int position) {
    if (scrollState == ViewPager.SCROLL_STATE_IDLE) {
        if (startX == Integer.MIN_VALUE) {
            post(new Runnable() {
                @Override
                public void run() {
                    onPageManuallyChanged(position);
                }
            });
        } else {
            onPageManuallyChanged(position);
        }
    }
}
 
Example 29
@Override
public void onPageScrollStateChanged(int state) {
    if (state == ViewPager.SCROLL_STATE_IDLE) {
        scrollToChild(pager.getCurrentItem(), 0);
    }

    if (delegatePageListener != null) {
        delegatePageListener.onPageScrollStateChanged(state);
    }
}
 
Example 30
Source Project: shortrain   Source File: MainActivity.java    License: MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);

    ShortcutManager shortcutManager = getSystemService(ShortcutManager.class);

    shortcutManager.removeAllDynamicShortcuts();
    int newWallId = ShortcutsUtils.getNextRailNumber(shortcutManager);
    ShortcutInfo ballShortcut = ShortcutsUtils.createTrainShortcut(this);
    ShortcutInfo wallShortcut = ShortcutsUtils.createRailShortcut(this, newWallId);
    shortcutManager.setDynamicShortcuts(Arrays.asList(ballShortcut, wallShortcut));

    setContentView(R.layout.activity_main);

    rootView = findViewById(R.id.activity_main_root);

    viewPager = (ViewPager) findViewById(R.id.activity_main_view_pager);
    pagerAdapter = new TutorialViewPagerAdapter(getFragmentManager());
    viewPager.setAdapter(pagerAdapter);
    rootView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            finishActivity();
        }
    });
}