Skip to content

Commit 67e1d36

Browse files
committed
initial commit
0 parents  commit 67e1d36

File tree

113 files changed

+3733
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+3733
-0
lines changed

.gitignore

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea
5+
.DS_Store
6+
/build
7+
/captures
8+
.externalNativeBuild
9+
.cxx
10+
local.properties
11+

README.md

+125
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
# RickAndMorty
2+
This is a app for the understanding about Clean Architecture and Kotlin technologys(Flow,Coroutune,ViewModel vs.)
3+
4+
5+
## Project Screens
6+
HOME SCREEN | DETAİL SCREEN |
7+
--- | --- |
8+
![Uygulama Ekran Görüntüsü](https://i.hizliresim.com/di18fsj.png) |![Uygulama Ekran Görüntüsü](https://i.hizliresim.com/di18fsj.png) |
9+
10+
11+
12+
13+
## Project Tech stack & Open-source libraries
14+
15+
- This app made %100 with [Kotlin](https://developer.android.com/kotlin)
16+
17+
- Made with [Android Architecture Components ](https://developer.android.com/topic/architecture)for the Collection of libraries that help you design robust, testable, and maintainable apps.
18+
19+
- [ViewModel](https://developer.android.com/topic/libraries/architecture/viewmodel):The ViewModel class is a business logic or screen level state holder. It exposes state to the UI and encapsulates related business logic. Its principal advantage is that it caches state and persists it through configuration changes. This means that your UI doesn’t have to fetch data again when navigating between activities, or following configuration changes, such as when rotating the screen.
20+
21+
- [Kotlin Flow](https://developer.android.com/kotlin/flow):In coroutines, a flow is a type that can emit multiple values sequentially, as opposed to suspend functions that return only a single value. For example, you can use a flow to receive live updates from a database.
22+
23+
- [Kotlin Coroutine](https://developer.android.com/kotlin/coroutines):On Android, coroutines help to manage long-running tasks that might otherwise block the main thread and cause your app to become unresponsive. Over 50% of professional developers who use coroutines have reported seeing increased productivity. This topic describes how you can use Kotlin coroutines to address these problems, enabling you to write cleaner and more concise app code.
24+
25+
- [Dependency Injection with Hilt](https://developer.android.com/training/dependency-injection/hilt-android):Hilt is a dependency injection library for Android that reduces the boilerplate of doing manual dependency injection in your project. Doing manual dependency injection requires you to construct every class and its dependencies by hand, and to use containers to reuse and manage dependencies.
26+
27+
- [Navigation Componenet](https://developer.android.com/guide/navigation):Navigation refers to the interactions that allow users to navigate across, into, and back out from the different pieces of content within your app. Android Jetpack's Navigation component helps you implement navigation, from simple button clicks to more complex patterns, such as app bars and the navigation drawer.
28+
29+
- [Retrofit](https://square.github.io/retrofit/):Retrofit is the class through which your API interfaces are turned into callable objects. By default, Retrofit will give you sane defaults for your platform but it allows for customization.
30+
31+
- [UseCase](https://developer.android.com/topic/architecture/domain-layer):Located domain layer that sits between the UI layer and the data layer.
32+
33+
- [Repository](https://developer.android.com/topic/architecture/data-layer):Located in data layer that contains application data and business logic.
34+
35+
- [Mockito ](https://site.mockito.org/):A mocking framework that tastes really good. It lets you write beautiful tests with a clean & simple API.
36+
37+
- [MockWebServer](https://github.com/square/okhttp/tree/master/mockwebserver):A scriptable web server for testing HTTP clients.
38+
39+
- [Truth ](https://truth.dev/):A library for performing assertions in tests.
40+
41+
- [Turbine ](https://github.com/cashapp/turbine):A small testing library for kotlinx.coroutines Flow.
42+
43+
- [Glide ](https://github.com/bumptech/glide):A library for imageView.
44+
45+
- [Lottie ](https://lottiefiles.com/):A library for animations.
46+
47+
48+
## Project Graph
49+
50+
- This app uses [MVVM (Model View View-Model)](https://developer.android.com/topic/architecture#recommended-app-arch)architecture
51+
52+
53+
![Logo](https://i.hizliresim.com/iq3kqv1.png)
54+
55+
This project has 4 Main package ;
56+
57+
-DATA
58+
59+
-Dİ
60+
61+
-DOMAİN
62+
63+
-Uİ
64+
65+
### DATA LAYER
66+
67+
![Logo](https://i.hizliresim.com/skpw70b.jpg)
68+
69+
70+
[Data Layer](https://developer.android.com/topic/architecture/data-layer): While the UI layer contains UI-related state and UI logic, the data layer contains application data and business logic. The business logic is what gives value to your app—it's made of real-world business rules that determine how application data must be created, stored, and changed.
71+
72+
inside the Data Layer:
73+
74+
-- Repository
75+
76+
-- Dto
77+
78+
-- Service
79+
80+
-- Source
81+
82+
83+
### DOMAİN LAYER
84+
85+
![Logo](https://i.hizliresim.com/l549eub.jpg)
86+
87+
[Domain Layer](https://developer.android.com/topic/architecture/data-layer): The domain layer is responsible for encapsulating complex business logic, or simple business logic that is reused by multiple ViewModels. This layer is optional because not all apps will have these requirements. You should only use it when needed-for example, to handle complexity or favor reusability.
88+
89+
inside the Domain Layer:
90+
91+
-- Mapper
92+
93+
-- UseCase
94+
95+
-- Entity
96+
97+
### Uİ LAYER
98+
99+
![Logo](https://i.hizliresim.com/3bfhzcg.jpg)
100+
101+
102+
[UI Layer](https://developer.android.com/topic/architecture/ui-layer): The role of the UI is to display the application data on the screen and also to serve as the primary point of user interaction. Whenever the data changes, either due to user interaction (like pressing a button) or external input (like a network response), the UI should update to reflect those changes. Effectively, the UI is a visual representation of the application state as retrieved from the data layer.
103+
104+
inside the Ui Layer:
105+
106+
-- Fragments
107+
108+
-- Components
109+
110+
-- Base
111+
112+
-- Contract
113+
114+
## UI and Unit Testing
115+
116+
[Testing ](https://developer.android.com/training/testing/fundamentals) is an integral part of the app development process. By running tests against your app consistently, you can verify your app's correctness, functional behavior, and usability before you release it publicly.
117+
118+
You can manually test your app by navigating through it. You might use different devices and emulators, change the system language, and try to generate every user error or traverse every user flow.
119+
120+
121+
122+
![Logo](https://i.hizliresim.com/nux42m9.png)
123+
124+
125+

app/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

app/build.gradle

+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
plugins {
2+
id 'com.android.application'
3+
id 'org.jetbrains.kotlin.android'
4+
id 'kotlin-kapt'
5+
id 'dagger.hilt.android.plugin'
6+
id 'androidx.navigation.safeargs'
7+
}
8+
9+
android {
10+
namespace 'com.serdar.rickandmorty'
11+
compileSdk 33
12+
13+
defaultConfig {
14+
applicationId "com.serdar.rickandmorty"
15+
minSdk 26
16+
targetSdk 33
17+
versionCode 1
18+
versionName "1.0"
19+
20+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
21+
}
22+
23+
buildTypes {
24+
release {
25+
minifyEnabled false
26+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
27+
}
28+
}
29+
compileOptions {
30+
sourceCompatibility JavaVersion.VERSION_1_8
31+
targetCompatibility JavaVersion.VERSION_1_8
32+
}
33+
kotlinOptions {
34+
jvmTarget = '1.8'
35+
}
36+
buildFeatures{
37+
viewBinding true
38+
}
39+
}
40+
41+
dependencies {
42+
43+
// AndroidX
44+
implementation "androidx.core:core-ktx:$android_core_ktx_version"
45+
implementation "androidx.appcompat:appcompat:$app_compat_version"
46+
47+
// Lifecycle
48+
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
49+
implementation 'androidx.fragment:fragment-ktx:1.5.4'
50+
implementation "androidx.activity:activity-ktx:1.6.1"
51+
implementation "androidx.lifecycle:lifecycle-extensions:2.2.0"
52+
53+
// Material
54+
implementation "com.google.android.material:material:$material_version"
55+
56+
// ConstraintLayout
57+
implementation "androidx.constraintlayout:constraintlayout:$constraint_layout_version"
58+
59+
// Retrofit
60+
implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
61+
implementation "com.squareup.retrofit2:converter-gson:$retrofit_version"
62+
63+
// Gson
64+
implementation "com.google.code.gson:gson:$gson_version"
65+
66+
// Hilt
67+
implementation "com.google.dagger:hilt-android:$hilt_version"
68+
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
69+
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.5.1'
70+
implementation 'androidx.navigation:navigation-fragment-ktx:2.5.3'
71+
implementation 'androidx.navigation:navigation-ui-ktx:2.5.3'
72+
kapt "com.google.dagger:hilt-compiler:$hilt_version"
73+
74+
//glide
75+
implementation "com.github.bumptech.glide:glide:$glide_version"
76+
annotationProcessor "com.github.bumptech.glide:compiler:$glide_version"
77+
78+
//lottie
79+
implementation "com.airbnb.android:lottie:$lottie_version"
80+
81+
82+
// Test
83+
testImplementation 'junit:junit:4.13.2'
84+
testImplementation "com.squareup.okhttp3:mockwebserver:$mock_webserver"
85+
testImplementation "com.google.truth:truth:$truth"
86+
testImplementation "org.mockito.kotlin:mockito-kotlin:$mockito_kotlin"
87+
testImplementation "org.mockito:mockito-inline:$mockito_inline"
88+
testImplementation "app.cash.turbine:turbine:$turbine"
89+
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutines_test"
90+
91+
implementation "androidx.arch.core:core-testing:$core_testing"
92+
93+
94+
androidTestImplementation "androidx.test.ext:junit:$junit"
95+
androidTestImplementation "androidx.test.espresso:espresso-core:$espresso"
96+
97+
98+
99+
100+
101+
102+
}

app/proguard-rules.pro

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.serdar.rickandmorty
2+
3+
import androidx.test.platform.app.InstrumentationRegistry
4+
import androidx.test.ext.junit.runners.AndroidJUnit4
5+
6+
import org.junit.Test
7+
import org.junit.runner.RunWith
8+
9+
import org.junit.Assert.*
10+
11+
/**
12+
* Instrumented test, which will execute on an Android device.
13+
*
14+
* See [testing documentation](http://d.android.com/tools/testing).
15+
*/
16+
@RunWith(AndroidJUnit4::class)
17+
class ExampleInstrumentedTest {
18+
@Test
19+
fun useAppContext() {
20+
// Context of the app under test.
21+
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22+
assertEquals("com.serdar.rickandmorty", appContext.packageName)
23+
}
24+
}

app/src/main/AndroidManifest.xml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools">
4+
5+
<uses-permission android:name="android.permission.INTERNET">
6+
7+
</uses-permission>
8+
<application
9+
android:allowBackup="true"
10+
android:dataExtractionRules="@xml/data_extraction_rules"
11+
android:fullBackupContent="@xml/backup_rules"
12+
android:icon="@mipmap/ic_launcher"
13+
android:label="@string/app_name"
14+
android:roundIcon="@mipmap/ic_launcher_round"
15+
android:supportsRtl="true"
16+
android:name=".RickAndMortyApp"
17+
android:theme="@style/Theme.RickAndMorty"
18+
tools:targetApi="31">
19+
<activity
20+
android:name=".MainActivity"
21+
android:exported="true">
22+
<intent-filter>
23+
<action android:name="android.intent.action.MAIN" />
24+
25+
<category android:name="android.intent.category.LAUNCHER" />
26+
</intent-filter>
27+
28+
<meta-data
29+
android:name="android.app.lib_name"
30+
android:value="" />
31+
</activity>
32+
</application>
33+
34+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.serdar.rickandmorty
2+
3+
import androidx.appcompat.app.AppCompatActivity
4+
import android.os.Bundle
5+
import androidx.activity.viewModels
6+
import com.serdar.rickandmorty.ui.home.HomeViewModel
7+
import dagger.hilt.android.AndroidEntryPoint
8+
9+
@AndroidEntryPoint
10+
class MainActivity : AppCompatActivity() {
11+
12+
private val viewModel by viewModels<HomeViewModel>()
13+
override fun onCreate(savedInstanceState: Bundle?) {
14+
super.onCreate(savedInstanceState)
15+
setContentView(R.layout.activity_main)
16+
}
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.serdar.rickandmorty
2+
3+
import android.app.Application
4+
import dagger.hilt.android.HiltAndroidApp
5+
6+
@HiltAndroidApp
7+
class RickAndMortyApp : Application(){
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.serdar.rickandmorty.data
2+
3+
4+
5+
sealed class NetworkResponse<out T :Any?> {
6+
object Loading : NetworkResponse<Nothing>()
7+
data class Error(val exception:Exception): NetworkResponse<Nothing>()
8+
data class Success<out T:Any>(val result: T?): NetworkResponse<T>()
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.serdar.rickandmorty.data.api
2+
3+
import retrofit2.http.GET
4+
import retrofit2.http.Path
5+
import com.serdar.rickandmorty.data.dto.allcharacter.RickAndMortyResponse
6+
import com.serdar.rickandmorty.data.dto.character.CharacterResponse
7+
8+
interface RickAndMortyApi {
9+
10+
@GET("character/{characterNumber}")
11+
suspend fun getRickAndMortyCharacter(@Path("characterNumber") characterNumber: String) : CharacterResponse
12+
13+
14+
@GET("character")
15+
suspend fun getRickAndMorty() : RickAndMortyResponse
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.serdar.rickandmorty.data.dto.allcharacter
2+
3+
4+
data class Location(
5+
val name: String,
6+
val url: String
7+
)

0 commit comments

Comments
 (0)