Skip to content
This repository has been archived by the owner on Jan 23, 2021. It is now read-only.

Commit

Permalink
Many transition. Such slide. Much target. Wow.
Browse files Browse the repository at this point in the history
* implement enter and exit transitions and more animations
* remove unused proguard references
* Introduce ViewUtils with a couple of Properties
* migrate Category display to RecyclerView
* replace GridView in category selection with RecyclerView
  * Espresso now requires espresso-contrib
  * enables use of notifyItemChanged
  * more control over updated items
  • Loading branch information
keyboardsurfer committed Nov 3, 2015
1 parent 2daeed3 commit 058fbed
Show file tree
Hide file tree
Showing 53 changed files with 1,021 additions and 392 deletions.
1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
6 changes: 5 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ android {
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

Expand All @@ -52,6 +51,11 @@ dependencies {
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.1') {
exclude module: 'espresso-idling-resource'
}
androidTestCompile('com.android.support.test.espresso:espresso-contrib:2.2.1') {
exclude module: 'espresso-core'
exclude module: 'recyclerview-v7'
exclude module: 'support-v4'
}
androidTestCompile 'com.android.support.test:rules:0.4'
androidTestCompile 'com.android.support.test:runner:0.4'
androidTestCompile 'org.hamcrest:hamcrest-core:1.3'
Expand Down
17 changes: 0 additions & 17 deletions app/proguard-rules.pro

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import android.content.Context;
import android.content.Intent;
import android.support.test.InstrumentationRegistry;
import android.support.test.espresso.contrib.RecyclerViewActions;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.LargeTest;
Expand All @@ -37,18 +38,15 @@

import java.util.List;

import static android.support.test.espresso.Espresso.onData;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.Espresso.openActionBarOverflowOrOptionsMenu;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.action.ViewActions.scrollTo;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import static junit.framework.Assert.assertFalse;
import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.is;

@RunWith(AndroidJUnit4.class)
@LargeTest
Expand Down Expand Up @@ -80,11 +78,14 @@ public void loadCategories() {
}

@Test
public void allCategories_areDisplayed() {
for (Category category : mCategories) {
onData(allOf(is(instanceOf(Category.class)), is(category)))
.inAdapterView(withId(R.id.categories))
.check(matches(isDisplayed()));
public void allCategories_areDisplayed() throws InterruptedException {
String categoryName;
for (int i = 0; i < mCategories.size(); i++) {
categoryName = mCategories.get(i).getName();
onView(withId(R.id.categories))
.perform(RecyclerViewActions.actionOnItemAtPosition(i, scrollTo()));
onView(withText(categoryName)).check(matches(isDisplayed()));

}
}

Expand Down
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
android:theme="@style/Topeka">

<activity android:name=".activity.SignInActivity"
android:theme="@style/Topeka.SignInActivity"
android:windowSoftInputMode="adjustPan">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
46 changes: 0 additions & 46 deletions app/src/main/java/android/util/IntProperty.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015 Google Inc.
* Copyright 2015 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -19,19 +19,24 @@
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.ActivityOptionsCompat;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.transition.TransitionInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;

import com.google.samples.apps.topeka.R;
import com.google.samples.apps.topeka.fragment.CategorySelectionFragment;
import com.google.samples.apps.topeka.helper.ApiLevelHelper;
import com.google.samples.apps.topeka.helper.PreferencesHelper;
import com.google.samples.apps.topeka.model.Player;
import com.google.samples.apps.topeka.persistence.TopekaDatabaseHelper;
Expand Down Expand Up @@ -73,6 +78,7 @@ protected void onCreate(Bundle savedInstanceState) {
} else {
setProgressBarVisibility(View.GONE);
}
supportPostponeEnterTransition();
}

@Override
Expand Down Expand Up @@ -100,6 +106,14 @@ public boolean onCreateOptionsMenu(Menu menu) {
return true;
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.category_container);
if (fragment != null) {
fragment.onActivityResult(requestCode, resultCode, data);
}
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
Expand All @@ -114,7 +128,11 @@ public boolean onOptionsItemSelected(MenuItem item) {
private void signOut() {
PreferencesHelper.signOut(this);
TopekaDatabaseHelper.reset(this);
SignInActivity.start(this, false, null);
if (ApiLevelHelper.isAtLeast(Build.VERSION_CODES.LOLLIPOP)) {
getWindow().setExitTransition(TransitionInflater.from(this)
.inflateTransition(R.transition.category_enter));
}
SignInActivity.start(this, false);
ActivityCompat.finishAfterTransition(this);
}

Expand All @@ -124,8 +142,13 @@ private String getDisplayName(Player player) {
}

private void attachCategoryGridFragment() {
getSupportFragmentManager().beginTransaction()
.replace(R.id.quiz_container, CategorySelectionFragment.newInstance())
FragmentManager supportFragmentManager = getSupportFragmentManager();
Fragment fragment = supportFragmentManager.findFragmentById(R.id.category_container);
if (!(fragment instanceof CategorySelectionFragment)) {
fragment = CategorySelectionFragment.newInstance();
}
supportFragmentManager.beginTransaction()
.replace(R.id.category_container, fragment)
.commit();
setProgressBarVisibility(View.GONE);
}
Expand Down
Loading

0 comments on commit 058fbed

Please sign in to comment.