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.waz.zclient.pages.main.participants.ParticipantBodyFragment.java

@Override
public Animation onCreateAnimation(int transit, boolean enter, int nextAnim) {
    final Fragment parent = getParentFragment();

    // Apply the workaround only if this is a child fragment, and the parent
    // is being removed.
    if (!enter && parent != null && parent.isRemoving()) {
        // This is a workaround for the bug where child fragments disappear when
        // the parent is removed (as all children are first removed from the parent)
        // See https://code.google.com/p/android/issues/detail?id=55228
        Animation doNothingAnim = new AlphaAnimation(1, 1);
        doNothingAnim.setDuration(ViewUtils.getNextAnimationDuration(parent));
        return doNothingAnim;
    } else {/*from   www  .j  a va  2s . co  m*/
        return super.onCreateAnimation(transit, enter, nextAnim);
    }
}

From source file:com.pentacog.mctracker.ServerListAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {

    RelativeLayout serverView = null;/*  w  ww  .  jav  a  2 s. c o m*/
    ServerViewHolder holder = null;
    Server server = serverList.get(position);
    server.id = position;
    if (convertView == null) {
        serverView = (RelativeLayout) LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item,
                parent, false);
        holder = new ServerViewHolder((int) getItemId(position), serverView);
        serverView.setTag(holder);
    } else {
        serverView = (RelativeLayout) convertView;
        holder = (ServerViewHolder) serverView.getTag();
        holder.id = (int) getItemId(position);
    }

    //set server name
    holder.serverTitle.setText(server.name);
    //set server IP
    String serverName = server.address.toString();
    if (!serverName.startsWith("/")) {
        int index = serverName.lastIndexOf('/');
        if (index != -1) {
            String tempString;
            tempString = serverName.substring(index + 1);
            serverName = serverName.substring(0, index);
            serverName += " " + tempString;
        }
    } else {
        serverName = serverName.replace("/", "");
    }
    if (server.port != 25565)
        serverName += ":" + server.port;
    holder.serverIp.setText(serverName);

    //set fav icon
    if (server.favorite) {
        holder.favStar.setVisibility(View.VISIBLE);
    } else {
        holder.favStar.setVisibility(View.INVISIBLE);
    }

    if (!server.queried) {
        AlphaAnimation a = new AlphaAnimation(1.0f, 0.2f);
        a.setRepeatCount(Animation.INFINITE);
        a.setRepeatMode(Animation.REVERSE);
        a.setDuration(300);
        holder.statusBar.setBackgroundColor(Color.BLUE);
        holder.statusBar.startAnimation(a);

        //         holder.loading.setVisibility(View.VISIBLE);
        holder.playerCount.setText("" + server.playerCount + "/" + server.maxPlayers);
        holder.serverData.setText(R.string.loading);
        holder.playerCount.setVisibility(View.INVISIBLE);
        holder.ping.setVisibility(View.INVISIBLE);
        new ServerViewUpdater(serverView, server);
    } else {
        setupServerCell(server, holder);
    }

    return serverView;
}

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

/**
 * Second part of the click animation./*w  w w.  j  a  v  a  2 s .  com*/
 *
 * @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.actionbarsherlock.sample.styledactionbar.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:
        // TODO handle clicking the app icon/logo
        return false;
    case R.id.menu_refresh:
        // switch to a progress animation
        item.setActionView(R.layout.indeterminate_progress_action);
        return true;
    case R.id.menu_both:
        // rotation animation of green fragment
        rotateLeftFrag();/* w ww.  j ava 2  s .  c  om*/
    case R.id.menu_text:
        // alpha animation of blue fragment
        if (IS_HONEYCOMB) {
            ObjectAnimatorAlpha.invoke(rightFrag.getView());
        } else {
            AlphaAnimation alpha = new AlphaAnimation(1f, 0f);
            alpha.setRepeatMode(Animation.REVERSE);
            alpha.setRepeatCount(1);
            alpha.setDuration(800);
            rightFrag.getView().startAnimation(alpha);
        }
        return true;
    case R.id.menu_logo:
        useLogo = !useLogo;
        item.setChecked(useLogo);
        getSupportActionBar().setDisplayUseLogoEnabled(useLogo);
        return true;
    case R.id.menu_up:
        showHomeUp = !showHomeUp;
        item.setChecked(showHomeUp);
        getSupportActionBar().setDisplayHomeAsUpEnabled(showHomeUp);
        return true;
    case R.id.menu_nav_tabs:
        item.setChecked(true);
        showTabsNav();
        return true;
    case R.id.menu_nav_label:
        item.setChecked(true);
        showStandardNav();
        return true;
    case R.id.menu_nav_drop_down:
        item.setChecked(true);
        showDropDownNav();
        return true;
    case R.id.menu_bak_none:
        item.setChecked(true);
        getSupportActionBar().setBackgroundDrawable(null);
        return true;
    case R.id.menu_bak_gradient:
        item.setChecked(true);
        getSupportActionBar()
                .setBackgroundDrawable(getResources().getDrawable(R.drawable.ad_action_bar_gradient_bak));
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:adventure_fragments.Hiking.java

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    final View rootView = inflater.inflate(R.layout.hiking_fragment, container, false);
    this.rootView = rootView;
    db = new DataBaseHelper(getActivity());
    list = db.getAllItemsHiking();//from  w  w w .  j  a  v a2s .  c  om

    adapt = new CustomAdapter2(getActivity(), R.layout.item_layout, list);
    listItem = (ListView) rootView.findViewById(R.id.listview_hike);
    listItem.setAdapter(adapt);
    nothingtext = (TextView) rootView.findViewById(R.id.nothing_here_hike);
    count = listItem.getCount();
    if (count > 0) {
        nothingtext.setVisibility(View.GONE);
    } else if (count == 0) {
        nothingtext.setVisibility(View.VISIBLE);
    }
    final ImageButton imageButton = (ImageButton) rootView.findViewById(R.id.add_item_hiking);
    listItem.setOnScrollListener(new AbsListView.OnScrollListener() {

        @Override
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {

        }

        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {
            // TODO Auto-generated method stub
            switch (scrollState) {
            case 2: // SCROLL_STATE_FLING
                //hide button here
                imageButton.setVisibility(View.GONE);
                break;

            case 1: // SCROLL_STATE_TOUCH_SCROLL
                //hide button here
                imageButton.setVisibility(View.GONE);
                break;

            case 0: // SCROLL_STATE_IDLE
                //show button here
                imageButton.setVisibility(View.VISIBLE);
                break;

            default:
                //show button here
                imageButton.setVisibility(View.VISIBLE);
                break;
            }
        }
    });

    imageButton.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            CountDownTimer timer = new CountDownTimer(4000, 1000) {

                @Override
                public void onTick(long millisUntilFinished) {
                    imageButton.setVisibility(View.GONE);
                }

                @Override
                public void onFinish() {
                    imageButton.setVisibility(View.VISIBLE);
                }

            };

            timer.start();

            return true;
        }
    });

    imageButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            AddItemNow();
            AlphaAnimation animation1 = new AlphaAnimation(0.2f, 1.0f);
            animation1.setDuration(500);
            imageButton.startAnimation(animation1);

        }
    });

    return rootView;

}

From source file:adventure_fragments.Running.java

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    final View rootView = inflater.inflate(R.layout.running_fragment, container, false);
    this.rootView = rootView;
    db = new DataBaseHelper(getActivity());
    list = db.getAllItemsRunning();/*w  w w  . j  av a  2  s  . c  om*/

    adapt = new CustomAdapter4(getActivity(), R.layout.item_layout, list);
    listItem = (ListView) rootView.findViewById(R.id.listview_run);
    listItem.setAdapter(adapt);
    nothingtext = (TextView) rootView.findViewById(R.id.nothing_here_running);
    count = listItem.getCount();
    if (count > 0) {
        nothingtext.setVisibility(View.GONE);
    } else if (count == 0) {
        nothingtext.setVisibility(View.VISIBLE);
    }
    final ImageButton imageButton = (ImageButton) rootView.findViewById(R.id.add_item_running);
    listItem.setOnScrollListener(new AbsListView.OnScrollListener() {

        @Override
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {

        }

        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {
            // TODO Auto-generated method stub
            switch (scrollState) {
            case 2: // SCROLL_STATE_FLING
                //hide button here
                imageButton.setVisibility(View.GONE);
                break;

            case 1: // SCROLL_STATE_TOUCH_SCROLL
                //hide button here
                imageButton.setVisibility(View.GONE);
                break;

            case 0: // SCROLL_STATE_IDLE
                //show button here
                imageButton.setVisibility(View.VISIBLE);
                break;

            default:
                //show button here
                imageButton.setVisibility(View.VISIBLE);
                break;
            }
        }
    });

    imageButton.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            CountDownTimer timer = new CountDownTimer(4000, 1000) {

                @Override
                public void onTick(long millisUntilFinished) {
                    imageButton.setVisibility(View.GONE);
                }

                @Override
                public void onFinish() {
                    imageButton.setVisibility(View.VISIBLE);
                }

            };

            timer.start();

            return true;
        }
    });

    imageButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            AddItemNow();
            AlphaAnimation animation1 = new AlphaAnimation(0.2f, 1.0f);
            animation1.setDuration(500);
            imageButton.startAnimation(animation1);

        }
    });

    return rootView;

}

From source file:adventure_fragments.Skiing.java

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    final View rootView = inflater.inflate(R.layout.skiing_fragment_layout, container, false);
    this.rootView = rootView;
    db = new DataBaseHelper(getActivity());
    list = db.getAllItemsSkiing();/* ww w  . j  av a 2  s . c  om*/

    adapt = new CustomAdapter5(getActivity(), R.layout.item_layout, list);
    listItem = (ListView) rootView.findViewById(R.id.listview_ski);
    listItem.setAdapter(adapt);
    nothingtext = (TextView) rootView.findViewById(R.id.nothing_here_ski);
    count = listItem.getCount();
    if (count > 0) {
        nothingtext.setVisibility(View.GONE);
    } else if (count == 0) {
        nothingtext.setVisibility(View.VISIBLE);
    }
    final ImageButton imageButton = (ImageButton) rootView.findViewById(R.id.add_item_skiing);
    listItem.setOnScrollListener(new AbsListView.OnScrollListener() {

        @Override
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {

        }

        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {
            // TODO Auto-generated method stub
            switch (scrollState) {
            case 2: // SCROLL_STATE_FLING
                //hide button here
                imageButton.setVisibility(View.GONE);
                break;

            case 1: // SCROLL_STATE_TOUCH_SCROLL
                //hide button here
                imageButton.setVisibility(View.GONE);
                break;

            case 0: // SCROLL_STATE_IDLE
                //show button here
                imageButton.setVisibility(View.VISIBLE);
                break;

            default:
                //show button here
                imageButton.setVisibility(View.VISIBLE);
                break;
            }
        }
    });

    imageButton.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            CountDownTimer timer = new CountDownTimer(4000, 1000) {

                @Override
                public void onTick(long millisUntilFinished) {
                    imageButton.setVisibility(View.GONE);
                }

                @Override
                public void onFinish() {
                    imageButton.setVisibility(View.VISIBLE);
                }

            };

            timer.start();

            return true;
        }
    });

    imageButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            AddItemNow();
            AlphaAnimation animation1 = new AlphaAnimation(0.2f, 1.0f);
            animation1.setDuration(500);
            imageButton.startAnimation(animation1);

        }
    });

    return rootView;

}

From source file:adventure_fragments.Kayaking.java

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    final View rootView = inflater.inflate(R.layout.kayaking_fragment, container, false);
    this.rootView = rootView;
    db = new DataBaseHelper(getActivity());
    list = db.getAllItemsKayaking();//from   w  w  w . ja  v  a 2s . c o  m

    adapt = new CustomAdapter3(getActivity(), R.layout.item_layout, list);
    listItem = (ListView) rootView.findViewById(R.id.listview_kayak);
    listItem.setAdapter(adapt);
    nothingtext = (TextView) rootView.findViewById(R.id.nothing_here_kayak);
    count = listItem.getCount();
    if (count > 0) {
        nothingtext.setVisibility(View.GONE);
    } else if (count == 0) {
        nothingtext.setVisibility(View.VISIBLE);
    }

    final ImageButton imageButton = (ImageButton) rootView.findViewById(R.id.add_item_kayaking);
    listItem.setOnScrollListener(new AbsListView.OnScrollListener() {

        @Override
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {

        }

        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {
            // TODO Auto-generated method stub
            switch (scrollState) {
            case 2: // SCROLL_STATE_FLING
                //hide button here
                imageButton.setVisibility(View.GONE);
                break;

            case 1: // SCROLL_STATE_TOUCH_SCROLL
                //hide button here
                imageButton.setVisibility(View.GONE);
                break;

            case 0: // SCROLL_STATE_IDLE
                //show button here
                imageButton.setVisibility(View.VISIBLE);
                break;

            default:
                //show button here
                imageButton.setVisibility(View.VISIBLE);
                break;
            }
        }
    });

    imageButton.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            CountDownTimer timer = new CountDownTimer(4000, 1000) {

                @Override
                public void onTick(long millisUntilFinished) {
                    imageButton.setVisibility(View.GONE);
                }

                @Override
                public void onFinish() {
                    imageButton.setVisibility(View.VISIBLE);
                }

            };

            timer.start();

            return true;
        }
    });

    imageButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            AddItemNow();
            AlphaAnimation animation1 = new AlphaAnimation(0.2f, 1.0f);
            animation1.setDuration(500);
            imageButton.startAnimation(animation1);

        }
    });

    return rootView;

}

From source file:adventure_fragments.Swimming.java

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    final View rootView = inflater.inflate(R.layout.swimming_fragment_layout, container, false);
    this.rootView = rootView;
    db = new DataBaseHelper(getActivity());
    list = db.getAllItemsSwimming();/*from  w w  w. ja va 2  s.com*/

    adapt = new CustomAdapter6(getActivity(), R.layout.item_layout, list);
    listItem = (ListView) rootView.findViewById(R.id.listview_swim);
    listItem.setAdapter(adapt);
    nothingtext = (TextView) rootView.findViewById(R.id.nothing_here_swim);
    count = listItem.getCount();
    if (count > 0) {
        nothingtext.setVisibility(View.GONE);
    } else if (count == 0) {
        nothingtext.setVisibility(View.VISIBLE);
    }
    final ImageButton imageButton = (ImageButton) rootView.findViewById(R.id.add_item_swimming);
    listItem.setOnScrollListener(new AbsListView.OnScrollListener() {

        @Override
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {

        }

        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {
            // TODO Auto-generated method stub
            switch (scrollState) {
            case 2: // SCROLL_STATE_FLING
                //hide button here
                imageButton.setVisibility(View.GONE);
                break;

            case 1: // SCROLL_STATE_TOUCH_SCROLL
                //hide button here
                imageButton.setVisibility(View.GONE);
                break;

            case 0: // SCROLL_STATE_IDLE
                //show button here
                imageButton.setVisibility(View.VISIBLE);
                break;

            default:
                //show button here
                imageButton.setVisibility(View.VISIBLE);
                break;
            }
        }
    });

    imageButton.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            CountDownTimer timer = new CountDownTimer(4000, 1000) {

                @Override
                public void onTick(long millisUntilFinished) {
                    imageButton.setVisibility(View.GONE);
                }

                @Override
                public void onFinish() {
                    imageButton.setVisibility(View.VISIBLE);
                }

            };

            timer.start();

            return true;
        }
    });

    imageButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            AddItemNow();
            AlphaAnimation animation1 = new AlphaAnimation(0.2f, 1.0f);
            animation1.setDuration(500);
            imageButton.startAnimation(animation1);

        }
    });

    return rootView;

}

From source file:adventure_fragments.Camping.java

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    final View rootView = inflater.inflate(R.layout.camping_fragment_layout, container, false);
    this.rootView = rootView;
    db = new DataBaseHelper(getActivity());
    list = db.getAllItemsCamping();//www .j a v  a2  s . c  o  m

    adapt = new CustomAdapter1(getActivity(), R.layout.item_layout, list);
    listItem = (ListView) rootView.findViewById(R.id.listview_camp);
    listItem.setAdapter(adapt);
    nothingtext = (TextView) rootView.findViewById(R.id.nothing_here_camp);
    count = listItem.getCount();
    if (count > 0) {
        nothingtext.setVisibility(View.GONE);
    } else if (count == 0) {
        nothingtext.setVisibility(View.VISIBLE);
    }

    final ImageButton imageButton = (ImageButton) rootView.findViewById(R.id.add_object_camping);
    listItem.setOnScrollListener(new AbsListView.OnScrollListener() {

        @Override
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {

        }

        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {
            // TODO Auto-generated method stub
            switch (scrollState) {
            case 2: // SCROLL_STATE_FLING
                //hide button here
                imageButton.setVisibility(View.GONE);
                break;

            case 1: // SCROLL_STATE_TOUCH_SCROLL
                //hide button here
                imageButton.setVisibility(View.GONE);
                break;

            case 0: // SCROLL_STATE_IDLE
                //show button here
                imageButton.setVisibility(View.VISIBLE);
                break;

            default:
                //show button here
                imageButton.setVisibility(View.VISIBLE);
                break;
            }
        }
    });

    imageButton.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            CountDownTimer timer = new CountDownTimer(4000, 1000) {

                @Override
                public void onTick(long millisUntilFinished) {
                    imageButton.setVisibility(View.GONE);
                }

                @Override
                public void onFinish() {
                    imageButton.setVisibility(View.VISIBLE);
                }

            };

            timer.start();

            return true;
        }
    });

    imageButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            AddItemNow();
            AlphaAnimation animation1 = new AlphaAnimation(0.2f, 1.0f);
            animation1.setDuration(500);
            imageButton.startAnimation(animation1);

        }
    });

    return rootView;

}