Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat/delete_refresh]: delete refresh 로직 추가 #165

Merged
merged 1 commit into from
Jul 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class AlbumDetailActivity : AppCompatActivity() {
(fragment as? AlbumDeleteDialogFragment)?.dismissAllowingStateLoss()
}
toast("앨범이 삭제되었습니다.")
setResult(RESULT_OK)
finish()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ import androidx.lifecycle.flowWithLifecycle
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager
import com.teampophory.pophory.R
import com.teampophory.pophory.feature.album.albumsort.AlbumSortBottomSheet
import com.teampophory.pophory.feature.album.albumsort.AlbumSortType
import com.teampophory.pophory.common.activity.hideLoading
import com.teampophory.pophory.common.activity.showLoading
import com.teampophory.pophory.common.context.stringOf
import com.teampophory.pophory.common.intent.parcelableExtra
import com.teampophory.pophory.common.view.viewBinding
import com.teampophory.pophory.databinding.ActivityAlbumListBinding
import com.teampophory.pophory.feature.album.albumsort.AlbumSortBottomSheet
import com.teampophory.pophory.feature.album.albumsort.AlbumSortType
import com.teampophory.pophory.feature.album.list.adapter.AlbumListAdapter
import com.teampophory.pophory.feature.home.photo.AddPhotoActivity
import com.teampophory.pophory.feature.home.store.model.AlbumItem
Expand All @@ -31,25 +31,29 @@ import timber.log.Timber
@AndroidEntryPoint
class AlbumListActivity : AppCompatActivity() {

private val albumListAdapter = AlbumListAdapter()
private val albumListAdapter = AlbumListAdapter { intent, activityOptionsCompat ->
photoCountRefreshLauncher.launch(intent, activityOptionsCompat)
}
private val viewModel by viewModels<AlbumListViewModel>()
private val binding by viewBinding(ActivityAlbumListBinding::inflate)
private val albumItem by parcelableExtra<AlbumItem>()

private val addAlbumActivityLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
if (result.resultCode == RESULT_OK) {
setResult(RESULT_OK)
finish()
private val photoCountRefreshLauncher =
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
if (result.resultCode == RESULT_OK) {
setResult(RESULT_OK)
finish()
}
}
}

private val imagePicker = registerForActivityResult(ActivityResultContracts.PickVisualMedia()) { uri ->
val currentAlbum = viewModel.albumItem.value
val intent = currentAlbum?.let { albumItem ->
AddPhotoActivity.getIntent(this, uri.toString(), albumItem)
private val imagePicker =
registerForActivityResult(ActivityResultContracts.PickVisualMedia()) { uri ->
val currentAlbum = viewModel.albumItem.value
val intent = currentAlbum?.let { albumItem ->
AddPhotoActivity.getIntent(this, uri.toString(), albumItem)
}
photoCountRefreshLauncher.launch(intent)
}
addAlbumActivityLauncher.launch(intent)
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package com.teampophory.pophory.feature.album.list.adapter

import android.app.Activity
import android.app.ActivityOptions
import android.content.Context
import android.content.Intent
import android.view.LayoutInflater
import android.view.ViewGroup
import android.widget.ImageView
import androidx.core.app.ActivityOptionsCompat
import androidx.recyclerview.widget.ListAdapter
import com.teampophory.pophory.common.view.ItemDiffCallback
import com.teampophory.pophory.databinding.ItemHorizontalPhotoBinding
Expand All @@ -16,7 +17,9 @@ import com.teampophory.pophory.feature.album.model.OrientType
import com.teampophory.pophory.feature.album.model.PhotoDetail
import com.teampophory.pophory.feature.album.model.PhotoItem

class AlbumListAdapter : ListAdapter<PhotoItem, AlbumViewHolder>(
class AlbumListAdapter(
private val onItemClicked: (Intent, ActivityOptionsCompat) -> Unit
) : ListAdapter<PhotoItem, AlbumViewHolder>(
ItemDiffCallback<PhotoItem>(
onItemsTheSame = { old, new -> old == new },
onContentsTheSame = { old, new -> old == new }
Expand Down Expand Up @@ -80,9 +83,9 @@ class AlbumListAdapter : ListAdapter<PhotoItem, AlbumViewHolder>(
) {
val activity = context as? Activity ?: return
val transitionAnimation =
ActivityOptions.makeSceneTransitionAnimation(activity, imageView, "thumb").toBundle()
ActivityOptionsCompat.makeSceneTransitionAnimation(activity, imageView, "thumb")
val intent = AlbumDetailActivity.newIntent(context, photoDetail)
context.startActivity(intent, transitionAnimation)
onItemClicked(intent, transitionAnimation)
}

enum class AlbumViewType {
Expand Down