List of usage examples for android.content.res Resources getIntArray
@NonNull public int[] getIntArray(@ArrayRes int id) throws NotFoundException
From source file:Main.java
private static long[] getLongIntArray(Resources r, int resid) { int[] ar = r.getIntArray(resid); long[] out;/*from www . j a v a2 s . c o m*/ if (ar == null) { out = null; } else { out = new long[ar.length]; for (int i = 0; i < ar.length; i++) out[i] = ar[i]; } return out; }
From source file:com.tct.mail.browse.ConversationItemViewCoordinates.java
/** * Returns the length (maximum of characters) of subject in this mode. *//* w w w . j a v a 2 s. c o m*/ public static int getSendersLength(Context context, int mode, boolean hasAttachments) { final Resources res = context.getResources(); if (hasAttachments) { return res.getIntArray(R.array.senders_with_attachment_lengths)[mode]; } else { return res.getIntArray(R.array.senders_lengths)[mode]; } }
From source file:org.totschnig.myexpenses.dialog.VersionDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { Bundle bundle = getArguments();// www .j a v a 2s . com Activity ctx = (Activity) getActivity(); LayoutInflater li = LayoutInflater.from(ctx); int from = bundle.getInt("from"); Resources res = getResources(); int[] versionCodes = res.getIntArray(R.array.version_codes); String[] versionNames = res.getStringArray(R.array.version_names); final ArrayList<VersionInfo> versions = new ArrayList<VersionInfo>(); for (int i = 0; i < versionCodes.length; i++) { int code = versionCodes[i]; if (from >= code) break; int resId = res.getIdentifier("whats_new_" + code, "array", ctx.getPackageName()); if (resId == 0) { Log.e(MyApplication.TAG, "missing change log entry for version " + code); } else { String changes[] = res .getStringArray(res.getIdentifier("whats_new_" + code, "array", ctx.getPackageName())); versions.add(new VersionInfo(code, versionNames[i], changes)); } } View view = li.inflate(R.layout.versiondialog, null); final ListView lv = (ListView) view.findViewById(R.id.list); ArrayAdapter<VersionInfo> adapter = new ArrayAdapter<VersionInfo>(ctx, R.layout.version_row, R.id.versionInfoName, versions) { @Override public View getView(int position, View convertView, ViewGroup parent) { LinearLayout row = (LinearLayout) super.getView(position, convertView, parent); VersionInfo version = versions.get(position); ((TextView) row.findViewById(R.id.versionInfoName)).setText(version.name); ((TextView) row.findViewById(R.id.versionInfoChanges)) .setText("- " + TextUtils.join("\n- ", version.changes)); return row; } }; lv.setAdapter(adapter); if (MyApplication.getInstance().showImportantUpgradeInfo) { view.findViewById(R.id.ImportantUpgradeInfoHeading).setVisibility(View.VISIBLE); view.findViewById(R.id.ImportantUpgradeInfoBody).setVisibility(View.VISIBLE); } AlertDialog.Builder builder = new AlertDialog.Builder(ctx) .setTitle(getString(R.string.help_heading_whats_new)).setIcon(R.drawable.icon).setView(view) .setNegativeButton(android.R.string.ok, this); if (!MyApplication.getInstance().isContribEnabled) builder.setPositiveButton(R.string.menu_contrib, this); return builder.create(); }
From source file:Main.java
public static Object getResource(Context context, Field field, int value) { Resources resources = context.getResources(); Class type = field.getType(); if (type.isAssignableFrom(Boolean.TYPE) || type.isAssignableFrom(Boolean.class)) return resources.getBoolean(value); else if (type.isAssignableFrom(Integer.TYPE) || type.isAssignableFrom(Integer.class)) { return resources.getInteger(value); } else if (type.isAssignableFrom(ColorStateList.class)) return resources.getColorStateList(value); else if (type.isAssignableFrom(XmlResourceParser.class)) return resources.getXml(value); else if (type.isAssignableFrom(Float.TYPE) || type.isAssignableFrom(Float.class)) return resources.getDimension(value); else if (type.isAssignableFrom(Drawable.class)) return resources.getDrawable(value); else if (type.isAssignableFrom(Animation.class)) return AnimationUtils.loadAnimation(context, value); else if (type.isAssignableFrom(Movie.class)) return resources.getMovie(value); else if (type.isAssignableFrom(String.class)) return resources.getString(value); else if (type.isArray()) { if (type.getName().equals("[I")) { return resources.getIntArray(value); } else if (type.isAssignableFrom(String[].class)) { return resources.getStringArray(value); }//w w w .j a v a2s. c o m } return null; }
From source file:com.bdevlin.apps.ui.activity.core.HelpActivity.java
private void initFragments() { mFragments = new ArrayList<>(); Resources res = getResources(); String[] helpTitles = res.getStringArray(R.array.help_screens); int[] helpKeys = res.getIntArray(R.array.help_keys); int length = helpTitles.length; String message = String.format(res.getString(R.string.welcome_messages), "Help", length); CharSequence styledText = Html.fromHtml(message); if (helpKeys.length != length) { if (DEBUG) Log.e(TAG, "Mismatch between keys length " + helpKeys.length + " and titles " + length); length = Math.min(length, helpKeys.length); }//w w w. j ava 2 s . com for (int i = 0; i < length; i++) { HelpListFragment fragment = new HelpListFragment(); Bundle args = new Bundle(); int index = helpKeys[i]; String idKey = "help" + index; int contentId = res.getIdentifier(idKey, "string", getPackageName()); CharSequence content = getText(contentId); args.putCharSequence(HelpListFragment.CONTENT, content); args.putString(HelpListFragment.TITLE, helpTitles[index]); args.putCharSequence(HelpListFragment.MESSAGE, styledText); fragment.setArguments(args); mFragments.add(fragment); } // few magic numbers for good luck... mQueryIndex = new HashMap<ListQuery, Integer>(); mQueryIndex.put(ListQuery.inbox, 1); mQueryIndex.put(ListQuery.dueToday, 2); mQueryIndex.put(ListQuery.dueNextWeek, 2); mQueryIndex.put(ListQuery.dueNextMonth, 2); mQueryIndex.put(ListQuery.nextTasks, 3); mQueryIndex.put(ListQuery.project, 4); mQueryIndex.put(ListQuery.context, 5); mQueryIndex.put(ListQuery.custom, 6); mQueryIndex.put(ListQuery.tickler, 7); }
From source file:org.zakky.memopad.PadActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mCanvases = new CanvasFragment[2]; for (int i = 0; i < mCanvases.length; i++) { mCanvases[i] = new CanvasFragment(); }/*from w w w. j a v a 2s. c om*/ fixOrientation(); setContentView(R.layout.placeholder); final FragmentManager fm = getSupportFragmentManager(); final FragmentTransaction tx = fm.beginTransaction(); try { final Fragment old = fm.findFragmentByTag(FG_TAG_CANVAS); if (old != null) { tx.remove(old); } tx.add(R.id.container, getCurrentCanvas(), FG_TAG_CANVAS); } finally { tx.commit(); } if (MyDialogFragment.showAtStartup(this)) { new MyDialogFragment().show(fm.beginTransaction(), "dialog"); } final Resources resources = getResources(); /* * ? */ mPenColorValues = resources.getIntArray(R.array.pen_color_value_list); /* * */ mBgColorLabels = resources.getStringArray(R.array.bg_color_label_list); mBgColorValues = resources.getIntArray(R.array.bg_color_value_list); }
From source file:com.wholegroup.rally.ScoreActivity.java
/** */ @Override//from ww w . j a va2 s .c om public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // ? ? ?? m_sbNumber = new StringBuffer(); // ? Resources m_res = getResources(); String[] arrDefaultNames = m_res.getStringArray(R.array.names); int[] arrDefaultScores = m_res.getIntArray(R.array.scores); m_arrRecords = new ScoreRecord[RECORDCOUNT]; for (int i = 0; i < RECORDCOUNT; i++) { if ((i < arrDefaultNames.length) && (i < arrDefaultScores.length)) { m_arrRecords[i] = new ScoreRecord(arrDefaultNames[i], arrDefaultScores[i], Rally.GAME_A); } else { m_arrRecords[i] = new ScoreRecord(getString(R.string.score_default_name), 0, Rally.GAME_A); } } m_strGameA = getString(R.string.rally_text_short_game_a); m_strGameB = getString(R.string.rally_text_short_game_b); // Intent intent = getIntent(); m_iScore = intent.getIntExtra(getString(R.string.score_parameter_score), 0); m_iType = intent.getIntExtra(getString(R.string.score_parameter_type), Rally.GAME_A); m_sName = getString(R.string.score_default_name); // LoadScore(); // ? ?? Arrays.sort(m_arrRecords); // ? ?? requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); setContentView(R.layout.score); // ? getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title); ((TextView) findViewById(R.id.custom_title_left_text)).setText(R.string.score_activity_title); ((TextView) findViewById(R.id.custom_title_right_text)).setText(R.string.application_upper); // ? ? ? ?? setListAdapter(new ScoreAdapter()); // ? if ((0 < m_iScore) && (m_iScore > m_arrRecords[RECORDCOUNT - 1].m_iScore)) { showDialog(0); } }
From source file:com.z299studio.pb.EditFragment.java
private AccountManager.Account getDefaultTemplate(int id) { int intArrayIds[] = { R.array.index_5, R.array.index_0, R.array.index_1, R.array.index_2, R.array.index_3, R.array.index_4 };/*from w w w.j av a 2 s . c o m*/ Resources r = getResources(); String[] defNames = r.getStringArray(R.array.def_field_names); int[] defTypes = r.getIntArray(R.array.def_field_types); int[] indexArray; AccountManager.Account account = mApp.getAccountManager().newAccount(id); if (id < intArrayIds.length) { indexArray = r.getIntArray(intArrayIds[id]); } else { indexArray = r.getIntArray(intArrayIds[0]); } for (int i : indexArray) { account.addEntry(defTypes[i], defNames[i], ""); } return account; }
From source file:com.android.calendar.event.EditEventView.java
/** * Loads an integer array asset into a list. *///from w ww. ja va2 s.co m private static ArrayList<Integer> loadIntegerArray(Resources r, int resNum) { int[] vals = r.getIntArray(resNum); int size = vals.length; ArrayList<Integer> list = new ArrayList<Integer>(size); for (int i = 0; i < size; i++) { list.add(vals[i]); } return list; }
From source file:com.microsoft.azure.engagement.fragment.RecentProductUpdatesFragment.java
@Nullable @Override/*from w ww .j a v a2 s .c om*/ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View view = inflater.inflate(R.layout.fragment_recent_product_updates, container, false); final Resources resources = getResources(); recyclerView = (RecyclerView) view.findViewById(R.id.recyclerView); recyclerView .setLayoutManager(new LinearLayoutManager(view.getContext(), LinearLayoutManager.VERTICAL, false)); recyclerView.addItemDecoration(new MarginItemDecoration((int) resources.getDimension(R.dimen.dimen20dip), (int) resources.getDimension(R.dimen.dimen15dip))); progressBar = view.findViewById(R.id.progressBar); retryButton = view.findViewById(R.id.retryButton); retryButton.setOnClickListener(this); errorContainer = view.findViewById(R.id.errorContainer); errorContainer.setVisibility(View.VISIBLE); swipeRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipeRefreshLayout); swipeRefreshLayout.setOnRefreshListener(this); swipeRefreshLayout.setColorSchemeColors(resources.getIntArray(R.array.refreshColors)); asyncTaskCall(false); AzmeTracker.startActivity(getActivity(), "recent_updates"); return view; }