-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from SEONGGYU96/feature/request_matching
Feature/request matching
- Loading branch information
Showing
12 changed files
with
275 additions
and
26 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
71 changes: 71 additions & 0 deletions
71
app/src/main/java/org/sopt/santamanitto/room/manittoroom/fragment/MatchingFragment.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,71 @@ | ||
package org.sopt.santamanitto.room.manittoroom.fragment | ||
|
||
import android.os.Bundle | ||
import android.os.Handler | ||
import android.os.Looper | ||
import android.util.Log | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.fragment.app.Fragment | ||
import androidx.fragment.app.activityViewModels | ||
import androidx.lifecycle.viewModelScope | ||
import dagger.hilt.android.AndroidEntryPoint | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.launch | ||
import org.sopt.santamanitto.databinding.FragmentMatchingBinding | ||
import org.sopt.santamanitto.room.manittoroom.ManittoRoomViewModel | ||
|
||
@AndroidEntryPoint | ||
class MatchingFragment: Fragment() { | ||
|
||
companion object { | ||
private const val TAG = "MatchingFragment" | ||
private const val DELAY_MILLIS = 2000L | ||
} | ||
|
||
private lateinit var binding: FragmentMatchingBinding | ||
|
||
private val manittoRoomViewModel: ManittoRoomViewModel by activityViewModels() | ||
|
||
private var isDelayDone = false | ||
|
||
private var isInBackground = false | ||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, | ||
container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View { | ||
binding = FragmentMatchingBinding.inflate(inflater, container, false) | ||
|
||
Handler(Looper.getMainLooper()).postDelayed({ | ||
isDelayDone = true | ||
}, DELAY_MILLIS) | ||
|
||
return binding.root | ||
} | ||
|
||
override fun onResume() { | ||
super.onResume() | ||
isInBackground = false | ||
navigateMissionFragment() | ||
} | ||
|
||
override fun onPause() { | ||
super.onPause() | ||
isInBackground = true | ||
} | ||
|
||
private fun navigateMissionFragment() { | ||
Log.d(TAG, "coroutine(): start") | ||
manittoRoomViewModel.viewModelScope.launch(Dispatchers.Default) { | ||
while ((!manittoRoomViewModel.isMatched || !isDelayDone) && !isInBackground) { } | ||
if (isInBackground) { | ||
return@launch | ||
} | ||
|
||
//Todo: 미션 프래그먼트로 이동 | ||
} | ||
} | ||
} |
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
5 changes: 5 additions & 0 deletions
5
app/src/main/java/org/sopt/santamanitto/room/manittoroom/network/ManittoMatchingData.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,5 @@ | ||
package org.sopt.santamanitto.room.manittoroom.network | ||
|
||
data class ManittoMatchingData( | ||
val roomId: Int | ||
) |
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
11 changes: 11 additions & 0 deletions
11
...rc/main/java/org/sopt/santamanitto/room/manittoroom/network/ManittoRoomMatchedMissions.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,11 @@ | ||
package org.sopt.santamanitto.room.manittoroom.network | ||
|
||
import com.google.gson.annotations.SerializedName | ||
import org.sopt.santamanitto.room.data.MissionContent | ||
|
||
data class ManittoRoomMatchedMissions( | ||
@SerializedName("UserId") val userId: Int, | ||
@SerializedName("SantaUserId") val santaUserId: Int, | ||
@SerializedName("ManittoUserId") val manittoUserId: Int, | ||
@SerializedName("MyMission") val myMission: MissionContent | ||
) |
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
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,13 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
|
||
<layout> | ||
|
||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
|
||
<!-- Todo: 레이아웃 작성하기 --> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> | ||
|
||
</layout> |
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.