List of usage examples for android.content.res Resources getStringArray
@NonNull public String[] getStringArray(@ArrayRes int id) throws NotFoundException
From source file:com.nikhilnayak.games.octoshootar.ui.fragments.GameScoreFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final Resources res = getResources(); View v = inflater.inflate(R.layout.fragment_score, container, false); final int[] clickable = new int[] { R.id.score_button_replay, R.id.score_button_home, R.id.score_button_skip, R.id.score_button_share, R.id.score_button_next_mission, R.id.fragment_score_btn_loot_help }; for (int i : clickable) { v.findViewById(i).setOnClickListener(this); }//from www . j a va 2 s .c o m if (savedInstanceState != null) { mIsDisplayDone = savedInstanceState.getBoolean(BUNDLE_IS_DISPLAY_DONE, false); mAchievementChecked = savedInstanceState.getBoolean(BUNDLE_CURRENT_ACHIEVEMENT_CHECKED, false); mPlayerProfileSaved = savedInstanceState.getBoolean(BUNDLE_CURRENT_PLAYER_PROFILE_SAVED, false); mHasIncreaseRank = savedInstanceState.getBoolean(BUNDLE_HAS_INCREASED_RANK, false); mHasLeveledUp = savedInstanceState.getBoolean(BUNDLE_HAS_LEVELED_UP, false); } if (getArguments().containsKey(EXTRA_GAME_INFORMATION)) { mGameInformation = getArguments().getParcelable(EXTRA_GAME_INFORMATION); retrieveGameDetails(mGameInformation); //set info to details card ((TextView) v.findViewById(R.id.numberOfTargetsKilled)).setText(String.valueOf(mRetrievedTargetKilled)); ((TextView) v.findViewById(R.id.numberOfBulletsFired)).setText(String.valueOf(mRetrievedBulletFired)); ((TextView) v.findViewById(R.id.maxCombo)).setText(String.valueOf(mRetrievedCombo)); ((TextView) v.findViewById(R.id.expEarned)).setText(String.valueOf(mRetrievedExpEarned)); ((TextView) v.findViewById(R.id.fragment_score_game_mode_name)) .setText(mGameInformation.getGameMode().getTitle()); } //update playerProfile with value of this game updatePlayerProfile(); //populate the view final LevelInformation levelInformation = mPlayerProfile.getLevelInformation(); ((TextView) v.findViewById(R.id.result_level)) .setText(String.format(getString(R.string.profile_level), levelInformation.getLevel())); ((TextView) v.findViewById(R.id.result_current_exp)).setText(String.format(getString(R.string.profile_exp), levelInformation.getExpProgress(), levelInformation.getExpNeededToLevelUp())); mRetrievedExpBar = levelInformation.getProgressInPercent(); //congratz card ? final View congratzCard = v.findViewById(R.id.result_card_congratz); final TextView congratsText = (TextView) v.findViewById(R.id.result_congratz_message); if (mHasLeveledUp) { congratzCard.setVisibility(View.VISIBLE); congratsText.setText(getString(R.string.score_congratz_level_up) + "\n"); } if (mHasIncreaseRank) { congratzCard.setVisibility(View.VISIBLE); congratsText.setText(congratsText.getText() + getString(R.string.score_congratz_rank_up)); } mFinalScoreTopTextView = (TextView) v.findViewById(R.id.result_score_top); mFinalScoreBottomTextView = (TextView) v.findViewById(R.id.finalScore); mSkipButton = (Button) v.findViewById(R.id.score_button_skip); mSignInView = v.findViewById(R.id.sign_in_message); mExpEarnedTextView = (TextView) v.findViewById(R.id.result_earned_exp); mExpbar = (ProgressBar) v.findViewById(R.id.result_level_progess_bar); HashMap<Integer, Integer> loots = mGameInformation.getLoot(); if (loots.size() != 0) { String stringLoot = ""; for (Map.Entry<Integer, Integer> entry : loots.entrySet()) { InventoryItemEntry inventoryItemEntry = InventoryItemEntryFactory.create(entry.getKey(), entry.getValue()); final long quantityDropped = inventoryItemEntry.getQuantityAvailable(); final int titleResourceId = inventoryItemEntry.getTitleResourceId(); stringLoot += String.valueOf(quantityDropped) + "x " + res.getQuantityString(titleResourceId, (int) quantityDropped) + "\n"; } stringLoot = stringLoot.substring(0, stringLoot.length() - 1); ((TextView) v.findViewById(R.id.score_loot_list)).setText(stringLoot); } //show the right rank String[] ranks = res.getStringArray(R.array.ranks_array_full); String[] grades = res.getStringArray(R.array.ranks_array_letter); final int gameRank = mGameInformation.getRank(); switch (gameRank) { case GameModeFactory.GAME_RANK_DESERTER: case GameModeFactory.GAME_RANK_SOLDIER: case GameModeFactory.GAME_RANK_CORPORAL: case GameModeFactory.GAME_RANK_SERGEANT: case GameModeFactory.GAME_RANK_ADMIRAL: ((TextView) v.findViewById(R.id.result_rang)).setText(ranks[gameRank]); ((TextView) v.findViewById(R.id.result_grade)).setText(grades[gameRank]); break; default: ((TextView) v.findViewById(R.id.result_rang)).setText(ranks[0]); ((TextView) v.findViewById(R.id.result_grade)).setText(grades[0]); break; } return v; }