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.freshdigitable.udonroad.StatusDetailFragment.java

@Override
public Animation onCreateAnimation(int transit, boolean enter, int nextAnim) {
    if (transit == FragmentTransaction.TRANSIT_FRAGMENT_OPEN) {
        if (enter) {
            return AnimationUtils.loadAnimation(getContext(), android.R.anim.fade_in);
        } else {//ww  w  .  j a v  a  2  s .  c o m
            return AnimationUtils.loadAnimation(getContext(), android.R.anim.fade_out);
        }
    }
    if (transit == FragmentTransaction.TRANSIT_FRAGMENT_CLOSE) {
        if (enter) {
            return AnimationUtils.loadAnimation(getContext(), android.R.anim.fade_in);
        } else {
            return AnimationUtils.loadAnimation(getContext(), android.R.anim.fade_out);
        }
    }
    return super.onCreateAnimation(transit, enter, nextAnim);
}

From source file:com.ohso.omgubuntu.BaseFragment.java

protected void hidefooterView() {
    final Animation fadeInAnimation = AnimationUtils.loadAnimation(getActivity(), R.anim.slide_out_to_bottom);
    footerView.startAnimation(fadeInAnimation);
    footerView.setVisibility(TextView.GONE);
}

From source file:com.sim2dial.dialer.HistoryFragment.java

private void showDeleteAllButton() {
    if (deleteAll == null || deleteAll.getVisibility() == View.VISIBLE) {
        return;/*from ww  w.java2 s  . c o  m*/
    }

    if (LinphoneActivity.instance().isAnimationDisabled()) {
        deleteAll.setVisibility(View.VISIBLE);
    } else {
        Animation animation = AnimationUtils.loadAnimation(getActivity(), R.anim.slide_in_left_to_right);
        animation.setAnimationListener(new AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {

            }

            @Override
            public void onAnimationRepeat(Animation animation) {

            }

            @Override
            public void onAnimationEnd(Animation animation) {
                deleteAll.setVisibility(View.VISIBLE);
                animation.setAnimationListener(null);
            }
        });
        deleteAll.startAnimation(animation);
    }
}

From source file:com.hctrom.romcontrol.MainViewActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    SharedPreferences.Editor editor;//from   w w  w.j  a v a 2  s. co  m
    SharedPreferences prefs = getSharedPreferences("ConfigMenuFlotante", Context.MODE_PRIVATE);
    switch (item.getItemId()) {
    case R.id.option1:
        if (item.isChecked()) {
            item.setChecked(false);
            menu.setEnabled(false);
            Toast.makeText(MainViewActivity.this, "Men flotante desactivado", Toast.LENGTH_LONG).show();
            editor = prefs.edit();
            editor.putBoolean("floating_button_activador", false);
            editor.commit();
        } else {
            item.setChecked(true);
            menu.setEnabled(true);
            Toast.makeText(MainViewActivity.this, "Men flotante activado", Toast.LENGTH_LONG).show();
            editor = prefs.edit();
            editor.putBoolean("floating_button_activador", true);
            editor.commit();
        }
        break;
    case R.id.option2:
        if (item.isChecked()) {
            item.setChecked(false);
            fab_close = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.fab_close);
            menu.startAnimation(fab_close);
            menu.hide();
            Toast.makeText(MainViewActivity.this, "Men flotante oculto", Toast.LENGTH_LONG).show();
            editor = prefs.edit();
            editor.putBoolean("floating_button_vista", false);
            editor.commit();
        } else {
            item.setChecked(true);
            fab_open = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.fab_open);
            menu.startAnimation(fab_open);
            menu.show();
            Toast.makeText(MainViewActivity.this, "Men flotante visible", Toast.LENGTH_LONG).show();
            editor = prefs.edit();
            editor.putBoolean("floating_button_vista", true);
            editor.commit();
        }
        break;
    case R.id.action_reboot:
        showHideRebootMenu();
        break;
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.autburst.picture.MainActivity.java

private void hideDeletionPanelAndCB(int mainActivityCommand) {
    deleteCheckboxesVisible = false;//from w  w w  . java 2s. co m

    controller.transformGUI(mainActivityCommand);

    // make checkboxes invisible
    for (CheckBox cbToDelete : deleteAlbumCheckBoxes) {
        if (cbToDelete.getVisibility() == View.VISIBLE) {
            Animation myFadeInAnimation = AnimationUtils.loadAnimation(MainActivity.this,
                    R.anim.slight_left_cb);
            cbToDelete.startAnimation(myFadeInAnimation);
            cbToDelete.setVisibility(View.GONE);
            if (cbToDelete.isChecked())
                cbToDelete.setChecked(false);
        }
    }
}

From source file:com.example.alyshia.customsimplelauncher.launcher.GridFragment.java

/**
 * Control whether the grid is being displayed.  You can make it not
 * displayed if you are waiting for the initial data to show in it.  During
 * this time an indeterminant progress indicator will be shown instead.
 *
 * @param shown If true, the grid view is shown; if false, the progress
 * indicator.  The initial value is true.
 * @param animate If true, an animation will be used to transition to the
 * new state.//from   ww  w . j a  v  a2s  . co m
 */
private void setGridShown(boolean shown, boolean animate) {
    ensureGrid();
    //        if (mProgressContainer == null) {
    //            throw new IllegalStateException("Can't be used with a custom content view");
    //        }
    if (mGridShown == shown) {
        return;
    }
    mGridShown = shown;
    if (shown) {
        if (animate) {
            //                mProgressContainer.startAnimation(AnimationUtils.loadAnimation(
            //                        getActivity(), android.R.anim.fade_out));
            mGridContainer.startAnimation(AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_in));
        } else {
            //                mProgressContainer.clearAnimation();
            mGridContainer.clearAnimation();
        }
        //            mProgressContainer.setVisibility(View.GONE);
        mGridContainer.setVisibility(View.VISIBLE);
    } else {
        if (animate) {
            //                mProgressContainer.startAnimation(AnimationUtils.loadAnimation(
            //                        getActivity(), android.R.anim.fade_in));
            mGridContainer.startAnimation(AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_out));
        } else {
            //                mProgressContainer.clearAnimation();
            mGridContainer.clearAnimation();
        }
        //            mProgressContainer.setVisibility(View.VISIBLE);
        mGridContainer.setVisibility(View.GONE);
    }
}

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

private void previousComapny() {
    count--;//ww w  .  j  a  va2s . c  o m
    comapny_switcher.setInAnimation(AnimationUtils.loadAnimation(getActivity(), R.anim.push_right_in));
    comapny_switcher.setOutAnimation(AnimationUtils.loadAnimation(getActivity(), R.anim.push_right_out));
    projects_list.startAnimation(AnimationUtils.loadAnimation(getActivity(), R.anim.rail_out));
    comapny_switcher.setText(mProjectsData.get(count).getCompanyName());
    adapter.notifyDataSetChanged();
    adapter.setListData(mProjectsData.get(count).getProjectDescription());
    projects_list.setAdapter(adapter);
}

From source file:com.sim2dial.dialer.InCallActivity.java

private void initUI() {
    inflater = LayoutInflater.from(this);
    container = (ViewGroup) findViewById(R.id.topLayout);
    callsList = (TableLayout) findViewById(R.id.calls);
    if (!showCallListInVideo) {
        callsList.setVisibility(View.GONE);
    }/*from  w  w  w . j  a va 2 s.com*/

    LinearLayout l1 = (LinearLayout) findViewById(R.id.l1);
    l1.setVisibility(View.GONE);

    LinearLayout l2 = (LinearLayout) findViewById(R.id.l2);
    l1.setVisibility(View.GONE);

    /*
     * video = (TextView) findViewById(R.id.video);
     * video.setOnClickListener(this); video.setEnabled(false);
     */
    micro = (ImageView) findViewById(R.id.micro);
    micro.setOnClickListener(this);
    // micro.setEnabled(false);
    speaker = (ImageView) findViewById(R.id.speaker);
    speaker.setOnClickListener(this);
    // speaker.setEnabled(false);
    addCall = (TextView) findViewById(R.id.addCall);
    addCall.setOnClickListener(this);
    addCall.setEnabled(false);
    addCall.setVisibility(View.GONE);

    transfer = (TextView) findViewById(R.id.transfer);
    transfer.setOnClickListener(this);
    transfer.setEnabled(false);
    transfer.setVisibility(View.GONE);

    /*
     * options = (TextView) findViewById(R.id.options);
     * options.setOnClickListener(this); options.setEnabled(false);
     */
    pause = (ImageView) findViewById(R.id.pause);
    pause.setOnClickListener(this);
    pause.setEnabled(false);

    hangUp = (TextView) findViewById(R.id.hangUp);
    hangUp.setOnClickListener(this);

    conference = (ImageView) findViewById(R.id.conference);
    conference.setOnClickListener(this);
    conference.setVisibility(View.GONE);

    dialer = (ImageView) findViewById(R.id.dialer);
    dialer.setOnClickListener(this);
    dialer.setEnabled(false);
    numpad = (Numpad) findViewById(R.id.numpad);

    switchCamera = (ImageView) findViewById(R.id.switchCamera);
    switchCamera.setOnClickListener(this);

    mControlsLayout = (ViewGroup) findViewById(R.id.menu);

    if (!isTransferAllowed) {
        addCall.setBackgroundResource(R.drawable.options_add_call);
    }

    if (!isAnimationDisabled) {
        slideInRightToLeft = AnimationUtils.loadAnimation(this, R.anim.slide_in_right_to_left);
        slideOutLeftToRight = AnimationUtils.loadAnimation(this, R.anim.slide_out_left_to_right);
        slideInBottomToTop = AnimationUtils.loadAnimation(this, R.anim.slide_in_bottom_to_top);
        slideInTopToBottom = AnimationUtils.loadAnimation(this, R.anim.slide_in_top_to_bottom);
        slideOutBottomToTop = AnimationUtils.loadAnimation(this, R.anim.slide_out_bottom_to_top);
        slideOutTopToBottom = AnimationUtils.loadAnimation(this, R.anim.slide_out_top_to_bottom);
    }
}

From source file:com.google.android.apps.santatracker.games.gumball.TiltGameFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mRootView = inflater.inflate(R.layout.fragment_gumball, container, false);
    mRootView.setKeepScreenOn(true);//  ww  w . j av a 2  s . c  om

    // Use a lower resolution background image to conserve memory below ICS
    if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        View matchScoreLayout = mRootView.findViewById(R.id.tilt_score_layout);
        matchScoreLayout.setBackgroundResource(R.drawable.score_background_gingerbread);
    }

    mViewPlayAgainScore = (TextView) mRootView.findViewById(R.id.play_again_score);
    mViewPlayAgainScore.setText(String.valueOf(mMatchScore));
    mViewPlayAgainLevel = (TextView) mRootView.findViewById(R.id.play_again_level);
    mViewPlayAgainLevel.setText(String.valueOf(mCurrentLevelNum));
    mViewPlayAgainBackground = mRootView.findViewById(R.id.play_again_bkgrd);
    mViewPlayAgainMain = mRootView.findViewById(R.id.play_again_main);
    mViewPlayAgainButton = (Button) mRootView.findViewById(R.id.play_again_btn);
    mViewPlayAgainButton.setOnClickListener(this);

    mViewGPlusSignIn = (ImageView) mRootView.findViewById(R.id.gplus_button);
    mViewGPlusSignIn.setOnClickListener(this);
    mViewGPlusLayout = mRootView.findViewById(R.id.play_again_gplus);
    mViewGPlusLayout.setVisibility(View.GONE);

    // Initialise all animations
    // Construct an animation to blink the timer indefinitely
    mAnimationTimerAlpha = new AlphaAnimation(0.0f, 1.0f);
    mAnimationTimerAlpha.setDuration(1000);
    mAnimationTimerAlpha.setRepeatMode(Animation.REVERSE);
    mAnimationTimerAlpha.setRepeatCount(Animation.INFINITE);

    // Load all other animations
    mAnimationPlayAgainBackground = AnimationUtils.loadAnimation(getActivity(), R.anim.play_again_bkgrd_anim);
    mAnimationPlayAgainBackground.setFillAfter(true);
    mAnimationPlayAgainBackground.setAnimationListener(this);
    mAnimationPlayAgainMain = AnimationUtils.loadAnimation(getActivity(), R.anim.play_again_main_anim);
    mAnimationPlayAgainMain.setFillAfter(true);
    mAnimationPlayAgainMain.setAnimationListener(this);
    mAnimationScaleLevelDown = AnimationUtils.loadAnimation(getActivity(), R.anim.scale_level_anim_down);
    mAnimationScaleLevelDown.setAnimationListener(this);
    mAnimationLevelFadeOut = AnimationUtils.loadAnimation(getActivity(), R.anim.level_fade_out_anim);
    mAnimationLevelFadeOut.setAnimationListener(this);
    mAnimationLevelScaleUp = AnimationUtils.loadAnimation(getActivity(), R.anim.scale_up_level_anim);
    mAnimationLevelScaleUp.setAnimationListener(this);

    mViewMainMenuButton = (ImageButton) mRootView.findViewById(R.id.main_menu_button);
    mViewMainMenuButton.setVisibility(View.GONE);
    mViewMainMenuButton.setOnClickListener(this);

    mGameOutlet = mRootView.findViewById(R.id.tiltGameOutlet);
    mOutletOffset = getResources().getInteger(R.integer.outlet_offset);

    mViewIndicators[0] = (ImageView) mRootView.findViewById(R.id.indicator1);
    mViewIndicators[1] = (ImageView) mRootView.findViewById(R.id.indicator2);
    mViewIndicators[2] = (ImageView) mRootView.findViewById(R.id.indicator3);
    mViewIndicators[3] = (ImageView) mRootView.findViewById(R.id.indicator4);
    mViewIndicators[4] = (ImageView) mRootView.findViewById(R.id.indicator5);
    mViewIndicators[5] = (ImageView) mRootView.findViewById(R.id.indicator6);
    mViewCountdown = (TextView) mRootView.findViewById(R.id.tiltTimer);

    mLevelNumberText = (LevelTextView) mRootView.findViewById(R.id.tilt_end_level_number);
    mLevelNumberText.setVisibility(View.GONE);
    mEndLevelCircle = (CircleView) mRootView.findViewById(R.id.tilt_end_level_circle);
    mEndLevelCircle.setVisibility(View.GONE);

    mViewPlayButton = (ImageView) mRootView.findViewById(R.id.tilt_play_button);
    mViewPlayButton.setOnClickListener(this);
    mViewPlayButton.setVisibility(View.GONE);
    mViewPauseButton = (ImageView) mRootView.findViewById(R.id.tilt_pause_button);
    mViewPauseButton.setOnClickListener(this);
    mViewPauseButton.setVisibility(View.VISIBLE);
    mViewMatchPauseOverlay = mRootView.findViewById(R.id.tilt_pause_overlay);
    mViewMatchPauseOverlay.setVisibility(View.GONE);
    mViewBigPlayButton = (ImageButton) mRootView.findViewById(R.id.tilt_big_play_button);
    mViewBigPlayButton.setOnClickListener(this);
    mViewCancelBar = (ImageView) mRootView.findViewById(R.id.tilt_cancel_bar);
    mViewCancelBar.setOnClickListener(this);
    mViewCancelBar.setVisibility(View.GONE);

    mViewScore = (TextView) mRootView.findViewById(R.id.tilt_score);
    mViewScore.setText(String.valueOf(mMatchScore));

    mGameView = (TiltGameView) mRootView.findViewById(R.id.tiltGameView);

    // Create the Box2D physics world.
    mWorld = new PhysicsWorld();
    Vec2 gravity = new Vec2(0.0f, 0.0f);
    mWorld.create(gravity);
    mGameView.setModel(mWorld);
    mWorld.getWorld().setContactListener(this);

    mGumballQueue = new LinkedList<>();

    // Initialise the sound pool and audio playback
    mSoundPool = new SoundPool(5, AudioManager.STREAM_MUSIC, 0);
    mSoundBounceSmall = mSoundPool.load(getActivity(), R.raw.gbg_ball_bounce_1, 1);
    mSoundBounceMed = mSoundPool.load(getActivity(), R.raw.gbg_ball_bounce_2, 1);
    mSoundBounceLarge = mSoundPool.load(getActivity(), R.raw.gbg_ball_bounce_3, 1);
    mSoundBallInMachine = mSoundPool.load(getActivity(), R.raw.gbg_ball_into_machine, 1);
    mSoundBallFail = mSoundPool.load(getActivity(), R.raw.gbg_ball_fall_out, 1);
    mSoundBallDrop = mSoundPool.load(getActivity(), R.raw.gbg_new_ball_bounce_drop, 1);
    mSoundGameOver = mSoundPool.load(getActivity(), R.raw.gameover, 1);

    // Display the instructions if they haven't been seen before
    mSharedPreferences = getActivity().getSharedPreferences(MatchingGameConstants.PREFERENCES_FILENAME,
            Context.MODE_PRIVATE);
    if (!mSharedPreferences.getBoolean(MatchingGameConstants.GUMBALL_INSTRUCTIONS_VIEWED, false)) {
        mDrawableTransition = new AnimationDrawable();
        mDrawableTransition.addFrame(getResources().getDrawable(R.drawable.instructions_shake_1), 300);
        mDrawableTransition.addFrame(getResources().getDrawable(R.drawable.instructions_shake_2), 300);
        mDrawableTransition.addFrame(getResources().getDrawable(R.drawable.instructions_shake_3), 300);
        mDrawableTransition.setOneShot(false);
        mViewInstructions = (ImageView) mRootView.findViewById(R.id.instructions);

        if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
            mViewInstructions.setImageResource(R.drawable.instructions_shake_1);
        } else {
            mViewInstructions.setImageDrawable(mDrawableTransition);
            mViewInstructions.post(new Runnable() {
                public void run() {
                    mDrawableTransition.start();
                }
            });
        }

        // Hide the instructions after 2 seconds
        mViewInstructions.postDelayed(new HideInstructionsRunnable(), 2200);
    }

    return mRootView;
}

From source file:com.almalence.opencam.PluginManager.java

@Override
public void onManagerCreate() {
    countdownAnimation = AnimationUtils.loadAnimation(ApplicationScreen.instance,
            R.anim.plugin_capture_selftimer_countdown);
    countdownAnimation.setFillAfter(true);

    LayoutInflater inflator = ApplicationScreen.instance.getLayoutInflater();
    countdownLayout = (RelativeLayout) inflator.inflate(R.layout.plugin_capture_selftimer_layout, null, false);
    countdownView = (TextView) countdownLayout.findViewById(R.id.countdown_text);

    photoTimeLapseLayout = (RelativeLayout) inflator.inflate(R.layout.plugin_capture_photo_timelapse_layout,
            null, false);/*from w w w .  j av a  2s.  c om*/
    photoTimeLapseView = (TextView) photoTimeLapseLayout.findViewById(R.id.photo_timelapse_text);
}