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

private void animateToHidden() {
    Log.v(TAG, "animateToHidden()");

    AlphaAnimation animation = new AlphaAnimation(1.0f, 0.0f);
    animation.setStartOffset(ANIMATION_END_PAUSE_DURATION);
    animation.setDuration(ANIMATION_END_FADE_DURATION);
    animation.setFillAfter(true);// w  w w  . j ava2  s.c o  m

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

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

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

    final Button button = (Button) rootView.findViewById(R.id.Button);
    final Button button2 = (Button) rootView.findViewById(R.id.Button2);
    final Button button3 = (Button) rootView.findViewById(R.id.Button3);

    button.setOnClickListener(new View.OnClickListener() {
        @Override//from  w  w w . j  ava2s .c om
        public void onClick(View v) {
            showTimePickerDialog(v);
            AlphaAnimation animation1 = new AlphaAnimation(0.2f, 1.0f);
            animation1.setDuration(500);
            button.startAnimation(animation1);

        }
    });

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

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

    button3.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            ComponentName receiver = new ComponentName(getActivity(), AlertClass.class);
            PackageManager pm = getActivity().getPackageManager();
            pm.setComponentEnabledSetting(receiver, PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
                    PackageManager.DONT_KILL_APP);

            Intent intent = new Intent(getActivity(), AlertClass.class);
            AlarmManager alarmManager = (AlarmManager) getActivity().getSystemService(Context.ALARM_SERVICE);
            alarmManager.cancel(PendingIntent.getBroadcast(getActivity().getApplicationContext(), 1, intent,
                    PendingIntent.FLAG_UPDATE_CURRENT));
            Toast.makeText(getActivity(), "Notification reset!", Toast.LENGTH_SHORT).show();

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

            //It would not let me assign void so I
            return true;
        }
    });

    return rootView;
}

From source file:quickbeer.android.views.ProgressIndicatorBar.java

private void animateToHidden() {
    Timber.v("animateToHidden()");
    checkNotNull(progressBar);/*from ww  w  . ja  v a  2s  .c  o m*/

    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:org.akvo.caddisfly.sensor.colorimetry.strip.camera.InstructionFragment.java

@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View rootView = inflater.inflate(R.layout.fragment_instruction, container, false);
    final Button buttonStart = (Button) rootView.findViewById(R.id.button_start);
    buttonStart.setEnabled(false);//from ww  w .j  a v a 2  s  .c o m
    buttonStart.setAlpha(BUTTON_START_ALPHA);
    LinearLayout linearLayout = (LinearLayout) rootView.findViewById(R.id.layout_information);

    TextView textTitle = (TextView) rootView.findViewById(R.id.textToolbarTitle);
    if (textTitle != null) {
        textTitle.setText(R.string.instructions);
    }

    if (getArguments() != null) {

        String uuid = getArguments().getString(Constant.UUID);
        int phase = getArguments().getInt(Constant.PHASE);

        StripTest stripTest = new StripTest();
        JSONArray instructions = stripTest.getBrand(uuid).getInstructions();

        if (phase == 1) {
            showInstruction(linearLayout, getString(R.string.success_quality_checks), BOLD);
        }

        if (instructions != null) {
            try {
                for (int i = 0; i < instructions.length(); i++) {

                    JSONObject object = instructions.getJSONObject(i);
                    Object item = instructions.getJSONObject(i).get("text");

                    if ((object.has("phase") ? object.getInt("phase") : 1) == phase) {
                        JSONArray jsonArray;

                        if (item instanceof JSONArray) {
                            jsonArray = (JSONArray) item;
                        } else {
                            String text = (String) item;
                            jsonArray = new JSONArray();
                            jsonArray.put(text);
                        }

                        for (int j = 0; j < jsonArray.length(); j++) {
                            showInstruction(linearLayout, jsonArray.getString(j), Typeface.NORMAL);
                        }
                    }
                }
            } catch (JSONException e) {
                Timber.e(e);
            }
        }

    }

    buttonStart.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mListener.nextFragment();
        }
    });

    (new Handler()).postDelayed(new Runnable() {
        public void run() {
            buttonStart.setEnabled(true);
            AlphaAnimation animation = new AlphaAnimation(BUTTON_START_ALPHA, 1f);
            buttonStart.setAlpha(1f);
            animation.setDuration(ANIMATION_DURATION_MILLIS);
            buttonStart.startAnimation(animation);
        }
    }, BUTTON_ENABLE_DELAY);

    return rootView;
}

From source file:io.realm.realmtasks.list.ItemViewHolder.java

public void setHintPanelVisible(boolean visible) {
    final int visibility = hintPanel.getVisibility();
    boolean previousVisible = visibility == View.VISIBLE;
    if (previousVisible == visible) {
        return;//from  w  w w .  jav a  2s  .co m
    }
    if (visible) {
        hintPanel.setVisibility(View.VISIBLE);
        final AlphaAnimation alphaAnimation = new AlphaAnimation(0.2f, 1.0f);
        alphaAnimation.setDuration(150);
        hintPanel.setAnimation(alphaAnimation);
        final RotateAnimation rotateAnimation = new RotateAnimation(-90, 0, RotateAnimation.RELATIVE_TO_SELF,
                0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f);
        rotateAnimation.setDuration(500);
        arrow.startAnimation(rotateAnimation);
    } else {
        hintPanel.setVisibility(View.GONE);
    }
}

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 w  w.  j a v a 2  s .co m*/
    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.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.ja  va  2 s  . c o m

    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.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   ww  w .  ja  va  2  s. com*/

    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:com.kunze.androidlocaltodo.TaskActivityFragment.java

@Override
public void SwipedWhileDisabled() {
    AlphaAnimation animation = new AlphaAnimation(1.0f, 0.0f);
    animation.setDuration(50);
    animation.setRepeatCount(5);//from  ww  w .ja  va 2  s  . co  m
    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: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 ava2  s. c o m

    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;

}