Android Open Source - CairoClockForAndroidWear Base Layout 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;
/* www  .  j a  va  2 s  .co  m*/
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;

import android.support.wearable.view.WatchViewStub;

public abstract class BaseLayoutActivity extends WatchFaceActivity {
    private ClockFrameView mClockView;
    private static final String TAG = "CairoClock";

    protected abstract int[] getFrameResources();
    private ImageView[] mViews = new ImageView[6];

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        Log.d(TAG, "Activity.onCreate()");
        super.onCreate(savedInstanceState);
        setContentView(R.layout.base_layout);
        final WatchViewStub stub = (WatchViewStub) findViewById(R.id.watch_view_stub);
        stub.setOnLayoutInflatedListener(new WatchViewStub.OnLayoutInflatedListener() {
            @Override
            public void onLayoutInflated(WatchViewStub stub) {
                Log.d(TAG, "onLayoutInflated called");
                int rids[] = getFrameResources();
                int[] wids = {
                        R.id.drop_shadow,
                        R.id.face,
                        R.id.marks,
                        R.id.face_shadow,
                        R.id.glass,
                        R.id.frame
                };
                for (int i = 0; i <= ClockView.ID_FRAME; i++) {
                    mViews[i] = (ImageView) stub.findViewById(wids[i]);
                    mViews[i].setImageResource(rids[i]);
                }
                mClockView = (ClockFrameView) stub.findViewById(R.id.clock_frame);
                mClockView.setResources(rids);
                Intent intent = getIntent();
                int time = intent.getIntExtra("time", -1);
                if (time != -1) {
                    int hour = time / 10000;
                    int min = (time /100 ) % 100;
                    int sec = time % 100;
                    long ts = ((hour * 60 + min) * 60 + sec ) * 1000;
                    mClockView.setFakeTime(ts);
                }
            }
        });
    }

    @Override
    protected void onPause() {
        Log.d(TAG, "Activity.onPause()");
        super.onPause();
    }

    @Override
    protected void onResume() {
        Log.d(TAG, "Activity.onResume()");
        super.onResume();
    }

    @Override
    protected void onDestroy() {
        Log.d(TAG, "Activity.onDestroy()");
        mClockView.onDestroy();
        super.onDestroy();
    }

    @Override
    protected void onDimChanged(boolean dim) {
        mClockView.setDim(dim);
    }

    @Override
    protected void onBacklightChanged(boolean off) {

    }
}




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