Skip to content

Commit

Permalink
Merge pull request #9 from manneohlund/rc-4.0.0
Browse files Browse the repository at this point in the history
Rc 4.0.0
  • Loading branch information
manneohlund authored Sep 28, 2019
2 parents 0936d96 + 607cf46 commit 0489f54
Show file tree
Hide file tree
Showing 171 changed files with 5,471 additions and 5,488 deletions.
9 changes: 7 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ captures/
.idea/dictionaries
.idea/libraries
# Android Studio 3 in .gitignore file.
.idea/caches
.idea/caches/
.idea/caches/build_file_checksums.ser
/.idea/caches/build_file_checksums.ser
.idea/modules.xml
# Comment next line if keeping position of elements in Navigation Editor is relevant for you
.idea/navEditor.xml
Expand Down Expand Up @@ -79,4 +81,7 @@ lint/intermediates/
lint/generated/
lint/outputs/
lint/tmp/
# lint/reports/
# lint/reports/

# Mac
*.DS_Store
Binary file removed .idea/caches/build_file_checksums.ser
Binary file not shown.
3 changes: 3 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,14 @@ before_install:
- yes | sdkmanager "build-tools;28.0.3"
jdk:
- oraclejdk8
before_script:
- touch local.properties
- echo "storeFile=/\n" >> local.properties
- echo "storePassword=a\n" >> local.properties
- echo "keyAlias=b\n" >> local.properties
- echo "keyPassword=c\n" >> local.properties
script:
- ./gradlew clean test
- ./gradlew clean testDebugUnitTest
notifications:
email: false
before_cache:
Expand Down
371 changes: 207 additions & 164 deletions README.md

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

ext {
VERSION_CODE = 9
VERSION_NAME = '3.0.0'
ARTIFACT_NAME = 'smart-recycler-adapter'
VERSION_CODE = 10
VERSION_NAME = '4.0.0'
TARGET_SDK_VERSION = 28
BUILD_TOOLS_VERSION = '29.0.2'
MIN_SDK_VERSION = 14
}

Expand Down
5 changes: 3 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
org.gradle.parallel=true

android.useAndroidX=true
android.enableJetifier=true
android.enableJetifier=true
android.enableUnitTestBinaryResources=true
37 changes: 34 additions & 3 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@ apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())

android {
compileSdkVersion TARGET_SDK_VERSION
buildToolsVersion BUILD_TOOLS_VERSION

defaultConfig {
applicationId "io.github.manneohlund.smartrecycleradapter.sample"
Expand All @@ -13,16 +17,39 @@ android {
versionName VERSION_NAME
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true

setProperty("archivesBaseName", "$ARTIFACT_NAME-$VERSION_NAME")
}

signingConfigs {
release {
storeFile file(properties['storeFile'])
storePassword properties['storePassword']
keyAlias properties['keyAlias']
keyPassword properties['keyPassword']
}
}

buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
debug {
applicationIdSuffix ".debug"
debuggable true
minifyEnabled false
}
beta {
initWith debug
applicationIdSuffix ".beta"
debuggable false
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
matchingFallbacks = ['debug']
}
}

Expand All @@ -42,16 +69,19 @@ dependencies {
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
exclude group: 'com.android.support', module: 'support-annotations'
})
androidTestCompile('androidx.test.espresso:espresso-contrib:3.1.0') {
androidTestImplementation('androidx.test.espresso:espresso-contrib:3.2.0') {
exclude group: 'com.android.support', module: 'appcompat'
exclude group: 'com.android.support', module: 'support-v4'
exclude module: 'recyclerview-v7'
}
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test:rules:1.2.0'
androidTestImplementation 'androidx.test:runner:1.2.0'
implementation 'androidx.annotation:annotation:1.1.0'
testImplementation 'androidx.test.ext:junit:1.1.1'
testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
testImplementation 'junit:junit:4.12'

implementation 'androidx.annotation:annotation:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'com.google.android.material:material:1.0.0'
Expand All @@ -62,5 +92,6 @@ dependencies {

implementation 'com.github.bumptech.glide:glide:4.9.0'

implementation 'io.github.manneohlund:smart-recycler-adapter:3.0.0'
//implementation 'io.github.manneohlund:smart-recycler-adapter:3.0.0'
implementation project(':smartadapter')
}
7 changes: 3 additions & 4 deletions sample/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
# hide the original source file name.
#-renamesourcefileattribute SourceFile

-keep class android.view.ViewGroup { *; }
-keep class android.view.View { *; }
-keep class **ViewHolder { *; }
-keep class **Listener { *; }
-keepclassmembers class **ViewHolder {
public <init>(**);
}
100 changes: 0 additions & 100 deletions sample/src/androidTest/java/smartrecycleradapter/DemoActivityTest.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package smartrecycleradapter

/*
* Created by Manne Öhlund on 31/05/17.
* Copyright © 2017 All rights reserved.
*/

import android.view.View
import androidx.recyclerview.widget.RecyclerView
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.NoMatchingViewException
import androidx.test.espresso.ViewAssertion
import androidx.test.espresso.contrib.RecyclerViewActions.scrollToPosition
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.rule.ActivityTestRule
import org.junit.Assert.*
import org.junit.Rule
import org.junit.Test
import smartadapter.Position
import smartadapter.SmartRecyclerAdapter
import smartrecycleradapter.models.*
import smartrecycleradapter.viewholder.*
import kotlin.reflect.KClass

class DemoActivityTest {

@get:Rule
var rule = ActivityTestRule(DemoActivity::class.java)

@Test
fun testSmartRecyclerAdapter_getItems() {
val adapter = rule.activity.recyclerView.adapter as SmartRecyclerAdapter
assertNotNull("Check SmartRecyclerAdapter is not null", adapter)
assertEquals("MoviePosterModel count", 1, adapter.getItems(MoviePosterModel::class).size.toLong())
assertEquals("MovieBannerModel count", 3, adapter.getItems(MovieBannerModel::class).size.toLong())
assertEquals("ComingSoonMoviesModel count", 1, adapter.getItems(ComingSoonMoviesModel::class).size.toLong())
assertEquals("MyWatchListModel count", 1, adapter.getItems(MyWatchListModel::class).size.toLong())
assertEquals("ActionMoviesModel count", 1, adapter.getItems(ActionMoviesModel::class).size.toLong())
assertEquals("AdventureMoviesModel count", 1, adapter.getItems(AdventureMoviesModel::class).size.toLong())
assertEquals("AnimatedMoviesModel count", 1, adapter.getItems(AnimatedMoviesModel::class).size.toLong())
assertEquals("SciFiMoviesModel count", 1, adapter.getItems(SciFiMoviesModel::class).size.toLong())
assertEquals("RecentlyPlayedMoviesModel count", 1, adapter.getItems(RecentlyPlayedMoviesModel::class).size.toLong())
assertEquals("CopyrightModel count", 1, adapter.getItems(CopyrightModel::class).size.toLong())
}

@Test
fun testSmartRecyclerAdapter_matchesViewHolderAtPosition() {
onView(withId(R.id.recycler_view))
.check(matchesViewHolderAtPosition(0, PosterViewHolder::class))
.perform(scrollToPosition<PosterViewHolder>(1))
.check(matchesViewHolderAtPosition(1, SampleFabViewHolder::class))
.perform(scrollToPosition<SampleFabViewHolder>(2))
.check(matchesViewHolderAtPosition(2, ComingSoonMoviesViewHolder::class))
.perform(scrollToPosition<ComingSoonMoviesViewHolder>(3))
.check(matchesViewHolderAtPosition(3, MyWatchListViewHolder::class))
.perform(scrollToPosition<MyWatchListViewHolder>(4))
.check(matchesViewHolderAtPosition(4, BannerViewHolder::class))
.perform(scrollToPosition<BannerViewHolder>(5))
.check(matchesViewHolderAtPosition(5, ActionMoviesViewHolder::class))
.perform(scrollToPosition<ActionMoviesViewHolder>(6))
.check(matchesViewHolderAtPosition(6, AdventureMoviesViewHolder::class))
.perform(scrollToPosition<AdventureMoviesViewHolder>(7))
.check(matchesViewHolderAtPosition(7, BannerViewHolder::class))
.perform(scrollToPosition<BannerViewHolder>(8))
.check(matchesViewHolderAtPosition(8, AnimatedMoviesViewHolder::class))
.perform(scrollToPosition<AnimatedMoviesViewHolder>(9))
.check(matchesViewHolderAtPosition(9, SciFiMoviesViewHolder::class))
.perform(scrollToPosition<SciFiMoviesViewHolder>( 10))
.check(matchesViewHolderAtPosition(10, BannerViewHolder::class))
.perform(scrollToPosition<BannerViewHolder>(11))
.check(matchesViewHolderAtPosition(11, RecentlyPlayedMoviesViewHolder::class))
.perform(scrollToPosition<RecentlyPlayedMoviesViewHolder>(12))
.check(matchesViewHolderAtPosition(12, CopyrightViewHolder::class))
}

private fun matchesViewHolderAtPosition(position: Position, target: KClass<*>): ViewAssertion {
return ViewAssertion { view: View?, _: NoMatchingViewException? ->
val recyclerView = view as RecyclerView
val source = recyclerView.findViewHolderForAdapterPosition(position)!!
assertTrue(String.format("Is <%s> assignable from <%s>", source::class, target), source::class == target)
}
}
}
Loading

0 comments on commit 0489f54

Please sign in to comment.