private void updateLanguagesWithSingleConfig(SmsBroadcastConfigInfo info) { int languageBeginIndex = info.getFromCodeScheme(); int languageEndIndex = info.getToCodeScheme(); if (languageBeginIndex != -1 && languageBeginIndex != -2) { for (int j = languageBeginIndex; j <= languageEndIndex; j++) { if (mCellBroadcastAsyncTask.isCancelled()) { break; } CellBroadcastLanguage language = getLanguageObjectFromKey(String.valueOf(j)); if (language != null) { language.setLanguageState(info.isSelected()); } } } else { MmsLog.d(LOG_TAG, "Select all language!"); if (languageBeginIndex == -2 && languageEndIndex == -2) { for (int i = 0; i < mLanguageList.size(); i++) { if (mCellBroadcastAsyncTask.isCancelled()) { break; } CellBroadcastLanguage language = (CellBroadcastLanguage) mLanguageList.get(i); CellBroadcastLanguage lang = getLanguageObjectFromKey(String.valueOf(language.getLanguageId())); if (lang != null) { lang.setLanguageState(true); } } } } }
private void initLanguageMap() { mLanguageMap = new HashMap<String, CellBroadcastLanguage>(); for (int i = 0; i < LANGUAGE_NUM; i++) { CellBroadcastLanguage language = mLanguageList.get(i); if (language != null) { int id = language.getLanguageId(); mLanguageMap.put(String.valueOf(id), language); } } }
// convert selection info to SmsBroadcastConfigInfo[],and send to the system private SmsBroadcastConfigInfo[] makeLanguageConfigArray() { ArrayList<SmsBroadcastConfigInfo> list = new ArrayList<SmsBroadcastConfigInfo>(); if (mLanguageList.get(0).getLanguageState()) { SmsBroadcastConfigInfo cBConfig = new SmsBroadcastConfigInfo(-1, -1, -2, -2, true); list.add(cBConfig); } else { int beginId = mLanguageList.get(1).getLanguageId(); int endId = beginId; boolean beginState = mLanguageList.get(1).getLanguageState(); int i = 2; int tSize = mLanguageList.size(); for (i = 2; i < tSize; i++) { CellBroadcastLanguage tLanguage = mLanguageList.get(i); int tempId = tLanguage.getLanguageId(); boolean tempState = tLanguage.getLanguageState(); if ((tempId == endId + 1) && (beginState == tempState)) { endId = tempId; } else { SmsBroadcastConfigInfo cBConfig = new SmsBroadcastConfigInfo(-1, -1, beginId, endId, beginState); list.add(cBConfig); beginId = tempId; endId = tempId; beginState = tempState; } } if (i == mLanguageList.size()) { endId = mLanguageList.get(i - 1).getLanguageId(); SmsBroadcastConfigInfo cBConfig = new SmsBroadcastConfigInfo(-1, -1, beginId, endId, beginState); list.add(cBConfig); } } return list.toArray(new SmsBroadcastConfigInfo[list.size()]); }