RetroArch/android/phoenix/src/com/retroarch/browser/HistorySelection.java

114 lines
3.3 KiB
Java
Raw Normal View History

package com.retroarch.browser;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import com.retroarch.R;
[Android] Initial huge underlying UI update: - The UI is now mostly Fragment-centric (finally!) - The Load Core, Load Game, Load Game (History) are now DialogFragments. - The directory activities are killed off and consolidated into one fragment named DirectoryFragment. DirectoryFragment is now a self-contained instantiable DirectoryFragment that can be instantiated anywhere by doing roughly the following. DirectorFragment dFrag = DirectoryFragment.newInstance(/* Resource ID for a string title here*/); dFrag.show(getFragmentManager(), "tag"); There are also other methods that were modified within the DirectoryFragment, such as addAllowedExt and disAllowedExt being changed to support a variable amount of arguments. This way, multiple calls of the same function aren't necessary in the case of adding multiple extensions, as well as supporting the case where only one extension is added. DirectoryFragment also has a new interface added to it called OnDirectoryFragmentClosedListener. Say you have a DirectoryFragment instance, but want to use the selected item's path for something *after* the dialog has closed, with this interface, it is now possible. Just implement this interface within an Activity or Fragment, and then set the DirectoryFragment to use the listener through setOnDirectoryFragmentClosedListener() method. Now what happens if this isn't set, wouldn't it be pointless to even use a DirectoryFragment in this case? Not necessarily. What if you only wanted to save the selected item into the applications SharedPreferences? This is a situation where it would be unnecessary to need that interface. So, to make a DirectoryFragment.java for the sole purpose of saving a selected directory/file path to the SharedPreferences, you would do this: DirectoryFragment dFrag = DirectoryFragment.newInstance(/* Resource ID to a string title here*/); dFrag.setPathSettingKey("key to store value in SharedPreferences at"); dFrag.show(getFragmentManager(), "tag"); Outside of these major changes, large portions of the code outside of this were simplified.
2013-11-17 02:37:33 -05:00
import com.retroarch.browser.mainmenu.MainMenuActivity;
import com.retroarch.browser.preferences.util.UserPreferences;
import android.content.Intent;
import android.os.Bundle;
import android.provider.Settings;
[Android] Initial huge underlying UI update: - The UI is now mostly Fragment-centric (finally!) - The Load Core, Load Game, Load Game (History) are now DialogFragments. - The directory activities are killed off and consolidated into one fragment named DirectoryFragment. DirectoryFragment is now a self-contained instantiable DirectoryFragment that can be instantiated anywhere by doing roughly the following. DirectorFragment dFrag = DirectoryFragment.newInstance(/* Resource ID for a string title here*/); dFrag.show(getFragmentManager(), "tag"); There are also other methods that were modified within the DirectoryFragment, such as addAllowedExt and disAllowedExt being changed to support a variable amount of arguments. This way, multiple calls of the same function aren't necessary in the case of adding multiple extensions, as well as supporting the case where only one extension is added. DirectoryFragment also has a new interface added to it called OnDirectoryFragmentClosedListener. Say you have a DirectoryFragment instance, but want to use the selected item's path for something *after* the dialog has closed, with this interface, it is now possible. Just implement this interface within an Activity or Fragment, and then set the DirectoryFragment to use the listener through setOnDirectoryFragmentClosedListener() method. Now what happens if this isn't set, wouldn't it be pointless to even use a DirectoryFragment in this case? Not necessarily. What if you only wanted to save the selected item into the applications SharedPreferences? This is a situation where it would be unnecessary to need that interface. So, to make a DirectoryFragment.java for the sole purpose of saving a selected directory/file path to the SharedPreferences, you would do this: DirectoryFragment dFrag = DirectoryFragment.newInstance(/* Resource ID to a string title here*/); dFrag.setPathSettingKey("key to store value in SharedPreferences at"); dFrag.show(getFragmentManager(), "tag"); Outside of these major changes, large portions of the code outside of this were simplified.
2013-11-17 02:37:33 -05:00
import android.support.v4.app.DialogFragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.ListFragment;
import android.view.LayoutInflater;
import android.view.View;
[Android] Initial huge underlying UI update: - The UI is now mostly Fragment-centric (finally!) - The Load Core, Load Game, Load Game (History) are now DialogFragments. - The directory activities are killed off and consolidated into one fragment named DirectoryFragment. DirectoryFragment is now a self-contained instantiable DirectoryFragment that can be instantiated anywhere by doing roughly the following. DirectorFragment dFrag = DirectoryFragment.newInstance(/* Resource ID for a string title here*/); dFrag.show(getFragmentManager(), "tag"); There are also other methods that were modified within the DirectoryFragment, such as addAllowedExt and disAllowedExt being changed to support a variable amount of arguments. This way, multiple calls of the same function aren't necessary in the case of adding multiple extensions, as well as supporting the case where only one extension is added. DirectoryFragment also has a new interface added to it called OnDirectoryFragmentClosedListener. Say you have a DirectoryFragment instance, but want to use the selected item's path for something *after* the dialog has closed, with this interface, it is now possible. Just implement this interface within an Activity or Fragment, and then set the DirectoryFragment to use the listener through setOnDirectoryFragmentClosedListener() method. Now what happens if this isn't set, wouldn't it be pointless to even use a DirectoryFragment in this case? Not necessarily. What if you only wanted to save the selected item into the applications SharedPreferences? This is a situation where it would be unnecessary to need that interface. So, to make a DirectoryFragment.java for the sole purpose of saving a selected directory/file path to the SharedPreferences, you would do this: DirectoryFragment dFrag = DirectoryFragment.newInstance(/* Resource ID to a string title here*/); dFrag.setPathSettingKey("key to store value in SharedPreferences at"); dFrag.show(getFragmentManager(), "tag"); Outside of these major changes, large portions of the code outside of this were simplified.
2013-11-17 02:37:33 -05:00
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.Toast;
/**
[Android] Initial huge underlying UI update: - The UI is now mostly Fragment-centric (finally!) - The Load Core, Load Game, Load Game (History) are now DialogFragments. - The directory activities are killed off and consolidated into one fragment named DirectoryFragment. DirectoryFragment is now a self-contained instantiable DirectoryFragment that can be instantiated anywhere by doing roughly the following. DirectorFragment dFrag = DirectoryFragment.newInstance(/* Resource ID for a string title here*/); dFrag.show(getFragmentManager(), "tag"); There are also other methods that were modified within the DirectoryFragment, such as addAllowedExt and disAllowedExt being changed to support a variable amount of arguments. This way, multiple calls of the same function aren't necessary in the case of adding multiple extensions, as well as supporting the case where only one extension is added. DirectoryFragment also has a new interface added to it called OnDirectoryFragmentClosedListener. Say you have a DirectoryFragment instance, but want to use the selected item's path for something *after* the dialog has closed, with this interface, it is now possible. Just implement this interface within an Activity or Fragment, and then set the DirectoryFragment to use the listener through setOnDirectoryFragmentClosedListener() method. Now what happens if this isn't set, wouldn't it be pointless to even use a DirectoryFragment in this case? Not necessarily. What if you only wanted to save the selected item into the applications SharedPreferences? This is a situation where it would be unnecessary to need that interface. So, to make a DirectoryFragment.java for the sole purpose of saving a selected directory/file path to the SharedPreferences, you would do this: DirectoryFragment dFrag = DirectoryFragment.newInstance(/* Resource ID to a string title here*/); dFrag.setPathSettingKey("key to store value in SharedPreferences at"); dFrag.show(getFragmentManager(), "tag"); Outside of these major changes, large portions of the code outside of this were simplified.
2013-11-17 02:37:33 -05:00
* Represents the {@link ListFragment} responsible
* for displaying the list of previously played games.
*/
[Android] Initial huge underlying UI update: - The UI is now mostly Fragment-centric (finally!) - The Load Core, Load Game, Load Game (History) are now DialogFragments. - The directory activities are killed off and consolidated into one fragment named DirectoryFragment. DirectoryFragment is now a self-contained instantiable DirectoryFragment that can be instantiated anywhere by doing roughly the following. DirectorFragment dFrag = DirectoryFragment.newInstance(/* Resource ID for a string title here*/); dFrag.show(getFragmentManager(), "tag"); There are also other methods that were modified within the DirectoryFragment, such as addAllowedExt and disAllowedExt being changed to support a variable amount of arguments. This way, multiple calls of the same function aren't necessary in the case of adding multiple extensions, as well as supporting the case where only one extension is added. DirectoryFragment also has a new interface added to it called OnDirectoryFragmentClosedListener. Say you have a DirectoryFragment instance, but want to use the selected item's path for something *after* the dialog has closed, with this interface, it is now possible. Just implement this interface within an Activity or Fragment, and then set the DirectoryFragment to use the listener through setOnDirectoryFragmentClosedListener() method. Now what happens if this isn't set, wouldn't it be pointless to even use a DirectoryFragment in this case? Not necessarily. What if you only wanted to save the selected item into the applications SharedPreferences? This is a situation where it would be unnecessary to need that interface. So, to make a DirectoryFragment.java for the sole purpose of saving a selected directory/file path to the SharedPreferences, you would do this: DirectoryFragment dFrag = DirectoryFragment.newInstance(/* Resource ID to a string title here*/); dFrag.setPathSettingKey("key to store value in SharedPreferences at"); dFrag.show(getFragmentManager(), "tag"); Outside of these major changes, large portions of the code outside of this were simplified.
2013-11-17 02:37:33 -05:00
public final class HistorySelection extends DialogFragment
{
private FragmentActivity ctx;
private IconAdapter<HistoryWrapper> adapter;
@Override
[Android] Initial huge underlying UI update: - The UI is now mostly Fragment-centric (finally!) - The Load Core, Load Game, Load Game (History) are now DialogFragments. - The directory activities are killed off and consolidated into one fragment named DirectoryFragment. DirectoryFragment is now a self-contained instantiable DirectoryFragment that can be instantiated anywhere by doing roughly the following. DirectorFragment dFrag = DirectoryFragment.newInstance(/* Resource ID for a string title here*/); dFrag.show(getFragmentManager(), "tag"); There are also other methods that were modified within the DirectoryFragment, such as addAllowedExt and disAllowedExt being changed to support a variable amount of arguments. This way, multiple calls of the same function aren't necessary in the case of adding multiple extensions, as well as supporting the case where only one extension is added. DirectoryFragment also has a new interface added to it called OnDirectoryFragmentClosedListener. Say you have a DirectoryFragment instance, but want to use the selected item's path for something *after* the dialog has closed, with this interface, it is now possible. Just implement this interface within an Activity or Fragment, and then set the DirectoryFragment to use the listener through setOnDirectoryFragmentClosedListener() method. Now what happens if this isn't set, wouldn't it be pointless to even use a DirectoryFragment in this case? Not necessarily. What if you only wanted to save the selected item into the applications SharedPreferences? This is a situation where it would be unnecessary to need that interface. So, to make a DirectoryFragment.java for the sole purpose of saving a selected directory/file path to the SharedPreferences, you would do this: DirectoryFragment dFrag = DirectoryFragment.newInstance(/* Resource ID to a string title here*/); dFrag.setPathSettingKey("key to store value in SharedPreferences at"); dFrag.show(getFragmentManager(), "tag"); Outside of these major changes, large portions of the code outside of this were simplified.
2013-11-17 02:37:33 -05:00
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
[Android] Initial huge underlying UI update: - The UI is now mostly Fragment-centric (finally!) - The Load Core, Load Game, Load Game (History) are now DialogFragments. - The directory activities are killed off and consolidated into one fragment named DirectoryFragment. DirectoryFragment is now a self-contained instantiable DirectoryFragment that can be instantiated anywhere by doing roughly the following. DirectorFragment dFrag = DirectoryFragment.newInstance(/* Resource ID for a string title here*/); dFrag.show(getFragmentManager(), "tag"); There are also other methods that were modified within the DirectoryFragment, such as addAllowedExt and disAllowedExt being changed to support a variable amount of arguments. This way, multiple calls of the same function aren't necessary in the case of adding multiple extensions, as well as supporting the case where only one extension is added. DirectoryFragment also has a new interface added to it called OnDirectoryFragmentClosedListener. Say you have a DirectoryFragment instance, but want to use the selected item's path for something *after* the dialog has closed, with this interface, it is now possible. Just implement this interface within an Activity or Fragment, and then set the DirectoryFragment to use the listener through setOnDirectoryFragmentClosedListener() method. Now what happens if this isn't set, wouldn't it be pointless to even use a DirectoryFragment in this case? Not necessarily. What if you only wanted to save the selected item into the applications SharedPreferences? This is a situation where it would be unnecessary to need that interface. So, to make a DirectoryFragment.java for the sole purpose of saving a selected directory/file path to the SharedPreferences, you would do this: DirectoryFragment dFrag = DirectoryFragment.newInstance(/* Resource ID to a string title here*/); dFrag.setPathSettingKey("key to store value in SharedPreferences at"); dFrag.show(getFragmentManager(), "tag"); Outside of these major changes, large portions of the code outside of this were simplified.
2013-11-17 02:37:33 -05:00
// Cache the context
this.ctx = getActivity();
}
[Android] Initial huge underlying UI update: - The UI is now mostly Fragment-centric (finally!) - The Load Core, Load Game, Load Game (History) are now DialogFragments. - The directory activities are killed off and consolidated into one fragment named DirectoryFragment. DirectoryFragment is now a self-contained instantiable DirectoryFragment that can be instantiated anywhere by doing roughly the following. DirectorFragment dFrag = DirectoryFragment.newInstance(/* Resource ID for a string title here*/); dFrag.show(getFragmentManager(), "tag"); There are also other methods that were modified within the DirectoryFragment, such as addAllowedExt and disAllowedExt being changed to support a variable amount of arguments. This way, multiple calls of the same function aren't necessary in the case of adding multiple extensions, as well as supporting the case where only one extension is added. DirectoryFragment also has a new interface added to it called OnDirectoryFragmentClosedListener. Say you have a DirectoryFragment instance, but want to use the selected item's path for something *after* the dialog has closed, with this interface, it is now possible. Just implement this interface within an Activity or Fragment, and then set the DirectoryFragment to use the listener through setOnDirectoryFragmentClosedListener() method. Now what happens if this isn't set, wouldn't it be pointless to even use a DirectoryFragment in this case? Not necessarily. What if you only wanted to save the selected item into the applications SharedPreferences? This is a situation where it would be unnecessary to need that interface. So, to make a DirectoryFragment.java for the sole purpose of saving a selected directory/file path to the SharedPreferences, you would do this: DirectoryFragment dFrag = DirectoryFragment.newInstance(/* Resource ID to a string title here*/); dFrag.setPathSettingKey("key to store value in SharedPreferences at"); dFrag.show(getFragmentManager(), "tag"); Outside of these major changes, large portions of the code outside of this were simplified.
2013-11-17 02:37:33 -05:00
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
ListView rootView = (ListView) inflater.inflate(R.layout.line_list, container, false);
rootView.setOnItemClickListener(onItemClickListener);
[Android] Initial huge underlying UI update: - The UI is now mostly Fragment-centric (finally!) - The Load Core, Load Game, Load Game (History) are now DialogFragments. - The directory activities are killed off and consolidated into one fragment named DirectoryFragment. DirectoryFragment is now a self-contained instantiable DirectoryFragment that can be instantiated anywhere by doing roughly the following. DirectorFragment dFrag = DirectoryFragment.newInstance(/* Resource ID for a string title here*/); dFrag.show(getFragmentManager(), "tag"); There are also other methods that were modified within the DirectoryFragment, such as addAllowedExt and disAllowedExt being changed to support a variable amount of arguments. This way, multiple calls of the same function aren't necessary in the case of adding multiple extensions, as well as supporting the case where only one extension is added. DirectoryFragment also has a new interface added to it called OnDirectoryFragmentClosedListener. Say you have a DirectoryFragment instance, but want to use the selected item's path for something *after* the dialog has closed, with this interface, it is now possible. Just implement this interface within an Activity or Fragment, and then set the DirectoryFragment to use the listener through setOnDirectoryFragmentClosedListener() method. Now what happens if this isn't set, wouldn't it be pointless to even use a DirectoryFragment in this case? Not necessarily. What if you only wanted to save the selected item into the applications SharedPreferences? This is a situation where it would be unnecessary to need that interface. So, to make a DirectoryFragment.java for the sole purpose of saving a selected directory/file path to the SharedPreferences, you would do this: DirectoryFragment dFrag = DirectoryFragment.newInstance(/* Resource ID to a string title here*/); dFrag.setPathSettingKey("key to store value in SharedPreferences at"); dFrag.show(getFragmentManager(), "tag"); Outside of these major changes, large portions of the code outside of this were simplified.
2013-11-17 02:37:33 -05:00
// Set the title for this dialog.
getDialog().setTitle(R.string.load_game_history);
[Android] Initial huge underlying UI update: - The UI is now mostly Fragment-centric (finally!) - The Load Core, Load Game, Load Game (History) are now DialogFragments. - The directory activities are killed off and consolidated into one fragment named DirectoryFragment. DirectoryFragment is now a self-contained instantiable DirectoryFragment that can be instantiated anywhere by doing roughly the following. DirectorFragment dFrag = DirectoryFragment.newInstance(/* Resource ID for a string title here*/); dFrag.show(getFragmentManager(), "tag"); There are also other methods that were modified within the DirectoryFragment, such as addAllowedExt and disAllowedExt being changed to support a variable amount of arguments. This way, multiple calls of the same function aren't necessary in the case of adding multiple extensions, as well as supporting the case where only one extension is added. DirectoryFragment also has a new interface added to it called OnDirectoryFragmentClosedListener. Say you have a DirectoryFragment instance, but want to use the selected item's path for something *after* the dialog has closed, with this interface, it is now possible. Just implement this interface within an Activity or Fragment, and then set the DirectoryFragment to use the listener through setOnDirectoryFragmentClosedListener() method. Now what happens if this isn't set, wouldn't it be pointless to even use a DirectoryFragment in this case? Not necessarily. What if you only wanted to save the selected item into the applications SharedPreferences? This is a situation where it would be unnecessary to need that interface. So, to make a DirectoryFragment.java for the sole purpose of saving a selected directory/file path to the SharedPreferences, you would do this: DirectoryFragment dFrag = DirectoryFragment.newInstance(/* Resource ID to a string title here*/); dFrag.setPathSettingKey("key to store value in SharedPreferences at"); dFrag.show(getFragmentManager(), "tag"); Outside of these major changes, large portions of the code outside of this were simplified.
2013-11-17 02:37:33 -05:00
// Setup the list adapter
adapter = new IconAdapter<HistoryWrapper>(ctx, R.layout.line_list_item);
[Android] Initial huge underlying UI update: - The UI is now mostly Fragment-centric (finally!) - The Load Core, Load Game, Load Game (History) are now DialogFragments. - The directory activities are killed off and consolidated into one fragment named DirectoryFragment. DirectoryFragment is now a self-contained instantiable DirectoryFragment that can be instantiated anywhere by doing roughly the following. DirectorFragment dFrag = DirectoryFragment.newInstance(/* Resource ID for a string title here*/); dFrag.show(getFragmentManager(), "tag"); There are also other methods that were modified within the DirectoryFragment, such as addAllowedExt and disAllowedExt being changed to support a variable amount of arguments. This way, multiple calls of the same function aren't necessary in the case of adding multiple extensions, as well as supporting the case where only one extension is added. DirectoryFragment also has a new interface added to it called OnDirectoryFragmentClosedListener. Say you have a DirectoryFragment instance, but want to use the selected item's path for something *after* the dialog has closed, with this interface, it is now possible. Just implement this interface within an Activity or Fragment, and then set the DirectoryFragment to use the listener through setOnDirectoryFragmentClosedListener() method. Now what happens if this isn't set, wouldn't it be pointless to even use a DirectoryFragment in this case? Not necessarily. What if you only wanted to save the selected item into the applications SharedPreferences? This is a situation where it would be unnecessary to need that interface. So, to make a DirectoryFragment.java for the sole purpose of saving a selected directory/file path to the SharedPreferences, you would do this: DirectoryFragment dFrag = DirectoryFragment.newInstance(/* Resource ID to a string title here*/); dFrag.setPathSettingKey("key to store value in SharedPreferences at"); dFrag.show(getFragmentManager(), "tag"); Outside of these major changes, large portions of the code outside of this were simplified.
2013-11-17 02:37:33 -05:00
// Populate the adapter
File history = new File(ctx.getApplicationInfo().dataDir, "retroarch-history.txt");
try
{
BufferedReader br = new BufferedReader(new InputStreamReader(
new FileInputStream(history)));
[Android] Initial huge underlying UI update: - The UI is now mostly Fragment-centric (finally!) - The Load Core, Load Game, Load Game (History) are now DialogFragments. - The directory activities are killed off and consolidated into one fragment named DirectoryFragment. DirectoryFragment is now a self-contained instantiable DirectoryFragment that can be instantiated anywhere by doing roughly the following. DirectorFragment dFrag = DirectoryFragment.newInstance(/* Resource ID for a string title here*/); dFrag.show(getFragmentManager(), "tag"); There are also other methods that were modified within the DirectoryFragment, such as addAllowedExt and disAllowedExt being changed to support a variable amount of arguments. This way, multiple calls of the same function aren't necessary in the case of adding multiple extensions, as well as supporting the case where only one extension is added. DirectoryFragment also has a new interface added to it called OnDirectoryFragmentClosedListener. Say you have a DirectoryFragment instance, but want to use the selected item's path for something *after* the dialog has closed, with this interface, it is now possible. Just implement this interface within an Activity or Fragment, and then set the DirectoryFragment to use the listener through setOnDirectoryFragmentClosedListener() method. Now what happens if this isn't set, wouldn't it be pointless to even use a DirectoryFragment in this case? Not necessarily. What if you only wanted to save the selected item into the applications SharedPreferences? This is a situation where it would be unnecessary to need that interface. So, to make a DirectoryFragment.java for the sole purpose of saving a selected directory/file path to the SharedPreferences, you would do this: DirectoryFragment dFrag = DirectoryFragment.newInstance(/* Resource ID to a string title here*/); dFrag.setPathSettingKey("key to store value in SharedPreferences at"); dFrag.show(getFragmentManager(), "tag"); Outside of these major changes, large portions of the code outside of this were simplified.
2013-11-17 02:37:33 -05:00
for (;;)
{
String game = br.readLine();
String core = br.readLine();
String name = br.readLine();
if (game == null || core == null || name == null)
break;
adapter.add(new HistoryWrapper(game, core, name));
}
br.close();
}
[Android] Initial huge underlying UI update: - The UI is now mostly Fragment-centric (finally!) - The Load Core, Load Game, Load Game (History) are now DialogFragments. - The directory activities are killed off and consolidated into one fragment named DirectoryFragment. DirectoryFragment is now a self-contained instantiable DirectoryFragment that can be instantiated anywhere by doing roughly the following. DirectorFragment dFrag = DirectoryFragment.newInstance(/* Resource ID for a string title here*/); dFrag.show(getFragmentManager(), "tag"); There are also other methods that were modified within the DirectoryFragment, such as addAllowedExt and disAllowedExt being changed to support a variable amount of arguments. This way, multiple calls of the same function aren't necessary in the case of adding multiple extensions, as well as supporting the case where only one extension is added. DirectoryFragment also has a new interface added to it called OnDirectoryFragmentClosedListener. Say you have a DirectoryFragment instance, but want to use the selected item's path for something *after* the dialog has closed, with this interface, it is now possible. Just implement this interface within an Activity or Fragment, and then set the DirectoryFragment to use the listener through setOnDirectoryFragmentClosedListener() method. Now what happens if this isn't set, wouldn't it be pointless to even use a DirectoryFragment in this case? Not necessarily. What if you only wanted to save the selected item into the applications SharedPreferences? This is a situation where it would be unnecessary to need that interface. So, to make a DirectoryFragment.java for the sole purpose of saving a selected directory/file path to the SharedPreferences, you would do this: DirectoryFragment dFrag = DirectoryFragment.newInstance(/* Resource ID to a string title here*/); dFrag.setPathSettingKey("key to store value in SharedPreferences at"); dFrag.show(getFragmentManager(), "tag"); Outside of these major changes, large portions of the code outside of this were simplified.
2013-11-17 02:37:33 -05:00
catch (IOException ignored)
{
}
[Android] Initial huge underlying UI update: - The UI is now mostly Fragment-centric (finally!) - The Load Core, Load Game, Load Game (History) are now DialogFragments. - The directory activities are killed off and consolidated into one fragment named DirectoryFragment. DirectoryFragment is now a self-contained instantiable DirectoryFragment that can be instantiated anywhere by doing roughly the following. DirectorFragment dFrag = DirectoryFragment.newInstance(/* Resource ID for a string title here*/); dFrag.show(getFragmentManager(), "tag"); There are also other methods that were modified within the DirectoryFragment, such as addAllowedExt and disAllowedExt being changed to support a variable amount of arguments. This way, multiple calls of the same function aren't necessary in the case of adding multiple extensions, as well as supporting the case where only one extension is added. DirectoryFragment also has a new interface added to it called OnDirectoryFragmentClosedListener. Say you have a DirectoryFragment instance, but want to use the selected item's path for something *after* the dialog has closed, with this interface, it is now possible. Just implement this interface within an Activity or Fragment, and then set the DirectoryFragment to use the listener through setOnDirectoryFragmentClosedListener() method. Now what happens if this isn't set, wouldn't it be pointless to even use a DirectoryFragment in this case? Not necessarily. What if you only wanted to save the selected item into the applications SharedPreferences? This is a situation where it would be unnecessary to need that interface. So, to make a DirectoryFragment.java for the sole purpose of saving a selected directory/file path to the SharedPreferences, you would do this: DirectoryFragment dFrag = DirectoryFragment.newInstance(/* Resource ID to a string title here*/); dFrag.setPathSettingKey("key to store value in SharedPreferences at"); dFrag.show(getFragmentManager(), "tag"); Outside of these major changes, large portions of the code outside of this were simplified.
2013-11-17 02:37:33 -05:00
// Set the adapter
rootView.setAdapter(adapter);
return rootView;
}
[Android] Initial huge underlying UI update: - The UI is now mostly Fragment-centric (finally!) - The Load Core, Load Game, Load Game (History) are now DialogFragments. - The directory activities are killed off and consolidated into one fragment named DirectoryFragment. DirectoryFragment is now a self-contained instantiable DirectoryFragment that can be instantiated anywhere by doing roughly the following. DirectorFragment dFrag = DirectoryFragment.newInstance(/* Resource ID for a string title here*/); dFrag.show(getFragmentManager(), "tag"); There are also other methods that were modified within the DirectoryFragment, such as addAllowedExt and disAllowedExt being changed to support a variable amount of arguments. This way, multiple calls of the same function aren't necessary in the case of adding multiple extensions, as well as supporting the case where only one extension is added. DirectoryFragment also has a new interface added to it called OnDirectoryFragmentClosedListener. Say you have a DirectoryFragment instance, but want to use the selected item's path for something *after* the dialog has closed, with this interface, it is now possible. Just implement this interface within an Activity or Fragment, and then set the DirectoryFragment to use the listener through setOnDirectoryFragmentClosedListener() method. Now what happens if this isn't set, wouldn't it be pointless to even use a DirectoryFragment in this case? Not necessarily. What if you only wanted to save the selected item into the applications SharedPreferences? This is a situation where it would be unnecessary to need that interface. So, to make a DirectoryFragment.java for the sole purpose of saving a selected directory/file path to the SharedPreferences, you would do this: DirectoryFragment dFrag = DirectoryFragment.newInstance(/* Resource ID to a string title here*/); dFrag.setPathSettingKey("key to store value in SharedPreferences at"); dFrag.show(getFragmentManager(), "tag"); Outside of these major changes, large portions of the code outside of this were simplified.
2013-11-17 02:37:33 -05:00
private final OnItemClickListener onItemClickListener = new OnItemClickListener()
{
@Override
public void onItemClick(AdapterView<?> listView, View view, int position, long id)
{
final HistoryWrapper item = adapter.getItem(position);
final String gamePath = item.getGamePath();
final String corePath = item.getCorePath();
// Set the core the selected game uses.
((MainMenuActivity)getActivity()).setModule(corePath, item.getCoreName());
// Update the config accordingly.
UserPreferences.updateConfigFile(ctx);
// Launch the game.
String current_ime = Settings.Secure.getString(ctx.getContentResolver(),
Settings.Secure.DEFAULT_INPUT_METHOD);
Toast.makeText(ctx, String.format(getString(R.string.loading_gamepath), gamePath), Toast.LENGTH_SHORT).show();
Intent myIntent = new Intent(ctx, RetroActivity.class);
myIntent.putExtra("ROM", gamePath);
myIntent.putExtra("LIBRETRO", corePath);
myIntent.putExtra("CONFIGFILE", UserPreferences.getDefaultConfigPath(ctx));
myIntent.putExtra("IME", current_ime);
startActivity(myIntent);
dismiss();
}
};
}