Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
EsracanGungor committed Mar 15, 2022
0 parents commit 0842363
Show file tree
Hide file tree
Showing 77 changed files with 1,763 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
local.properties
3 changes: 3 additions & 0 deletions .idea/.gitignore

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

1 change: 1 addition & 0 deletions .idea/.name

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

6 changes: 6 additions & 0 deletions .idea/compiler.xml

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

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

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

23 changes: 23 additions & 0 deletions .idea/misc.xml

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

6 changes: 6 additions & 0 deletions .idea/vcs.xml

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

1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
68 changes: 68 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-kapt'
id 'kotlin-android-extensions'
id 'androidx.navigation.safeargs'
}

android {
compileSdk 31

dataBinding{
enabled = true
}

buildFeatures {
viewBinding true
}

defaultConfig {
applicationId "com.esracangungor.photolist"
minSdk 23
targetSdk 31
versionCode 1
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}

dependencies {

implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

implementation "com.squareup.retrofit2:retrofit:2.9.0"
implementation "com.squareup.retrofit2:converter-gson:2.9.0"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.1"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1"
implementation "io.coil-kt:coil:1.4.0"
implementation 'androidx.fragment:fragment-ktx:1.4.1'

implementation "androidx.navigation:navigation-fragment-ktx:2.4.1"
implementation "androidx.navigation:navigation-ui-ktx:2.4.1"

implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2"

}
21 changes: 21 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.esracangungor.photolist

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4

import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.esracangungor.photolist", appContext.packageName)
}
}
29 changes: 29 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.esracangungor.photolist">

<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_app_logo_round"
android:supportsRtl="true"
android:theme="@style/Theme.photolist">
<activity
android:name=".view.SplashScreenActivity"
android:exported="true"
android:theme="@style/Theme.photolist.noActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".view.MainActivity"
android:exported="false">
</activity>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package com.esracangungor.photolist.adapter

import android.annotation.SuppressLint
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.navigation.Navigation
import androidx.recyclerview.widget.RecyclerView
import coil.load
import coil.transform.RoundedCornersTransformation
import com.esracangungor.photolist.R
import com.esracangungor.photolist.databinding.RecyclerListRowBinding
import com.esracangungor.photolist.model.PhotoItem
import com.esracangungor.photolist.view.PhotoFragmentDirections

class PhotoAdapter(private val photoList: ArrayList<PhotoItem>) :
RecyclerView.Adapter<PhotoAdapter.PhotoViewHolder>() {

inner class PhotoViewHolder(val binding: RecyclerListRowBinding) :
RecyclerView.ViewHolder(binding.root)

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): PhotoViewHolder {
val inflater = LayoutInflater.from(parent.context)
val binding = DataBindingUtil.inflate<RecyclerListRowBinding>(
inflater,
R.layout.recycler_list_row,
parent,
false
)
return PhotoViewHolder(binding)
}

override fun onBindViewHolder(holder: PhotoViewHolder, position: Int) {
with(holder) {
with(photoList[position]) {
binding.tvRecylerListRowAuthorName.text = author
binding.ivRecylerListRowImage.load(photoList[position].download_url) {
placeholder(R.drawable.image)
crossfade(true)
crossfade(600)
transformations(RoundedCornersTransformation(20f))
}
binding.root.setOnClickListener {
val action =
PhotoFragmentDirections.actionPhotoFragmentToPhotoDetailFragment(photoList[position])
Navigation.findNavController(it).navigate(action)
}
}
}
}

override fun getItemCount(): Int {
return photoList.size
}

@SuppressLint("NotifyDataSetChanged")
fun setUpdatePhotoList(newPhotoList: List<PhotoItem>) {
photoList.clear()
photoList.addAll(newPhotoList)
notifyDataSetChanged()
}

}
14 changes: 14 additions & 0 deletions app/src/main/java/com/esracangungor/photolist/model/PhotoItem.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.esracangungor.photolist.model

import android.os.Parcelable
import kotlinx.android.parcel.Parcelize

@Parcelize
data class PhotoItem(
val author: String,
val download_url: String,
val height: Int,
val id: String,
val url: String,
val width: Int
) : Parcelable
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.esracangungor.photolist.model

class PhotoList : ArrayList<PhotoItem>()
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.esracangungor.photolist.service

import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory

class RetrofitInstance {

companion object {
private const val BASE_URL = "https://picsum.photos/v2/"

fun getRetroInstance(): Retrofit {

return Retrofit.Builder()
.baseUrl(BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.build()
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.esracangungor.photolist.service

import com.esracangungor.photolist.model.PhotoList
import retrofit2.http.GET

interface RetrofitService {

@GET("list")
suspend fun getDataFromApi(): PhotoList
}
Loading

0 comments on commit 0842363

Please sign in to comment.