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:mirko.android.datetimepicker.date.DatePickerDialogSupport.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Log.d(TAG, "onCreateView: ");
    getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);

    View view = inflater.inflate(
            mEnableClearButton ? R.layout.date_picker_dialog_clear : R.layout.date_picker_dialog, null);

    mDayOfWeekView = (TextView) view.findViewById(R.id.date_picker_header);
    mMonthAndDayView = (LinearLayout) view.findViewById(R.id.date_picker_month_and_day);
    mMonthAndDayView.setOnClickListener(this);
    mSelectedMonthTextView = (TextView) view.findViewById(R.id.date_picker_month);
    mSelectedDayTextView = (TextView) view.findViewById(R.id.date_picker_day);
    mYearView = (TextView) view.findViewById(R.id.date_picker_year);
    mYearView.setOnClickListener(this);

    int listPosition = -1;
    int listPositionOffset = 0;
    int currentView = MONTH_AND_DAY_VIEW;
    if (savedInstanceState != null) {
        mWeekStart = savedInstanceState.getInt(KEY_WEEK_START);
        mMinYear = savedInstanceState.getInt(KEY_YEAR_START);
        mMaxYear = savedInstanceState.getInt(KEY_YEAR_END);
        currentView = savedInstanceState.getInt(KEY_CURRENT_VIEW);
        listPosition = savedInstanceState.getInt(KEY_LIST_POSITION);
        listPositionOffset = savedInstanceState.getInt(KEY_LIST_POSITION_OFFSET);
    }//from w ww  .ja  v a  2s .co  m

    final Activity activity = getActivity();
    mDayPickerView = new DayPickerView(activity, this);
    mYearPickerView = new YearPickerView(activity, this);

    Resources res = getResources();
    mDayPickerDescription = res.getString(R.string.day_picker_description);
    mSelectDay = res.getString(R.string.select_day);
    mYearPickerDescription = res.getString(R.string.year_picker_description);
    mSelectYear = res.getString(R.string.select_year);

    mAnimator = (AccessibleDateAnimator) view.findViewById(R.id.animator);
    mAnimator.addView(mDayPickerView);
    mAnimator.addView(mYearPickerView);
    mAnimator.setDateMillis(mCalendar.getTimeInMillis());
    // TODO: Replace with animation decided upon by the design team.
    Animation animation = new AlphaAnimation(0.0f, 1.0f);
    animation.setDuration(ANIMATION_DURATION);
    mAnimator.setInAnimation(animation);
    // TODO: Replace with animation decided upon by the design team.
    Animation animation2 = new AlphaAnimation(1.0f, 0.0f);
    animation2.setDuration(ANIMATION_DURATION);
    mAnimator.setOutAnimation(animation2);

    mDoneButton = (Button) view.findViewById(R.id.done);
    mDoneButton.setOnClickListener(this);
    mClearButton = (Button) view.findViewById(R.id.clear);
    mClearButton.setOnClickListener(this);

    updateDisplay(false);
    setCurrentView(currentView);

    if (listPosition != -1) {
        if (currentView == MONTH_AND_DAY_VIEW) {
            mDayPickerView.postSetSelection(listPosition);
        } else if (currentView == YEAR_VIEW) {
            mYearPickerView.postSetSelectionFromTop(listPosition, listPositionOffset);
        }
    }
    return view;
}

From source file:com.chinabike.plugins.mip.activity.LocalAlbumDetail.java

@Override
public void onSingleTap() {
    if (headerBar.getVisibility() == View.VISIBLE) {
        AlphaAnimation animation = new AlphaAnimation(1, 0);
        animation.setDuration(300);/* ww  w .ja  v  a2 s .  c  om*/
        headerBar.startAnimation(animation);
        headerBar.setVisibility(View.GONE);
    } else {
        headerBar.setVisibility(View.VISIBLE);
        AlphaAnimation animation = new AlphaAnimation(0, 1);
        animation.setDuration(300);
        headerBar.startAnimation(animation);
    }
}

From source file:org.secuso.privacyfriendlydicegame.MainActivity.java

public void flashResult() {

    Animation animation = new AlphaAnimation(0.0f, 1.0f);
    animation.setDuration(500);// w w  w. j  a va 2  s .  c om
    animation.setStartOffset(20);
    animation.setRepeatMode(Animation.REVERSE);

    TextView finalResult = (TextView) findViewById(R.id.resultTextView);

    for (int i = 0; i < dice.length; i++) {
        if (!isLocked[i])
            dice[i].startAnimation(animation);
    }

    if (roundCounter == 3) {
        finalResult.startAnimation(animation);
    }

}

From source file:jp.seesaa.android.datetimepicker.date.DatePickerDialog.java

private View createView(LayoutInflater inflater, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.dtp_date_picker_dialog, null);

    mDayOfWeekView = (TextView) view.findViewById(R.id.date_picker_header);
    mMonthAndDayView = (LinearLayout) view.findViewById(R.id.date_picker_month_and_day);
    mMonthAndDayView.setOnClickListener(this);
    mSelectedMonthTextView = (TextView) view.findViewById(R.id.date_picker_month);
    mSelectedDayTextView = (TextView) view.findViewById(R.id.date_picker_day);
    mYearView = (TextView) view.findViewById(R.id.date_picker_year);
    mYearView.setOnClickListener(this);

    int listPosition = -1;
    int listPositionOffset = 0;
    int currentView = MONTH_AND_DAY_VIEW;
    if (savedInstanceState != null) {
        mWeekStart = savedInstanceState.getInt(KEY_WEEK_START);
        mMinYear = savedInstanceState.getInt(KEY_YEAR_START);
        mMaxYear = savedInstanceState.getInt(KEY_YEAR_END);
        currentView = savedInstanceState.getInt(KEY_CURRENT_VIEW);
        listPosition = savedInstanceState.getInt(KEY_LIST_POSITION);
        listPositionOffset = savedInstanceState.getInt(KEY_LIST_POSITION_OFFSET);
    }//from   w  w w.  j av  a2  s  . co  m

    final Activity activity = getActivity();
    mDayPickerView = new SimpleDayPickerView(activity, this);
    mYearPickerView = new YearPickerView(activity, this);

    Resources res = getResources();
    mDayPickerDescription = res.getString(R.string.dtp_day_picker_description);
    mSelectDay = res.getString(R.string.dtp_select_day);
    mYearPickerDescription = res.getString(R.string.dtp_year_picker_description);
    mSelectYear = res.getString(R.string.dtp_select_year);

    mAnimator = (AccessibleDateAnimator) view.findViewById(R.id.animator);
    mAnimator.addView(mDayPickerView);
    mAnimator.addView(mYearPickerView);
    mAnimator.setDateMillis(mCalendar.getTimeInMillis());
    // TODO: Replace with animation decided upon by the design team.
    Animation animation = new AlphaAnimation(0.0f, 1.0f);
    animation.setDuration(ANIMATION_DURATION);
    mAnimator.setInAnimation(animation);
    // TODO: Replace with animation decided upon by the design team.
    Animation animation2 = new AlphaAnimation(1.0f, 0.0f);
    animation2.setDuration(ANIMATION_DURATION);
    mAnimator.setOutAnimation(animation2);

    updateDisplay(false);
    setCurrentView(currentView);

    if (listPosition != -1) {
        if (currentView == MONTH_AND_DAY_VIEW) {
            mDayPickerView.postSetSelection(listPosition);
        } else if (currentView == YEAR_VIEW) {
            mYearPickerView.postSetSelectionFromTop(listPosition, listPositionOffset);
        }
    }

    mHapticFeedbackController = new HapticFeedbackController(activity);
    return view;
}

From source file:com.oginotihiro.datepicker.DatePickerDialog.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);

    int currentView = MONTH_AND_DAY_VIEW;
    int listPosition = -1;
    int listPositionOffset = 0;

    if (savedInstanceState != null) {
        currentView = savedInstanceState.getInt(KEY_CURRENT_VIEW);
        listPosition = savedInstanceState.getInt(KEY_LIST_POSITION);
        listPositionOffset = savedInstanceState.getInt(KEY_LIST_POSITION_OFFSET);
    }/* w ww .  ja v a 2s  .  c  o  m*/

    View view = inflater.inflate(R.layout.oginotihiro_date_picker_dialog, container, false);

    mDayOfWeekView = (TextView) view.findViewById(R.id.datePickerHeader);

    mMonthAndDayView = (LinearLayout) view.findViewById(R.id.date_picker_month_and_day);
    mMonthAndDayView.setOnClickListener(this);

    mSelectedMonthTv = (TextView) view.findViewById(R.id.date_picker_month);
    mSelectedDayTv = (TextView) view.findViewById(R.id.date_picker_day);
    mSelectedYearTv = (TextView) view.findViewById(R.id.date_picker_year);
    mSelectedYearTv.setOnClickListener(this);

    int[][] states = new int[][] { new int[] { -android.R.attr.state_pressed, -android.R.attr.state_selected },
            new int[] { -android.R.attr.state_pressed, android.R.attr.state_selected },
            new int[] { android.R.attr.state_pressed } };
    int[] colors = new int[] { getResources().getColor(R.color.date_picker_text_normal), mColor, mDarkColor };
    ColorStateList csl = new ColorStateList(states, colors);

    mSelectedMonthTv.setTextColor(csl);
    mSelectedDayTv.setTextColor(csl);
    mSelectedYearTv.setTextColor(csl);

    Activity activity = getActivity();
    mYearPickerView = new YearPickerView(activity, this);
    mDayPickerView = new DayPickerView(activity, this);

    mAnimator = (ViewAnimator) view.findViewById(R.id.animator);
    mAnimator.addView(mDayPickerView);
    mAnimator.addView(mYearPickerView);

    AlphaAnimation inAlphaAnimation = new AlphaAnimation(0.0F, 1.0F);
    inAlphaAnimation.setDuration(300);
    mAnimator.setInAnimation(inAlphaAnimation);

    AlphaAnimation outAlphaAnimation = new AlphaAnimation(1.0F, 0.0F);
    outAlphaAnimation.setDuration(300);
    mAnimator.setOutAnimation(outAlphaAnimation);

    mDoneButton = (Button) view.findViewById(R.id.done);

    StateListDrawable sld = new StateListDrawable();
    sld.addState(new int[] { android.R.attr.state_pressed },
            new ColorDrawable(Color.argb(60, Color.red(mColor), Color.green(mColor), Color.blue(mColor))));

    mDoneButton.setOnClickListener(this);

    if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) {
        mDoneButton.setBackgroundDrawable(sld);
    } else {
        mDoneButton.setBackground(sld);
    }

    updateDisplay();
    setCurrentView(currentView, true);

    if (listPosition != -1) {
        if (currentView == MONTH_AND_DAY_VIEW) {
            mDayPickerView.postSetSelection(listPosition);
        }
        if (currentView == YEAR_VIEW) {
            mYearPickerView.postSetSelectionFromTop(listPosition, listPositionOffset);
        }
    }
    return view;
}

From source file:com.launcher.silverfish.launcher.homescreen.HomeScreenFragment.java

@SuppressWarnings("deprecation")
private void updateShortcuts() {
    int count = appsList.size();
    int size = (int) Math.ceil(Math.sqrt(count));
    shortcutLayout.removeAllViews();//from  w  ww.ja  v  a 2 s  . com

    if (size == 0) {
        size = 1;
    }

    // Redraw the layout
    shortcutLayout.setSize(size);
    shortcutLayout.requestLayout();
    shortcutLayout.invalidate();

    for (int i = 0; i < appsList.size(); i++) {
        final AppDetail app = appsList.get(i);
        View convertView = getActivity().getLayoutInflater().inflate(R.layout.shortcut_item, null);

        // load the app icon in an async task
        ImageView im = (ImageView) convertView.findViewById(R.id.item_app_icon);
        Utils.loadAppIconAsync(mPacMan, app.packageName.toString(), im);

        TextView tv = (TextView) convertView.findViewById(R.id.item_app_label);
        tv.setText(app.label);
        shortcutLayout.addView(convertView);

        convertView.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View view, MotionEvent event) {
                switch (MotionEventCompat.getActionMasked(event)) {
                case MotionEvent.ACTION_DOWN:
                    updateTouchDown(event);
                    break;

                case MotionEvent.ACTION_MOVE:
                    tryConsumeSwipe(event);
                    break;

                case MotionEvent.ACTION_UP:
                    // We only want to launch the activity if the touch was not consumed yet!
                    if (!touchConsumed) {
                        Intent i = mPacMan.getLaunchIntentForPackage(app.packageName.toString());
                        if (i != null) {
                            // Sanity check (application may have been uninstalled)
                            // TODO Remove it from the database
                            startActivity(i);
                        } else {
                            Toast.makeText(getContext(), R.string.application_not_installed, Toast.LENGTH_SHORT)
                                    .show();
                        }
                    }
                    break;
                }

                return touchConsumed;
            }
        });

        // start a drag when an app has been long clicked
        final long appId = app.id;
        final int appIndex = i;
        convertView.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View view) {
                String[] mime_types = { ClipDescription.MIMETYPE_TEXT_PLAIN };
                ClipData data = new ClipData(Constants.DRAG_SHORTCUT_REMOVAL, mime_types,
                        new ClipData.Item(Long.toString(appId)));

                data.addItem(new ClipData.Item(Integer.toString(appIndex)));

                View.DragShadowBuilder shadowBuilder = new View.DragShadowBuilder(
                        view.findViewById(R.id.item_app_icon));

                // "This method was deprecated in API level 24. Use startDragAndDrop()
                // for newer platform versions."
                if (Build.VERSION.SDK_INT < 24) {
                    view.startDrag(data, shadowBuilder, view, 0);
                } else {
                    view.startDragAndDrop(data, shadowBuilder, view, 0);
                }

                // Show removal indicator
                FrameLayout rem_ind = (FrameLayout) rootView.findViewById(R.id.remove_indicator);
                rem_ind.setVisibility(View.VISIBLE);
                AlphaAnimation animation = new AlphaAnimation(0.0f, 1.0f);
                animation.setDuration(500);
                rem_ind.startAnimation(animation);
                return true;

            }
        });
    }
}

From source file:net.bither.fragment.hot.AddAddressHotHDMFragment.java

private void finalAnimation() {
    final int fadeDuration = 400;
    final int zoomDuration = 500;

    AlphaAnimation fadeOut = new AlphaAnimation(1, 0);
    fadeOut.setDuration(fadeDuration);/*from   w  w w. j  a v a 2  s . c o m*/
    fadeOut.setFillAfter(true);
    vBg.startAnimation(fadeOut);
    tvHot.startAnimation(fadeOut);
    tvCold.startAnimation(fadeOut);
    tvServer.startAnimation(fadeOut);
    if (llSingularRunning.getVisibility() == View.VISIBLE) {
        llSingularRunning.startAnimation(fadeOut);
    }
    flContainer.postDelayed(new Runnable() {
        @Override
        public void run() {
            vBg.setVisibility(View.GONE);
            tvHot.setVisibility(View.INVISIBLE);
            tvCold.setVisibility(View.INVISIBLE);
            tvServer.setVisibility(View.INVISIBLE);

            int[] size = getCompactContainerSize();
            WrapLayoutParamsForAnimator animWrapper = new WrapLayoutParamsForAnimator(flContainer);
            ObjectAnimator animatorWidth = ObjectAnimator.ofInt(animWrapper, "width", size[0])
                    .setDuration(zoomDuration);
            ObjectAnimator animatorHeight = ObjectAnimator.ofInt(animWrapper, "height", size[1])
                    .setDuration(zoomDuration);
            AnimatorSet animatorSet = new AnimatorSet();
            animatorSet.playTogether(animatorWidth, animatorHeight);
            animatorSet.start();

            flContainer.postDelayed(new Runnable() {
                @Override
                public void run() {
                    Animation anim = AnimationUtils.loadAnimation(getActivity(), R.anim.hdm_keychain_add_spin);
                    anim.setFillAfter(true);
                    flContainer.startAnimation(anim);

                    ArrayList<String> addresses = getAddresses();
                    Intent intent = new Intent();
                    intent.putExtra(BitherSetting.INTENT_REF.ADDRESS_POSITION_PASS_VALUE_TAG, addresses);
                    getActivity().setResult(Activity.RESULT_OK, intent);

                    flContainer.postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            if (getActivity() != null) {
                                ((AddPrivateKeyActivity) getActivity()).save();
                            }
                        }
                    }, anim.getDuration());
                }
            }, zoomDuration);
        }
    }, fadeDuration);
}

From source file:com.pdftron.pdf.utils.ViewerUtils.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public static void animateView(final View view, final PDFViewCtrl pdfViewCtrl) {
    // Example of another animation that could be applied to the view.
    //ValueAnimator colorAnim = ObjectAnimator.ofInt(view, "backgroundColor", /*Red*/0xFFFF8080, /*Blue*/0xFF8080FF);
    //colorAnim.setDuration(1500);
    //colorAnim.setEvaluator(new ArgbEvaluator());
    //colorAnim.setRepeatCount(2);
    //colorAnim.setRepeatMode(ValueAnimator.REVERSE);

    // Honeycomb introduced new Animation classes that are easier to use
    // and provide more options. Let's do a runtime check here and use
    // older classes for pre-Honeycomb devices.
    if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB) {
        AlphaAnimation anim1 = new AlphaAnimation(0.0f, 1.0f);
        final AlphaAnimation anim2 = new AlphaAnimation(1.0f, 0.0f);
        anim1.setDuration(500);//from w w w .j  av  a 2 s  .c  om
        anim2.setDuration(500);
        anim1.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
            }

            @Override
            public void onAnimationEnd(Animation animation) {
                view.startAnimation(anim2);
            }
        });
        anim2.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
            }

            @Override
            public void onAnimationEnd(Animation animation) {
                if (pdfViewCtrl != null) {
                    pdfViewCtrl.removeView(view);
                }
            }
        });
        view.startAnimation(anim1);

    } else {
        // Since we want the flashing view to be removed once the animation
        // is finished, we use this listener to remove the view from
        // PDFViewCtrl when the event is triggered.
        Animator.AnimatorListener animListener = new Animator.AnimatorListener() {
            @Override
            public void onAnimationStart(Animator animation) {
            }

            @Override
            public void onAnimationRepeat(Animator animation) {
            }

            @Override
            public void onAnimationEnd(Animator animation) {
                pdfViewCtrl.removeView(view);
            }

            @Override
            public void onAnimationCancel(Animator animation) {
            }
        };

        // Get animator for the flashing view.
        Animator fader = createAlphaAnimator(view, animListener);

        // If using more than one animator, you can create a set and
        // play them together, or in some other order...
        AnimatorSet animation = new AnimatorSet();
        animation.playTogether(/*colorAnim, */fader);
        animation.start();
    }
}

From source file:com.zhangyp.higo.drawingboard.fragment.SketchFragment.java

void setAlpha(View v, float alpha) {
    if (Build.VERSION.SDK_INT < 11) {
        AlphaAnimation animation = new AlphaAnimation(1.0F, alpha);
        animation.setFillAfter(true);//from   ww  w. j ava 2  s. c om
        v.startAnimation(animation);
    } else {
        v.setAlpha(alpha);
    }

}

From source file:com.mina.breathitout.AnalyzeActivity.java

private void moveUp() {
    AnalyzeActivity.this.runOnUiThread(new Runnable() {
        @Override//from   www . j  a  v a  2 s .c  o m
        public void run() {
            view.moveUP();
            breathOutView.setVisibility(View.VISIBLE);
            AlphaAnimation fadeIn_breathout = new AlphaAnimation(0.0f, 1.0f);
            fadeIn_breathout.setDuration(2000);
            fadeIn_breathout.setAnimationListener(new Animation.AnimationListener() {
                @Override
                public void onAnimationStart(Animation animation) {

                }

                @Override
                public void onAnimationEnd(Animation animation) {
                    AlphaAnimation fadeOut_breathout = new AlphaAnimation(1.0f, 0.0f);
                    breathOutView.startAnimation(fadeOut_breathout);
                    fadeOut_breathout.setDuration(2000);
                    breathOutView.setVisibility(View.INVISIBLE);
                }

                @Override
                public void onAnimationRepeat(Animation animation) {

                }
            });

            breathOutView.startAnimation(fadeIn_breathout);
            fadeIn_breathout.setFillAfter(true);
            animateProgressBar();
        }
    });
}