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:com.layernet.thaidatetimepicker.date.DatePickerDialog.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    // All options have been set at this point: round the initial selection if necessary
    setToNearestDate(mCalendar);/*www.j a v  a  2  s  . c  o m*/

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

    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 = mDefaultView;
    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);
        mMinDate = (Calendar) savedInstanceState.getSerializable(KEY_MIN_DATE);
        mMaxDate = (Calendar) savedInstanceState.getSerializable(KEY_MAX_DATE);
        highlightedDays = (Calendar[]) savedInstanceState.getSerializable(KEY_HIGHLIGHTED_DAYS);
        selectableDays = (Calendar[]) savedInstanceState.getSerializable(KEY_SELECTABLE_DAYS);
        disabledDays = (Calendar[]) savedInstanceState.getSerializable(KEY_DISABLED_DAYS);
        mThemeDark = savedInstanceState.getBoolean(KEY_THEME_DARK);
        mThemeDarkChanged = savedInstanceState.getBoolean(KEY_THEME_DARK_CHANGED);
        mAccentColor = savedInstanceState.getInt(KEY_ACCENT);
        mVibrate = savedInstanceState.getBoolean(KEY_VIBRATE);
        mDismissOnPause = savedInstanceState.getBoolean(KEY_DISMISS);
        mAutoDismiss = savedInstanceState.getBoolean(KEY_AUTO_DISMISS);
        mTitle = savedInstanceState.getString(KEY_TITLE);
        mOkResid = savedInstanceState.getInt(KEY_OK_RESID);
        mOkString = savedInstanceState.getString(KEY_OK_STRING);
        mCancelResid = savedInstanceState.getInt(KEY_CANCEL_RESID);
        mCancelString = savedInstanceState.getString(KEY_CANCEL_STRING);
    }

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

    // if theme mode has not been set by java code, check if it is specified in Style.xml
    if (!mThemeDarkChanged) {
        mThemeDark = Utils.isDarkTheme(activity, mThemeDark);
    }

    Resources res = getResources();
    mDayPickerDescription = res.getString(R.string.mdtp_day_picker_description);
    mSelectDay = res.getString(R.string.mdtp_select_day);
    mYearPickerDescription = res.getString(R.string.mdtp_year_picker_description);
    mSelectYear = res.getString(R.string.mdtp_select_year);

    int bgColorResource = mThemeDark ? R.color.mdtp_date_picker_view_animator_dark_theme
            : R.color.mdtp_date_picker_view_animator;
    view.setBackgroundColor(ContextCompat.getColor(activity, bgColorResource));

    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);

    Button okButton = (Button) view.findViewById(R.id.ok);
    okButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            tryVibrate();
            notifyOnDateListener();
            dismiss();
        }
    });
    okButton.setTypeface(TypefaceHelper.get(activity, "Roboto-Medium"));
    if (mOkString != null)
        okButton.setText(mOkString);
    else
        okButton.setText(mOkResid);

    Button cancelButton = (Button) view.findViewById(R.id.cancel);
    cancelButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            tryVibrate();
            if (getDialog() != null)
                getDialog().cancel();
        }
    });
    cancelButton.setTypeface(TypefaceHelper.get(activity, "Roboto-Medium"));
    if (mCancelString != null)
        cancelButton.setText(mCancelString);
    else
        cancelButton.setText(mCancelResid);
    cancelButton.setVisibility(isCancelable() ? View.VISIBLE : View.GONE);

    // If an accent color has not been set manually, get it from the context
    if (mAccentColor == -1) {
        mAccentColor = Utils.getAccentColorFromThemeIfAvailable(getActivity());
    }
    if (mDayOfWeekView != null)
        mDayOfWeekView.setBackgroundColor(Utils.darkenColor(mAccentColor));
    view.findViewById(R.id.day_picker_selected_date_layout).setBackgroundColor(mAccentColor);
    okButton.setTextColor(mAccentColor);
    cancelButton.setTextColor(mAccentColor);

    if (getDialog() == null) {
        view.findViewById(R.id.done_background).setVisibility(View.GONE);
    }

    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.example.camera360.ui.ImageDetailActivity.java

private void showDetailView(final float p1, final float p2) {
    AlphaAnimation alphaAnimation = new AlphaAnimation(p1, p2);
    alphaAnimation.setDuration(DURATION_MILLIS);
    alphaAnimation.setAnimationListener(new AnimationListener() {
        @Override/*from   w w w. j a v  a  2  s. co m*/
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            mImageDetailView.clearAnimation();
            if (p2 == 0) {
                mImageDetailView.setVisibility(View.INVISIBLE);
            }
            checkStatus();
        }
    });
    mImageDetailView.setAnimation(alphaAnimation);
    alphaAnimation.setFillAfter(true);
}

From source file:com.almalence.opencam.ui.AlmalenceStore.java

public void ShowUnlockControl() {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(MainScreen.getMainContext());
    boolean bOnSale = prefs.getBoolean("bOnSale", false);
    final RotateImageView unlock = ((RotateImageView) guiView.findViewById(R.id.Unlock));
    unlock.setImageDrawable(//w  w  w .  jav  a2 s . c  o  m
            MainScreen.getAppResources().getDrawable(bOnSale ? R.drawable.unlock_sale : R.drawable.unlock));
    unlock.setAlpha(1.0f);
    unlock.setVisibility(View.VISIBLE);

    Animation invisible_alpha = new AlphaAnimation(1, 0.4f);
    invisible_alpha.setDuration(7000);
    invisible_alpha.setRepeatCount(0);

    invisible_alpha.setAnimationListener(new AnimationListener() {
        @Override
        public void onAnimationEnd(Animation animation) {
            unlock.clearAnimation();
            unlock.setImageDrawable(MainScreen.getAppResources().getDrawable(R.drawable.unlock_gray));
            unlock.setAlpha(0.4f);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }

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

    unlock.startAnimation(invisible_alpha);
}

From source file:com.jarklee.materialdatetimepicker.date.DatePickerDialog.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    // All options have been set at this point: round the initial selection if necessary
    setToNearestDate(mCalendar);/*  w  w  w  .j ava2s.  c  om*/

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

    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 = mDefaultView;
    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);
        mMinDate = (Calendar) savedInstanceState.getSerializable(KEY_MIN_DATE);
        mMaxDate = (Calendar) savedInstanceState.getSerializable(KEY_MAX_DATE);
        highlightedDays = (Calendar[]) savedInstanceState.getSerializable(KEY_HIGHLIGHTED_DAYS);
        selectableDays = (Calendar[]) savedInstanceState.getSerializable(KEY_SELECTABLE_DAYS);
        disabledDays = (Calendar[]) savedInstanceState.getSerializable(KEY_DISABLED_DAYS);
        mThemeDark = savedInstanceState.getBoolean(KEY_THEME_DARK);
        mThemeDarkChanged = savedInstanceState.getBoolean(KEY_THEME_DARK_CHANGED);
        mAccentColor = savedInstanceState.getInt(KEY_ACCENT);
        mVibrate = savedInstanceState.getBoolean(KEY_VIBRATE);
        mDismissOnPause = savedInstanceState.getBoolean(KEY_DISMISS);
        mAutoDismiss = savedInstanceState.getBoolean(KEY_AUTO_DISMISS);
        mTitle = savedInstanceState.getString(KEY_TITLE);
        mOkResid = savedInstanceState.getInt(KEY_OK_RESID);
        mOkString = savedInstanceState.getString(KEY_OK_STRING);
        mCancelResid = savedInstanceState.getInt(KEY_CANCEL_RESID);
        mCancelString = savedInstanceState.getString(KEY_CANCEL_STRING);
    }

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

    // if theme mode has not been set by java code, check if it is specified in Style.xml
    if (!mThemeDarkChanged) {
        mThemeDark = Utils.isDarkTheme(activity, mThemeDark);
    }

    Resources res = getResources();
    mDayPickerDescription = res.getString(R.string.mdtp_day_picker_description);
    mSelectDay = res.getString(R.string.mdtp_select_day);
    mYearPickerDescription = res.getString(R.string.mdtp_year_picker_description);
    mSelectYear = res.getString(R.string.mdtp_select_year);

    int bgColorResource = mThemeDark ? R.color.mdtp_date_picker_view_animator_dark_theme
            : R.color.mdtp_date_picker_view_animator;
    view.setBackgroundColor(ContextCompat.getColor(activity, bgColorResource));

    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);

    mOkButton = (Button) view.findViewById(R.id.ok);
    mOkButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            tryVibrate();
            notifyOnDateListener();
            dismiss();
        }
    });
    mOkButton.setTypeface(TypefaceHelper.get(activity, "Roboto-Medium"));
    if (mOkString != null)
        mOkButton.setText(mOkString);
    else
        mOkButton.setText(Utils.getStringFromLocale(getContext(), mOkResid, getLocale()));

    mCancelButton = (Button) view.findViewById(R.id.cancel);
    mCancelButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            tryVibrate();
            if (getDialog() != null)
                getDialog().cancel();
        }
    });
    mCancelButton.setTypeface(TypefaceHelper.get(activity, "Roboto-Medium"));
    if (mCancelString != null)
        mCancelButton.setText(mCancelString);
    else
        mCancelButton.setText(Utils.getStringFromLocale(getContext(), mCancelResid, getLocale()));
    mCancelButton.setVisibility(isCancelable() ? View.VISIBLE : View.GONE);

    // If an accent color has not been set manually, get it from the context
    if (mAccentColor == -1) {
        mAccentColor = Utils.getAccentColorFromThemeIfAvailable(getActivity());
    }
    if (mDayOfWeekView != null)
        mDayOfWeekView.setBackgroundColor(Utils.darkenColor(mAccentColor));
    view.findViewById(R.id.day_picker_selected_date_layout).setBackgroundColor(mAccentColor);
    mOkButton.setTextColor(mAccentColor);
    mCancelButton.setTextColor(mAccentColor);

    if (getDialog() == null) {
        view.findViewById(R.id.done_background).setVisibility(View.GONE);
    }

    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.kubotaku.android.sample.sensordataviewer.SensorDataActivity.java

private void setShowValueAnimation(View view) {
    final AlphaAnimation alphaAnimation = new AlphaAnimation(0.0f, 1.0f);
    alphaAnimation.setDuration(750);//from   ww  w .  j  a va2  s.  c om
    alphaAnimation.setFillAfter(true);
    view.setAnimation(alphaAnimation);
}

From source file:com.kunze.androidlocaltodo.TaskActivityFragment.java

@Override
public void SwipedWhileDisabled() {
    AlphaAnimation animation = new AlphaAnimation(1.0f, 0.0f);
    animation.setDuration(50);//from w w  w  . jav  a  2 s.c om
    animation.setRepeatCount(5);
    animation.setRepeatMode(Animation.REVERSE);
    Button revertButton = (Button) getView().findViewById(R.id.revert_button);
    Button acceptButton = (Button) getView().findViewById(R.id.accept_button);
    revertButton.startAnimation(animation);
    acceptButton.startAnimation(animation);
}

From source file:it.imwatch.nfclottery.dialogs.InsertContactDialog.java

/**
 * Shows the email error textfield with the appropriate
 * error message.//w  ww . j av  a  2  s  . c  om
 *
 * @param message The error message to show
 */
private void showEmailError(CharSequence message, int errState) {
    mEmailErrorTextView.setText(message);
    mEmailErrorState = errState;

    // Disable the positive button of the dialog
    setFormIsValidated(false);

    if (mEmailErrorTextView.getVisibility() == View.VISIBLE) {
        return; // No need to animate in the textview, it's already visible
    }

    mEmailErrorTextView.setVisibility(View.VISIBLE);

    AnimationSet fadeInSet = new AnimationSet(true);
    fadeInSet.addAnimation(new AlphaAnimation(0f, 1f));
    fadeInSet.addAnimation(new TranslateAnimation(0f, 0f, -mErrorAnimTranslateY, 0f));
    fadeInSet.setDuration(300);
    mEmailErrorTextView.startAnimation(fadeInSet);
}

From source file:com.sahildave.snackbar.SnackBar.java

private AnimationSet getEntryAnimation() {
    //In//from   w w w .j  a v a2  s. c  o  m
    mInAnimationSet = new AnimationSet(false);

    TranslateAnimation mSlideInAnimation = new TranslateAnimation(TranslateAnimation.RELATIVE_TO_PARENT, 0.0f,
            TranslateAnimation.RELATIVE_TO_PARENT, 0.0f, TranslateAnimation.RELATIVE_TO_SELF, 1.0f,
            TranslateAnimation.RELATIVE_TO_SELF, 0.0f);
    mSlideInAnimation.setFillAfter(true);

    AlphaAnimation mFadeInAnimation = new AlphaAnimation(0.0f, 1.0f);
    mFadeInAnimation.setFillAfter(true);

    mInAnimationSet.addAnimation(mSlideInAnimation);
    mInAnimationSet.addAnimation(mFadeInAnimation);

    mInAnimationSet.setDuration(IN_ANIMATION_DURATION);

    return mInAnimationSet;

}

From source file:com.customdatepicker.date.DatePickerDialog.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    int listPosition = -1;
    int listPositionOffset = 0;
    int currentView = mDefaultView;
    if (savedInstanceState != null) {
        mWeekStart = savedInstanceState.getInt(KEY_WEEK_START);
        currentView = savedInstanceState.getInt(KEY_CURRENT_VIEW);
        listPosition = savedInstanceState.getInt(KEY_LIST_POSITION);
        listPositionOffset = savedInstanceState.getInt(KEY_LIST_POSITION_OFFSET);
        //noinspection unchecked
        highlightedDays = (HashSet<Calendar>) savedInstanceState.getSerializable(KEY_HIGHLIGHTED_DAYS);
        mThemeDark = savedInstanceState.getBoolean(KEY_THEME_DARK);
        mThemeDarkChanged = savedInstanceState.getBoolean(KEY_THEME_DARK_CHANGED);
        mAccentColor = savedInstanceState.getInt(KEY_ACCENT);
        mVibrate = savedInstanceState.getBoolean(KEY_VIBRATE);
        mDismissOnPause = savedInstanceState.getBoolean(KEY_DISMISS);
        mAutoDismiss = savedInstanceState.getBoolean(KEY_AUTO_DISMISS);
        mTitle = savedInstanceState.getString(KEY_TITLE);
        mOkResid = savedInstanceState.getInt(KEY_OK_RESID);
        mOkString = savedInstanceState.getString(KEY_OK_STRING);
        mOkColor = savedInstanceState.getInt(KEY_OK_COLOR);
        mCancelResid = savedInstanceState.getInt(KEY_CANCEL_RESID);
        mCancelString = savedInstanceState.getString(KEY_CANCEL_STRING);
        mCancelColor = savedInstanceState.getInt(KEY_CANCEL_COLOR);
        mVersion = (Version) savedInstanceState.getSerializable(KEY_VERSION);
        mTimezone = (TimeZone) savedInstanceState.getSerializable(KEY_TIMEZONE);
        mDateRangeLimiter = savedInstanceState.getParcelable(KEY_DATERANGELIMITER);

        /*/* w w  w  .j a  v a2 s.c om*/
        If the user supplied a custom limiter, we need to create a new default one to prevent
        null pointer exceptions on the configuration methods
        If the user did not supply a custom limiter we need to ensure both mDefaultLimiter
        and mDateRangeLimiter are the same reference, so that the config methods actually
        ffect the behaviour of the picker (in the unlikely event the user reconfigures
        the picker when it is shown)
         */
        if (mDateRangeLimiter instanceof DefaultDateRangeLimiter) {
            mDefaultLimiter = (DefaultDateRangeLimiter) mDateRangeLimiter;
        } else {
            mDefaultLimiter = new DefaultDateRangeLimiter();
        }
    }

    mDefaultLimiter.setController(this);

    int viewRes = mVersion == Version.VERSION_1 ? R.layout.mdtp_date_picker_dialog
            : R.layout.mdtp_date_picker_dialog_v2;
    View view = inflater.inflate(viewRes, container, false);
    // All options have been set at this point: round the initial selection if necessary
    mCalendar = mDateRangeLimiter.setToNearestDate(mCalendar);

    mDatePickerHeaderView = (TextView) view.findViewById(R.id.mdtp_date_picker_header);
    mImageViewLeft = (ImageView) view.findViewById(R.id.imageViewLeft);
    mImageViewRight = (ImageView) view.findViewById(R.id.imageViewRight);
    mMonthAndDayView = (LinearLayout) view.findViewById(R.id.mdtp_date_picker_month_and_day);
    mMonthAndDayView.setOnClickListener(this);
    mSelectedMonthTextView = (TextView) view.findViewById(R.id.mdtp_date_picker_month);
    mSelectedDayTextView = (TextView) view.findViewById(R.id.mdtp_date_picker_day);
    mYearView = (TextView) view.findViewById(R.id.mdtp_date_picker_year);
    mYearView.setOnClickListener(this);
    mImageViewLeft.setOnClickListener(this);
    mImageViewRight.setOnClickListener(this);
    final Activity activity = getActivity();
    mDayPickerView = new SimpleDayPickerView(activity, this);
    mYearPickerView = new YearPickerView(activity, this);

    // if theme mode has not been set by java code, check if it is specified in Style.xml
    if (!mThemeDarkChanged) {
        mThemeDark = Utils.isDarkTheme(activity, mThemeDark);
    }

    Resources res = getResources();
    mDayPickerDescription = res.getString(R.string.mdtp_day_picker_description);
    mSelectDay = res.getString(R.string.mdtp_select_day);
    mYearPickerDescription = res.getString(R.string.mdtp_year_picker_description);
    mSelectYear = res.getString(R.string.mdtp_select_year);

    int bgColorResource = mThemeDark ? R.color.mdtp_date_picker_view_animator_dark_theme
            : R.color.mdtp_date_picker_view_animator;
    view.setBackgroundColor(ContextCompat.getColor(activity, bgColorResource));

    mAnimator = (AccessibleDateAnimator) view.findViewById(R.id.mdtp_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);

    Button okButton = (Button) view.findViewById(R.id.mdtp_ok);
    okButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            tryVibrate();
            notifyOnDateListener();
            dismiss();
        }
    });
    okButton.setTypeface(TypefaceHelper.get(activity, "Roboto-Medium"));
    if (mOkString != null)
        okButton.setText(mOkString);
    else
        okButton.setText(mOkResid);

    Button cancelButton = (Button) view.findViewById(R.id.mdtp_cancel);
    cancelButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            tryVibrate();
            if (getDialog() != null)
                getDialog().cancel();
        }
    });
    cancelButton.setTypeface(TypefaceHelper.get(activity, "Roboto-Medium"));
    if (mCancelString != null)
        cancelButton.setText(mCancelString);
    else
        cancelButton.setText(mCancelResid);
    cancelButton.setVisibility(isCancelable() ? View.VISIBLE : View.GONE);

    // If an accent color has not been set manually, get it from the context
    if (mAccentColor == -1) {
        mAccentColor = Utils.getAccentColorFromThemeIfAvailable(getActivity());
    }
    if (mDatePickerHeaderView != null)
        mDatePickerHeaderView.setBackgroundColor(Utils.darkenColor(mAccentColor));
    view.findViewById(R.id.mdtp_day_picker_selected_date_layout).setBackgroundColor(mAccentColor);

    // Buttons can have a different color
    if (mOkColor != -1)
        okButton.setTextColor(mOkColor);
    else
        okButton.setTextColor(mAccentColor);
    if (mCancelColor != -1)
        cancelButton.setTextColor(mCancelColor);
    else
        cancelButton.setTextColor(mAccentColor);

    if (getDialog() == null) {
        view.findViewById(R.id.mdtp_done_background).setVisibility(View.GONE);
    }

    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:it.imwatch.nfclottery.dialogs.InsertContactDialog.java

/**
 * Shows the name error textfield with the appropriate
 * error message./*  w  ww  .  ja va 2  s.  com*/
 */
private void showNameError() {
    mNameErrorState = 1;

    // Disable the positive button of the dialog
    setFormIsValidated(false);

    if (mNameErrorTextView.getVisibility() == View.VISIBLE) {
        return; // No need to animate in the textview, it's already visible
    }

    mNameErrorTextView.setVisibility(View.VISIBLE);

    AnimationSet fadeInSet = new AnimationSet(true);
    fadeInSet.addAnimation(new AlphaAnimation(0f, 1f));
    fadeInSet.addAnimation(new TranslateAnimation(0f, 0f, -mErrorAnimTranslateY, 0f));
    fadeInSet.setDuration(300);
    mNameErrorTextView.startAnimation(fadeInSet);
}