mirror of
https://github.com/IllusionMan1212/NPS-Browser.git
synced 2026-10-24 18:12:38 +00:00
Add RecyclerView to display basic app list and parse PSVita data only for now
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package com.illusionware.npsbrowser.activities
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.illusionware.npsbrowser.AppData
|
||||
import com.illusionware.npsbrowser.RecyclerTouchListener
|
||||
import com.illusionware.npsbrowser.adapters.AppAdapter
|
||||
import com.illusionware.npsbrowser.databinding.ActivityAppsListBinding
|
||||
|
||||
class AppsListActivity : AppCompatActivity() {
|
||||
companion object {
|
||||
lateinit var apps : ArrayList<AppData>
|
||||
}
|
||||
private lateinit var recyclerView: RecyclerView
|
||||
private lateinit var viewAdapter: RecyclerView.Adapter<*>
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
val binding = ActivityAppsListBinding.inflate(layoutInflater);
|
||||
setContentView(binding.root)
|
||||
|
||||
viewAdapter = AppAdapter(apps)
|
||||
|
||||
recyclerView = binding.appsRecycler
|
||||
recyclerView.apply {
|
||||
layoutManager = LinearLayoutManager(applicationContext)
|
||||
adapter = viewAdapter
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import android.util.Log
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.app.ActivityCompat
|
||||
import com.github.doyaaaaaken.kotlincsv.dsl.csvReader
|
||||
import com.illusionware.npsbrowser.AppData
|
||||
import com.illusionware.npsbrowser.databinding.ActivityMainBinding
|
||||
import java.io.InputStream
|
||||
|
||||
@@ -42,7 +43,32 @@ class MainActivity : AppCompatActivity() {
|
||||
if (requestCode == 1 && resultCode == Activity.RESULT_OK) {
|
||||
resultData?.data?.also { uri ->
|
||||
val inputStream: InputStream? = contentResolver.openInputStream(uri)
|
||||
val entries : List<Map<String, String>> = tsvReader.readAllWithHeader(inputStream!!)
|
||||
val entries : List<Map<String, String?>> = tsvReader.readAllWithHeader(inputStream!!)
|
||||
val myIntent = Intent(this, AppsListActivity::class.java)
|
||||
var apps = ArrayList<AppData>(entries.size)
|
||||
|
||||
entries.forEach { entry ->
|
||||
if (entry["Name"].isNullOrEmpty()) {
|
||||
return@forEach;
|
||||
}
|
||||
val id = entry["Title ID"]
|
||||
val region = entry["Region"]
|
||||
val name = entry["Name"]
|
||||
val link = entry["PKG direct link"]
|
||||
val license = entry["zRIF"]
|
||||
val contentID = entry["Content ID"]
|
||||
val lastDateTime = entry["Last Modification Date"]
|
||||
val fileSize = entry["File Size"]?.toLongOrNull()
|
||||
val sha256 = entry["SHA256"]
|
||||
val minFW = entry["Required FW"]
|
||||
var app = AppData(id, region, name, link ?: "MISSING", license ?: "MISSING",
|
||||
contentID ?: "MISSING", lastDateTime ?: "MISSING",
|
||||
fileSize ?: 0, sha256 ?: "MISSING", minFW ?: "MISSING")
|
||||
apps.add(app)
|
||||
}
|
||||
apps.sortBy { it.Title }
|
||||
AppsListActivity.apps = apps;
|
||||
startActivity(myIntent)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user