-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f72bde7
Showing
47 changed files
with
1,077 additions
and
0 deletions.
There are no files selected for viewing
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,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 |
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 @@ | ||
/build |
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,56 @@ | ||
plugins { | ||
id 'com.android.application' | ||
id 'org.jetbrains.kotlin.android' | ||
} | ||
|
||
android { | ||
namespace 'com.kkyume.android.imagecollecter' | ||
compileSdk 33 | ||
|
||
defaultConfig { | ||
applicationId "com.kkyume.android.imagecollecter" | ||
minSdk 24 | ||
targetSdk 33 | ||
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.8.0' | ||
implementation 'androidx.appcompat:appcompat:1.6.1' | ||
implementation 'com.google.android.material:material:1.5.0' | ||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4' | ||
testImplementation 'junit:junit:4.13.2' | ||
androidTestImplementation 'androidx.test.ext:junit:1.1.5' | ||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' | ||
|
||
// Retrofit | ||
implementation 'com.squareup.retrofit2:retrofit:2.9.0' | ||
implementation 'com.squareup.retrofit2:converter-moshi:2.9.0' | ||
|
||
//Gson | ||
implementation 'com.squareup.retrofit2:converter-gson:2.9.0' | ||
|
||
// OkHttp | ||
implementation 'com.squareup.okhttp3:okhttp:4.10.0' | ||
implementation 'com.squareup.okhttp3:logging-interceptor:4.10.0' | ||
|
||
implementation group: "org.jetbrains.kotlinx", name: "kotlinx-serialization-core-jvm", version: "1.5.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
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 |
24 changes: 24 additions & 0 deletions
24
app/src/androidTest/java/com/kkyume/android/imagecollecter/ExampleInstrumentedTest.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,24 @@ | ||
package com.kkyume.android.imagecollecter | ||
|
||
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.kkyume.android.imagecollecter", appContext.packageName) | ||
} | ||
} |
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,27 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<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:allowBackup="true" | ||
android:dataExtractionRules="@xml/data_extraction_rules" | ||
android:fullBackupContent="@xml/backup_rules" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/Theme.ImageCollecter" | ||
tools:targetApi="31"> | ||
<meta-data android:name="com.kakao.sdk.AppKey" android:value="25db72779d72da271d22dfd33f4d471e" /> | ||
<activity | ||
android:name=".MainActivity" | ||
android:exported="true"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
60 changes: 60 additions & 0 deletions
60
app/src/main/java/com/kkyume/android/imagecollecter/ImageViewModel.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,60 @@ | ||
package com.kkyume.android.imagecollecter | ||
|
||
import android.app.Application | ||
import androidx.lifecycle.LiveData | ||
import androidx.lifecycle.MutableLiveData | ||
import com.kkyume.android.imagecollecter.model.image.ImageRequest | ||
import com.kkyume.android.imagecollecter.model.image.ImageResponse | ||
import com.kkyume.android.imagecollecter.model.video.VideoRequest | ||
import com.kkyume.android.imagecollecter.model.video.VideoResponse | ||
import com.kkyume.android.imagecollecter.network.RetrofitService | ||
import retrofit2.Call | ||
import retrofit2.Callback | ||
import retrofit2.Response | ||
|
||
class ImageViewModel(application: Application){ | ||
|
||
// 주소명으로 시군구코드 조회 MutableLiveData | ||
private var mImageMutableLiveData = MutableLiveData<ImageResponse>() | ||
|
||
// 간편결제 메인 MutableLiveData | ||
private var mVideoMutableLiveData = MutableLiveData<VideoResponse>() | ||
|
||
|
||
|
||
val imageLiveData : LiveData<ImageResponse> | ||
get() = mImageMutableLiveData | ||
|
||
val videoLiveData : LiveData<VideoResponse> | ||
get() = mVideoMutableLiveData | ||
|
||
|
||
fun requestImageResponse(imageRequest: ImageRequest) { | ||
val call = RetrofitService.getInterface().getImage("iu", "recency", 10, 10) | ||
call.enqueue(object : Callback<ImageResponse> { | ||
override fun onResponse(call: Call<ImageResponse>, response: Response<ImageResponse>) { | ||
println(">>>>> 성공") | ||
} | ||
|
||
override fun onFailure(call: Call<ImageResponse>, t: Throwable) { | ||
println(">>>>> 실패") | ||
|
||
} | ||
}) | ||
} | ||
|
||
fun requestVideoResponse(videoRequest: VideoRequest) { | ||
val call = RetrofitService.getInterface().getVideo("iu", "recency", 10, 10) | ||
call.enqueue(object : Callback<VideoResponse> { | ||
override fun onResponse(call: Call<VideoResponse>, response: Response<VideoResponse>) { | ||
println(">>>>> 성공") | ||
} | ||
|
||
override fun onFailure(call: Call<VideoResponse>, t: Throwable) { | ||
println(">>>>> 실패") | ||
|
||
} | ||
}) | ||
} | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
app/src/main/java/com/kkyume/android/imagecollecter/MainActivity.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,38 @@ | ||
package com.kkyume.android.imagecollecter | ||
|
||
import android.app.Activity | ||
import androidx.appcompat.app.AppCompatActivity | ||
import android.os.Bundle | ||
import android.os.Handler | ||
import android.os.Looper | ||
import android.view.View | ||
import androidx.lifecycle.LifecycleOwner | ||
import com.kkyume.android.imagecollecter.model.image.ImageRequest | ||
|
||
class MainActivity : AppCompatActivity() { | ||
private var mViewModel: ImageViewModel? = null | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_main) | ||
|
||
|
||
init() | ||
mViewModel?.requestImageResponse(ImageRequest("IU","recency",10, 10)) | ||
|
||
initLiveData() | ||
} | ||
private fun init(){ | ||
mViewModel = (this as? Activity)?.let { ImageViewModel(it.application) } | ||
|
||
} | ||
private fun initLiveData() { | ||
mViewModel?.let { viewModel -> | ||
viewModel.imageLiveData.observe(this as LifecycleOwner) { res -> | ||
res?.let { | ||
println(it.documents.get(0)) | ||
} | ||
} | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
app/src/main/java/com/kkyume/android/imagecollecter/model/image/ImageMeta.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,15 @@ | ||
package com.kkyume.android.imagecollecter.model.image | ||
|
||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class ImageMeta( | ||
@SerialName("is_end") | ||
val isEnd: Boolean, | ||
@SerialName("pageable_count") | ||
val pageableCount: Int, | ||
@SerialName("total_count") | ||
val totalCount: Int | ||
) |
18 changes: 18 additions & 0 deletions
18
app/src/main/java/com/kkyume/android/imagecollecter/model/image/ImageRequest.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,18 @@ | ||
package com.kkyume.android.imagecollecter.model.image | ||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
data class ImageRequest( | ||
|
||
@SerializedName("query") | ||
val query: String = "", | ||
|
||
@SerializedName("sort") | ||
val sort: String = "", | ||
|
||
@SerializedName("page") | ||
val page: Int, | ||
|
||
@SerializedName("size") | ||
val size: Int, | ||
) |
13 changes: 13 additions & 0 deletions
13
app/src/main/java/com/kkyume/android/imagecollecter/model/image/ImageResponse.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,13 @@ | ||
package com.kkyume.android.imagecollecter.model.image | ||
|
||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class ImageResponse( | ||
@SerialName("documents") | ||
val documents: List<Image_Document>, | ||
@SerialName("meta") | ||
val meta: ImageMeta | ||
) |
24 changes: 24 additions & 0 deletions
24
app/src/main/java/com/kkyume/android/imagecollecter/model/image/Image_Document.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,24 @@ | ||
package com.kkyume.android.imagecollecter.model.image | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class Image_Document( | ||
@SerialName("collection") | ||
val collection: String, | ||
@SerialName("datetime") | ||
val datetime: String, | ||
@SerialName("display_sitename") | ||
val displaySitename: String, | ||
@SerialName("doc_url") | ||
val docUrl: String, | ||
@SerialName("height") | ||
val height: Int, | ||
@SerialName("image_url") | ||
val imageUrl: String, | ||
@SerialName("thumbnail_url") | ||
val thumbnailUrl: String, | ||
@SerialName("width") | ||
val width: Int | ||
) |
18 changes: 18 additions & 0 deletions
18
app/src/main/java/com/kkyume/android/imagecollecter/model/video/VideoRequest.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,18 @@ | ||
package com.kkyume.android.imagecollecter.model.video | ||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
data class VideoRequest( | ||
|
||
@SerializedName("query") | ||
val query: String = "", | ||
|
||
@SerializedName("sort") | ||
val sort: String = "", | ||
|
||
@SerializedName("page") | ||
val page: Int, | ||
|
||
@SerializedName("size") | ||
val size: Int, | ||
) |
13 changes: 13 additions & 0 deletions
13
app/src/main/java/com/kkyume/android/imagecollecter/model/video/VideoResponse.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,13 @@ | ||
package com.kkyume.android.imagecollecter.model.video | ||
|
||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class VideoResponse( | ||
@SerialName("documents") | ||
val documents: List<Video_Document>, | ||
@SerialName("meta") | ||
val meta: Video_Meta | ||
) |
21 changes: 21 additions & 0 deletions
21
app/src/main/java/com/kkyume/android/imagecollecter/model/video/Video_Document.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,21 @@ | ||
package com.kkyume.android.imagecollecter.model.video | ||
|
||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class Video_Document( | ||
@SerialName("author") | ||
val author: String, | ||
@SerialName("datetime") | ||
val datetime: String, | ||
@SerialName("play_time") | ||
val playTime: Int, | ||
@SerialName("thumbnail") | ||
val thumbnail: String, | ||
@SerialName("title") | ||
val title: String, | ||
@SerialName("url") | ||
val url: String | ||
) |
Oops, something went wrong.