Android: Handle case where core list could not be retrieved better

This commit is contained in:
Lioncash 2014-12-18 13:40:09 -05:00
parent 8b14bbc6e2
commit 9e3587c96f
2 changed files with 8 additions and 4 deletions

View File

@ -44,6 +44,7 @@
<string name="download_core_confirm_title">Confirm</string>
<string name="download_core_confirm_msg">Are you sure you want to download %1$s?</string>
<string name="downloading_msg">Downloading %1$s…</string>
<string name="download_core_list_error">Error retrieving list of cores.</string>
<!-- Core Downloader - Downloadable Cores Context Menu -->
<string name="downloadable_cores_ctx_title">Actions</string>

View File

@ -41,6 +41,7 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.ListView;
import android.widget.Toast;
import com.retroarch.R;
@ -193,9 +194,7 @@ public final class DownloadableCoresFragment extends ListFragment
Log.e("PopulateCoresListOperation", e.getMessage());
// Make a dummy entry to notify an error.
final ArrayList<DownloadableCore> errorList = new ArrayList<DownloadableCore>();
errorList.add(new DownloadableCore("Error", e.getMessage()));
return errorList;
return new ArrayList<DownloadableCore>();
}
}
@ -203,7 +202,11 @@ public final class DownloadableCoresFragment extends ListFragment
protected void onPostExecute(ArrayList<DownloadableCore> result)
{
super.onPostExecute(result);
adapter.addAll(result);
if (result.isEmpty())
Toast.makeText(adapter.getContext(), R.string.download_core_list_error, Toast.LENGTH_SHORT).show();
else
adapter.addAll(result);
}
// Literally downloads the info file, writes it, and parses it for the corename key/value pair.