-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #145 from Team-HMH/fix/onboarding_all
[fix/onboarding_all]: 온보딩 전반적인 이슈 수정
- Loading branch information
Showing
18 changed files
with
148 additions
and
137 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
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
48 changes: 44 additions & 4 deletions
48
...nge/src/main/java/com/hmh/hamyeonham/challenge/appadd/appselection/AppSelectionAdapter.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 |
---|---|---|
@@ -1,34 +1,74 @@ | ||
package com.hmh.hamyeonham.challenge.appadd.appselection | ||
|
||
import android.util.SparseBooleanArray | ||
import android.view.LayoutInflater | ||
import android.view.ViewGroup | ||
import androidx.recyclerview.widget.ListAdapter | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.hmh.hamyeonham.common.context.getAppIconFromPackageName | ||
import com.hmh.hamyeonham.common.context.getAppNameFromPackageName | ||
import com.hmh.hamyeonham.common.view.ItemDiffCallback | ||
import com.hmh.hamyeonham.feature.challenge.databinding.ItemAppBinding | ||
|
||
class AppSelectionAdapter( | ||
private val onAppCheckboxClicked: (String) -> Unit, | ||
private val onAppCheckboxUnClicked: (String) -> Unit | ||
private val onAppCheckboxUnClicked: (String) -> Unit, | ||
) : | ||
ListAdapter<String, AppSelectionViewHolder>( | ||
ListAdapter<String, AppSelectionAdapter.AppSelectionViewHolder>( | ||
ItemDiffCallback(onItemsTheSame = { oldItem, newItem -> | ||
oldItem == newItem | ||
}, onContentsTheSame = { oldItem, newItem -> | ||
oldItem == newItem | ||
}) | ||
}), | ||
) { | ||
|
||
private val checkBoxStatus = SparseBooleanArray() | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): AppSelectionViewHolder { | ||
val inflater = LayoutInflater.from(parent.context) | ||
val binding = ItemAppBinding.inflate(inflater, parent, false) | ||
return AppSelectionViewHolder( | ||
binding, | ||
onAppCheckboxClicked = onAppCheckboxClicked, | ||
onAppCheckboxUnClicked = onAppCheckboxUnClicked | ||
onAppCheckboxUnClicked = onAppCheckboxUnClicked, | ||
) | ||
} | ||
|
||
override fun onBindViewHolder(holder: AppSelectionViewHolder, position: Int) { | ||
holder.onBind(currentList[position]) | ||
} | ||
|
||
inner class AppSelectionViewHolder( | ||
private val binding: ItemAppBinding, | ||
private val onAppCheckboxClicked: (String) -> Unit, | ||
private val onAppCheckboxUnClicked: (String) -> Unit, | ||
) : RecyclerView.ViewHolder(binding.root) { | ||
fun onBind(packageName: String) { | ||
binding.run { | ||
val context = binding.root.context | ||
tvAppname.text = context.getAppNameFromPackageName(packageName) | ||
ivAppicon.setImageDrawable(context.getAppIconFromPackageName(packageName)) | ||
cbApp.isClickable = false | ||
cbApp.isChecked = checkBoxStatus[adapterPosition] | ||
} | ||
initAppSelectionListener(packageName) | ||
binding.cbApp.isClickable = false | ||
} | ||
|
||
private fun initAppSelectionListener(packageName: String) { | ||
binding.root.setOnClickListener { | ||
if (adapterPosition != RecyclerView.NO_POSITION) { | ||
if (binding.cbApp.isChecked) { | ||
binding.cbApp.isChecked = false | ||
onAppCheckboxUnClicked(packageName) | ||
checkBoxStatus.put(adapterPosition, false) | ||
} else { | ||
binding.cbApp.isChecked = true | ||
onAppCheckboxClicked(packageName) | ||
checkBoxStatus.put(adapterPosition, true) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
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
34 changes: 0 additions & 34 deletions
34
...in/java/com/hmh/hamyeonham/feature/onboarding/adapter/OnBoardingAppSelectionViewHolder.kt
This file was deleted.
Oops, something went wrong.
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
3 changes: 0 additions & 3 deletions
3
...g/src/main/java/com/hmh/hamyeonham/feature/onboarding/model/OnBoardingPermissionsState.kt
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
...onboarding/src/main/java/com/hmh/hamyeonham/feature/onboarding/model/OnboardingBtnInfo.kt
This file was deleted.
Oops, something went wrong.
23 changes: 0 additions & 23 deletions
23
...arding/src/main/java/com/hmh/hamyeonham/feature/onboarding/model/OnboardingInformation.kt
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
...nboarding/src/main/java/com/hmh/hamyeonham/feature/onboarding/model/OnboardingPageInfo.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.