Skip to content

Commit 0489f54

Browse files
authored
Merge pull request #9 from manneohlund/rc-4.0.0
Rc 4.0.0
2 parents 0936d96 + 607cf46 commit 0489f54

File tree

171 files changed

+5471
-5488
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

171 files changed

+5471
-5488
lines changed

Diff for: .gitignore

+7-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ captures/
4343
.idea/dictionaries
4444
.idea/libraries
4545
# Android Studio 3 in .gitignore file.
46-
.idea/caches
46+
.idea/caches/
47+
.idea/caches/build_file_checksums.ser
48+
/.idea/caches/build_file_checksums.ser
4749
.idea/modules.xml
4850
# Comment next line if keeping position of elements in Navigation Editor is relevant for you
4951
.idea/navEditor.xml
@@ -79,4 +81,7 @@ lint/intermediates/
7981
lint/generated/
8082
lint/outputs/
8183
lint/tmp/
82-
# lint/reports/
84+
# lint/reports/
85+
86+
# Mac
87+
*.DS_Store

Diff for: .idea/caches/build_file_checksums.ser

-598 Bytes
Binary file not shown.

Diff for: .idea/gradle.xml

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: .idea/modules.xml

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: .travis.yml

+7-1
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,14 @@ before_install:
2121
- yes | sdkmanager "build-tools;28.0.3"
2222
jdk:
2323
- oraclejdk8
24+
before_script:
25+
- touch local.properties
26+
- echo "storeFile=/\n" >> local.properties
27+
- echo "storePassword=a\n" >> local.properties
28+
- echo "keyAlias=b\n" >> local.properties
29+
- echo "keyPassword=c\n" >> local.properties
2430
script:
25-
- ./gradlew clean test
31+
- ./gradlew clean testDebugUnitTest
2632
notifications:
2733
email: false
2834
before_cache:

Diff for: README.md

+207-164
Large diffs are not rendered by default.

Diff for: build.gradle

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22

33
ext {
4-
VERSION_CODE = 9
5-
VERSION_NAME = '3.0.0'
4+
ARTIFACT_NAME = 'smart-recycler-adapter'
5+
VERSION_CODE = 10
6+
VERSION_NAME = '4.0.0'
67
TARGET_SDK_VERSION = 28
8+
BUILD_TOOLS_VERSION = '29.0.2'
79
MIN_SDK_VERSION = 14
810
}
911

Diff for: gradle.properties

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ org.gradle.jvmargs=-Xmx1536m
1414
# When configured, Gradle will run in incubating parallel mode.
1515
# This option should only be used with decoupled projects. More details, visit
1616
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17-
# org.gradle.parallel=true
17+
org.gradle.parallel=true
1818

1919
android.useAndroidX=true
20-
android.enableJetifier=true
20+
android.enableJetifier=true
21+
android.enableUnitTestBinaryResources=true

Diff for: sample/build.gradle

+34-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@ apply plugin: 'com.android.application'
22
apply plugin: 'kotlin-android'
33
apply plugin: 'kotlin-android-extensions'
44

5+
Properties properties = new Properties()
6+
properties.load(project.rootProject.file('local.properties').newDataInputStream())
7+
58
android {
69
compileSdkVersion TARGET_SDK_VERSION
10+
buildToolsVersion BUILD_TOOLS_VERSION
711

812
defaultConfig {
913
applicationId "io.github.manneohlund.smartrecycleradapter.sample"
@@ -13,16 +17,39 @@ android {
1317
versionName VERSION_NAME
1418
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1519
vectorDrawables.useSupportLibrary = true
20+
21+
setProperty("archivesBaseName", "$ARTIFACT_NAME-$VERSION_NAME")
22+
}
23+
24+
signingConfigs {
25+
release {
26+
storeFile file(properties['storeFile'])
27+
storePassword properties['storePassword']
28+
keyAlias properties['keyAlias']
29+
keyPassword properties['keyPassword']
30+
}
1631
}
1732

1833
buildTypes {
1934
release {
2035
minifyEnabled true
36+
shrinkResources true
2137
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
38+
signingConfig signingConfigs.release
2239
}
2340
debug {
41+
applicationIdSuffix ".debug"
42+
debuggable true
2443
minifyEnabled false
44+
}
45+
beta {
46+
initWith debug
47+
applicationIdSuffix ".beta"
48+
debuggable false
49+
minifyEnabled true
50+
shrinkResources true
2551
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
52+
matchingFallbacks = ['debug']
2653
}
2754
}
2855

@@ -42,16 +69,19 @@ dependencies {
4269
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
4370
exclude group: 'com.android.support', module: 'support-annotations'
4471
})
45-
androidTestCompile('androidx.test.espresso:espresso-contrib:3.1.0') {
72+
androidTestImplementation('androidx.test.espresso:espresso-contrib:3.2.0') {
4673
exclude group: 'com.android.support', module: 'appcompat'
4774
exclude group: 'com.android.support', module: 'support-v4'
4875
exclude module: 'recyclerview-v7'
4976
}
77+
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
5078
androidTestImplementation 'androidx.test:rules:1.2.0'
5179
androidTestImplementation 'androidx.test:runner:1.2.0'
52-
implementation 'androidx.annotation:annotation:1.1.0'
80+
testImplementation 'androidx.test.ext:junit:1.1.1'
81+
testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
5382
testImplementation 'junit:junit:4.12'
5483

84+
implementation 'androidx.annotation:annotation:1.1.0'
5585
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
5686
implementation 'androidx.appcompat:appcompat:1.0.2'
5787
implementation 'com.google.android.material:material:1.0.0'
@@ -62,5 +92,6 @@ dependencies {
6292

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

65-
implementation 'io.github.manneohlund:smart-recycler-adapter:3.0.0'
95+
//implementation 'io.github.manneohlund:smart-recycler-adapter:3.0.0'
96+
implementation project(':smartadapter')
6697
}

Diff for: sample/proguard-rules.pro

+3-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
# hide the original source file name.
2525
#-renamesourcefileattribute SourceFile
2626

27-
-keep class android.view.ViewGroup { *; }
28-
-keep class android.view.View { *; }
29-
-keep class **ViewHolder { *; }
30-
-keep class **Listener { *; }
27+
-keepclassmembers class **ViewHolder {
28+
public <init>(**);
29+
}

Diff for: sample/src/androidTest/java/smartrecycleradapter/DemoActivityTest.java

-100
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
package smartrecycleradapter
2+
3+
/*
4+
* Created by Manne Öhlund on 31/05/17.
5+
* Copyright © 2017 All rights reserved.
6+
*/
7+
8+
import android.view.View
9+
import androidx.recyclerview.widget.RecyclerView
10+
import androidx.test.espresso.Espresso.onView
11+
import androidx.test.espresso.NoMatchingViewException
12+
import androidx.test.espresso.ViewAssertion
13+
import androidx.test.espresso.contrib.RecyclerViewActions.scrollToPosition
14+
import androidx.test.espresso.matcher.ViewMatchers.withId
15+
import androidx.test.rule.ActivityTestRule
16+
import org.junit.Assert.*
17+
import org.junit.Rule
18+
import org.junit.Test
19+
import smartadapter.Position
20+
import smartadapter.SmartRecyclerAdapter
21+
import smartrecycleradapter.models.*
22+
import smartrecycleradapter.viewholder.*
23+
import kotlin.reflect.KClass
24+
25+
class DemoActivityTest {
26+
27+
@get:Rule
28+
var rule = ActivityTestRule(DemoActivity::class.java)
29+
30+
@Test
31+
fun testSmartRecyclerAdapter_getItems() {
32+
val adapter = rule.activity.recyclerView.adapter as SmartRecyclerAdapter
33+
assertNotNull("Check SmartRecyclerAdapter is not null", adapter)
34+
assertEquals("MoviePosterModel count", 1, adapter.getItems(MoviePosterModel::class).size.toLong())
35+
assertEquals("MovieBannerModel count", 3, adapter.getItems(MovieBannerModel::class).size.toLong())
36+
assertEquals("ComingSoonMoviesModel count", 1, adapter.getItems(ComingSoonMoviesModel::class).size.toLong())
37+
assertEquals("MyWatchListModel count", 1, adapter.getItems(MyWatchListModel::class).size.toLong())
38+
assertEquals("ActionMoviesModel count", 1, adapter.getItems(ActionMoviesModel::class).size.toLong())
39+
assertEquals("AdventureMoviesModel count", 1, adapter.getItems(AdventureMoviesModel::class).size.toLong())
40+
assertEquals("AnimatedMoviesModel count", 1, adapter.getItems(AnimatedMoviesModel::class).size.toLong())
41+
assertEquals("SciFiMoviesModel count", 1, adapter.getItems(SciFiMoviesModel::class).size.toLong())
42+
assertEquals("RecentlyPlayedMoviesModel count", 1, adapter.getItems(RecentlyPlayedMoviesModel::class).size.toLong())
43+
assertEquals("CopyrightModel count", 1, adapter.getItems(CopyrightModel::class).size.toLong())
44+
}
45+
46+
@Test
47+
fun testSmartRecyclerAdapter_matchesViewHolderAtPosition() {
48+
onView(withId(R.id.recycler_view))
49+
.check(matchesViewHolderAtPosition(0, PosterViewHolder::class))
50+
.perform(scrollToPosition<PosterViewHolder>(1))
51+
.check(matchesViewHolderAtPosition(1, SampleFabViewHolder::class))
52+
.perform(scrollToPosition<SampleFabViewHolder>(2))
53+
.check(matchesViewHolderAtPosition(2, ComingSoonMoviesViewHolder::class))
54+
.perform(scrollToPosition<ComingSoonMoviesViewHolder>(3))
55+
.check(matchesViewHolderAtPosition(3, MyWatchListViewHolder::class))
56+
.perform(scrollToPosition<MyWatchListViewHolder>(4))
57+
.check(matchesViewHolderAtPosition(4, BannerViewHolder::class))
58+
.perform(scrollToPosition<BannerViewHolder>(5))
59+
.check(matchesViewHolderAtPosition(5, ActionMoviesViewHolder::class))
60+
.perform(scrollToPosition<ActionMoviesViewHolder>(6))
61+
.check(matchesViewHolderAtPosition(6, AdventureMoviesViewHolder::class))
62+
.perform(scrollToPosition<AdventureMoviesViewHolder>(7))
63+
.check(matchesViewHolderAtPosition(7, BannerViewHolder::class))
64+
.perform(scrollToPosition<BannerViewHolder>(8))
65+
.check(matchesViewHolderAtPosition(8, AnimatedMoviesViewHolder::class))
66+
.perform(scrollToPosition<AnimatedMoviesViewHolder>(9))
67+
.check(matchesViewHolderAtPosition(9, SciFiMoviesViewHolder::class))
68+
.perform(scrollToPosition<SciFiMoviesViewHolder>( 10))
69+
.check(matchesViewHolderAtPosition(10, BannerViewHolder::class))
70+
.perform(scrollToPosition<BannerViewHolder>(11))
71+
.check(matchesViewHolderAtPosition(11, RecentlyPlayedMoviesViewHolder::class))
72+
.perform(scrollToPosition<RecentlyPlayedMoviesViewHolder>(12))
73+
.check(matchesViewHolderAtPosition(12, CopyrightViewHolder::class))
74+
}
75+
76+
private fun matchesViewHolderAtPosition(position: Position, target: KClass<*>): ViewAssertion {
77+
return ViewAssertion { view: View?, _: NoMatchingViewException? ->
78+
val recyclerView = view as RecyclerView
79+
val source = recyclerView.findViewHolderForAdapterPosition(position)!!
80+
assertTrue(String.format("Is <%s> assignable from <%s>", source::class, target), source::class == target)
81+
}
82+
}
83+
}

0 commit comments

Comments
 (0)