Android Open Source - CairoClockForAndroidWear Watch Face Activity






From Project

Back to project page CairoClockForAndroidWear.

License

The source code is released under:

GNU General Public License

If you think the Android project CairoClockForAndroidWear 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 ganachoco.wear.clockface.cairoclock;
/*from ww w.  j av  a 2 s .  com*/
import android.app.Activity;
import android.content.Context;
import android.hardware.display.DisplayManager;
import android.os.Bundle;
import android.view.Display;

public class WatchFaceActivity extends Activity implements DisplayManager.DisplayListener {
    private boolean mDim;
    private boolean mBacklightOff;
    private DisplayManager mDisplayManager;
    @Override
    public void onDisplayAdded(int displayId) {}

    @Override
    public void onDisplayRemoved(int displayId) {}

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mDisplayManager = (DisplayManager) getSystemService(Context.DISPLAY_SERVICE);
        mDisplayManager.registerDisplayListener(this, null);
    }
    @Override
    protected void onDestroy() {
        mDisplayManager.unregisterDisplayListener(this);
        super.onDestroy();
    }

    protected void onDimChanged(boolean dim) {

    }
    protected void onBacklightChanged(boolean off) {

    }

    @Override
    public void onDisplayChanged(int displayId) {
        if (displayId != Display.DEFAULT_DISPLAY)
            return;

        switch(mDisplayManager.getDisplay(displayId).getState()) {
            case Display.STATE_DOZING:
                // go to dim
                if (!mDim) {
                    mDim = true;
                    onDimChanged(mDim);
                }
                break;
            case Display.STATE_OFF:
                // go to screen off
                if (!mBacklightOff) {
                    mBacklightOff = true;
                    onBacklightChanged(mBacklightOff);
                }
                break;
            default:
                if (mDim) {
                    mDim = false;
                    onDimChanged(mDim);
                }
                if (mBacklightOff) {
                    mBacklightOff = false;
                    onBacklightChanged(mBacklightOff);
                }
                break;
        }
    }
}




Java Source Code List

ganachoco.wear.clockface.cairoclock.AntiqueActivity.java
ganachoco.wear.clockface.cairoclock.BaseLayoutActivity.java
ganachoco.wear.clockface.cairoclock.BlankActivity.java
ganachoco.wear.clockface.cairoclock.ClockFrameView.java
ganachoco.wear.clockface.cairoclock.ClockHandView.java
ganachoco.wear.clockface.cairoclock.ClockSurfaceView.java
ganachoco.wear.clockface.cairoclock.ClockView.java
ganachoco.wear.clockface.cairoclock.DefaultActivity.java
ganachoco.wear.clockface.cairoclock.FdoActivity.java
ganachoco.wear.clockface.cairoclock.FunkyActivity.java
ganachoco.wear.clockface.cairoclock.GlassyActivity.java
ganachoco.wear.clockface.cairoclock.GremlinActivity.java
ganachoco.wear.clockface.cairoclock.IpulseActivity.java
ganachoco.wear.clockface.cairoclock.RadiumActivity.java
ganachoco.wear.clockface.cairoclock.SilviaActivity.java
ganachoco.wear.clockface.cairoclock.SimpleActivity.java
ganachoco.wear.clockface.cairoclock.TangoActivity.java
ganachoco.wear.clockface.cairoclock.WatchFaceActivity.java
ganachoco.wear.clockface.cairoclock.ZenActivity.java