From 4da7a9cdbc035beda9017fc9d3fc64548fe684cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=97=B1=20PixelyIon?= Date: Thu, 4 Jul 2019 02:18:43 +0530 Subject: [PATCH] Support non-libnx NROs --- .../java/gq/cyuubi/lightswitch/FileAdapter.java | 14 ++++++++++---- .../java/gq/cyuubi/lightswitch/MainActivity.java | 2 +- app/src/main/res/values/strings.xml | 1 + 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/gq/cyuubi/lightswitch/FileAdapter.java b/app/src/main/java/gq/cyuubi/lightswitch/FileAdapter.java index cdda9333..0cee1f22 100644 --- a/app/src/main/java/gq/cyuubi/lightswitch/FileAdapter.java +++ b/app/src/main/java/gq/cyuubi/lightswitch/FileAdapter.java @@ -25,10 +25,13 @@ class GameItem { int index; - public GameItem(File file) { + public GameItem(File file, Context ctx) { this.file = file; index = file.getName().lastIndexOf("."); meta = NroMeta.getTitleEntry(getPath()); + if(meta==null) { + meta = new TitleEntry(file.getName(), ctx.getString(R.string.aset_missing), null); + } } public Bitmap getIcon() { @@ -39,7 +42,7 @@ class GameItem { return meta.getName() + " (" + getType() + ")"; } - public String getAuthor() { + public String getSubTitle() { return meta.getAuthor(); } @@ -93,8 +96,11 @@ public class FileAdapter extends ArrayAdapter implements View.OnClickL viewHolder = (ViewHolder) convertView.getTag(); } viewHolder.txtTitle.setText(dataModel.getTitle()); - viewHolder.txtSub.setText(dataModel.getAuthor()); - viewHolder.icon.setImageBitmap(dataModel.getIcon()); + viewHolder.txtSub.setText(dataModel.getSubTitle()); + Bitmap icon = dataModel.getIcon(); + if(icon!=null) { + viewHolder.icon.setImageBitmap(icon); + } viewHolder.icon.setOnClickListener(this); viewHolder.icon.setTag(position); return convertView; diff --git a/app/src/main/java/gq/cyuubi/lightswitch/MainActivity.java b/app/src/main/java/gq/cyuubi/lightswitch/MainActivity.java index 92497057..57dfbf4f 100644 --- a/app/src/main/java/gq/cyuubi/lightswitch/MainActivity.java +++ b/app/src/main/java/gq/cyuubi/lightswitch/MainActivity.java @@ -67,7 +67,7 @@ public class MainActivity extends AppCompatActivity { adapter.clear(); List files = findFile("nro", new File(sharedPreferences.getString("search_location", "")), null); for (File file : files) { - adapter.add(new GameItem(file)); + adapter.add(new GameItem(file, getApplicationContext())); } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 08f2e00b..d658c887 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -6,6 +6,7 @@ The list of ROMs has been refreshed. Launching + ASET Header Missing Icon Search