List of usage examples for android.support.v4.view ViewPager startAnimation
public void startAnimation(Animation animation)
From source file:com.poloure.simplerss.AsyncNewTagAdapters.java
@Override protected void onPostExecute(TreeMap<Long, FeedItem>[] result) { ViewPager pager = (ViewPager) m_activity.findViewById(R.id.viewpager); PagerAdapter pagerAdapter = pager.getAdapter(); int pageCount = pagerAdapter.getCount(); for (int i = 0; pageCount > i; i++) { // Get the tag page and skip ListViews that are null. ListFragmentTag fragment = FragmentFeeds.getViewPagerFragment(i); LinkedMapAdapter<Long, FeedItem> adapterTag = fragment.getListAdapter(); ListViewFeeds listView = fragment.getListView(); if (null == adapterTag) { fragment.setListAdapter(new AdapterFeedItems(m_activity, result[i])); listView.setSelectionOldestUnread(m_activity.getReadItemTimes()); } else {// w ww. j ava2 s. c o m long topKeyBefore = 0L; int top = 0; // If there are items in the currently viewed page, save the position. boolean firstLoad = null == listView || 0 == listView.getCount(); if (!firstLoad) { // Get the time of the top item. int topVisibleItem = listView.getFirstVisiblePosition(); topKeyBefore = adapterTag.getKey(topVisibleItem); View v = listView.getChildAt(0); top = null == v ? 0 : v.getTop(); } // Update the feedItems in the adapter. adapterTag.replaceAll(result[i]); // Now find the position of the item with the time timeBefore. if (firstLoad) { listView.setSelectionOldestUnread(m_activity.getReadItemTimes()); } else { int newPos = adapterTag.indexOf(topKeyBefore); listView.setSelectionFromTop(newPos, top - listView.getPaddingTop()); } } } // If the pager is invisible, use a fade in animation. if (View.VISIBLE != pager.getVisibility()) { pager.setVisibility(View.VISIBLE); AlphaAnimation animation = new AlphaAnimation(0.0F, 1.0F); animation.setDuration(300); pager.startAnimation(animation); } }