android.support.wearable.view.WatchViewStub Java Examples

The following examples show how to use android.support.wearable.view.WatchViewStub. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TrackActivity.java    From android-samples with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_track);

    //Set this to allow activity to enable the ambient mode
    setAmbientEnabled();

    //Get the watch view stub
    mWatchViewStub = (WatchViewStub) findViewById(R.id.watch_view_stub);
    mWatchViewStub.setOnLayoutInflatedListener(new WatchViewStub.OnLayoutInflatedListener() {
        @Override
        public void onLayoutInflated(WatchViewStub watchViewStub) {
            init(watchViewStub);
        }
    });

    //Connect Google api client to communicate with phone
    connectGoogleApiClient();
}
 
Example #2
Source File: TrackActivity.java    From android-samples with Apache License 2.0 5 votes vote down vote up
/**
 * Initialize the UI.
 */
private void init(WatchViewStub watchViewStub) {
    mHeaderIv = (ImageView) watchViewStub.findViewById(R.id.header_icon);
    mHeaderIv.setColorFilter(ContextCompat.getColor(this, R.color.icon_red));

    mStepCountTv = (TextView) watchViewStub.findViewById(R.id.step_count_tv);
}
 
Example #3
Source File: BasePomodoroActivity.java    From WearPomodoro with GNU General Public License v2.0 5 votes vote down vote up
@DebugLog
public void setContentViews(int rectLayoutResId, int roundLayoutResId) {
    WatchViewStub watchViewStub = new WatchViewStub(this);
    watchViewStub.setLayoutParams(new WatchViewStub.LayoutParams(WatchViewStub.LayoutParams.MATCH_PARENT, WatchViewStub.LayoutParams.MATCH_PARENT));
    watchViewStub.setRectLayout(rectLayoutResId);
    watchViewStub.setRoundLayout(roundLayoutResId);
    watchViewStub.setOnLayoutInflatedListener(this);
    setContentView(watchViewStub);
}
 
Example #4
Source File: WatchMainActivity.java    From android-wear-gopro-remote with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mGoogleApiClient = new GoogleApiClient.Builder(this)
            .addApi(Wearable.API)
            .addConnectionCallbacks(this)
            .build();

    mGoogleApiClient.connect();
    setContentView(R.layout.activity_main);
    mWatchViewStub = (WatchViewStub) findViewById(R.id.watch_view_stub);
    mWatchViewStub.setOnLayoutInflatedListener(new WatchViewStub.OnLayoutInflatedListener() {
        @Override
        public void onLayoutInflated(WatchViewStub stub) {
            mBtnCameraMode = (ImageButton)findViewById(R.id.btnCameraMode);
            mBtnReconnect = (ImageButton)findViewById(R.id.btnReconnect);
            mBtnVideoMode = (Button)findViewById(R.id.btnVideoMode);
            mTxtBatteryLevel = (TextView)findViewById(R.id.txtBatteryLevel);
            mImgBatteryLevel = (ImageView)findViewById(R.id.imgBatteryLevel);
            mBtnShutter = (Button)findViewById(R.id.btnShutter);
            mTxtStatus = (TextView)findViewById(R.id.txtStatus);
            mLayoutControls = (RelativeLayout)findViewById(R.id.layoutControls);
            mLayoutStatus = (FrameLayout)findViewById(R.id.layoutStatus);
            mLoadingPanel = (RelativeLayout)findViewById(R.id.loadingPanel);
            mProgressBarConnecting = (ProgressBar)findViewById(R.id.progressBarConnecting);
        }
    });

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    mSettings = new WearSettings();
    mSettings.loadFromPreferences(this, PreferenceManager.getDefaultSharedPreferences(this));

    mThumbsCacheDirectory = ThumbCache.getThumbCacheFolderFile(this);
    PreferenceManager.getDefaultSharedPreferences(this).registerOnSharedPreferenceChangeListener(this);
    WatchDataLayerListenerService.disable(getApplicationContext());
}
 
Example #5
Source File: BasePomodoroActivity.java    From WearPomodoro with GNU General Public License v2.0 4 votes vote down vote up
@DebugLog
@Override
public void onLayoutInflated(WatchViewStub stub) {
    ButterKnife.inject(this, stub.getRootView());
}
 
Example #6
Source File: PomodoroTransitionActivity.java    From WearPomodoro with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onLayoutInflated(WatchViewStub stub) {
    super.onLayoutInflated(stub);
    PomodoroAlarmReceiver.completeWakefulIntent(getIntent());
    pomodoroMaster.cancelNotification();
    vibrator.vibrate(1000);

    awesomeGif = (GifImageView) stub.findViewById(R.id.transition_awesome_gif);
    awesomeGif.setBytes(PomodoroUtils.readRawResourceBytes(getResources(), R.raw.pomodoro));
    awesomeGif.startAnimation();

    if (nextActivityType.isBreak()) {
        float dp = PomodoroUtils.dipToPixels(this, 1);
        ObjectAnimator anim = ObjectAnimator.ofFloat(awesomeGif, View.TRANSLATION_X, -8*dp, 8*dp);
        anim.setDuration(1200);
        anim.setRepeatMode(ObjectAnimator.REVERSE);
        anim.setRepeatCount(ObjectAnimator.INFINITE);
        anim.setInterpolator(new AccelerateDecelerateInterpolator());
        anim.start();
    }

    final TextView messageText = (TextView) stub.findViewById(R.id.transition_text);
    final int eatenPomodoros = pomodoroMaster.getEatenPomodoros();

    if (nextActivityType.isBreak()) {
        int templateId = nextActivityType == ActivityType.LONG_BREAK ?
                R.string.transition_text_before_long_break_message_template :
                R.string.transition_text_before_short_break_message_template;
        messageText.setText(String.format(
                getString(templateId),
                eatenPomodoros + 1));
        activateStepsCounter();
    } else if (nextActivityType.isPomodoro()) {
        messageText.setText(String.format(
                getString(R.string.transition_text_before_pomodoro_message_template),
                eatenPomodoros + 1));
        uiTimer.schedule(new UITimer.Task() {
            @Override
            public void run() {
                cancelTask();
                finish();
                pomodoroMaster.start(ActivityType.POMODORO);
            }
        }, 3000, "PomodoroTransitionActivity.DelayTimer");
    }
}