diff --git a/app/src/main/java/foodrev/org/foodrev/presentation/presenters/SignInPresenter.java b/app/src/main/java/foodrev/org/foodrev/presentation/presenters/SignInPresenter.java index 8ec5f33..f1e9fd5 100644 --- a/app/src/main/java/foodrev/org/foodrev/presentation/presenters/SignInPresenter.java +++ b/app/src/main/java/foodrev/org/foodrev/presentation/presenters/SignInPresenter.java @@ -14,11 +14,10 @@ public interface SignInPresenter extends BasePresenter, interface View extends BaseView { void startGoogleSignIn(GoogleApiClient googleApiClient); void displaySignInError(); + boolean hasSeenIntroSlides(); + void goToUserTypeActivity(); void goToIntroSlides(); - //TODO: remove - void showRetrievedData(String string); } - void signIn(); void onSignInResult(GoogleSignInResult result); } diff --git a/app/src/main/java/foodrev/org/foodrev/presentation/presenters/impl/SignInPresenterImpl.java b/app/src/main/java/foodrev/org/foodrev/presentation/presenters/impl/SignInPresenterImpl.java index 70054af..9d7bf8d 100644 --- a/app/src/main/java/foodrev/org/foodrev/presentation/presenters/impl/SignInPresenterImpl.java +++ b/app/src/main/java/foodrev/org/foodrev/presentation/presenters/impl/SignInPresenterImpl.java @@ -181,37 +181,20 @@ public void onComplete(@NonNull Task task) { //Log.w(TAG, "signInWithCredential", task.getException()); mView.displaySignInError(); } else { -// retrieveAppInfoWithInteractor(); - mView.goToIntroSlides(); + goToNextActivity(); } } }); } -// private void retrieveAppInfoWithInteractor() { -// FirebaseDatabaseWrapper wrapper = new FirebaseDatabaseWrapper(); -// GetFirebaseInfoInteractorImpl getFirebaseInfoInteractor = -// new GetFirebaseInfoInteractorImpl(mExecutor, -// mMainThread, -// this, -// wrapper.getInstance()); -// getFirebaseInfoInteractor.execute(); -// } - -// @Override -// public void onDataReceived(PopulateInfos populateInfos) { -// String driverOne = populateInfos.getCareInfo().getCare(0).getCareTitle(); -// -// // Stop loading and switch activities -// // Pass data to mainActivity for recyclerView propagation -// -// mView.showRetrievedData(driverOne); -// } - -// @Override -// public void onDataReceiveFailed() { -// // Display some kind of error -// } + private void goToNextActivity() { + if(mView.hasSeenIntroSlides()) { + mView.goToUserTypeActivity(); + } else { + mView.goToIntroSlides(); + } + } + @Override public void resume() { SignInInteractorImpl interactor = new SignInInteractorImpl(mExecutor, mMainThread, this); diff --git a/app/src/main/java/foodrev/org/foodrev/presentation/ui/activities/SignInActivity.java b/app/src/main/java/foodrev/org/foodrev/presentation/ui/activities/SignInActivity.java index be529f3..fb2c7cd 100644 --- a/app/src/main/java/foodrev/org/foodrev/presentation/ui/activities/SignInActivity.java +++ b/app/src/main/java/foodrev/org/foodrev/presentation/ui/activities/SignInActivity.java @@ -18,6 +18,7 @@ import android.content.Context; import android.content.Intent; +import android.content.SharedPreferences; import android.os.Bundle; import android.support.v4.app.FragmentActivity; import android.support.v7.app.AppCompatActivity; @@ -41,7 +42,8 @@ public class SignInActivity extends AppCompatActivity implements SignInPresenter.View, View.OnClickListener { - + private SharedPreferences mPreferences; + private static final String INTRO_SLIDES_PREF = "hasSeenIntroSlides"; private static final String TAG = "SignInActivity"; private static final int RC_SIGN_IN = 9001; private SignInPresenter mPresenter; @@ -54,8 +56,8 @@ protected void onCreate(Bundle savedInstanceState) { mDefaultWebClientId = getString(R.string.default_web_client_id); attachPresenter(); setupUi(); - } + public void attachPresenter() { mPresenter = (SignInPresenterImpl) getLastCustomNonConfigurationInstance(); if (mPresenter == null) { @@ -161,10 +163,25 @@ public void hideProgressDialog() { findViewById(R.id.progressBar).setVisibility(View.GONE); } + @Override + public boolean hasSeenIntroSlides() { + mPreferences = getPreferences(MODE_PRIVATE); + return mPreferences.getBoolean(INTRO_SLIDES_PREF, false); + } + + @Override + public void goToUserTypeActivity() { + startActivity(new Intent(this, UserTypeActivity.class)); + finish(); + } + @Override public void goToIntroSlides() { + // Set hasSeenIntroSlides to true and go to slides + SharedPreferences.Editor editor = mPreferences.edit(); + editor.putBoolean(INTRO_SLIDES_PREF, true); + editor.commit(); startActivity(new Intent(this, IntroSlidesGeneric.class)); - //TODO create shared preferences for skipping intros if seen finish(); }