Skip to content

Commit

Permalink
Item Decoration 문제 해결 및 Version 1.0.6으로 수정 (#124)
Browse files Browse the repository at this point in the history
* fix: 잘못 설정한 itemDecoration 코드 수정

* build: version 1.0.6으로 update
  • Loading branch information
DoTheBestMayB authored Jul 4, 2024
1 parent f169de2 commit bc1eb21
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 12 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ android {
applicationId = "com.bestapp.zipbab"
minSdk = 26
targetSdk = 34
versionCode = 6
versionName = "1.0.5"
versionCode = 7
versionName = "1.0.6"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

Expand Down
24 changes: 15 additions & 9 deletions app/src/main/java/com/bestapp/zipbab/ui/profile/ProfileFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,9 @@ class ProfileFragment : Fragment() {
private fun setRecyclerView() {
binding.rvGalleryItem.addItemDecoration(object : ItemDecoration() {
private val marginSize =
binding.root.context.resources.getDimension(R.dimen.default_margin2).toInt()
binding.root.context.resources.getDimension(R.dimen.default_margin3).toInt()

private val VIEW_LOCATION_TAG_KEY = R.id.view_location_tag_key

override fun getItemOffsets(
outRect: Rect,
Expand All @@ -168,23 +170,27 @@ class ProfileFragment : Fragment() {
val position = parent.getChildAdapterPosition(view)
when (Location.get(position)) {
Location.START -> {
outRect.left = 0
outRect.right = marginSize
view.setTag(VIEW_LOCATION_TAG_KEY, Location.START)
outRect.set(0, 0, marginSize, 0)
}

Location.MIDDLE -> {
outRect.left = marginSize / 2
outRect.right = marginSize / 2
view.setTag(VIEW_LOCATION_TAG_KEY, Location.MIDDLE)
outRect.set(marginSize / 2, 0, marginSize / 2, 0)
}

Location.END -> {
outRect.left = marginSize
outRect.right = 0
view.setTag(VIEW_LOCATION_TAG_KEY, Location.END)
outRect.set(marginSize, 0, 0, 0)
}

null -> {
outRect.left = 0
outRect.right = 0
when (view.getTag(VIEW_LOCATION_TAG_KEY) as? Location) {
Location.START -> outRect.set(0, 0, marginSize, 0)
Location.MIDDLE -> outRect.set(marginSize / 2, 0, marginSize / 2, 0)
Location.END -> outRect.set(marginSize, 0, 0, 0)
null -> Unit
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ package com.bestapp.zipbab.ui.profile

import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.bestapp.zipbab.args.ImagePostSubmitArgs
import com.bestapp.zipbab.data.repository.AppSettingRepository
import com.bestapp.zipbab.data.repository.PostRepository
import com.bestapp.zipbab.data.repository.ReportRepository
import com.bestapp.zipbab.data.repository.UserRepository
import com.bestapp.zipbab.model.PostUiState
import com.bestapp.zipbab.model.UploadState
import com.bestapp.zipbab.args.ImagePostSubmitArgs
import com.bestapp.zipbab.model.toArgs
import com.bestapp.zipbab.model.toUiState
import dagger.hilt.android.lifecycle.HiltViewModel
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<resources>
<!-- margin, padding -->
<dimen name="default_margin2">2dp</dimen>
<dimen name="default_margin3">3dp</dimen>
<dimen name="default_margin4">4dp</dimen>
<dimen name="default_margin8">8dp</dimen>
<dimen name="default_margin12">12dp</dimen>
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values/key.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item type="id" name="view_location_tag_key" />
</resources>

0 comments on commit bc1eb21

Please sign in to comment.