-
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
33 changed files
with
570 additions
and
210 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
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 |
---|---|---|
@@ -1,24 +1,17 @@ | ||
package com.mashup.api.notice | ||
|
||
import com.mashup.model.Notice | ||
import com.mashup.model.VoteStatus | ||
import com.mashup.api.notice.request.AttendanceUpdateRequest | ||
import com.mashup.repository.notice.remote.response.NoticeListResponse | ||
import io.reactivex.Completable | ||
import io.reactivex.Flowable | ||
import retrofit2.http.* | ||
|
||
interface NoticeService { | ||
|
||
@GET("api/v1/notice/list?size=10") | ||
fun getNotice(@Query("type") type: String, @Query("page") page: Int): Flowable<List<Notice>> | ||
|
||
|
||
@GET("api/v1/notice/active/list?type=public&size=10") | ||
fun getRecentPublicNotice(): Flowable<List<Notice>> | ||
|
||
@GET("api/notices/") | ||
fun getNoticeList(): Flowable<List<Notice>> | ||
fun getNoticeList(): Flowable<NoticeListResponse> | ||
|
||
@PATCH("api/notices/attendances/{id}/") | ||
fun updateNoticeAttendance(@Path("id") userId: Int, @Body voteStatus: VoteStatus): Completable | ||
fun updateNoticeAttendance(@Header("Authorization") token: String, @Path("id") noticeId: Int, @Body attendanceUpdateRequest: AttendanceUpdateRequest): Completable | ||
|
||
} |
8 changes: 8 additions & 0 deletions
8
app/src/main/java/com/mashup/api/notice/request/AttendanceUpdateRequest.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,8 @@ | ||
package com.mashup.api.notice.request | ||
|
||
import com.google.gson.annotations.SerializedName | ||
import com.mashup.model.VoteStatus | ||
|
||
data class AttendanceUpdateRequest( | ||
@SerializedName("vote") val voteStatus: VoteStatus | ||
) |
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,19 +1,14 @@ | ||
package com.mashup.api.user | ||
|
||
import com.mashup.api.user.request.UserLoginRequest | ||
import com.mashup.api.user.request.UserRegisterRequest | ||
import com.mashup.model.User | ||
import com.mashup.api.user.request.AuthTokenRequest | ||
import com.mashup.model.AuthToken | ||
import io.reactivex.Flowable | ||
import retrofit2.http.Body | ||
import retrofit2.http.POST | ||
|
||
interface UserService { | ||
|
||
@POST("api/v1/register/member") | ||
fun register(@Body request: UserRegisterRequest): Flowable<User> | ||
|
||
|
||
@POST("api/v1/login") | ||
fun login(@Body request: UserLoginRequest): Flowable<User> | ||
@POST("api/members/auth-token/") | ||
fun getAuthToken(@Body request: AuthTokenRequest): Flowable<AuthToken> | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
app/src/main/java/com/mashup/api/user/request/AuthTokenRequest.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,9 @@ | ||
package com.mashup.api.user.request | ||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
data class AuthTokenRequest( | ||
@SerializedName("username") val name: String, | ||
@SerializedName("email") val email: String, | ||
@SerializedName("password") val password: String | ||
) |
8 changes: 0 additions & 8 deletions
8
app/src/main/java/com/mashup/api/user/request/UserLoginRequest.kt
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
app/src/main/java/com/mashup/api/user/request/UserRegisterRequest.kt
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,18 @@ | ||
package com.mashup.app.login | ||
|
||
import android.os.Bundle | ||
import androidx.appcompat.app.AppCompatActivity | ||
import com.mashup.R | ||
|
||
class LoginActivity : AppCompatActivity() { | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.login_activity) | ||
if (savedInstanceState == null) { | ||
supportFragmentManager.beginTransaction() | ||
.replace(R.id.container, LoginFragment.newInstance()) | ||
.commitNow() | ||
} | ||
} | ||
} |
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,56 @@ | ||
package com.mashup.app.login | ||
|
||
import android.content.Intent | ||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.fragment.app.Fragment | ||
import com.google.android.material.snackbar.Snackbar | ||
import com.mashup.app.notices.NoticesActivity | ||
import com.mashup.databinding.LoginFragmentBinding | ||
import com.mashup.util.EventObserver | ||
import com.mashup.util.setupSnackbar | ||
import org.koin.androidx.viewmodel.ext.android.viewModel | ||
|
||
class LoginFragment : Fragment() { | ||
|
||
companion object { | ||
fun newInstance() = LoginFragment() | ||
} | ||
|
||
private val viewModel: LoginViewModel by viewModel() | ||
private lateinit var viewDataBinding: LoginFragmentBinding | ||
|
||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View { | ||
viewDataBinding = LoginFragmentBinding.inflate(inflater, container, false).apply { | ||
viewmodel = viewModel | ||
} | ||
return viewDataBinding.root | ||
} | ||
|
||
override fun onActivityCreated(savedInstanceState: Bundle?) { | ||
super.onActivityCreated(savedInstanceState) | ||
viewDataBinding.setLifecycleOwner(this.viewLifecycleOwner) | ||
setupSnackbar() | ||
setupEventObserver() | ||
} | ||
|
||
private fun setupSnackbar() { | ||
view?.setupSnackbar(this, viewModel.snackbarText, Snackbar.LENGTH_SHORT) | ||
} | ||
|
||
private fun setupEventObserver() { | ||
viewModel.isLoginSuccess.observe(this, EventObserver { | ||
if (it) { | ||
activity?.finishAffinity() | ||
val intent = Intent(this.context, NoticesActivity::class.java) | ||
startActivity(intent) | ||
} | ||
}) | ||
} | ||
} |
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,8 @@ | ||
package com.mashup.app.login | ||
|
||
import org.koin.androidx.viewmodel.dsl.viewModel | ||
import org.koin.dsl.module | ||
|
||
val LoginModule = module { | ||
viewModel { LoginViewModel(get()) } | ||
} |
Oops, something went wrong.