Skip to content

Commit 4165bb1

Browse files
committed
feat: initial commit with minimal UI
0 parents  commit 4165bb1

50 files changed

Lines changed: 1137 additions & 0 deletions

Some content is hidden

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

.gitignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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
16+
.idea

app/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

app/build.gradle.kts

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
plugins {
2+
alias(libs.plugins.android.application)
3+
alias(libs.plugins.kotlin.android)
4+
}
5+
6+
android {
7+
namespace = "com.example.pokemoncollection"
8+
compileSdk = 35
9+
10+
defaultConfig {
11+
applicationId = "com.example.pokemoncollection"
12+
minSdk = 24
13+
targetSdk = 35
14+
versionCode = 1
15+
versionName = "1.0"
16+
17+
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
18+
}
19+
20+
buildTypes {
21+
release {
22+
isMinifyEnabled = false
23+
proguardFiles(
24+
getDefaultProguardFile("proguard-android-optimize.txt"),
25+
"proguard-rules.pro"
26+
)
27+
}
28+
}
29+
compileOptions {
30+
sourceCompatibility = JavaVersion.VERSION_11
31+
targetCompatibility = JavaVersion.VERSION_11
32+
}
33+
kotlinOptions {
34+
jvmTarget = "11"
35+
}
36+
buildFeatures {
37+
viewBinding = true
38+
}
39+
}
40+
41+
dependencies {
42+
43+
implementation(libs.androidx.core.ktx)
44+
implementation(libs.androidx.appcompat)
45+
implementation(libs.material)
46+
implementation(libs.androidx.constraintlayout)
47+
implementation(libs.androidx.lifecycle.livedata.ktx)
48+
implementation(libs.androidx.lifecycle.viewmodel.ktx)
49+
implementation(libs.androidx.navigation.fragment.ktx)
50+
implementation(libs.androidx.navigation.ui.ktx)
51+
testImplementation(libs.junit)
52+
androidTestImplementation(libs.androidx.junit)
53+
androidTestImplementation(libs.androidx.espresso.core)
54+
}

app/proguard-rules.pro

Lines changed: 21 additions & 0 deletions
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
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.example.pokemoncollection
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.pokemoncollection", appContext.packageName)
23+
}
24+
}

app/src/main/AndroidManifest.xml

Lines changed: 27 additions & 0 deletions
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.PokemonCollection"
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+
27+
</manifest>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.example.pokemoncollection
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.setupWithNavController
8+
import com.example.pokemoncollection.databinding.ActivityMainBinding
9+
10+
class MainActivity : AppCompatActivity() {
11+
12+
private lateinit var binding: ActivityMainBinding
13+
14+
override fun onCreate(savedInstanceState: Bundle?) {
15+
super.onCreate(savedInstanceState)
16+
17+
binding = ActivityMainBinding.inflate(layoutInflater)
18+
setContentView(binding.root)
19+
20+
val navView: BottomNavigationView = binding.navView
21+
22+
val navController = findNavController(R.id.nav_host_fragment_activity_main)
23+
navView.setupWithNavController(navController)
24+
}
25+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.example.pokemoncollection.adapter
2+
3+
import android.view.LayoutInflater
4+
import android.view.View
5+
import android.view.ViewGroup
6+
import android.widget.TextView
7+
import androidx.recyclerview.widget.RecyclerView
8+
import com.example.pokemoncollection.R
9+
import com.example.pokemoncollection.ui.home.Pokemon
10+
11+
class PokemonAdapter(private val pokemonList: List<Pokemon>) :
12+
RecyclerView.Adapter<PokemonAdapter.PokemonViewHolder>() {
13+
14+
class PokemonViewHolder(view: View) : RecyclerView.ViewHolder(view) {
15+
val nameText: TextView = view.findViewById(R.id.pokemonName)
16+
val descText: TextView = view.findViewById(R.id.pokemonDescription)
17+
}
18+
19+
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): PokemonViewHolder {
20+
val view = LayoutInflater.from(parent.context)
21+
.inflate(R.layout.item_pokemon, parent, false)
22+
return PokemonViewHolder(view)
23+
}
24+
25+
override fun onBindViewHolder(holder: PokemonViewHolder, position: Int) {
26+
val pokemon = pokemonList[position]
27+
holder.nameText.text = pokemon.name
28+
holder.descText.text = pokemon.description
29+
}
30+
31+
override fun getItemCount(): Int = pokemonList.size
32+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.example.pokemoncollection.ui.dashboard
2+
3+
import android.os.Bundle
4+
import android.view.LayoutInflater
5+
import android.view.View
6+
import android.view.ViewGroup
7+
import androidx.fragment.app.Fragment
8+
import com.example.pokemoncollection.databinding.FragmentDashboardBinding
9+
10+
class DashboardFragment : Fragment() {
11+
12+
private var _binding: FragmentDashboardBinding? = null
13+
14+
// This property is only valid between onCreateView and
15+
// onDestroyView.
16+
private val binding get() = _binding!!
17+
18+
override fun onCreateView(
19+
inflater: LayoutInflater,
20+
container: ViewGroup?,
21+
savedInstanceState: Bundle?
22+
): View {
23+
_binding = FragmentDashboardBinding.inflate(inflater, container, false)
24+
val root: View = binding.root
25+
26+
27+
binding.sampleButton.setOnClickListener {
28+
println("Dashboard Button clicked!") // Shows in Logcat under System.out
29+
}
30+
return root
31+
}
32+
33+
override fun onDestroyView() {
34+
super.onDestroyView()
35+
_binding = null
36+
}
37+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package com.example.pokemoncollection.ui.home
2+
3+
import android.os.Bundle
4+
import android.view.LayoutInflater
5+
import android.view.View
6+
import android.view.ViewGroup
7+
import android.widget.TextView
8+
import androidx.fragment.app.Fragment
9+
import androidx.lifecycle.ViewModelProvider
10+
import com.example.pokemoncollection.adapter.PokemonAdapter
11+
import com.example.pokemoncollection.databinding.FragmentHomeBinding
12+
13+
class HomeFragment : Fragment() {
14+
15+
private var _binding: FragmentHomeBinding? = null
16+
17+
// This property is only valid between onCreateView and
18+
// onDestroyView.
19+
private val binding get() = _binding!!
20+
21+
override fun onCreateView(
22+
inflater: LayoutInflater,
23+
container: ViewGroup?,
24+
savedInstanceState: Bundle?
25+
): View {
26+
val homeViewModel =
27+
ViewModelProvider(this)[HomeViewModel::class.java]
28+
29+
_binding = FragmentHomeBinding.inflate(inflater, container, false)
30+
val root: View = binding.root
31+
32+
val adapter = PokemonAdapter(homeViewModel.pokemonList)
33+
binding.pokemonRecyclerView.adapter = adapter
34+
35+
return root
36+
}
37+
38+
override fun onDestroyView() {
39+
super.onDestroyView()
40+
_binding = null
41+
}
42+
}

0 commit comments

Comments
 (0)