From 07e0a5422efd6a105b0ed5e316f06c3212be55f4 Mon Sep 17 00:00:00 2001 From: Isaac Shoebottom Date: Tue, 6 Dec 2022 06:09:54 -0400 Subject: [PATCH] Add back recycler view code --- .../java/com/example/myapplication/MainActivity.kt | 13 +++++++++++-- .../myapplication/ui/settings/SettingsFragment.kt | 5 +---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/example/myapplication/MainActivity.kt b/app/src/main/java/com/example/myapplication/MainActivity.kt index 6c4b446..c72af23 100644 --- a/app/src/main/java/com/example/myapplication/MainActivity.kt +++ b/app/src/main/java/com/example/myapplication/MainActivity.kt @@ -5,11 +5,10 @@ import android.content.Intent import android.net.Uri import android.os.Bundle import android.view.Menu -import android.view.View import android.view.MenuItem +import android.view.View import android.widget.Toast import androidx.activity.result.contract.ActivityResultContracts -import com.google.android.material.bottomnavigation.BottomNavigationView import androidx.appcompat.app.AppCompatActivity import androidx.navigation.findNavController import androidx.navigation.ui.AppBarConfiguration @@ -54,7 +53,14 @@ class MainActivity : AppCompatActivity() { //adds actions for when you press buttons override fun onOptionsItemSelected(item: MenuItem): Boolean { + val compressingRecycler = findViewById(R.id.compressing_recycler_view) as? RecyclerView + compressingRecycler?.adapter = CompressingAdapter(compressingItems) + compressingRecycler?.layoutManager = LinearLayoutManager(this) + return when (item.itemId) { + + + //runs when pressing "Files" R.id.addFile -> { val intent = Intent() @@ -64,6 +70,9 @@ class MainActivity : AppCompatActivity() { resultLauncher.launch(intent) Toast.makeText(applicationContext, "Files", Toast.LENGTH_LONG).show() + + compressingItems.add(CompressingItem("Testing", 0.5, Date(1))) + return true } R.id.addYoutube ->{ diff --git a/app/src/main/java/com/example/myapplication/ui/settings/SettingsFragment.kt b/app/src/main/java/com/example/myapplication/ui/settings/SettingsFragment.kt index fe6509b..5e2b11b 100644 --- a/app/src/main/java/com/example/myapplication/ui/settings/SettingsFragment.kt +++ b/app/src/main/java/com/example/myapplication/ui/settings/SettingsFragment.kt @@ -6,10 +6,7 @@ import android.text.TextWatcher import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import android.widget.RadioButton import android.widget.Toast -import androidx.core.view.isVisible -import androidx.core.widget.addTextChangedListener import androidx.fragment.app.Fragment import androidx.lifecycle.ViewModelProvider import com.example.myapplication.databinding.FragmentSettingsBinding @@ -28,7 +25,7 @@ class SettingsFragment : Fragment() { container: ViewGroup?, savedInstanceState: Bundle? ): View { - ViewModelProvider(this)[SettingsViewModel::class.java] + val homeViewModel = ViewModelProvider(this)[SettingsViewModel::class.java] _binding = FragmentSettingsBinding.inflate(inflater, container, false) val root: View = binding.root