Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Updating code to fix a few bugs

  • Loading branch information...
commit 0ec57443f66b604b89ca536bc6d6f5cfe64b15f4 1 parent 8afcaee
Donn Felker authored July 10, 2013
4  android-bootstrap/app/AndroidManifest.xml
@@ -2,8 +2,8 @@
2 2
 
3 3
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
4 4
     package="com.donnfelker.android.bootstrap"
5  
-    android:versionCode="100"
6  
-    android:versionName="1.0" >
  5
+    android:versionCode="102"
  6
+    android:versionName="1.1" >
7 7
 
8 8
     <uses-sdk
9 9
         android:minSdkVersion="8"
1  android-bootstrap/app/pom.xml
@@ -190,6 +190,7 @@
190 190
                                 <debug>false</debug>
191 191
                             </sign>
192 192
                             <zipalign>
  193
+                                <skip>false</skip>
193 194
                                 <verbose>true</verbose>
194 195
                                 <outputApk>${project.build.directory}/${project.artifactId}-${project.version}-signed-aligned.apk</outputApk>
195 196
                             </zipalign>
54  android-bootstrap/app/src/main/java/com/donnfelker/android/bootstrap/ui/CarouselActivity.java
@@ -2,6 +2,7 @@
2 2
 
3 3
 package com.donnfelker.android.bootstrap.ui;
4 4
 
  5
+import android.accounts.OperationCanceledException;
5 6
 import android.content.Intent;
6 7
 import android.os.Bundle;
7 8
 import android.support.v4.view.ViewPager;
@@ -9,9 +10,14 @@
9 10
 
10 11
 import com.actionbarsherlock.view.MenuItem;
11 12
 import com.actionbarsherlock.view.Window;
  13
+import com.donnfelker.android.bootstrap.BootstrapServiceProvider;
12 14
 import com.donnfelker.android.bootstrap.R;
  15
+import com.donnfelker.android.bootstrap.core.BootstrapService;
  16
+import com.donnfelker.android.bootstrap.util.SafeAsyncTask;
13 17
 import com.viewpagerindicator.TitlePageIndicator;
14 18
 
  19
+import javax.inject.Inject;
  20
+
15 21
 import butterknife.InjectView;
16 22
 import butterknife.Views;
17 23
 import net.simonvt.menudrawer.MenuDrawer;
@@ -25,8 +31,12 @@
25 31
     @InjectView(R.id.tpi_header) TitlePageIndicator indicator;
26 32
     @InjectView(R.id.vp_pages) ViewPager pager;
27 33
 
  34
+    @Inject BootstrapServiceProvider serviceProvider;
  35
+
28 36
     private MenuDrawer menuDrawer;
29 37
 
  38
+    private boolean userHasAuthenticated = false;
  39
+
30 40
     @Override
31 41
     protected void onCreate(Bundle savedInstanceState) {
32 42
 
@@ -43,14 +53,52 @@ protected void onCreate(Bundle savedInstanceState) {
43 53
 
44 54
         Views.inject(this);
45 55
 
46  
-        pager.setAdapter(new BootstrapPagerAdapter(getResources(), getSupportFragmentManager()));
  56
+        checkAuth();
  57
+
  58
+    }
  59
+
  60
+    private void initScreen() {
  61
+        if(userHasAuthenticated) {
  62
+            pager.setAdapter(new BootstrapPagerAdapter(getResources(), getSupportFragmentManager()));
47 63
 
48  
-        indicator.setViewPager(pager);
49  
-        pager.setCurrentItem(1);
  64
+            indicator.setViewPager(pager);
  65
+            pager.setCurrentItem(1);
  66
+
  67
+        }
50 68
 
51 69
         setNavListeners();
52 70
     }
53 71
 
  72
+    private void checkAuth() {
  73
+        new SafeAsyncTask<Boolean>() {
  74
+
  75
+            @Override
  76
+            public Boolean call() throws Exception {
  77
+                    final BootstrapService svc = serviceProvider.getService(CarouselActivity.this);
  78
+                    return svc != null;
  79
+
  80
+            }
  81
+
  82
+            @Override
  83
+            protected void onException(Exception e) throws RuntimeException {
  84
+                super.onException(e);
  85
+                if(e instanceof OperationCanceledException) {
  86
+                    // User cancelled the authentication process (back button, etc).
  87
+                    // Since auth could not take place, lets finish this activity.
  88
+                    finish();
  89
+                }
  90
+            }
  91
+
  92
+            @Override
  93
+            protected void onSuccess(Boolean hasAuthenticated) throws Exception {
  94
+                super.onSuccess(hasAuthenticated);
  95
+                userHasAuthenticated = true;
  96
+                initScreen();
  97
+            }
  98
+        }.execute();
  99
+    }
  100
+
  101
+
54 102
     private void setNavListeners() {
55 103
 
56 104
         menuDrawer.findViewById(R.id.home).setOnClickListener(new View.OnClickListener() {

0 notes on commit 0ec5744

Please sign in to comment.
Something went wrong with that request. Please try again.