List of usage examples for android.database Cursor getDouble
double getDouble(int columnIndex);
From source file:nl.sogeti.android.gpstracker.viewer.LoggerMap.java
/** * Retrieve the last point of the current track *///from w w w . j a v a 2s .com private GeoPoint getLastTrackPoint() { Cursor waypoint = null; GeoPoint lastPoint = null; // First try the service which might have a cached version Location lastLoc = mLoggerServiceManager.getLastWaypoint(); if (lastLoc != null) { int microLatitude = (int) (lastLoc.getLatitude() * 1E6d); int microLongitude = (int) (lastLoc.getLongitude() * 1E6d); lastPoint = new GeoPoint(microLatitude, microLongitude); } // If nothing yet, try the content resolver and query the track if (lastPoint == null || lastPoint.getLatitudeE6() == 0 || lastPoint.getLongitudeE6() == 0) { try { ContentResolver resolver = this.getContentResolver(); waypoint = resolver.query(Uri.withAppendedPath(Tracks.CONTENT_URI, mTrackId + "/waypoints"), new String[] { Waypoints.LATITUDE, Waypoints.LONGITUDE, "max(" + Waypoints.TABLE + "." + Waypoints._ID + ")" }, null, null, null); if (waypoint != null && waypoint.moveToLast()) { int microLatitude = (int) (waypoint.getDouble(0) * 1E6d); int microLongitude = (int) (waypoint.getDouble(1) * 1E6d); lastPoint = new GeoPoint(microLatitude, microLongitude); } } finally { if (waypoint != null) { waypoint.close(); } } } // If nothing yet, try the last generally known location if (lastPoint == null || lastPoint.getLatitudeE6() == 0 || lastPoint.getLongitudeE6() == 0) { lastPoint = getLastKnowGeopointLocation(); } return lastPoint; }
From source file:org.digitalcampus.oppia.application.DbHelper.java
public ArrayList<Course> getAllCourses() { ArrayList<Course> courses = new ArrayList<Course>(); String order = COURSE_C_ORDER_PRIORITY + " DESC, " + COURSE_C_TITLE + " ASC"; Cursor c = db.query(COURSE_TABLE, null, null, null, null, null, order); c.moveToFirst();// w ww.j a va2 s. c o m while (c.isAfterLast() == false) { Course course = new Course(prefs.getString(PrefsActivity.PREF_STORAGE_LOCATION, "")); course.setCourseId(c.getInt(c.getColumnIndex(COURSE_C_ID))); course.setVersionId(c.getDouble(c.getColumnIndex(COURSE_C_VERSIONID))); course.setTitlesFromJSONString(c.getString(c.getColumnIndex(COURSE_C_TITLE))); course.setImageFile(c.getString(c.getColumnIndex(COURSE_C_IMAGE))); course.setLangsFromJSONString(c.getString(c.getColumnIndex(COURSE_C_LANGS))); course.setShortname(c.getString(c.getColumnIndex(COURSE_C_SHORTNAME))); course.setPriority(c.getInt(c.getColumnIndex(COURSE_C_ORDER_PRIORITY))); courses.add(course); c.moveToNext(); } c.close(); return courses; }
From source file:org.digitalcampus.oppia.application.DbHelper.java
public ArrayList<Course> getCourses(long userId) { ArrayList<Course> courses = new ArrayList<Course>(); String order = COURSE_C_ORDER_PRIORITY + " DESC, " + COURSE_C_TITLE + " ASC"; Cursor c = db.query(COURSE_TABLE, null, null, null, null, null, order); c.moveToFirst();/* w w w . jav a 2 s .c om*/ while (c.isAfterLast() == false) { Course course = new Course(prefs.getString(PrefsActivity.PREF_STORAGE_LOCATION, "")); course.setCourseId(c.getInt(c.getColumnIndex(COURSE_C_ID))); course.setVersionId(c.getDouble(c.getColumnIndex(COURSE_C_VERSIONID))); course.setTitlesFromJSONString(c.getString(c.getColumnIndex(COURSE_C_TITLE))); course.setImageFile(c.getString(c.getColumnIndex(COURSE_C_IMAGE))); course.setLangsFromJSONString(c.getString(c.getColumnIndex(COURSE_C_LANGS))); course.setShortname(c.getString(c.getColumnIndex(COURSE_C_SHORTNAME))); course.setPriority(c.getInt(c.getColumnIndex(COURSE_C_ORDER_PRIORITY))); course.setDescriptionsFromJSONString(c.getString(c.getColumnIndex(COURSE_C_DESC))); course = this.courseSetProgress(course, userId); courses.add(course); c.moveToNext(); } c.close(); return courses; }
From source file:com.alboteanu.android.sunshine.app.DetailFragment.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { if (data != null && data.moveToFirst()) { ViewParent vp = getView().getParent(); if (vp instanceof CardView) { ((View) vp).setVisibility(View.VISIBLE); }//w w w . ja va 2 s . c om // Read weather condition ID from cursor int weatherId = data.getInt(COL_WEATHER_CONDITION_ID); if (Utility.usingLocalGraphics(getActivity())) { mIconView.setImageResource(Utility.getArtResourceForWeatherCondition(weatherId)); } else { // Use weather art image Glide.with(this).load(Utility.getArtUrlForWeatherCondition(getActivity(), weatherId)) .error(Utility.getArtResourceForWeatherCondition(weatherId)).crossFade().into(mIconView); } // Read date from cursor and update views for day of week and date long date = data.getLong(COL_WEATHER_DATE); String dateText = Utility.getFullFriendlyDayString(getActivity(), date); mDateView.setText(dateText); // Get description from weather condition ID // String description = Utility.getStringForWeatherCondition(getActivity(), weatherId); //orig String description = data.getString(COL_WEATHER_DESC); //eu mDescriptionView.setText(description); mDescriptionView.setContentDescription(getString(R.string.a11y_forecast, description)); // For accessibility, add a content description to the icon field. Because the ImageView // is independently focusable, it's better to have a description of the image. Using // null is appropriate when the image is purely decorative or when the image already // has text describing it in the same UI component. mIconView.setContentDescription(getString(R.string.a11y_forecast_icon, description)); // Read high temperature from cursor and update view boolean isMetric = Utility.isMetric(getActivity()); double high = data.getDouble(COL_WEATHER_MAX_TEMP); String highString = Utility.formatTemperature(getActivity(), high); mHighTempView.setText(highString); mHighTempView.setContentDescription(getString(R.string.a11y_high_temp, highString)); // Read low temperature from cursor and update view double low = data.getDouble(COL_WEATHER_MIN_TEMP); String lowString = Utility.formatTemperature(getActivity(), low); mLowTempView.setText(lowString); mLowTempView.setContentDescription(getString(R.string.a11y_low_temp, lowString)); // Read humidity from cursor and update view float humidity = data.getFloat(COL_WEATHER_HUMIDITY); mHumidityView.setText(getActivity().getString(R.string.format_humidity, humidity)); mHumidityView.setContentDescription(getString(R.string.a11y_humidity, mHumidityView.getText())); mHumidityLabelView.setContentDescription(mHumidityView.getContentDescription()); // Read wind speed and direction from cursor and update view float windSpeedStr = data.getFloat(COL_WEATHER_WIND_SPEED); float windDirStr = data.getFloat(COL_WEATHER_DEGREES); mWindView.setText(Utility.getFormattedWind(getActivity(), windSpeedStr, windDirStr)); mWindView.setContentDescription(getString(R.string.a11y_wind, mWindView.getText())); mWindLabelView.setContentDescription(mWindView.getContentDescription()); // Read pressure from cursor and update view float pressure = data.getFloat(COL_WEATHER_PRESSURE); mPressureView.setText(getString(R.string.format_pressure, pressure)); mPressureView.setContentDescription(getString(R.string.a11y_pressure, mPressureView.getText())); mPressureLabelView.setContentDescription(mPressureView.getContentDescription()); // We still need this for the share intent mForecast = String.format("%s - %s - %s/%s", dateText, description, high, low); } AppCompatActivity activity = (AppCompatActivity) getActivity(); Toolbar toolbarView = (Toolbar) getView().findViewById(R.id.toolbar); // We need to start the enter transition after the data has loaded if (mTransitionAnimation) { activity.supportStartPostponedEnterTransition(); if (null != toolbarView) { activity.setSupportActionBar(toolbarView); activity.getSupportActionBar().setDisplayShowTitleEnabled(false); activity.getSupportActionBar().setDisplayHomeAsUpEnabled(true); } } else { if (null != toolbarView) { Menu menu = toolbarView.getMenu(); if (null != menu) menu.clear(); toolbarView.inflateMenu(R.menu.detailfragment); finishCreatingMenu(toolbarView.getMenu()); } } /* adRequest = new AdRequest.Builder() .addTestDevice(getString(R.string.test_device)) .build(); adView.setAdListener(new AdListener() { @Override public void onAdLoaded() { super.onAdLoaded(); adView.setVisibility(View.VISIBLE); } }); adView.loadAd(adRequest);*/ getView().setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mInterstitial == null) mInterstitial = Utility.requestNewInterstitial(getActivity()); else if (mInterstitial.isLoaded()) mInterstitial.show(); } }); }
From source file:com.money.manager.ex.fragment.HomeFragment.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { MainActivity mainActivity = null;//from w w w. j av a 2 s . c o m if (getActivity() != null && getActivity() instanceof MainActivity) mainActivity = (MainActivity) getActivity(); switch (loader.getId()) { case ID_LOADER_USER_NAME: if (data != null && data.moveToFirst()) { while (data.isAfterLast() == false) { String infoValue = data.getString(data.getColumnIndex(infoTable.INFONAME)); // save into preferences username and basecurrency id if (Constants.INFOTABLE_USERNAME.equalsIgnoreCase(infoValue)) { application.setUserName(data.getString(data.getColumnIndex(infoTable.INFOVALUE))); } else if (Constants.INFOTABLE_BASECURRENCYID.equalsIgnoreCase(infoValue)) { //application.setBaseCurrencyId(data.getInt(data.getColumnIndex(infoTable.INFOVALUE))); } data.moveToNext(); } } // show username if (!TextUtils.isEmpty(application.getUserName())) ((SherlockFragmentActivity) getActivity()).getSupportActionBar() .setSubtitle(application.getUserName()); // set user name on drawer if (mainActivity != null) mainActivity.setDrawableUserName(application.getUserName()); break; case ID_LOADER_ACCOUNT_BILLS: double curTotal = 0, curReconciled = 0; AccountBillsAdapter adapter = null; linearHome.setVisibility(data != null && data.getCount() > 0 ? View.VISIBLE : View.GONE); linearWelcome.setVisibility(linearHome.getVisibility() == View.GONE ? View.VISIBLE : View.GONE); // cycle cursor if (data != null && data.moveToFirst()) { while (data.isAfterLast() == false) { curTotal += data.getDouble(data.getColumnIndex(QueryAccountBills.TOTALBASECONVRATE)); curReconciled += data.getDouble(data.getColumnIndex(QueryAccountBills.RECONCILEDBASECONVRATE)); data.moveToNext(); } // create adapter adapter = new AccountBillsAdapter(getActivity(), data); } // write accounts total txtTotalAccounts.setText(currencyUtils.getBaseCurrencyFormatted(curTotal)); // manage footer listview if (linearFooter == null) { linearFooter = (LinearLayout) getActivity().getLayoutInflater().inflate(R.layout.item_account_bills, null); // textview into layout txtFooterSummary = (TextView) linearFooter.findViewById(R.id.textVievItemAccountTotal); txtFooterSummaryReconciled = (TextView) linearFooter .findViewById(R.id.textVievItemAccountTotalReconciled); // set text TextView txtTextSummary = (TextView) linearFooter.findViewById(R.id.textVievItemAccountName); txtTextSummary.setText(R.string.summary); // invisibile image ImageView imgSummary = (ImageView) linearFooter.findViewById(R.id.imageViewAccountType); imgSummary.setVisibility(View.INVISIBLE); // set color textview txtTextSummary.setTextColor(Color.GRAY); txtFooterSummary.setTextColor(Color.GRAY); txtFooterSummaryReconciled.setTextColor(Color.GRAY); } // remove footer lstAccountBills.removeFooterView(linearFooter); // set text txtFooterSummary.setText(txtTotalAccounts.getText()); txtFooterSummaryReconciled.setText(currencyUtils.getBaseCurrencyFormatted(curReconciled)); // add footer lstAccountBills.addFooterView(linearFooter, null, false); // set adapter and shown lstAccountBills.setAdapter(adapter); setListViewAccountBillsVisible(true); // set total accounts in drawer if (mainActivity != null) { mainActivity.setDrawableTotalAccounts(txtTotalAccounts.getText().toString()); } break; case ID_LOADER_BILL_DEPOSITS: mainActivity.setDrawableRepeatingTransactions(data != null ? data.getCount() : 0); break; case ID_LOADER_INCOME_EXPENSES: double income = 0, expenses = 0; if (data != null && data.moveToFirst()) { while (!data.isAfterLast()) { expenses = data.getDouble(data.getColumnIndex(QueryReportIncomeVsExpenses.Expenses)); income = data.getDouble(data.getColumnIndex(QueryReportIncomeVsExpenses.Income)); //move to next record data.moveToNext(); } } TextView txtIncome = (TextView) getActivity().findViewById(R.id.textViewIncome); TextView txtExpenses = (TextView) getActivity().findViewById(R.id.textViewExpenses); TextView txtDifference = (TextView) getActivity().findViewById(R.id.textViewDifference); // set value if (txtIncome != null) txtIncome.setText(currencyUtils.getCurrencyFormatted(currencyUtils.getBaseCurrencyId(), income)); if (txtExpenses != null) txtExpenses.setText( currencyUtils.getCurrencyFormatted(currencyUtils.getBaseCurrencyId(), Math.abs(expenses))); if (txtDifference != null) txtDifference.setText(currencyUtils.getCurrencyFormatted(currencyUtils.getBaseCurrencyId(), income - Math.abs(expenses))); // manage progressbar final ProgressBar barIncome = (ProgressBar) getActivity().findViewById(R.id.progressBarIncome); final ProgressBar barExpenses = (ProgressBar) getActivity().findViewById(R.id.progressBarExpenses); if (barIncome != null && barExpenses != null) { barIncome.setMax((int) (Math.abs(income) + Math.abs(expenses))); barExpenses.setMax((int) (Math.abs(income) + Math.abs(expenses))); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) { ObjectAnimator animationIncome = ObjectAnimator.ofInt(barIncome, "progress", (int) Math.abs(income)); animationIncome.setDuration(1000); // 0.5 second animationIncome.setInterpolator(new DecelerateInterpolator()); animationIncome.start(); ObjectAnimator animationExpenses = ObjectAnimator.ofInt(barExpenses, "progress", (int) Math.abs(expenses)); animationExpenses.setDuration(1000); // 0.5 second animationExpenses.setInterpolator(new DecelerateInterpolator()); animationExpenses.start(); } else { barIncome.setProgress((int) Math.abs(income)); barExpenses.setProgress((int) Math.abs(expenses)); } } } }
From source file:com.ichi2.anki.SyncClient.java
/** * Anki Desktop -> libanki/anki/sync.py, SyncTools - getMedia *//*from w w w . ja v a2 s.co m*/ private JSONArray getMedia(JSONArray ids) { JSONArray media = new JSONArray(); Cursor cursor = AnkiDatabaseManager.getDatabase(mDeck.getDeckPath()).getDatabase() .rawQuery("SELECT id, filename, size, created, originalPath, description FROM media WHERE id IN " + Utils.ids2str(ids), null); while (cursor.moveToNext()) { try { JSONArray m = new JSONArray(); // id m.put(cursor.getLong(0)); // filename m.put(cursor.getString(1)); // size m.put(cursor.getInt(2)); // created m.put(cursor.getDouble(3)); // originalPath m.put(cursor.getString(4)); // description m.put(cursor.getString(5)); media.put(m); } catch (JSONException e) { Log.i(AnkiDroidApp.TAG, "JSONException = " + e.getMessage()); } } cursor.close(); return media; }
From source file:com.ichi2.anki.SyncClient.java
/** * Anki Desktop -> libanki/anki/sync.py, SyncTools - getCards *//*from www .j a v a 2 s . c o m*/ private JSONArray getCards(JSONArray ids) { JSONArray cards = new JSONArray(); // SELECT id, factId, cardModelId, created, modified, tags, ordinal, priority, interval, lastInterval, due, // lastDue, factor, // firstAnswered, reps, successive, averageTime, reviewTime, youngEase0, youngEase1, youngEase2, youngEase3, // youngEase4, // matureEase0, matureEase1, matureEase2, matureEase3, matureEase4, yesCount, noCount, question, answer, // lastFactor, spaceUntil, // type, combinedDue FROM cards WHERE id IN " + ids2str(ids) Cursor cursor = AnkiDatabaseManager.getDatabase(mDeck.getDeckPath()).getDatabase() .rawQuery("SELECT * FROM cards WHERE id IN " + Utils.ids2str(ids), null); while (cursor.moveToNext()) { try { JSONArray card = new JSONArray(); // id card.put(cursor.getLong(0)); // factId card.put(cursor.getLong(1)); // cardModelId card.put(cursor.getLong(2)); // created card.put(cursor.getDouble(3)); // modified card.put(cursor.getDouble(4)); // tags card.put(cursor.getString(5)); // ordinal card.put(cursor.getInt(6)); // priority card.put(cursor.getInt(9)); // interval card.put(cursor.getDouble(10)); // lastInterval card.put(cursor.getDouble(11)); // due card.put(cursor.getDouble(12)); // lastDue card.put(cursor.getDouble(13)); // factor card.put(cursor.getDouble(14)); // firstAnswered card.put(cursor.getDouble(16)); // reps card.put(cursor.getString(17)); // successive card.put(cursor.getInt(18)); // averageTime card.put(cursor.getDouble(19)); // reviewTime card.put(cursor.getDouble(20)); // youngEase0 card.put(cursor.getInt(21)); // youngEase1 card.put(cursor.getInt(22)); // youngEase2 card.put(cursor.getInt(23)); // youngEase3 card.put(cursor.getInt(24)); // youngEase4 card.put(cursor.getInt(25)); // matureEase0 card.put(cursor.getInt(26)); // matureEase1 card.put(cursor.getInt(27)); // matureEase2 card.put(cursor.getInt(28)); // matureEase3 card.put(cursor.getInt(29)); // matureEase4 card.put(cursor.getInt(30)); // yesCount card.put(cursor.getInt(31)); // noCount card.put(cursor.getInt(32)); // question card.put(cursor.getString(7)); // answer card.put(cursor.getString(8)); // lastFactor card.put(cursor.getDouble(15)); // spaceUntil card.put(cursor.getDouble(33)); // type card.put(cursor.getInt(36)); // combinedDue card.put(cursor.getInt(37)); cards.put(card); } catch (JSONException e) { Log.i(AnkiDroidApp.TAG, "JSONException = " + e.getMessage()); } } cursor.close(); return cards; }
From source file:us.theparamountgroup.android.inventory.EditorActivity.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) { // Bail early if the cursor is null or there is less than 1 row in the cursor if (cursor == null || cursor.getCount() < 1) { return;//from w w w . ja v a2 s . co m } // Proceed with moving to the first row of the cursor and reading data from it // (This should be the only row in the cursor) if (cursor.moveToFirst()) { // Find the columns of Shell attributes that we're interested in int nameColumnIndex = cursor.getColumnIndex(ShellContract.ShellEntry.COLUMN_SHELL_NAME); int breedColumnIndex = cursor.getColumnIndex(ShellContract.ShellEntry.COLUMN_SHELL_COLOR); int genderColumnIndex = cursor.getColumnIndex(ShellContract.ShellEntry.COLUMN_SHELL_HOLE); int typeColumnIndex = cursor.getColumnIndex(ShellContract.ShellEntry.COLUMN_SHELL_TYPE); int photoColumnIndex = cursor.getColumnIndex(ShellContract.ShellEntry.COLUMN_SHELL_PHOTO); int quantityColumnIndex = cursor.getColumnIndex(ShellContract.ShellEntry.COLUMN_SHELL_QUANTITY); int priceColumnIndex = cursor.getColumnIndex(ShellContract.ShellEntry.COLUMN_SHELL_PRICE); // Extract out the value from the Cursor for the given column index String name = cursor.getString(nameColumnIndex); String color = cursor.getString(breedColumnIndex); int hole = cursor.getInt(genderColumnIndex); int type = cursor.getInt(typeColumnIndex); String photo = cursor.getString(photoColumnIndex); int quantity = cursor.getInt(quantityColumnIndex); double price = cursor.getDouble(priceColumnIndex); // Update the views on the screen with the values from the database mNameEditText.setText(name); mColorEditText.setText(color); mQuantityTextView.setText(Integer.toString(quantity)); mPriceEditText.setText(Double.toString(price)); if (!photo.isEmpty()) { mUri = Uri.parse(photo); mBitmap = getBitmapFromUri(mUri); mImageView.setImageBitmap(mBitmap); } // Hole is a dropdown spinner, so map the constant value from the database // into one of the dropdown options (0 is Unknown, 1 is Hole, 2 is No Hole). // Then call setSelection() so that option is displayed on screen as the current selection. switch (hole) { case ShellContract.ShellEntry.HOLE: mHoleSpinner.setSelection(1); break; case ShellContract.ShellEntry.NO_HOLE: mHoleSpinner.setSelection(2); break; default: mHoleSpinner.setSelection(0); break; } // type is a dropdown spinner, so map the constant value from the database // into one of the dropdown options (0 is Scallop, 1 is Jingle, 2 is Slipper, 3 is Shard). // Then call setSelection() so that option is displayed on screen as the current selection. switch (type) { case ShellContract.ShellEntry.TYPE_SHARD: mTypeSpinner.setSelection(3); break; case ShellContract.ShellEntry.TYPE_JINGLE: mTypeSpinner.setSelection(1); break; case ShellContract.ShellEntry.TYPE_SLIPPER: mTypeSpinner.setSelection(2); break; default: mTypeSpinner.setSelection(0); break; } } }
From source file:org.digitalcampus.oppia.application.DbHelper.java
public ArrayList<Course> getLearningCourses(long userId) { ArrayList<Course> courses = new ArrayList<Course>(); String order = COURSE_C_ORDER_PRIORITY + " DESC, " + COURSE_C_TITLE + " ASC"; String where = COURSE_C_SHORTNAME + " NOT IN (" + MobileLearning.CLIENT_COUNSELLING_COURSES + ")"; Cursor c = db.query(COURSE_TABLE, null, where, null, null, null, order); //Cursor c = db.query(COURSE_TABLE, null, null, null, null, null, order); c.moveToFirst();/*w ww . java2 s . com*/ while (c.isAfterLast() == false) { Course course = new Course(prefs.getString(PrefsActivity.PREF_STORAGE_LOCATION, "")); course.setCourseId(c.getInt(c.getColumnIndex(COURSE_C_ID))); course.setVersionId(c.getDouble(c.getColumnIndex(COURSE_C_VERSIONID))); course.setTitlesFromJSONString(c.getString(c.getColumnIndex(COURSE_C_TITLE))); course.setImageFile(c.getString(c.getColumnIndex(COURSE_C_IMAGE))); course.setLangsFromJSONString(c.getString(c.getColumnIndex(COURSE_C_LANGS))); course.setShortname(c.getString(c.getColumnIndex(COURSE_C_SHORTNAME))); course.setPriority(c.getInt(c.getColumnIndex(COURSE_C_ORDER_PRIORITY))); course.setDescriptionsFromJSONString(c.getString(c.getColumnIndex(COURSE_C_DESC))); course = this.courseSetProgress(course, userId); courses.add(course); c.moveToNext(); } c.close(); return courses; }
From source file:com.harlie.android.sunshine.app.DetailFragment.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { if (getView() != null) { if (data != null && data.moveToFirst()) { ViewParent vp = getView().getParent(); if (vp != null) { if (vp instanceof CardView) { ((View) vp).setVisibility(View.VISIBLE); }//w ww . j a va 2 s . c om } // Read weather condition ID from cursor int weatherId = data.getInt(COL_WEATHER_CONDITION_ID); if (Utility.usingLocalGraphics()) { mIconView.setImageResource(Utility.getArtResourceForWeatherCondition(weatherId)); } else { // Use weather art image Glide.with(this).load(Utility.getArtUrlForWeatherCondition(weatherId)) .error(Utility.getArtResourceForWeatherCondition(weatherId)).crossFade() .into(mIconView); } // Read date from cursor and update views for day of week and date long date = data.getLong(COL_WEATHER_DATE); String dateText = Utility.getFullFriendlyDayString(date); mDateView.setText(dateText); // Get description from weather condition ID String description = Utility.getStringForWeatherCondition(getActivity(), weatherId); mDescriptionView.setText(description); mDescriptionView.setContentDescription(getString(R.string.a11y_forecast, description)); // For accessibility, add a content description to the icon field. Because the ImageView // is independently focusable, it's better to have a description of the image. Using // null is appropriate when the image is purely decorative or when the image already // has text describing it in the same UI component. mIconView.setContentDescription(getString(R.string.a11y_forecast_icon, description)); // Read high temperature from cursor and update view @SuppressWarnings("UnusedAssignment") boolean isMetric = Utility.isMetric(); double high = data.getDouble(COL_WEATHER_MAX_TEMP); String highString = Utility.formatTemperature(high); mHighTempView.setText(highString); mHighTempView.setContentDescription(getString(R.string.a11y_high_temp, highString)); // Read low temperature from cursor and update view double low = data.getDouble(COL_WEATHER_MIN_TEMP); String lowString = Utility.formatTemperature(low); mLowTempView.setText(lowString); mLowTempView.setContentDescription(getString(R.string.a11y_low_temp, lowString)); // Read humidity from cursor and update view float humidity = data.getFloat(COL_WEATHER_HUMIDITY); mHumidityView.setText(getActivity().getString(R.string.format_humidity, humidity)); mHumidityView.setContentDescription(getString(R.string.a11y_humidity, mHumidityView.getText())); mHumidityLabelView.setContentDescription(mHumidityView.getContentDescription()); // Read wind speed and direction from cursor and update view float windSpeedStr = data.getFloat(COL_WEATHER_WIND_SPEED); float windDirStr = data.getFloat(COL_WEATHER_DEGREES); mWindView.setText(Utility.getFormattedWind(getActivity(), windSpeedStr, windDirStr)); mWindView.setContentDescription(getString(R.string.a11y_wind, mWindView.getText())); mWindLabelView.setContentDescription(mWindView.getContentDescription()); // Read pressure from cursor and update view float pressure = data.getFloat(COL_WEATHER_PRESSURE); mPressureView.setText(getString(R.string.format_pressure, pressure)); mPressureView.setContentDescription(getString(R.string.a11y_pressure, mPressureView.getText())); mPressureLabelView.setContentDescription(mPressureView.getContentDescription()); // We still need this for the share intent mForecast = String.format("%s - %s - %s/%s", dateText, description, high, low); } AppCompatActivity activity = (AppCompatActivity) getActivity(); Toolbar toolbarView = (Toolbar) getView().findViewById(R.id.toolbar); // We need to start the enter transition after the data has loaded if (mTransitionAnimation && activity != null) { activity.supportStartPostponedEnterTransition(); if (null != toolbarView && null != activity.getSupportActionBar()) { activity.setSupportActionBar(toolbarView); activity.getSupportActionBar().setDisplayShowTitleEnabled(false); activity.getSupportActionBar().setDisplayHomeAsUpEnabled(true); } } else { if (null != toolbarView) { Menu menu = toolbarView.getMenu(); if (null != menu) menu.clear(); toolbarView.inflateMenu(R.menu.detailfragment); finishCreatingMenu(toolbarView.getMenu()); } } } }