Skip to content

Update project #21

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

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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ allprojects {
Add the dependency:
```Groovy
dependencies {
implementation 'com.github.Yalantis:Koloda-Android:v0.0.2-alpha'
implementation 'com.github.Yalantis:Koloda-Android:v0.0.3-alpha'
}
```

Expand Down
38 changes: 22 additions & 16 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'

repositories {
maven { url 'https://maven.fabric.io/public' }
google()
mavenCentral()
mavenLocal()
}

android {
compileSdkVersion 26
compileSdkVersion 33
defaultConfig {
applicationId "com.yalantis.kolodaandroid"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
targetSdkVersion 33
versionCode 2
versionName "1.0.3"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand All @@ -25,19 +25,25 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

buildFeatures {
viewBinding true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

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'
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")
implementation "androidx.appcompat:appcompat:1.5.1"
implementation "androidx.constraintlayout:constraintlayout:2.1.4"
implementation "androidx.cardview:cardview:1.0.0"
implementation "androidx.recyclerview:recyclerview:1.2.1"
implementation "com.github.bumptech.glide:glide:4.13.2"
testImplementation "junit:junit:4.13.2"
androidTestImplementation "com.android.support.test:runner:1.0.2"
androidTestImplementation "com.android.support.test.espresso:espresso-core:3.0.2"
implementation project(":library")
}
4 changes: 3 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
package com.yalantis.kolodaandroid

import android.content.Context
import android.support.v7.widget.RecyclerView
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.BaseAdapter
import androidx.recyclerview.widget.RecyclerView
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.view.*
import com.yalantis.kolodaandroid.databinding.ItemKolodaBinding


/**
* Created by anna on 11/10/17.
*/
class KolodaSampleAdapter(val context: Context,val data: List<Int>?) : BaseAdapter() {
class KolodaSampleAdapter(val context: Context, data: List<Int>) : BaseAdapter() {

private val dataList = mutableListOf<Int>()

init {
if (data != null) {
dataList.addAll(data)
}
dataList.addAll(data)
}

override fun getCount(): Int {
Expand All @@ -49,8 +47,9 @@ class KolodaSampleAdapter(val context: Context,val data: List<Int>?) : BaseAdapt
var view = convertView

if (view == null) {
view = LayoutInflater.from(parent.context).inflate(R.layout.item_koloda, parent, false)
holder = DataViewHolder(view)
val binding =
ItemKolodaBinding.inflate(LayoutInflater.from(parent.context), parent, false)
holder = DataViewHolder(binding)
view?.tag = holder
} else {
holder = view.tag as DataViewHolder
Expand All @@ -64,8 +63,8 @@ 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
class DataViewHolder(binding: ItemKolodaBinding) : RecyclerView.ViewHolder(binding.root) {
var picture = binding.kolodaImage

internal fun bindData(context: Context, data: Int) {
val transforms = RequestOptions().transforms(CenterCrop(), RoundedCorners(20))
Expand Down
28 changes: 14 additions & 14 deletions app/src/main/java/com/yalantis/kolodaandroid/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
package com.yalantis.kolodaandroid

import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import com.yalantis.library.KolodaListener
import kotlinx.android.synthetic.main.activity_main.*
import android.annotation.SuppressLint
import android.view.Menu
import android.view.MenuItem
import android.view.ViewTreeObserver
import androidx.appcompat.app.AppCompatActivity
import com.yalantis.kolodaandroid.R.id.actionReload
import com.yalantis.kolodaandroid.databinding.ActivityMainBinding


class MainActivity : AppCompatActivity() {

private var adapter: KolodaSampleAdapter? = null
private val binding by lazy { ActivityMainBinding.inflate(layoutInflater) }

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
setContentView(binding.root)
initializeDeck()
fillData()
setUpCLickListeners()
}

override fun onStart() {
super.onStart()
activityMain.viewTreeObserver.addOnGlobalLayoutListener(object : ViewTreeObserver.OnGlobalLayoutListener {
binding.activityMain.viewTreeObserver.addOnGlobalLayoutListener(object : ViewTreeObserver.OnGlobalLayoutListener {
@SuppressLint("NewApi")
override fun onGlobalLayout() {
//now we can retrieve the width and height
Expand All @@ -38,9 +38,9 @@ class MainActivity : AppCompatActivity() {


if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN)
activityMain.viewTreeObserver.removeOnGlobalLayoutListener(this)
binding.activityMain.viewTreeObserver.removeOnGlobalLayoutListener(this)
else
activityMain.viewTreeObserver.removeGlobalOnLayoutListener(this)
binding.activityMain.viewTreeObserver.removeGlobalOnLayoutListener(this)
}
})
}
Expand All @@ -50,7 +50,7 @@ class MainActivity : AppCompatActivity() {
* Also implemented listener for caching requests
*/
private fun initializeDeck() {
koloda.kolodaListener = object : KolodaListener {
binding.koloda.kolodaListener = object : KolodaListener {

internal var cardsSwiped = 0

Expand Down Expand Up @@ -89,14 +89,14 @@ class MainActivity : AppCompatActivity() {
R.drawable.marshmallow,
R.drawable.nougat,
R.drawable.oreo)
adapter = KolodaSampleAdapter(this, data.toList())
koloda.adapter = adapter
koloda.isNeedCircleLoading = true
val adapter = KolodaSampleAdapter(this, data.toList())
binding.koloda.adapter = adapter
binding.koloda.isNeedCircleLoading = true
}

private fun setUpCLickListeners() {
dislike.setOnClickListener { koloda.onClickLeft() }
like.setOnClickListener { koloda.onClickRight() }
binding.dislike.setOnClickListener { binding.koloda.onClickLeft() }
binding.like.setOnClickListener { binding.koloda.onClickRight() }
}

override fun onCreateOptionsMenu(menu: Menu?): Boolean {
Expand All @@ -106,7 +106,7 @@ class MainActivity : AppCompatActivity() {

override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
actionReload -> { koloda.reloadAdapterData() }
actionReload -> { binding.koloda.reloadAdapterData() }
}
return super.onOptionsItemSelected(item)
}
Expand Down
4 changes: 2 additions & 2 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 @@ -21,4 +21,4 @@
android:background="@drawable/koloda_card_view_background"
android:scaleType="centerCrop" />

</android.support.v7.widget.CardView>
</androidx.cardview.widget.CardView>
8 changes: 4 additions & 4 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.7.10'
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'com.android.tools.build:gradle:7.3.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

// NOTE: Do not place your application dependencies here; they belong
Expand All @@ -18,7 +18,7 @@ buildscript {
allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}

Expand Down
5 changes: 5 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,8 @@ org.gradle.jvmargs=-Xmx1536m
# 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

android.useAndroidX=true
android.enableJetifier=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official
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-7.4-all.zip
21 changes: 12 additions & 9 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

android {
compileSdkVersion 26
compileSdkVersion 33



defaultConfig {
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
targetSdkVersion 33
versionCode 2
versionName "1.0.3"

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

Expand All @@ -23,18 +23,21 @@ android {
}
}

buildFeatures {
viewBinding true
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

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

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"
testImplementation "junit:junit:4.13.2"
androidTestImplementation "com.android.support.test:runner:1.0.2"
androidTestImplementation "com.android.support.test.espresso:espresso-core:3.0.2"
}
repositories {
google()
mavenCentral()
}
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,12 +2,12 @@ package com.yalantis.library

import android.content.Context
import android.os.Build
import android.support.annotation.DrawableRes
import android.support.v4.content.ContextCompat
import android.util.AttributeSet
import android.view.View
import android.widget.FrameLayout
import android.widget.ImageView
import androidx.annotation.DrawableRes
import androidx.core.content.ContextCompat

/**
* Created by anna on 1/2/18.
Expand Down
12 changes: 6 additions & 6 deletions library/src/main/java/com/yalantis/library/CardOperator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ class CardOperator(
private val cardGestureListener = object : GestureDetector.SimpleOnGestureListener() {

override fun onFling(
e1: MotionEvent?,
e2: MotionEvent?,
e1: MotionEvent,
e2: MotionEvent,
velocityX: Float,
velocityY: Float
): Boolean {
Expand All @@ -40,17 +40,17 @@ class CardOperator(
return false
}

override fun onDoubleTap(e: MotionEvent?): Boolean {
override fun onDoubleTap(e: MotionEvent): Boolean {
cardCallback.onCardDoubleTap(adapterPosition, cardView)
return super.onDoubleTap(e)
}

override fun onSingleTapConfirmed(e: MotionEvent?): Boolean {
override fun onSingleTapConfirmed(e: MotionEvent): Boolean {
cardCallback.onCardSingleTap(adapterPosition, cardView)
return super.onSingleTapConfirmed(e)
}

override fun onLongPress(e: MotionEvent?) {
override fun onLongPress(e: MotionEvent) {
cardCallback.onCardLongPress(adapterPosition, cardView)
super.onLongPress(e)
}
Expand Down Expand Up @@ -158,7 +158,7 @@ class CardOperator(
currentCardAnimator?.duration = 200
currentCardAnimator?.addUpdateListener { updateCardProgress() }
currentCardAnimator?.addListener(object : AnimatorListenerAdapter() {
override fun onAnimationStart(animation: Animator?, isReverse: Boolean) {
override fun onAnimationStart(animation: Animator, isReverse: Boolean) {
super.onAnimationStart(animation, isReverse)
animationCycle = AnimationCycle.ANIMATION_IN_PROGRESS
}
Expand Down
Loading