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:quickbeer.android.views.ProgressIndicatorBar.java

private void animateToHidden() {
    Timber.v("animateToHidden()");
    checkNotNull(progressBar);//from w w w  . jav  a2  s  . c om

    AlphaAnimation animation = new AlphaAnimation(1.0f, 0.0f);
    animation.setStartOffset(ANIMATION_END_PAUSE_DURATION);
    animation.setDuration(ANIMATION_END_FADE_DURATION);
    animation.setFillAfter(true);

    progressBar.clearAnimation();
    progressBar.startAnimation(animation);
}

From source file:com.hookedonplay.decoviewsample.SamplePeopleFragment.java

private void showAvatar(boolean show, View view) {
    AlphaAnimation animation = new AlphaAnimation(show ? 0.0f : 1.0f, show ? 1.0f : 0.0f);
    animation.setDuration(1000);/*  ww  w  .ja v  a2s.  co  m*/
    animation.setFillAfter(true);
    view.startAnimation(animation);
}

From source file:com.cachirulop.moneybox.fragment.MoneyboxFragment.java

/**
 * Create dynamically an android animation for a coin or a bill getting from
 * the moneybox./*  ww  w . j a  v a  2  s. c  om*/
 * 
 * @param img
 *            ImageView to receive the animation
 * @param layout
 *            Layout that paint the image
 * @return Set of animations to apply to the image
 */
private AnimationSet createGetAnimation(ImageView img, View layout) {
    AnimationSet result;

    result = new AnimationSet(false);
    result.setFillAfter(true);

    // get
    TranslateAnimation get;
    int bottom;

    bottom = Math.abs(layout.getHeight() - img.getLayoutParams().height);
    get = new TranslateAnimation(1.0f, 1.0f, bottom, 1.0f);
    get.setDuration(1500);
    result.addAnimation(get);

    // Fade out
    AlphaAnimation fadeOut;

    fadeOut = new AlphaAnimation(1.0f, 0.0f);
    fadeOut.setDuration(300);
    fadeOut.setStartOffset(1500);

    result.addAnimation(fadeOut);

    return result;
}

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

private void showViewPager(int index) {
    pagerContainer.setVisibility(View.VISIBLE);
    gridView.setVisibility(View.GONE);
    findViewById(FakeR.getId(this, "id", "album_title_bar")).setVisibility(View.GONE);
    viewpager.setAdapter(viewpager.new LocalViewPagerAdapter(currentFolder));
    viewpager.setCurrentItem(index);/*ww  w.  ja  v  a2s  .  c o  m*/
    mCountView.setText((index + 1) + "/" + currentFolder.size());
    //?
    if (index == 0) {
        checkBox.setTag(currentFolder.get(index));
        checkBox.setChecked(checkedItems.contains(currentFolder.get(index)));
    }
    AnimationSet set = new AnimationSet(true);
    ScaleAnimation scaleAnimation = new ScaleAnimation((float) 0.9, 1, (float) 0.9, 1,
            pagerContainer.getWidth() / 2, pagerContainer.getHeight() / 2);
    scaleAnimation.setDuration(300);
    set.addAnimation(scaleAnimation);
    AlphaAnimation alphaAnimation = new AlphaAnimation((float) 0.1, 1);
    alphaAnimation.setDuration(200);
    set.addAnimation(alphaAnimation);
    pagerContainer.startAnimation(set);
}

From source file:com.tr4android.support.extension.widget.LabelView.java

private static Animation createAnimationSet(float fromAlpha, float toAlpha, int fromXDelta, int toXDelta) {
    AnimationSet anim = new AnimationSet(true);
    anim.addAnimation(new AlphaAnimation(fromAlpha, toAlpha));
    anim.addAnimation(new TranslateAnimation(fromXDelta, toXDelta, 0, 0));
    return anim;/*from  w ww  .  j  a  v  a 2 s  .com*/
}

From source file:com.diandi.widget.googledatetimepicker.date.DatePickerDialog.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(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 www.  j a va2 s  .  c  o 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(new OnClickListener() {

        @Override
        public void onClick(View v) {
            tryVibrate();
            if (mCallBack != null) {
                mCallBack.onDateSet(DatePickerDialog.this, mCalendar.get(Calendar.YEAR),
                        mCalendar.get(Calendar.MONTH), mCalendar.get(Calendar.DAY_OF_MONTH));
            }
            dismiss();
        }
    });

    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.glabs.homegenie.StartActivity.java

public void hideLogo() {
    _islogovisible = false;/*  www.j a  v  a2 s .  c o  m*/
    runOnUiThread(new Runnable() {
        @Override
        public void run() {
            Animation fadeOut = new AlphaAnimation(0.8f, 0);
            fadeOut.setInterpolator(new AccelerateInterpolator()); //and this
            fadeOut.setStartOffset(0);
            fadeOut.setDuration(500);
            //
            AnimationSet animation = new AnimationSet(false); //change to false
            animation.addAnimation(fadeOut);
            animation.setFillAfter(true);
            RelativeLayout ivlogo = (RelativeLayout) findViewById(R.id.logo);
            ivlogo.startAnimation(animation);
        }
    });
}

From source file:com.zzisoo.toylibrary.adapter.ToyListAdapter.java

@Override
public void onBindViewHolder(ViewHolder viewHolder, final int position) {
    Log.e(TAG, "onBindViewHolder #" + position);

    // Get element from your dataset at this position and replace the contents of the view
    // with that element
    View v = viewHolder.getVh();/*from   w ww. j  ava2s .  c  o  m*/
    final ImageView ivToyImage = viewHolder.getIvToyImage();
    final TextView textView = viewHolder.getTvTitle();
    final FlipImageView flipImageView = viewHolder.getFlipImageView();

    View.OnClickListener l = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            String strPid = mDataSet.get(position).getStrPid();

            if (mPref.getStringArrayList(SharedPref.PREF_FAVORITE_LIST).contains(strPid)) {
                mPref.removeStringArrayListItem(SharedPref.PREF_FAVORITE_LIST, strPid);
            } else {
                mPref.addStringArrayListItem(SharedPref.PREF_FAVORITE_LIST, strPid);
            }
            flipImageView.toggleFlip();
        }
    };
    textView.setOnClickListener(l);
    flipImageView.setOnClickListener(l);

    viewHolder.getTvLoadingBackground().setBackgroundColor(getPastelRBG());
    viewHolder.getTvLoading().setText("ToyToI");
    if (-1 < position && position < mDataSet.size()) {
        setItemSize(v);

        mFavList = mPref.getStringArrayList(SharedPref.PREF_FAVORITE_LIST);
        if (mFavList.contains(mDataSet.get(position).getStrPid())) {
            flipImageView.setFlipped(true);
        } else {
            flipImageView.setFlipped(false);
        }

        final Toy toy = mDataSet.get(position);

        String bgImage = Config.HOST_SERVER_URL + toy.getImage().replace("..", "");
        String strTitle = toy.getTitle();
        textView.setText(strTitle);//

        ImageLoadingListener fadeImageLoadingListener = new ImageLoadingListener() {

            long ANIM_DURATION = 500;

            @Override
            public void onLoadingStarted(String s, View view) {
                view.clearAnimation();
                ((ImageView) view).setImageResource(R.drawable.alpha_zero);
            }

            @Override
            public void onLoadingFailed(String s, View view, FailReason failReason) {
                Toast.makeText(view.getContext(), "Network Error : " + failReason.getType().toString(),
                        Toast.LENGTH_LONG).show();
                ((TextView) ((FrameLayout) view.getParent()).findViewById(R.id.tvLoading)).setText("Error");
                Log.e(TAG, "onLoadingFailed :" + s);
            }

            @Override
            public void onLoadingComplete(String s, View view, Bitmap bitmap) {
                ((ImageView) view).setImageBitmap(bitmap);
                Animation fadeIn = new AlphaAnimation(0, 1);
                fadeIn.setInterpolator(new DecelerateInterpolator()); // add this
                fadeIn.setDuration(ANIM_DURATION);
                view.clearAnimation();
                view.startAnimation(fadeIn);
            }

            @Override
            public void onLoadingCancelled(String s, View view) {
                if (view != null) {
                    ((TextView) ((FrameLayout) view.getParent()).findViewById(R.id.tvLoading)).setText("Error");
                    Log.e(TAG, "onLoadingCancelled :" + s);
                }
            }
        };

        App.getImageLoader(v.getContext()).displayImage(bgImage, ivToyImage, fadeImageLoadingListener);
        ivToyImage.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(final View v) {
                AsyncHttpClient asyncHttpClient = new AsyncHttpClient();

                asyncHttpClient.get(v.getContext(), Config.URL_DETAIL + mDataSet.get(position).getStrPid(),
                        new AsyncHttpResponseHandler() {

                            @Override
                            public void onSuccess(int i, Header[] headers, byte[] bytes) {
                                String responseStr = new String(bytes);
                                Context context = v.getContext();

                                Bundle bundle = new Bundle();
                                Gson gson = new Gson();
                                Product[] products = gson.fromJson(responseStr, Product[].class);

                                Intent intent = new Intent(context,
                                        FlexibleSpaceWithImageRecyclerViewActivity.class);
                                intent.putExtra("Products", gson.toJson(products));
                                intent.putExtra("title", toy.getTitle());
                                intent.putExtra("image", toy.getImage());
                                intent.putExtra("favorite",
                                        mPref.getStringArrayList(SharedPref.PREF_FAVORITE_LIST)
                                                .contains(toy.getStrPid()));
                                context.startActivity(intent);

                                //changeFragment
                            }

                            private void changeFragment(Bundle bundle) {
                                Fragment fragment = new ProductListViewFragment();
                                fragment.setArguments(bundle);

                                FragmentTransaction transaction = ((FragmentActivity) v.getContext())
                                        .getSupportFragmentManager().beginTransaction();
                                transaction.setCustomAnimations(R.anim.enter, R.anim.exit, R.anim.popenter,
                                        R.anim.popexit);
                                transaction.addToBackStack(getClass().getSimpleName());
                                transaction.replace(R.id.toyListViewWraper, fragment);
                                transaction.commit();
                            }

                            @Override
                            public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) {

                            }
                        });

                Log.d(TAG, "Element " + position + " clicked.");
                mClickedPostion = position;
                //
            }
        });
    }

}

From source file:com.cachirulop.moneybox.fragment.MoneyboxFragment.java

/**
 * Create dynamically an android animation for a coin or a bill deleted from
 * the moneybox.//ww  w.  j a  v a  2 s  .  co m
 * 
 * @param img
 *            ImageView to receive the animation
 * @param layout
 *            Layout that paint the image
 * @return Set of animations to apply to the image
 */
private AnimationSet createDeleteAnimation(ImageView img, View layout) {
    AnimationSet result;

    result = new AnimationSet(false);
    result.setFillAfter(true);

    // Fade out
    AlphaAnimation fadeOut;

    fadeOut = new AlphaAnimation(1.0f, 0.0f);
    fadeOut.setStartOffset(300);
    fadeOut.setDuration(300);

    result.addAnimation(fadeOut);

    return result;
}

From source file:com.philliphsu.bottomsheetpickers.date.BottomSheetDatePickerDialog.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View view = super.onCreateView(inflater, container, savedInstanceState);

    mDayOfWeekView = (TextView) view.findViewById(R.id.date_picker_header);
    mMonthDayYearView = (LinearLayout) view.findViewById(R.id.date_picker_month_day_year);
    mFirstTextView = (TextView) view.findViewById(R.id.date_picker_first_textview);
    mFirstTextView.setOnClickListener(this);
    mSecondTextView = (TextView) view.findViewById(R.id.date_picker_second_textview);
    mSecondTextView.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);
    }/*w w w.j  av a  2s .c  o  m*/

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

    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 = (FloatingActionButton) view.findViewById(R.id.done);
    mDoneButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            tryVibrate();
            if (mCallBack != null) {
                mCallBack.onDateSet(BottomSheetDatePickerDialog.this, mCalendar.get(Calendar.YEAR),
                        mCalendar.get(Calendar.MONTH), mCalendar.get(Calendar.DAY_OF_MONTH));
            }
            dismiss();
        }
    });

    // Theme-specific configurations.
    if (mThemeDark) {
        // This is so the margin gets colored as well.
        view.setBackgroundColor(mDarkGray);
        mAnimator.setBackgroundColor(mDarkGray);
    } else {
        // Setup FAB icon color.
        Drawable fabIcon = mDoneButton.getDrawable();
        Utils.setTint(fabIcon, mAccentColor);
        mDoneButton.setImageDrawable(fabIcon);
    }

    // Configurations for both themes.
    View selectedDateLayout = view.findViewById(R.id.day_picker_selected_date_layout);
    selectedDateLayout.setBackgroundColor(mThemeDark ? mLightGray : mAccentColor);

    int white = ContextCompat.getColor(getActivity(), android.R.color.white);
    mDoneButton.setBackgroundTintList(ColorStateList.valueOf(mThemeDark ? mAccentColor : white));

    determineLocale_MD_Y_Indices();
    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;
}