Android Open Source - circle-timer-widget My Activity






From Project

Back to project page circle-timer-widget.

License

The source code is released under:

Copyright (c) 2014, Nikolai Doronin All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:...

If you think the Android project circle-timer-widget listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.github.lassana.circletimerwidget;
//from w  w  w.j  a  v a2  s.co  m
import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.Menu;
import android.view.MenuItem;
import com.github.lassana.circletimerwidget.widget.CircleTimerListener;
import com.github.lassana.circletimerwidget.widget.CircleTimerView;

public class MyActivity extends Activity {

    private CircleTimerView mCircleTimerWidget;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        mCircleTimerWidget = (CircleTimerView) findViewById(R.id.circle);
        mCircleTimerWidget.setCircleTimerListener(new CircleTimerListener() {
            @Override
            public void onPositionChanged(int newPosition) {
                setTitle(getResources().getStringArray(R.array.timer_names)[newPosition]);
            }
        });
        setTitle(savedInstanceState == null
                ? getResources().getStringArray(R.array.timer_names)[0]
                : savedInstanceState.getCharSequence("title"));
    }

    @Override
    protected void onSaveInstanceState(@NonNull Bundle outState) {
        outState.putCharSequence("title", getTitle());
        super.onSaveInstanceState(outState);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.main, menu);
        return super.onCreateOptionsMenu(menu);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if (item.getItemId() == R.id.action_reset) {
            mCircleTimerWidget.setIndicatorPosition(0);
            setTitle(getResources().getStringArray(R.array.timer_names)[0]);
            return true;
        } else {
            return super.onOptionsItemSelected(item);
        }
    }
}




Java Source Code List

com.github.lassana.circletimerwidget.MyActivity.java
com.github.lassana.circletimerwidget.widget.CircleTimerListener.java
com.github.lassana.circletimerwidget.widget.CircleTimerSavedState.java
com.github.lassana.circletimerwidget.widget.CircleTimerTouchHelper.java
com.github.lassana.circletimerwidget.widget.CircleTimerView.java