@Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { if (!data.moveToFirst()) { return; } final String surveyName = data.getString(ResponseQuery.SURVEY_TITLE); final Long completedDate = data.getLong(ResponseQuery.TIME); mHeadertext.setText(surveyName); mSubtext.setText(data.getString(ResponseQuery.CAMPAIGN_NAME)); SimpleDateFormat df = new SimpleDateFormat(); mNotetext.setText(df.format(new Date(completedDate))); final String iconUrl = data.getString(ResponseQuery.CAMPAIGN_ICON); if (iconUrl == null || mImageLoader.bind(mIconView, iconUrl, null) != ImageLoader.BindResult.OK) { mIconView.setImageResource(R.drawable.apple_logo); } mEntityHeader.setVisibility(View.VISIBLE); // Make the map view button status aware so it can provide some useful info about the gps state if (data.getInt(ResponseQuery.STATUS) == Response.STATUS_WAITING_FOR_LOCATION) { mapViewButton.setText("Waiting for Location"); mapViewButton.setEnabled(false); } else if (!(SurveyGeotagService.LOCATION_VALID.equals( data.getString(ResponseQuery.LOCATION_STATUS)))) { mapViewButton.setText("Location Not Available"); mapViewButton.setEnabled(false); } else { mapViewButton.setText("View Map"); mapViewButton.setEnabled(true); } }
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { if (!data.moveToFirst()) { Toast.makeText(this, R.string.response_info_response_deleted, Toast.LENGTH_SHORT).show(); finish(); return; } final String surveyName = data.getString(ResponseQuery.SURVEY_TITLE); final Long completedDate = data.getLong(ResponseQuery.TIME); mStatus = data.getInt(ResponseQuery.STATUS); if (mStatus == Response.STATUS_STANDBY) uploadButton.setContentDescription( getString(R.string.response_info_entity_action_button_upload_description)); else if (mStatus == Response.STATUS_WAITING_FOR_LOCATION) uploadButton.setContentDescription( getString(R.string.response_info_entity_action_button_upload_force_description)); else uploadButton.setContentDescription( getString(R.string.response_info_entity_action_button_upload_error_description)); mHeadertext.setText(surveyName); mSubtext.setText(data.getString(ResponseQuery.CAMPAIGN_NAME)); // If we aren't in single campaign mode, show the campaign name mSubtext.setVisibility((ConfigHelper.isSingleCampaignMode()) ? View.GONE : View.VISIBLE); SimpleDateFormat df = new SimpleDateFormat(); mNotetext.setText(df.format(new Date(completedDate))); final String iconUrl = data.getString(ResponseQuery.CAMPAIGN_ICON); if (iconUrl == null || mImageLoader.bind(mIconView, iconUrl, null) != ImageLoader.BindResult.OK) { mIconView.setImageResource(R.drawable.apple_logo); } mEntityHeader.setVisibility(View.VISIBLE); // Make the map view button status aware so it can provide some useful info about the gps state if (mStatus == Response.STATUS_WAITING_FOR_LOCATION) { mapViewButton.setText(R.string.response_info_gps_wait); mapViewButton.setEnabled(false); } else if (!(SurveyGeotagService.LOCATION_VALID.equals( data.getString(ResponseQuery.LOCATION_STATUS)))) { mapViewButton.setText(R.string.response_info_no_location); mapViewButton.setEnabled(false); } else { mapViewButton.setText(R.string.response_info_view_map); mapViewButton.setEnabled(true); } // Make upload button visible if applicable uploadButton.setVisibility(View.VISIBLE); switch (mStatus) { case Response.STATUS_DOWNLOADED: case Response.STATUS_UPLOADED: uploadButton.setVisibility(View.GONE); break; case Response.STATUS_STANDBY: case Response.STATUS_WAITING_FOR_LOCATION: uploadButton.setText(R.string.response_info_upload); uploadButton.setEnabled(true); break; case Response.STATUS_QUEUED: case Response.STATUS_UPLOADING: uploadButton.setText(R.string.response_info_uploading); uploadButton.setEnabled(false); break; default: // Error uploadButton.setText(R.string.response_info_upload_error); uploadButton.setEnabled(true); } }