本文整理匯總了Java中android.support.v4.util.ArrayMap類的典型用法代碼示例。如果您正苦於以下問題:Java ArrayMap類的具體用法?Java ArrayMap怎麽用?Java ArrayMap使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ArrayMap類屬於android.support.v4.util包,在下文中一共展示了ArrayMap類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getDefaultStyle
import android.support.v4.util.ArrayMap; //導入依賴的package包/類
@Override
protected Map<String, String> getDefaultStyle() {
Map<String,String> map = new ArrayMap<>();
boolean isVertical = true;
if (parent != null) {
if (parent.getType() != null) {
if (parent.getType().equals(WXBasicComponentType.HLIST)) {
isVertical = false;
}
}
}
String prop = isVertical ? Constants.Name.HEIGHT : Constants.Name.WIDTH;
if (getStyles().get(prop) == null &&
getStyles().get(Constants.Name.FLEX) == null) {
map.put(Constants.Name.FLEX, "1");
}
return map;
}
示例2: findAllFragmentsWithViews
import android.support.v4.util.ArrayMap; //導入依賴的package包/類
private void findAllFragmentsWithViews(
android.app.FragmentManager fragmentManager, ArrayMap<View, android.app.Fragment> result) {
int index = 0;
while (true) {
tempBundle.putInt(FRAGMENT_INDEX_KEY, index++);
android.app.Fragment fragment = null;
try {
fragment = fragmentManager.getFragment(tempBundle, FRAGMENT_MANAGER_GET_FRAGMENT_KEY);
} catch (Exception e) {
// This generates log spam from FragmentManager anyway.
}
if (fragment == null) {
break;
}
if (fragment.getView() != null) {
result.put(fragment.getView(), fragment);
if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN_MR1) {
findAllFragmentsWithViews(fragment.getChildFragmentManager(), result);
}
}
}
}
示例3: pauseTest
import android.support.v4.util.ArrayMap; //導入依賴的package包/類
@Test
public void pauseTest() {
Class<?> reflected = showDoc.getClass();
try {
Method method = reflected.getDeclaredMethod("resetValues");
method.setAccessible(true);
method.invoke(showDoc);
Field pauseBool = reflected.getDeclaredField("boolValues");
pauseBool.setAccessible(true);
Assert.assertFalse(((ArrayMap<String, Boolean>) pauseBool.get(showDoc)).get("isPaused"));
Field field = reflected.getDeclaredField("audioPlayer");
field.setAccessible(true);
field.set(showDoc,new MediaPlayer());
showDoc.pause();
Assert.assertTrue(((ArrayMap<String, Boolean>) pauseBool.get(showDoc)).get("isPaused"));
} catch(Exception e){
assertFalse(true);
}
}
示例4: fromSimpleDeviceModel
import android.support.v4.util.ArrayMap; //導入依賴的package包/類
private DeviceState fromSimpleDeviceModel(Models.SimpleDevice offlineDevice) {
Set<String> functions = new HashSet<>();
Map<String, VariableType> variables = new ArrayMap<>();
return new DeviceState.DeviceStateBuilder(offlineDevice.id, functions, variables)
.name(offlineDevice.name)
.cellular(offlineDevice.cellular)
.connected(offlineDevice.isConnected)
.version("")
.deviceType(ParticleDeviceType.fromInt(offlineDevice.productId))
.platformId(offlineDevice.platformId)
.productId(offlineDevice.productId)
.imei(offlineDevice.imei)
.currentBuild(offlineDevice.currentBuild)
.defaultBuild(offlineDevice.defaultBuild)
.ipAddress(offlineDevice.ipAddress)
.lastAppName("")
.status(offlineDevice.status)
.requiresUpdate(false)
.lastHeard(offlineDevice.lastHeard)
.build();
}
示例5: generateViewType
import android.support.v4.util.ArrayMap; //導入依賴的package包/類
/**
* generate viewtype by component
*
* @param component
* @return
*/
private int generateViewType(WXComponent component) {
long id;
try {
id = Integer.parseInt(component.getDomObject().getRef());
String type = component.getDomObject().getAttrs().getScope();
if (!TextUtils.isEmpty(type)) {
if (mRefToViewType == null) {
mRefToViewType = new ArrayMap<>();
}
if (!mRefToViewType.containsKey(type)) {
mRefToViewType.put(type, id);
}
id = mRefToViewType.get(type);
}
} catch (RuntimeException e) {
WXLogUtils.eTag(TAG, e);
id = RecyclerView.NO_ID;
WXLogUtils.e(TAG, "getItemViewType: NO ID, this will crash the whole render system of WXListRecyclerView");
}
return (int) id;
}
示例6: loadData
import android.support.v4.util.ArrayMap; //導入依賴的package包/類
/**
* Load voice settings from file and set radio buttons
* @throws IOException
* @throws XmlPullParserException
*/
private void loadData() throws IOException, XmlPullParserException {
ArrayMap<String, String> values = settingsManager.getSettings();
voice = values.get("id");
Voice loadedVoice = searchVoice(voice);
if(loadedVoice == null){
Toast.makeText(getContext(), "Errore caricamento impostazioni", Toast.LENGTH_SHORT).show();
return;
}
// Language/Locale
language = loadedVoice.get("locale");
spnLanguage.setSelection(((ArrayAdapter) spnLanguage.getAdapter()).getPosition(language));
// Gender
gender = loadedVoice.get("gender");
if(gender.equals("male"))
rbM.setChecked(true);
else
rbF.setChecked(true);
updateChoice();
// Voice
int pos=((ArrayAdapter) spnVoice.getAdapter()).getPosition(voice);
spnVoice.setSelection(pos);
// Speed
speed = Float.valueOf(values.get("speed"));
spnSpeed.setSelection(Math.round((speed - 1) / 0.25f));
}
示例7: bindConnect
import android.support.v4.util.ArrayMap; //導入依賴的package包/類
private void bindConnect() {
refreshListAndNotifyData(presenter.getLastMessages(dbMessageCount));
Bundle bundle = new Bundle();
Map<String, String> map = new ArrayMap<>();
map.put("appid", SPUtils.getAppid());
map.put("platform", "Android");
map.put("token", SPUtils.getUserToken());
map.put("version", "2.2");
map.put("uuid", Utils.getUUID(mActivity));
bundle.putString("query", com.kf5.sdk.im.utils.Utils.getMapAppend(map));
bundle.putString("url", SPUtils.getChatUrl());
presenter.initParams(bundle);
presenter.connect();
}
示例8: getUniqueMap
import android.support.v4.util.ArrayMap; //導入依賴的package包/類
/**
* Construct a new map, that contains a unique String key for each value.
* <p>
* Current algorithm will construct unique key by appending a unique position number to
* key's toString() value
*
* @return a {@link Map}
*/
public ArrayMap<String, V> getUniqueMap() {
ArrayMap<String, V> uniqueMap = new ArrayMap<>();
for (Map.Entry<K, List<V>> entry : mInternalMap.entrySet()) {
int count = 1;
for (V value : entry.getValue()) {
if (count == 1) {
addUniqueEntry(uniqueMap, entry.getKey().toString(), value);
} else {
// append unique number to key for each value
addUniqueEntry(uniqueMap, String.format("%s%d", entry.getKey(), count), value);
}
count++;
}
}
return uniqueMap;
}
示例9: RecyclerViewGroupAdapter
import android.support.v4.util.ArrayMap; //導入依賴的package包/類
public RecyclerViewGroupAdapter(Context context, List<T> dataList
, @LayoutRes int[] typeLayoutIds, Integer groupType, RecyclerViewGroupTypeProcessor<T> groupTypeProcessor) {
mContext = context;
if (groupType != null && groupType >= 0) mGroupViewType = groupType;
mDataList = dataList;
if (typeLayoutIds != null && typeLayoutIds.length != 0) {
mTypeLayoutIds = new ArrayMap<>();
int typeSize = typeLayoutIds.length;
for (int i = 0; i < typeSize; i++) {
mTypeLayoutIds.put(i, typeLayoutIds[i]);
}
}
mGroupTypeProcessor = groupTypeProcessor;
initGroup();
}
示例10: initGroup
import android.support.v4.util.ArrayMap; //導入依賴的package包/類
/**
* init group info for group count, position map and count map
*/
private void initGroup() {
mGroupPositionMap = new ArrayMap<>();
mGroupItemCountMap = new ArrayMap<>();
mGroupCount = 0;
int lastGroupPosition = 0;
if (mDataList != null && !mDataList.isEmpty()) {
int dataSize = mDataList.size();
for (int i = 0; i < dataSize; i++) {
if (getItemViewType(i) == mGroupViewType) {
mGroupPositionMap.put(mGroupCount, i);
lastGroupPosition = i;
if (mGroupCount != 0) {
mGroupItemCountMap.put(mGroupCount - 1, i - mGroupPositionMap.get(mGroupCount - 1));
}
mGroupCount++;
}
}
mGroupItemCountMap.put(mGroupCount - 1, dataSize - lastGroupPosition);
}
}
示例11: findChildGroupPosition
import android.support.v4.util.ArrayMap; //導入依賴的package包/類
/**
* find out the child position of its group
*
* @param position adapter item position
* @return
*/
private int findChildGroupPosition(int position) {
if (mChildGroupPositionCacheMap == null)
mChildGroupPositionCacheMap = new ArrayMap<>();
if (mDataList == null || mDataList.isEmpty()) return -1;
int tempPosition = mDataList.size();
int groupPosition = 0;
if (mChildGroupPositionCacheMap.containsKey(position))
return mChildGroupPositionCacheMap.get(position);
for (int i = mGroupCount; i > 0; i--) {
if (tempPosition <= position) {
groupPosition = i;
mChildGroupPositionCacheMap.put(position, groupPosition);
break;
}
tempPosition -= mGroupItemCountMap.get(i - 1);
}
return groupPosition;
}
示例12: findChildPosition
import android.support.v4.util.ArrayMap; //導入依賴的package包/類
/**
* find out the child position of its group
*
* @param groupPosition the group position of the group list
* @param position adapter item position
* @return
*/
private int findChildPosition(int groupPosition, int position) {
if (mChildItemPositionCacheMap == null)
mChildItemPositionCacheMap = new ArrayMap<>();
if (mDataList == null || mDataList.isEmpty()) return -1;
int positionInGroup = 0;
if (mChildItemPositionCacheMap.containsKey(position))
return mChildItemPositionCacheMap.get(position);
int groupItemCount = mGroupItemCountMap.get(groupPosition);
int groupRealPosition = mGroupPositionMap.get(groupPosition);
positionInGroup = (position - groupRealPosition) % groupItemCount - 1;
mChildItemPositionCacheMap.put(position, positionInGroup);
return positionInGroup;
}
示例13: readThemeSetting
import android.support.v4.util.ArrayMap; //導入依賴的package包/類
/***
* Public method that read information about theme settings from XML file
* @param parser the current parser used to parse the XML file
* @return ThemeSetting contains loaded settings
* @throws XmlPullParserException
* @throws IOException
*/
private ThemeSetting readThemeSetting(XmlPullParser parser) throws XmlPullParserException, IOException {
parser.require(XmlPullParser.START_TAG, null, "themesetting");
ArrayMap<String, String> newValues = new ArrayMap<>();
while (parser.next() != XmlPullParser.END_TAG) {
if (parser.getEventType() != XmlPullParser.START_TAG) {
continue;
}
String name = parser.getName();
if (name.equals("font")) {
newValues.put("font", readText(parser));
} else if (name.equals("palette")) {
newValues.put("palette", readText(parser));
} else if (name.equals("highlight")) {
newValues.put("highlight", readText(parser));
}
}
ThemeSetting themesetting = new ThemeSetting();
themesetting.changeSetting(newValues);
return themesetting;
}
示例14: performLogin
import android.support.v4.util.ArrayMap; //導入依賴的package包/類
private void performLogin() {
if (!TextUtils.isEmpty(mNameView.getText().toString())
&& !TextUtils.isEmpty(mPasswordView.getText().toString())
&& !TextUtils.isEmpty(mUrlView.getText().toString())) {
final String userName = mNameView.getText().toString().trim();
final String userPassword = mPasswordView.getText().toString();
final Map<String, Object> params = new ArrayMap<String, Object>();
params.put(Constants.PREFS_USER, userName);
params.put(Constants.PREFS_PASSWORD, userPassword);
showDialog();
Communicator.getInstance().login(params,
collectUrl(mUrlView.getText().toString()), this);
} else {
DialogHelper.showAlertDialog(LoginActivity.this, getString(R.string.fill_fields));
}
}
示例15: getIds
import android.support.v4.util.ArrayMap; //導入依賴的package包/類
public ArrayMap<Integer, long[]> getIds() {
ArrayMap<Integer, long[]> arrayMap = new ArrayMap<>();
if (choiceMode == ListView.CHOICE_MODE_MULTIPLE) {
for (Map.Entry<Integer, SparseBooleanArray> entry : multipleIds.entrySet()) {
List<Integer> l = new ArrayList<>();
SparseBooleanArray ids = entry.getValue();
for (int i = 0; i < ids.size(); i++) {
if (ids.valueAt(i)) {
l.add(ids.keyAt(i));
}
}
long[] _ids = new long[l.size()];
for (int i = 0; i < l.size(); i++) {
_ids[i] = l.get(i);
}
arrayMap.put(entry.getKey(), _ids);
}
}
return arrayMap;
}