Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lib update #11

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ repositories {
}

android {
compileSdkVersion 26
compileSdkVersion 28
defaultConfig {
applicationId "com.yalantis.kolodaandroid"
minSdkVersion 15
targetSdkVersion 26
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
Expand All @@ -29,15 +29,15 @@ android {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation "com.android.support:cardview-v7:26.1.0"
implementation 'com.android.support:recyclerview-v7:26.1.0'
implementation 'com.github.bumptech.glide:glide:4.3.1'
kapt 'com.github.bumptech.glide:compiler:4.3.1'
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha2'
implementation "androidx.cardview:cardview:1.0.0"
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'com.github.bumptech.glide:glide:4.8.0'
kapt 'com.github.bumptech.glide:compiler:4.8.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
compile project(":library")
androidTestImplementation 'androidx.test:runner:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
implementation project(":library")
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.yalantis.kolodaandroid

import android.support.test.InstrumentationRegistry
import android.support.test.runner.AndroidJUnit4
import androidx.test.InstrumentationRegistry
import androidx.test.runner.AndroidJUnit4

import org.junit.Test
import org.junit.runner.RunWith
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.yalantis.kolodaandroid

import android.content.Context
import android.support.v7.widget.RecyclerView
import androidx.recyclerview.widget.RecyclerView
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
Expand All @@ -10,7 +10,6 @@ import com.bumptech.glide.Glide
import com.bumptech.glide.load.resource.bitmap.CenterCrop
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
import com.bumptech.glide.request.RequestOptions
import kotlinx.android.synthetic.main.item_koloda.*
import kotlinx.android.synthetic.main.item_koloda.view.*


Expand Down Expand Up @@ -66,7 +65,7 @@ class KolodaSampleAdapter(val context: Context,val data: List<Int>?) : BaseAdapt
* Static view items holder
*/
class DataViewHolder(view: View) : RecyclerView.ViewHolder(view) {
var picture = view.kolodaImage
private var picture = view.kolodaImage

internal fun bindData(context: Context, data: Int) {
val transforms = RequestOptions().transforms(CenterCrop(), RoundedCorners(20))
Expand All @@ -75,6 +74,5 @@ class KolodaSampleAdapter(val context: Context,val data: List<Int>?) : BaseAdapt
.apply(transforms)
.into(picture)
}

}
}
4 changes: 2 additions & 2 deletions app/src/main/java/com/yalantis/kolodaandroid/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.yalantis.kolodaandroid

import android.support.v7.app.AppCompatActivity
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.yalantis.library.KolodaListener
import kotlinx.android.synthetic.main.activity_main.*
Expand Down Expand Up @@ -106,7 +106,7 @@ class MainActivity : AppCompatActivity() {

override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
actionReload -> { koloda.reloadPreviousCard() }
actionReload -> { koloda.reloadAdapterData() }
}
return super.onOptionsItemSelected(item)
}
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/res/layout/item_koloda.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?><!--<android.support.v7.widget.CardView xmlns:app="http://schemas.android.com/apk/res-auto"--><!--xmlns:card_view="http://schemas.android.com/apk/res-auto"--><!--xmlns:android="http://schemas.android.com/apk/res/android"--><!--android:id="@+id/card_view_outer"--><!--android:layout_gravity="center"--><!--android:layout_height="350dp"--><!--android:layout_width="350dp"--><!--card_view:cardBackgroundColor="@android:color/transparent"--><!--card_view:cardCornerRadius="0dp"--><!--card_view:cardElevation="3dp">-->

<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:card_view="http://schemas.android.com/tools"
android:id="@+id/cardView"
Expand All @@ -14,11 +14,11 @@
app:cardUseCompatPadding="true"
card_view:cardPreventCornerOverlap="false">

<ImageView
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/kolodaImage"
android:layout_width="332dp"
android:layout_height="380dp"
android:background="@drawable/koloda_card_view_background"
android:scaleType="centerCrop" />

</android.support.v7.widget.CardView>
</androidx.cardview.widget.CardView>
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.1.51'
ext.kotlin_version = '1.3.0'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'com.android.tools.build:gradle:3.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

// NOTE: Do not place your application dependencies here; they belong
Expand Down
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
android.enableJetifier=true
android.useAndroidX=true
org.gradle.jvmargs=-Xmx1536m

# When configured, Gradle will run in incubating parallel mode.
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
14 changes: 7 additions & 7 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

android {
compileSdkVersion 26
compileSdkVersion 28



defaultConfig {
minSdkVersion 15
targetSdkVersion 26
targetSdkVersion 28
versionCode 1
versionName "1.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

}

Expand All @@ -28,12 +28,12 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'androidx.appcompat:appcompat:1.0.2'

testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
androidTestImplementation 'androidx.test:runner:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
repositories {
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.yalantis.library;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import androidx.test.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;
Expand Down
3 changes: 1 addition & 2 deletions library/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.yalantis.library" />
<manifest package="com.yalantis.library" />
4 changes: 2 additions & 2 deletions library/src/main/java/com/yalantis/library/CardLayout.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package com.yalantis.library

import android.content.Context
import android.os.Build
import android.support.annotation.DrawableRes
import android.support.v4.content.ContextCompat
import androidx.annotation.DrawableRes
import androidx.core.content.ContextCompat
import android.util.AttributeSet
import android.view.View
import android.widget.FrameLayout
Expand Down
10 changes: 3 additions & 7 deletions library/src/main/java/com/yalantis/library/Koloda.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ package com.yalantis.library
import android.annotation.TargetApi
import android.content.Context
import android.database.DataSetObserver
import android.graphics.Color
import android.os.Build
import android.support.annotation.DrawableRes
import androidx.annotation.DrawableRes
import android.util.AttributeSet
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.widget.Adapter
Expand Down Expand Up @@ -225,7 +223,7 @@ constructor(context: Context, attrs: AttributeSet? = null,

override fun onInvalidated() {
super.onInvalidated()
adapterPosition = 0
adapterPosition = -1
removeAllViews()
addCards()
}
Expand Down Expand Up @@ -360,9 +358,7 @@ constructor(context: Context, attrs: AttributeSet? = null,
* Reload all data. Start show data from the beginning
*/
fun reloadAdapterData() {
removeAllViews()
adapterPosition = 0
dataSetObservable?.onChanged()
dataSetObservable?.onInvalidated()
}

/**
Expand Down