Skip to content

Commit

Permalink
data class equals implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
har2008preet committed Sep 9, 2022
1 parent 46e8d69 commit 37216ef
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class ToastGenerate constructor(private val context: Context) {
addSource(listen) { value = it to value?.second }
addSource(toastShown) { value = value?.first to it }
}.observe(context as LifecycleOwner) { pair ->
Log.d("Debug", pair.first.toString()+ " " + pair.second)
Log.d("DebugSSSS", pair.first!!.size.toString() + " " + pair.second)

if(pair.second!=null && !pair.second!!) {
if (pair.first != null) {
Expand Down
15 changes: 14 additions & 1 deletion Toast/src/main/java/com/collegedunia/toast/ToastModel.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
package com.collegedunia.toast

import android.graphics.drawable.Drawable
import java.util.*

data class ToastModel(val type: ToastType, val title: String?, val message: String?, val leftImage: Drawable?, val length: ToastLength? = ToastLength.SHORT)
data class ToastModel(val type: ToastType, val title: String?, val message: String?, val leftImage: Drawable?, val length: ToastLength? = ToastLength.SHORT) {
override fun equals(other: Any?): Boolean{
return when (other) {
is ToastModel -> {
this.type == other.type &&
this.title == other.title &&
this.message == other.message
}
else -> false
}
}

}
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_warning.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="28dp"
android:height="28dp"
android:viewportWidth="28"
android:viewportHeight="28">
<path
android:pathData="M14,12.667C13.646,12.667 13.307,12.807 13.057,13.057C12.807,13.307 12.667,13.646 12.667,14V19.333C12.667,19.687 12.807,20.026 13.057,20.276C13.307,20.526 13.646,20.667 14,20.667C14.354,20.667 14.693,20.526 14.943,20.276C15.193,20.026 15.333,19.687 15.333,19.333V14C15.333,13.646 15.193,13.307 14.943,13.057C14.693,12.807 14.354,12.667 14,12.667ZM14.507,7.44C14.182,7.307 13.818,7.307 13.493,7.44C13.33,7.503 13.18,7.599 13.053,7.72C12.936,7.85 12.841,7.998 12.773,8.16C12.699,8.318 12.662,8.492 12.667,8.667C12.666,8.842 12.699,9.016 12.766,9.179C12.832,9.341 12.93,9.489 13.053,9.613C13.183,9.731 13.332,9.826 13.493,9.893C13.695,9.976 13.915,10.008 14.132,9.987C14.349,9.965 14.558,9.891 14.74,9.769C14.921,9.648 15.071,9.484 15.174,9.292C15.278,9.1 15.332,8.885 15.333,8.667C15.328,8.314 15.19,7.975 14.947,7.72C14.82,7.599 14.67,7.503 14.507,7.44ZM14,0.667C11.363,0.667 8.785,1.449 6.592,2.914C4.4,4.379 2.691,6.461 1.682,8.898C0.672,11.334 0.408,14.015 0.923,16.601C1.437,19.188 2.707,21.563 4.572,23.428C6.437,25.293 8.812,26.563 11.399,27.077C13.985,27.592 16.666,27.327 19.102,26.318C21.539,25.309 23.621,23.6 25.086,21.408C26.551,19.215 27.333,16.637 27.333,14C27.333,12.249 26.989,10.515 26.318,8.898C25.648,7.28 24.666,5.81 23.428,4.572C22.19,3.334 20.72,2.352 19.102,1.682C17.485,1.012 15.751,0.667 14,0.667ZM14,24.667C11.89,24.667 9.828,24.041 8.074,22.869C6.32,21.697 4.953,20.031 4.145,18.082C3.338,16.133 3.127,13.988 3.538,11.919C3.95,9.85 4.966,7.949 6.458,6.457C7.949,4.966 9.85,3.95 11.919,3.538C13.988,3.127 16.133,3.338 18.082,4.145C20.031,4.953 21.697,6.32 22.869,8.074C24.041,9.828 24.667,11.89 24.667,14C24.667,16.829 23.543,19.542 21.542,21.542C19.542,23.543 16.829,24.667 14,24.667Z"
android:fillColor="#F2C94C"/>
</vector>

0 comments on commit 37216ef

Please sign in to comment.