Android Open Source - ShareManager Swipe Listener

From Project

Back to project page ShareManager.


The source code is released under:

Copyright (c) 2013, Nelspike All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Red...

If you think the Android project ShareManager listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package share.manager.listeners;
/*from  w  w w  . ja  va  2 s . c  o m*/
import share.manager.adapters.MainPagerAdapter;
import share.manager.fragments.MineFragment;
import share.manager.fragments.PortfolioFragment;
import share.manager.fragments.SharesFragment;
import android.content.Context;

public class SwipeListener extends ViewPager.SimpleOnPageChangeListener {

  private ViewPager mViewPager;
  private Context context;

  public SwipeListener(ViewPager mViewPager, Context context) {
    this.mViewPager = mViewPager;
    this.context = context;

  public void onPageSelected(int position) {
    MainPagerAdapter adapter = (MainPagerAdapter) mViewPager.getAdapter();

    if (position == 0) {
      ((MineFragment) adapter.instantiateItem(mViewPager, position)).refresh();
    else if (position == 1) {
      ((SharesFragment) adapter.instantiateItem(mViewPager, position))
    else {
      ((PortfolioFragment) adapter.instantiateItem(mViewPager, position))

    ((Activity) context).getActionBar().setSelectedNavigationItem(position);



Java Source Code List