-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add view binding and fix order phone number
- Loading branch information
1 parent
766560f
commit 595de44
Showing
11 changed files
with
119 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
app/src/main/java/com/tahmeel/task/binding/RecyclerViewBinding.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.tahmeel.task.binding | ||
|
||
import androidx.databinding.BindingAdapter | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.skydoves.baserecyclerviewadapter.RecyclerViewPaginator | ||
import com.skydoves.bindables.BindingListAdapter | ||
import com.skydoves.whatif.whatIfNotNullAs | ||
import com.tahmeel.task.ui.main.MainViewModel | ||
|
||
/** | ||
* Created by @mohamedebrahim96 on 16,April,2021 | ||
* ShopiniWorld, Inc | ||
* ebrahimm131@gmail.com | ||
*/ | ||
|
||
object RecyclerViewBinding { | ||
|
||
@JvmStatic | ||
@BindingAdapter("adapter") | ||
fun bindAdapter(view: RecyclerView, adapter: RecyclerView.Adapter<*>) { | ||
view.adapter = adapter.apply { | ||
stateRestorationPolicy = RecyclerView.Adapter.StateRestorationPolicy.PREVENT_WHEN_EMPTY | ||
} | ||
} | ||
|
||
@JvmStatic | ||
@BindingAdapter("submitList") | ||
fun bindSubmitList(view: RecyclerView, itemList: List<Any>?) { | ||
view.adapter.whatIfNotNullAs<BindingListAdapter<Any, *>> { adapter -> | ||
adapter.submitList(itemList) | ||
} | ||
} | ||
|
||
@JvmStatic | ||
@BindingAdapter("paginationPendingOrder") | ||
fun paginationPendingOrderList(view: RecyclerView, viewModel: MainViewModel) { | ||
RecyclerViewPaginator( | ||
recyclerView = view, | ||
isLoading = { viewModel.isLoading }, | ||
loadMore = { viewModel.fetchNextPendingOrderList() }, | ||
onLast = { false } | ||
).run { | ||
threshold = 8 | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.tahmeel.task.binding | ||
|
||
import android.view.View | ||
import android.widget.Toast | ||
import androidx.databinding.BindingAdapter | ||
import com.skydoves.whatif.whatIfNotNullOrEmpty | ||
|
||
/** | ||
* Created by @mohamedebrahim96 on 16,April,2021 | ||
* ShopiniWorld, Inc | ||
* ebrahimm131@gmail.com | ||
*/ | ||
|
||
object ViewBinding { | ||
|
||
@JvmStatic | ||
@BindingAdapter("toast") | ||
fun bindToast(view: View, text: String?) { | ||
text.whatIfNotNullOrEmpty { | ||
Toast.makeText(view.context, it, Toast.LENGTH_SHORT).show() | ||
} | ||
} | ||
|
||
@JvmStatic | ||
@BindingAdapter("gone") | ||
fun bindGone(view: View, shouldBeGone: Boolean) { | ||
view.visibility = if (shouldBeGone) { | ||
View.GONE | ||
} else { | ||
View.VISIBLE | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,14 @@ | ||
<resources xmlns:tools="http://schemas.android.com/tools"> | ||
<!-- Base application theme. --> | ||
<style name="Theme.TahmeelTask" parent="Theme.MaterialComponents.DayNight.DarkActionBar"> | ||
<!-- Primary brand color. --> | ||
<style name="Theme.TahmeelTask" parent="Theme.MaterialComponents.Light.NoActionBar"> | ||
<item name="colorPrimary">@color/purple_500</item> | ||
<item name="colorPrimaryVariant">@color/purple_700</item> | ||
<item name="colorOnPrimary">@color/white</item> | ||
<!-- Secondary brand color. --> | ||
|
||
<item name="android:textColorPrimary">@android:color/white</item> | ||
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item> | ||
<item name="colorSecondary">@color/teal_200</item> | ||
<item name="colorSecondaryVariant">@color/teal_700</item> | ||
<item name="colorOnSecondary">@color/black</item> | ||
<!-- Status bar color. --> | ||
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item> | ||
<!-- Customize your theme here. --> | ||
</style> | ||
</resources> |