Example usage for android.view.animation AnimationUtils loadAnimation

List of usage examples for android.view.animation AnimationUtils loadAnimation

Introduction

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

Prototype

public static Animation loadAnimation(Context context, @AnimRes int id) throws NotFoundException 

Source Link

Document

Loads an Animation object from a resource

Usage

From source file:com.jekyll.wu.widget.FreeSnackBar.java

private void animateViewOut(final int event) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        ViewCompat.animate(mView).translationY(gravity == TOP ? -mView.getHeight() : mView.getHeight())
                .setInterpolator(FAST_OUT_SLOW_IN_INTERPOLATOR).setDuration(ANIMATION_DURATION)
                .setListener(new ViewPropertyAnimatorListenerAdapter() {
                    @Override//  w w  w .j a  va  2s.co  m
                    public void onAnimationStart(View view) {
                        mView.animateChildrenOut(0, ANIMATION_FADE_DURATION);
                    }

                    @Override
                    public void onAnimationEnd(View view) {
                        onViewHidden(event);
                    }
                }).start();
    } else {
        Animation anim = AnimationUtils.loadAnimation(mView.getContext(),
                gravity == TOP ? R.anim.my_design_snackbar_out : R.anim.my_design_snackbar_bottom_out);
        anim.setInterpolator(FAST_OUT_SLOW_IN_INTERPOLATOR);
        anim.setDuration(ANIMATION_DURATION);
        anim.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationEnd(Animation animation) {
                onViewHidden(event);
            }

            @Override
            public void onAnimationStart(Animation animation) {
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
            }
        });
        mView.startAnimation(anim);
    }
}

From source file:com.audiokernel.euphonyrmt.fragments.NowPlayingFragment.java

@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
        final Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);

    final Animation fadeIn = AnimationUtils.loadAnimation(mActivity, android.R.anim.fade_in);
    final Animation fadeOut = AnimationUtils.loadAnimation(mActivity, android.R.anim.fade_out);
    final int viewLayout;
    final View view;

    mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(mActivity);

    mSharedPreferences.registerOnSharedPreferenceChangeListener(this);

    if (mApp.isTabletUiEnabled()) {
        viewLayout = R.layout.main_fragment_tablet;
    } else {/*w  w  w  . j  a v a 2s .c  o  m*/
        viewLayout = R.layout.main_fragment;
    }

    view = inflater.inflate(viewLayout, container, false);

    mTrackTime = (TextView) view.findViewById(R.id.trackTime);
    mTrackTotalTime = (TextView) view.findViewById(R.id.trackTotalTime);
    mVolumeIcon = (ImageView) view.findViewById(R.id.volume_icon);

    /** These load the TextView resource, and set it as selected. */
    mAlbumNameText = findSelected(view, R.id.albumName);
    mArtistNameText = findSelected(view, R.id.artistName);
    mAudioNameText = findSelected(view, R.id.audioName);
    mSongNameText = findSelected(view, R.id.songName);
    mSongNameText.setText(R.string.notConnected);
    mYearNameText = findSelected(view, R.id.yearName);
    applyViewVisibility(mYearNameText, "enableAlbumYearText");
    mSongRating = (RatingBar) view.findViewById(R.id.songRating);
    mSongRating.setOnRatingBarChangeListener(new RatingChangedHandler());
    mSongRating.setVisibility(View.GONE);

    /** These get the event button, then setup listeners for them. */
    mPlayPauseButton = getEventButton(view, R.id.playpause, true);
    mRepeatButton = getEventButton(view, R.id.repeat, false);
    mShuffleButton = getEventButton(view, R.id.shuffle, false);
    mStopButton = getEventButton(view, R.id.stop, true);
    applyViewVisibility(mStopButton, "enableStopButton");

    /** Same as above, but these don't require a stored field. */
    getEventButton(view, R.id.next, false);
    getEventButton(view, R.id.prev, false);

    /** These have methods to initialize everything required to get them setup. */
    mCoverArt = getCoverArt(view);
    mCoverAsyncHelper = getCoverAsyncHelper(view);
    mSongInfo = getSongInfo(view);
    mTrackSeekBar = getTrackSeekBar(view);
    mVolumeSeekBar = getVolumeSeekBar(view);

    fadeIn.setDuration(ANIMATION_DURATION);
    fadeOut.setDuration(ANIMATION_DURATION);

    Log.i(TAG, "Initialization succeeded");

    return view;
}

From source file:com.gh4a.BaseActivity.java

private void updateViewVisibility(View view, boolean animate, boolean show) {
    int visibility = show ? View.VISIBLE : View.GONE;
    if (view.getVisibility() == visibility) {
        return;/*w  w w  .j  a  va2  s  .c  om*/
    }

    if (animate) {
        Animation anim = AnimationUtils.loadAnimation(view.getContext(),
                show ? android.R.anim.fade_in : android.R.anim.fade_out);
        view.startAnimation(anim);
    } else {
        view.clearAnimation();
    }
    view.setVisibility(visibility);
}

From source file:com.battlelancer.seriesguide.ui.OverviewFragment.java

@SuppressLint("NewApi")
private void onPopulateEpisodeData(Cursor episode) {
    mCurrentEpisodeCursor = episode;/*from  ww  w  .j  a v a2 s .com*/

    final TextView episodeTitle = (TextView) getView().findViewById(R.id.episodeTitle);
    final TextView episodeTime = (TextView) getView().findViewById(R.id.episodeTime);
    final TextView episodeSeasonAndNumber = (TextView) getView().findViewById(R.id.episodeInfo);
    final View episodemeta = getView().findViewById(R.id.episode_meta_container);
    final View episodePrimaryContainer = getView().findViewById(R.id.episode_primary_container);
    final View buttons = getView().findViewById(R.id.buttonbar);
    final View ratings = getView().findViewById(R.id.ratingbar);

    if (episode != null && episode.moveToFirst()) {
        // some episode properties
        mCurrentEpisodeTvdbId = episode.getInt(EpisodeQuery._ID);

        // title
        episodeTitle.setText(episode.getString(EpisodeQuery.TITLE));

        // number
        StringBuilder infoText = new StringBuilder();
        infoText.append(getString(R.string.season_number, episode.getInt(EpisodeQuery.SEASON)));
        infoText.append(" ");
        int episodeNumber = episode.getInt(EpisodeQuery.NUMBER);
        infoText.append(getString(R.string.episode_number, episodeNumber));
        int episodeAbsoluteNumber = episode.getInt(EpisodeQuery.ABSOLUTE_NUMBER);
        if (episodeAbsoluteNumber > 0 && episodeAbsoluteNumber != episodeNumber) {
            infoText.append(" (").append(episodeAbsoluteNumber).append(")");
        }
        episodeSeasonAndNumber.setText(infoText);

        // air date
        long releaseTime = episode.getLong(EpisodeQuery.FIRST_RELEASE_MS);
        if (releaseTime != -1) {
            Date actualRelease = TimeTools.getEpisodeReleaseTime(getActivity(), releaseTime);
            // "in 14 mins (Fri)"
            episodeTime.setText(getString(R.string.release_date_and_day,
                    TimeTools.formatToRelativeLocalReleaseTime(getActivity(), actualRelease),
                    TimeTools.formatToLocalReleaseDay(actualRelease)));
        } else {
            episodeTime.setText(null);
        }

        // make title and image clickable
        episodePrimaryContainer.setOnClickListener(new OnClickListener() {
            @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
            @Override
            public void onClick(View view) {
                // display episode details
                Intent intent = new Intent(getActivity(), EpisodesActivity.class);
                intent.putExtra(EpisodesActivity.InitBundle.EPISODE_TVDBID, mCurrentEpisodeTvdbId);

                ActivityCompat.startActivity(getActivity(), intent, ActivityOptionsCompat
                        .makeScaleUpAnimation(view, 0, 0, view.getWidth(), view.getHeight()).toBundle());
            }
        });
        episodePrimaryContainer.setFocusable(true);

        // Button bar
        // check-in button
        View checkinButton = buttons.findViewById(R.id.buttonEpisodeCheckin);
        checkinButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                onCheckIn();
            }
        });
        CheatSheet.setup(checkinButton);

        // watched button
        View watchedButton = buttons.findViewById(R.id.buttonEpisodeWatched);
        watchedButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                // disable button, will be re-enabled on data reload once action completes
                v.setEnabled(false);
                onEpisodeWatched();
            }
        });
        watchedButton.setEnabled(true);
        CheatSheet.setup(watchedButton);

        // collected button
        boolean isCollected = episode.getInt(EpisodeQuery.COLLECTED) == 1;
        Button collectedButton = (Button) buttons.findViewById(R.id.buttonEpisodeCollected);
        Utils.setCompoundDrawablesRelativeWithIntrinsicBounds(collectedButton, 0,
                isCollected ? R.drawable.ic_collected
                        : Utils.resolveAttributeToResourceId(getActivity().getTheme(), R.attr.drawableCollect),
                0, 0);
        collectedButton
                .setText(isCollected ? R.string.action_collection_remove : R.string.action_collection_add);
        CheatSheet.setup(collectedButton,
                isCollected ? R.string.action_collection_remove : R.string.action_collection_add);
        collectedButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                // disable button, will be re-enabled on data reload once action completes
                v.setEnabled(false);
                onToggleCollected();
            }
        });
        collectedButton.setEnabled(true);

        // skip button
        View skipButton = buttons.findViewById(R.id.buttonEpisodeSkip);
        skipButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                // disable button, will be re-enabled on data reload once action completes
                v.setEnabled(false);
                onEpisodeSkipped();
            }
        });
        skipButton.setEnabled(true);
        CheatSheet.setup(skipButton);

        // ratings
        ratings.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                rateOnTrakt();
            }
        });
        ratings.setFocusable(true);
        CheatSheet.setup(ratings, R.string.action_rate);

        // load all other info
        onLoadEpisodeDetails(episode);

        // episode image
        onLoadImage(episode.getString(EpisodeQuery.IMAGE));

        // episode actions
        loadEpisodeActionsDelayed();

        episodemeta.setVisibility(View.VISIBLE);
    } else {
        // no next episode: display single line info text, remove other
        // views
        episodeTitle.setText(R.string.no_nextepisode);
        episodeTime.setText(null);
        episodeSeasonAndNumber.setText(null);
        episodePrimaryContainer.setOnClickListener(null);
        episodePrimaryContainer.setClickable(false);
        episodePrimaryContainer.setFocusable(false);
        episodemeta.setVisibility(View.GONE);
        ratings.setOnClickListener(null);
        ratings.setClickable(false);
        ratings.setFocusable(false);
        onLoadImage(null);
    }

    // enable/disable applicable menu items
    getActivity().invalidateOptionsMenu();

    // animate view into visibility
    if (mContainerEpisode.getVisibility() == View.GONE) {
        final View progressContainer = getView().findViewById(R.id.progress_container);
        progressContainer.startAnimation(
                AnimationUtils.loadAnimation(episodemeta.getContext(), android.R.anim.fade_out));
        progressContainer.setVisibility(View.GONE);
        mContainerEpisode
                .startAnimation(AnimationUtils.loadAnimation(episodemeta.getContext(), android.R.anim.fade_in));
        mContainerEpisode.setVisibility(View.VISIBLE);
    }
}

From source file:chickennugget.spaceengineersdata.material.widgets.ListPopupWindow.java

/**
 * Show the popup list. If the list is already showing, this method
 * will recalculate the popup's size and position.
 *///  w ww .  j  a  va  2s  .c o m
public void show() {
    int height = buildDropDown();

    int widthSpec = 0;
    int heightSpec = 0;

    boolean noInputMethod = isInputMethodNotNeeded();

    if (mPopup.isShowing()) {
        if (mDropDownWidth == ViewGroup.LayoutParams.MATCH_PARENT) {
            // The call to PopupWindow's update method below can accept -1 for any
            // value you do not want to update.
            widthSpec = -1;
        } else if (mDropDownWidth == ViewGroup.LayoutParams.WRAP_CONTENT) {
            widthSpec = getAnchorView().getWidth();
        } else {
            widthSpec = mDropDownWidth;
        }

        if (mDropDownHeight == ViewGroup.LayoutParams.MATCH_PARENT) {
            // The call to PopupWindow's update method below can accept -1 for any
            // value you do not want to update.
            heightSpec = noInputMethod ? height : ViewGroup.LayoutParams.MATCH_PARENT;
            if (noInputMethod) {
                mPopup.setWindowLayoutMode(mDropDownWidth == ViewGroup.LayoutParams.MATCH_PARENT
                        ? ViewGroup.LayoutParams.MATCH_PARENT
                        : 0, 0);
            } else {
                mPopup.setWindowLayoutMode(mDropDownWidth == ViewGroup.LayoutParams.MATCH_PARENT
                        ? ViewGroup.LayoutParams.MATCH_PARENT
                        : 0, ViewGroup.LayoutParams.MATCH_PARENT);
            }
        } else if (mDropDownHeight == ViewGroup.LayoutParams.WRAP_CONTENT) {
            heightSpec = height;
        } else {
            heightSpec = mDropDownHeight;
        }

        mPopup.setOutsideTouchable(!mForceIgnoreOutsideTouch && !mDropDownAlwaysVisible);

        mPopup.update(getAnchorView(), mDropDownHorizontalOffset, mDropDownVerticalOffset, widthSpec,
                heightSpec);
    } else {
        if (mDropDownWidth == ViewGroup.LayoutParams.MATCH_PARENT) {
            widthSpec = ViewGroup.LayoutParams.MATCH_PARENT;
        } else {
            if (mDropDownWidth == ViewGroup.LayoutParams.WRAP_CONTENT) {
                mPopup.setWidth(getAnchorView().getWidth());
            } else {
                mPopup.setWidth(mDropDownWidth);
            }
        }

        if (mDropDownHeight == ViewGroup.LayoutParams.MATCH_PARENT) {
            heightSpec = ViewGroup.LayoutParams.MATCH_PARENT;
        } else {
            if (mDropDownHeight == ViewGroup.LayoutParams.WRAP_CONTENT) {
                mPopup.setHeight(height);
            } else {
                mPopup.setHeight(mDropDownHeight);
            }
        }

        mPopup.setWindowLayoutMode(widthSpec, heightSpec);
        setPopupClipToScreenEnabled(true);

        // use outside touchable to dismiss drop down when touching outside of it, so
        // only set this if the dropdown is not always visible
        mPopup.setOutsideTouchable(!mForceIgnoreOutsideTouch && !mDropDownAlwaysVisible);
        mPopup.setTouchInterceptor(mTouchInterceptor);
        PopupWindowCompat.showAsDropDown(mPopup, getAnchorView(), mDropDownHorizontalOffset,
                mDropDownVerticalOffset, mDropDownGravity);
        mDropDownList.setSelection(ListView.INVALID_POSITION);

        if (!mModal || mDropDownList.isInTouchMode()) {
            clearListSelection();
        }
        if (!mModal) {
            mHandler.post(mHideSelector);
        }

        // show item animation
        if (mItemAnimationId != 0)
            mPopup.getContentView().getViewTreeObserver()
                    .addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {

                        @Override
                        public boolean onPreDraw() {
                            mPopup.getContentView().getViewTreeObserver().removeOnPreDrawListener(this);
                            for (int i = 0, count = mDropDownList.getChildCount(); i < count; i++) {
                                View v = mDropDownList.getChildAt(i);

                                Animation anim = AnimationUtils.loadAnimation(mContext, mItemAnimationId);
                                anim.setStartOffset(mItemAnimationOffset * i);
                                v.startAnimation(anim);
                            }
                            return false;
                        }

                    });
    }
}

From source file:com.github.topbottomsnackbar.TBSnackbar.java

private void in2(int animId) {
    Animation anim = AnimationUtils.loadAnimation(mView.getContext(), animId);
    anim.setInterpolator(FAST_OUT_SLOW_IN_INTERPOLATOR);
    anim.setDuration(ANIMATION_DURATION);
    anim.setAnimationListener(new Animation.AnimationListener() {
        @Override//w  w w  . j  a  v  a  2  s. com
        public void onAnimationEnd(Animation animation) {
            onViewShown();
        }

        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }
    });
    mView.startAnimation(anim);
}

From source file:com.wheelphone.remotemini.WheelphoneRemoteMini.java

public void onCreate(Bundle savedInstanceState) {
    if (debugUsbComm) {
        logString = TAG + ": onCreate";
        Log.d(TAG, logString);/*www .  ja v  a  2  s .c om*/
        appendLog("debugUsbComm.txt", logString, false);
    }

    super.onCreate(savedInstanceState);

    setContentView(R.layout.main);

    camera = (SurfaceView) findViewById(R.id.smallcameraview);
    context = this.getApplicationContext();
    line1 = (TextView) findViewById(R.id.line1);
    line2 = (TextView) findViewById(R.id.line2);
    version = (TextView) findViewById(R.id.version);
    signWifi = (TextView) findViewById(R.id.advice);
    signStreaming = (TextView) findViewById(R.id.streaming);
    signInformation = (LinearLayout) findViewById(R.id.information);
    pulseAnimation = AnimationUtils.loadAnimation(this, R.anim.pulse);

    SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);

    settings.registerOnSharedPreferenceChangeListener(this);

    camera.getHolder().setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
    holder = camera.getHolder();

    PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
    wl = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "com.wheelphone.remotemini.wakelock");

    httpServer = new CustomHttpServer(8080, this.getApplicationContext(), handler);

    soundPool.setOnLoadCompleteListener(new OnLoadCompleteListener() {
        public void onLoadComplete(SoundPool soundPool, int sampleId, int status) {
            soundPool.play(sampleId, 0.99f, 0.99f, 1, 0, 1);
        }
    });

    timerImg = new Timer();

    intent = new Intent(context, FrontImageActivity.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    //startActivity(intent);        

    // Query the QCAR initialization flags:
    mQCARFlags = getInitializationFlags();

    // Update the application status to start initializing application
    updateApplicationStatus(APPSTATUS_INIT_APP);

    Display display = getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    updateRendering(size.x, size.y);

    btnStart = (Button) findViewById(R.id.btnStart);

    //Make sure that the app stays open:
    getWindow().addFlags(
            WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
                    | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
                    | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);

    wheelphone = new WheelphoneRobot(getApplicationContext(), getIntent());
    wheelphone.enableSpeedControl();
    wheelphone.setWheelPhoneRobotListener(this);

}

From source file:com.luanthanhthai.android.liteworkouttimer.TimerFragment.java

/**
 * Animation for keypad slide up from bottom
 *///from   w w w.  java2  s .c  om
public void animSlidePanelUp(ViewGroup slidePanelUp) {
    Animation slideUp = AnimationUtils.loadAnimation(getContext(), R.anim.panel_slide_up);
    slidePanelUp.startAnimation(slideUp);
    slidePanelUp.setVisibility(View.VISIBLE);
}

From source file:com.kaichaohulian.baocms.ecdemo.ui.chatting.ChattingFragment.java

private void showMsgLayoutMask() {
    if (isViewMode && !mMsgLayoutMask.isShown()) {
        if (mAnimation == null) {
            mAnimation = AnimationUtils.loadAnimation(getChattingActivity(), R.anim.buttomtip_in);
        }/* w  w w  .j a va 2  s.  c o m*/
        mMsgLayoutMask.setVisibility(View.VISIBLE);
        mMsgLayoutMask.startAnimation(mAnimation);
        mAnimation.start();
    }
}

From source file:com.luanthanhthai.android.liteworkouttimer.TimerFragment.java

/**
 * Animation for keypad slide down and disappear
 *//*ww w  .  j av  a  2  s.c  o  m*/
public void animSlidePanelDown(ViewGroup slidePanelDown) {
    Animation slideDown = AnimationUtils.loadAnimation(getContext(), R.anim.panel_slide_down);
    slidePanelDown.startAnimation(slideDown);
    slidePanelDown.setVisibility(View.GONE);
}