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:org.secuso.privacyfriendlydicegame.MainActivity.java

public void hints(int position) {

    TextView hint = (TextView) findViewById(R.id.initialTextView);
    TextView initialText = (TextView) findViewById(R.id.initialTextTextView);
    TextView hint2 = (TextView) findViewById(R.id.initialTextView2);
    ImageView background = (ImageView) findViewById(R.id.backgroundImageView);

    Animation anim = new AlphaAnimation(0.0f, 1.0f);

    if (position == 0) {
        hint.setVisibility(View.VISIBLE);
        hint2.setVisibility(View.VISIBLE);
        background.setVisibility(View.VISIBLE);
        initialText.setVisibility(View.VISIBLE);

        anim.setDuration(1000);/*w ww  . j a v a2 s . c o m*/
        anim.setStartOffset(20);
        anim.setRepeatMode(Animation.REVERSE);
        anim.setRepeatCount(Animation.INFINITE);
        hint.startAnimation(anim);
        hint2.startAnimation(anim);

    } else {
        hint.clearAnimation();
        hint2.clearAnimation();
        hint.setVisibility(View.INVISIBLE);
        hint2.setVisibility(View.INVISIBLE);
        background.setVisibility(View.INVISIBLE);
        initialText.setVisibility(View.INVISIBLE);
    }

}

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);//from  w w  w. j a  v a  2 s.  co m

    // 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.atinternet.tracker.Tool.java

/**
 * Helper to create alpha animation//from   w w w.j  a va 2 s  .  c o  m
 *
 * @param view    View
 * @param visible boolean
 */
static void setVisibleViewWithAnimation(View view, boolean visible) {
    AlphaAnimation animation;
    if (visible) {
        view.setVisibility(View.VISIBLE);
        animation = new AlphaAnimation(0.f, 1.f);
    } else {
        view.setVisibility(View.GONE);
        animation = new AlphaAnimation(1.f, 0.f);
    }
    animation.setDuration(400);
    view.startAnimation(animation);
}

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

public AlphaAnimation getShowAnimation(final View view0, final long time) {
    AlphaAnimation show = new AlphaAnimation(0.0f, 1.0f);
    show.setFillAfter(true);/*w  w w.  ja va  2  s.c  om*/
    show.setDuration(time);
    show.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
            view0.setVisibility(View.VISIBLE);
        }

        @Override
        public void onAnimationEnd(Animation animation) {
        }

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

From source file:com.sonvp.tooltip.Tooltip.java

/**
 * Removes the tool tip view from the view hierarchy.
 *///from  w  ww  .  j a va2  s  .  c  om
@UiThread
public void remove() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) {
        container.setPivotX(pivotX);
        container.setPivotY(pivotY);
        container.animate().setDuration(ANIMATION_DURATION).alpha(0.0F).scaleX(0.0F).scaleY(0.0F)
                .setListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animation) {
                        popupWindow.dismiss();

                    }
                });
    } else {
        AnimationSet animationSet = new AnimationSet(true);
        animationSet.setDuration(ANIMATION_DURATION);
        animationSet.addAnimation(new AlphaAnimation(1.0F, 0.0F));
        animationSet.addAnimation(new ScaleAnimation(1.0F, 0.0F, 1.0F, 0.0F, pivotX, pivotY));
        animationSet.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {
                // do nothing
            }

            @Override
            public void onAnimationEnd(Animation animation) {
                popupWindow.dismiss();
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
                // do nothing
            }
        });
        container.startAnimation(animationSet);
    }
}

From source file:com.example.testtab.fragment.TwitEyesPageFragment.java

public synchronized void endImgLoad(ImgFileIO status, String resMessage, final Bitmap bitmap, final int index,
        final int fresh) {
    showErrorLog("endImageLoad : index : " + index + " ---- //");
    boolean isContinue = true;
    switch (status) {
    case InterruptError:
        toastFormThread(Table.ERROR_INTERRUPTED + " while loading image.");
        isContinue = false;//from  w ww.j  a v a  2 s  .  com
        break;
    case HttpCodeError:
        toastFormThread(Table.ERROR_HTTP_CODE + " while loading image. Http Response: " + resMessage);
        isContinue = false;
        break;
    case FileMalformedError:
        toastFormThread(Table.ERROR_MALFORMED_URL + " while loading image.");
        isContinue = false;
        break;
    case ClientProtocolError:
        toastFormThread(Table.ERROR_CLIENT_PROTOCOL + " while loading image.");
        isContinue = false;
        break;
    case FileIOError:
        toastFormThread(Table.ERROR_IO + " while loading image.");
        isContinue = false;
        break;
    case FileCloserror:
        toastFormThread(Table.ERROR_FILE_CLOSE + " while loading image.");
        isContinue = false;
    }
    if (!isContinue)
        return;
    if (bitmap == null) {
        toastFormThread(Table.ERROR_IMAGE_NULL + " while loading image. Http Response: " + resMessage + " (No. "
                + index + ")");
        //return;
    }

    // CONTINUE
    this.handler.post(new Runnable() {
        public void run() {
            ImageButton image = (ImageButton) mRootView.findViewById(imageViews[index]);
            image.setImageBitmap(bitmap);

            if (bitmap != null) {
                AnimationSet set = new AnimationSet(true);

                AlphaAnimation alpha;
                switch (fresh) {
                case 1:
                case 2:
                    alpha = new AlphaAnimation(0.0f, 0.8f);
                    break;
                case 3:
                case 4:
                    alpha = new AlphaAnimation(0.0f, 0.6f);
                    break;
                case 5:
                case 6:
                    alpha = new AlphaAnimation(0.0f, 0.4f);
                    break;
                case 7:
                    alpha = new AlphaAnimation(0.0f, 0.2f);
                    break;
                default:
                    alpha = new AlphaAnimation(0.0f, 1.0f);
                }
                set.addAnimation(alpha);
                set.setDuration(500);
                set.setFillAfter(true);

                image.startAnimation(set);
            }
        }
    });
}

From source file:com.duy.pascal.ui.debug.activities.DebugActivity.java

@WorkerThread
private void showPopupAt(final LineNumber lineNumber, final String msg) {
    mHandler.post(new Runnable() {
        @Override//from   w  w  w  . j  a v  a2s .  com
        public void run() {
            if (isFinishing())
                return;
            //get relative position of expression at edittext
            Point position = mCodeView.getDebugPosition(lineNumber.getLine(), lineNumber.getColumn(),
                    Gravity.TOP);
            DLog.d(TAG, "generate: " + position);
            dismissPopup();
            //create new popup
            PopupWindow window = new PopupWindow(DebugActivity.this);
            LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
            View container = inflater.inflate(R.layout.popup_expr_result, null);
            container.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED),
                    View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
            int windowHeight = container.getMeasuredHeight();
            int windowWidth = container.getMeasuredWidth();

            window.setContentView(container);
            window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
            window.setTouchable(true);
            window.setSplitTouchEnabled(true);
            window.setOutsideTouchable(true);

            window.showAtLocation(mCodeView, Gravity.NO_GRAVITY, position.x - windowWidth / 3,
                    position.y + toolbar.getHeight() - windowHeight);

            TextView txtResult = container.findViewById(R.id.txt_result);
            txtResult.setText(msg);
            AlphaAnimation alphaAnimation = new AlphaAnimation(1.0f, 0.5f);
            alphaAnimation.setDuration(1000);
            alphaAnimation.setRepeatMode(Animation.REVERSE);
            alphaAnimation.setRepeatCount(Animation.INFINITE);
            txtResult.startAnimation(alphaAnimation);
            DebugActivity.this.mPopupWindow = window;
        }
    });
}

From source file:org.secuso.privacyfriendlypasswordgenerator.activities.MainActivity.java

public void hints(int position) {

    Animation anim = new AlphaAnimation(0.0f, 1.0f);

    if (metadatalist.size() == 0 || position == 0) {

        initialAlert.setVisibility(View.VISIBLE);
        anim.setDuration(1500);//from ww w .  j  a va  2 s.c o m
        anim.setStartOffset(20);
        anim.setRepeatMode(Animation.REVERSE);
        anim.setRepeatCount(Animation.INFINITE);
        initialAlert.startAnimation(anim);

    } else {
        initialAlert.setVisibility(View.GONE);
        initialAlert.clearAnimation();
    }

}

From source file:de.madvertise.android.sdk.MadvertiseView.java

private Animation createAnimation(final boolean isOutAnimation) {
    Animation animation = null;//ww w  .j  a va  2  s  .  c om

    if (isOutAnimation) {
        if (mAnimationType != null && mAnimationType.equals(MadvertiseUtil.ANIMATION_TYPE_FADE)) {
            animation = new AlphaAnimation(1.0f, 0.0f);
            animation.setDuration(700);
        } else if (mAnimationType != null
                && mAnimationType.equals(MadvertiseUtil.ANIMATION_TYPE_LEFT_TO_RIGHT)) {
            animation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT,
                    1.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f);
            animation.setDuration(900);
            animation.setInterpolator(new AccelerateInterpolator());
        } else if (mAnimationType != null && mAnimationType.equals(MadvertiseUtil.ANIMATION_TYPE_TOP_DOWN)) {
            animation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT,
                    0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 1.0f);
            animation.setDuration(900);
            animation.setInterpolator(new AccelerateInterpolator());
        }
    } else {
        if (mAnimationType != null && mAnimationType.equals(MadvertiseUtil.ANIMATION_TYPE_FADE)) {
            animation = new AlphaAnimation(0.0f, 1.0f);
            animation.setDuration(1200);
        } else if (mAnimationType != null
                && mAnimationType.equals(MadvertiseUtil.ANIMATION_TYPE_LEFT_TO_RIGHT)) {
            animation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, -1.0f,
                    Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f,
                    Animation.RELATIVE_TO_PARENT, 0.0f);
            animation.setDuration(900);
            animation.setInterpolator(new AccelerateInterpolator());
        } else if (mAnimationType != null && mAnimationType.equals(MadvertiseUtil.ANIMATION_TYPE_TOP_DOWN)) {
            animation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT,
                    0.0f, Animation.RELATIVE_TO_PARENT, -1.0f, Animation.RELATIVE_TO_PARENT, 0.0f);
            animation.setDuration(900);
            animation.setInterpolator(new AccelerateInterpolator());
        }
    }

    // create a no-animation animation
    // if (animation == null) {
    // animation = new AlphaAnimation(1.0f, 1.0f);
    // }

    return animation;
}

From source file:com.launcher.silverfish.launcher.appdrawer.TabbedAppDrawerFragment.java

private void showUninstallIndicator() {
    // Get the layout
    FrameLayout uninstall_indicator;//from w  ww  .j ava  2 s.  co  m
    uninstall_indicator = (FrameLayout) rootView.findViewById(R.id.uninstall_indicator);

    // Make it visible
    uninstall_indicator.setVisibility(View.VISIBLE);

    // And start the animation
    AlphaAnimation animation = new AlphaAnimation(0.0f, 1.0f);
    animation.setDuration(500);
    uninstall_indicator.startAnimation(animation);
}