Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
f184421
Create post card
Apr 15, 2023
9c59eae
Create bottom navigation
Apr 16, 2023
9e110a8
Merge remote-tracking branch 'origin/feature/1.1.0-create_bottom_navi…
Apr 16, 2023
c82e4da
Merge branch 'develop' into feature/1.1.0-create_bottom_navigation
Cavc13 Apr 16, 2023
9f44533
Merge pull request #4 from Cavc13/feature/1.1.0-create_bottom_navigation
Cavc13 Apr 16, 2023
52d3989
Merge remote-tracking branch 'origin/develop' into develop
Apr 16, 2023
d75f041
Create FAB & SnackBar
Apr 16, 2023
d3b33ba
Merge pull request #5 from Cavc13/feature/1.2.0-create_FAB_&_SnackBar
Cavc13 Apr 16, 2023
000e9a7
Create ViewModel
Apr 22, 2023
729a867
Merge pull request #6 from Cavc13/feature/1.3.0-create_view_model
Cavc13 Apr 22, 2023
12ee8b2
Learned delegates
Apr 22, 2023
d377737
Merge pull request #7 from Cavc13/feature/1.3.1-delegates
Cavc13 Apr 22, 2023
014a985
Create callbacks
Apr 22, 2023
f0340c3
Merge pull request #8 from Cavc13/feature/1.4.0-create_vk_viewmodel
Cavc13 Apr 22, 2023
bdb26e5
Add MainViewModel
Apr 22, 2023
057ba28
Merge pull request #9 from Cavc13/feature/1.4.1-add_view_model
Cavc13 Apr 22, 2023
52e90f3
Create LazyColumn
Apr 23, 2023
48fc147
Merge pull request #10 from Cavc13/feature/1.5.0-create_lazy_column
Cavc13 Apr 23, 2023
49ab876
Create compose navigation and CommentScreen
Apr 24, 2023
c9da6a2
Merge pull request #11 from Cavc13/feature/1.6.0-compose_navigation
Cavc13 Apr 24, 2023
365a1af
Create HomeScreenState
May 3, 2023
9a4d687
Navigation
May 3, 2023
42b3a56
Merge pull request #12 from Cavc13/feature/1.8.0-navigation
Cavc13 May 3, 2023
15e1e2d
Split MainViewModel
May 3, 2023
83998f6
Merge pull request #13 from Cavc13/feature/1.8.1-split_mainViewModel
Cavc13 May 3, 2023
584b2f6
Share param to ViewModel
May 3, 2023
ab630aa
Merge pull request #14 from Cavc13/feature/1.8.2-share_param_to_viewM…
Cavc13 May 3, 2023
9367e00
Nested Graph Navigation
May 3, 2023
85544f1
Merge pull request #15 from Cavc13/feature/1.8.3-Nested_Graph_Navigation
Cavc13 May 3, 2023
90d4f2f
Nested Graph Navigation
May 4, 2023
ae132a5
Merge pull request #16 from Cavc13/feature/1.8.4-fix_navigation_bugs
Cavc13 May 4, 2023
fa63924
Nested Graph Navigation
May 4, 2023
212e95e
Merge pull request #17 from Cavc13/feature/1.8.5-JetpackNavigation_sh…
Cavc13 May 4, 2023
15235d3
Init VK API
Sep 25, 2023
5f87a9a
Merge pull request #18 from Cavc13/feature/2.0.0-_Init_VK_API
Cavc13 Sep 25, 2023
dcb13a5
Scroll next posts
Sep 30, 2023
6d97773
Merge pull request #19 from Cavc13/feature/2.0.1-Scroll_next_posts
Cavc13 Sep 30, 2023
7838619
Delete post from wall
Sep 30, 2023
33b4e13
Merge pull request #20 from Cavc13/feature/2.0.2-Ignore-Item
Cavc13 Sep 30, 2023
59be286
Start progress bar
Sep 30, 2023
e40a986
Merge pull request #21 from Cavc13/feature/2.0.3-Start-progress-bar
Cavc13 Sep 30, 2023
b4ebdea
Add wall comments
Oct 1, 2023
9bd378c
Merge pull request #22 from Cavc13/feature/2.1.0-Comments
Cavc13 Oct 1, 2023
9c32cd5
Add wall comments
Oct 4, 2023
e8f7a42
Merge pull request #23 from Cavc13/feature/3.0.1-Started-flow
Cavc13 Oct 4, 2023
e501937
Add wall comments
Oct 5, 2023
d549fcb
Merge pull request #24 from Cavc13/features/3.0.2-Exception_handling
Cavc13 Oct 5, 2023
b5d3158
Add Flow in MainViewModel
Oct 5, 2023
6014db4
Merge pull request #25 from Cavc13/feature/3.0.3-MainViewModel-Flow
Cavc13 Oct 5, 2023
b4c621c
Start Clean Architecture
Oct 5, 2023
4288658
Merge pull request #26 from Cavc13/features/4.0.1-Start-Clean-Archite…
Cavc13 Oct 5, 2023
5982f27
Start Clean Architecture
Oct 7, 2023
ccd2080
Merge pull request #27 from Cavc13/feature/4.0.2-DI
Cavc13 Oct 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions .idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 37 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 24 additions & 7 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'kotlin-parcelize'
id 'kotlin-kapt'
}

android {
namespace 'com.snusnu.vkapicompose'
compileSdk 32
compileSdk 33

defaultConfig {
applicationId "com.snusnu.vkapicompose"
minSdk 21
targetSdk 32
targetSdk 33
versionCode 1
versionName "1.0"

Expand All @@ -37,7 +39,7 @@ android {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion '1.1.1'
kotlinCompilerExtensionVersion '1.4.1'
}
packagingOptions {
resources {
Expand All @@ -48,16 +50,31 @@ android {

dependencies {

implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
implementation 'androidx.activity:activity-compose:1.3.1'
implementation 'androidx.core:core-ktx:1.10.0'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.1'
implementation 'androidx.activity:activity-compose:1.7.1'
implementation "androidx.compose.ui:ui:$compose_ui_version"
implementation "androidx.compose.ui:ui-tooling-preview:$compose_ui_version"
implementation 'androidx.compose.material:material:1.1.1'
implementation 'androidx.compose.material:material:1.4.2'
implementation 'androidx.compose.runtime:runtime-livedata:1.4.2'
implementation 'androidx.navigation:navigation-compose:2.5.3'
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:2.6.1"
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_ui_version"
debugImplementation "androidx.compose.ui:ui-tooling:$compose_ui_version"
debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_ui_version"
implementation "com.google.code.gson:gson:2.10"
implementation "io.coil-kt:coil-compose:2.3.0"
implementation "com.vk:android-sdk-core:4.0.1"
implementation "com.vk:android-sdk-api:4.0.1"

//retrofit
implementation "com.squareup.retrofit2:converter-gson:2.9.0"
implementation "com.squareup.okhttp3:logging-interceptor:4.10.0"

//Dagger2
implementation 'com.google.dagger:dagger:2.44.2'
kapt 'com.google.dagger:dagger-compiler:2.43.2'
}
6 changes: 5 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,22 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.INTERNET"/>

<application
android:name=".presentation.VkApplication"
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:usesCleartextTraffic="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.VKAPICompose"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:name=".presentation.main.MainActivity"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/Theme.VKAPICompose">
Expand Down
26 changes: 0 additions & 26 deletions app/src/main/java/com/snusnu/vkapicompose/MainActivity.kt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package com.snusnu.vkapicompose.data.mapper

import com.snusnu.vkapicompose.data.model.ResponseDto
import com.snusnu.vkapicompose.data.model.WallCommentsDTO
import com.snusnu.vkapicompose.data.model.WallCommentProfileDTO
import com.snusnu.vkapicompose.data.model.WallCommentContentDTO
import com.snusnu.vkapicompose.domain.entity.FeedPost
import com.snusnu.vkapicompose.domain.entity.PostComment
import com.snusnu.vkapicompose.domain.entity.StatisticItem
import com.snusnu.vkapicompose.domain.entity.StatisticType
import java.text.SimpleDateFormat
import java.util.Date
import java.util.Locale
import javax.inject.Inject
import kotlin.math.absoluteValue

class NewsFeedMapper @Inject constructor(){

fun mapResponseToPosts(responseDto: ResponseDto): List<FeedPost> {
val result = mutableListOf<FeedPost>()

val posts = responseDto.newsFeedContentDto.posts
val groups = responseDto.newsFeedContentDto.groups

posts.forEach{ post ->
val group = groups.find { it.id == post.communityId.absoluteValue } ?: return@forEach
val countLikes = post.likes?.userLikes
val feedPost = FeedPost(
id = post.id,
communityId = post.communityId,
communityName = group.name,
publicationDate = mapTimestampToDate(post.date),
communityImageUrl = group.imageUrl,
contentText = post.text,
contentImageUrl = post.attachments?.firstOrNull()?.photo?.photoUrls?.lastOrNull()?.url,
statistics = listOf(
StatisticItem(type = StatisticType.LIKES, post.likes?.count ?: 0),
StatisticItem(type = StatisticType.VIEWS, post.views?.count ?: 0),
StatisticItem(type = StatisticType.COMMENTS, post.comments?.count ?: 0),
StatisticItem(type = StatisticType.SHARES, post.reposts?.count ?: 0)
),

isLiked = if(countLikes != null ) countLikes > 0 else false
)
result.add(feedPost)
}
return result
}

fun mapWallCommentsResponseToPostComments(response: WallCommentsDTO) : List<PostComment> {
val commentsList: List<WallCommentContentDTO> = response.wallComments
val profilesList: List<WallCommentProfileDTO> = response.wallCommentProfiles
val postCommentsList = mutableListOf<PostComment>()

for(comment in commentsList) {
if (comment.textComment.isBlank()) continue
val author = profilesList.find {
it.idCommentProfile == comment.idOwnerComment
} ?: continue

val postComment = PostComment(
id = comment.id,
authorName = "${author.firstNameCommentProfile} ${author.lastNameCommentProfile}",
authorAvatarUrl = author.photoCommentProfile,
comment = comment.textComment,
publicationDate = mapTimestampToDate(comment.dateComment)
)
postCommentsList.add(postComment)
}

return postCommentsList
}

private fun mapTimestampToDate(timestamp: Long): String {
val date = Date(timestamp * 1_000)
return SimpleDateFormat("d MMMM yyyy, hh:mm", Locale.getDefault()).format(date)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.snusnu.vkapicompose.data.model

import com.google.gson.annotations.SerializedName

data class AttachmentDto(
@SerializedName("photo") val photo: PhotoDto?
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.snusnu.vkapicompose.data.model

import com.google.gson.annotations.SerializedName

data class CommentsDto(
@SerializedName("count") val count: Int
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.snusnu.vkapicompose.data.model

import com.google.gson.annotations.SerializedName

data class GroupDto(
@SerializedName("id") val id: Long,
@SerializedName("name") val name: String,
@SerializedName("photo_200") val imageUrl: String,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.snusnu.vkapicompose.data.model

import com.google.gson.annotations.SerializedName

data class LikesCountDto(
@SerializedName("likes") val count: Int
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.snusnu.vkapicompose.data.model

import com.google.gson.annotations.SerializedName

data class LikesCountResponseDto(
@SerializedName("response") val likes: LikesCountDto
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.snusnu.vkapicompose.data.model

import com.google.gson.annotations.SerializedName

data class LikesDto(
@SerializedName("count") val count: Int,
@SerializedName("user_likes") val userLikes: Int
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.snusnu.vkapicompose.data.model

import com.google.gson.annotations.SerializedName

data class NewsFeedContentDto(
@SerializedName("items") val posts: List<PostDto>,
@SerializedName("groups") val groups: List<GroupDto>,
@SerializedName("next_from") val nextFrom: String?
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.snusnu.vkapicompose.data.model

import com.google.gson.annotations.SerializedName

data class PhotoDto(
@SerializedName("sizes") val photoUrls: List<PhotoUrlDto>
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.snusnu.vkapicompose.data.model

import com.google.gson.annotations.SerializedName

class PhotoUrlDto(
@SerializedName("url") val url: String
)
15 changes: 15 additions & 0 deletions app/src/main/java/com/snusnu/vkapicompose/data/model/PostDto.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.snusnu.vkapicompose.data.model

import com.google.gson.annotations.SerializedName

data class PostDto(
@SerializedName("id") val id: Long,
@SerializedName("source_id") val communityId: Long,
@SerializedName("text") val text: String,
@SerializedName("date") val date: Long,
@SerializedName("likes") val likes: LikesDto?,
@SerializedName("comments") val comments: CommentsDto?,
@SerializedName("views") val views: ViewsDto?,
@SerializedName("reposts") val reposts: RepostsDto?,
@SerializedName("attachments") val attachments: List<AttachmentDto>?
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.snusnu.vkapicompose.data.model

import com.google.gson.annotations.SerializedName

data class RepostsDto(
@SerializedName("count") val count: Int
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.snusnu.vkapicompose.data.model

import com.google.gson.annotations.SerializedName

data class ResponseDto(
@SerializedName("response") val newsFeedContentDto: NewsFeedContentDto
)
Loading