Permalink
Browse files

Updating code to fix a few bugs

  • Loading branch information...
1 parent 8afcaee commit 0ec57443f66b604b89ca536bc6d6f5cfe64b15f4 @donnfelker donnfelker committed Jul 11, 2013
@@ -2,8 +2,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.donnfelker.android.bootstrap"
- android:versionCode="100"
- android:versionName="1.0" >
+ android:versionCode="102"
+ android:versionName="1.1" >
<uses-sdk
android:minSdkVersion="8"
@@ -190,6 +190,7 @@
<debug>false</debug>
</sign>
<zipalign>
+ <skip>false</skip>
<verbose>true</verbose>
<outputApk>${project.build.directory}/${project.artifactId}-${project.version}-signed-aligned.apk</outputApk>
</zipalign>
@@ -2,16 +2,22 @@
package com.donnfelker.android.bootstrap.ui;
+import android.accounts.OperationCanceledException;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.view.View;
import com.actionbarsherlock.view.MenuItem;
import com.actionbarsherlock.view.Window;
+import com.donnfelker.android.bootstrap.BootstrapServiceProvider;
import com.donnfelker.android.bootstrap.R;
+import com.donnfelker.android.bootstrap.core.BootstrapService;
+import com.donnfelker.android.bootstrap.util.SafeAsyncTask;
import com.viewpagerindicator.TitlePageIndicator;
+import javax.inject.Inject;
+
import butterknife.InjectView;
import butterknife.Views;
import net.simonvt.menudrawer.MenuDrawer;
@@ -25,8 +31,12 @@
@InjectView(R.id.tpi_header) TitlePageIndicator indicator;
@InjectView(R.id.vp_pages) ViewPager pager;
+ @Inject BootstrapServiceProvider serviceProvider;
+
private MenuDrawer menuDrawer;
+ private boolean userHasAuthenticated = false;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -43,14 +53,52 @@ protected void onCreate(Bundle savedInstanceState) {
Views.inject(this);
- pager.setAdapter(new BootstrapPagerAdapter(getResources(), getSupportFragmentManager()));
+ checkAuth();
+
+ }
+
+ private void initScreen() {
+ if(userHasAuthenticated) {
+ pager.setAdapter(new BootstrapPagerAdapter(getResources(), getSupportFragmentManager()));
- indicator.setViewPager(pager);
- pager.setCurrentItem(1);
+ indicator.setViewPager(pager);
+ pager.setCurrentItem(1);
+
+ }
setNavListeners();
}
+ private void checkAuth() {
+ new SafeAsyncTask<Boolean>() {
+
+ @Override
+ public Boolean call() throws Exception {
+ final BootstrapService svc = serviceProvider.getService(CarouselActivity.this);
+ return svc != null;
+
+ }
+
+ @Override
+ protected void onException(Exception e) throws RuntimeException {
+ super.onException(e);
+ if(e instanceof OperationCanceledException) {
+ // User cancelled the authentication process (back button, etc).
+ // Since auth could not take place, lets finish this activity.
+ finish();
+ }
+ }
+
+ @Override
+ protected void onSuccess(Boolean hasAuthenticated) throws Exception {
+ super.onSuccess(hasAuthenticated);
+ userHasAuthenticated = true;
+ initScreen();
+ }
+ }.execute();
+ }
+
+
private void setNavListeners() {
menuDrawer.findViewById(R.id.home).setOnClickListener(new View.OnClickListener() {

0 comments on commit 0ec5744

Please sign in to comment.