Skip to content

Commit

Permalink
Merge pull request #46 from nathan29849/develop_android
Browse files Browse the repository at this point in the history
[Android] Search화면, 키워드 검색 화면 구현
  • Loading branch information
jminie-o8o committed May 27, 2022
2 parents 1f948bc + 9aacefe commit 8a438e4
Show file tree
Hide file tree
Showing 81 changed files with 2,461 additions and 0 deletions.
Empty file added .idea/.gitignore
Empty file.
9 changes: 9 additions & 0 deletions .idea/airbnb.iml

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

8 changes: 8 additions & 0 deletions .idea/modules.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.

39 changes: 39 additions & 0 deletions .idea/workspace.xml

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

10 changes: 10 additions & 0 deletions android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
*.iml
.gradle
/local.properties
/.idea
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
local.properties
1 change: 1 addition & 0 deletions android/app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
77 changes: 77 additions & 0 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'androidx.navigation.safeargs.kotlin'
id 'kotlin-kapt'
id 'dagger.hilt.android.plugin'
}


android {
dataBinding {
enabled true
}
compileSdk 32

defaultConfig {
applicationId "com.example.airbnb"
minSdk 23
targetSdk 32
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 {
// Chart Library
implementation 'com.github.stfalcon-studio:StfalconPriceRangeBar-android:v1.5'

def lifecycle_version = "2.4.0"
// repeatOnLifecycle
implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version"
// navigation component
implementation "androidx.navigation:navigation-fragment-ktx:2.4.2"
implementation "androidx.navigation:navigation-ui-ktx:2.4.2"
//coil
implementation "io.coil-kt:coil:0.11.0"
//viewModel
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.4.1'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.1'
//hilt
implementation 'com.google.dagger:hilt-android:2.40'
kapt 'com.google.dagger:hilt-compiler:2.40'
// Retrofit
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
// OkHttp
implementation 'com.squareup.okhttp3:okhttp:4.9.1'
implementation 'com.squareup.okhttp3:logging-interceptor:4.9.1'
//lifecycle runtime
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.4.1'
//calendar
implementation 'com.google.android.material:material:1.6.0'
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.6.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
21 changes: 21 additions & 0 deletions android/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,22 @@
package com.example.airbnb

import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith

/**
* 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.example.airbnb", appContext.packageName)
}
}
27 changes: 27 additions & 0 deletions android/app/src/main/AndroidManifest.xml
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"
package="com.example.airbnb">

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

<application
android:name=".common.MainApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Airbnb">
<activity
android:name=".ui.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>
40 changes: 40 additions & 0 deletions android/app/src/main/assets/closeTravel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"closeTravel": [
{
"id": 1,
"imageUrl": "https://s3-alpha-sig.figma.com/img/4ee4/e169/870b792e3a4ae88671095fad825a8ef0?Expires=1654473600&Signature=TQ8Um2PqB135YjD9Nk4L51PJC5kzSV5lsp5oY9n-Y9QHAKzzW4zIrKXIEOjG5IeJUOYG-r3zS2uaWhLlkgDaDT-b5abY~BYGmBetze1xhXIgAWhdiVaYLvosEvFIFfD4RheMMFbCllOX9TgSwJo7FNv8Xv36Y24aGqTSmoaQBYjNzvnY55TgsbGOdAkTNppXZH6Wl1FgT5VuEUerqbfoQ4nqgntyY~P4ZWP7NydW5ksOzv-Wo1aJRm3sxgg~qB7KHeqYfKBxPSGtD4jF4Idozxiyzd~ipWVXLxIXC5xDgR~qGQF~xj2hs7T9JqpX2SbEYCA5ybVLKeGyf41k7o60Qg__&Key-Pair-Id=APKAINTVSUGEWH5XD5UA",
"title": "서울",
"contents": "차로 30분 거리"
},
{
"id": 1,
"imageUrl": "https://s3-alpha-sig.figma.com/img/d11b/fafa/041959faaab5d3d5bd0c98fc56ab6feb?Expires=1654473600&Signature=AIKFWnJfXVMOoFp70Jjbb0liJ8DejemAdMt2sQZFjqeGYqIRY4Y7mGseDcC5b8do8EFRh97Foy-~6gcdyrFefsEIBb06~yV8cQbIcK~sZ1QXu9HobheuNzP-N0~icBA47~qN6KCxUhiDz4lsymM9y41pdeFDAiFPIDqVrkvhNpggFTLsWDgcBe7mjRT6XVe15YYu0oK3yBG57cvDarIDfq4AhH-8fl2Sprk4k2AC3Ia58A9k5kd30Oqy0VbIi6B5Ztclgxjt~2ScmGtRDMJi7g1uwR9kqWyIKtljgPriKKJcC6oUOQjGnb-aWwkBHVY3NcOK9BNH~XxLi-O375akGQ__&Key-Pair-Id=APKAINTVSUGEWH5XD5UA",
"title": "광주",
"contents": "차로 4시간 거리"
},
{
"id": 1,
"imageUrl": "https://s3-alpha-sig.figma.com/img/4ee4/e169/870b792e3a4ae88671095fad825a8ef0?Expires=1654473600&Signature=TQ8Um2PqB135YjD9Nk4L51PJC5kzSV5lsp5oY9n-Y9QHAKzzW4zIrKXIEOjG5IeJUOYG-r3zS2uaWhLlkgDaDT-b5abY~BYGmBetze1xhXIgAWhdiVaYLvosEvFIFfD4RheMMFbCllOX9TgSwJo7FNv8Xv36Y24aGqTSmoaQBYjNzvnY55TgsbGOdAkTNppXZH6Wl1FgT5VuEUerqbfoQ4nqgntyY~P4ZWP7NydW5ksOzv-Wo1aJRm3sxgg~qB7KHeqYfKBxPSGtD4jF4Idozxiyzd~ipWVXLxIXC5xDgR~qGQF~xj2hs7T9JqpX2SbEYCA5ybVLKeGyf41k7o60Qg__&Key-Pair-Id=APKAINTVSUGEWH5XD5UA",
"title": "서울",
"contents": "차로 30분 거리"
},
{
"id": 1,
"imageUrl": "https://s3-alpha-sig.figma.com/img/d11b/fafa/041959faaab5d3d5bd0c98fc56ab6feb?Expires=1654473600&Signature=AIKFWnJfXVMOoFp70Jjbb0liJ8DejemAdMt2sQZFjqeGYqIRY4Y7mGseDcC5b8do8EFRh97Foy-~6gcdyrFefsEIBb06~yV8cQbIcK~sZ1QXu9HobheuNzP-N0~icBA47~qN6KCxUhiDz4lsymM9y41pdeFDAiFPIDqVrkvhNpggFTLsWDgcBe7mjRT6XVe15YYu0oK3yBG57cvDarIDfq4AhH-8fl2Sprk4k2AC3Ia58A9k5kd30Oqy0VbIi6B5Ztclgxjt~2ScmGtRDMJi7g1uwR9kqWyIKtljgPriKKJcC6oUOQjGnb-aWwkBHVY3NcOK9BNH~XxLi-O375akGQ__&Key-Pair-Id=APKAINTVSUGEWH5XD5UA",
"title": "광주",
"contents": "차로 4시간 거리"
},
{
"id": 1,
"imageUrl": "https://s3-alpha-sig.figma.com/img/4ee4/e169/870b792e3a4ae88671095fad825a8ef0?Expires=1654473600&Signature=TQ8Um2PqB135YjD9Nk4L51PJC5kzSV5lsp5oY9n-Y9QHAKzzW4zIrKXIEOjG5IeJUOYG-r3zS2uaWhLlkgDaDT-b5abY~BYGmBetze1xhXIgAWhdiVaYLvosEvFIFfD4RheMMFbCllOX9TgSwJo7FNv8Xv36Y24aGqTSmoaQBYjNzvnY55TgsbGOdAkTNppXZH6Wl1FgT5VuEUerqbfoQ4nqgntyY~P4ZWP7NydW5ksOzv-Wo1aJRm3sxgg~qB7KHeqYfKBxPSGtD4jF4Idozxiyzd~ipWVXLxIXC5xDgR~qGQF~xj2hs7T9JqpX2SbEYCA5ybVLKeGyf41k7o60Qg__&Key-Pair-Id=APKAINTVSUGEWH5XD5UA",
"title": "서울",
"contents": "차로 30분 거리"
},
{
"id": 1,
"imageUrl": "https://s3-alpha-sig.figma.com/img/d11b/fafa/041959faaab5d3d5bd0c98fc56ab6feb?Expires=1654473600&Signature=AIKFWnJfXVMOoFp70Jjbb0liJ8DejemAdMt2sQZFjqeGYqIRY4Y7mGseDcC5b8do8EFRh97Foy-~6gcdyrFefsEIBb06~yV8cQbIcK~sZ1QXu9HobheuNzP-N0~icBA47~qN6KCxUhiDz4lsymM9y41pdeFDAiFPIDqVrkvhNpggFTLsWDgcBe7mjRT6XVe15YYu0oK3yBG57cvDarIDfq4AhH-8fl2Sprk4k2AC3Ia58A9k5kd30Oqy0VbIi6B5Ztclgxjt~2ScmGtRDMJi7g1uwR9kqWyIKtljgPriKKJcC6oUOQjGnb-aWwkBHVY3NcOK9BNH~XxLi-O375akGQ__&Key-Pair-Id=APKAINTVSUGEWH5XD5UA",
"title": "광주",
"contents": "차로 4시간 거리"
}
]
}
3 changes: 3 additions & 0 deletions android/app/src/main/assets/heroImage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"imageUrl": "https://user-images.githubusercontent.com/79504043/169987721-839ddb22-7aff-49f2-bad0-76ffc0f8f249.png"
}
23 changes: 23 additions & 0 deletions android/app/src/main/java/com/example/airbnb/common/AssetLoader.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.example.airbnb.common

import android.content.Context
import dagger.hilt.android.qualifiers.ApplicationContext
import javax.inject.Inject

class AssetLoader @Inject constructor(@ApplicationContext private val context: Context) {

fun getJsonString(fileName: String): String? {
return kotlin.runCatching {
loadAsset(fileName)
}.getOrNull()
}

private fun loadAsset(fileName: String): String {
return context.assets.open(fileName).use { inputStream ->
val size = inputStream.available()
val bytes = ByteArray(size)
inputStream.read(bytes)
String(bytes)
}
}
}
16 changes: 16 additions & 0 deletions android/app/src/main/java/com/example/airbnb/common/BindModule.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.example.airbnb.common

import com.example.airbnb.data.repository.DataSource
import com.example.airbnb.data.repository.DataSourceImpl
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent

@Module
@InstallIn(SingletonComponent::class)
abstract class BindModule {

@Binds
abstract fun bindRepository(dataSourceImpl: DataSourceImpl): DataSource
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.example.airbnb.common

import android.app.Application
import dagger.hilt.android.HiltAndroidApp

@HiltAndroidApp
class MainApplication : Application()
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.example.airbnb.data.model

sealed class PlaceData {
data class SearchPlaceData(val placeName: String, val image: String? = null) : PlaceData()
data class PopularPlaceData(val placeName: String, val image: String, val distance: String) :
PlaceData()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.example.airbnb.data.repository

import com.example.airbnb.network.dto.HeroImage
import com.example.airbnb.network.dto.Travel

interface DataSource {

suspend fun loadHeroImage(): HeroImage?

suspend fun loadCloseTravel(): Travel?
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.example.airbnb.data.repository

import com.example.airbnb.network.dto.HeroImage
import com.example.airbnb.network.dto.Travel
import com.example.airbnb.common.AssetLoader
import com.google.gson.Gson
import javax.inject.Inject

class DataSourceImpl @Inject constructor(private val assetLoader: AssetLoader) : DataSource {

private val gson = Gson()

override suspend fun loadHeroImage(): HeroImage? {
return assetLoader.getJsonString("heroImage.json")?.let { heroImageString ->
gson.fromJson(heroImageString, HeroImage::class.java)
}
}

override suspend fun loadCloseTravel(): Travel? {
return assetLoader.getJsonString("closeTravel.json")?.let { closeTravelString ->
gson.fromJson(closeTravelString, Travel::class.java)
}
}
}
Loading

0 comments on commit 8a438e4

Please sign in to comment.