Skip to content

Commit

Permalink
#19 업적 진행도 함수
Browse files Browse the repository at this point in the history
  • Loading branch information
otcroz committed Sep 14, 2022
1 parent ad8680d commit fa714c6
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,18 @@ class AchieveActivity : AppCompatActivity() {
/* 준비도: progressBar */
private fun DisplayProgress(){
var clearCount = 0
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")
binding.pbAchieveTodo.progress = (ratio * 100).toInt()
if(SaveSharedPreference.getAchieve(this)!! == null){
binding.pbAchieveTodo.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")
binding.pbAchieveTodo.progress = (ratio * 100).toInt()
}
}
}
}
Expand All @@ -188,7 +192,7 @@ class AchieveActivity : AppCompatActivity() {
// 라우터 연결, 업데이트
val call: Call<CompleteAchieveRes> = MyApplication.networkServiceUsers.setCheckedTrue(
userID = SaveSharedPreference.getUserID(this)!!, position = position
)
)

call?.enqueue(object : Callback<CompleteAchieveRes> {
override fun onResponse(call: Call<CompleteAchieveRes>, response: Response<CompleteAchieveRes>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class LoginActivity : AppCompatActivity() {

// petID 프리퍼런스에 저장
if(response.body()!!.user.familyID != null){
//Log.d("")
callGetPetID(response.body()!!.user.familyID!!)
} else{
// 메인 페이지로 이동
Expand Down Expand Up @@ -94,6 +95,7 @@ class LoginActivity : AppCompatActivity() {
Log.d("mobileApp", "$response ${response.body()}")
if(response.body()!!.success){
SaveSharedPreference.setPetID(baseContext, response.body()!!.petID)
Log.d("mobileApp", "${response.body()!!.petID}" )

// 메인 페이지로 이동
val intent = Intent(baseContext, MainActivity::class.java)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.example.shape_up_2022.data

import android.app.Application
import android.util.Log
import com.example.shape_up_2022.common.SaveSharedPreference
import com.example.shape_up_2022.retrofit.CompleteAchieveRes
import com.example.shape_up_2022.retrofit.MyApplication
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response

class GlobalVariableManage {

}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class MyApplication: Application() {
var client = OkHttpClient.Builder().addInterceptor(httpLoggingInterceptor()).build()

/* 서버 요청용 */
val apiserver = "http://192.168.219.113:5000/"
val apiserver = "http://192.168.197.30:5000/"
// http://ec2-13-124-250-65.ap-northeast-2.compute.amazonaws.com:5000/

var networkServiceUsers: NetworkServiceUsers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import android.util.Log
import android.view.View
import android.widget.Toast
import androidx.appcompat.app.AlertDialog
import com.example.shape_up_2022.achieve.AchieveActivity.Companion.clearAchieve
import com.example.shape_up_2022.common.MainActivity
import com.example.shape_up_2022.achieve.AchieveActivity
import com.example.shape_up_2022.common.SaveSharedPreference
import com.example.shape_up_2022.databinding.ActivitySimStartNamingBinding
import com.example.shape_up_2022.retrofit.*
Expand Down Expand Up @@ -94,7 +93,7 @@ class SimStartNamingActivity : AppCompatActivity() {
// 강아지 업적 달성 position: 0
val check = SaveSharedPreference.getAchieve(this)!![0] // 업적 달성 여부 확인
if(!check){ // 업적을 1번도 달성하지 않았었다면
clearAchieve(0) // 업적 달성 업데이트 실행
AchieveActivity().clearAchieve(0) // 업적 달성 업데이트 실행
}

}
Expand Down

0 comments on commit fa714c6

Please sign in to comment.