Skip to content

Commit

Permalink
Added user type selection activity and presenter
Browse files Browse the repository at this point in the history
  • Loading branch information
darver committed Jun 27, 2017
1 parent 292d515 commit 0aa64fc
Show file tree
Hide file tree
Showing 10 changed files with 169 additions and 48 deletions.

This file was deleted.

Expand Up @@ -14,7 +14,7 @@ public interface SignInPresenter extends BasePresenter<SignInPresenter.View>,
interface View extends BaseView {
void startGoogleSignIn(GoogleApiClient googleApiClient);
void displaySignInError();
void goToMainActivity();
void goToIntroSlides();
//TODO: remove
void showRetrievedData(String string);
}
Expand Down
@@ -0,0 +1,17 @@
package foodrev.org.foodrev.presentation.presenters;

import foodrev.org.foodrev.presentation.presenters.base.BasePresenter;
import foodrev.org.foodrev.presentation.ui.BaseView;

/**
* Created by darver on 5/15/17.
*/

public interface UserTypePresenter extends BasePresenter<UserTypePresenter.View> {
interface View extends BaseView {
void goToCoordinatorMode();
void goToDriverMode();
}
void coordinatorSelected();
void driverSelected();
}
Expand Up @@ -182,7 +182,7 @@ public void onComplete(@NonNull Task<AuthResult> task) {
mView.displaySignInError();
} else {
// retrieveAppInfoWithInteractor();
mView.goToMainActivity();
mView.goToIntroSlides();
}
}
});
Expand Down
@@ -0,0 +1,61 @@
package foodrev.org.foodrev.presentation.presenters.impl;

import foodrev.org.foodrev.presentation.presenters.UserTypePresenter;

/**
* Created by darver on 5/15/17.
*/

public class UserTypePresenterImpl implements UserTypePresenter {
private UserTypePresenter.View mView;

@Override
public void attachView(View view) {
mView = view;
}

@Override
public void coordinatorSelected() {
// Do some checking to see if the authenticated user is able to be coordinator

mView.goToCoordinatorMode();
}

@Override
public void driverSelected() {
// Look for driver associated with auth hash

mView.goToDriverMode();
}

@Override
public void detachView() {
mView = null;
}

@Override
public void resume() {

}

@Override
public void pause() {

}

@Override
public void stop() {

}

@Override
public void destroy() {

}

@Override
public void onError(String message) {

}

}
Expand Up @@ -162,10 +162,9 @@ public void hideProgressDialog() {
}

@Override
public void goToMainActivity() {
public void goToIntroSlides() {
startActivity(new Intent(this, IntroSlidesGeneric.class));
//TODO create shared preferences for skipping intros if seen
//startActivity(new Intent(this, MessageMainActivity.class));
finish();
}

Expand Down
@@ -1,15 +1,76 @@
package foodrev.org.foodrev.presentation.ui.activities;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;

import foodrev.org.foodrev.R;
import foodrev.org.foodrev.presentation.presenters.UserTypePresenter;
import foodrev.org.foodrev.presentation.presenters.impl.UserTypePresenterImpl;
import foodrev.org.foodrev.presentation.ui.activities.rapidprototype.DriverMode.DriverModeActivity;

public class UserTypeActivity extends AppCompatActivity {
public class UserTypeActivity extends AppCompatActivity implements UserTypePresenter.View, View.OnClickListener {
private UserTypePresenter mPresenter;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_user_type);
attachPresenter();
attachButtons();
}

public void attachPresenter() {
mPresenter = (UserTypePresenter) getLastCustomNonConfigurationInstance();
if (mPresenter == null) {
mPresenter = new UserTypePresenterImpl();
}
mPresenter.attachView(this);
}



private void attachButtons() {
findViewById(R.id.select_type_coordinator_button).setOnClickListener(this);
findViewById(R.id.select_type_driver_button).setOnClickListener(this);

}

@Override
public void onClick(View view) {
int buttonId = view.getId();
if (buttonId == R.id.select_type_coordinator_button) {
mPresenter.coordinatorSelected();
} else if (buttonId == R.id.select_type_driver_button) {
mPresenter.driverSelected();
}
}

@Override
public void goToCoordinatorMode() {
startActivity(new Intent(this, MainActivity.class));
// finish();
}

@Override
public void goToDriverMode() {
startActivity(new Intent(this, DriverModeActivity.class));
// finish();
}

@Override
public void showProgressDialog() {

}

@Override
public void hideProgressDialog() {

}

@Override
public void showError(String message) {

}
}
Expand Up @@ -8,6 +8,7 @@
import agency.tango.materialintroscreen.SlideFragmentBuilder;
import foodrev.org.foodrev.R;
import foodrev.org.foodrev.presentation.ui.activities.MainActivity;
import foodrev.org.foodrev.presentation.ui.activities.UserTypeActivity;

public class IntroSlidesGeneric extends MaterialIntroActivity {

Expand Down Expand Up @@ -45,7 +46,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
//override the finish method in order to determine where the user goes after intro slides
@Override
public void finish() {
Intent i = new Intent(IntroSlidesGeneric.this, MainActivity.class);
Intent i = new Intent(IntroSlidesGeneric.this, UserTypeActivity.class);
startActivity(i);
super.finish();
}
Expand Down
33 changes: 23 additions & 10 deletions app/src/main/res/layout/activity_user_type.xml
Expand Up @@ -10,27 +10,40 @@
android:id="@+id/textView2"
android:layout_width="292dp"
android:layout_height="32dp"
android:text="TextView"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:text="@string/user_type"
android:textAlignment="center"
android:textSize="22sp"
tools:layout_editor_absoluteX="59dp"
tools:layout_editor_absoluteY="186dp"
tools:text="@string/user_type" />
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
tools:text="@string/user_type"
app:layout_constraintHorizontal_bias="0.495"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="166dp" />

<Button
android:id="@+id/coordinatorButton"
android:id="@+id/select_type_coordinator_button"
android:layout_width="173dp"
android:layout_height="51dp"
android:text="Coordinator"
tools:layout_editor_absoluteX="119dp"
tools:layout_editor_absoluteY="304dp" />
android:layout_marginTop="22dp"
app:layout_constraintTop_toBottomOf="@+id/select_type_driver_button"
android:layout_marginRight="8dp"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginLeft="8dp"
app:layout_constraintLeft_toLeftOf="parent" />

<Button
android:id="@+id/DriverButton"
android:id="@+id/select_type_driver_button"
android:layout_width="173dp"
android:layout_height="51dp"
android:text="Driver"
tools:layout_editor_absoluteX="119dp"
tools:layout_editor_absoluteY="382dp" />
android:layout_marginTop="75dp"
app:layout_constraintTop_toBottomOf="@+id/textView2"
android:layout_marginRight="8dp"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginLeft="8dp"
app:layout_constraintLeft_toLeftOf="parent" />

</android.support.constraint.ConstraintLayout>
2 changes: 1 addition & 1 deletion build.gradle
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
classpath 'com.android.tools.build:gradle:2.3.2'
classpath 'com.google.gms:google-services:3.0.0'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'

Expand Down

0 comments on commit 0aa64fc

Please sign in to comment.