Closed otcroz closed 2 years ago
// 프리퍼런스 값 바꾸기 Log.d("mobileApp", "clearAchieve!") val temp = SaveSharedPreference.getAchieve(context)!! temp[position] = true SaveSharedPreference.setAchieve(context, temp) // 라우터 연결, 업데이트 val call: Call<CompleteAchieveRes> = MyApplication.networkServiceUsers.setCheckedTrue( userID = SaveSharedPreference.getUserID(context)!!, position = position ) call?.enqueue(object : Callback<CompleteAchieveRes> { override fun onResponse(call: Call<CompleteAchieveRes>, response: Response<CompleteAchieveRes>) { if(response.isSuccessful){ Log.d("mobileApp", "$response ${response.body()}") if(response.body()!!.success){ Log.d("mobileApp", "업데이트 완료!") } } } override fun onFailure(call: Call<CompleteAchieveRes>, t: Throwable) { Log.d("mobileApp", "onFailure $t") //Toast.makeText(baseContext, "네트워크 오류 발생", Toast.LENGTH_SHORT).show() } })
private fun DisplayProgress(){ var clearCount = 0 //binding = ActivityAchieveBinding.inflate(layoutInflater) val progress = binding.pbAchieveTodo if(SaveSharedPreference.getAchieve(this)!! == null){ // 준비도 = 0 progress.progress = 0 } else{ val checkedArray = SaveSharedPreference.getAchieve(this)!! for(i in 0 until checkedArray.size){ if(checkedArray[i]) clearCount++ if(i == checkedArray.size - 1){ // 마지막 인덱스일 때 // 준비도 반영하기 val ratio = (clearCount.toFloat() / 14) Log.d("mobileApp", "$ratio") progress.progress = (ratio * 100).toInt() } } }
업적을 달성했을 때 스탬프를 찍어주는 로직
업적 준비도 = 업적 달성 횟수 / 업적 전체