Skip to content

Commit

Permalink
[FEAT] #15 - 레벨, Exp 별 나무 이미지, ProgressBar 연동
Browse files Browse the repository at this point in the history
  • Loading branch information
JaesungLeee committed Feb 4, 2022
1 parent d213a04 commit 8da6a2c
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 2 deletions.
1 change: 1 addition & 0 deletions EarthGardener/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package team.gdsc.earthgardener.presentation.home
import android.annotation.SuppressLint
import android.os.Bundle
import android.view.View
import androidx.core.content.ContextCompat
import androidx.core.content.res.ResourcesCompat.getDrawable
import org.koin.androidx.viewmodel.ext.android.sharedViewModel
import team.gdsc.earthgardener.R
import team.gdsc.earthgardener.databinding.FragmentHomeBinding
Expand Down Expand Up @@ -59,6 +61,9 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>(R.layout.fragment_home) {
setTreeExp(treeExp, treeLevel)
setTreeTotalSum(treeTotalSum)
setTreeMonthlySum(treeMonthlySum)

setTreeDrawableByTreeLevel(treeLevel)
setProgressBarByTreeExp(treeExp, treeLevel)
}

private fun setTreeName(treeName: String) {
Expand All @@ -78,7 +83,9 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>(R.layout.fragment_home) {
3 -> 2000
4 -> 2500
5 -> 3000
else -> { throw Exception() }
else -> {
throw Exception()
}
}
binding.tvTreeExp.text = "$treeExp/$maxExp"
}
Expand All @@ -90,4 +97,64 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>(R.layout.fragment_home) {
private fun setTreeMonthlySum(treeMonthlySum: Int) {
binding.tvTreeMonthlyCount.text = "$treeMonthlySum"
}

private fun setTreeDrawableByTreeLevel(treeLevel: Int) {
when (treeLevel) {
1 -> binding.ivTree.setImageDrawable(
ContextCompat.getDrawable(
context!!,
R.drawable.img_tree_level_1
)
)
2 -> binding.ivTree.setImageDrawable(
ContextCompat.getDrawable(
context!!,
R.drawable.img_tree_level_2
)
)
3 -> binding.ivTree.setImageDrawable(
ContextCompat.getDrawable(
context!!,
R.drawable.img_tree_level_3
)
)
4 -> binding.ivTree.setImageDrawable(
ContextCompat.getDrawable(
context!!,
R.drawable.img_tree_level_4
)
)
5 -> binding.ivTree.setImageDrawable(
ContextCompat.getDrawable(
context!!,
R.drawable.img_tree_level_5
)
)
}
}

private fun setProgressBarByTreeExp(treeExp: Int, treeLevel: Int) {
when (treeLevel) {
1 -> {
binding.pbTreeExp.max = 1000
binding.pbTreeExp.progress = treeExp
}
2 -> {
binding.pbTreeExp.max = 1500
binding.pbTreeExp.progress = treeExp
}
3 -> {
binding.pbTreeExp.max = 2000
binding.pbTreeExp.progress = treeExp
}
4 -> {
binding.pbTreeExp.max = 2500
binding.pbTreeExp.progress = treeExp
}
5 -> {
binding.pbTreeExp.max = 3000
binding.pbTreeExp.progress = treeExp
}
}
}
}
1 change: 0 additions & 1 deletion EarthGardener/app/src/main/res/layout/fragment_home.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_marginTop="18dp"
android:src="@drawable/ic_plus"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_tree_title"
Expand Down

0 comments on commit 8da6a2c

Please sign in to comment.