package com.emmaguy.todayilearned.comments;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.wearable.view.DotsPageIndicator;
import android.support.wearable.view.GridViewPager;
import android.view.View;
import android.view.WindowInsets;
import android.widget.Toast;

import com.emmaguy.todayilearned.R;
import com.emmaguy.todayilearned.sharedlib.Comment;
import com.emmaguy.todayilearned.sharedlib.Constants;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import java.util.ArrayList;
import java.util.List;

public class CommentsActivity extends Activity implements ActionFragment.OnActionListener {
    private final Gson mGson = new Gson();
    private GridViewPager mGridViewPager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_comments);

        String stringComments = getIntent().getStringExtra(Constants.KEY_REDDIT_POSTS);
        final ArrayList<Comment> comments = mGson.fromJson(stringComments, new TypeToken<List<Comment>>() {}.getType());
        if (comments == null || comments.isEmpty()) {
            Toast.makeText(this, R.string.thread_has_no_comments_yet, Toast.LENGTH_SHORT).show();
            finish();
            return;
        }

        mGridViewPager = (GridViewPager) findViewById(R.id.pager);
        mGridViewPager.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
            @Override
            public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
                // A little extra horizontal spacing between pages looks a bit less crowded on a round display
                int rowMargin = getResources().getDimensionPixelOffset(R.dimen.page_row_margin);
                int colMargin = getResources().getDimensionPixelOffset(insets.isRound() ? R.dimen.page_column_margin_round : R.dimen.page_column_margin);
                mGridViewPager.setPageMargins(rowMargin, colMargin);

                // GridViewPager relies on insets to properly handle layout for round displays
                // They must be explicitly applied since this listener has taken them over
                mGridViewPager.onApplyWindowInsets(insets);
                return insets;
            }
        });
        mGridViewPager.setAdapter(new CommentsGridPagerAdapter(CommentsActivity.this, getFragmentManager(), comments));

        DotsPageIndicator dotsPageIndicator = (DotsPageIndicator) findViewById(R.id.page_indicator);
        dotsPageIndicator.setPager(mGridViewPager);
    }

    @Override
    public void onActionPerformed(String replies) {
        Intent intent = new Intent(this, CommentsActivity.class);
        intent.putExtra(Constants.KEY_REDDIT_POSTS, replies);
        startActivity(intent);
    }
}

@@ -232,16 +232,41 @@
 wPager;%0A
+import android.util.Log;%0A
 import a
@@ -968,16 +968,22 @@
         
+final 
 String s
@@ -1361,31 +1361,21 @@
     
-    return;%0A        %7D%0A%0A
+%7D else %7B%0A    
     
@@ -1437,32 +1437,36 @@
 pager);%0A        
+  
+  
 mGridViewPager.s
@@ -1532,24 +1532,28 @@
 istener() %7B%0A
+    
             
@@ -1570,24 +1570,28 @@
             
+    
 public Windo
@@ -1665,16 +1665,20 @@
         
+  
+  
 // A lit
@@ -1764,16 +1764,20 @@
 display%0A
+    
         
@@ -1877,24 +1877,28 @@
             
+    
 int colMargi
@@ -2031,32 +2031,36 @@
                 
+  
+  
 mGridViewPager.s
@@ -2093,24 +2093,28 @@
 olMargin);%0A%0A
+    
             
@@ -2212,16 +2212,20 @@
         
+    
 // They 
@@ -2299,32 +2299,36 @@
                 
+  
+  
 mGridViewPager.o
@@ -2371,16 +2371,20 @@
         
+    
 return i
@@ -2406,18 +2406,24 @@
     
-%7D%0A
+    %7D%0A  
         
 %7D);%0A
@@ -2422,12 +2422,18 @@
     
+  
 %7D);%0A
+    
     
@@ -2557,16 +2557,20 @@
         
+    
 DotsPage
@@ -2662,16 +2662,20 @@
         
+  
+  
 dotsPage
@@ -2706,24 +2706,34 @@
 ViewPager);%0A
+        %7D%0A
     %7D%0A%0A    @

Tidy up, use an else rather than a return