com.pdftron.pdf.utils.StickyNotePagerAdapter.java Source code

Java tutorial

Introduction

Here is the source code for com.pdftron.pdf.utils.StickyNotePagerAdapter.java

Source

//---------------------------------------------------------------------------------------
// Copyright (c) 2001-2014 by PDFTron Systems Inc. All Rights Reserved.
// Consult legal.txt regarding legal and license information.
//---------------------------------------------------------------------------------------

package com.pdftron.pdf.utils;

import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;

import java.util.List;

public class StickyNotePagerAdapter extends PagerAdapter {

    private List<Integer> mData;
    private View mMainView;

    public StickyNotePagerAdapter(List<Integer> data, View mainView) {
        mData = data;
        mMainView = mainView;
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        View view = mMainView.findViewById(mData.get(position));
        container.addView(view);
        return view;
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView((View) object);
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }

    @Override
    public int getCount() {
        return mData.size();
    }

    public void updateData(List<Integer> data) {
        mData = data;
        notifyDataSetChanged();
    }

}