Implement functional locator and path navigation
This commit is contained in:
parent
88beeb147d
commit
22adcee052
|
@ -60,8 +60,8 @@ public class FileBrowser extends Fragment {
|
|||
|
||||
private SharedPreferences mPrefs;
|
||||
private File sdcard = Environment.getExternalStorageDirectory();
|
||||
private String home_directory = sdcard + "/dc";
|
||||
private String game_directory = sdcard + "/dc";
|
||||
private String home_directory = sdcard.getAbsolutePath();
|
||||
private String game_directory = sdcard.getAbsolutePath();
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -193,12 +193,11 @@ public class FileBrowser extends Fragment {
|
|||
Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
if (!ImgBrowse) {
|
||||
// navigate(sdcard);
|
||||
if (!ImgBrowse && !games) {
|
||||
LocateGames mLocateGames = new LocateGames(R.array.flash);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
|
||||
mLocateGames
|
||||
.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, home_directory);
|
||||
.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, home_directory);
|
||||
} else {
|
||||
mLocateGames.execute(home_directory);
|
||||
}
|
||||
|
@ -254,31 +253,38 @@ public class FileBrowser extends Fragment {
|
|||
|
||||
@Override
|
||||
protected void onPostExecute(List<File> items) {
|
||||
final LinearLayout list = (LinearLayout) parentActivity.findViewById(R.id.game_list);
|
||||
if (list != null) {
|
||||
list.removeAllViews();
|
||||
}
|
||||
|
||||
String heading = parentActivity.getString(R.string.games_listing);
|
||||
createListHeader(heading, list, array == R.array.images);
|
||||
if (items != null && !items.isEmpty()) {
|
||||
final LinearLayout list = (LinearLayout) parentActivity.findViewById(R.id.game_list);
|
||||
if (list != null) {
|
||||
list.removeAllViews();
|
||||
}
|
||||
|
||||
String heading = parentActivity.getString(R.string.games_listing);
|
||||
createListHeader(heading, list, array == R.array.images);
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
createListItem(list, items.get(i), i, array == R.array.images);
|
||||
}
|
||||
list.invalidate();
|
||||
} else {
|
||||
HashSet<String> extStorage = FileBrowser.getExternalMounts();
|
||||
if (extStorage != null && !extStorage.isEmpty()) {
|
||||
for (Iterator<String> sd = extStorage.iterator(); sd.hasNext();) {
|
||||
String sdCardPath = sd.next();
|
||||
if (!sdCardPath.equals(sdcard)) {
|
||||
sdcard = new File(sdCardPath);
|
||||
}
|
||||
browseStorage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void browseStorage() {
|
||||
HashSet<String> extStorage = FileBrowser.getExternalMounts();
|
||||
if (extStorage != null && !extStorage.isEmpty()) {
|
||||
for (Iterator<String> sd = extStorage.iterator(); sd.hasNext();) {
|
||||
String sdCardPath = sd.next().replace("mnt/media_rw", "storage");
|
||||
if (!sdCardPath.equals(sdcard.getAbsolutePath())) {
|
||||
if (new File(sdCardPath).canRead()) {
|
||||
navigate(new File(sdCardPath));
|
||||
return;
|
||||
}
|
||||
}
|
||||
navigate(sdcard);
|
||||
}
|
||||
list.invalidate();
|
||||
}
|
||||
navigate(sdcard);
|
||||
}
|
||||
|
||||
private static final class DirSort implements Comparator<File> {
|
||||
|
@ -352,12 +358,8 @@ public class FileBrowser extends Fragment {
|
|||
|
||||
final XMLParser xmlParser = new XMLParser(game, index, mPrefs);
|
||||
xmlParser.setViewParent(parentActivity, childview);
|
||||
xmlParser.execute(game.getName());
|
||||
|
||||
orig_bg = childview.getBackground();
|
||||
|
||||
// vw.findViewById(R.id.childview).setBackgroundColor(0xFFFFFFFF);
|
||||
|
||||
childview.findViewById(R.id.childview).setOnClickListener(
|
||||
new OnClickListener() {
|
||||
public void onClick(View view) {
|
||||
|
@ -421,6 +423,7 @@ public class FileBrowser extends Fragment {
|
|||
}
|
||||
});
|
||||
list.addView(childview);
|
||||
xmlParser.execute(game.getName());
|
||||
}
|
||||
|
||||
void navigate(final File root_sd) {
|
||||
|
|
|
@ -46,7 +46,7 @@ public class MainActivity extends SlidingFragmentActivity implements
|
|||
|
||||
private SharedPreferences mPrefs;
|
||||
private static File sdcard = Environment.getExternalStorageDirectory();
|
||||
public static String home_directory = sdcard + "/dc";
|
||||
public static String home_directory = sdcard.getAbsolutePath();
|
||||
|
||||
private TextView menuHeading;
|
||||
private boolean hasAndroidMarket = false;
|
||||
|
|
|
@ -50,8 +50,8 @@ public class OptionsFragment extends Fragment {
|
|||
|
||||
private SharedPreferences mPrefs;
|
||||
private File sdcard = Environment.getExternalStorageDirectory();
|
||||
private String home_directory = sdcard + "/dc";
|
||||
private String game_directory = sdcard + "/dc";
|
||||
private String home_directory = sdcard.getAbsolutePath();
|
||||
private String game_directory = sdcard.getAbsolutePath();
|
||||
|
||||
private String[] codes;
|
||||
|
||||
|
@ -91,10 +91,9 @@ public class OptionsFragment extends Fragment {
|
|||
HashSet<String> extStorage = FileBrowser.getExternalMounts();
|
||||
if (extStorage != null && !extStorage.isEmpty()) {
|
||||
for (Iterator<String> sd = extStorage.iterator(); sd.hasNext();) {
|
||||
String sdCardPath = sd.next();
|
||||
if (!sdCardPath.equals(sdcard)) {
|
||||
// home_directory = sdCardPath + "/dc";
|
||||
game_directory = sdCardPath + "/dc";
|
||||
String sdCardPath = sd.next().replace("mnt/media_rw", "storage");
|
||||
if (!sdCardPath.equals(sdcard.getAbsolutePath())) {
|
||||
game_directory = sdCardPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue