List of usage examples for android.util SparseIntArray indexOfValue
public int indexOfValue(int value)
From source file:io.fabric.samples.cannonball.activity.PoemBuilderActivity.java
private void createPoem() { if (poemContainer.getChildCount() > 0) { final String poemText = getPoemText(); final SparseIntArray imgList = poemTheme.getImageList(); // the line below seems weird, but relies on the fact that the index of SparseIntArray could be any integer final int poemImage = imgList .keyAt(imgList.indexOfValue(imgList.get(poemImagePager.getCurrentItem() + 1))); Crashlytics.setString(App.CRASHLYTICS_KEY_POEM_TEXT, poemText); Crashlytics.setInt(App.CRASHLYTICS_KEY_POEM_IMAGE, poemImage); AppService.createPoem(getApplicationContext(), poemText, poemImage, poemTheme.getDisplayName(), dateFormat.format(Calendar.getInstance().getTime())); } else {// w w w. j ava2s . c o m Toast.makeText(getApplicationContext(), getResources().getString(R.string.toast_wordless_poem), Toast.LENGTH_SHORT).show(); Crashlytics.log("PoemBuilder: User tried to create poem without words on it"); } }
From source file:galilei.kelimekavanozu.activity.PoemBuilderActivity.java
private void createPoem() { if (poemContainer.getChildCount() > 0) { final String poemText = getPoemText(); final SparseIntArray imgList = poemTheme.getImageList(); // the line below seems weird, but relies on the fact that the index of SparseIntArray could be any integer final int poemImage = imgList .keyAt(imgList.indexOfValue(imgList.get(poemImagePager.getCurrentItem() + 1))); Crashlytics.setString(App.CRASHLYTICS_KEY_POEM_TEXT, poemText); Crashlytics.setInt(App.CRASHLYTICS_KEY_POEM_IMAGE, poemImage); Answers.getInstance().logCustom( new CustomEvent("clicked save poem").putCustomAttribute("poem size", poemText.length()) .putCustomAttribute("poem theme", poemTheme.getDisplayName()) .putCustomAttribute("poem image", poemImage)); AppService.createPoem(getApplicationContext(), poemText, poemImage, poemTheme.getDisplayName(), dateFormat.format(Calendar.getInstance().getTime())); } else {/*www. j a v a2 s . c o m*/ Toast.makeText(getApplicationContext(), getResources().getString(R.string.toast_wordless_poem), Toast.LENGTH_SHORT).show(); Crashlytics.log("PoemBuilder: User tried to create poem without words on it"); } }