java类android.support.v4.view.ViewPager.SimpleOnPageChangeListener的实例源码

AddFoodListActivity.java 文件源码 项目:boohee_v5.6 阅读 18 收藏 0 点赞 0 评论 0
private void initViewPager() {
    this.mViewPager.setOffscreenPageLimit(5);
    this.mViewPager.setAdapter(new ArrayPagerAdapter(getSupportFragmentManager(), this
            .mContentFragments, this.mTitles));
    this.mSlidingTab.setViewPager(this.mViewPager);
    this.mSlidingTab.setOnPageChangeListener(new SimpleOnPageChangeListener() {
        public void onPageSelected(int position) {
            if (position == 1 && AddFoodListActivity.this.mFavoriteFragment.isFirstLoad) {
                MobclickAgent.onEvent(AddFoodListActivity.this.ctx, Event
                        .TOOL_FOODANDSPORT_FAVORITETAB);
                AddFoodListActivity.this.mFavoriteFragment.firstLoad();
            } else if (position == 2 && AddFoodListActivity.this.mCustomFoodFragmennt
                    .isFirstLoad) {
                MobclickAgent.onEvent(AddFoodListActivity.this.ctx, Event
                        .TOOL_FOODANDSPORT_MINETAB);
                AddFoodListActivity.this.mCustomFoodFragmennt.firstLoad();
            } else if (position == 3 && AddFoodListActivity.this.mUploadFoodFragment
                    .isFirstLoad) {
                AddFoodListActivity.this.mUploadFoodFragment.firstLoad();
            } else if (position == 4 && AddFoodListActivity.this.mCookFoodFragment
                    .isFirstLoad) {
                AddFoodListActivity.this.mCookFoodFragment.firstLoad();
            }
        }
    });
}
NewWeightGalleryActivity.java 文件源码 项目:boohee_v5.6 阅读 20 收藏 0 点赞 0 评论 0
private void init() {
    if (getIntent() == null) {
        finish();
        return;
    }
    this.mCurrentIndex = getIntent().getIntExtra(KEY_INDEX, 0);
    this.mPhotoList = getIntent().getParcelableArrayListExtra(KEY_WEIGHT_PHOTOS);
    if (this.mPhotoList == null || this.mPhotoList.size() == 0) {
        finish();
        return;
    }
    this.mAdapter = new ImagePagerAdapter(getSupportFragmentManager(), this.mPhotoList);
    this.viewpager.setAdapter(this.mAdapter);
    this.viewpager.addOnPageChangeListener(new SimpleOnPageChangeListener() {
        public void onPageSelected(int position) {
            NewWeightGalleryActivity.this.mCurrentIndex = position;
            NewWeightGalleryActivity.this.setCurrentItem();
        }
    });
    setCurrentItem();
}
ShopMainFragment.java 文件源码 项目:boohee_v5.6 阅读 19 收藏 0 点赞 0 评论 0
private void addListener() {
    this.mPullListView.setOnRefreshListener(new OnRefreshListener<ListView>() {
        public void onRefresh(PullToRefreshBase<ListView> pullToRefreshBase) {
            ShopMainFragment.this.requestShopHomePages();
        }
    });
    this.mPullListView.setOnLastItemVisibleListener(new OnLastItemVisibleListener() {
        public void onLastItemVisible() {
            if (ShopMainFragment.this.mPage > ShopMainFragment.this.mCurrentPage &&
                    ShopMainFragment.this.hasMore) {
                ShopMainFragment.this.mCurrentPage = ShopMainFragment.this.mPage;
                ShopMainFragment.this.requestShopHomeMoreGoods();
            }
        }
    });
    this.mIndicator.setOnPageChangeListener(new SimpleOnPageChangeListener() {
        public void onPageSelected(int position) {
            super.onPageSelected(position);
            ShopMainFragment.this.mCurrentIndex = position;
        }
    });
}
MyFavoriteActivity.java 文件源码 项目:boohee_v5.6 阅读 20 收藏 0 点赞 0 评论 0
private void initView() {
    initFragments();
    this.adapter = new CollectionPagerAdapter(getSupportFragmentManager(), this.fragmentList);
    this.viewpager.setAdapter(this.adapter);
    this.viewpager.setOffscreenPageLimit(2);
    this.slidingTabs.setViewPager(this.viewpager);
    this.slidingTabs.setOnPageChangeListener(new SimpleOnPageChangeListener() {
        public void onPageSelected(int position) {
            if (position == 1 && MyFavoriteActivity.this.webFavoriteFragment != null &&
                    MyFavoriteActivity.this.webFavoriteFragment.isFirstLoad()) {
                MyFavoriteActivity.this.webFavoriteFragment.pullToRefresh();
                MyFavoriteActivity.this.webFavoriteFragment.setIsFirstLoad(false);
            }
            super.onPageSelected(position);
        }
    });
}
MentionPreviewActivity.java 文件源码 项目:boohee_v5.6 阅读 27 收藏 0 点赞 0 评论 0
private void initView() {
    if (this.mentionList != null && this.mentionList.size() != 0) {
        this.pagerAdapter = new MentionPreviewPagerAdapter(getSupportFragmentManager(), this
                .mentionList);
        this.viewPager.setAdapter(this.pagerAdapter);
        this.viewPager.addOnPageChangeListener(new SimpleOnPageChangeListener() {
            public void onPageSelected(int position) {
                super.onPageSelected(position);
                MentionPreviewActivity.this.videoView.stopPlayback();
                MentionPreviewActivity.this.currentMention = (Mention) MentionPreviewActivity
                        .this.mentionList.get(position);
                MentionPreviewActivity.this.setCurrentIndex(position);
            }
        });
        this.viewPager.setCurrentItem(this.position);
        setCurrentIndex(this.position);
    }
}
GoodsDetailActivity.java 文件源码 项目:boohee_v5.6 阅读 28 收藏 0 点赞 0 评论 0
private void initActionbar() {
    View view_tab = LayoutInflater.from(this).inflate(R.layout.h1, null);
    this.mSlidingTab = (PagerSlidingTabStrip) view_tab.findViewById(R.id.sliding_tabs);
    LayoutParams layoutParams = new LayoutParams(-2, -1);
    layoutParams.gravity = GravityCompat.END;
    getSupportActionBar().setDisplayShowCustomEnabled(true);
    getSupportActionBar().setCustomView(view_tab, layoutParams);
    this.mSlidingTab.setViewPager(this.viewpager);
    this.mSlidingTab.setOnPageChangeListener(new SimpleOnPageChangeListener() {
        public void onPageSelected(int position) {
            super.onPageSelected(position);
            if (position == 1 && !GoodsDetailActivity.this.isSecondLoad) {
                GoodsDetailActivity.this.goodsPostsFragment.loadFirst();
                GoodsDetailActivity.this.isSecondLoad = true;
            }
        }
    });
}
MQPhotoPreviewActivity.java 文件源码 项目:boohee_v5.6 阅读 28 收藏 0 点赞 0 评论 0
private void initListener() {
    findViewById(R.id.back_iv).setOnClickListener(this);
    this.mDownloadIv.setOnClickListener(this);
    this.mContentHvp.addOnPageChangeListener(new SimpleOnPageChangeListener() {
        public void onPageSelected(int position) {
            MQPhotoPreviewActivity.this.renderTitleTv();
        }
    });
}
MQPhotoPickerPreviewActivity.java 文件源码 项目:boohee_v5.6 阅读 20 收藏 0 点赞 0 评论 0
private void initListener() {
    findViewById(R.id.back_iv).setOnClickListener(this);
    this.mSubmitTv.setOnClickListener(this);
    this.mChooseTv.setOnClickListener(this);
    this.mContentHvp.addOnPageChangeListener(new SimpleOnPageChangeListener() {
        public void onPageSelected(int position) {
            MQPhotoPickerPreviewActivity.this.handlePageSelectedStatus();
        }
    });
}
MQEmotionKeyboardLayout.java 文件源码 项目:boohee_v5.6 阅读 28 收藏 0 点赞 0 评论 0
protected void setListener() {
    this.mContentVp.addOnPageChangeListener(new SimpleOnPageChangeListener() {
        public void onPageSelected(int position) {
            for (int i = 0; i < MQEmotionKeyboardLayout.this.mIndicatorIvList.size(); i++) {
                ((ImageView) MQEmotionKeyboardLayout.this.mIndicatorIvList.get(i)).setEnabled
                        (false);
            }
            ((ImageView) MQEmotionKeyboardLayout.this.mIndicatorIvList.get(position))
                    .setEnabled(true);
        }
    });
}
AddSportListActivity.java 文件源码 项目:boohee_v5.6 阅读 21 收藏 0 点赞 0 评论 0
private void initViewPager() {
    this.mViewPager.setOffscreenPageLimit(this.mTitles.length);
    this.mViewPager.setAdapter(new ArrayPagerAdapter(getSupportFragmentManager(), this
            .mContentFragments, this.mTitles));
    this.mSlidingTab.setViewPager(this.mViewPager);
    this.mSlidingTab.setOnPageChangeListener(new SimpleOnPageChangeListener() {
        public void onPageSelected(int position) {
            if (position == 1 && AddSportListActivity.this.mCustomSportFragment.isFirstLoad) {
                AddSportListActivity.this.mCustomSportFragment.firstLoad();
            }
        }
    });
}
BetFragment.java 文件源码 项目:boohee_v5.6 阅读 19 收藏 0 点赞 0 评论 0
private void initView() {
    this.scrollview.setOnRefreshListener(new OnRefreshListener<ScrollView>() {
        public void onRefresh(PullToRefreshBase<ScrollView> pullToRefreshBase) {
            BetFragment.this.loadData();
        }
    });
    this.tipsIndicator.setOnPageChangeListener(new SimpleOnPageChangeListener() {
        public void onPageSelected(int position) {
            super.onPageSelected(position);
            BetFragment.this.currentItem = position;
        }
    });
    ViewUtils.setViewScaleHeight(getActivity(), this.ivBetTop, 750, 250);
}
NewPartnerFragment.java 文件源码 项目:boohee_v5.6 阅读 34 收藏 0 点赞 0 评论 0
private void addListener() {
    this.scrollView.setOnRefreshListener(new OnRefreshListener<ScrollView>() {
        public void onRefresh(PullToRefreshBase<ScrollView> pullToRefreshBase) {
            NewPartnerFragment.this.initUI();
        }
    });
    this.indicator.setOnPageChangeListener(new SimpleOnPageChangeListener() {
        public void onPageSelected(int position) {
            super.onPageSelected(position);
            NewPartnerFragment.this.mCurrentItem = position;
        }
    });
}
PartnerFragment.java 文件源码 项目:boohee_v5.6 阅读 20 收藏 0 点赞 0 评论 0
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    this.mTabLayout = ((MainActivity) getActivity()).getPartnerTab();
    this.mTitleList.add("精选");
    this.mTitleList.add("好友圈");
    this.mFabButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            if (!PartnerFragment.this.isDetached()) {
                new BuilderIntent(PartnerFragment.this.getActivity(), StatusPostTextActivity
                        .class).startActivity();
            }
        }
    });
    this.mAdapter = new PartnerFragmentAdapter(getActivity().getSupportFragmentManager());
    this.mFragmentList.add(new PartnerDiscoverFragment());
    this.mFragmentList.add(new HomeTimelineFragment());
    this.mViewPager.setAdapter(this.mAdapter);
    this.mViewPager.addOnPageChangeListener(new SimpleOnPageChangeListener() {
        public void onPageSelected(int position) {
            PartnerFragment.this.mCache.put(CacheKey.HOME_STATUS_TAB, String.valueOf(position));
        }
    });
    this.mTabLayout.setupWithViewPager(this.mViewPager);
    this.mTabLayout.setTabMode(1);
    EventBus.getDefault().register(this);
    this.mViewPager.post(new Runnable() {
        public void run() {
            try {
                PartnerFragment.this.mViewPager.setCurrentItem(Integer.parseInt
                        (PartnerFragment.this.mCache.getAsString(CacheKey.HOME_STATUS_TAB)));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
}
BannerPager.java 文件源码 项目:Shared-Route 阅读 19 收藏 0 点赞 0 评论 0
public void setImage(ArrayList<Integer> imageList) {
    for (int i = 0; i < imageList.size(); i++) {
        Integer imageID = ((Integer) imageList.get(i)).intValue();
        ImageView iv = new ImageView(mContext);
        iv.setLayoutParams(new LayoutParams(
                LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
        iv.setScaleType(ImageView.ScaleType.FIT_XY);
        iv.setImageResource(imageID);
        iv.setOnClickListener(this);
        mViewList.add(iv);
    }
    mPager.setAdapter(new ImageAdapater());
    mPager.addOnPageChangeListener(new SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            setButton(position);
        }
    });

    mCount = imageList.size();
    for (int i = 0; i < mCount; i++) {
        RadioButton radio = new RadioButton(mContext);
        radio.setLayoutParams(new RadioGroup.LayoutParams(dip_15, dip_15));
        radio.setGravity(Gravity.CENTER);
        radio.setButtonDrawable(R.drawable.indicator_selector);
        mGroup.addView(radio);
    }
    mPager.setCurrentItem(0);
    setButton(0);
}
Home.java 文件源码 项目:msb-android 阅读 24 收藏 0 点赞 0 评论 0
private void initViewPager() {
    mViewPager.setPageMargin(UIUtils.dip2px(10));
    mViewPager.setPageMarginDrawable(new ColorDrawable(0x00FFFFFF));

    mAdapter = new HomePagerAdapter(getChildFragmentManager());
    mViewPager.setAdapter(mAdapter);
    mViewPager.setOnPageChangeListener(new SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            mTabView.switchButton(position == 0);
        }
    });
}
ControllerFragment.java 文件源码 项目:MiraSlide 阅读 19 收藏 0 点赞 0 评论 0
/** We create the viewpager which shows the pages of the pdf file. If the user change the slide, the listener
 * updates tell the parent Activity to change the image in the presentation.
 * 
 * @param v : the fragment view
 */
private void createViewPager(View v) {
    mSlidesPagerAdapter = new SlidesPagerAdapter(((FragmentActivity) getActivity()).getSupportFragmentManager());
    mSlidesViewPager = (ViewPager) v.findViewById(R.id.fragment_controller_pager);
    mSlidesViewPager.setAdapter(mSlidesPagerAdapter);
    mSlidesViewPager.setOnPageChangeListener(new SimpleOnPageChangeListener() {

        @Override
        public void onPageSelected(int page) {
            ((MainActivity) getActivity()).getPresentation().moveTo(page);
        }
    });
}
StudentDetailActivity.java 文件源码 项目:teacher_toolkit 阅读 19 收藏 0 点赞 0 评论 0
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_student_detail);

    // define tab titles
    mTabTitles = new String[] { "基本資料", "筆記", "成績", "獎懲", "出缺勤" };

    // ViewPager and its adapters use support library
    // fragments, so use getSupportFragmentManager.
    mDemoCollectionPagerAdapter = new DemoCollectionPagerAdapter(
            getSupportFragmentManager());
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mDemoCollectionPagerAdapter);
    mViewPager.setOnPageChangeListener(new SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            // When swiping between pages, select the
            // corresponding tab.
            getActionBar().setSelectedNavigationItem(position);
            Log.d("DEBUG", "page selected :position" + position);
        }
    });

    // get StudentInfo object
    Intent i = getIntent();
    String ap_id = i.getStringExtra(PARAM_APID);
    String student_id = i.getStringExtra(PARAM_STUDENT_ID);
    mStud = StudentsTempData.getStudentByID(ap_id, student_id);

    String title = mStud.getName() + "(" + mStud.getClassName() + " "
            + mStud.getSeatNo() + "號, "
            + APTempData.getAPByID(mStud.getAPID()).getFullName() + ")";
    getActionBar().setTitle(title);
    getActionBar().setDisplayHomeAsUpEnabled(true);

    // init tabs
    initTabs();
}
PartnerDiscoverFragment.java 文件源码 项目:boohee_v5.6 阅读 18 收藏 0 点赞 0 评论 0
private void initViews() {
    View headerView = LayoutInflater.from(getActivity()).inflate(R.layout.qc, null, false);
    this.viewPager = (ViewPager) headerView.findViewById(R.id.viewpager_partner);
    this.indicator = (LinePageIndicator) headerView.findViewById(R.id.indicator);
    this.flPartner = (FrameLayout) headerView.findViewById(R.id.fl_partner);
    this.llLabel = (LinearLayout) headerView.findViewById(R.id.ll_label);
    this.tvHint = (TextView) getView().findViewById(R.id.tv_hint);
    this.tvHint.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            PartnerDiscoverFragment.this.onRefresh();
        }
    });
    this.mListView = (ListView) this.mPullRefreshListView.getRefreshableView();
    this.mListView.addHeaderView(headerView);
    this.mPostAdapter = new HomeTimelineAdapter(getActivity(), this.mPosts);
    this.mPullRefreshListView.setAdapter(this.mPostAdapter);
    this.mPullRefreshListView.setOnRefreshListener(new OnRefreshListener<ListView>() {
        public void onRefresh(PullToRefreshBase<ListView> pullToRefreshBase) {
            PartnerDiscoverFragment.this.hasLoadSlider = false;
            PartnerDiscoverFragment.this.hasLoadPost = false;
            PartnerDiscoverFragment.this.hideHint();
            PartnerDiscoverFragment.this.requestSliders();
            PartnerDiscoverFragment.this.getCurrentTopic();
        }
    });
    this.mPullRefreshListView.setOnLastItemVisibleListener(new OnLastItemVisibleListener() {
        public void onLastItemVisible() {
            if (!PartnerDiscoverFragment.this.isLastVisible) {
                PartnerDiscoverFragment.this.getNextTopic();
            }
        }
    });
    this.indicator.setOnPageChangeListener(new SimpleOnPageChangeListener() {
        public void onPageSelected(int position) {
            super.onPageSelected(position);
            PartnerDiscoverFragment.this.mCurrentItem = position;
        }
    });
    JSONObject object = this.mCache.getAsJSONObject(CacheKey.NEW_SQUARE_LIGHT);
    initHeader(object);
    initLable(object);
    new Handler().postDelayed(new Runnable() {
        public void run() {
            if (PartnerDiscoverFragment.this.isLoadFirst && PartnerDiscoverFragment.this
                    .mPullRefreshListView != null) {
                PartnerDiscoverFragment.this.mPullRefreshListView.setRefreshing(true);
            }
        }
    }, 800);
}
ShopCategoryActivity.java 文件源码 项目:boohee_v5.6 阅读 19 收藏 0 点赞 0 评论 0
private void initViewPager(ShopList shopList) {
    if (shopList != null) {
        if (!TextUtils.isEmpty(shopList.name)) {
            setTitle(shopList.name);
        }
        List<Label> labels = shopList.sub_labels;
        if (labels != null && labels.size() > 0) {
            final BaseFragmentPagerAdapter fragmentAdapter = new BaseFragmentPagerAdapter
                    (getSupportFragmentManager());
            for (int i = 0; i < labels.size(); i++) {
                Label label = (Label) labels.get(i);
                if (i == 0) {
                    fragmentAdapter.addFragment(ShopCategoryFragment.newInstance(this
                            .labelId, label.id, shopList), label.name);
                } else {
                    fragmentAdapter.addFragment(ShopCategoryFragment.newInstance(this
                            .labelId, label.id), label.name);
                }
            }
            this.mViewPager.setAdapter(fragmentAdapter);
            this.mViewPager.setOffscreenPageLimit(labels.size());
            this.mSlidingTab.setViewPager(this.mViewPager);
            if (labels != null && labels.size() <= 1) {
                this.mSlidingTab.setVisibility(8);
            } else if (labels != null && labels.size() > 1) {
                this.mSlidingTab.setVisibility(0);
            }
            this.mSlidingTab.setOnPageChangeListener(new SimpleOnPageChangeListener() {
                public void onPageSelected(int position) {
                    ShopCategoryFragment shopLabelFragment = (ShopCategoryFragment)
                            fragmentAdapter.getItem(position);
                    if (position == 0 && shopLabelFragment.isFirstLoad) {
                        shopLabelFragment.loadAll();
                    } else if (shopLabelFragment.isFirstLoad) {
                        shopLabelFragment.loadFirst();
                    }
                }
            });
        }
    }
}
ImageViewer.java 文件源码 项目:Mizuu 阅读 24 收藏 0 点赞 0 评论 0
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (MizLib.hasKitKat()) {
        setTheme(R.style.Mizuu_Theme_Translucent_FullScreen);
    } else {
        setTheme(R.style.Mizuu_Theme_Transparent_FullScreen);
    }

    ViewUtils.setupWindowFlagsForStatusbarOverlay(getWindow(), true);

    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(mToolbar);

    ViewUtils.setProperToolbarSize(this, mToolbar);

    getSupportActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.transparent_actionbar));

    mBus = MizuuApplication.getBus();

    mPortraitPhotos = getIntent().getBooleanExtra("portraitPhotos", true);
    mPhotos = getIntent().getStringArrayExtra("photos");

    getSupportActionBar().setTitle((getIntent().getIntExtra("selectedIndex", 0) + 1) + " " + getString(R.string.of) + " " + mPhotos.length);

    mViewPager = (ViewPager) findViewById(R.id.awesomepager);
    mViewPager.setPageMargin(MizLib.convertDpToPixels(getApplicationContext(), 16));
    mViewPager.setAdapter(new ActorPhotosAdapter(getSupportFragmentManager()));
    mViewPager.setOnPageChangeListener(new SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int arg0) {
            getSupportActionBar().setTitle((arg0 + 1) + " " + getString(R.string.of) + " " + mPhotos.length);
        }

    });
    mViewPager.setCurrentItem(getIntent().getIntExtra("selectedIndex", 0));

    View decorView = getWindow().getDecorView();
    decorView.setOnSystemUiVisibilityChangeListener(new OnSystemUiVisibilityChangeListener() {
        @Override
        public void onSystemUiVisibilityChange(int visibility) {
            if (visibility == 0) {
                // The UI is visible due to user interaction - let's hide it again after three seconds
                mHandler.postDelayed(mHideSystemUiRunnable, 3000);
            }
        }
    });
}


问题


面经


文章

微信
公众号

扫码关注公众号