Skip to content

Commit 7622aa6

Browse files
Fix: App name Gravity and Layout Params.
Signed-off-by: HeCodes2Much <wayne6324@gmail.com>
1 parent 96b221a commit 7622aa6

File tree

2 files changed

+15
-17
lines changed

2 files changed

+15
-17
lines changed

app/src/main/java/com/github/droidworksstudio/launcher/ui/hidden/HiddenViewHolder.kt

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,18 @@ class HiddenViewHolder(
1919
RecyclerView.ViewHolder(binding.root) {
2020
fun bind(appInfo: AppInfo) {
2121
binding.apply {
22-
// Get the current LayoutParams of appFavoriteName
23-
val layoutParams = LinearLayoutCompat.LayoutParams(
24-
LinearLayoutCompat.LayoutParams.WRAP_CONTENT,
25-
LinearLayoutCompat.LayoutParams.WRAP_CONTENT
26-
).apply {
27-
gravity = Gravity.START
28-
topMargin = preferenceHelper.homeAppPadding.toInt()
29-
bottomMargin = preferenceHelper.homeAppPadding.toInt()
30-
}
22+
// Get the current LayoutParams of appHiddenName
23+
val layoutParams = appHiddenName.layoutParams as LinearLayoutCompat.LayoutParams
24+
25+
// Set the margins
26+
layoutParams.topMargin = preferenceHelper.homeAppPadding.toInt()
27+
layoutParams.bottomMargin = preferenceHelper.homeAppPadding.toInt()
3128

3229
appHiddenName.layoutParams = layoutParams
3330
appHiddenName.text = appInfo.appName
3431
appHiddenName.setTextColor(preferenceHelper.appColor)
3532
appHiddenName.textSize = preferenceHelper.appTextSize
33+
appHiddenName.gravity = Gravity.START
3634
Log.d("Tag", "Draw Adapter: ${appInfo.appName}")
3735

3836
if (preferenceHelper.showAppIcon) {

app/src/main/java/com/github/droidworksstudio/launcher/ui/home/HomeViewHolder.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import android.util.Log
66
import android.view.Gravity
77
import android.view.View
88
import androidx.appcompat.widget.LinearLayoutCompat
9+
import androidx.core.view.marginTop
910
import androidx.recyclerview.widget.RecyclerView
1011
import com.github.droidworksstudio.launcher.data.entities.AppInfo
1112
import com.github.droidworksstudio.launcher.databinding.ItemHomeBinding
@@ -22,19 +23,18 @@ class HomeViewHolder @Inject constructor(
2223
@SuppressLint("ClickableViewAccessibility")
2324
fun bind(appInfo: AppInfo) {
2425
binding.apply {
25-
val layoutParams = LinearLayoutCompat.LayoutParams(
26-
LinearLayoutCompat.LayoutParams.WRAP_CONTENT,
27-
LinearLayoutCompat.LayoutParams.WRAP_CONTENT
28-
).apply {
29-
gravity = preferenceHelper.homeAppAlignment
30-
topMargin = preferenceHelper.homeAppPadding.toInt()
31-
bottomMargin = preferenceHelper.homeAppPadding.toInt()
32-
}
26+
// Get the current LayoutParams of appHomeName
27+
val layoutParams = appHomeName.layoutParams as LinearLayoutCompat.LayoutParams
28+
29+
// Set the margins
30+
layoutParams.topMargin = preferenceHelper.homeAppPadding.toInt()
31+
layoutParams.bottomMargin = preferenceHelper.homeAppPadding.toInt()
3332

3433
appHomeName.layoutParams = layoutParams
3534
appHomeName.text = appInfo.appName
3635
appHomeName.setTextColor(preferenceHelper.appColor)
3736
appHomeName.textSize = preferenceHelper.appTextSize
37+
appHomeName.gravity = preferenceHelper.homeAppAlignment
3838
Log.d("Tag", "Home Adapter Color: ${preferenceHelper.appColor}")
3939

4040
if (preferenceHelper.showAppIcon) {

0 commit comments

Comments
 (0)