-
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.
Merge branch 'develop' into feature/setting-keyword
- Loading branch information
Showing
42 changed files
with
487 additions
and
1,093 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
13 changes: 0 additions & 13 deletions
13
app/src/main/java/com/dongyang/android/youdongknowme/data/remote/service/DetailService.kt
This file was deleted.
Oops, something went wrong.
23 changes: 12 additions & 11 deletions
23
app/src/main/java/com/dongyang/android/youdongknowme/data/remote/service/NoticeService.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,22 +1,23 @@ | ||
package com.dongyang.android.youdongknowme.data.remote.service | ||
|
||
import com.dongyang.android.youdongknowme.data.remote.entity.Notice | ||
import com.dongyang.android.youdongknowme.data.remote.entity.NoticeDetail | ||
import retrofit2.Response | ||
import retrofit2.http.GET | ||
import retrofit2.http.Path | ||
import retrofit2.http.Query | ||
|
||
interface NoticeService { | ||
@GET("/notice/{code}") | ||
suspend fun getList( | ||
@Path("code") code : Int | ||
) : List<Notice> | ||
|
||
@GET("/notice/{code}/search") | ||
suspend fun getSearchList( | ||
@Path("code") code : Int, | ||
@Query("keyword") keyword : String | ||
) : List<Notice> | ||
@GET("api/v1/dmu/universityNotice") | ||
suspend fun getUniversityNotice( | ||
@Query("page") page: Int, | ||
@Query("size") size: Int | ||
): List<Notice> | ||
|
||
@GET("api/v1/dmu/departmentNotice/{department}") | ||
suspend fun getDepartmentNotice( | ||
@Path("department") department: String, | ||
@Query("page") page: Int, | ||
@Query("size") size: Int | ||
): List<Notice> | ||
} | ||
|
22 changes: 0 additions & 22 deletions
22
app/src/main/java/com/dongyang/android/youdongknowme/data/repository/DetailRepository.kt
This file was deleted.
Oops, something went wrong.
36 changes: 10 additions & 26 deletions
36
app/src/main/java/com/dongyang/android/youdongknowme/data/repository/NoticeRepository.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,54 +1,38 @@ | ||
package com.dongyang.android.youdongknowme.data.repository | ||
|
||
import com.dongyang.android.youdongknowme.data.local.SharedPreference | ||
import com.dongyang.android.youdongknowme.data.local.dao.AlarmDao | ||
import com.dongyang.android.youdongknowme.data.remote.entity.Notice | ||
import com.dongyang.android.youdongknowme.data.remote.service.NoticeService | ||
import com.dongyang.android.youdongknowme.standard.network.ErrorResponseHandler | ||
import com.dongyang.android.youdongknowme.standard.network.NetworkResult | ||
import com.dongyang.android.youdongknowme.standard.network.RetrofitObject | ||
import kotlinx.coroutines.flow.Flow | ||
import retrofit2.Response | ||
|
||
class NoticeRepository( | ||
private val alarmDao: AlarmDao, | ||
private val errorResponseHandler: ErrorResponseHandler | ||
) { | ||
suspend fun fetchAllNotices(): NetworkResult<Map<String,List<Notice>>> { | ||
suspend fun fetchUniversityNotices(page: Int): NetworkResult<List<Notice>> { | ||
return try { | ||
val departNotices = RetrofitObject.getNetwork().create(NoticeService::class.java).getList(SharedPreference.getCode()) | ||
val schoolNotices = RetrofitObject.getNetwork().create(NoticeService::class.java).getList(CODE.SCHOOL_CODE) | ||
val universityNotices = RetrofitObject.getNetwork().create(NoticeService::class.java) | ||
.getUniversityNotice(page, DEFAULT_SIZE) | ||
|
||
val result : Map<String,List<Notice>> = mapOf("school" to schoolNotices, "depart" to departNotices) | ||
|
||
NetworkResult.Success(result) | ||
NetworkResult.Success(universityNotices) | ||
} catch (exception: Exception) { | ||
val error = errorResponseHandler.getError(exception) | ||
NetworkResult.Error(error) | ||
} | ||
} | ||
|
||
suspend fun fetchNotices(code: Int): NetworkResult<List<Notice>> { | ||
suspend fun fetchDepartmentNotices(department: String, page: Int): NetworkResult<List<Notice>> { | ||
return try { | ||
val response = RetrofitObject.getNetwork().create(NoticeService::class.java).getList(code) | ||
NetworkResult.Success(response) | ||
val departmentNotices = RetrofitObject.getNetwork().create(NoticeService::class.java) | ||
.getDepartmentNotice(department, page, DEFAULT_SIZE) | ||
NetworkResult.Success(departmentNotices) | ||
} catch (exception: Exception) { | ||
val error = errorResponseHandler.getError(exception) | ||
NetworkResult.Error(error) | ||
} | ||
} | ||
|
||
suspend fun fetchSearchNotices(code: Int, keyword: String): NetworkResult<List<Notice>> { | ||
return try { | ||
val response = RetrofitObject.getNetwork().create(NoticeService::class.java).getSearchList(code, keyword) | ||
NetworkResult.Success(response) | ||
} catch (exception: Exception) { | ||
val error = errorResponseHandler.getError(exception) | ||
NetworkResult.Error(error) | ||
} | ||
companion object { | ||
private const val DEFAULT_SIZE = 20 | ||
} | ||
|
||
fun getUnVisitedAlarmCount(): Flow<Int> = alarmDao.getUnVisitedAlarmCount() | ||
|
||
fun getDepartmentCode(): Int = SharedPreference.getCode() | ||
} |
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
57 changes: 0 additions & 57 deletions
57
app/src/main/java/com/dongyang/android/youdongknowme/ui/adapter/AlarmAdapter.kt
This file was deleted.
Oops, something went wrong.
48 changes: 0 additions & 48 deletions
48
app/src/main/java/com/dongyang/android/youdongknowme/ui/adapter/FileAdapter.kt
This file was deleted.
Oops, something went wrong.
47 changes: 0 additions & 47 deletions
47
app/src/main/java/com/dongyang/android/youdongknowme/ui/adapter/ImageAdapter.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.