Example usage for android.os CountDownTimer start

List of usage examples for android.os CountDownTimer start

Introduction

In this page you can find the example usage for android.os CountDownTimer start.

Prototype

public synchronized final CountDownTimer start() 

Source Link

Document

Start the countdown.

Usage

From source file:com.hyung.jin.seo.getup.wear.G3tUpActivity.java

private void selectFragment() {
    fragment = null;//  w w  w .  ja  v a2 s . com
    // If CounterFragment is about to display, trigger timer as well
    if (status == G3tUpConstants.COUNTER_STATE) {
        fragment = new CounterFragment();
        CountDownTimer timer = new MyCountDownTimer(G3tUpConstants.SECOND * timerDuration * 60,
                G3tUpConstants.SECOND);
        timer.start();

        // ExerciseFragment
    } else if (status == G3tUpConstants.EXERCISE_STATE) {

        fragment = new ExerciseFragment();

        // DisplayFragment
    } else {

        fragment = new DisplayFragment();
    }
    FragmentManager fm = getFragmentManager();
    FragmentTransaction ftx = fm.beginTransaction();
    ftx.replace(R.id.fragment_place, fragment);
    ftx.commit();
}

From source file:nl.hnogames.domoticz.UpdateActivity.java

private void updateServer() {
    // Cancel the check prerequisites dialog
    if (progressDialog != null)
        progressDialog.cancel();//w ww.  j av  a 2 s .  c  o  m

    final boolean showMinMax = false;
    final MaterialDialog dialog = new MaterialDialog.Builder(this).title(R.string.msg_please_wait)
            .content(getString(R.string.please_wait_while_server_updated) + UsefulBits.newLine()
                    + getString(R.string.this_take_minutes))
            .cancelable(false).progress(false, SERVER_UPDATE_TIME * 60, showMinMax).show();

    CountDownTimer mCountDownTimer = new CountDownTimer(SERVER_UPDATE_TIME * 60 * 1000, 1000) {

        @Override
        public void onTick(long millisUntilFinished) {
            dialog.incrementProgress(1);
        }

        @Override
        public void onFinish() {
            dialog.cancel();
            showMessageUpdateSuccess();
            refreshData();
        }
    };

    mCountDownTimer.start();
    if (!mSharedPrefs.isDebugEnabled()
            || serverUtil.getActiveServer().getServerUpdateInfo(this).isUpdateAvailable()) {
        mDomoticz.updateDomoticzServer(null);
        // No feedback is provided when updating

        /*
            new UpdateDomoticzServerReceiver() {
        @Override
        public void onUpdateFinish(boolean updateSuccess) {
            if (!updateSuccess) showMessageUpdateFailed();
            else showMessageUpdateSuccess();
        }
                
        @Override
        public void onError(Exception error) {
            showMessageUpdateNotStarted();
        }
        });
        */
    }
}

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  ava 2 s  .co 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 www.j  a v a 2 s  .c o  m

    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.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();/*from www .j  av a2s .  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();//w  ww  . j  av  a 2 s.com

    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   www  .  j  a v a  2s  .co m

    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();/*  w w  w.ja v  a  2 s .c om*/

    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;

}

From source file:adventure_fragments.Climbing.java

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

    adapt = new CustomAdapter1(getActivity(), R.layout.item_layout, list);
    listItem = (ListView) rootView.findViewById(R.id.listview_climb);
    listItem.setAdapter(adapt);
    nothingtext = (TextView) rootView.findViewById(R.id.nothing_here_climb);
    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.climb_button);
    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.Biking.java

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

    this.rootView = rootView;
    db = new DataBaseHelper(getActivity());
    list = db.getAllItemsBiking();/*from w w w .  j  a va 2 s  .  co  m*/
    listItem = (ListView) rootView.findViewById(R.id.listview_bike);
    adapt = new CustomAdapter(getActivity(), R.layout.item_layout, list);
    listItem.setAdapter(adapt);
    nothingtext = (TextView) rootView.findViewById(R.id.nothing_here_bike);
    count = listItem.getCount();
    if (count > 0) {
        nothingtext.setVisibility(View.GONE);
    } else if (count == 0) {
        nothingtext.setVisibility(View.VISIBLE);
    }
    Log.i("Count = ", "" + count);

    final ImageButton imageButton = (ImageButton) rootView.findViewById(R.id.refresh);

    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;

}