diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts index 67369eea..15d423aa 100644 --- a/android/app/build.gradle.kts +++ b/android/app/build.gradle.kts @@ -25,7 +25,11 @@ android { val properties = Properties() properties.load(FileInputStream(rootProject.file("local.properties"))) - buildConfigField("String", "GOOGLE_WEB_CLIENT_ID", properties.getProperty("google_web_client_id")) + buildConfigField( + "String", + "GOOGLE_WEB_CLIENT_ID", + properties.getProperty("google_web_client_id"), + ) } buildTypes { diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index ef1877ad..29c7f3e5 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -15,7 +15,7 @@ android:theme="@style/Theme.Pengcook" tools:targetApi="31"> diff --git a/android/app/src/main/java/net/pengcook/android/data/FeedPagingSource.kt b/android/app/src/main/java/net/pengcook/android/data/datasource/FeedPagingSource.kt similarity index 90% rename from android/app/src/main/java/net/pengcook/android/data/FeedPagingSource.kt rename to android/app/src/main/java/net/pengcook/android/data/datasource/FeedPagingSource.kt index bd612fbb..1414d146 100644 --- a/android/app/src/main/java/net/pengcook/android/data/FeedPagingSource.kt +++ b/android/app/src/main/java/net/pengcook/android/data/datasource/FeedPagingSource.kt @@ -1,8 +1,8 @@ -package net.pengcook.android.data +package net.pengcook.android.data.datasource import androidx.paging.PagingSource import androidx.paging.PagingState -import net.pengcook.android.model.Feed +import net.pengcook.android.presentation.core.model.Feed class FeedPagingSource( private val initialPageNumber: Int = 0, diff --git a/android/app/src/main/java/net/pengcook/android/data/model/.gitkeep b/android/app/src/main/java/net/pengcook/android/data/model/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/android/app/src/main/java/net/pengcook/android/data/remote/api/.gitkeep b/android/app/src/main/java/net/pengcook/android/data/remote/api/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/android/app/src/main/java/net/pengcook/android/data/repository/DummyFeedsRepository.kt b/android/app/src/main/java/net/pengcook/android/data/repository/DummyFeedsRepository.kt index e9ce3d04..d4f5b2eb 100644 --- a/android/app/src/main/java/net/pengcook/android/data/repository/DummyFeedsRepository.kt +++ b/android/app/src/main/java/net/pengcook/android/data/repository/DummyFeedsRepository.kt @@ -1,6 +1,6 @@ package net.pengcook.android.data.repository -import net.pengcook.android.model.Feed +import net.pengcook.android.presentation.core.model.Feed class DummyFeedsRepository { suspend fun fetchFeeds( diff --git a/android/app/src/main/java/net/pengcook/android/listner/FeedItemEventListener.kt b/android/app/src/main/java/net/pengcook/android/listner/FeedItemEventListener.kt deleted file mode 100644 index 3b2c0081..00000000 --- a/android/app/src/main/java/net/pengcook/android/listner/FeedItemEventListener.kt +++ /dev/null @@ -1,7 +0,0 @@ -package net.pengcook.android.listner - -import net.pengcook.android.model.Feed - -interface FeedItemEventListener { - fun onNavigateToDetail(feedInfo: Feed) -} diff --git a/android/app/src/main/java/net/pengcook/android/BindingAdapters.kt b/android/app/src/main/java/net/pengcook/android/presentation/BindingAdapters.kt similarity index 94% rename from android/app/src/main/java/net/pengcook/android/BindingAdapters.kt rename to android/app/src/main/java/net/pengcook/android/presentation/BindingAdapters.kt index e18eefa1..fef051bc 100644 --- a/android/app/src/main/java/net/pengcook/android/BindingAdapters.kt +++ b/android/app/src/main/java/net/pengcook/android/presentation/BindingAdapters.kt @@ -1,9 +1,10 @@ -package net.pengcook.android +package net.pengcook.android.presentation import android.widget.ImageView import android.widget.TextView import androidx.databinding.BindingAdapter import com.bumptech.glide.Glide +import net.pengcook.android.R @BindingAdapter("app:imageUrl") fun loadImage( diff --git a/android/app/src/main/java/net/pengcook/android/MainActivity.kt b/android/app/src/main/java/net/pengcook/android/presentation/MainActivity.kt similarity index 93% rename from android/app/src/main/java/net/pengcook/android/MainActivity.kt rename to android/app/src/main/java/net/pengcook/android/presentation/MainActivity.kt index 4d2d40f7..8ffa3bf9 100644 --- a/android/app/src/main/java/net/pengcook/android/MainActivity.kt +++ b/android/app/src/main/java/net/pengcook/android/presentation/MainActivity.kt @@ -1,10 +1,11 @@ -package net.pengcook.android +package net.pengcook.android.presentation import android.os.Bundle import android.view.View import androidx.appcompat.app.AppCompatActivity import androidx.navigation.fragment.NavHostFragment import androidx.navigation.ui.NavigationUI +import net.pengcook.android.R class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { diff --git a/android/app/src/main/java/net/pengcook/android/presentation/uimodel/Comment.kt b/android/app/src/main/java/net/pengcook/android/presentation/core/model/Comment.kt similarity index 78% rename from android/app/src/main/java/net/pengcook/android/presentation/uimodel/Comment.kt rename to android/app/src/main/java/net/pengcook/android/presentation/core/model/Comment.kt index cccf02b8..ecfec1a1 100644 --- a/android/app/src/main/java/net/pengcook/android/presentation/uimodel/Comment.kt +++ b/android/app/src/main/java/net/pengcook/android/presentation/core/model/Comment.kt @@ -1,4 +1,4 @@ -package net.pengcook.android.presentation.uimodel +package net.pengcook.android.presentation.core.model import android.os.Parcelable import kotlinx.parcelize.Parcelize diff --git a/android/app/src/main/java/net/pengcook/android/model/Feed.kt b/android/app/src/main/java/net/pengcook/android/presentation/core/model/Feed.kt similarity index 79% rename from android/app/src/main/java/net/pengcook/android/model/Feed.kt rename to android/app/src/main/java/net/pengcook/android/presentation/core/model/Feed.kt index 0e1b625b..6d43cc70 100644 --- a/android/app/src/main/java/net/pengcook/android/model/Feed.kt +++ b/android/app/src/main/java/net/pengcook/android/presentation/core/model/Feed.kt @@ -1,4 +1,4 @@ -package net.pengcook.android.model +package net.pengcook.android.presentation.core.model data class Feed( val id: Long, diff --git a/android/app/src/main/java/net/pengcook/android/presentation/uimodel/Recipe.kt b/android/app/src/main/java/net/pengcook/android/presentation/core/model/Recipe.kt similarity index 87% rename from android/app/src/main/java/net/pengcook/android/presentation/uimodel/Recipe.kt rename to android/app/src/main/java/net/pengcook/android/presentation/core/model/Recipe.kt index 58263aea..29da4035 100644 --- a/android/app/src/main/java/net/pengcook/android/presentation/uimodel/Recipe.kt +++ b/android/app/src/main/java/net/pengcook/android/presentation/core/model/Recipe.kt @@ -1,4 +1,4 @@ -package net.pengcook.android.presentation.uimodel +package net.pengcook.android.presentation.core.model import android.os.Parcelable import kotlinx.parcelize.Parcelize diff --git a/android/app/src/main/java/net/pengcook/android/presentation/uimodel/User.kt b/android/app/src/main/java/net/pengcook/android/presentation/core/model/User.kt similarity index 77% rename from android/app/src/main/java/net/pengcook/android/presentation/uimodel/User.kt rename to android/app/src/main/java/net/pengcook/android/presentation/core/model/User.kt index 9fd4c3dd..ac7075a3 100644 --- a/android/app/src/main/java/net/pengcook/android/presentation/uimodel/User.kt +++ b/android/app/src/main/java/net/pengcook/android/presentation/core/model/User.kt @@ -1,4 +1,4 @@ -package net.pengcook.android.presentation.uimodel +package net.pengcook.android.presentation.core.model import android.os.Parcelable import kotlinx.parcelize.Parcelize diff --git a/android/app/src/main/java/net/pengcook/android/home/FeedRecyclerViewAdapter.kt b/android/app/src/main/java/net/pengcook/android/presentation/home/FeedRecyclerViewAdapter.kt similarity index 80% rename from android/app/src/main/java/net/pengcook/android/home/FeedRecyclerViewAdapter.kt rename to android/app/src/main/java/net/pengcook/android/presentation/home/FeedRecyclerViewAdapter.kt index aacbf42a..a05a16be 100644 --- a/android/app/src/main/java/net/pengcook/android/home/FeedRecyclerViewAdapter.kt +++ b/android/app/src/main/java/net/pengcook/android/presentation/home/FeedRecyclerViewAdapter.kt @@ -1,16 +1,13 @@ -package net.pengcook.android.home +package net.pengcook.android.presentation.home import android.view.LayoutInflater import android.view.ViewGroup -import android.widget.ImageView -import androidx.databinding.BindingAdapter import androidx.paging.PagingDataAdapter import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.RecyclerView -import com.bumptech.glide.Glide import net.pengcook.android.databinding.ItemFeedBinding -import net.pengcook.android.listner.FeedItemEventListener -import net.pengcook.android.model.Feed +import net.pengcook.android.presentation.core.model.Feed +import net.pengcook.android.presentation.home.listener.FeedItemEventListener class FeedRecyclerViewAdapter(private val eventListener: FeedItemEventListener) : PagingDataAdapter(diffCallback) { @@ -59,11 +56,3 @@ class FeedRecyclerViewAdapter(private val eventListener: FeedItemEventListener) } } } - -@BindingAdapter("app:image") -fun ImageView.image(url: String?) { - if (url == null) return - Glide.with(this.context) - .load(url) - .into(this) -} diff --git a/android/app/src/main/java/net/pengcook/android/home/HomeFragment.kt b/android/app/src/main/java/net/pengcook/android/presentation/home/HomeFragment.kt similarity index 97% rename from android/app/src/main/java/net/pengcook/android/home/HomeFragment.kt rename to android/app/src/main/java/net/pengcook/android/presentation/home/HomeFragment.kt index da197dce..625683d9 100644 --- a/android/app/src/main/java/net/pengcook/android/home/HomeFragment.kt +++ b/android/app/src/main/java/net/pengcook/android/presentation/home/HomeFragment.kt @@ -1,4 +1,4 @@ -package net.pengcook.android.home +package net.pengcook.android.presentation.home import android.os.Bundle import android.view.LayoutInflater diff --git a/android/app/src/main/java/net/pengcook/android/home/HomeViewModel.kt b/android/app/src/main/java/net/pengcook/android/presentation/home/HomeViewModel.kt similarity index 79% rename from android/app/src/main/java/net/pengcook/android/home/HomeViewModel.kt rename to android/app/src/main/java/net/pengcook/android/presentation/home/HomeViewModel.kt index 2d369524..d218b320 100644 --- a/android/app/src/main/java/net/pengcook/android/home/HomeViewModel.kt +++ b/android/app/src/main/java/net/pengcook/android/presentation/home/HomeViewModel.kt @@ -1,4 +1,4 @@ -package net.pengcook.android.home +package net.pengcook.android.presentation.home import androidx.lifecycle.LiveData import androidx.lifecycle.ViewModel @@ -8,10 +8,10 @@ import androidx.paging.PagingConfig import androidx.paging.PagingData import androidx.paging.cachedIn import androidx.paging.liveData -import net.pengcook.android.data.FeedPagingSource +import net.pengcook.android.data.datasource.FeedPagingSource import net.pengcook.android.data.repository.DummyFeedsRepository -import net.pengcook.android.listner.FeedItemEventListener -import net.pengcook.android.model.Feed +import net.pengcook.android.presentation.core.model.Feed +import net.pengcook.android.presentation.home.listener.FeedItemEventListener class HomeViewModel : ViewModel(), FeedItemEventListener { private val dummyFeedsRepository = DummyFeedsRepository() diff --git a/android/app/src/main/java/net/pengcook/android/presentation/home/listener/FeedItemEventListener.kt b/android/app/src/main/java/net/pengcook/android/presentation/home/listener/FeedItemEventListener.kt new file mode 100644 index 00000000..58e6d504 --- /dev/null +++ b/android/app/src/main/java/net/pengcook/android/presentation/home/listener/FeedItemEventListener.kt @@ -0,0 +1,7 @@ +package net.pengcook.android.presentation.home.listener + +import net.pengcook.android.presentation.core.model.Feed + +interface FeedItemEventListener { + fun onNavigateToDetail(feedInfo: Feed) +} diff --git a/android/app/src/main/res/layout/activity_main.xml b/android/app/src/main/res/layout/activity_main.xml index 84cafbc4..e86e35a2 100644 --- a/android/app/src/main/res/layout/activity_main.xml +++ b/android/app/src/main/res/layout/activity_main.xml @@ -6,7 +6,7 @@ android:layout_height="match_parent" android:orientation="vertical" android:weightSum="1" - tools:context=".MainActivity"> + tools:context=".presentation.MainActivity"> + type="net.pengcook.android.presentation.home.HomeViewModel" /> + tools:context=".presentation.MainActivity"> + type="net.pengcook.android.presentation.core.model.Feed" /> @@ -47,7 +47,7 @@ android:layout_height="200dp" android:layout_marginTop="8dp" android:layout_marginBottom="8dp" - app:image="@{feed.recipeImageUrl}" + app:imageUrl="@{feed.recipeImageUrl}" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/profile_image" /> diff --git a/android/app/src/main/res/navigation/nav_graph.xml b/android/app/src/main/res/navigation/nav_graph.xml index a841f916..6df4ad58 100644 --- a/android/app/src/main/res/navigation/nav_graph.xml +++ b/android/app/src/main/res/navigation/nav_graph.xml @@ -7,7 +7,7 @@