@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { boolean newWork = false; String link = getArguments().getString(Constants.ArgsName.LINK); Work incomingWork = (Work) getArguments().getSerializable(Constants.ArgsName.WORK); if (incomingWork != null && !incomingWork.equals(work)) { work = incomingWork; newWork = true; } else if (link != null) { if (work == null || !work.getLink().equals(link)) { work = new Work(link); newWork = true; } } pagesSize = 999; if (newWork) { clearData(); try { setDataSource(new IllustrationsParser(work)); } catch (MalformedURLException e) { Log.e(TAG, "Unknown exception", e); ErrorFragment.show(IllustrationPagerFragment.this, R.string.error); } } else { postEvent(new IllustrationsParsedEvent(adapter.getItems())); } return super.onCreateView(inflater, container, savedInstanceState); }
/** * Show a dialog returned by Google Play services for the connection error code * * @param errorCode An error code returned from onConnectionFailed */ private void showErrorDialog(int errorCode) { // Get the error dialog from Google Play services Dialog errorDialog = GooglePlayServicesUtil.getErrorDialog( errorCode, this, LocationUtils.CONNETION_FAILURE_RESOLUTION_REQUEST); // If Google Play services can provide an error dialog if (errorDialog != null) { // Create a new DialogFragment in which to show the error dialog ErrorFragment errorFragment = new ErrorFragment(); // Set the dialog in the DialogFragment errorFragment.setDialog(errorDialog); // Show the error dialog in the DialogFragment errorFragment.show(getFragmentManager(), LocationUtils.APPTAG); } }
@SuppressWarnings("NewApi") private boolean serviceConnected() { // check google play service is available int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this); // available if (ConnectionResult.SUCCESS == resultCode) { Log.d(LocationUtils.APPTAG, getString(R.string.play_services_available)); return true; } else { Dialog dialog = GooglePlayServicesUtil.getErrorDialog(resultCode, this, 0); if (dialog != null) { ErrorFragment errorFragment = new ErrorFragment(); errorFragment.setDialog(dialog); errorFragment.show(getFragmentManager(), LocationUtils.APPTAG); } return false; } }