Example usage for android.view.animation LayoutAnimationController LayoutAnimationController

List of usage examples for android.view.animation LayoutAnimationController LayoutAnimationController

Introduction

In this page you can find the example usage for android.view.animation LayoutAnimationController LayoutAnimationController.

Prototype

public LayoutAnimationController(Animation animation) 

Source Link

Document

Creates a new layout animation controller with a delay of 50% and the specified animation.

Usage

From source file:eu.inmite.apps.smsjizdenka.fragment.TicketsFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    vList = (ListView) view.findViewById(android.R.id.list);
    vTopHelp = view.findViewById(R.id.top_help);
    vBottomHelp = view.findViewById(R.id.bottom_help);
    vBuy = (Button) view.findViewById(R.id.buy);
    vEmpty = view.findViewById(android.R.id.empty);
    vProgress = view.findViewById(android.R.id.progress);
    vList.setEmptyView(vEmpty);//from w  ww.j a v  a 2 s  .  c om
    showProgress();
    vList.setVisibility(View.GONE);
    if (mShowAnimation) {
        vList.setLayoutAnimation(
                new LayoutAnimationController(AnimationUtils.loadAnimation(c, android.R.anim.slide_in_left)));
    }
    vList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            collapseUncollapseTicket(id, false);
        }
    });
    vBuy.setOnClickListener(new

    View.OnClickListener() {
        @Override
        public void onClick(View v) {

            startActivity(CitiesActivity.class);
        }
    });
    vSwipeDismissList = new SwipeDismissList(vList, callback, SwipeDismissList.UndoMode.COLLAPSED_UNDO);
    vSwipeDismissList.setUndoString(c.getString(R.string.tickets_ticket_deleted));
    vSwipeDismissList.setUndoMultipleString(c.getString(R.string.tickets_tickets_deleted));
    // first launch animations
    int dpi = getResources().getDisplayMetrics().densityDpi;
    if (mShowAnimation && getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT
            && dpi != DisplayMetrics.DENSITY_LOW && dpi != DisplayMetrics.DENSITY_MEDIUM) {
        AnimationUtil.addAnimationToView(vTopHelp, R.anim.slide_in_top);
        AnimationUtil.addAnimationToView(vBottomHelp, R.anim.slide_in_bottom);
    }
    mShowAnimation = false;
    //SL.get(AnalyticsService.class).trackScreen("my-tickets");
}

From source file:com.kuloud.android.aboutlibraries.ui.LibsFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    mAdapter.addLibs(libraries);/*from   w w  w . j  av a2s . com*/

    if (animate) {
        Animation fadeIn = AnimationUtils.loadAnimation(LibsFragment.this.getActivity(),
                android.R.anim.slide_in_left);
        fadeIn.setDuration(500);
        LayoutAnimationController layoutAnimationController = new LayoutAnimationController(fadeIn);
        mRecyclerView.setLayoutAnimation(layoutAnimationController);
        mRecyclerView.startLayoutAnimation();
    }

    super.onViewCreated(view, savedInstanceState);
}

From source file:com.fastbootmobile.encore.app.fragments.AlbumViewFragment.java

private void setupHeader(LayoutInflater inflater) {
    // Load the header
    View headerView = inflater.inflate(R.layout.header_listview_songs, mListView, false);
    mIvHero = (ImageView) headerView.findViewById(R.id.ivHero);
    mTvAlbumName = (TextView) headerView.findViewById(R.id.tvAlbumName);
    mTvAlbumName.setBackgroundColor(0xBBFFFFFF & mBackgroundColor);

    if (mAlbum != null) {
        mTvAlbumName.setText(mAlbum.getName());
    }//  w  w w  . ja v  a2s. co m

    if (!Utils.hasLollipop()) {
        // Since we don't have the transition animation, make sure everything is visible
        mTvAlbumName.setVisibility(View.VISIBLE);
        mTvAlbumName.setAlpha(0.0f);
        mTvAlbumName.animate().alpha(1.0f).setDuration(AlbumActivity.BACK_DELAY).start();
    }

    // Hide download button by default
    headerView.findViewById(R.id.cpbOffline).setVisibility(View.GONE);

    mPlayFab = (FloatingActionButton) headerView.findViewById(R.id.fabPlay);

    // Set source logo
    ImageView ivSource = (ImageView) headerView.findViewById(R.id.ivSourceLogo);
    if (mAlbum != null) {
        mLogoBitmap = PluginsLookup.getDefault().getCachedLogo(getResources(), mAlbum);
        ivSource.setImageDrawable(mLogoBitmap);
    }

    // Set the FAB animated drawable
    mFabDrawable = new PlayPauseDrawable(getResources(), 1);
    mFabDrawable.setShape(PlayPauseDrawable.SHAPE_PLAY);
    mFabDrawable.setYOffset(6);

    mPlayFab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (mFabDrawable.getCurrentShape() == PlayPauseDrawable.SHAPE_PLAY) {
                if (mFabShouldResume) {
                    PlaybackProxy.play();
                    mFabDrawable.setShape(PlayPauseDrawable.SHAPE_PAUSE);
                    mBarDrawable.setShape(PlayPauseDrawable.SHAPE_PAUSE);
                } else {
                    PlaybackProxy.playAlbum(mAlbum);
                }

                if (Utils.hasLollipop()) {
                    // No Lollipop, no cool animation!
                    showMaterialReelBar(mPlayFab);
                }
            } else {
                mFabShouldResume = true;
                PlaybackProxy.pause();
                mFabDrawable.setShape(PlayPauseDrawable.SHAPE_PLAY);
                mBarDrawable.setShape(PlayPauseDrawable.SHAPE_PLAY);
                hideMaterialReelBar(mPlayFab);
            }
        }
    });
    mHandler.post(new Runnable() {
        @Override
        public void run() {
            showFab(false, false);
        }
    });
    mPlayFab.setImageDrawable(mFabDrawable);

    if (mHeroImage != null) {
        mIvHero.setImageBitmap(mHeroImage);
    } else {
        mIvHero.setImageResource(R.drawable.album_placeholder);
    }

    // Set the header view and adapter
    mListView.addParallaxedHeaderView(headerView);
    mListView.setAdapter(mAdapter);

    AlphaAnimation anim = new AlphaAnimation(0.f, 1.f);
    anim.setDuration(200);
    mListView.setLayoutAnimation(new LayoutAnimationController(anim));

    setupMaterialReelBar(headerView, mReelFabClickListener);
}

From source file:com.fastbootmobile.encore.app.fragments.PlaylistViewFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View root = inflater.inflate(R.layout.fragment_playlist_view, container, false);
    assert root != null;

    if (mPlaylist == null) {
        // If playlist couldn't load, abort early
        return root;
    }//from www.  j ava  2  s . com

    mListViewContents = (PlaylistListView) root.findViewById(R.id.lvPlaylistContents);

    // Setup the parallaxed header
    View headerView = inflater.inflate(R.layout.header_listview_songs, mListViewContents, false);
    mListViewContents.addParallaxedHeaderView(headerView);

    mAdapter = new PlaylistAdapter();
    mListViewContents.setAdapter(mAdapter);
    mListViewContents.setOnScrollListener(new ScrollStatusBarColorListener() {
        @Override
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
            if (view.getChildCount() == 0 || getActivity() == null) {
                return;
            }

            final float heroHeight = mIvHero.getMeasuredHeight();
            final float scrollY = getScroll(view);
            final float toolbarBgAlpha = Math.min(1, scrollY / heroHeight);
            final int toolbarAlphaInteger = (((int) (toolbarBgAlpha * 255)) << 24) | 0xFFFFFF;
            mColorDrawable.setColor(toolbarAlphaInteger & getResources().getColor(R.color.primary));

            SpannableString spannableTitle = new SpannableString(
                    mPlaylist.getName() != null ? mPlaylist.getName() : "");
            mAlphaSpan.setAlpha(toolbarBgAlpha);

            ActionBar actionbar = ((AppActivity) getActivity()).getSupportActionBar();
            if (actionbar != null) {
                actionbar.setBackgroundDrawable(mColorDrawable);
                spannableTitle.setSpan(mAlphaSpan, 0, spannableTitle.length(),
                        Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                actionbar.setTitle(spannableTitle);
                if (Utils.hasLollipop()) {
                    getActivity().getWindow().setStatusBarColor(
                            toolbarAlphaInteger & getResources().getColor(R.color.primary_dark));
                }
            }
        }
    });

    headerView.findViewById(R.id.pbAlbumLoading).setVisibility(View.GONE);

    mIvHero = (ImageView) headerView.findViewById(R.id.ivHero);

    mTvPlaylistName = (TextView) headerView.findViewById(R.id.tvAlbumName);

    // Download button
    mOfflineBtn = (CircularProgressButton) headerView.findViewById(R.id.cpbOffline);
    mOfflineBtn.setAlpha(0.0f);
    mOfflineBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            ProviderIdentifier pi = mPlaylist.getProvider();
            IMusicProvider provider = PluginsLookup.getDefault().getProvider(pi).getBinder();
            try {
                if (mPlaylist.getOfflineStatus() == BoundEntity.OFFLINE_STATUS_NO) {
                    provider.setPlaylistOfflineMode(mPlaylist.getRef(), true);
                    mOfflineBtn.setIndeterminateProgressMode(true);
                    mOfflineBtn.setProgress(1);

                    if (ProviderAggregator.getDefault().isOfflineMode()) {
                        Toast.makeText(getActivity(), R.string.toast_offline_playlist_sync, Toast.LENGTH_SHORT)
                                .show();
                    }
                } else {
                    provider.setPlaylistOfflineMode(mPlaylist.getRef(), false);
                    mOfflineBtn.setProgress(0);
                }
            } catch (RemoteException e) {
                Log.e(TAG, "Cannot set this playlist to offline mode", e);
                mOfflineBtn.setProgress(-1);
            }
        }
    });

    mHandler.sendEmptyMessageDelayed(UPDATE_OFFLINE_STATUS, 300);
    mTvPlaylistName.setText(mPlaylist.getName());

    Bitmap hero = Utils.dequeueBitmap(PlaylistActivity.BITMAP_PLAYLIST_HERO);
    if (hero == null) {
        mIvHero.setImageResource(R.drawable.album_placeholder);
    } else {
        mIvHero.setImageBitmap(hero);

        // Request the higher resolution
        loadArt();
    }

    mPlayFab = (FloatingActionButton) headerView.findViewById(R.id.fabPlay);

    // Set source logo
    mIvSource = (ImageView) headerView.findViewById(R.id.ivSourceLogo);
    mLogoBitmap = PluginsLookup.getDefault().getCachedLogo(getResources(), mPlaylist);
    mIvSource.setImageDrawable(mLogoBitmap);

    // Set the FAB animated drawable
    mFabDrawable = new PlayPauseDrawable(getResources(), 1);
    mFabDrawable.setShape(PlayPauseDrawable.SHAPE_PLAY);
    mFabDrawable.setYOffset(6);

    mPlayFab.setImageDrawable(mFabDrawable);
    mPlayFab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (mFabDrawable.getCurrentShape() == PlayPauseDrawable.SHAPE_PLAY) {
                if (mFabShouldResume) {
                    PlaybackProxy.play();
                    mFabDrawable.setShape(PlayPauseDrawable.SHAPE_PAUSE);
                    mFabDrawable.setBuffering(true);
                } else {
                    playNow();
                }

                if (Utils.hasLollipop()) {
                    showMaterialReelBar(mPlayFab);
                }
            } else {
                mFabShouldResume = true;
                PlaybackProxy.pause();
                mFabDrawable.setBuffering(true);
            }
        }
    });

    // Fill the playlist
    mAdapter.setPlaylist(mPlaylist);

    // Set the list listener
    mListViewContents.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            Song song = mAdapter.getItem(i - 1);
            if (Utils.canPlaySong(song)) {
                PlaybackProxy.clearQueue();
                PlaybackProxy.queuePlaylist(mPlaylist, false);
                PlaybackProxy.playAtIndex(i - 1);

                // Update FAB
                mFabShouldResume = true;
                mFabDrawable.setShape(PlayPauseDrawable.SHAPE_PAUSE);
                mFabDrawable.setBuffering(true);

                if (Utils.hasLollipop()) {
                    showMaterialReelBar(mPlayFab);
                }
            }
        }
    });

    // Set the display animation
    AlphaAnimation anim = new AlphaAnimation(0.f, 1.f);
    anim.setDuration(200);
    mListViewContents.setLayoutAnimation(new LayoutAnimationController(anim));

    setupMaterialReelBar(root, mReelFabClickListener);

    // Setup the opening animations for non-Lollipop devices
    if (!Utils.hasLollipop()) {
        mTvPlaylistName.setVisibility(View.VISIBLE);
        mTvPlaylistName.setAlpha(0.0f);
        mTvPlaylistName.animate().alpha(1.0f).setDuration(AlbumActivity.BACK_DELAY).start();
    }

    mIvSource.setAlpha(0.0f);
    mIvSource.animate().alpha(1).setDuration(200).start();

    return root;
}