Skip to content

Commit ffb80ed

Browse files
committed
Initial commit
0 parents  commit ffb80ed

Some content is hidden

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

58 files changed

+1320
-0
lines changed

.gitignore

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/caches
5+
/.idea/libraries
6+
/.idea/modules.xml
7+
/.idea/workspace.xml
8+
/.idea/navEditor.xml
9+
/.idea/assetWizardSettings.xml
10+
.DS_Store
11+
/build
12+
/captures
13+
.externalNativeBuild
14+
.cxx
15+
local.properties

.idea/.gitignore

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/compiler.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/gradle.xml

+19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/kotlinc.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/.gitignore

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

app/build.gradle

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
plugins {
2+
id 'com.android.application'
3+
id 'org.jetbrains.kotlin.android'
4+
}
5+
6+
android {
7+
namespace 'com.example.tap'
8+
compileSdk 33
9+
10+
defaultConfig {
11+
applicationId "com.example.tap"
12+
minSdk 24
13+
targetSdk 33
14+
versionCode 1
15+
versionName "1.0"
16+
17+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
18+
}
19+
20+
buildTypes {
21+
release {
22+
minifyEnabled false
23+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
24+
}
25+
}
26+
compileOptions {
27+
sourceCompatibility JavaVersion.VERSION_1_8
28+
targetCompatibility JavaVersion.VERSION_1_8
29+
}
30+
kotlinOptions {
31+
jvmTarget = '1.8'
32+
}
33+
buildFeatures {
34+
viewBinding true
35+
}
36+
}
37+
38+
dependencies {
39+
40+
implementation 'androidx.core:core-ktx:1.8.0'
41+
implementation 'androidx.appcompat:appcompat:1.4.1'
42+
implementation 'com.google.android.material:material:1.5.0'
43+
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
44+
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.4.1'
45+
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.1'
46+
implementation 'androidx.navigation:navigation-fragment-ktx:2.5.2'
47+
implementation 'androidx.navigation:navigation-ui-ktx:2.5.2'
48+
testImplementation 'junit:junit:4.13.2'
49+
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
50+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
51+
implementation 'com.github.bumptech.glide:glide:4.12.0'
52+
annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
53+
}

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.example.tap
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.example.tap", appContext.packageName)
23+
}
24+
}

app/src/main/AndroidManifest.xml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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+
<application
6+
android:allowBackup="true"
7+
android:dataExtractionRules="@xml/data_extraction_rules"
8+
android:fullBackupContent="@xml/backup_rules"
9+
android:icon="@mipmap/ic_launcher"
10+
android:label="@string/app_name"
11+
android:roundIcon="@mipmap/ic_launcher_round"
12+
android:supportsRtl="true"
13+
android:theme="@style/Theme.Tap"
14+
tools:targetApi="31">
15+
<activity
16+
android:name=".MainActivity"
17+
android:exported="true"
18+
android:label="@string/app_name">
19+
<intent-filter>
20+
<action android:name="android.intent.action.MAIN" />
21+
22+
<category android:name="android.intent.category.LAUNCHER" />
23+
</intent-filter>
24+
</activity>
25+
</application>
26+
<uses-permission android:name="android.permission.INTERNET" />
27+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package com.example.tap
2+
3+
import android.os.Bundle
4+
import com.google.android.material.bottomnavigation.BottomNavigationView
5+
import androidx.appcompat.app.AppCompatActivity
6+
import androidx.navigation.findNavController
7+
import androidx.navigation.ui.AppBarConfiguration
8+
import androidx.navigation.ui.setupActionBarWithNavController
9+
import androidx.navigation.ui.setupWithNavController
10+
import com.example.tap.databinding.ActivityMainBinding
11+
12+
class MainActivity : AppCompatActivity() {
13+
14+
private lateinit var binding: ActivityMainBinding
15+
16+
override fun onCreate(savedInstanceState: Bundle?) {
17+
super.onCreate(savedInstanceState)
18+
19+
binding = ActivityMainBinding.inflate(layoutInflater)
20+
setContentView(binding.root)
21+
22+
val navView: BottomNavigationView = binding.navView
23+
24+
val navController = findNavController(R.id.nav_host_fragment_activity_main)
25+
// Passing each menu ID as a set of Ids because each
26+
// menu should be considered as top level destinations.
27+
val appBarConfiguration = AppBarConfiguration(
28+
setOf(
29+
R.id.navigation_home, R.id.navigation_dashboard, R.id.navigation_notifications
30+
)
31+
)
32+
setupActionBarWithNavController(navController, appBarConfiguration)
33+
navView.setupWithNavController(navController)
34+
}
35+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
package com.example.tap.ui.dashboard
2+
3+
import android.app.ActivityOptions
4+
import android.content.Intent
5+
import android.graphics.drawable.Drawable
6+
import android.os.Bundle
7+
import android.view.LayoutInflater
8+
import android.view.View
9+
import android.view.ViewGroup
10+
import android.widget.TextView
11+
import android.widget.Toast
12+
import androidx.core.view.drawToBitmap
13+
import androidx.fragment.app.Fragment
14+
import androidx.lifecycle.ViewModelProvider
15+
import androidx.recyclerview.widget.GridLayoutManager
16+
import androidx.recyclerview.widget.RecyclerView
17+
import androidx.recyclerview.widget.RecyclerView.Recycler
18+
import com.example.tap.databinding.FragmentDashboardBinding
19+
import com.example.tap.databinding.ItmeRecyclerViewBinding
20+
import com.bumptech.glide.Glide
21+
import com.example.tap.R
22+
23+
24+
data class BoardItem(val image: String, val title: String, val time: String)
25+
26+
class BoardAdapter(val itemList: ArrayList<BoardItem>):
27+
RecyclerView.Adapter<BoardAdapter.BoardViewHolder>(){
28+
override fun getItemCount(): Int {
29+
return itemList.count()
30+
}
31+
32+
override fun onBindViewHolder(holder: BoardViewHolder, position: Int) {
33+
holder.bindItems(itemList[position])
34+
}
35+
36+
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BoardViewHolder {
37+
val view =LayoutInflater.from(parent.context).inflate(R.layout.itme_recycler_view, parent, false)
38+
return BoardViewHolder(view)
39+
}
40+
41+
42+
class BoardViewHolder(view: View):RecyclerView.ViewHolder(view){
43+
fun bindItems(data: BoardItem){
44+
Glide.with(itemView.context)
45+
.load(data.image)
46+
.into(itemView.findViewById(R.id.tv_img))
47+
itemView.findViewById<TextView>(R.id.tv_title).text = data.title
48+
itemView.findViewById<TextView>(R.id.tv_time).text = data.time
49+
50+
51+
itemView.setOnClickListener({
52+
//여기서 토스터를 어떻게?
53+
// zoomImageFromThumb(itemView, data.image)
54+
Toast.makeText(itemView.context, "아이템 '${data.title}'를 클릭했습니다.", Toast.LENGTH_LONG).show()
55+
})
56+
}
57+
}
58+
59+
60+
}
61+
62+
63+
class DashboardFragment : Fragment() {
64+
65+
private var _binding: FragmentDashboardBinding? = null
66+
67+
// This property is only valid between onCreateView and
68+
// onDestroyView.
69+
private val binding get() = _binding!!
70+
71+
//클릭시 이미지 확대
72+
// private fun clickEvent(view: View, pos: Int) {
73+
// val intent = Intent(this, ImageActivity::class.java)
74+
// intent.putExtra("pos", pos)
75+
// val opt = ActivityOptions.makeSceneTransitionAnimation(this, view, "imgTrans")
76+
// startActivity(intent, opt.toBundle())
77+
// }
78+
79+
override fun onCreateView(
80+
inflater: LayoutInflater,
81+
container: ViewGroup?,
82+
savedInstanceState: Bundle?
83+
): View {
84+
val dashboardViewModel =
85+
ViewModelProvider(this).get(DashboardViewModel::class.java)
86+
87+
_binding = FragmentDashboardBinding.inflate(inflater, container, false)
88+
val root: View = binding.root
89+
90+
val textView: TextView = binding.textDashboard
91+
dashboardViewModel.text.observe(viewLifecycleOwner) {
92+
textView.text = it
93+
}
94+
95+
/*make itemList*/
96+
val itemList = ArrayList<BoardItem>()
97+
itemList.add(BoardItem("res/drawable/jokebear33.jpg","농담입니다","2023/07/01"))
98+
itemList.add(BoardItem("https://postfiles.pstatic.net/MjAyMTEyMTdfNDIg/MDAxNjM5NzI0NTM0NTQy.Kg00KseRfKe1s7IYhOxaA_q8ZwPqrmyf5rg1loN9scEg.UGdQ2hlKt4RzmTXAlMuzwWM9q3F3L88euDZZfwvw8Wwg.JPEG.xvx404/KakaoTalk_20211104_114046906.jpg?type=w966","농담곰인물","2023/07/01"))
99+
itemList.add(BoardItem("res/drawable/jokebear33.jpg","농담입니다","2023/07/01"))
100+
itemList.add(BoardItem("https://postfiles.pstatic.net/MjAyMTEyMTdfNDIg/MDAxNjM5NzI0NTM0NTQy.Kg00KseRfKe1s7IYhOxaA_q8ZwPqrmyf5rg1loN9scEg.UGdQ2hlKt4RzmTXAlMuzwWM9q3F3L88euDZZfwvw8Wwg.JPEG.xvx404/KakaoTalk_20211104_114046906.jpg?type=w966","농담곰인물","2023/07/01"))
101+
itemList.add(BoardItem("res/drawable/jokebear33.jpg","농담입니다","2023/07/01"))
102+
itemList.add(BoardItem("https://postfiles.pstatic.net/MjAyMTEyMTdfNDIg/MDAxNjM5NzI0NTM0NTQy.Kg00KseRfKe1s7IYhOxaA_q8ZwPqrmyf5rg1loN9scEg.UGdQ2hlKt4RzmTXAlMuzwWM9q3F3L88euDZZfwvw8Wwg.JPEG.xvx404/KakaoTalk_20211104_114046906.jpg?type=w966","농담곰인물","2023/07/01"))
103+
itemList.add(BoardItem("res/drawable/jokebear33.jpg","농담입니다","2023/07/01"))
104+
itemList.add(BoardItem("https://postfiles.pstatic.net/MjAyMTEyMTdfNDIg/MDAxNjM5NzI0NTM0NTQy.Kg00KseRfKe1s7IYhOxaA_q8ZwPqrmyf5rg1loN9scEg.UGdQ2hlKt4RzmTXAlMuzwWM9q3F3L88euDZZfwvw8Wwg.JPEG.xvx404/KakaoTalk_20211104_114046906.jpg?type=w966","농담곰인물","2023/07/01"))
105+
itemList.add(BoardItem("res/drawable/jokebear33.jpg","농담입니다","2023/07/01"))
106+
itemList.add(BoardItem("https://postfiles.pstatic.net/MjAyMTEyMTdfNDIg/MDAxNjM5NzI0NTM0NTQy.Kg00KseRfKe1s7IYhOxaA_q8ZwPqrmyf5rg1loN9scEg.UGdQ2hlKt4RzmTXAlMuzwWM9q3F3L88euDZZfwvw8Wwg.JPEG.xvx404/KakaoTalk_20211104_114046906.jpg?type=w966","농담곰인물","2023/07/01"))
107+
itemList.add(BoardItem("res/drawable/jokebear33.jpg","농담입니다","2023/07/01"))
108+
itemList.add(BoardItem("https://postfiles.pstatic.net/MjAyMTEyMTdfNDIg/MDAxNjM5NzI0NTM0NTQy.Kg00KseRfKe1s7IYhOxaA_q8ZwPqrmyf5rg1loN9scEg.UGdQ2hlKt4RzmTXAlMuzwWM9q3F3L88euDZZfwvw8Wwg.JPEG.xvx404/KakaoTalk_20211104_114046906.jpg?type=w966","농담곰인물","2023/07/01"))
109+
110+
val boardAdapter = BoardAdapter(itemList)
111+
boardAdapter.notifyDataSetChanged()
112+
113+
val RV_board :RecyclerView = binding.rvBoard
114+
RV_board.adapter = boardAdapter
115+
RV_board.layoutManager = GridLayoutManager(context, 2, GridLayoutManager.VERTICAL, false)
116+
117+
return root
118+
}
119+
120+
121+
override fun onDestroyView() {
122+
super.onDestroyView()
123+
_binding = null
124+
}
125+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.example.tap.ui.dashboard
2+
3+
import androidx.lifecycle.LiveData
4+
import androidx.lifecycle.MutableLiveData
5+
import androidx.lifecycle.ViewModel
6+
7+
class DashboardViewModel : ViewModel() {
8+
9+
private val _text = MutableLiveData<String>().apply {
10+
value = "This is ww Fragment"
11+
}
12+
val text: LiveData<String> = _text
13+
}

0 commit comments

Comments
 (0)