-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added MsgsLoadStateAdapter. Refactored code.| #1806
- Loading branch information
Showing
3 changed files
with
68 additions
and
1 deletion.
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
43 changes: 43 additions & 0 deletions
43
FlowCrypt/src/main/java/com/flowcrypt/email/ui/adapter/MsgsLoadStateAdapter.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,43 @@ | ||
/* | ||
* © 2016-present FlowCrypt a.s. Limitations apply. Contact [email protected] | ||
* Contributors: DenBond7 | ||
*/ | ||
|
||
package com.flowcrypt.email.ui.adapter | ||
|
||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.paging.LoadState | ||
import androidx.paging.LoadStateAdapter | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.flowcrypt.email.R | ||
import com.flowcrypt.email.databinding.LoadMsgsProgressBinding | ||
import com.flowcrypt.email.extensions.visibleOrGone | ||
|
||
/** | ||
* @author Denis Bondarenko | ||
* Date: 5/18/22 | ||
* Time: 6:23 PM | ||
* E-mail: [email protected] | ||
*/ | ||
class MsgsLoadStateAdapter : LoadStateAdapter<MsgsLoadStateAdapter.ViewHolder>() { | ||
override fun onBindViewHolder(holder: ViewHolder, loadState: LoadState) { | ||
holder.bind(loadState) | ||
} | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, loadState: LoadState): ViewHolder { | ||
return ViewHolder( | ||
LayoutInflater.from(parent.context) | ||
.inflate(R.layout.load_msgs_progress, parent, false) | ||
) | ||
} | ||
|
||
inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { | ||
val binding: LoadMsgsProgressBinding = LoadMsgsProgressBinding.bind(itemView) | ||
|
||
fun bind(loadState: LoadState) { | ||
binding.progressBar.visibleOrGone(loadState is LoadState.Loading) | ||
} | ||
} | ||
} |
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,23 @@ | ||
<?xml version="1.0" encoding="utf-8"?><!-- | ||
~ © 2016-present FlowCrypt a.s. Limitations apply. Contact [email protected] | ||
~ Contributors: DenBond7 | ||
--> | ||
|
||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content"> | ||
|
||
<ProgressBar | ||
android:id="@+id/progressBar" | ||
style="?android:attr/progressBarStyle" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="@dimen/default_margin_content_small" | ||
android:layout_marginBottom="@dimen/default_margin_content_small" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> |