Example usage for android.view.animation AlphaAnimation AlphaAnimation

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

Introduction

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

Prototype

public AlphaAnimation(float fromAlpha, float toAlpha) 

Source Link

Document

Constructor to use when building an AlphaAnimation from code

Usage

From source file:com.adityarathi.muo.ui.activities.NowPlayingActivity.java

/**
 * Initiates the strobe effect on the seekbar.
 *///ww w.ja v a  2s .  c o m
private void initSeekbarStrobeEffect() {
    mSeekbarStrobeAnim = new AlphaAnimation(1.0f, 0.0f);
    mSeekbarStrobeAnim.setRepeatCount(SEEKBAR_STROBE_ANIM_REPEAT);
    mSeekbarStrobeAnim.setDuration(700);
    mSeekbarStrobeAnim.setRepeatMode(Animation.REVERSE);

    mSeekbar.startAnimation(mSeekbarStrobeAnim);

}

From source file:com.irccloud.android.fragment.MessageViewFragment.java

public void showSpinner(boolean show) {
    if (show) {//w  w w . ja v  a2s .c  om
        if (Build.VERSION.SDK_INT < 16) {
            AlphaAnimation anim = new AlphaAnimation(0, 1);
            anim.setDuration(150);
            anim.setFillAfter(true);
            spinner.setAnimation(anim);
        } else {
            spinner.setAlpha(0);
            spinner.animate().alpha(1);
        }
        spinner.setVisibility(View.VISIBLE);
    } else {
        if (Build.VERSION.SDK_INT < 16) {
            AlphaAnimation anim = new AlphaAnimation(1, 0);
            anim.setDuration(150);
            anim.setFillAfter(true);
            anim.setAnimationListener(new AnimationListener() {
                @Override
                public void onAnimationStart(Animation animation) {

                }

                @Override
                public void onAnimationEnd(Animation animation) {
                    spinner.setVisibility(View.GONE);
                }

                @Override
                public void onAnimationRepeat(Animation animation) {

                }
            });
            spinner.setAnimation(anim);
        } else {
            spinner.animate().alpha(0).withEndAction(new Runnable() {
                @Override
                public void run() {
                    spinner.setVisibility(View.GONE);
                }
            });
        }
    }
}

From source file:com.adityarathi.muo.ui.activities.NowPlayingActivity.java

/**
 * Stops the seekbar strobe effect.//from ww  w .  j  a v  a2s.c o m
 */
private void stopSeekbarStrobeEffect() {
    mSeekbarStrobeAnim = new AlphaAnimation(mSeekbar.getAlpha(), 1.0f);
    mSeekbarStrobeAnim.setDuration(700);
    mSeekbar.startAnimation(mSeekbarStrobeAnim);

}

From source file:android.support.v7.app.MediaRouteControllerDialog.java

private void animateGroupListItemsInternal(Map<MediaRouter.RouteInfo, Rect> previousRouteBoundMap,
        Map<MediaRouter.RouteInfo, BitmapDrawable> previousRouteBitmapMap) {
    if (mGroupMemberRoutesAdded == null || mGroupMemberRoutesRemoved == null) {
        return;//from   ww w . j av a  2s.com
    }
    int groupSizeDelta = mGroupMemberRoutesAdded.size() - mGroupMemberRoutesRemoved.size();
    boolean listenerRegistered = false;
    Animation.AnimationListener listener = new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
            mVolumeGroupList.startAnimationAll();
            mVolumeGroupList.postDelayed(mGroupListFadeInAnimation, mGroupListAnimationDurationMs);
        }

        @Override
        public void onAnimationEnd(Animation animation) {
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }
    };

    // Animate visible items from previous positions to current positions except routes added
    // just before. Added routes will remain hidden until translate animation finishes.
    int first = mVolumeGroupList.getFirstVisiblePosition();
    for (int i = 0; i < mVolumeGroupList.getChildCount(); ++i) {
        View view = mVolumeGroupList.getChildAt(i);
        int position = first + i;
        MediaRouter.RouteInfo route = mVolumeGroupAdapter.getItem(position);
        Rect previousBounds = previousRouteBoundMap.get(route);
        int currentTop = view.getTop();
        int previousTop = previousBounds != null ? previousBounds.top
                : (currentTop + mVolumeGroupListItemHeight * groupSizeDelta);
        AnimationSet animSet = new AnimationSet(true);
        if (mGroupMemberRoutesAdded != null && mGroupMemberRoutesAdded.contains(route)) {
            previousTop = currentTop;
            Animation alphaAnim = new AlphaAnimation(0.0f, 0.0f);
            alphaAnim.setDuration(mGroupListFadeInDurationMs);
            animSet.addAnimation(alphaAnim);
        }
        Animation translationAnim = new TranslateAnimation(0, 0, previousTop - currentTop, 0);
        translationAnim.setDuration(mGroupListAnimationDurationMs);
        animSet.addAnimation(translationAnim);
        animSet.setFillAfter(true);
        animSet.setFillEnabled(true);
        animSet.setInterpolator(mInterpolator);
        if (!listenerRegistered) {
            listenerRegistered = true;
            animSet.setAnimationListener(listener);
        }
        view.clearAnimation();
        view.startAnimation(animSet);
        previousRouteBoundMap.remove(route);
        previousRouteBitmapMap.remove(route);
    }

    // If a member route doesn't exist any longer, it can be either removed or moved out of the
    // ListView layout boundary. In this case, use the previously captured bitmaps for
    // animation.
    for (Map.Entry<MediaRouter.RouteInfo, BitmapDrawable> item : previousRouteBitmapMap.entrySet()) {
        final MediaRouter.RouteInfo route = item.getKey();
        final BitmapDrawable bitmap = item.getValue();
        final Rect bounds = previousRouteBoundMap.get(route);
        OverlayObject object = null;
        if (mGroupMemberRoutesRemoved.contains(route)) {
            object = new OverlayObject(bitmap, bounds).setAlphaAnimation(1.0f, 0.0f)
                    .setDuration(mGroupListFadeOutDurationMs).setInterpolator(mInterpolator);
        } else {
            int deltaY = groupSizeDelta * mVolumeGroupListItemHeight;
            object = new OverlayObject(bitmap, bounds).setTranslateYAnimation(deltaY)
                    .setDuration(mGroupListAnimationDurationMs).setInterpolator(mInterpolator)
                    .setAnimationEndListener(new OverlayObject.OnAnimationEndListener() {
                        @Override
                        public void onAnimationEnd() {
                            mGroupMemberRoutesAnimatingWithBitmap.remove(route);
                            mVolumeGroupAdapter.notifyDataSetChanged();
                        }
                    });
            mGroupMemberRoutesAnimatingWithBitmap.add(route);
        }
        mVolumeGroupList.addOverlayObject(object);
    }
}

From source file:androidx.mediarouter.app.MediaRouteControllerDialog.java

void animateGroupListItemsInternal(Map<MediaRouter.RouteInfo, Rect> previousRouteBoundMap,
        Map<MediaRouter.RouteInfo, BitmapDrawable> previousRouteBitmapMap) {
    if (mGroupMemberRoutesAdded == null || mGroupMemberRoutesRemoved == null) {
        return;//from w  w w  .j a  v a  2s  .c  o  m
    }
    int groupSizeDelta = mGroupMemberRoutesAdded.size() - mGroupMemberRoutesRemoved.size();
    boolean listenerRegistered = false;
    Animation.AnimationListener listener = new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
            mVolumeGroupList.startAnimationAll();
            mVolumeGroupList.postDelayed(mGroupListFadeInAnimation, mGroupListAnimationDurationMs);
        }

        @Override
        public void onAnimationEnd(Animation animation) {
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }
    };

    // Animate visible items from previous positions to current positions except routes added
    // just before. Added routes will remain hidden until translate animation finishes.
    int first = mVolumeGroupList.getFirstVisiblePosition();
    for (int i = 0; i < mVolumeGroupList.getChildCount(); ++i) {
        View view = mVolumeGroupList.getChildAt(i);
        int position = first + i;
        MediaRouter.RouteInfo route = mVolumeGroupAdapter.getItem(position);
        Rect previousBounds = previousRouteBoundMap.get(route);
        int currentTop = view.getTop();
        int previousTop = previousBounds != null ? previousBounds.top
                : (currentTop + mVolumeGroupListItemHeight * groupSizeDelta);
        AnimationSet animSet = new AnimationSet(true);
        if (mGroupMemberRoutesAdded != null && mGroupMemberRoutesAdded.contains(route)) {
            previousTop = currentTop;
            Animation alphaAnim = new AlphaAnimation(0.0f, 0.0f);
            alphaAnim.setDuration(mGroupListFadeInDurationMs);
            animSet.addAnimation(alphaAnim);
        }
        Animation translationAnim = new TranslateAnimation(0, 0, previousTop - currentTop, 0);
        translationAnim.setDuration(mGroupListAnimationDurationMs);
        animSet.addAnimation(translationAnim);
        animSet.setFillAfter(true);
        animSet.setFillEnabled(true);
        animSet.setInterpolator(mInterpolator);
        if (!listenerRegistered) {
            listenerRegistered = true;
            animSet.setAnimationListener(listener);
        }
        view.clearAnimation();
        view.startAnimation(animSet);
        previousRouteBoundMap.remove(route);
        previousRouteBitmapMap.remove(route);
    }

    // If a member route doesn't exist any longer, it can be either removed or moved out of the
    // ListView layout boundary. In this case, use the previously captured bitmaps for
    // animation.
    for (Map.Entry<MediaRouter.RouteInfo, BitmapDrawable> item : previousRouteBitmapMap.entrySet()) {
        final MediaRouter.RouteInfo route = item.getKey();
        final BitmapDrawable bitmap = item.getValue();
        final Rect bounds = previousRouteBoundMap.get(route);
        OverlayListView.OverlayObject object = null;
        if (mGroupMemberRoutesRemoved.contains(route)) {
            object = new OverlayListView.OverlayObject(bitmap, bounds).setAlphaAnimation(1.0f, 0.0f)
                    .setDuration(mGroupListFadeOutDurationMs).setInterpolator(mInterpolator);
        } else {
            int deltaY = groupSizeDelta * mVolumeGroupListItemHeight;
            object = new OverlayListView.OverlayObject(bitmap, bounds).setTranslateYAnimation(deltaY)
                    .setDuration(mGroupListAnimationDurationMs).setInterpolator(mInterpolator)
                    .setAnimationEndListener(new OverlayListView.OverlayObject.OnAnimationEndListener() {
                        @Override
                        public void onAnimationEnd() {
                            mGroupMemberRoutesAnimatingWithBitmap.remove(route);
                            mVolumeGroupAdapter.notifyDataSetChanged();
                        }
                    });
            mGroupMemberRoutesAnimatingWithBitmap.add(route);
        }
        mVolumeGroupList.addOverlayObject(object);
    }
}

From source file:com.brandroidtools.filemanager.fragments.NavigationFragment.java

/**
 * Method that changes the current directory of the view.
 *
 * @param newDir The new directory location
 * @param addToHistory Add the directory to history
 * @param reload Force the reload of the data
 * @param useCurrent If this method must use the actual data (for back actions)
 * @param searchInfo The search information (if calling activity is {@link "SearchActivity"})
 * @param scrollTo If not null, then listview must scroll to this item
 *///from   ww w  . ja  va2 s .co  m
private void changeCurrentDir(final String newDir, final boolean addToHistory, final boolean reload,
        final boolean useCurrent, final SearchInfoParcelable searchInfo, final FileSystemObject scrollTo) {

    // Check navigation security (don't allow to go outside the ChRooted environment if one
    // is created)
    final String fNewDir = checkChRootedNavigation(newDir);

    synchronized (this.mSync) {
        //Check that it is really necessary change the directory
        if (!reload && this.mCurrentDir != null && this.mCurrentDir.compareTo(fNewDir) == 0) {
            return;
        }

        final boolean hasChanged = !(this.mCurrentDir != null && this.mCurrentDir.compareTo(fNewDir) == 0);
        final boolean isNewHistory = (this.mCurrentDir != null);

        //Execute the listing in a background process
        AsyncTask<String, Integer, List<FileSystemObject>> task = new AsyncTask<String, Integer, List<FileSystemObject>>() {
            /**
             * {@inheritDoc}
             */
            @Override
            protected List<FileSystemObject> doInBackground(String... params) {
                try {
                    //Reset the custom title view and returns to breadcrumb
                    if (NavigationFragment.this.mTitle != null) {
                        NavigationFragment.this.mTitle.post(new Runnable() {
                            @Override
                            public void run() {
                                try {
                                    NavigationFragment.this.mTitle.restoreView();
                                } catch (Exception e) {
                                    e.printStackTrace();
                                }
                            }
                        });
                    }

                    //Start of loading data
                    if (NavigationFragment.this.mBreadcrumb != null) {
                        try {
                            NavigationFragment.this.mBreadcrumb.startLoading();
                        } catch (Throwable ex) {
                            /**NON BLOCK**/
                        }
                    }

                    //Get the files, resolve links and apply configuration
                    //(sort, hidden, ...)
                    List<FileSystemObject> files = NavigationFragment.this.mFiles;
                    if (!useCurrent) {
                        files = CommandHelper.listFiles(mActivity, fNewDir, null);
                    }
                    return files;
                } catch (final ConsoleAllocException e) {
                    //Show exception and exists
                    mNavigationViewHolder.post(new Runnable() {
                        @Override
                        public void run() {
                            Log.e(TAG, mActivity.getString(R.string.msgs_cant_create_console), e);
                            DialogHelper.showToast(mActivity, R.string.msgs_cant_create_console,
                                    Toast.LENGTH_LONG);
                            mActivity.finish();
                        }
                    });
                    return null;

                } catch (Exception ex) {
                    //End of loading data
                    if (NavigationFragment.this.mBreadcrumb != null) {
                        try {
                            NavigationFragment.this.mBreadcrumb.endLoading();
                        } catch (Throwable ex2) {
                            /**NON BLOCK**/
                        }
                    }

                    //Capture exception (attach task, and use listener to do the anim)
                    ExceptionUtil.attachAsyncTask(ex, new AsyncTask<Object, Integer, Boolean>() {
                        private List<FileSystemObject> mTaskFiles = null;

                        @Override
                        @SuppressWarnings({ "unchecked", "unqualified-field-access" })
                        protected Boolean doInBackground(Object... taskParams) {
                            mTaskFiles = (List<FileSystemObject>) taskParams[0];
                            return Boolean.TRUE;
                        }

                        @Override
                        @SuppressWarnings("unqualified-field-access")
                        protected void onPostExecute(Boolean result) {
                            if (!result.booleanValue()) {
                                return;
                            }
                            onPostExecuteTask(mTaskFiles, addToHistory, isNewHistory, hasChanged, searchInfo,
                                    fNewDir, scrollTo);
                        }
                    });
                    final ExceptionUtil.OnRelaunchCommandResult exListener = new ExceptionUtil.OnRelaunchCommandResult() {
                        @Override
                        public void onSuccess() {
                            // Do animation
                            fadeEfect(false);
                        }

                        @Override
                        public void onFailed(Throwable cause) {
                            // Do animation
                            fadeEfect(false);
                        }

                        @Override
                        public void onCancelled() {
                            // Do animation
                            fadeEfect(false);
                        }
                    };
                    ExceptionUtil.translateException(mActivity, ex, false, true, exListener);
                }
                return null;
            }

            /**
             * {@inheritDoc}
             */
            @Override
            protected void onPreExecute() {
                // Do animation
                fadeEfect(true);
            }

            /**
             * {@inheritDoc}
             */
            @Override
            protected void onPostExecute(List<FileSystemObject> files) {
                if (files != null) {
                    onPostExecuteTask(files, addToHistory, isNewHistory, hasChanged, searchInfo, fNewDir,
                            scrollTo);

                    // Do animation
                    fadeEfect(false);
                }
            }

            /**
             * Method that performs a fade animation.
             *
             * @param out Fade out (true); Fade in (false)
             */
            void fadeEfect(final boolean out) {
                mActivity.runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        Animation fadeAnim = out ? new AlphaAnimation(1, 0) : new AlphaAnimation(0, 1);
                        fadeAnim.setDuration(50L);
                        fadeAnim.setFillAfter(true);
                        fadeAnim.setInterpolator(new AccelerateInterpolator());
                        mNavigationViewHolder.startAnimation(fadeAnim);
                    }
                });
            }
        };
        task.execute(fNewDir);
    }
}

From source file:com.irccloud.android.activity.MainActivity.java

private void update_suggestions(boolean force) {
    if (buffer != null && suggestionsContainer != null && messageTxt != null && messageTxt.getText() != null) {
        String text;//from   ww w.  j  a v a  2  s  .  c o  m
        try {
            text = messageTxt.getText().toString();
        } catch (Exception e) {
            text = "";
        }
        if (text.lastIndexOf(' ') > 0 && text.lastIndexOf(' ') < text.length() - 1) {
            text = text.substring(text.lastIndexOf(' ') + 1);
        }
        if (text.endsWith(":"))
            text = text.substring(0, text.length() - 1);
        text = text.toLowerCase();
        final ArrayList<String> sugs = new ArrayList<String>();
        HashSet<String> sugs_set = new HashSet<String>();
        if (text.length() > 2 || force || (text.length() > 0 && suggestionsAdapter.activePos != -1)) {
            ArrayList<ChannelsDataSource.Channel> channels = sortedChannels;
            if (channels == null) {
                channels = ChannelsDataSource.getInstance().getChannels();
                Collections.sort(channels, new Comparator<ChannelsDataSource.Channel>() {
                    @Override
                    public int compare(ChannelsDataSource.Channel lhs, ChannelsDataSource.Channel rhs) {
                        return lhs.name.compareTo(rhs.name);
                    }
                });

                sortedChannels = channels;
            }

            if (buffer != null && messageTxt.getText().length() > 0 && buffer.type.equals("channel")
                    && buffer.name.toLowerCase().startsWith(text) && !sugs_set.contains(buffer.name)) {
                sugs_set.add(buffer.name);
                sugs.add(buffer.name);
            }
            if (channels != null) {
                for (ChannelsDataSource.Channel channel : channels) {
                    if (text.length() > 0 && text.charAt(0) == channel.name.charAt(0)
                            && channel.name.toLowerCase().startsWith(text)
                            && !sugs_set.contains(channel.name)) {
                        sugs_set.add(channel.name);
                        sugs.add(channel.name);
                    }
                }
            }

            JSONObject disableAutoSuggest = null;
            if (NetworkConnection.getInstance().getUserInfo() != null
                    && NetworkConnection.getInstance().getUserInfo().prefs != null) {
                try {
                    if (NetworkConnection.getInstance().getUserInfo().prefs.has("channel-disableAutoSuggest"))
                        disableAutoSuggest = NetworkConnection.getInstance().getUserInfo().prefs
                                .getJSONObject("channel-disableAutoSuggest");
                } catch (Exception e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }

            boolean disabled;
            try {
                disabled = disableAutoSuggest != null && disableAutoSuggest.has(String.valueOf(buffer.bid))
                        && disableAutoSuggest.getBoolean(String.valueOf(buffer.bid));
            } catch (JSONException e) {
                disabled = false;
            }

            ArrayList<UsersDataSource.User> users = sortedUsers;
            if (users == null && buffer != null && (force || !disabled)) {
                users = UsersDataSource.getInstance().getUsersForBuffer(buffer.bid);
                if (users != null) {
                    Collections.sort(users, new Comparator<UsersDataSource.User>() {
                        @Override
                        public int compare(UsersDataSource.User lhs, UsersDataSource.User rhs) {
                            if (lhs.last_mention > rhs.last_mention)
                                return -1;
                            if (lhs.last_mention < rhs.last_mention)
                                return 1;
                            return lhs.nick.compareToIgnoreCase(rhs.nick);
                        }
                    });
                }
                sortedUsers = users;
            }
            if (users != null) {
                for (UsersDataSource.User user : users) {
                    String nick = user.nick_lowercase;
                    if (text.matches("^[a-zA-Z0-9]+.*"))
                        nick = nick.replaceFirst("^[^a-zA-Z0-9]+", "");

                    if (nick.startsWith(text) && !sugs_set.contains(user.nick)) {
                        sugs_set.add(user.nick);
                        sugs.add(user.nick);
                    }
                }
            }
        }

        if (Build.VERSION.SDK_INT >= 14 && text.startsWith(":") && text.length() > 1) {
            String q = text.toLowerCase().substring(1);
            for (String emocode : ColorFormatter.emojiMap.keySet()) {
                if (emocode.startsWith(q)) {
                    String emoji = ColorFormatter.emojiMap.get(emocode);
                    if (!sugs_set.contains(emoji)) {
                        sugs_set.add(emoji);
                        sugs.add(emoji);
                    }
                }
            }
        }

        if (sugs.size() == 0 && suggestionsContainer.getVisibility() == View.INVISIBLE)
            return;

        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                if (sugs.size() > 0) {
                    if (suggestionsAdapter.activePos == -1) {
                        suggestionsAdapter.clear();
                        for (String s : sugs) {
                            suggestionsAdapter.add(s);
                        }
                        suggestionsAdapter.notifyDataSetChanged();
                        suggestions.smoothScrollToPosition(0);
                    }
                    if (suggestionsContainer.getVisibility() == View.INVISIBLE) {
                        if (Build.VERSION.SDK_INT < 16) {
                            AlphaAnimation anim = new AlphaAnimation(0, 1);
                            anim.setDuration(250);
                            anim.setFillAfter(true);
                            suggestionsContainer.startAnimation(anim);
                        } else {
                            suggestionsContainer.setAlpha(0);
                            suggestionsContainer.setTranslationY(1000);
                            suggestionsContainer.animate().alpha(1).translationY(0)
                                    .setInterpolator(new DecelerateInterpolator());
                        }
                        suggestionsContainer.setVisibility(View.VISIBLE);
                        runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                if (suggestionsContainer.getHeight() < 48) {
                                    getSupportActionBar().hide();
                                }
                            }
                        });
                    }
                } else {
                    if (suggestionsContainer.getVisibility() == View.VISIBLE) {
                        if (Build.VERSION.SDK_INT < 16) {
                            AlphaAnimation anim = new AlphaAnimation(1, 0);
                            anim.setDuration(250);
                            anim.setFillAfter(true);
                            anim.setAnimationListener(new Animation.AnimationListener() {
                                @Override
                                public void onAnimationStart(Animation animation) {

                                }

                                @Override
                                public void onAnimationEnd(Animation animation) {
                                    suggestionsContainer.setVisibility(View.INVISIBLE);
                                    suggestionsAdapter.clear();
                                    suggestionsAdapter.notifyDataSetChanged();
                                }

                                @Override
                                public void onAnimationRepeat(Animation animation) {

                                }
                            });
                            suggestionsContainer.startAnimation(anim);
                        } else {
                            suggestionsContainer.animate().alpha(1).translationY(1000)
                                    .setInterpolator(new AccelerateInterpolator())
                                    .withEndAction(new Runnable() {
                                        @Override
                                        public void run() {
                                            suggestionsContainer.setVisibility(View.INVISIBLE);
                                            suggestionsAdapter.clear();
                                            suggestionsAdapter.notifyDataSetChanged();
                                        }
                                    });
                        }
                        sortedUsers = null;
                        sortedChannels = null;
                        if (!getSupportActionBar().isShowing())
                            getSupportActionBar().show();
                    }
                }
            }
        });
    }
}

From source file:android.support.v7.app.MediaRouteControllerDialog.java

private void fadeInAddedRoutes() {
    Animation.AnimationListener listener = new Animation.AnimationListener() {
        @Override//w  w  w.  j  ava2  s . c o  m
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            finishAnimation(true);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }
    };
    boolean listenerRegistered = false;
    int first = mVolumeGroupList.getFirstVisiblePosition();
    for (int i = 0; i < mVolumeGroupList.getChildCount(); ++i) {
        View view = mVolumeGroupList.getChildAt(i);
        int position = first + i;
        MediaRouter.RouteInfo route = mVolumeGroupAdapter.getItem(position);
        if (mGroupMemberRoutesAdded.contains(route)) {
            Animation alphaAnim = new AlphaAnimation(0.0f, 1.0f);
            alphaAnim.setDuration(mGroupListFadeInDurationMs);
            alphaAnim.setFillEnabled(true);
            alphaAnim.setFillAfter(true);
            if (!listenerRegistered) {
                listenerRegistered = true;
                alphaAnim.setAnimationListener(listener);
            }
            view.clearAnimation();
            view.startAnimation(alphaAnim);
        }
    }
}

From source file:android.support.v7.app.MediaRouteControllerDialog.java

void clearGroupListAnimation(boolean exceptAddedRoutes) {
    int first = mVolumeGroupList.getFirstVisiblePosition();
    for (int i = 0; i < mVolumeGroupList.getChildCount(); ++i) {
        View view = mVolumeGroupList.getChildAt(i);
        int position = first + i;
        MediaRouter.RouteInfo route = mVolumeGroupAdapter.getItem(position);
        if (exceptAddedRoutes && mGroupMemberRoutesAdded != null && mGroupMemberRoutesAdded.contains(route)) {
            continue;
        }/*from  w w  w  .j  ava 2s .c  o m*/
        LinearLayout container = (LinearLayout) view.findViewById(R.id.volume_item_container);
        container.setVisibility(View.VISIBLE);
        AnimationSet animSet = new AnimationSet(true);
        Animation alphaAnim = new AlphaAnimation(1.0f, 1.0f);
        alphaAnim.setDuration(0);
        animSet.addAnimation(alphaAnim);
        Animation translationAnim = new TranslateAnimation(0, 0, 0, 0);
        translationAnim.setDuration(0);
        animSet.setFillAfter(true);
        animSet.setFillEnabled(true);
        view.clearAnimation();
        view.startAnimation(animSet);
    }
    mVolumeGroupList.stopAnimationAll();
    if (!exceptAddedRoutes) {
        finishAnimation(false);
    }
}

From source file:com.ebaonet.lawyer.ui.weight.DraggableGridViewPager.java

private void animateDragged() {
    if (mLastDragged >= 0) {
        final View v = getChildAt(mLastDragged);

        final Rect r = new Rect(v.getLeft(), v.getTop(), v.getRight(), v.getBottom());
        r.inset(-r.width() / 20, -r.height() / 20);
        v.measure(MeasureSpec.makeMeasureSpec(r.width(), MeasureSpec.EXACTLY),
                MeasureSpec.makeMeasureSpec(r.height(), MeasureSpec.EXACTLY));
        v.layout(r.left, r.top, r.right, r.bottom);

        AnimationSet animSet = new AnimationSet(true);
        ScaleAnimation scale = new ScaleAnimation(0.9091f, 1, 0.9091f, 1, v.getWidth() / 2, v.getHeight() / 2);
        scale.setDuration(ANIMATION_DURATION);
        AlphaAnimation alpha = new AlphaAnimation(1, .8f);
        alpha.setDuration(ANIMATION_DURATION);

        animSet.addAnimation(scale);/*from w  w  w  . j av a  2s .  co m*/
        animSet.addAnimation(alpha);
        animSet.setFillEnabled(true);
        animSet.setFillAfter(true);

        v.clearAnimation();
        v.startAnimation(animSet);
    }
}