diff --git a/newProject/.gitignore b/assignment_week_7/.gitignore similarity index 100% rename from newProject/.gitignore rename to assignment_week_7/.gitignore diff --git a/newProject/.idea/compiler.xml b/assignment_week_7/.idea/compiler.xml similarity index 100% rename from newProject/.idea/compiler.xml rename to assignment_week_7/.idea/compiler.xml diff --git a/newProject/.idea/deploymentTargetSelector.xml b/assignment_week_7/.idea/deploymentTargetSelector.xml similarity index 100% rename from newProject/.idea/deploymentTargetSelector.xml rename to assignment_week_7/.idea/deploymentTargetSelector.xml diff --git a/newProject/.idea/gradle.xml b/assignment_week_7/.idea/gradle.xml similarity index 100% rename from newProject/.idea/gradle.xml rename to assignment_week_7/.idea/gradle.xml diff --git a/newProject/.idea/kotlinc.xml b/assignment_week_7/.idea/kotlinc.xml similarity index 100% rename from newProject/.idea/kotlinc.xml rename to assignment_week_7/.idea/kotlinc.xml diff --git a/newProject/.idea/migrations.xml b/assignment_week_7/.idea/migrations.xml similarity index 100% rename from newProject/.idea/migrations.xml rename to assignment_week_7/.idea/migrations.xml diff --git a/newProject/.idea/misc.xml b/assignment_week_7/.idea/misc.xml similarity index 100% rename from newProject/.idea/misc.xml rename to assignment_week_7/.idea/misc.xml diff --git a/newProject/.idea/vcs.xml b/assignment_week_7/.idea/vcs.xml similarity index 82% rename from newProject/.idea/vcs.xml rename to assignment_week_7/.idea/vcs.xml index 62bd7a0..6c0b863 100644 --- a/newProject/.idea/vcs.xml +++ b/assignment_week_7/.idea/vcs.xml @@ -1,7 +1,6 @@ - \ No newline at end of file diff --git a/newProject/app/.gitignore b/assignment_week_7/app/.gitignore similarity index 100% rename from newProject/app/.gitignore rename to assignment_week_7/app/.gitignore diff --git a/newProject/app/build.gradle.kts b/assignment_week_7/app/build.gradle.kts similarity index 100% rename from newProject/app/build.gradle.kts rename to assignment_week_7/app/build.gradle.kts diff --git a/newProject/app/proguard-rules.pro b/assignment_week_7/app/proguard-rules.pro similarity index 100% rename from newProject/app/proguard-rules.pro rename to assignment_week_7/app/proguard-rules.pro diff --git a/newProject/app/src/androidTest/java/com/example/assignment_week_7/ExampleInstrumentedTest.kt b/assignment_week_7/app/src/androidTest/java/com/example/assignment_week_7/ExampleInstrumentedTest.kt similarity index 100% rename from newProject/app/src/androidTest/java/com/example/assignment_week_7/ExampleInstrumentedTest.kt rename to assignment_week_7/app/src/androidTest/java/com/example/assignment_week_7/ExampleInstrumentedTest.kt diff --git a/newProject/app/src/main/AndroidManifest.xml b/assignment_week_7/app/src/main/AndroidManifest.xml similarity index 100% rename from newProject/app/src/main/AndroidManifest.xml rename to assignment_week_7/app/src/main/AndroidManifest.xml diff --git a/assignment_week_7/app/src/main/java/com/example/assignment_week_7/MainActivity.kt b/assignment_week_7/app/src/main/java/com/example/assignment_week_7/MainActivity.kt new file mode 100644 index 0000000..8f7a266 --- /dev/null +++ b/assignment_week_7/app/src/main/java/com/example/assignment_week_7/MainActivity.kt @@ -0,0 +1,85 @@ +package com.example.assignment_week_7 + +import android.os.Bundle +import android.widget.EditText +import android.widget.Button +import androidx.activity.enableEdgeToEdge +import androidx.appcompat.app.AlertDialog +import androidx.appcompat.app.AppCompatActivity +import androidx.core.view.ViewCompat +import androidx.core.view.WindowInsetsCompat +import androidx.recyclerview.widget.LinearLayoutManager +import androidx.recyclerview.widget.RecyclerView + +class MainActivity : AppCompatActivity() { + private lateinit var adapter: NameAdapter + private val names = mutableListOf() + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + enableEdgeToEdge() + setContentView(R.layout.activity_main) + ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets -> + val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars()) + v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom) + insets + } + + setupRecyclerView() + setupAddButton() + } + + private fun setupRecyclerView() { + adapter = NameAdapter( + names, + onItemClick = { position -> showDeleteDialog(position) }, + onItemLongClick = { position -> showEditDialog(position) } + ) + findViewById(R.id.recyclerView).apply { + layoutManager = LinearLayoutManager(this@MainActivity) + adapter = this@MainActivity.adapter + } + } + + private fun setupAddButton() { + val nameEditText = findViewById(R.id.editText) + findViewById