Example usage for android.support.v4.view ViewPager getContext

List of usage examples for android.support.v4.view ViewPager getContext

Introduction

In this page you can find the example usage for android.support.v4.view ViewPager getContext.

Prototype

@ViewDebug.CapturedViewProperty
public final Context getContext() 

Source Link

Document

Returns the context the view is running in, through which it can access the current theme, resources, etc.

Usage

From source file:com.manaschaudhari.android_mvvm.sample.BindingAdapters.java

/**
 * Binding Adapter Wrapper for checking memory leak
 *//*  w  ww.  j a  v  a  2 s. c  o  m*/
@BindingAdapter({ "items", "view_provider" })
public static void bindViewPagerAdapter(ViewPager viewPager, io.reactivex.Observable<List<ViewModel>> items,
        ViewProvider viewProvider) {
    PagerAdapter previousAdapter = viewPager.getAdapter();
    BindingUtils.bindAdapterWithDefaultBinder(viewPager, items, viewProvider);

    // Previous adapter should get deallocated
    if (previousAdapter != null)
        ExampleApplication.getRefWatcher(viewPager.getContext()).watch(previousAdapter);
}

From source file:org.centum.android.learn.LearnPagerAdapter.java

public LearnPagerAdapter(ViewPager viewPager, Stack stack) {
    viewPager.setOnPageChangeListener(this);
    this.context = viewPager.getContext();
    this.stack = stack;
    loadMoreCards();//  w ww .j  a  v  a  2 s.  co m
}

From source file:com.vuze.android.remote.adapter.TorrentDetailsPagerAdapter.java

public TorrentDetailsPagerAdapter(FragmentManager fm, ViewPager pager, PagerSlidingTabStrip tabs) {
    super(fm);/*from   w  w w . j  a  va  2s.  c  o  m*/
    this.tabs = tabs;
    count = 4;
    if (pager.getContext() instanceof SessionInfoGetter) {
        SessionInfoGetter getter = (SessionInfoGetter) pager.getContext();
        sessionInfo = getter.getSessionInfo();
    }
    init(fm, pager, tabs);
}

From source file:com.shopify.buy.ui.ProductImagePagerAdapter.java

@Override
public View getView(final int pos, ViewPager pager) {
    Context context = pager.getContext();
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    ViewGroup layout = (ViewGroup) inflater.inflate(R.layout.view_product_image, pager, false);
    layout.setTag(pos);/*  w  w w  .j a  v  a 2s  . c o m*/

    final View imageLoadingIndicator = layout.findViewById(R.id.image_loading_indicator);
    final ImageView imageView = (ImageView) layout.findViewById(R.id.image);

    if (bitmaps == null) {
        bitmaps = new Bitmap[images.size()];
        Arrays.fill(bitmaps, null);
    }

    final boolean needBitmap = bitmaps[pos] == null;
    if (!needBitmap) {
        imageLoadingIndicator.setVisibility(View.INVISIBLE);
        imageView.setImageBitmap(bitmaps[pos]);

    } else {
        // We don't ask Picasso to show a placeholder because we want to scale the placeholder differently than
        // the product image. The placeholder should be displayed using CENTER_INSIDE, while the image should be
        // loaded using Picasso's fit() request method (to reduce memory usage during decoding) and then cropped
        // or fitted into the target view.
        String imageUrl = stripQueryFromUrl(images.get(pos).getSrc());
        ImageUtility.loadRemoteImageIntoViewWithoutSize(Picasso.with(context), imageUrl, imageView, maxWidth,
                maxHeight, false, new Callback() {
                    @Override
                    public void onSuccess() {
                        bitmaps[pos] = ((BitmapDrawable) imageView.getDrawable()).getBitmap();
                        imageLoadingIndicator.setVisibility(View.INVISIBLE);
                        addBackgroundColor(pos);
                    }

                    @Override
                    public void onError() {
                        imageLoadingIndicator.setVisibility(View.VISIBLE);
                    }
                });
    }

    return layout;
}

From source file:com.roughike.swipeselector.SwipeAdapter.java

private SwipeAdapter(ViewPager viewPager, ViewGroup indicatorContainer, int indicatorSize, int indicatorMargin,
        int inActiveIndicatorColor, int activeIndicatorColor, int leftButtonResource, int rightButtonResource,
        ImageView leftButton, ImageView rightButton, String customFontPath, int titleTextAppearance,
        int descriptionTextAppearance) {
    mContext = viewPager.getContext();

    mViewPager = viewPager;/* w  w  w  .  j  a v  a  2  s  .c om*/
    mViewPager.addOnPageChangeListener(this);

    mIndicatorContainer = indicatorContainer;
    mCircleParams = new LinearLayout.LayoutParams(indicatorSize, indicatorSize);
    mCircleParams.leftMargin = indicatorMargin;

    mInActiveCircleDrawable = Indicator.newOne(indicatorSize, inActiveIndicatorColor);
    mActiveCircleDrawable = Indicator.newOne(indicatorSize, activeIndicatorColor);

    if (customFontPath != null && !customFontPath.isEmpty()) {
        mCustomTypeFace = Typeface.createFromAsset(mContext.getAssets(), customFontPath);
    }

    mTitleTextAppearance = titleTextAppearance;
    mDescriptionTextAppearance = descriptionTextAppearance;

    mLeftButton = leftButton;
    mLeftButton.setImageResource(leftButtonResource);

    mRightButton = rightButton;
    mRightButton.setImageResource(rightButtonResource);

    // Calculate paddings for the content so the left and right buttons
    // don't overlap.
    mSweetSixteen = (int) PixelUtils.dpToPixel(mContext, 16);
    mContentLeftPadding = ContextCompat.getDrawable(mContext, leftButtonResource).getIntrinsicWidth()
            + mSweetSixteen;
    mContentRightPadding = ContextCompat.getDrawable(mContext, rightButtonResource).getIntrinsicWidth()
            + mSweetSixteen;

    mLeftButton.setOnClickListener(this);
    mRightButton.setOnClickListener(this);

    mLeftButton.setTag(TAG_HIDDEN);
    mLeftButton.setClickable(false);
    mLeftButton.setAlpha(0.0f);
}

From source file:com.github.antoniodisanto92.swipeselector.SwipeAdapter.java

private SwipeAdapter(ViewPager viewPager, ViewGroup indicatorContainer, int indicatorSize, int indicatorMargin,
        int inActiveIndicatorColor, int activeIndicatorColor, int leftButtonResource, int rightButtonResource,
        ImageView leftButton, ImageView rightButton, String customFontPath, int titleTextAppearance,
        int descriptionTextAppearance, int descriptionGravity) {
    mContext = viewPager.getContext();

    mViewPager = viewPager;// w  w w . j  ava2 s  .  c  o  m
    mViewPager.addOnPageChangeListener(this);

    mIndicatorContainer = indicatorContainer;
    mCircleParams = new LinearLayout.LayoutParams(indicatorSize, indicatorSize);
    mCircleParams.leftMargin = indicatorMargin;

    mInActiveCircleDrawable = Indicator.newOne(indicatorSize, inActiveIndicatorColor);
    mActiveCircleDrawable = Indicator.newOne(indicatorSize, activeIndicatorColor);

    if (customFontPath != null
            && ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB && !customFontPath.isEmpty())
                    || customFontPath.length() > 0)) {
        mCustomTypeFace = Typeface.createFromAsset(mContext.getAssets(), customFontPath);
    }

    mTitleTextAppearance = titleTextAppearance;
    mDescriptionTextAppearance = descriptionTextAppearance;
    mDescriptionGravity = getGravity(descriptionGravity);

    mLeftButton = leftButton;
    mLeftButton.setImageResource(leftButtonResource);

    mRightButton = rightButton;
    mRightButton.setImageResource(rightButtonResource);

    // Calculate paddings for the content so the left and right buttons
    // don't overlap.
    mSweetSixteen = (int) PixelUtils.dpToPixel(mContext, 16);
    mContentLeftPadding = ContextCompat.getDrawable(mContext, leftButtonResource).getIntrinsicWidth()
            + mSweetSixteen;
    mContentRightPadding = ContextCompat.getDrawable(mContext, rightButtonResource).getIntrinsicWidth()
            + mSweetSixteen;

    mLeftButton.setOnClickListener(this);
    mRightButton.setOnClickListener(this);

    mLeftButton.setTag(TAG_HIDDEN);
    mLeftButton.setClickable(false);

    setAlpha(0.0f, mLeftButton);
}