Skip to content

Commit

Permalink
Merge pull request #120 from INFRAcp/seungmin
Browse files Browse the repository at this point in the history
[feat] #119 Splash & My Project Apply List API Connection
  • Loading branch information
peter-j0y authored Mar 28, 2022
2 parents 7b6800b + d9508b7 commit a58e5fc
Show file tree
Hide file tree
Showing 16 changed files with 387 additions and 205 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.example.infraandroid.category.model

import com.example.infraandroid.myinfo.myideamanage.model.ResponseModifyProjectData
import retrofit2.Call
import retrofit2.http.*

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,46 +57,7 @@ class LoginFragment : BaseFragment<FragmentLoginBinding>(R.layout.fragment_login
// // Automatically sign in when exactly one credential is retrieved.
// .setAutoSelectEnabled(true)
// .build()
if(InfraApplication.prefs.getUserId().isNotEmpty()
and InfraApplication.prefs.getUserPW().isNotEmpty()){

val requestLoginData = RequestLoginData(
userId = InfraApplication.prefs.getUserId(),
userPw = InfraApplication.prefs.getUserPW(),
)

val call: Call<ResponseLoginData> = ServiceCreator.loginService
.postLogin(requestLoginData)

call.enqueue(object : Callback<ResponseLoginData>{
override fun onResponse(
call: Call<ResponseLoginData>,
response: Response<ResponseLoginData>
) {
if(response.isSuccessful){
val code = response.body()?.code
when(code){
1000 -> {
InfraApplication.prefs.setString("jwt", response.body()?.result?.jwt.toString())
InfraApplication.prefs.setString("refreshToken", response.body()?.result?.refreshToken.toString())
InfraApplication.prefs.setString("userId", response.body()?.result?.userId.toString())
InfraApplication.prefs.setString("userNickName", response.body()?.result?.userNickName.toString())
Toast.makeText(requireActivity(),"요청에 성공하셨습니다.", Toast.LENGTH_SHORT).show()
// 로그인 버튼을 누르면 home_fragment로 이동
findNavController().navigate(R.id.action_login_fragment_to_home_fragment)
}
2001 -> {Toast.makeText(requireActivity(),"id가 비어있습니다.", Toast.LENGTH_SHORT).show()}
3014 -> {Toast.makeText(requireActivity(),"없는 아이디거나 비밀번호가 틀렸습니다.", Toast.LENGTH_SHORT).show()}
4000 -> {Toast.makeText(requireActivity(),"데이터베이스 연결에 실패하였습니다.", Toast.LENGTH_SHORT).show()}
}
}
}

override fun onFailure(call: Call<ResponseLoginData>, t: Throwable) {
Log.e("login_server_test", "fail")
}
})
}
}

override fun FragmentLoginBinding.onViewCreated(){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.example.infraandroid.category.model.ResponseLookUpAllProjectData
import retrofit2.Call
import retrofit2.http.GET
import retrofit2.http.Header
import retrofit2.http.PATCH
import retrofit2.http.Query

interface MyProjectService {
Expand All @@ -13,4 +14,18 @@ interface MyProjectService {
@Header("X-REFRESH-TOKEN") refreshToken: Int,
@Query("user_id") userId : String
): Call<ResponseMyProjectListData>

@PATCH("/project/modify")
fun modifyProject(
@Header("X-ACCESS-TOKEN") jwt: String,
@Header("X-REFRESH-TOKEN") refreshToken: Int
): Call<ResponseModifyProjectData>

@GET("/project/apply-list?")
fun viewProjectApply(
@Header("X-ACCESS-TOKEN") jwt: String,
@Header("X-REFRESH-TOKEN") refreshToken: Int,
@Query("user_id") userId: String,
@Query("pj_num") pjNum: Int?
): Call<ResponseViewProjectApplyData>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.example.infraandroid.myinfo.myideamanage.model

data class ResponseModifyProjectData(
val code: Int,
val isSuccess: Boolean,
val message: String,
val result: Result
){
data class Result(
val pj_string: String
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.example.infraandroid.myinfo.myideamanage.model

data class ResponseViewProjectApplyData(
val code: Int,
val isSuccess: Boolean,
val message: String,
val result: ArrayList<Result>
){
data class Result(
val pj_inviteStatus: String,
val user_id: String,
val user_nickname: String,
val user_prphoto: String,
val user_grade: String
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ import com.example.infraandroid.databinding.ItemTeamMemberApplicationRecyclervie
import com.example.infraandroid.myinfo.myideamanage.view.WarningAcceptDialog
import com.example.infraandroid.myinfo.myideamanage.view.WarningRejectDialog
import com.example.infraandroid.myinfo.myideamanage.model.MyIdeaMemberApplyManageInfo
import com.example.infraandroid.myinfo.myideamanage.model.ResponseViewProjectApplyData
import com.example.infraandroid.myinfo.myinfomodify.view.MyInfoPhotoMoreMenuBottomSheetFragment

//fragmentManager: FragmentManager
class MyIdeaMemberApplyAdapter(): RecyclerView.Adapter<RecyclerView.ViewHolder>() {
val teamMemberAppliList = mutableListOf<MyIdeaMemberApplyManageInfo>()
var teamMemberApplyList = mutableListOf<ResponseViewProjectApplyData.Result>()
private lateinit var context: Context
//private var mFragmentManager: FragmentManager

Expand All @@ -26,29 +27,28 @@ class MyIdeaMemberApplyAdapter(): RecyclerView.Adapter<RecyclerView.ViewHolder>(
false
)
context = parent.context
return TeamMemberAppliViewHolder(binding)
return TeamMemberApplyViewHolder(binding)
}

override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
(holder as TeamMemberAppliViewHolder).onBind(teamMemberAppliList[position])
(holder as TeamMemberApplyViewHolder).onBind(teamMemberApplyList[position])
}

override fun getItemCount(): Int = teamMemberAppliList.size
override fun getItemCount(): Int = teamMemberApplyList.size

inner class TeamMemberAppliViewHolder(
inner class TeamMemberApplyViewHolder(
private val binding: ItemTeamMemberApplicationRecyclerviewBinding
): RecyclerView.ViewHolder(binding.root){
fun onBind(myIdeaMemberApplyManageInfo: MyIdeaMemberApplyManageInfo){
binding.teamMemberNameTv.text = myIdeaMemberApplyManageInfo.name
//binding.teamMemberProfileIv.setImageResource(teamMemberApplicationInfo.profileImg)
fun onBind(myIdeaMemberApplyManageInfo: ResponseViewProjectApplyData.Result){

//팀원 프로필 클릭시 팀원 소개 페이지 바텀싵
//bottom sheet layout 설정
val bottomSheetDialogFragment = MyInfoPhotoMoreMenuBottomSheetFragment()
binding.teamMemberProfileConstraintLayout.setOnClickListener {
//bottomSheetDialogFragment.show(getFragmentManager() , "TAG")
//bottomSheetDialogFragment.show(mFragmentManager, bottomSheetDialogFragment.tag)
}
// //bottom sheet layout 설정
// val bottomSheetDialogFragment = MyInfoPhotoMoreMenuBottomSheetFragment()
// binding.teamMemberProfileConstraintLayout.setOnClickListener {
// //bottomSheetDialogFragment.show(getFragmentManager() , "TAG")
// //bottomSheetDialogFragment.show(mFragmentManager, bottomSheetDialogFragment.tag)
// }

binding.applyPerson = myIdeaMemberApplyManageInfo

//수락하기 버튼 클릭시
binding.teamMemberApplicationAcceptBoxIv.setOnClickListener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,46 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModelProvider
import com.example.infraandroid.R
import com.example.infraandroid.databinding.FragmentTeamMemberBinding
import com.example.infraandroid.myinfo.myideamanage.model.MyIdeaMemberManageInfo
import com.example.infraandroid.myinfo.myideamanage.model.MyIdeaMemberApplyManageInfo
import com.example.infraandroid.myinfo.myideamanage.model.MyProjectViewModel
import com.example.infraandroid.myinfo.myideamanage.model.ResponseViewProjectApplyData
import com.example.infraandroid.myinfo.myideamanage.view.adapter.MyIdeaMemberApplyAdapter
import com.example.infraandroid.myinfo.teammembereval.view.adapter.TeamMemberAdapter
import com.example.infraandroid.util.BaseFragment
import com.example.infraandroid.util.InfraApplication
import com.example.infraandroid.util.ServiceCreator
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response

// 내 정보 > 내 아이디어 탭 레이아웃의 팀원 탭
class MyIdeaMemberFragment : Fragment() {
private var mBinding : FragmentTeamMemberBinding? = null
//private lateinit var mFragmentManager: FragmentManager
private val TeamMemberAdapter = TeamMemberAdapter()
private val TeamMemberAppliAdapter = MyIdeaMemberApplyAdapter()
class MyIdeaMemberFragment : BaseFragment<FragmentTeamMemberBinding>(R.layout.fragment_team_member) {

private lateinit var viewModel : MyProjectViewModel

private val teamMemberAdapter = TeamMemberAdapter()
private val teamMemberApplyAdapter = MyIdeaMemberApplyAdapter()
private val teamMemberInfo = mutableListOf<MyIdeaMemberManageInfo>()
private val teamMemberApplicationInfo = mutableListOf<MyIdeaMemberApplyManageInfo>()

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
val binding = FragmentTeamMemberBinding.inflate(inflater, container, false)
mBinding = binding
return mBinding?.root
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

activity?.run{
viewModel = ViewModelProvider(this, ViewModelProvider.NewInstanceFactory())
.get(MyProjectViewModel::class.java)
}
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
override fun FragmentTeamMemberBinding.onCreateView(){

}

override fun FragmentTeamMemberBinding.onViewCreated() {

// //팀원 관리 어뎁터 연결
// mBinding?.teamMemberManagementRecyclerview?.adapter = TeamMemberAdapter
Expand All @@ -41,15 +54,36 @@ class MyIdeaMemberFragment : Fragment() {
// TeamMemberAdapter.notifyDataSetChanged()

//신청 관리 어뎁터 연결
mBinding?.applicationManagementRecyclerview?.adapter = TeamMemberAppliAdapter
val tempDataAppli = MyIdeaMemberApplyManageInfo(3,"나받아줘")
teamMemberApplicationInfo.add(tempDataAppli)
TeamMemberAppliAdapter.teamMemberAppliList.addAll(teamMemberApplicationInfo)
TeamMemberAppliAdapter.notifyDataSetChanged()
}
binding.applicationManagementRecyclerview.adapter = teamMemberApplyAdapter
val call : Call<ResponseViewProjectApplyData> = ServiceCreator.myProjectService
.viewProjectApply(InfraApplication.prefs.getString("jwt", "null"), InfraApplication.prefs.getString("refreshToken", "null").toInt(),
InfraApplication.prefs.getString("userId", "null"), viewModel.currentObservingProjectNum.value)

call.enqueue(object: Callback<ResponseViewProjectApplyData> {
override fun onResponse(
call: Call<ResponseViewProjectApplyData>,
response: Response<ResponseViewProjectApplyData>
) {
if(response.isSuccessful){
val body = response.body()
if(body!=null){
when(body.code){
1000->{
val data = body.result
if(data!=null){
teamMemberApplyAdapter.teamMemberApplyList = data
}
teamMemberApplyAdapter.notifyDataSetChanged()
}
}
}
}
}

override fun onFailure(call: Call<ResponseViewProjectApplyData>, t: Throwable) {
TODO("Not yet implemented")
}

override fun onDestroyView() {
mBinding = null
super.onDestroyView()
})
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
package com.example.infraandroid.myinfo.scrap.view

import android.util.Log
import android.widget.Toast
import androidx.navigation.fragment.findNavController
import com.example.infraandroid.R
import com.example.infraandroid.databinding.FragmentScrapBinding
import com.example.infraandroid.id.model.RequestLoginData
import com.example.infraandroid.id.model.ResponseLoginData
import com.example.infraandroid.util.BaseFragment
import com.example.infraandroid.util.InfraApplication
import com.example.infraandroid.util.ServiceCreator
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response

class ScrapFragment : BaseFragment<FragmentScrapBinding>(R.layout.fragment_scrap){
override fun FragmentScrapBinding.onCreateView(){

}

override fun FragmentScrapBinding.onViewCreated(){


}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ object ServiceCreator {
val sendSMSService : SMSService = retrofit.create(SMSService::class.java)
val profileViewService : ProfileViewService = retrofit.create(ProfileViewService::class.java)
val createProjectService : CreateProjectService = retrofit.create(CreateProjectService::class.java)
val applyProjectService : ApplyProjectService = retrofit.create(ApplyProjectService::class.java)
val lookUpAllProjectService : LookUpAllProjectService = retrofit.create(LookUpAllProjectService::class.java)
val myinfoService : MyInfoService = retrofit.create(MyInfoService::class.java)
val projectService : ProjectService = retrofit.create(ProjectService::class.java)
val myProjectService : MyProjectService = retrofit.create(MyProjectService::class.java)
Expand Down
68 changes: 68 additions & 0 deletions app/src/main/java/com/example/infraandroid/util/SplashFragment.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package com.example.infraandroid.util

import android.util.Log
import android.widget.Toast
import androidx.fragment.app.Fragment
import androidx.navigation.fragment.findNavController
import com.example.infraandroid.R
import com.example.infraandroid.databinding.FragmentSplashBinding
import com.example.infraandroid.id.model.RequestLoginData
import com.example.infraandroid.id.model.ResponseLoginData
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response

class SplashFragment : BaseFragment<FragmentSplashBinding>(R.layout.fragment_splash){
override fun FragmentSplashBinding.onCreateView() {

}

override fun FragmentSplashBinding.onViewCreated(){
if(InfraApplication.prefs.getUserId().isNotEmpty()
and InfraApplication.prefs.getUserPW().isNotEmpty()){

val requestLoginData = RequestLoginData(
userId = InfraApplication.prefs.getUserId(),
userPw = InfraApplication.prefs.getUserPW(),
)

val call: Call<ResponseLoginData> = ServiceCreator.loginService
.postLogin(requestLoginData)

call.enqueue(object : Callback<ResponseLoginData> {
override fun onResponse(
call: Call<ResponseLoginData>,
response: Response<ResponseLoginData>
) {
if(response.isSuccessful){
when(response.body()?.code){
1000 -> {
InfraApplication.prefs.setString("jwt", response.body()?.result?.jwt.toString())
InfraApplication.prefs.setString("refreshToken", response.body()?.result?.refreshToken.toString())
InfraApplication.prefs.setString("userId", response.body()?.result?.userId.toString())
InfraApplication.prefs.setString("userNickName", response.body()?.result?.userNickName.toString())
Toast.makeText(requireActivity(),"요청에 성공하셨습니다.", Toast.LENGTH_SHORT).show()
// 로그인 버튼을 누르면 home_fragment로 이동
findNavController().navigate(R.id.action_splashFragment_to_home_fragment)
}
2001 -> {
Toast.makeText(requireActivity(),"id가 비어있습니다.", Toast.LENGTH_SHORT).show()}
3014 -> {
Toast.makeText(requireActivity(),"없는 아이디거나 비밀번호가 틀렸습니다.", Toast.LENGTH_SHORT).show()}
4000 -> {
Toast.makeText(requireActivity(),"데이터베이스 연결에 실패하였습니다.", Toast.LENGTH_SHORT).show()}
}
}
}

override fun onFailure(call: Call<ResponseLoginData>, t: Throwable) {
Log.e("login_server_test", "fail")
}
})
}

else{
findNavController().navigate(R.id.action_splashFragment_to_login_fragment)
}
}
}
Binary file added app/src/main/res/drawable/splash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions app/src/main/res/layout/fragment_my_info_modify.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<variable
name="MyInfoModify"
type="com.example.infraandroid.myinfo.myinfomodify.model.ResponseViewMyInfoData.Result" />
<!-- <variable-->
<!-- name="MyInfoModify"-->
<!-- type="com.example.infraandroid.myinfo.myinfomodify.model.ResponseViewMyInfoData.Result" />-->
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
Expand Down
Loading

0 comments on commit a58e5fc

Please sign in to comment.