Example usage for android.view View startAnimation

List of usage examples for android.view View startAnimation

Introduction

In this page you can find the example usage for android.view View startAnimation.

Prototype

public void startAnimation(Animation animation) 

Source Link

Document

Start the specified animation now.

Usage

From source file:de.fahrgemeinschaft.RideDetailsFragment.java

private void fadeOutFast(final View view) {
    Animation fade_out = new AlphaAnimation(0.5f, 0f);
    fade_out.setAnimationListener(new AnimationListener() {

        @Override//from  ww w  .  j  a  va2  s . co m
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
        }
    });
    fade_out.setDuration(300);
    fade_out.setFillAfter(true);
    view.startAnimation(fade_out);
}

From source file:com.andryr.musicplayer.MainActivity.java

private void updateTrackInfo() {
    View trackInfoLayout = findViewById(R.id.track_info);

    if (mPlaybackService != null && mPlaybackService.hasPlaylist()) {

        if (trackInfoLayout.getVisibility() != View.VISIBLE) {
            trackInfoLayout.setVisibility(View.VISIBLE);
            trackInfoLayout
                    .startAnimation(AnimationUtils.loadAnimation(this, R.anim.abc_grow_fade_in_from_bottom));
        }//from  www  .j  a v a  2  s .  co m
        String title = mPlaybackService.getSongTitle();
        String artist = mPlaybackService.getArtistName();
        if (title != null) {
            ((TextView) findViewById(R.id.song_title)).setText(title);

        }
        if (artist != null) {
            ((TextView) findViewById(R.id.song_artist)).setText(artist);
        }

        long albumId = mPlaybackService.getAlbumId();
        final ImageView minArtworkView = (ImageView) findViewById(R.id.artwork_min);
        ArtworkCache.getInstance().loadBitmap(albumId, minArtworkView, mThumbSize, mThumbSize);

        int duration = mPlaybackService.getTrackDuration();
        if (duration != -1) {
            mProgressBar.setMax(duration);

            updateProgressBar();
        }

    } else {
        trackInfoLayout.setVisibility(View.GONE);
    }
}

From source file:fm.krui.kruifm.StreamFragment.java

/**
 * Performs animation between album art pane and settings view.
 *//*from  w ww .  j ava  2 s  .c o  m*/
private void flipCard() {
    View rootLayout = (View) getActivity().findViewById(R.id.stream_now_playing_container_relativelayout);
    View cardFace = (View) getActivity().findViewById(R.id.album_art_pane);
    View cardBack = (View) getActivity().findViewById(R.id.player_settings_tablelayout);

    FlipAnimation flipAnimation = new FlipAnimation(cardFace, cardBack);

    if (cardFace.getVisibility() == View.GONE) {
        flipAnimation.reverse();
    }
    rootLayout.startAnimation(flipAnimation);
}

From source file:git.egatuts.nxtremotecontroller.fragment.OnlineControllerFragment.java

public AlphaAnimation getHideAnimation(final View view0, final View view1, final long time) {
    AlphaAnimation hide = new AlphaAnimation(1.0f, 0.0f);
    hide.setDuration(time);/*from   w  w w.ja  v a  2  s.  c  o m*/
    hide.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
            view0.setVisibility(View.VISIBLE);
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            view0.setVisibility(View.GONE);
            view1.startAnimation(getShowAnimation(view1, time));
        }

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

From source file:com.aboveware.common.crouton.Manager.java

/**
 * Adds a {@link Crouton} to the {@link ViewParent} of it's {@link Activity}.
 *
 * @param crouton/*from w  w w.j  a va 2s  . c  o m*/
 *          The {@link Crouton} that should be added.
 */
private void addCroutonToView(Crouton crouton) {
    // don't add if it is already showing
    if (crouton.isShowing()) {
        return;
    }

    View croutonView = crouton.getView();
    if (croutonView.getParent() == null) {
        ViewGroup.LayoutParams params = croutonView.getLayoutParams();
        if (params == null) {
            params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                    ViewGroup.LayoutParams.WRAP_CONTENT);
        }
        // display Crouton in ViewGroup is it has been supplied
        if (crouton.getViewGroup() != null) {
            // TODO implement add to last position feature (need to align with how this will be requested for activity)
            crouton.getViewGroup().addView(croutonView, 0, params);
        } else {
            crouton.getActivity().addContentView(croutonView, params);
        }
    }
    croutonView.startAnimation(crouton.getInAnimation());
    announceForAccessibilityCompat(crouton.getActivity(), crouton.getText());
    sendMessageDelayed(crouton, Messages.REMOVE_CROUTON,
            crouton.getStyle().durationInMilliseconds + +crouton.getInAnimation().getDuration());
}

From source file:com.vaguehope.onosendai.widget.SidebarLayout.java

protected void animateSidebar(final boolean gotoOpen) {
    final View host = getHostView();
    if (host.getAnimation() != null)
        return;//from   ww w .  ja v  a2s .  co  m

    final float deltaX;
    final Animation animation;
    if (gotoOpen) {
        deltaX = host.getTranslationX() > 0 ? -host.getTranslationX() : -this.sidebarWidth;
        animation = new TranslateAnimation(0, deltaX, 0, 0);
        animation.setAnimationListener(this.openListener);
    } else {
        deltaX = this.sidebarWidth - host.getTranslationX();
        animation = new TranslateAnimation(0, deltaX, 0, 0);
        animation.setAnimationListener(this.closeListener);
    }
    animation.setDuration((long) (SLIDE_DURATION * (Math.abs(deltaX) / this.sidebarWidth)));
    animation.setFillAfter(true);
    animation.setFillEnabled(true);
    host.startAnimation(animation);
}

From source file:fm.krui.kruifm.StreamActivity.java

/**
 * Performs animation between album art pane and settings view.
 *//*from   w  w w.j av a2 s . c o  m*/
private void flipCard() {
    View rootLayout = (View) this.findViewById(R.id.stream_now_playing_container_relativelayout);
    View cardFace = (View) this.findViewById(R.id.album_art_pane);
    View cardBack = (View) this.findViewById(R.id.player_settings_tablelayout);

    FlipAnimation flipAnimation = new FlipAnimation(cardFace, cardBack);

    if (cardFace.getVisibility() == View.GONE) {
        flipAnimation.reverse();
    }
    rootLayout.startAnimation(flipAnimation);
}

From source file:com.timecontents.smartnotice.animate.AnimatedListViewAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if (position > _objects.size()) {
        return null;
    }//www  .  j  ava 2s  . c  o  m

    View v = convertView;
    ViewHolder holder;
    if (v == null) {
        v = _inflater.inflate(_resourceId, parent, false);

        holder = new ViewHolder();
        holder.tvTitle = (TextView) v.findViewById(R.id.tv_notice_title);
        holder.tvDate = (TextView) v.findViewById(R.id.tv_notice_date);
        holder.tvContent = (LinkEllipseTextView) v.findViewById(R.id.tv_notice_content_ellipse);
        holder.imgContent = (ImageView) v.findViewById(R.id.img_notice_content);
        holder.imgFileIcon = (ImageView) v.findViewById(R.id.img_notice_file_icon);
        holder.imgType = (ImageView) v.findViewById(R.id.img_notice_type_icon); // ? ?  ?

        v.setTag(holder);
    } else
        holder = (ViewHolder) v.getTag();

    JSONObject object = _objects.get(position);
    _objectMapper.bindObjectToView(object, holder, v);

    if (v != null) {
        Animation animation = new TranslateAnimation(0, 0, (position > lastPosition) ? 100 : -100, 0);
        animation.setDuration(400);
        v.startAnimation(animation);
    }
    lastPosition = position;

    return v;
}

From source file:com.htc.dotdesign.ToolBoxService.java

private void playAnimation(View view, Animation animation) {
    if (view != null && animation != null) {
        mbIsAnimationPlaying = true;/*  w w  w.ja  va 2s .  c  o m*/
        view.startAnimation(animation);
    } else {
        if (view == null) {
            Log.w(DotDesignConstants.LOG_TAG, LOG_PREFIX + "playAnimation, view can't be null!");
        }
        if (view == null) {
            Log.w(DotDesignConstants.LOG_TAG, LOG_PREFIX + "playAnimation, animation can't be null!");
        }
    }
}

From source file:com.spoiledmilk.ibikecph.controls.SortableListView.java

void translate(View v, float deltaY, final boolean finalAnim) {
    float newY = posY + deltaY;
    if (animation != null && animation.isInitialized())
        animation.cancel();/*from w  w w  .  j  ava2 s .  co  m*/
    animation = new TranslateAnimation(0, 0, posY, newY);
    animation.setDuration(finalAnim ? 0 : 100);
    animation.setAnimationListener(new AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            if (!finalAnim) {
                animation.setFillEnabled(true);
                animation.setFillAfter(true);
            } else {
                view.clearAnimation();
                posY = 0;
            }
        }
    });

    posY = newY;

    v.startAnimation(animation);
}