-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
김영록 3주차 미션 #9
base: main
Are you sure you want to change the base?
김영록 3주차 미션 #9
Changes from 5 commits
1827488
df9d202
ee7427d
965d101
0481b95
8a98d7d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import org.jetbrains.kotlin.storage.CacheResetOnProcessCanceled.enabled | ||
|
||
plugins { | ||
id("com.android.application") | ||
id("org.jetbrains.kotlin.android") | ||
} | ||
|
||
android { | ||
namespace = "com.example.carrotmarket" | ||
compileSdk = 33 | ||
|
||
buildFeatures { | ||
viewBinding = true | ||
} | ||
defaultConfig { | ||
applicationId = "com.example.carrotmarket" | ||
minSdk = 30 | ||
targetSdk = 33 | ||
versionCode = 1 | ||
versionName = "1.0" | ||
|
||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
|
||
buildTypes { | ||
release { | ||
isMinifyEnabled = 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.9.0") | ||
implementation("androidx.appcompat:appcompat:1.6.1") | ||
implementation("com.google.android.material:material:1.9.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") | ||
} |
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.example.carrotmarket | ||
|
||
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.example.myapplication", appContext.packageName) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools"> | ||
|
||
<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.MyApplication" | ||
tools:targetApi="31"> | ||
<activity | ||
android:name=".AlarmActivity" | ||
android:exported="false" /> | ||
<activity | ||
android:name=".StuffInfoActivity" | ||
android:exported="false" /> | ||
<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> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.example.carrotmarket | ||
|
||
import android.os.Bundle | ||
import androidx.fragment.app.Fragment | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import com.example.carrotmarket.databinding.FragmentActivityNotifyBinding | ||
import com.example.carrotmarket.databinding.FragmentHomeBinding | ||
|
||
class ActivityNotify : Fragment() { | ||
lateinit var binding : FragmentActivityNotifyBinding | ||
override fun onCreateView( | ||
inflater: LayoutInflater, container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View? { | ||
// Inflate the layout for this fragment | ||
binding = FragmentActivityNotifyBinding.inflate(layoutInflater) | ||
return binding.root | ||
} | ||
|
||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.example.carrotmarket | ||
|
||
import androidx.appcompat.app.AppCompatActivity | ||
import android.os.Bundle | ||
import androidx.activity.setViewTreeOnBackPressedDispatcherOwner | ||
import com.example.carrotmarket.databinding.ActivityAlarmBinding | ||
|
||
class AlarmActivity : AppCompatActivity() { | ||
lateinit var binding : ActivityAlarmBinding | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
binding = ActivityAlarmBinding.inflate(layoutInflater) | ||
setContentView(binding.root) | ||
|
||
supportFragmentManager.beginTransaction().replace(R.id.fl_notify_contents, ActivityNotify()).commit() | ||
|
||
binding.clActiviyNotify.setOnClickListener { | ||
supportFragmentManager.beginTransaction().replace(R.id.fl_notify_contents, ActivityNotify()).commit() | ||
binding.viewLine1.setBackgroundResource(R.color.black) | ||
binding.viewLine2.setBackgroundResource(R.color.gray) | ||
} | ||
|
||
binding.clKeywordNotify.setOnClickListener { | ||
supportFragmentManager.beginTransaction().replace(R.id.fl_notify_contents, KeywordNotify()).commit() | ||
binding.viewLine1.setBackgroundResource(R.color.gray) | ||
binding.viewLine2.setBackgroundResource(R.color.black) | ||
} | ||
|
||
binding.btnPrevious.setOnClickListener { | ||
finish() | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.example.carrotmarket | ||
|
||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.fragment.app.Fragment | ||
import com.example.carrotmarket.databinding.FragmentChattingBinding | ||
|
||
class ChattingFragment : Fragment() { | ||
lateinit var binding : FragmentChattingBinding | ||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, | ||
container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View? { | ||
binding = FragmentChattingBinding.inflate(layoutInflater) | ||
return binding.root | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.example.carrotmarket | ||
|
||
import android.content.Intent | ||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.fragment.app.Fragment | ||
import com.example.carrotmarket.databinding.FragmentHomeBinding | ||
|
||
class HomeFragment : Fragment() { | ||
lateinit var binding: FragmentHomeBinding | ||
override fun onCreateView( | ||
inflater: LayoutInflater, | ||
container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View? { | ||
binding = FragmentHomeBinding.inflate(layoutInflater) | ||
|
||
parentFragmentManager.beginTransaction().replace(R.id.fl_stuff_info, HomeScrollFragment()).commit() | ||
|
||
// 기능 추가 | ||
// binding.clItem1.setOnClickListener { | ||
// val intent = Intent(requireContext(), StuffInfoActivity::class.java) // ::은 리플렉션이라고 함 왜 .java붙음? | ||
// startActivity(intent) | ||
// } | ||
// binding.clItem2.setOnClickListener { | ||
// val intent = Intent(requireContext(), StuffInfoActivity::class.java) // ::은 리플렉션이라고 함 왜 .java붙음? | ||
// startActivity(intent) | ||
// } | ||
|
||
binding.ivHomeAlarm.setOnClickListener { | ||
val intent = Intent(requireContext(), AlarmActivity::class.java) // ::은 리플렉션이라고 함 왜 .java붙음? | ||
startActivity(intent) | ||
} | ||
Comment on lines
+32
to
+35
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (저도 잘 몰랐던 부분인데 이번기회에 조사해보고 정리한내용 공유드립니닷 ^^7) public Intent(Context packageContext, Class<?> cls) {
throw new RuntimeException("Stub!");
} Intent가 실제로 Context와 제네릭 타입의 Class를 인자로 받도록 구현되어 있습니다. 즉 정확히 어떤 클래스를 받을지 명시되지 않았기 때문에 컴파일 시점에서 이를 명시해주어야 하고 리플렉션을 통해 어떤 클래스를 참조하게 할 것인지 명시하고 있는 것입니다. ::class로 참조하는 방식은 코틀린의 리플렉션 메서드입니다. 따라서 AClass::class로 참조하게 되면 코틀린의 클래스타입인 KClass 객체가 반환됩니다. 그러나 Intent 코드를 보면 Class를 받도록 되어있기 때문에 자바의 클래스타입인 Class를 반환하도록 AClass::class.java를 사용합니다. |
||
return binding.root | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ScrollView를 프래그먼트로 띄우셨네요!
물론 구현방법에 정답은 존재하지 않지만 몇가지 고려사항을 제시해보겠습니다!
물론 프래그먼트는 액티비티보다 가벼운 퍼포먼스를 가지기 때문에 적극 활용하는것은 매우 좋은 선택입니다!
그러나 충분히 하나의 UI내에서 그려낼 수 있는 상황에서 프래그먼트를 추가함으로써 오버헤드를 발생시키게 되는것은 아닌지 고려해보고 설계한다면 더 좋은 사용자경험을 이끌어낼 수 있을것 같습니다!