Search in sources :

Example 1 with OnPagedViewChangeListener

use of greendroid.widget.PagedView.OnPagedViewChangeListener 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)

Aggregations

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