-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
499 additions
and
256 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
app/src/main/java/kr/co/sujungvillage_admin/RollCallActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,72 @@ | ||
package kr.co.sujungvillage_admin | ||
|
||
import android.content.Context | ||
import androidx.appcompat.app.AppCompatActivity | ||
import android.os.Bundle | ||
import android.util.Log | ||
import android.view.View | ||
import androidx.recyclerview.widget.LinearLayoutManager | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.prolificinteractive.materialcalendarview.CalendarDay | ||
import kr.co.sujungvillage_admin.adapter.RollcallAdapter | ||
import kr.co.sujungvillage_admin.data.RollcallGetListResultDTO | ||
import kr.co.sujungvillage_admin.databinding.ActivityCommWriteBinding | ||
import kr.co.sujungvillage_admin.databinding.ActivityRollCallBinding | ||
import kr.co.sujungvillage_admin.retrofit.RetrofitBuilder | ||
import retrofit2.Call | ||
import retrofit2.Callback | ||
import retrofit2.Response | ||
|
||
class RollCallActivity : AppCompatActivity() { | ||
val binding by lazy { ActivityRollCallBinding.inflate(layoutInflater) } | ||
|
||
companion object { | ||
var selectedRollcall: MutableList<Long> = mutableListOf() | ||
} | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(binding.root) | ||
|
||
// 로컬에서 토큰 불러오기 | ||
val shared = this.getSharedPreferences("SujungVillage_Admin", Context.MODE_PRIVATE) | ||
val token = shared?.getString("token", "error").toString() | ||
|
||
// 대기 중인 점호 리스트 불러오기 | ||
loadRollcallData(token) | ||
|
||
// 뒤로가기 버튼 연결 | ||
binding.btnBack.setOnClickListener{ finish() } | ||
} | ||
|
||
// 점호 신청 리스트 불러오기 함수 | ||
fun loadRollcallData(token: String) { | ||
// 점호 신청 리스트 조회 API 연결 (★★★ 대기 중인 점호 리스트로 수정하기) | ||
RetrofitBuilder.rollcallApi.rollcallGetList(token, CalendarDay.today().date.plusDays(-1).toString(), "대기").enqueue(object: Callback<List<RollcallGetListResultDTO>> { | ||
override fun onResponse(call: Call<List<RollcallGetListResultDTO>>, response: Response<List<RollcallGetListResultDTO>>) { | ||
Log.d("ROLLCALL_LIST_REQUEST", "점호 신청 리스트 조회 성공") | ||
Log.d("ROLLCALL_LIST_REQUEST", response.body().toString()) | ||
|
||
if (response.body()?.size == 0) { | ||
binding.textExist.visibility = View.VISIBLE | ||
} else { | ||
binding.textExist.visibility = View.GONE | ||
} | ||
|
||
var rollcallList: MutableList<RollcallGetListResultDTO> = mutableListOf() | ||
for (info in response.body()!!) { | ||
rollcallList.add(RollcallGetListResultDTO(info.id, info.userId, info.userName, info.dormitory, info.address, info.image, info.location, info.date, info.state)) | ||
} | ||
val adapter = RollcallAdapter() | ||
adapter.rollcallList = rollcallList | ||
binding.recycleRollcall.adapter = adapter | ||
binding.recycleRollcall.layoutManager = LinearLayoutManager(this@RollCallActivity) | ||
} | ||
|
||
override fun onFailure(call: Call<List<RollcallGetListResultDTO>>, t: Throwable) { | ||
Log.e("ROLLCALL_LIST_REQUEST", "점호 신청 리스트 조회 실패") | ||
Log.e("ROLLCALL_LIST_REQUEST", t.message.toString()) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
app/src/main/java/kr/co/sujungvillage_admin/adapter/RollcallAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package kr.co.sujungvillage_admin.adapter | ||
|
||
import android.view.LayoutInflater | ||
import android.view.ViewGroup | ||
import androidx.core.content.ContextCompat | ||
import androidx.recyclerview.widget.RecyclerView | ||
import kr.co.sujungvillage_admin.R | ||
import kr.co.sujungvillage_admin.RollCallActivity.Companion.selectedRollcall | ||
import kr.co.sujungvillage_admin.base.toBitmap | ||
import kr.co.sujungvillage_admin.data.RollcallGetListResultDTO | ||
import kr.co.sujungvillage_admin.databinding.ListitemRollcallBinding | ||
|
||
class RollcallAdapter : RecyclerView.Adapter<RollcallHolder>() { | ||
var rollcallList= mutableListOf<RollcallGetListResultDTO>() | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RollcallHolder { | ||
val binding = ListitemRollcallBinding.inflate(LayoutInflater.from(parent.context), parent, false) | ||
return RollcallHolder(binding) | ||
} | ||
|
||
override fun onBindViewHolder(holder: RollcallHolder, position: Int) { | ||
val rollcall = rollcallList.get(position) | ||
holder.setRollcall(rollcall) | ||
} | ||
|
||
override fun getItemCount(): Int { | ||
return rollcallList.size | ||
} | ||
} | ||
|
||
class RollcallHolder(val binding: ListitemRollcallBinding): RecyclerView.ViewHolder(binding.root) { | ||
fun setRollcall(rollcall: RollcallGetListResultDTO) { | ||
binding.imgRollcall.setImageBitmap(rollcall.image.toBitmap()) | ||
binding.textName.text = "이름 : ${rollcall.userName}" | ||
binding.textStudentNum.text = "학번 : ${rollcall.userId}" | ||
binding.textDormitory.text = "기숙사 : ${rollcall.dormitory} ${rollcall.address}" | ||
binding.textLocation.text = "위치 : ${rollcall.location}" | ||
|
||
// 점호를 선택한 경우 | ||
binding.root.setOnClickListener { | ||
// 이미 선택한 점호인 경우 | ||
if (selectedRollcall.contains(rollcall.id)) { | ||
selectedRollcall.remove(rollcall.id) | ||
binding.layout.setBackgroundColor(ContextCompat.getColor(itemView.context, R.color.green_200)) | ||
} | ||
// 선택되지 않은 점호인 경우 | ||
else { | ||
selectedRollcall.add(rollcall.id) | ||
binding.layout.setBackgroundColor(ContextCompat.getColor(itemView.context, R.color.green_200)) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.