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:fr.shywim.antoinedaniel.utils.Utils.java

/**
 * First part of the click animation.// www  . ja v  a  2s.com
 *
 * @param context Any context.
 * @param v View who will have the effect.
 * @param isRoot Whether the passed view is the ViewGroup parent.
 */
public static void clickAnimDown(Context context, View v, boolean isRoot) {
    RelativeLayout root;
    if (isRoot)
        root = (RelativeLayout) v;
    else
        root = (RelativeLayout) v.getParent();
    final View rectView = new View(context);
    rectView.setId(R.id.rect_view_id);
    rectView.setVisibility(View.GONE);
    rectView.setBackgroundResource(R.drawable.square);
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(v.getMeasuredWidth(),
            v.getMeasuredHeight());
    params.addRule(RelativeLayout.ALIGN_TOP, v.getId());
    rectView.setLayoutParams(params);
    AlphaAnimation rectAnim = new AlphaAnimation(0f, 0.4f);
    rectAnim.setFillAfter(true);
    rectAnim.setInterpolator(new AccelerateInterpolator());
    rectAnim.setDuration(150);
    rectAnim.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
            rectView.setVisibility(View.VISIBLE);
        }

        @Override
        public void onAnimationEnd(Animation animation) {

        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }
    });
    root.addView(rectView);
    rectView.startAnimation(rectAnim);
}

From source file:fr.shywim.antoinedaniel.utils.Utils.java

/**
 * Second part of the click animation./*from w ww  . jav a2  s.co m*/
 *
 * @param v View who will have the effect.
 * @param isRoot Whether the passed view is the ViewGroup parent.
 */
public static void clickAnimUp(View v, boolean isRoot) {
    RelativeLayout root;
    if (isRoot)
        root = (RelativeLayout) v;
    else
        root = (RelativeLayout) v.getParent();
    final View rectView = root.findViewById(R.id.rect_view_id);
    if (rectView != null) {
        AlphaAnimation rectAnim = new AlphaAnimation(0.4f, 0f);
        rectAnim.setFillAfter(true);
        rectAnim.setInterpolator(new DecelerateInterpolator());
        rectAnim.setDuration(150);
        rectAnim.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {

            }

            @Override
            public void onAnimationEnd(Animation animation) {
                new Handler().post(new Runnable() {
                    @Override
                    public void run() {
                        ViewGroup parent = (ViewGroup) rectView.getParent();
                        rectView.setVisibility(View.GONE);
                        if (parent != null)
                            parent.removeView(rectView);
                    }
                });
            }

            @Override
            public void onAnimationRepeat(Animation animation) {

            }
        });
        rectView.clearAnimation();
        rectView.startAnimation(rectAnim);
    }
}

From source file:com.atinternet.tracker.Tool.java

/**
 * Helper to create alpha animation/*  w  w  w. ja  v a2  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:com.example.leebeomwoo.viewbody_final.MainActivity.java

public static void startAlphaAnimation(View v, long duration, int visibility) {
    AlphaAnimation alphaAnimation = (visibility == View.VISIBLE) ? new AlphaAnimation(0f, 1f)
            : new AlphaAnimation(1f, 0f);
    alphaAnimation.setDuration(duration);
    alphaAnimation.setFillAfter(true);//from  w  w  w.  j  a  va 2 s. co m
    v.startAnimation(alphaAnimation);
}

From source file:com.eutectoid.dosomething.picker.PickerFragment.java

private static void setAlpha(View view, float alpha) {
    // Set the alpha appropriately (setAlpha is API >= 11, this technique works on all API levels).
    AlphaAnimation alphaAnimation = new AlphaAnimation(alpha, alpha);
    alphaAnimation.setDuration(0);
    alphaAnimation.setFillAfter(true);//from   w  ww. j  a  v a  2s.c  o m
    view.startAnimation(alphaAnimation);
}

From source file:com.devbrackets.android.exomedia.ui.animation.TopViewHideShowAnimation.java

public TopViewHideShowAnimation(View view, boolean toVisible, long duration) {
    super(false);
    this.toVisible = toVisible;
    this.animationView = view;

    //Creates the Alpha animation for the transition
    float startAlpha = toVisible ? 0 : 1;
    float endAlpha = toVisible ? 1 : 0;

    AlphaAnimation alphaAnimation = new AlphaAnimation(startAlpha, endAlpha);
    alphaAnimation.setDuration(duration);

    //Creates the Translate animation for the transition
    int startY = toVisible ? -view.getHeight() : 0;
    int endY = toVisible ? 0 : -view.getHeight();
    TranslateAnimation translateAnimation = new TranslateAnimation(0, 0, startY, endY);
    translateAnimation//from w  w w  .  ja v  a2 s  . c o m
            .setInterpolator(toVisible ? new LinearOutSlowInInterpolator() : new FastOutLinearInInterpolator());
    translateAnimation.setDuration(duration);

    //Adds the animations to the set
    addAnimation(alphaAnimation);
    addAnimation(translateAnimation);

    setAnimationListener(new Listener());
}

From source file:com.devbrackets.android.exomedia.ui.animation.BottomViewHideShowAnimation.java

public BottomViewHideShowAnimation(View view, boolean toVisible, long duration) {
    super(false);
    this.toVisible = toVisible;
    this.animationView = view;

    //Creates the Alpha animation for the transition
    float startAlpha = toVisible ? 0 : 1;
    float endAlpha = toVisible ? 1 : 0;

    AlphaAnimation alphaAnimation = new AlphaAnimation(startAlpha, endAlpha);
    alphaAnimation.setDuration(duration);

    //Creates the Translate animation for the transition
    int startY = toVisible ? getHideShowDelta(view) : 0;
    int endY = toVisible ? 0 : getHideShowDelta(view);
    TranslateAnimation translateAnimation = new TranslateAnimation(0, 0, startY, endY);
    translateAnimation/*www.j a  v a 2 s .  c om*/
            .setInterpolator(toVisible ? new LinearOutSlowInInterpolator() : new FastOutLinearInInterpolator());
    translateAnimation.setDuration(duration);

    //Adds the animations to the set
    addAnimation(alphaAnimation);
    addAnimation(translateAnimation);

    setAnimationListener(new Listener());
}

From source file:townley.stuart.app.android.trekkinly.DisplayGPS.java

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.gps_layout, container, false);

    gps_data = new GPS_Data(getActivity());
    db = new DataBaseHelper(getActivity());
    db.getWritableDatabase();//from ww  w .  java2s . c  o  m
    db.getGPS(gps_data);
    db.upDateDataBaseGPS(gps_data);

    final TextView textView_lat = (TextView) rootView.findViewById(R.id.gps_latitude_data);
    final TextView textView_long = (TextView) rootView.findViewById(R.id.gps_longitude_data);

    String latitude = db.rowone;
    String longitude = db.rowtwo;

    if (latitude == null && longitude == null) {
        textView_lat.setText("No information is present");
        textView_long.setText("No information is present");
    } else {
        textView_lat.setText("" + latitude);
        textView_long.setText("" + longitude);

    }
    final ImageButton imageButton = (ImageButton) rootView.findViewById(R.id.refresh_gps);
    imageButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            AlphaAnimation animation1 = new AlphaAnimation(0.2f, 1.0f);
            animation1.setDuration(500);
            imageButton.startAnimation(animation1);

            if (gps_data.locationObtainable()) {

                db.addGPS(gps_data);
                db.getGPS(gps_data);
                db.upDateDataBaseGPS(gps_data);

                textView_lat.setText("" + db.rowone);
                textView_long.setText("" + db.rowtwo);

                Log.w("GPS DATA Latitude is", "" + gps_data.lat);
                Log.w("GPS DATA Longitude is", "" + gps_data.longi);

                gps_data.stopUsingGPS();

            }

            else {

                gps_data.SettingsAlertDialog();

            }
        }
    });

    return rootView;
}

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

private void showAvatar(boolean show, View view) {
    AlphaAnimation animation = new AlphaAnimation(show ? 0.0f : 1.0f, show ? 1.0f : 0.0f);
    animation.setDuration(2000);
    animation.setFillAfter(true);/*from   w w w  .ja v  a 2s  .c o  m*/
    view.startAnimation(animation);
}

From source file:com.poloure.simplerss.AsyncNewTagAdapters.java

@Override
protected void onPostExecute(TreeMap<Long, FeedItem>[] result) {
    ViewPager pager = (ViewPager) m_activity.findViewById(R.id.viewpager);
    PagerAdapter pagerAdapter = pager.getAdapter();
    int pageCount = pagerAdapter.getCount();

    for (int i = 0; pageCount > i; i++) {
        // Get the tag page and skip ListViews that are null.
        ListFragmentTag fragment = FragmentFeeds.getViewPagerFragment(i);
        LinkedMapAdapter<Long, FeedItem> adapterTag = fragment.getListAdapter();
        ListViewFeeds listView = fragment.getListView();

        if (null == adapterTag) {
            fragment.setListAdapter(new AdapterFeedItems(m_activity, result[i]));
            listView.setSelectionOldestUnread(m_activity.getReadItemTimes());
        } else {//from   w  w  w.  j  a  v a  2s .co m
            long topKeyBefore = 0L;
            int top = 0;

            // If there are items in the currently viewed page, save the position.
            boolean firstLoad = null == listView || 0 == listView.getCount();
            if (!firstLoad) {
                // Get the time of the top item.
                int topVisibleItem = listView.getFirstVisiblePosition();
                topKeyBefore = adapterTag.getKey(topVisibleItem);

                View v = listView.getChildAt(0);
                top = null == v ? 0 : v.getTop();
            }

            // Update the feedItems in the adapter.
            adapterTag.replaceAll(result[i]);

            // Now find the position of the item with the time timeBefore.
            if (firstLoad) {
                listView.setSelectionOldestUnread(m_activity.getReadItemTimes());
            } else {
                int newPos = adapterTag.indexOf(topKeyBefore);
                listView.setSelectionFromTop(newPos, top - listView.getPaddingTop());
            }
        }
    }

    // If the pager is invisible, use a fade in animation.
    if (View.VISIBLE != pager.getVisibility()) {
        pager.setVisibility(View.VISIBLE);
        AlphaAnimation animation = new AlphaAnimation(0.0F, 1.0F);
        animation.setDuration(300);
        pager.startAnimation(animation);
    }
}