diff --git a/app/AndroidManifest.xml b/app/AndroidManifest.xml index 5ffa40f..00242b4 100644 --- a/app/AndroidManifest.xml +++ b/app/AndroidManifest.xml @@ -23,7 +23,7 @@ android:debuggable="true"> @@ -34,7 +34,7 @@ - diff --git a/app/src/main/java/com/donnfelker/android/bootstrap/BootstrapModule.java b/app/src/main/java/com/donnfelker/android/bootstrap/BootstrapModule.java index 196abed..a97a023 100644 --- a/app/src/main/java/com/donnfelker/android/bootstrap/BootstrapModule.java +++ b/app/src/main/java/com/donnfelker/android/bootstrap/BootstrapModule.java @@ -23,7 +23,7 @@ injects = { BootstrapApplication.class, BootstrapAuthenticatorActivity.class, - CarouselActivity.class, + CarouselActivity_.class, BootstrapTimerActivity.class, CheckInsListFragment.class, NewsActivity_.class, diff --git a/app/src/main/java/com/donnfelker/android/bootstrap/ui/BootstrapActivity.java b/app/src/main/java/com/donnfelker/android/bootstrap/ui/BootstrapActivity.java index c542042..479b401 100644 --- a/app/src/main/java/com/donnfelker/android/bootstrap/ui/BootstrapActivity.java +++ b/app/src/main/java/com/donnfelker/android/bootstrap/ui/BootstrapActivity.java @@ -5,6 +5,8 @@ import com.actionbarsherlock.app.SherlockActivity; import com.actionbarsherlock.view.MenuItem; import com.donnfelker.android.bootstrap.BootstrapApplication; +import com.googlecode.androidannotations.annotations.EActivity; +import com.googlecode.androidannotations.annotations.OptionsItem; import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TOP; import static android.content.Intent.FLAG_ACTIVITY_SINGLE_TOP; @@ -12,6 +14,7 @@ /** * Base activity for a Bootstrap activity which does not use fragments. */ +@EActivity public abstract class BootstrapActivity extends SherlockActivity { @Override @@ -21,17 +24,15 @@ protected void onCreate(Bundle savedInstanceState) { BootstrapApplication.getInstance().inject(this); } - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: // This is the home button in the top left corner of the screen. - // Dont call finish! Because activity could have been started by an outside activity and the home button would not operated as expected! - Intent homeIntent = new Intent(this, CarouselActivity.class); - homeIntent.addFlags(FLAG_ACTIVITY_CLEAR_TOP | FLAG_ACTIVITY_SINGLE_TOP); - startActivity(homeIntent); - return true; - default: - return super.onOptionsItemSelected(item); - } + /** + * This is the home button in the top left corner of the screen. + * Dont call finish! Because activity could have been started by an outside activity and the home button would not operated as expected! + * */ + @OptionsItem + boolean homeSelected() { + Intent homeIntent = new Intent(this, CarouselActivity_.class); + homeIntent.addFlags(FLAG_ACTIVITY_CLEAR_TOP | FLAG_ACTIVITY_SINGLE_TOP); + startActivity(homeIntent); + return true; } } diff --git a/app/src/main/java/com/donnfelker/android/bootstrap/ui/BootstrapPagerAdapter.java b/app/src/main/java/com/donnfelker/android/bootstrap/ui/BootstrapPagerAdapter.java index f896477..84895db 100644 --- a/app/src/main/java/com/donnfelker/android/bootstrap/ui/BootstrapPagerAdapter.java +++ b/app/src/main/java/com/donnfelker/android/bootstrap/ui/BootstrapPagerAdapter.java @@ -18,7 +18,7 @@ public class BootstrapPagerAdapter extends FragmentPagerAdapter { private final Resources resources; /** - * Create pager adapter + * Create vp_pages adapter * * @param resources * @param fragmentManager diff --git a/app/src/main/java/com/donnfelker/android/bootstrap/ui/BootstrapTimerActivity.java b/app/src/main/java/com/donnfelker/android/bootstrap/ui/BootstrapTimerActivity.java index 567c7b5..5d2ec63 100644 --- a/app/src/main/java/com/donnfelker/android/bootstrap/ui/BootstrapTimerActivity.java +++ b/app/src/main/java/com/donnfelker/android/bootstrap/ui/BootstrapTimerActivity.java @@ -17,12 +17,15 @@ import com.donnfelker.android.bootstrap.core.TimerService; import com.donnfelker.android.bootstrap.core.TimerTickEvent; import javax.inject.Inject; + +import com.googlecode.androidannotations.annotations.EActivity; import com.squareup.otto.Bus; import com.squareup.otto.Subscribe; import butterknife.InjectView; import butterknife.Views; +@EActivity(R.layout.bootstrap_timer) public class BootstrapTimerActivity extends BootstrapFragmentActivity implements View.OnClickListener { @Inject Bus BUS; @@ -37,8 +40,6 @@ public class BootstrapTimerActivity extends BootstrapFragmentActivity implements protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(R.layout.bootstrap_timer); - setTitle(R.string.timer); start.setOnClickListener(this); diff --git a/app/src/main/java/com/donnfelker/android/bootstrap/ui/CarouselActivity.java b/app/src/main/java/com/donnfelker/android/bootstrap/ui/CarouselActivity.java index 6cf6021..6c9f05e 100644 --- a/app/src/main/java/com/donnfelker/android/bootstrap/ui/CarouselActivity.java +++ b/app/src/main/java/com/donnfelker/android/bootstrap/ui/CarouselActivity.java @@ -2,31 +2,29 @@ package com.donnfelker.android.bootstrap.ui; -import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TOP; -import static android.content.Intent.FLAG_ACTIVITY_SINGLE_TOP; import android.content.Intent; import android.os.Bundle; import android.support.v4.view.ViewPager; -import com.actionbarsherlock.view.Menu; import com.actionbarsherlock.view.MenuItem; import com.actionbarsherlock.view.Window; -import com.donnfelker.android.bootstrap.BootstrapApplication; import com.donnfelker.android.bootstrap.R; import com.donnfelker.android.bootstrap.R.id; +import com.googlecode.androidannotations.annotations.AfterViews; +import com.googlecode.androidannotations.annotations.EActivity; +import com.googlecode.androidannotations.annotations.OptionsItem; +import com.googlecode.androidannotations.annotations.ViewById; import com.viewpagerindicator.TitlePageIndicator; -import butterknife.InjectView; -import butterknife.Views; - /** - * Activity to view the carousel and view pager indicator with fragments. + * Activity to view the carousel and view vp_pages tpi_header with fragments. */ +@EActivity(R.layout.carousel_view) public class CarouselActivity extends BootstrapFragmentActivity { - @InjectView(id.tpi_header) TitlePageIndicator indicator; - @InjectView(id.vp_pages) ViewPager pager; + @ViewById TitlePageIndicator tpi_header; + @ViewById ViewPager vp_pages; @Override protected void onCreate(Bundle savedInstanceState) { @@ -34,23 +32,20 @@ protected void onCreate(Bundle savedInstanceState) { requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); super.onCreate(savedInstanceState); - setContentView(R.layout.carousel_view); + } - pager.setAdapter(new BootstrapPagerAdapter(getResources(), getSupportFragmentManager())); + @AfterViews + protected void configureAdapter(){ + vp_pages.setAdapter(new BootstrapPagerAdapter(getResources(), getSupportFragmentManager())); - indicator.setViewPager(pager); - pager.setCurrentItem(1); + tpi_header.setViewPager(vp_pages); + vp_pages.setCurrentItem(1); } - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch(item.getItemId()) { - case id.timer: - final Intent i = new Intent(this, BootstrapTimerActivity.class); - startActivity(i); - return true; - default: - return super.onOptionsItemSelected(item); - } + @OptionsItem + boolean timerSelected() { + final Intent i = new Intent(this, BootstrapTimerActivity.class); + startActivity(i); + return true; } }