mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-11-29 13:44:20 +01:00
UI update: Pop-up Icons
The icons of games will now pop-up if you click on them.
This commit is contained in:
parent
ae6dddf9f6
commit
3ed3365d81
@ -1,12 +1,17 @@
|
|||||||
package gq.cyuubi.lightswitch;
|
package gq.cyuubi.lightswitch;
|
||||||
|
|
||||||
|
import android.app.Dialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.drawable.ColorDrawable;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.view.Window;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
import android.widget.RelativeLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
@ -14,13 +19,13 @@ import androidx.annotation.NonNull;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
class DataModel {
|
class GameItem {
|
||||||
File file;
|
File file;
|
||||||
TitleEntry meta;
|
TitleEntry meta;
|
||||||
|
|
||||||
int index;
|
int index;
|
||||||
|
|
||||||
public DataModel(File file) {
|
public GameItem(File file) {
|
||||||
this.file = file;
|
this.file = file;
|
||||||
index = file.getName().lastIndexOf(".");
|
index = file.getName().lastIndexOf(".");
|
||||||
meta = NroMeta.GetNroTitle(getPath());
|
meta = NroMeta.GetNroTitle(getPath());
|
||||||
@ -34,10 +39,6 @@ class DataModel {
|
|||||||
return meta.getName() + " (" + getType() + ")";
|
return meta.getName() + " (" + getType() + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFileName() {
|
|
||||||
return file.getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAuthor() {
|
public String getAuthor() {
|
||||||
return meta.getAuthor();
|
return meta.getAuthor();
|
||||||
}
|
}
|
||||||
@ -51,33 +52,34 @@ class DataModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class FileAdapter extends ArrayAdapter<DataModel> implements View.OnClickListener {
|
public class FileAdapter extends ArrayAdapter<GameItem> implements View.OnClickListener {
|
||||||
|
|
||||||
Context mContext;
|
Context mContext;
|
||||||
private ArrayList<DataModel> dataSet;
|
|
||||||
|
|
||||||
public FileAdapter(Context context, @NonNull ArrayList<DataModel> data) {
|
public FileAdapter(Context context, @NonNull ArrayList<GameItem> data) {
|
||||||
super(context, R.layout.file_item, data);
|
super(context, R.layout.file_item, data);
|
||||||
this.dataSet = new ArrayList<>();
|
|
||||||
this.mContext = context;
|
this.mContext = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
|
||||||
int position = (Integer) v.getTag();
|
int position = (Integer) v.getTag();
|
||||||
Object object = getItem(position);
|
GameItem dataModel = getItem(position);
|
||||||
DataModel dataModel = (DataModel) object;
|
|
||||||
switch (v.getId()) {
|
switch (v.getId()) {
|
||||||
case R.id.icon:
|
case R.id.icon:
|
||||||
|
Dialog builder = new Dialog(mContext);
|
||||||
|
builder.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||||
|
builder.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
|
||||||
|
ImageView imageView = new ImageView(mContext);
|
||||||
|
imageView.setImageBitmap(dataModel.getIcon());
|
||||||
|
builder.addContentView(imageView, new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||||
|
builder.show();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View getView(int position, View convertView, ViewGroup parent) {
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
DataModel dataModel = getItem(position);
|
GameItem dataModel = getItem(position);
|
||||||
ViewHolder viewHolder;
|
ViewHolder viewHolder;
|
||||||
if (convertView == null) {
|
if (convertView == null) {
|
||||||
viewHolder = new ViewHolder();
|
viewHolder = new ViewHolder();
|
||||||
@ -93,6 +95,8 @@ public class FileAdapter extends ArrayAdapter<DataModel> implements View.OnClick
|
|||||||
viewHolder.txtTitle.setText(dataModel.getTitle());
|
viewHolder.txtTitle.setText(dataModel.getTitle());
|
||||||
viewHolder.txtSub.setText(dataModel.getAuthor());
|
viewHolder.txtSub.setText(dataModel.getAuthor());
|
||||||
viewHolder.icon.setImageBitmap(dataModel.getIcon());
|
viewHolder.icon.setImageBitmap(dataModel.getIcon());
|
||||||
|
viewHolder.icon.setOnClickListener(this);
|
||||||
|
viewHolder.icon.setTag(position);
|
||||||
return convertView;
|
return convertView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,6 @@ import android.view.MenuItem;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
@ -66,7 +65,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
adapter.clear();
|
adapter.clear();
|
||||||
List<File> files = findFile("nro", new File(sharedPreferences.getString("search_location", "")), null);
|
List<File> files = findFile("nro", new File(sharedPreferences.getString("search_location", "")), null);
|
||||||
for (File file : files) {
|
for (File file : files) {
|
||||||
adapter.add(new DataModel(file));
|
adapter.add(new GameItem(file));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,13 +82,13 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
|
setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
|
||||||
PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
|
PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
|
||||||
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
|
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
adapter = new FileAdapter(this, new ArrayList<DataModel>());
|
adapter = new FileAdapter(this, new ArrayList<GameItem>());
|
||||||
ListView game_list = findViewById(R.id.game_list);
|
ListView game_list = findViewById(R.id.game_list);
|
||||||
game_list.setAdapter(adapter);
|
game_list.setAdapter(adapter);
|
||||||
game_list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
game_list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||||
String path = ((DataModel) parent.getItemAtPosition(position)).getPath();
|
String path = ((GameItem) parent.getItemAtPosition(position)).getPath();
|
||||||
notifyUser(getString(R.string.launch_string) + " " + path);
|
notifyUser(getString(R.string.launch_string) + " " + path);
|
||||||
loadFile(path);
|
loadFile(path);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user