use of com.nolanlawson.keepscore.data.GamesBackupSummaryAdapter in project KeepScore by nolanlawson.
the class MainActivity method showLoadBackupDialogFinished.
private void showLoadBackupDialogFinished(List<GamesBackupSummary> summaries) {
DisplayMetrics displayMetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
final GamesBackupSummaryAdapter adapter = new GamesBackupSummaryAdapter(MainActivity.this, displayMetrics, summaries);
new AlertDialog.Builder(MainActivity.this).setCancelable(true).setTitle(R.string.title_choose_backup).setNegativeButton(android.R.string.cancel, null).setAdapter(adapter, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
GamesBackupSummary summary = adapter.getItem(which);
Uri uri = Uri.fromFile(SdcardHelper.getFile(summary.getFilename(), Location.Backups));
Format format = summary.getFilename().endsWith(".gz") ? Format.GZIP : Format.XML;
loadBackup(summary, uri, format);
}
}).show();
}
use of com.nolanlawson.keepscore.data.GamesBackupSummaryAdapter in project KeepScore by nolanlawson.
the class MainActivity method loadBackupFileFromShare.
/**
* if the user opened up a games-20xxxxxxxxx.xml.gz file from a file browser, open it here.
* @param intent
*/
private void loadBackupFileFromShare(final Intent intent) {
if (intent == null || intent.getData() == null) {
// no intent data, so abort
return;
}
// this functionality is not supported in Eclair
if (VersionHelper.getVersionSdkIntCompat() < VersionHelper.VERSION_FROYO) {
return;
}
if (uriIntentsConfirmedByUser.contains(intent.getDataString())) {
// user already dismissed or confirmed the dialog; no need to show it again
return;
}
log.i("Received intent: %s", intent);
log.i("Received data: %s", intent.getData());
GamesBackupSummary summary;
try {
summary = GamesBackupSerializer.readGamesBackupSummary(intent.getData(), Format.XML, getContentResolver());
} catch (Exception e) {
log.e(e, "Unexpected error loading %s", intent.getData());
ToastHelper.showLong(this, R.string.toast_error_with_backup);
return;
}
final GamesBackupSummary finalSummary = summary;
DisplayMetrics displayMetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
GamesBackupSummaryAdapter adapter = new GamesBackupSummaryAdapter(this, displayMetrics, new ArrayList<GamesBackupSummary>(Collections.singleton(finalSummary)));
DialogInterface.OnClickListener onOk = new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
uriIntentsConfirmedByUser.add(intent.getDataString());
loadBackup(finalSummary, intent.getData(), Format.XML);
}
};
DialogInterface.OnClickListener onCancel = new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
uriIntentsConfirmedByUser.add(intent.getDataString());
}
};
new AlertDialog.Builder(this).setCancelable(true).setTitle(R.string.title_choose_backup).setNegativeButton(android.R.string.cancel, onCancel).setPositiveButton(android.R.string.ok, onOk).setAdapter(adapter, onOk).show();
}
Aggregations