-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/develop' into feat/back-emojiAPI2
# Conflicts: # springboot/src/main/kotlin/com/goliath/emojihub/springboot/domain/emoji/service/EmojiService.kt
- Loading branch information
Showing
55 changed files
with
1,743 additions
and
538 deletions.
There are no files selected for viewing
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
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
4 changes: 2 additions & 2 deletions
4
android/app/src/main/java/com/goliath/emojihub/data_sources/BottomNavigationController.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
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
37 changes: 37 additions & 0 deletions
37
android/app/src/main/java/com/goliath/emojihub/data_sources/ReactionPagingSource.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,37 @@ | ||
package com.goliath.emojihub.data_sources | ||
|
||
import androidx.paging.PagingSource | ||
import androidx.paging.PagingState | ||
import com.goliath.emojihub.data_sources.api.ReactionApi | ||
import com.goliath.emojihub.models.ReactionWithEmojiDto | ||
import javax.inject.Inject | ||
|
||
class ReactionPagingSource @Inject constructor( | ||
private val api: ReactionApi, | ||
private val postId: String, | ||
private val emojiUnicode: String | ||
): PagingSource<Int, ReactionWithEmojiDto>(){ | ||
override suspend fun load(params: LoadParams<Int>): LoadResult<Int, ReactionWithEmojiDto> { | ||
val cursor = params.key ?: 1 | ||
val count = params.loadSize | ||
return try { | ||
val response: List<ReactionWithEmojiDto>? = api.fetchReactionList(postId, emojiUnicode, cursor, count).body() | ||
val data = response ?: listOf() | ||
val nextKey = if (response?.size!! < count) null else cursor + 1 //Stops infinite fetching | ||
LoadResult.Page( | ||
data = data, | ||
prevKey = if (cursor == 1) null else cursor - 1, | ||
nextKey = nextKey | ||
) | ||
} catch (exception: Exception) { | ||
LoadResult.Error(exception) | ||
} | ||
} | ||
|
||
override fun getRefreshKey(state: PagingState<Int, ReactionWithEmojiDto>): Int? { | ||
return state.anchorPosition?.let { anchorPosition -> | ||
state.closestPageToPosition(anchorPosition)?.prevKey?.plus(1) | ||
?: state.closestPageToPosition(anchorPosition)?.nextKey?.minus(1) | ||
} | ||
} | ||
} |
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
35 changes: 35 additions & 0 deletions
35
android/app/src/main/java/com/goliath/emojihub/data_sources/api/ReactionApi.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,35 @@ | ||
package com.goliath.emojihub.data_sources.api | ||
|
||
import com.goliath.emojihub.models.ReactionWithEmojiDto | ||
import retrofit2.Response | ||
import retrofit2.http.DELETE | ||
import retrofit2.http.GET | ||
import retrofit2.http.POST | ||
import retrofit2.http.Path | ||
import retrofit2.http.Query | ||
|
||
interface ReactionApi { | ||
@POST("reaction") | ||
suspend fun uploadReaction( | ||
@Query("postId") postId: String, | ||
@Query("emojiId") emojiId: String | ||
): Response<Unit> | ||
|
||
@GET("reaction") | ||
suspend fun fetchReactionList( | ||
@Query("postId") postId: String, | ||
@Query("emojiUnicode") emojiUnicode: String, | ||
@Query("index") index: Int, | ||
@Query("count") count: Int | ||
): Response<List<ReactionWithEmojiDto>> | ||
|
||
@GET("reaction") | ||
suspend fun getReactionWithId( | ||
@Path("id") id: String | ||
): Response<Unit> | ||
|
||
@DELETE("reaction") | ||
suspend fun deleteReaction( | ||
@Query("reactionId") reactionId: String | ||
): Response<Unit> | ||
} |
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
40 changes: 40 additions & 0 deletions
40
android/app/src/main/java/com/goliath/emojihub/data_sources/remote/EmojiDataSource.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,40 @@ | ||
package com.goliath.emojihub.data_sources.remote | ||
|
||
import android.content.Context | ||
import android.graphics.Bitmap | ||
import android.media.MediaMetadataRetriever | ||
import android.util.Log | ||
import dagger.hilt.android.qualifiers.ApplicationContext | ||
import java.io.File | ||
import java.io.FileOutputStream | ||
import javax.inject.Inject | ||
|
||
interface EmojiDataSource { | ||
fun createVideoThumbNail(videoFile: File): File? | ||
} | ||
class EmojiDataSourceImpl @Inject constructor( | ||
@ApplicationContext private val context: Context | ||
): EmojiDataSource { | ||
|
||
override fun createVideoThumbNail(videoFile: File): File? { | ||
val retriever = MediaMetadataRetriever() | ||
try { | ||
retriever.setDataSource(videoFile.absolutePath) | ||
val bitmap = retriever.frameAtTime | ||
|
||
bitmap?.let { | ||
val thumbnailFile = File(context.cacheDir, "thumbnail_${videoFile.name}.jpg") | ||
FileOutputStream(thumbnailFile).use { out -> | ||
bitmap.compress(Bitmap.CompressFormat.JPEG, 75, out) | ||
} | ||
Log.d("EmojiDataSource", "Thumbnail created: ${thumbnailFile.absolutePath}") | ||
return thumbnailFile | ||
} | ||
} catch (e: Exception) { | ||
Log.e("EmojiDataSource", "ERROR creating thumbnail: ${e.message?:"Unknown error"}") | ||
} finally { | ||
retriever.release() | ||
} | ||
return null | ||
} | ||
} |
Oops, something went wrong.