Skip to content

Commit

Permalink
array.xml 내용과 유저 achieve 배열 가져와서 업적 달성 여부 반영하기
Browse files Browse the repository at this point in the history
  • Loading branch information
otcroz committed Sep 13, 2022
1 parent 21fbf58 commit 792ae9d
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 116 deletions.
1 change: 1 addition & 0 deletions SHAPEUP2022/.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
@@ -1,6 +1,7 @@
package com.example.shape_up_2022.achieve

import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
Expand Down Expand Up @@ -74,8 +75,8 @@ class AchieveFragment1 : Fragment() {
/* 업적 리사이클러 뷰 */
private fun achieveList(){
val achieveAdapter = AchieveProgressAdapter(requireContext(), addAchieveList())
binding.walkSearchRecyclerView.layoutManager = LinearLayoutManager(requireContext())
binding.walkSearchRecyclerView.adapter = achieveAdapter // data array
binding.achieveProgressRecyclerview.layoutManager = LinearLayoutManager(requireContext())
binding.achieveProgressRecyclerview.adapter = achieveAdapter // data array
}

/* 업적 목록 추가 */
Expand All @@ -88,7 +89,8 @@ class AchieveFragment1 : Fragment() {
val achieveChecked : ArrayList<Boolean> = SaveSharedPreference.getAchieve(requireContext())!! // 달성 여부

// 목록 추가
for(i in achieveArray.indices) AchieveProgress(achieveArray[i], achieveChecked[i])
for(i in achieveArray.indices) data.add(AchieveProgress(achieveArray[i], achieveChecked[i]))
Log.d("mobileApp", "$data")

return data
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import android.content.Context
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import com.example.shape_up_2022.R
import com.example.shape_up_2022.achieve.AchieveFragment1
import com.example.shape_up_2022.databinding.ItemAchieveBinding
import com.example.shape_up_2022.retrofit.myItem
Expand All @@ -20,6 +22,22 @@ class AchieveProgressAdapter(val context: Context, val datas:ArrayList<AchieveFr
val binding = (holder as ViewHolderAchieve).binding
val model = datas!![position]

// 업적 목록
binding.achieveContent.text = model.content

// 스탬프 찍기
if(model.checked) {
Glide.with(binding.root)
.load(R.drawable.ic_icon_dog_orange)
.override(30,30)
.into(binding.achieveStamp)
}
else{
Glide.with(binding.root)
.load(R.drawable.ic_icon_dog_gray)
.override(30,30)
.into(binding.achieveStamp)
}
}

override fun getItemCount(): Int {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,13 @@ class LoginActivity : AppCompatActivity() {
SaveSharedPreference.setAchieve(baseContext, response.body()!!.user.achieve) // 업적 달성 여부

// petID 프리퍼런스에 저장
if(response.body()!!.user.familyID!! != null){
if(response.body()!!.user.familyID != null){
callGetPetID(response.body()!!.user.familyID!!)
} else{
// 메인 페이지로 이동
val intent = Intent(baseContext, MainActivity::class.java)
startActivity(intent)
finish()
}

} else { // 로그인 실패 or null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ data class CompleteTestReq(val userID: String)
data class CompleteTestRes(val success: String, val message: String)

// data class
data class UserInfo(val _id: String, val name: String, val email: String, val tested: Boolean, val familyID: String, val achieve: ArrayList<Boolean>)
data class UserInfo(val _id: String, val name: String, val email: String, val tested: Boolean, val familyID: String?, val achieve: ArrayList<Boolean>)
115 changes: 4 additions & 111 deletions SHAPEUP2022/app/src/main/res/layout/achieve_fragment_1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,119 +4,12 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:context=".achieve.AchieveFragment1">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">

<!-- TODO: Update blank fragment layout -->
<LinearLayout
<!--리사이클러 뷰-->
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/achieve_progress_recyclerview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">


<!--아래 항목들은 추후 item_achieve.xml로 대체할 예정-->
<!--리사이클러 뷰-->
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/walk_search_recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="12dp"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="반려견을 입양했어요"/>
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:src="@drawable/ic_icon_dog_orange"
/>
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="12dp"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="우리가족의 반려견 호감도를 점검했어요"/>
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:src="@drawable/ic_icon_dog_orange"
/>
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="12dp"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="반려견을 쓰다듬었어요"/>
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:src="@drawable/ic_icon_dog_orange"
/>
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="12dp"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="투두리스트 100% 3일 달성"/>
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:src="@drawable/ic_icon_dog_gray"
/>
</LinearLayout>


<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="12dp"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="예산서에서 지출 항목을 추가했어요"/>
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:src="@drawable/ic_icon_dog_gray"
/>
</LinearLayout>


</LinearLayout>

</ScrollView>
android:layout_height="match_parent" />


</FrameLayout>
2 changes: 2 additions & 0 deletions SHAPEUP2022/app/src/main/res/layout/item_achieve.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
android:gravity="center"
android:orientation="horizontal">
<TextView
android:id="@+id/achieve_content"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="업적 미달성 항목"/>
<ImageView
android:id="@+id/achieve_stamp"
android:layout_width="30dp"
android:layout_height="30dp"
android:src="@drawable/ic_icon_dog_gray"
Expand Down

0 comments on commit 792ae9d

Please sign in to comment.