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.example.mego.adas.directions.ui.DirectionsFragment.java

/**
 * implement the click of the floating action button click
 *///from  w w w.ja  va  2s.  c  o  m
@Override
public void onClick(View v) {
    if (NetworkUtil.isAvailableInternetConnection(getContext())) {
        switch (v.getId()) {
        case R.id.add_new_location_fab:
            if (!isEditTextVisible) {
                detailView.setVisibility(View.INVISIBLE);
                revealEditText(revealView);
                locationEditText.requestFocus();
                if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
                    addLocationButton.setImageResource(R.drawable.icn_morp);
                    mAnimatable = (Animatable) (addLocationButton).getDrawable();
                    if (mAnimatable != null) {
                        mAnimatable.start();
                    }
                }
                revealView.setBackgroundColor(Color.WHITE);
                startPlacePicker();
            } else {
                if (goingPlace != null) {
                    //put the going location in the firebase
                    mGoingLocationDatabaseReference.setValue(goingPlace.getLatLng());
                }

                hideEditText(revealView);
                if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.LOLLIPOP) {
                    revealView.setVisibility(View.INVISIBLE);
                }

                if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
                    addLocationButton.setImageResource(R.drawable.icn_morph_reverse);
                    mAnimatable = (Animatable) (addLocationButton).getDrawable();
                    if (mAnimatable != null) {
                        mAnimatable.start();
                    }
                }
                locationImageView.setVisibility(View.INVISIBLE);

                //check for the internet connection if is ok init the loader
                loadingbar.setVisibility(View.VISIBLE);

                if (NetworkUtil.isAvailableInternetConnection(getContext())) {
                    fetchDirectionsData();
                } else {
                    showToast(getString(R.string.no_internet_connection));
                    loadingbar.setVisibility(View.INVISIBLE);
                }
            }
            break;
        case R.id.down_page_Image_View:
            //setup the animation
            Animation slideDown = AnimationUtils.loadAnimation(getContext(), R.anim.slide_down);
            Animation slideUp = AnimationUtils.loadAnimation(getContext(), R.anim.slide_up_map);

            if (mapView.getVisibility() == View.GONE) {
                mapView.setVisibility(View.VISIBLE);
                mapView.startAnimation(slideDown);
                stepsListButton.setImageResource(R.drawable.ic_up_page);
            } else {
                mapView.startAnimation(slideUp);
                mapView.setVisibility(View.GONE);
                stepsListButton.setImageResource(R.drawable.ic_down_page);
            }
            break;
        }
    } else {
        Toast.makeText(getContext(), R.string.no_internet_connection, Toast.LENGTH_SHORT).show();
    }
}

From source file:com.scoreflex.ScoreflexView.java

/**
 * Closes this ScoreflexView. If the view is attached to the developer
 * hierarchy it will be detached. If the view is attached to a
 * ScoreflexActivity, this activity will be terminated.
 *//*from w w  w. ja  v  a2s  . co  m*/
public void close() {
    // If we're displayed in the developer view hierarchy,
    // remove ourselves.
    final ViewParent parent = this.getParent();
    ViewGroup.LayoutParams currentLayoutParams = getLayoutParams();
    boolean isFullscreen = currentLayoutParams.height == LayoutParams.MATCH_PARENT;

    LocalBroadcastManager.getInstance(getContext()).unregisterReceiver(mLoginReceiver);

    if (isFullscreen && null != parent && parent instanceof ViewGroup) {
        int gravity = getLayoutGravity();
        int anim = (Gravity.TOP == (gravity & Gravity.VERTICAL_GRAVITY_MASK)) ? R.anim.scoreflex_exit_slide_up
                : R.anim.scoreflex_exit_slide_down;
        Animation animation = AnimationUtils.loadAnimation(mParentActivity, anim);
        animation.setAnimationListener(new AnimationListener() {

            @Override
            public void onAnimationEnd(Animation arg0) {
                ViewGroup parentGroup = (ViewGroup) parent;
                parentGroup.removeView(ScoreflexView.this);
                if (mScoreflexViewHandler != null) {
                    mScoreflexViewHandler.onViewClosed();
                    mScoreflexViewHandler = null;
                }
            }

            @Override
            public void onAnimationRepeat(Animation arg0) {

            }

            @Override
            public void onAnimationStart(Animation arg0) {

            }

        });
        startAnimation(animation);
    } else if (null != parent && parent instanceof ViewGroup) {
        ViewGroup parentGroup = (ViewGroup) parent;
        parentGroup.removeView(this);
        if (mScoreflexViewHandler != null) {
            mScoreflexViewHandler.onViewClosed();
            mScoreflexViewHandler = null;
        }
    }
}

From source file:ac.robinson.ticqr.TicQRActivity.java

private void addTickHighlight(TickBoxHolder tickBox) {
    int tickIcon = R.drawable.ic_highlight_tick;
    Drawable tickDrawable = getResources().getDrawable(tickIcon);

    ImageView tickHighlight = new ImageView(TicQRActivity.this);
    tickHighlight.setImageResource(tickIcon);
    RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParams.leftMargin = mImageView.getLeft() + Math.round(tickBox.imagePosition.x)
            - (tickDrawable.getIntrinsicWidth() / 2);
    layoutParams.topMargin = mImageView.getTop() + Math.round(tickBox.imagePosition.y)
            - (tickDrawable.getIntrinsicHeight() / 2);

    ((RelativeLayout) findViewById(R.id.tick_highlight_holder)).addView(tickHighlight, layoutParams);
    tickHighlight.startAnimation(AnimationUtils.loadAnimation(this, R.anim.pulse));

    tickHighlight.setOnClickListener(mTickClickListener);
    tickHighlight.setTag(tickBox);/*from  w  w w . j av  a 2 s .c o m*/
}

From source file:com.sonymobile.android.media.testmediaplayer.MainActivity.java

public void init() {
    if (mMediaPlayer == null) {
        mMediaPlayer = new MediaPlayer(getApplicationContext());
        mMediaPlayer.setScreenOnWhilePlaying(true);
    }/*from w  w w  .j  av  a  2 s  . co  m*/
    mHandler = new Handler();
    mDecorView = getWindow().getDecorView();
    mSeekbar = (SeekBar) findViewById(R.id.activity_main_seekbar);
    mSeekbar.setMax(1000);
    mPlayPauseButton = (ImageView) findViewById(R.id.activity_main_playpause_button);
    mSeekBarUpdater = new SeekbarUpdater(mSeekbar, mMediaPlayer);
    mTopLayout = (RelativeLayout) findViewById(R.id.activity_main_mainlayout);
    mTrackDialog = new AudioSubtitleTrackDialog(this);
    mAudioPos = mSubPos = 0;
    mTimeView = (TextView) findViewById(R.id.activity_main_time);
    mDurationView = (TextView) findViewById(R.id.activity_main_duration);
    mTimeLayout = (LinearLayout) findViewById(R.id.activity_main_timelayout);
    mTimeTracker = new TimeTracker(mMediaPlayer, mTimeView);
    mSubtitleView = (TextView) findViewById(R.id.activity_main_subtitleView);
    mSubtitleRenderer = new SubtitleRenderer(mSubtitleView, Looper.myLooper(), mMediaPlayer);
    mSubtitleLayoutAboveTimeView = (RelativeLayout.LayoutParams) mSubtitleView.getLayoutParams();
    mSubtitleLayoutBottom = (RelativeLayout.LayoutParams) ((TextView) findViewById(
            R.id.activity_main_subtitleView_params)).getLayoutParams();
    mTimeSeekView = (TextView) findViewById(R.id.activity_main_time_seek);
    mMediaPlayer.setOnInfoListener(this);
    RelativeLayout browsingL = (RelativeLayout) findViewById(R.id.activity_main_browsing_layout);
    ExpandableListView elv = (ExpandableListView) browsingL.findViewById(R.id.file_browsing_exp_list_view);
    ListView lv = (ListView) browsingL.findViewById(R.id.file_browsing_listview);
    RelativeLayout debugLayout = (RelativeLayout) findViewById(R.id.activity_main_debug_view);
    LinearLayout debugLinearLayout = (LinearLayout) debugLayout.findViewById(R.id.activity_main_debug_linear);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerLayout.setScrimColor(Color.TRANSPARENT);
    mDrawerLayout.setDrawerListener(this);
    mFileBrowser = new MediaBrowser(this, elv, lv, mMediaPlayer, (MainActivity) this, mDrawerLayout,
            debugLinearLayout);
    mIsFileBrowsing = false;
    mPreview = (SurfaceView) findViewById(R.id.mSurfaceView);
    mPreview.setOnTouchListener(this);
    mTopLayout.setSystemUiVisibility(
            View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
    mPreview.setSystemUiVisibility(
            View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
    mSubtitleTracker = new HashMap<Integer, Integer>();
    mAudioTracker = new HashMap<Integer, Integer>();
    findViewById(R.id.activity_main_loading_panel).bringToFront();
    findViewById(R.id.activity_main_browsing_layout).bringToFront();
    mUpperControls = (RelativeLayout) findViewById(R.id.UpperButtonLayout);
    mBottomControls = (RelativeLayout) findViewById(R.id.ButtonLayout);
    mSlideInAnimation = AnimationUtils.loadAnimation(this, R.anim.in_top);
    mSlideInAnimation.setAnimationListener(new AnimationListener() {

        @Override
        public void onAnimationEnd(Animation animation) {
            mUpperControls.setVisibility(View.VISIBLE);
            Runnable r = new Runnable() {
                @Override
                public void run() {
                    mBottomControls.setVisibility(View.INVISIBLE);
                }
            };
            mHandler.postDelayed(r, 3500);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }

        @Override
        public void onAnimationStart(Animation animation) {
            mBottomControls.setVisibility(View.INVISIBLE);
        }
    });
    mHolder = mPreview.getHolder();
    mHolder.addCallback(this);
    mFadeOutRunnable = new Runnable() {
        @Override
        public void run() {
            mSeekbar.setEnabled(false);
            Animation fadeoutBottom = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.out_bottom);
            fadeoutBottom.setAnimationListener(new AnimationListener() {

                @Override
                public void onAnimationEnd(Animation animation) {
                    if (mOngoingAnimation) {
                        mOngoingAnimation = false;
                        mBottomControls.setVisibility(View.INVISIBLE);
                        mUpperControls.setVisibility(View.INVISIBLE);
                        mSeekbar.setVisibility(View.GONE);
                        mTimeLayout.setVisibility(View.GONE);
                        mSubtitleView.setLayoutParams(mSubtitleLayoutBottom);
                    }
                }

                @Override
                public void onAnimationRepeat(Animation animation) {
                }

                @Override
                public void onAnimationStart(Animation animation) {
                    mOngoingAnimation = true;
                }
            });
            Animation fadeoutTop = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.out_top);
            mBottomControls.startAnimation(fadeoutBottom);
            mUpperControls.startAnimation(fadeoutTop);
            mSeekbar.startAnimation(fadeoutBottom);
            mTimeLayout.startAnimation(fadeoutBottom);
        }
    };
    mHideNavigationRunnable = new Runnable() {
        @Override
        public void run() {
            mPreview.setSystemUiVisibility(mUiOptions);
        }
    };

    mDecorView.setOnSystemUiVisibilityChangeListener(this);
    mSeekbar.setOnSeekBarChangeListener(new OwnOnSeekBarChangeListener(mMediaPlayer));
    mMediaPlayer.setOnCompletionListener(this);
    mMediaPlayer.setOnPreparedListener(this);
    mMediaPlayer.setOnSeekCompleteListener(this);
    mMediaPlayer.setOnErrorListener(this);
    mMediaPlayer.setOnSubtitleDataListener(this);

    RelativeLayout browsingLayout = (RelativeLayout) findViewById(R.id.activity_main_browsing_layout);
    DrawerLayout.LayoutParams params = (DrawerLayout.LayoutParams) browsingLayout.getLayoutParams();
    Resources resources = getResources();
    int top = 0;
    int bottom = 0;
    RelativeLayout.LayoutParams tempParams;
    int resourceId = resources.getIdentifier("status_bar_height", "dimen", "android");
    if (resourceId > 0) {
        top = resources.getDimensionPixelSize(resourceId);
    }
    resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
    if (resourceId > 0) {
        bottom = resources.getDimensionPixelSize(resourceId);
    }
    if (navigationBarAtBottom()) {
        tempParams = (RelativeLayout.LayoutParams) mBottomControls.getLayoutParams();
        tempParams.bottomMargin += bottom;
        mBottomControls.setLayoutParams(tempParams);
        tempParams = (RelativeLayout.LayoutParams) mSeekbar.getLayoutParams();
        tempParams.bottomMargin += bottom;
        mSeekbar.setLayoutParams(tempParams);
        params.setMargins(0, top, 0, bottom);
    } else {
        tempParams = (RelativeLayout.LayoutParams) mBottomControls.getLayoutParams();
        tempParams.rightMargin += bottom;
        mBottomControls.setLayoutParams(tempParams);
        params.setMargins(0, top, 0, 0);
    }
    browsingLayout.setLayoutParams(params);
    mDrawerLayout.openDrawer(Gravity.START);

    mMediaPlayer.setOnOutputControlListener(this);
}

From source file:com.brandao.tictactoe.board.BoardFragment.java

public void animateOut(final ImageView image, final int index) {
    Animation zoomOutOut = AnimationUtils.loadAnimation(getActivity(), R.anim.zoom_out);
    zoomOutOut.setInterpolator(//w w w. j av a2s  .  c  o  m
            AnimationUtils.loadInterpolator(getActivity(), android.R.anim.anticipate_interpolator));
    zoomOutOut.setAnimationListener(new AnimationListener() {
        @Override
        public void onAnimationEnd(Animation animation) {
            mAnimating = false;
            image.setBackgroundResource(R.drawable.transparent_image);
            if (index == 8) {
                initFirstTurn();
            }
        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }

        @Override
        public void onAnimationStart(Animation animation) {
            mAnimating = true;
        }
    });

    image.startAnimation(zoomOutOut);
}

From source file:com.sean.takeastand.ui.MainImageButtonFragment.java

private void setTextSwitchers() {
    txtTap.setFactory(new ViewSwitcher.ViewFactory() {
        @Override// w  ww. j  a v a2s  .  c o m
        public View makeView() {
            tapTextView = new TextView(getActivity());
            tapTextView.setTextSize(24);
            tapTextView.setGravity(Gravity.CENTER_HORIZONTAL);
            tapTextView.setTextColor(getResources().getColor(android.R.color.secondary_text_light));
            tapTextView.setText(getResources().getString(R.string.tap_to_start));
            mCurrentText = getResources().getString(R.string.tap_to_start);
            return tapTextView;
        }
    });
    Animation in = AnimationUtils.loadAnimation(getActivity(), R.anim.slide_in_left);
    Animation out = AnimationUtils.loadAnimation(getActivity(), R.anim.slide_out_left);

    txtTap.setInAnimation(in);
    txtTap.setOutAnimation(out);
}

From source file:com.teitsmch.hearthmaker.MainActivity.java

private void rotate(MenuItem item) {
    Animation rotation = AnimationUtils.loadAnimation(this, R.anim.rotate);
    rotation.setFillAfter(true);/*  w  w w  .j a  va 2  s .c o  m*/
    item.getActionView().startAnimation(rotation);
}

From source file:com.teitsmch.hearthmaker.MainActivity.java

private void setBarUpAnimation(View viewToAnimate) {
    Animation animation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.slide_out_up);
    animation.setAnimationListener(new SlideUpAnimationListener(getSupportActionBar()));
    viewToAnimate.startAnimation(animation);
}

From source file:com.raja.knowme.FragmentWorkExp.java

private void nextCompany() {
    count++;/*from w w  w.  ja v  a  2  s .c o m*/
    mCompanyNameSwitcher.setInAnimation(AnimationUtils.loadAnimation(getActivity(), R.anim.push_left_in));
    mCompanyNameSwitcher.setOutAnimation(AnimationUtils.loadAnimation(getActivity(), R.anim.push_left_out));
    mCompanySpanSwitcher.setInAnimation(AnimationUtils.loadAnimation(getActivity(), R.anim.push_left_in));
    mCompanySpanSwitcher.setOutAnimation(AnimationUtils.loadAnimation(getActivity(), R.anim.push_left_out));
    mCompanySummarySwitcher.setInAnimation(AnimationUtils.loadAnimation(getActivity(), R.anim.push_left_in));
    mCompanySummarySwitcher.setOutAnimation(AnimationUtils.loadAnimation(getActivity(), R.anim.push_left_out));
    mCompanyNameSwitcher.setText(mData.get(count).getCompanyName());
    mCompanySpanSwitcher.setText(mData.get(count).getWorkSpan());
    mCompanySummarySwitcher.setText(mData.get(count).getWorkDetails());
    mScrollContainer.scrollTo(0, 0);
}

From source file:com.example.mego.adas.directions.ui.DirectionsFragment.java

private void fetchDirectionsData() {

    stepAdapter.clear();//from w w w.  j  a  v  a 2s .c  o  m

    if (carWayPolyLine != null) {
        carWayPolyLine.remove();
    }

    //put the start location in the firebase
    mStartLocationDatabaseReference.setValue(startLocation);

    directionsApiInterface = DirectionsApiClient.getDirectionApiClient().create(DirectionsApiInterface.class);

    Call<Direction> call = directionsApiInterface.getDirections(startLocation,
            LocationUtilities.getLatLang(goingPlace));

    call.enqueue(new Callback<Direction>() {
        @Override
        public void onResponse(Call<Direction> call, Response<Direction> response) {
            loadingbar.setVisibility(View.INVISIBLE);

            if (response.body() != null) {
                mStepsDatabaseReference.removeValue();

                Animation slideUp = AnimationUtils.loadAnimation(getContext(), R.anim.slide_up);
                if (detailView.getVisibility() == View.INVISIBLE) {
                    detailView.startAnimation(slideUp);
                    detailView.setVisibility(View.VISIBLE);
                }
                if (response.body().getStatus().equals(DirectionsApiConstants.STATUES_OK)) {
                    distanceTextView.setText(DirectionsApiUtilities.getLegDistance(response.body()));
                    durationTextView.setText(DirectionsApiUtilities.getLegDuration(response.body()));
                    drawPolyline(DirectionsApiUtilities.getOverViewPolyLine(response.body()));
                    stepAdapter.setSteps(DirectionsApiUtilities.getSteps(response.body()));

                    //Put the value in the firebase
                    mStepsDatabaseReference.push().setValue(DirectionsApiUtilities.getSteps(response.body()));

                    mLegDurationTextDatabaseReference
                            .setValue(DirectionsApiUtilities.getLegDuration(response.body()));
                    mLegDistanceTextDatabaseReference
                            .setValue(DirectionsApiUtilities.getLegDistance(response.body()));
                    mOverViewPolylineDatabaseReference
                            .setValue(DirectionsApiUtilities.getOverViewPolyLine(response.body()));

                } else {
                    showToast(DirectionsApiUtilities.checkResponseState(response.body().getStatus()));
                }
            }
        }

        @Override
        public void onFailure(Call<Direction> call, Throwable t) {
            loadingbar.setVisibility(View.INVISIBLE);
            Timber.e(t.getLocalizedMessage());
        }
    });
}