-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
384 additions
and
139 deletions.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
...ion/src/main/java/org/gdsc/presentation/view/mypage/adapter/PhotoWillBeUploadedAdapter.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,64 @@ | ||
package org.gdsc.presentation.view.mypage.adapter | ||
|
||
import android.view.LayoutInflater | ||
import android.view.ViewGroup | ||
import androidx.core.net.toUri | ||
import androidx.recyclerview.widget.DiffUtil | ||
import androidx.recyclerview.widget.ListAdapter | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.bumptech.glide.Glide | ||
import org.gdsc.presentation.databinding.ItemPhotoWillBeUploadedBinding | ||
|
||
class PhotoWillBeUploadedAdapter( | ||
private val onDeleteButtonClicked: (String) -> Unit | ||
) : | ||
ListAdapter<String, PhotoWillBeUploadedAdapter.PhotoWillBeUploadedViewHolder>( | ||
diffUtil | ||
) { | ||
inner class PhotoWillBeUploadedViewHolder(private val binding: ItemPhotoWillBeUploadedBinding) : | ||
RecyclerView.ViewHolder(binding.root) { | ||
|
||
fun bind(url: String) { | ||
|
||
Glide.with(binding.root) | ||
.load(url.toUri()) | ||
.into(binding.photoWillBeUploaded) | ||
|
||
binding.deleteButton.setOnClickListener { | ||
onDeleteButtonClicked(url) | ||
} | ||
} | ||
} | ||
|
||
companion object { | ||
val diffUtil = object : DiffUtil.ItemCallback<String>() { | ||
override fun areItemsTheSame(oldItem: String, newItem: String): Boolean { | ||
return oldItem == newItem | ||
} | ||
|
||
override fun areContentsTheSame(oldItem: String, newItem: String): Boolean { | ||
return oldItem == newItem | ||
} | ||
} | ||
} | ||
|
||
override fun onCreateViewHolder( | ||
parent: ViewGroup, | ||
viewType: Int | ||
): PhotoWillBeUploadedViewHolder { | ||
val inflater = LayoutInflater.from(parent.context) | ||
return PhotoWillBeUploadedViewHolder( | ||
ItemPhotoWillBeUploadedBinding.inflate( | ||
inflater, | ||
parent, | ||
false | ||
) | ||
) | ||
} | ||
|
||
override fun onBindViewHolder(holder: PhotoWillBeUploadedViewHolder, position: Int) { | ||
holder.apply { | ||
bind(getItem(position)) | ||
} | ||
} | ||
} |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,9 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<selector > | ||
<item xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<shape android:shape="rectangle"> | ||
<solid android:color="@color/main500" /> | ||
<corners android:radius="6dp" /> | ||
</shape> | ||
</item> | ||
</selector> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.