Search in sources :

Example 1 with PagedView

use of greendroid.widget.PagedView in project simplefacebook by androidquery.

the class ImageActivity method initView.

private void initView() {
    photos = new ArrayList<FeedItem>();
    pv = (PagedView) findViewById(R.id.paged);
    pi = (PageIndicator) findViewById(R.id.page_indicator);
    pv.setOnPageChangeListener(new OnPagedViewChangeListener() {

        @Override
        public void onStopTracking(PagedView pagedView) {
        }

        @Override
        public void onStartTracking(PagedView pagedView) {
        }

        @Override
        public void onPageChanged(PagedView pagedView, int previousPage, int newPage) {
            pi.setActiveDot(newPage);
        }
    });
    adapter = new PagedAdapter() {

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            if (position >= photos.size())
                return PageAdapter.getEmptyView(parent);
            FeedItem item = photos.get(position);
            String url = item.getSource();
            if (url == null)
                return PageAdapter.getEmptyView(parent);
            String name = item.getItemName();
            View cached = photoViews.get(url);
            if (cached == null) {
                convertView = aq.inflate(null, R.layout.item_photo, parent);
                photoViews.put(url, convertView);
            } else {
                convertView = cached;
                return convertView;
            }
            PQuery aq = aq2.recycle(convertView);
            aq.id(R.id.web).progress(R.id.progress).invisible();
            AQUtility.debug("image load url", url);
            aq.webImage(url, true, false, 0xFF000000);
            aq.id(R.id.text).text(name, BufferType.NORMAL, true);
            convertView.setDrawingCacheEnabled(true);
            return convertView;
        }

        @Override
        public long getItemId(int position) {
            return position;
        }

        @Override
        public Object getItem(int position) {
            return photos.get(position);
        }

        @Override
        public int getCount() {
            return photos.size();
        }
    };
    pv.setAdapter(adapter);
}
Also used : PagedView(greendroid.widget.PagedView) FeedItem(com.androidquery.simplefeed.data.FeedItem) ViewGroup(android.view.ViewGroup) OnPagedViewChangeListener(greendroid.widget.PagedView.OnPagedViewChangeListener) PQuery(com.androidquery.simplefeed.PQuery) PagedAdapter(greendroid.widget.PagedAdapter) JSONObject(org.json.JSONObject) PagedView(greendroid.widget.PagedView) View(android.view.View)

Example 2 with PagedView

use of greendroid.widget.PagedView in project GreenDroid by cyrilmottier.

the class PagedViewActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setActionBarContentView(R.layout.paged_view);
    final PagedView pagedView = (PagedView) findViewById(R.id.paged_view);
    pagedView.setOnPageChangeListener(mOnPagedViewChangedListener);
    pagedView.setAdapter(new PhotoSwipeAdapter());
    mPageIndicatorNext = (PageIndicator) findViewById(R.id.page_indicator_next);
    mPageIndicatorNext.setDotCount(PAGE_MAX_INDEX);
    mPageIndicatorNext.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            pagedView.smoothScrollToNext();
        }
    });
    mPageIndicatorPrev = (PageIndicator) findViewById(R.id.page_indicator_prev);
    mPageIndicatorPrev.setDotCount(PAGE_MAX_INDEX);
    mPageIndicatorPrev.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            pagedView.smoothScrollToPrevious();
        }
    });
    mPageIndicatorOther = (PageIndicator) findViewById(R.id.page_indicator_other);
    mPageIndicatorOther.setDotCount(PAGE_COUNT);
    setActivePage(pagedView.getCurrentPage());
}
Also used : PagedView(greendroid.widget.PagedView) OnClickListener(android.view.View.OnClickListener) PagedView(greendroid.widget.PagedView) TextView(android.widget.TextView) View(android.view.View)

Aggregations

View (android.view.View)2 PagedView (greendroid.widget.PagedView)2 OnClickListener (android.view.View.OnClickListener)1 ViewGroup (android.view.ViewGroup)1 TextView (android.widget.TextView)1 PQuery (com.androidquery.simplefeed.PQuery)1 FeedItem (com.androidquery.simplefeed.data.FeedItem)1 PagedAdapter (greendroid.widget.PagedAdapter)1 OnPagedViewChangeListener (greendroid.widget.PagedView.OnPagedViewChangeListener)1 JSONObject (org.json.JSONObject)1