Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
anna committed Dec 27, 2017
1 parent 34af8df commit 4f2408d
Show file tree
Hide file tree
Showing 27 changed files with 260 additions and 110 deletions.
32 changes: 5 additions & 27 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,31 +1,9 @@
*.iml
.gradle
/local.properties
.DS_Store
/build
/captures
.externalNativeBuild
bin
gen

# log files
log*.txt

# archives
*.gz
*.tar
*.zip

# eclipse
*.metadata
*.settings
*.prefs

#idea
*.idea
out/

build/
.gradle/

.keystore/
app-release.apk

.DS_Store
.idea/
gradle/
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@ 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.*


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

private val dataList = mutableListOf<String>()
private val dataList = mutableListOf<Int>()

init {
if (data != null) {
Expand All @@ -30,15 +31,15 @@ class KolodaSampleAdapter(val context: Context,val data: List<String>?) : BaseAd
return dataList.size
}

override fun getItem(position: Int): String {
override fun getItem(position: Int): Int {
return dataList[position]
}

override fun getItemId(position: Int): Long {
return position.toLong()
}

fun setData(data: List<String>) {
fun setData(data: List<Int>) {
dataList.clear()
dataList.addAll(data)
notifyDataSetChanged()
Expand Down Expand Up @@ -67,7 +68,7 @@ class KolodaSampleAdapter(val context: Context,val data: List<String>?) : BaseAd
class DataViewHolder(view: View) : RecyclerView.ViewHolder(view) {
var picture = view.kolodaImage

internal fun bindData(context: Context, data: String) {
internal fun bindData(context: Context, data: Int) {
val transforms = RequestOptions().transforms(CenterCrop(), RoundedCorners(20))
Glide.with(context)
.load(data)
Expand Down
27 changes: 20 additions & 7 deletions app/src/main/java/com/yalantis/kolodaandroid/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class MainActivity : AppCompatActivity() {
setContentView(R.layout.activity_main)
initializeDeck()
fillData()
setUpCLickListeners()
}

override fun onStart() {
Expand Down Expand Up @@ -75,14 +76,26 @@ class MainActivity : AppCompatActivity() {
* Fills deck with data
*/
private fun fillData() {
val data = arrayOf("https://source.unsplash.com/Xq1ntWruZQI/600x800",
"https://source.unsplash.com/NYyCqdBOKwc/600x800",
"https://source.unsplash.com/buF62ewDLcQ/600x800",
"https://source.unsplash.com/THozNzxEP3g/600x800",
"https://source.unsplash.com/USrZRcRS2Lw/600x800",
"https://source.unsplash.com/PeFk7fzxTdk/600x800",
"https://source.unsplash.com/LrMWHKqilUw/600x800")
val data = arrayOf(R.drawable.cupcacke,
R.drawable.donut,
R.drawable.eclair,
R.drawable.froyo,
R.drawable.gingerbread,
R.drawable.honeycomb,
R.drawable.ice_cream_sandwich,
R.drawable.jelly_bean,
R.drawable.kitkat,
R.drawable.lollipop,
R.drawable.marshmallow,
R.drawable.nougat,
R.drawable.oreo)
adapter = KolodaSampleAdapter(this, data.toList())
koloda.adapter = adapter
koloda.isNeedCircleLoading = true
}

private fun setUpCLickListeners() {
dislike.setOnClickListener { koloda.onClickLeft() }
like.setOnClickListener { koloda.onClickRight() }
}
}
Binary file added app/src/main/res/drawable/cupcacke.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/donut.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/eclair.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/froyo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/gingerbread.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/honeycomb.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions app/src/main/res/drawable/ic_dislike.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="48dp" android:viewportHeight="24.0" android:viewportWidth="24.0" android:width="48dp">
<path android:fillColor="#b5554c" android:pathData="M19,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12z"/>
</vector>
4 changes: 4 additions & 0 deletions app/src/main/res/drawable/ic_like.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="48dp" android:viewportHeight="24.0" android:viewportWidth="24.0" android:width="48dp">
<path android:fillColor="#719455" android:pathData="M9,16.2L4.8,12l-1.4,1.4L9,19 21,7l-1.4,-1.4L9,16.2z"/>
</vector>
Binary file added app/src/main/res/drawable/ice_cream_sandwich.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/jelly_bean.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/kitkat.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion app/src/main/res/drawable/koloda_card_view_background.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
android:shape="rectangle">

<solid android:color="@android:color/white"/>
<corners android:radius="12dp" />
<corners android:bottomRightRadius="12dp"
android:bottomLeftRadius="12dp"
android:topLeftRadius="12dp"
android:topRightRadius="12dp" />

</shape>
Binary file added app/src/main/res/drawable/lollipop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/marshmallow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/nougat.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/oreo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 34 additions & 4 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,16 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/activityMain"
android:background="@android:color/white"
android:background="@color/colorPrimary"
android:clipToPadding="false"
android:layout_width="match_parent"
android:layout_height="match_parent">

<com.yalantis.library.Koloda
android:id="@+id/koloda"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:layout_gravity="center"
android:elevation="1dp"
app:koloda_card_layout="@layout/item_koloda" />

</FrameLayout>
<LinearLayout
android:id="@+id/buttonsLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:layout_marginBottom="16dp"
android:orientation="horizontal">

<ImageButton
android:id="@+id/dislike"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_dislike"
android:layout_weight="1"
android:background="@android:color/transparent"/>


<ImageButton
android:id="@+id/like"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_like"
android:layout_weight="0.5"
android:layout_marginLeft="40dp"
android:background="@android:color/transparent"/>

</LinearLayout>

</RelativeLayout>
28 changes: 16 additions & 12 deletions app/src/main/res/layout/item_koloda.xml
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<?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"
android:layout_width="350dp"
android:layout_height="350dp"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:card_view="http://schemas.android.com/tools"
card_view:cardCornerRadius="20dp"
card_view:contentPadding="25dp"
card_view:cardElevation="4dp"
card_view:cardMaxElevation="6dp"
android:layout_gravity="center">
android:id="@+id/cardView"
android:layout_width="350dp"
android:layout_height="400dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="32dp"
app:cardCornerRadius="10dp"
app:cardElevation="3dp"
app:cardMaxElevation="6dp"
app:cardUseCompatPadding="true"
card_view:cardPreventCornerOverlap="false">

<ImageView
android:id="@+id/kolodaImage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_width="332dp"
android:layout_height="380dp"
android:background="@drawable/koloda_card_view_background"
android:scaleType="centerCrop"/>

android:scaleType="centerCrop" />

</android.support.v7.widget.CardView>
6 changes: 4 additions & 2 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorPrimary">#222233</color>
<color name="colorPrimaryDark">#222233</color>
<color name="colorAccent">#FF4081</color>
<color name="colorCancel">#b5554c</color>
<color name="colorAccept">#719455</color>
</resources>
4 changes: 4 additions & 0 deletions library/src/main/java/com/yalantis/library/CardCallback.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ interface CardCallback {

fun onCardSwipedRight(adapterPosition: Int, card: View, notify: Boolean)

fun onCardMovedOnClickRight(adapterPosition: Int, card: View, notify: Boolean)

fun onCardMovedOnClickLeft(adapterPosition: Int, card: View, notify: Boolean)

fun onCardOffScreen(adapterPosition: Int, card: View)

fun onCardSingleTap(adapterPosition: Int, card: View)
Expand Down
Loading

0 comments on commit 4f2408d

Please sign in to comment.