package org.shokai.voicetweet;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.wearable.view.DelayedConfirmationView;
import android.support.wearable.view.WatchViewStub;
import android.view.View;
import android.widget.TextView;

public class WearTweetConfirmActivity extends Activity implements DelayedConfirmationView.DelayedConfirmationListener {

    private DelayedConfirmationView mDelayedView;
    private TextView mTextView;
    private String mTweet;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_tweet_confirm);
        final WatchViewStub stub = (WatchViewStub) findViewById(R.id.watch_view_stub);
        stub.setOnLayoutInflatedListener(new WatchViewStub.OnLayoutInflatedListener() {
            @Override
            public void onLayoutInflated(WatchViewStub watchViewStub) {
                mTextView = (TextView) stub.findViewById(R.id.text);
                if(mTweet != null) {
                    mTextView.setText(mTweet);
                }
                mDelayedView = (DelayedConfirmationView) stub.findViewById(R.id.delayed_confirm);
                mDelayedView.setListener(WearTweetConfirmActivity.this);
                mDelayedView.setTotalTimeMs(6000);
                mDelayedView.start();
            }
        });

        Intent intent = getIntent();
        if(intent != null){
            mTweet = intent.getExtras().getString("tweet");
        }

    }

    @Override
    public void onTimerFinished(View view) {
        setResult(RESULT_OK);
        finish();
    }

    @Override
    public void onTimerSelected(View view) {
        setResult(RESULT_CANCELED);
        finish();
    }
}

@@ -349,16 +349,72 @@
 plements
+%0A        WatchViewStub.OnLayoutInflatedListener,%0A       
  Delayed
@@ -755,14 +755,8 @@
     
-final 
 Watc
@@ -869,85 +869,173 @@
 ner(
-new WatchViewStub.OnLayoutInflatedListener() %7B%0A            @Override%0A        
+this);%0A%0A        Intent intent = getIntent();%0A        if(intent != null)%7B%0A            mTweet = intent.getExtras().getString(%22tweet%22);%0A        %7D%0A%0A    %7D%0A%0A    @Override%0A
     
@@ -1081,18 +1081,9 @@
 tub 
-watchViewS
+s
 tub)
@@ -1089,32 +1089,24 @@
 ) %7B%0A        
-    
-    
 mTextView = 
@@ -1142,32 +1142,24 @@
 R.id.text);%0A
-        
         if(m
@@ -1187,24 +1187,16 @@
         
-        
 mTextVie
@@ -1222,34 +1222,18 @@
         
-    
-    %7D%0A        
+%7D%0A
         
@@ -1314,24 +1314,16 @@
 nfirm);%0A
-        
         
@@ -1383,32 +1383,24 @@
 s);%0A        
-     
-   
 mDelayedView
@@ -1422,24 +1422,16 @@
 (6000);%0A
-        
         
@@ -1456,171 +1456,8 @@
 ();%0A
-            %7D%0A        %7D);%0A%0A        Intent intent = getIntent();%0A        if(intent != null)%7B%0A            mTweet = intent.getExtras().getString(%22tweet%22);%0A        %7D%0A%0A
     
@@ -1692,10 +1692,11 @@
 ;%0A    %7D%0A
+%0A
 %7D%0A

refactor TweetConfirmActivity #4