Example usage for android.view.animation AlphaAnimation setDuration

List of usage examples for android.view.animation AlphaAnimation setDuration

Introduction

In this page you can find the example usage for android.view.animation AlphaAnimation setDuration.

Prototype

public void setDuration(long durationMillis) 

Source Link

Document

How long this animation should last.

Usage

From source file:com.launcher.silverfish.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 a2  s  . co m

    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.name.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.name.toString());
                        startActivity(i);
                    }
                    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: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);/*from   w  w w  . ja va 2 s .  co  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:git.egatuts.nxtremotecontroller.fragment.OnlineControllerFragment.java

public AlphaAnimation getHideAnimation(final View view0, final View view1, final long time) {
    AlphaAnimation hide = new AlphaAnimation(1.0f, 0.0f);
    hide.setDuration(time);
    hide.setAnimationListener(new Animation.AnimationListener() {
        @Override//ww w  .ja  v  a2s .c om
        public void onAnimationStart(Animation animation) {
            view0.setVisibility(View.VISIBLE);
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            view0.setVisibility(View.GONE);
            view1.startAnimation(getShowAnimation(view1, time));
        }

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

From source file:com.fastbootmobile.encore.app.fragments.AlbumViewFragment.java

private void setupHeader(LayoutInflater inflater) {
    // Load the header
    View headerView = inflater.inflate(R.layout.header_listview_songs, mListView, false);
    mIvHero = (ImageView) headerView.findViewById(R.id.ivHero);
    mTvAlbumName = (TextView) headerView.findViewById(R.id.tvAlbumName);
    mTvAlbumName.setBackgroundColor(0xBBFFFFFF & mBackgroundColor);

    if (mAlbum != null) {
        mTvAlbumName.setText(mAlbum.getName());
    }/*from   w ww .  j av  a2 s  .c  o m*/

    if (!Utils.hasLollipop()) {
        // Since we don't have the transition animation, make sure everything is visible
        mTvAlbumName.setVisibility(View.VISIBLE);
        mTvAlbumName.setAlpha(0.0f);
        mTvAlbumName.animate().alpha(1.0f).setDuration(AlbumActivity.BACK_DELAY).start();
    }

    // Hide download button by default
    headerView.findViewById(R.id.cpbOffline).setVisibility(View.GONE);

    mPlayFab = (FloatingActionButton) headerView.findViewById(R.id.fabPlay);

    // Set source logo
    ImageView ivSource = (ImageView) headerView.findViewById(R.id.ivSourceLogo);
    if (mAlbum != null) {
        mLogoBitmap = PluginsLookup.getDefault().getCachedLogo(getResources(), mAlbum);
        ivSource.setImageDrawable(mLogoBitmap);
    }

    // Set the FAB animated drawable
    mFabDrawable = new PlayPauseDrawable(getResources(), 1);
    mFabDrawable.setShape(PlayPauseDrawable.SHAPE_PLAY);
    mFabDrawable.setYOffset(6);

    mPlayFab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (mFabDrawable.getCurrentShape() == PlayPauseDrawable.SHAPE_PLAY) {
                if (mFabShouldResume) {
                    PlaybackProxy.play();
                    mFabDrawable.setShape(PlayPauseDrawable.SHAPE_PAUSE);
                    mBarDrawable.setShape(PlayPauseDrawable.SHAPE_PAUSE);
                } else {
                    PlaybackProxy.playAlbum(mAlbum);
                }

                if (Utils.hasLollipop()) {
                    // No Lollipop, no cool animation!
                    showMaterialReelBar(mPlayFab);
                }
            } else {
                mFabShouldResume = true;
                PlaybackProxy.pause();
                mFabDrawable.setShape(PlayPauseDrawable.SHAPE_PLAY);
                mBarDrawable.setShape(PlayPauseDrawable.SHAPE_PLAY);
                hideMaterialReelBar(mPlayFab);
            }
        }
    });
    mHandler.post(new Runnable() {
        @Override
        public void run() {
            showFab(false, false);
        }
    });
    mPlayFab.setImageDrawable(mFabDrawable);

    if (mHeroImage != null) {
        mIvHero.setImageBitmap(mHeroImage);
    } else {
        mIvHero.setImageResource(R.drawable.album_placeholder);
    }

    // Set the header view and adapter
    mListView.addParallaxedHeaderView(headerView);
    mListView.setAdapter(mAdapter);

    AlphaAnimation anim = new AlphaAnimation(0.f, 1.f);
    anim.setDuration(200);
    mListView.setLayoutAnimation(new LayoutAnimationController(anim));

    setupMaterialReelBar(headerView, mReelFabClickListener);
}

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  ww  w  .  j ava  2  s  .co  m

    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:de.gebatzens.sia.MainActivity.java

public void toggleShareToolbar(final boolean show) {
    final Toolbar shareToolbar = (Toolbar) findViewById(R.id.share_toolbar);

    AlphaAnimation anim = new AlphaAnimation(show ? 0.f : 1.f, show ? 1.f : 0.f);
    anim.setDuration(200);

    anim.setAnimationListener(new Animation.AnimationListener() {
        @Override/*  w w w.ja v a2s.c o m*/
        public void onAnimationStart(Animation animation) {
            if (show) {
                shareToolbar.setVisibility(View.VISIBLE);
            }
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            if (!show) {
                shareToolbar.setVisibility(View.GONE);
            }
        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }
    });

    shareToolbar.startAnimation(anim);
}

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 . j av a 2s. com*/
    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.mina.breathitout.AnalyzeActivity.java

public void fadeInText() {
    AlphaAnimation fadeIn = new AlphaAnimation(0.0f, 1.0f);
    AlphaAnimation fadeOut = new AlphaAnimation(1.0f, 0.0f);
    txtView.startAnimation(fadeIn);/*  ww w  . j  a v a 2s.  c om*/
    txtView.startAnimation(fadeOut);
    fadeIn.setDuration(4000);
    fadeIn.setFillAfter(true);
    fadeOut.setDuration(4000);
    fadeOut.setFillAfter(true);
    fadeIn.setStartOffset(4200);
}

From source file:com.aero2.android.DefaultActivities.SmogMapActivity.java

public void animateExit() {
    RelativeLayout layout = (RelativeLayout) findViewById(R.id.map_layout);
    AlphaAnimation animation = new AlphaAnimation(1.0f, 0.0f);
    animation.setFillAfter(true);//w  ww  .j a v  a  2  s.  com
    animation.setDuration(1000);
    //apply the animation ( fade In ) to your LAyout
    layout.startAnimation(animation);

}

From source file:com.aero2.android.DefaultActivities.SmogMapActivity.java

public void fadeSplashScreen() {
    // Set Runnable to remove splash screen just in case
    final Handler handler = new Handler();
    handler.postDelayed(new Runnable() {
        @Override//ww  w  .  java2s .  com
        public void run() {
            removeSplashScreen();
        }
    }, 1000);

    if (!permissionJustGranted) {
        RelativeLayout layout = (RelativeLayout) findViewById(R.id.map_layout);
        AlphaAnimation animation = new AlphaAnimation(-2f, 1.0f);
        animation.setFillAfter(true);
        animation.setDuration(1500);

        //apply the animation ( fade In ) to your LAyout
        layout.startAnimation(animation);
    }

}