Java Code Examples for android.support.v4.view.ViewPager#startAnimation()

The following examples show how to use android.support.v4.view.ViewPager#startAnimation() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DetailActivity.java    From MaterialTransitionAnimation with Apache License 2.0 5 votes vote down vote up
private void setupViewPager(final ViewPager viewPager) {
    ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager());
    adapter.addFragment(new TabFragment(), "OVERVIEW");
    adapter.addFragment(new TabFragment(), "USAGE");
    adapter.addFragment(new TabFragment(), "STYLE");
    viewPager.setAdapter(adapter);

    Animation bottomUp = AnimationUtils.loadAnimation(DetailActivity.this,
            R.anim.bottom_up);
    viewPager.startAnimation(bottomUp);


}
 
Example 2
Source File: AsyncNewTagAdapters.java    From rss with GNU General Public License v3.0 4 votes vote down vote up
@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
        {
            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);
    }
}