Java Code Examples for android.support.v4.util.ArrayMap#put()
The following examples show how to use
android.support.v4.util.ArrayMap#put() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseExpandableAdapter.java From ExpandableRecyclerview with Apache License 2.0 | 6 votes |
/** * check has item is expanded by default */ private void checkDefaultExpand() { ArrayMap<Object, List<?>> childArrayMap = new ArrayMap<>(); Iterator<Object> iterator = mDataList.iterator(); while (iterator.hasNext()) { Object next = iterator.next(); if (next instanceof ExpandableListItem) { ExpandableListItem expandableListItem = (ExpandableListItem) next; if (expandableListItem.isExpanded()) { List<?> childItemList = expandableListItem.getChildItemList(); if (childItemList != null && !childItemList.isEmpty()) { childArrayMap.put(next, childItemList); } } } } int size = childArrayMap.size(); if (size == 0) return; for (int i = 0; i < size; i++) { Object o = childArrayMap.keyAt(i); List<?> objects = childArrayMap.valueAt(i); int indexOf = mDataList.indexOf(o); mDataList.addAll(indexOf + 1, objects); } }
Example 2
Source File: BackStackRecord.java From adt-leanback-support with Apache License 2.0 | 6 votes |
/** * Remaps a name-to-View map, substituting different names for keys. * * @param inMap A list of keys found in the map, in the order in toGoInMap * @param toGoInMap A list of keys to use for the new map, in the order of inMap * @param namedViews The current mapping * @return A copy of namedViews with the keys coming from toGoInMap. */ private static ArrayMap<String, View> remapNames(ArrayList<String> inMap, ArrayList<String> toGoInMap, ArrayMap<String, View> namedViews) { if (namedViews.isEmpty()) { return namedViews; } ArrayMap<String, View> remappedViews = new ArrayMap<String, View>(); int numKeys = inMap.size(); for (int i = 0; i < numKeys; i++) { View view = namedViews.get(inMap.get(i)); if (view != null) { remappedViews.put(toGoInMap.get(i), view); } } return remappedViews; }
Example 3
Source File: FullSharedElementAnimationScene.java From scene with Apache License 2.0 | 6 votes |
@Override public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); ArrayMap<String, SceneTransition> map = new ArrayMap<>(); SceneTransitionSet a = new SceneTransitionSet(); a.addSceneTransition(new ChangeTransform()); a.addSceneTransition(new ChangeBounds()); map.put("haha", a); map.put("imageView", new AutoSceneTransition().addSceneTransition(new ChangeImageTransform())); map.put("haha_parent", new AutoSceneTransition().addSceneTransition(new BackgroundRecolor())); map.put("shared_element_text_no_size_change", new AutoSceneTransition().addSceneTransition(new BackgroundRecolor()).addSceneTransition(new TextRecolor())); // map.put("shared_element_text_no_size_change", new AutoSceneTransition()); final SharedElementSceneTransitionExecutor sharedElementSceneTransitionExecutor = new SharedElementSceneTransitionExecutor(map, new Slide()); findViewById(R.id.haha).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { getNavigationScene().push(new FullSharedElementAnimationScene1(), new PushOptions.Builder().setAnimation(sharedElementSceneTransitionExecutor).build()); } }); }
Example 4
Source File: BackStackRecord.java From letv with Apache License 2.0 | 5 votes |
private static void setNameOverride(ArrayMap<String, String> overrides, String source, String target) { if (source != null && target != null) { for (int index = 0; index < overrides.size(); index++) { if (source.equals(overrides.valueAt(index))) { overrides.setValueAt(index, target); return; } } overrides.put(source, target); } }
Example 5
Source File: BluetoothChatFragment.java From AndroidDemo with MIT License | 5 votes |
/** * 接收对方消息 * * @param message */ public void pushMessage(String message) { if (TextUtils.isEmpty(message)) return; ArrayMap<String, Object> am = new ArrayMap<>(); am.put("type", 0); am.put("text", message); chatData.add(am); chatAdapter.notifyDataSetChanged(); }
Example 6
Source File: MediaDatabase.java From VCL-Android with Apache License 2.0 | 5 votes |
public synchronized ArrayMap<String, Long> getVideoTimes() { Cursor cursor; ArrayMap<String, Long> times = new ArrayMap<String, Long>(); int chunk_count = 0; int count; do { count = 0; cursor = mDb.rawQuery(String.format(Locale.US, "SELECT %s,%s FROM %s WHERE %s=%d LIMIT %d OFFSET %d", MEDIA_LOCATION, //0 string MEDIA_TIME, //1 long MEDIA_TABLE_NAME, MEDIA_TYPE, MediaWrapper.TYPE_VIDEO, CHUNK_SIZE, chunk_count * CHUNK_SIZE), null); if (cursor != null) { if (cursor.moveToFirst()) { do { String location = cursor.getString(0); long time = cursor.getLong(1); times.put(location, time); count++; } while (cursor.moveToNext()); } cursor.close(); } chunk_count++; } while (count == CHUNK_SIZE); return times; }
Example 7
Source File: VectorDrawable.java From ElasticProgressBar with Apache License 2.0 | 5 votes |
public VGroup(VGroup copy, ArrayMap<String, Object> targetsMap) { mRotate = copy.mRotate; mPivotX = copy.mPivotX; mPivotY = copy.mPivotY; mScaleX = copy.mScaleX; mScaleY = copy.mScaleY; mTranslateX = copy.mTranslateX; mTranslateY = copy.mTranslateY; mThemeAttrs = copy.mThemeAttrs; mGroupName = copy.mGroupName; mChangingConfigurations = copy.mChangingConfigurations; if (mGroupName != null) { targetsMap.put(mGroupName, this); } mLocalMatrix.set(copy.mLocalMatrix); final ArrayList<Object> children = copy.mChildren; for (int i = 0; i < children.size(); i++) { Object copyChild = children.get(i); if (copyChild instanceof VGroup) { VGroup copyGroup = (VGroup) copyChild; mChildren.add(new VGroup(copyGroup, targetsMap)); } else { VPath newPath = null; if (copyChild instanceof VFullPath) { newPath = new VFullPath((VFullPath) copyChild); } else if (copyChild instanceof VClipPath) { newPath = new VClipPath((VClipPath) copyChild); } else { throw new IllegalStateException("Unknown object in the tree!"); } mChildren.add(newPath); if (newPath.mPathName != null) { targetsMap.put(newPath.mPathName, newPath); } } } }
Example 8
Source File: VectorDrawable.java From CanDialog with Apache License 2.0 | 5 votes |
public VGroup(VGroup copy, ArrayMap<String, Object> targetsMap) { mRotate = copy.mRotate; mPivotX = copy.mPivotX; mPivotY = copy.mPivotY; mScaleX = copy.mScaleX; mScaleY = copy.mScaleY; mTranslateX = copy.mTranslateX; mTranslateY = copy.mTranslateY; mThemeAttrs = copy.mThemeAttrs; mGroupName = copy.mGroupName; mChangingConfigurations = copy.mChangingConfigurations; if (mGroupName != null) { targetsMap.put(mGroupName, this); } mLocalMatrix.set(copy.mLocalMatrix); final ArrayList<Object> children = copy.mChildren; for (int i = 0; i < children.size(); i++) { Object copyChild = children.get(i); if (copyChild instanceof VGroup) { VGroup copyGroup = (VGroup) copyChild; mChildren.add(new VGroup(copyGroup, targetsMap)); } else { VPath newPath = null; if (copyChild instanceof VFullPath) { newPath = new VFullPath((VFullPath) copyChild); } else if (copyChild instanceof VClipPath) { newPath = new VClipPath((VClipPath) copyChild); } else { throw new IllegalStateException("Unknown object in the tree!"); } mChildren.add(newPath); if (newPath.mPathName != null) { targetsMap.put(newPath.mPathName, newPath); } } } }
Example 9
Source File: VectorDrawable.java From MrVector with MIT License | 5 votes |
public VGroup(VGroup copy, ArrayMap<String, Object> targetsMap) { mRotate = copy.mRotate; mPivotX = copy.mPivotX; mPivotY = copy.mPivotY; mScaleX = copy.mScaleX; mScaleY = copy.mScaleY; mTranslateX = copy.mTranslateX; mTranslateY = copy.mTranslateY; mThemeAttrs = copy.mThemeAttrs; mGroupName = copy.mGroupName; mChangingConfigurations = copy.mChangingConfigurations; if (mGroupName != null) { targetsMap.put(mGroupName, this); } mLocalMatrix.set(copy.mLocalMatrix); final ArrayList<Object> children = copy.mChildren; for (int i = 0; i < children.size(); i++) { Object copyChild = children.get(i); if (copyChild instanceof VGroup) { VGroup copyGroup = (VGroup) copyChild; mChildren.add(new VGroup(copyGroup, targetsMap)); } else { VPath newPath = null; if (copyChild instanceof VFullPath) { newPath = new VFullPath((VFullPath) copyChild); } else if (copyChild instanceof VClipPath) { newPath = new VClipPath((VClipPath) copyChild); } else { throw new IllegalStateException("Unknown object in the tree!"); } mChildren.add(newPath); if (newPath.mPathName != null) { targetsMap.put(newPath.mPathName, newPath); } } } }
Example 10
Source File: SocialMentionTextView.java From SocialMentionAutoComplete with Apache License 2.0 | 5 votes |
public void setMentionText(String text) { originalString = text; ArrayMap<String, MentionPerson> map = new ArrayMap<>(); Pattern p = Pattern.compile("\\[([^]]+)]\\(([^ )]+)\\)"); Matcher m = p.matcher(text); String finalDesc = text; while (m.find()) { String name = m.group(1); String id = m.group(2); /* * My way of formatting the input i get to the out i need conversion * my input : @[Sajesh Cc](user:665c23720db84014ae3f83c67aca8046) * my out : @Sajesh Cc * */ finalDesc = finalDesc.replace("@[" + name + "](" + id + ")", "@" + name); MentionPerson mentionPerson = new MentionPerson(); mentionPerson.name = name; mentionPerson.id = id; map.put("@" + name, mentionPerson); } Spannable spannable = new SpannableString(finalDesc); for (Map.Entry<String, MentionPerson> stringMentionPersonEntry : map.entrySet()) { int startIndex = finalDesc.indexOf(stringMentionPersonEntry.getKey()); int endIndex = startIndex + stringMentionPersonEntry.getKey().length(); InternalURLSpan internalURLSpan = new InternalURLSpan(); internalURLSpan.text = stringMentionPersonEntry.getKey(); spannable.setSpan(internalURLSpan, startIndex, endIndex, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } setText(spannable); }
Example 11
Source File: PluginManager.java From Phantom with Apache License 2.0 | 5 votes |
private void initHostCompileDependencies() { final AssetManager assetManager = mContext.getAssets(); InputStream inputStream = null; try { inputStream = assetManager.open(COMPILE_DEPENDENCIES_FILE, AssetManager.ACCESS_BUFFER); final List<String> lines = IoUtils.readLines(inputStream, IoUtils.DEFAULT_CHARSET); ArrayMap<String, String> librariesMap = new ArrayMap<>(); // lib -> version for (String line : lines) { final String[] parts = line.split(":"); if (parts.length == 3) { final String lib = parts[0] + ":" + parts[1]; // groupId:artifactId final String newVersion = parts[2]; final String oldVersion = librariesMap.get(lib); if (oldVersion != null && new Version(newVersion).lessThan(new Version(oldVersion))) { // skip lower version continue; } librariesMap.put(lib, newVersion); } } mHostCompileDependencyMap = librariesMap; ArraySet<String> librariesSet = new ArraySet<>(); for (Map.Entry entry : librariesMap.entrySet()) { librariesSet.add(entry.getKey() + ":" + entry.getValue()); } mHostCompileDependencySet = librariesSet; } catch (IOException e) { VLog.w(e, "error initHostCompileDependencies"); mHostCompileDependencyMap = Collections.emptyMap(); mHostCompileDependencySet = Collections.emptySet(); } finally { IoUtils.closeQuietly(inputStream); } }
Example 12
Source File: VectorDrawableCompat.java From VectorChildFinder with Apache License 2.0 | 5 votes |
public VGroup(VGroup copy, ArrayMap<String, Object> targetsMap) { mRotate = copy.mRotate; mPivotX = copy.mPivotX; mPivotY = copy.mPivotY; mScaleX = copy.mScaleX; mScaleY = copy.mScaleY; mTranslateX = copy.mTranslateX; mTranslateY = copy.mTranslateY; mThemeAttrs = copy.mThemeAttrs; mGroupName = copy.mGroupName; mChangingConfigurations = copy.mChangingConfigurations; if (mGroupName != null) { targetsMap.put(mGroupName, this); } mLocalMatrix.set(copy.mLocalMatrix); final ArrayList<Object> children = copy.mChildren; for (int i = 0; i < children.size(); i++) { Object copyChild = children.get(i); if (copyChild instanceof VGroup) { VGroup copyGroup = (VGroup) copyChild; mChildren.add(new VGroup(copyGroup, targetsMap)); } else { VPath newPath = null; if (copyChild instanceof VFullPath) { newPath = new VFullPath((VFullPath) copyChild); } else if (copyChild instanceof VClipPath) { newPath = new VClipPath((VClipPath) copyChild); } else { throw new IllegalStateException("Unknown object in the tree!"); } mChildren.add(newPath); if (newPath.mPathName != null) { targetsMap.put(newPath.mPathName, newPath); } } } }
Example 13
Source File: AutofillDao_Impl.java From android-AutofillFramework with Apache License 2.0 | 4 votes |
@Override public List<DatasetWithFilledAutofillFields> getDatasetsWithName(List<String> fieldTypes, String datasetName) { StringBuilder _stringBuilder = StringUtil.newStringBuilder(); _stringBuilder.append("SELECT DISTINCT id, datasetName FROM FilledAutofillField, AutofillDataset WHERE AutofillDataset.id = FilledAutofillField.datasetId AND AutofillDataset.datasetName = ("); _stringBuilder.append("?"); _stringBuilder.append(") AND FilledAutofillField.fieldTypeName IN ("); final int _inputSize = fieldTypes.size(); StringUtil.appendPlaceholders(_stringBuilder, _inputSize); _stringBuilder.append(")"); final String _sql = _stringBuilder.toString(); final int _argCount = 1 + _inputSize; final RoomSQLiteQuery _statement = RoomSQLiteQuery.acquire(_sql, _argCount); int _argIndex = 1; if (datasetName == null) { _statement.bindNull(_argIndex); } else { _statement.bindString(_argIndex, datasetName); } _argIndex = 2; for (String _item : fieldTypes) { if (_item == null) { _statement.bindNull(_argIndex); } else { _statement.bindString(_argIndex, _item); } _argIndex ++; } final Cursor _cursor = __db.query(_statement); try { final ArrayMap<String, ArrayList<FilledAutofillField>> _collectionFilledAutofillFields = new ArrayMap<String, ArrayList<FilledAutofillField>>(); final int _cursorIndexOfMId = _cursor.getColumnIndexOrThrow("id"); final int _cursorIndexOfMDatasetName = _cursor.getColumnIndexOrThrow("datasetName"); final List<DatasetWithFilledAutofillFields> _result = new ArrayList<DatasetWithFilledAutofillFields>(_cursor.getCount()); while(_cursor.moveToNext()) { final DatasetWithFilledAutofillFields _item_1; final AutofillDataset _tmpAutofillDataset; if (! (_cursor.isNull(_cursorIndexOfMId) && _cursor.isNull(_cursorIndexOfMDatasetName))) { final String _tmpMId; _tmpMId = _cursor.getString(_cursorIndexOfMId); final String _tmpMDatasetName; _tmpMDatasetName = _cursor.getString(_cursorIndexOfMDatasetName); _tmpAutofillDataset = new AutofillDataset(_tmpMId,_tmpMDatasetName,null); } else { _tmpAutofillDataset = null; } _item_1 = new DatasetWithFilledAutofillFields(); if (!_cursor.isNull(_cursorIndexOfMId)) { final String _tmpKey = _cursor.getString(_cursorIndexOfMId); ArrayList<FilledAutofillField> _tmpCollection = _collectionFilledAutofillFields.get(_tmpKey); if(_tmpCollection == null) { _tmpCollection = new ArrayList<FilledAutofillField>(); _collectionFilledAutofillFields.put(_tmpKey, _tmpCollection); } _item_1.filledAutofillFields = _tmpCollection; } _item_1.autofillDataset = _tmpAutofillDataset; _result.add(_item_1); } __fetchRelationshipFilledAutofillFieldAscomExampleAndroidAutofillServiceModelFilledAutofillField(_collectionFilledAutofillFields); return _result; } finally { _cursor.close(); _statement.release(); } }
Example 14
Source File: AutofillDao_Impl.java From android-AutofillFramework with Apache License 2.0 | 4 votes |
@Override public List<FieldTypeWithHeuristics> getFieldTypesForAutofillHints(List<String> autofillHints) { StringBuilder _stringBuilder = StringUtil.newStringBuilder(); _stringBuilder.append("SELECT DISTINCT typeName, autofillTypes, saveInfo, partition, strictExampleSet, textTemplate, dateTemplate FROM FieldType, AutofillHint WHERE FieldType.typeName = AutofillHint.fieldTypeName AND AutofillHint.autofillHint IN ("); final int _inputSize = autofillHints.size(); StringUtil.appendPlaceholders(_stringBuilder, _inputSize); _stringBuilder.append(") UNION SELECT DISTINCT typeName, autofillTypes, saveInfo, partition, strictExampleSet, textTemplate, dateTemplate FROM FieldType, ResourceIdHeuristic WHERE FieldType.typeName = ResourceIdHeuristic.fieldTypeName"); final String _sql = _stringBuilder.toString(); final int _argCount = 0 + _inputSize; final RoomSQLiteQuery _statement = RoomSQLiteQuery.acquire(_sql, _argCount); int _argIndex = 1; for (String _item : autofillHints) { if (_item == null) { _statement.bindNull(_argIndex); } else { _statement.bindString(_argIndex, _item); } _argIndex ++; } final Cursor _cursor = __db.query(_statement); try { final ArrayMap<String, ArrayList<AutofillHint>> _collectionAutofillHints = new ArrayMap<String, ArrayList<AutofillHint>>(); final ArrayMap<String, ArrayList<ResourceIdHeuristic>> _collectionResourceIdHeuristics = new ArrayMap<String, ArrayList<ResourceIdHeuristic>>(); final int _cursorIndexOfMTypeName = _cursor.getColumnIndexOrThrow("typeName"); final int _cursorIndexOfMAutofillTypes = _cursor.getColumnIndexOrThrow("autofillTypes"); final int _cursorIndexOfMSaveInfo = _cursor.getColumnIndexOrThrow("saveInfo"); final int _cursorIndexOfMPartition = _cursor.getColumnIndexOrThrow("partition"); final int _cursorIndexOfStrictExampleSet = _cursor.getColumnIndexOrThrow("strictExampleSet"); final int _cursorIndexOfTextTemplate = _cursor.getColumnIndexOrThrow("textTemplate"); final int _cursorIndexOfDateTemplate = _cursor.getColumnIndexOrThrow("dateTemplate"); final List<FieldTypeWithHeuristics> _result = new ArrayList<FieldTypeWithHeuristics>(_cursor.getCount()); while(_cursor.moveToNext()) { final FieldTypeWithHeuristics _item_1; final FieldType _tmpFieldType; if (! (_cursor.isNull(_cursorIndexOfMTypeName) && _cursor.isNull(_cursorIndexOfMAutofillTypes) && _cursor.isNull(_cursorIndexOfMSaveInfo) && _cursor.isNull(_cursorIndexOfMPartition) && _cursor.isNull(_cursorIndexOfStrictExampleSet) && _cursor.isNull(_cursorIndexOfTextTemplate) && _cursor.isNull(_cursorIndexOfDateTemplate))) { final String _tmpMTypeName; _tmpMTypeName = _cursor.getString(_cursorIndexOfMTypeName); final Converters.IntList _tmpMAutofillTypes; final String _tmp; _tmp = _cursor.getString(_cursorIndexOfMAutofillTypes); _tmpMAutofillTypes = Converters.storedStringToIntList(_tmp); final Integer _tmpMSaveInfo; if (_cursor.isNull(_cursorIndexOfMSaveInfo)) { _tmpMSaveInfo = null; } else { _tmpMSaveInfo = _cursor.getInt(_cursorIndexOfMSaveInfo); } final Integer _tmpMPartition; if (_cursor.isNull(_cursorIndexOfMPartition)) { _tmpMPartition = null; } else { _tmpMPartition = _cursor.getInt(_cursorIndexOfMPartition); } final FakeData _tmpMFakeData; final Converters.StringList _tmpStrictExampleSet; final String _tmp_1; _tmp_1 = _cursor.getString(_cursorIndexOfStrictExampleSet); _tmpStrictExampleSet = Converters.storedStringToStringList(_tmp_1); final String _tmpTextTemplate; _tmpTextTemplate = _cursor.getString(_cursorIndexOfTextTemplate); final String _tmpDateTemplate; _tmpDateTemplate = _cursor.getString(_cursorIndexOfDateTemplate); _tmpMFakeData = new FakeData(_tmpStrictExampleSet,_tmpTextTemplate,_tmpDateTemplate); _tmpFieldType = new FieldType(_tmpMTypeName,_tmpMAutofillTypes,_tmpMSaveInfo,_tmpMPartition,_tmpMFakeData); } else { _tmpFieldType = null; } _item_1 = new FieldTypeWithHeuristics(); if (!_cursor.isNull(_cursorIndexOfMTypeName)) { final String _tmpKey = _cursor.getString(_cursorIndexOfMTypeName); ArrayList<AutofillHint> _tmpCollection = _collectionAutofillHints.get(_tmpKey); if(_tmpCollection == null) { _tmpCollection = new ArrayList<AutofillHint>(); _collectionAutofillHints.put(_tmpKey, _tmpCollection); } _item_1.autofillHints = _tmpCollection; } if (!_cursor.isNull(_cursorIndexOfMTypeName)) { final String _tmpKey_1 = _cursor.getString(_cursorIndexOfMTypeName); ArrayList<ResourceIdHeuristic> _tmpCollection_1 = _collectionResourceIdHeuristics.get(_tmpKey_1); if(_tmpCollection_1 == null) { _tmpCollection_1 = new ArrayList<ResourceIdHeuristic>(); _collectionResourceIdHeuristics.put(_tmpKey_1, _tmpCollection_1); } _item_1.resourceIdHeuristics = _tmpCollection_1; } _item_1.fieldType = _tmpFieldType; _result.add(_item_1); } __fetchRelationshipAutofillHintAscomExampleAndroidAutofillServiceModelAutofillHint(_collectionAutofillHints); __fetchRelationshipResourceIdHeuristicAscomExampleAndroidAutofillServiceModelResourceIdHeuristic(_collectionResourceIdHeuristics); return _result; } finally { _cursor.close(); _statement.release(); } }
Example 15
Source File: AutofillDao_Impl.java From android-AutofillFramework with Apache License 2.0 | 4 votes |
@Override public List<DatasetWithFilledAutofillFields> getAllDatasets() { final String _sql = "SELECT DISTINCT id, datasetName FROM FilledAutofillField, AutofillDataset WHERE AutofillDataset.id = FilledAutofillField.datasetId"; final RoomSQLiteQuery _statement = RoomSQLiteQuery.acquire(_sql, 0); final Cursor _cursor = __db.query(_statement); try { final ArrayMap<String, ArrayList<FilledAutofillField>> _collectionFilledAutofillFields = new ArrayMap<String, ArrayList<FilledAutofillField>>(); final int _cursorIndexOfMId = _cursor.getColumnIndexOrThrow("id"); final int _cursorIndexOfMDatasetName = _cursor.getColumnIndexOrThrow("datasetName"); final List<DatasetWithFilledAutofillFields> _result = new ArrayList<DatasetWithFilledAutofillFields>(_cursor.getCount()); while(_cursor.moveToNext()) { final DatasetWithFilledAutofillFields _item; final AutofillDataset _tmpAutofillDataset; if (! (_cursor.isNull(_cursorIndexOfMId) && _cursor.isNull(_cursorIndexOfMDatasetName))) { final String _tmpMId; _tmpMId = _cursor.getString(_cursorIndexOfMId); final String _tmpMDatasetName; _tmpMDatasetName = _cursor.getString(_cursorIndexOfMDatasetName); _tmpAutofillDataset = new AutofillDataset(_tmpMId,_tmpMDatasetName,null); } else { _tmpAutofillDataset = null; } _item = new DatasetWithFilledAutofillFields(); if (!_cursor.isNull(_cursorIndexOfMId)) { final String _tmpKey = _cursor.getString(_cursorIndexOfMId); ArrayList<FilledAutofillField> _tmpCollection = _collectionFilledAutofillFields.get(_tmpKey); if(_tmpCollection == null) { _tmpCollection = new ArrayList<FilledAutofillField>(); _collectionFilledAutofillFields.put(_tmpKey, _tmpCollection); } _item.filledAutofillFields = _tmpCollection; } _item.autofillDataset = _tmpAutofillDataset; _result.add(_item); } __fetchRelationshipFilledAutofillFieldAscomExampleAndroidAutofillServiceModelFilledAutofillField(_collectionFilledAutofillFields); return _result; } finally { _cursor.close(); _statement.release(); } }
Example 16
Source File: AutofillDao_Impl.java From android-AutofillFramework with Apache License 2.0 | 4 votes |
@Override public List<DatasetWithFilledAutofillFields> getAllDatasets() { final String _sql = "SELECT DISTINCT id, datasetName FROM FilledAutofillField, AutofillDataset WHERE AutofillDataset.id = FilledAutofillField.datasetId"; final RoomSQLiteQuery _statement = RoomSQLiteQuery.acquire(_sql, 0); final Cursor _cursor = __db.query(_statement); try { final ArrayMap<String, ArrayList<FilledAutofillField>> _collectionFilledAutofillFields = new ArrayMap<String, ArrayList<FilledAutofillField>>(); final int _cursorIndexOfMId = _cursor.getColumnIndexOrThrow("id"); final int _cursorIndexOfMDatasetName = _cursor.getColumnIndexOrThrow("datasetName"); final List<DatasetWithFilledAutofillFields> _result = new ArrayList<DatasetWithFilledAutofillFields>(_cursor.getCount()); while(_cursor.moveToNext()) { final DatasetWithFilledAutofillFields _item; final AutofillDataset _tmpAutofillDataset; if (! (_cursor.isNull(_cursorIndexOfMId) && _cursor.isNull(_cursorIndexOfMDatasetName))) { final String _tmpMId; _tmpMId = _cursor.getString(_cursorIndexOfMId); final String _tmpMDatasetName; _tmpMDatasetName = _cursor.getString(_cursorIndexOfMDatasetName); _tmpAutofillDataset = new AutofillDataset(_tmpMId,_tmpMDatasetName,null); } else { _tmpAutofillDataset = null; } _item = new DatasetWithFilledAutofillFields(); if (!_cursor.isNull(_cursorIndexOfMId)) { final String _tmpKey = _cursor.getString(_cursorIndexOfMId); ArrayList<FilledAutofillField> _tmpCollection = _collectionFilledAutofillFields.get(_tmpKey); if(_tmpCollection == null) { _tmpCollection = new ArrayList<FilledAutofillField>(); _collectionFilledAutofillFields.put(_tmpKey, _tmpCollection); } _item.filledAutofillFields = _tmpCollection; } _item.autofillDataset = _tmpAutofillDataset; _result.add(_item); } __fetchRelationshipFilledAutofillFieldAscomExampleAndroidAutofillServiceModelFilledAutofillField(_collectionFilledAutofillFields); return _result; } finally { _cursor.close(); _statement.release(); } }
Example 17
Source File: AutofillDao_Impl.java From android-AutofillFramework with Apache License 2.0 | 4 votes |
@Override public List<FieldTypeWithHeuristics> getFieldTypesWithHints() { final String _sql = "SELECT DISTINCT typeName, autofillTypes, saveInfo, partition, strictExampleSet, textTemplate, dateTemplate FROM FieldType, AutofillHint WHERE FieldType.typeName = AutofillHint.fieldTypeName UNION SELECT DISTINCT typeName, autofillTypes, saveInfo, partition, strictExampleSet, textTemplate, dateTemplate FROM FieldType, ResourceIdHeuristic WHERE FieldType.typeName = ResourceIdHeuristic.fieldTypeName"; final RoomSQLiteQuery _statement = RoomSQLiteQuery.acquire(_sql, 0); final Cursor _cursor = __db.query(_statement); try { final ArrayMap<String, ArrayList<AutofillHint>> _collectionAutofillHints = new ArrayMap<String, ArrayList<AutofillHint>>(); final ArrayMap<String, ArrayList<ResourceIdHeuristic>> _collectionResourceIdHeuristics = new ArrayMap<String, ArrayList<ResourceIdHeuristic>>(); final int _cursorIndexOfMTypeName = _cursor.getColumnIndexOrThrow("typeName"); final int _cursorIndexOfMAutofillTypes = _cursor.getColumnIndexOrThrow("autofillTypes"); final int _cursorIndexOfMSaveInfo = _cursor.getColumnIndexOrThrow("saveInfo"); final int _cursorIndexOfMPartition = _cursor.getColumnIndexOrThrow("partition"); final int _cursorIndexOfStrictExampleSet = _cursor.getColumnIndexOrThrow("strictExampleSet"); final int _cursorIndexOfTextTemplate = _cursor.getColumnIndexOrThrow("textTemplate"); final int _cursorIndexOfDateTemplate = _cursor.getColumnIndexOrThrow("dateTemplate"); final List<FieldTypeWithHeuristics> _result = new ArrayList<FieldTypeWithHeuristics>(_cursor.getCount()); while(_cursor.moveToNext()) { final FieldTypeWithHeuristics _item; final FieldType _tmpFieldType; if (! (_cursor.isNull(_cursorIndexOfMTypeName) && _cursor.isNull(_cursorIndexOfMAutofillTypes) && _cursor.isNull(_cursorIndexOfMSaveInfo) && _cursor.isNull(_cursorIndexOfMPartition) && _cursor.isNull(_cursorIndexOfStrictExampleSet) && _cursor.isNull(_cursorIndexOfTextTemplate) && _cursor.isNull(_cursorIndexOfDateTemplate))) { final String _tmpMTypeName; _tmpMTypeName = _cursor.getString(_cursorIndexOfMTypeName); final Converters.IntList _tmpMAutofillTypes; final String _tmp; _tmp = _cursor.getString(_cursorIndexOfMAutofillTypes); _tmpMAutofillTypes = Converters.storedStringToIntList(_tmp); final Integer _tmpMSaveInfo; if (_cursor.isNull(_cursorIndexOfMSaveInfo)) { _tmpMSaveInfo = null; } else { _tmpMSaveInfo = _cursor.getInt(_cursorIndexOfMSaveInfo); } final Integer _tmpMPartition; if (_cursor.isNull(_cursorIndexOfMPartition)) { _tmpMPartition = null; } else { _tmpMPartition = _cursor.getInt(_cursorIndexOfMPartition); } final FakeData _tmpMFakeData; final Converters.StringList _tmpStrictExampleSet; final String _tmp_1; _tmp_1 = _cursor.getString(_cursorIndexOfStrictExampleSet); _tmpStrictExampleSet = Converters.storedStringToStringList(_tmp_1); final String _tmpTextTemplate; _tmpTextTemplate = _cursor.getString(_cursorIndexOfTextTemplate); final String _tmpDateTemplate; _tmpDateTemplate = _cursor.getString(_cursorIndexOfDateTemplate); _tmpMFakeData = new FakeData(_tmpStrictExampleSet,_tmpTextTemplate,_tmpDateTemplate); _tmpFieldType = new FieldType(_tmpMTypeName,_tmpMAutofillTypes,_tmpMSaveInfo,_tmpMPartition,_tmpMFakeData); } else { _tmpFieldType = null; } _item = new FieldTypeWithHeuristics(); if (!_cursor.isNull(_cursorIndexOfMTypeName)) { final String _tmpKey = _cursor.getString(_cursorIndexOfMTypeName); ArrayList<AutofillHint> _tmpCollection = _collectionAutofillHints.get(_tmpKey); if(_tmpCollection == null) { _tmpCollection = new ArrayList<AutofillHint>(); _collectionAutofillHints.put(_tmpKey, _tmpCollection); } _item.autofillHints = _tmpCollection; } if (!_cursor.isNull(_cursorIndexOfMTypeName)) { final String _tmpKey_1 = _cursor.getString(_cursorIndexOfMTypeName); ArrayList<ResourceIdHeuristic> _tmpCollection_1 = _collectionResourceIdHeuristics.get(_tmpKey_1); if(_tmpCollection_1 == null) { _tmpCollection_1 = new ArrayList<ResourceIdHeuristic>(); _collectionResourceIdHeuristics.put(_tmpKey_1, _tmpCollection_1); } _item.resourceIdHeuristics = _tmpCollection_1; } _item.fieldType = _tmpFieldType; _result.add(_item); } __fetchRelationshipAutofillHintAscomExampleAndroidAutofillServiceModelAutofillHint(_collectionAutofillHints); __fetchRelationshipResourceIdHeuristicAscomExampleAndroidAutofillServiceModelResourceIdHeuristic(_collectionResourceIdHeuristics); return _result; } finally { _cursor.close(); _statement.release(); } }
Example 18
Source File: AutofillDao_Impl.java From android-AutofillFramework with Apache License 2.0 | 4 votes |
@Override public List<FieldTypeWithHeuristics> getFieldTypesForAutofillHints(List<String> autofillHints) { StringBuilder _stringBuilder = StringUtil.newStringBuilder(); _stringBuilder.append("SELECT DISTINCT typeName, autofillTypes, saveInfo, partition, strictExampleSet, textTemplate, dateTemplate FROM FieldType, AutofillHint WHERE FieldType.typeName = AutofillHint.fieldTypeName AND AutofillHint.autofillHint IN ("); final int _inputSize = autofillHints.size(); StringUtil.appendPlaceholders(_stringBuilder, _inputSize); _stringBuilder.append(") UNION SELECT DISTINCT typeName, autofillTypes, saveInfo, partition, strictExampleSet, textTemplate, dateTemplate FROM FieldType, ResourceIdHeuristic WHERE FieldType.typeName = ResourceIdHeuristic.fieldTypeName"); final String _sql = _stringBuilder.toString(); final int _argCount = 0 + _inputSize; final RoomSQLiteQuery _statement = RoomSQLiteQuery.acquire(_sql, _argCount); int _argIndex = 1; for (String _item : autofillHints) { if (_item == null) { _statement.bindNull(_argIndex); } else { _statement.bindString(_argIndex, _item); } _argIndex ++; } final Cursor _cursor = __db.query(_statement); try { final ArrayMap<String, ArrayList<AutofillHint>> _collectionAutofillHints = new ArrayMap<String, ArrayList<AutofillHint>>(); final ArrayMap<String, ArrayList<ResourceIdHeuristic>> _collectionResourceIdHeuristics = new ArrayMap<String, ArrayList<ResourceIdHeuristic>>(); final int _cursorIndexOfMTypeName = _cursor.getColumnIndexOrThrow("typeName"); final int _cursorIndexOfMAutofillTypes = _cursor.getColumnIndexOrThrow("autofillTypes"); final int _cursorIndexOfMSaveInfo = _cursor.getColumnIndexOrThrow("saveInfo"); final int _cursorIndexOfMPartition = _cursor.getColumnIndexOrThrow("partition"); final int _cursorIndexOfStrictExampleSet = _cursor.getColumnIndexOrThrow("strictExampleSet"); final int _cursorIndexOfTextTemplate = _cursor.getColumnIndexOrThrow("textTemplate"); final int _cursorIndexOfDateTemplate = _cursor.getColumnIndexOrThrow("dateTemplate"); final List<FieldTypeWithHeuristics> _result = new ArrayList<FieldTypeWithHeuristics>(_cursor.getCount()); while(_cursor.moveToNext()) { final FieldTypeWithHeuristics _item_1; final FieldType _tmpFieldType; if (! (_cursor.isNull(_cursorIndexOfMTypeName) && _cursor.isNull(_cursorIndexOfMAutofillTypes) && _cursor.isNull(_cursorIndexOfMSaveInfo) && _cursor.isNull(_cursorIndexOfMPartition) && _cursor.isNull(_cursorIndexOfStrictExampleSet) && _cursor.isNull(_cursorIndexOfTextTemplate) && _cursor.isNull(_cursorIndexOfDateTemplate))) { final String _tmpMTypeName; _tmpMTypeName = _cursor.getString(_cursorIndexOfMTypeName); final Converters.IntList _tmpMAutofillTypes; final String _tmp; _tmp = _cursor.getString(_cursorIndexOfMAutofillTypes); _tmpMAutofillTypes = Converters.storedStringToIntList(_tmp); final Integer _tmpMSaveInfo; if (_cursor.isNull(_cursorIndexOfMSaveInfo)) { _tmpMSaveInfo = null; } else { _tmpMSaveInfo = _cursor.getInt(_cursorIndexOfMSaveInfo); } final Integer _tmpMPartition; if (_cursor.isNull(_cursorIndexOfMPartition)) { _tmpMPartition = null; } else { _tmpMPartition = _cursor.getInt(_cursorIndexOfMPartition); } final FakeData _tmpMFakeData; final Converters.StringList _tmpStrictExampleSet; final String _tmp_1; _tmp_1 = _cursor.getString(_cursorIndexOfStrictExampleSet); _tmpStrictExampleSet = Converters.storedStringToStringList(_tmp_1); final String _tmpTextTemplate; _tmpTextTemplate = _cursor.getString(_cursorIndexOfTextTemplate); final String _tmpDateTemplate; _tmpDateTemplate = _cursor.getString(_cursorIndexOfDateTemplate); _tmpMFakeData = new FakeData(_tmpStrictExampleSet,_tmpTextTemplate,_tmpDateTemplate); _tmpFieldType = new FieldType(_tmpMTypeName,_tmpMAutofillTypes,_tmpMSaveInfo,_tmpMPartition,_tmpMFakeData); } else { _tmpFieldType = null; } _item_1 = new FieldTypeWithHeuristics(); if (!_cursor.isNull(_cursorIndexOfMTypeName)) { final String _tmpKey = _cursor.getString(_cursorIndexOfMTypeName); ArrayList<AutofillHint> _tmpCollection = _collectionAutofillHints.get(_tmpKey); if(_tmpCollection == null) { _tmpCollection = new ArrayList<AutofillHint>(); _collectionAutofillHints.put(_tmpKey, _tmpCollection); } _item_1.autofillHints = _tmpCollection; } if (!_cursor.isNull(_cursorIndexOfMTypeName)) { final String _tmpKey_1 = _cursor.getString(_cursorIndexOfMTypeName); ArrayList<ResourceIdHeuristic> _tmpCollection_1 = _collectionResourceIdHeuristics.get(_tmpKey_1); if(_tmpCollection_1 == null) { _tmpCollection_1 = new ArrayList<ResourceIdHeuristic>(); _collectionResourceIdHeuristics.put(_tmpKey_1, _tmpCollection_1); } _item_1.resourceIdHeuristics = _tmpCollection_1; } _item_1.fieldType = _tmpFieldType; _result.add(_item_1); } __fetchRelationshipAutofillHintAscomExampleAndroidAutofillServiceModelAutofillHint(_collectionAutofillHints); __fetchRelationshipResourceIdHeuristicAscomExampleAndroidAutofillServiceModelResourceIdHeuristic(_collectionResourceIdHeuristics); return _result; } finally { _cursor.close(); _statement.release(); } }
Example 19
Source File: PictureScanner.java From PicturePicker with Apache License 2.0 | 4 votes |
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { pictureFolderList.clear(); if (data != null) { // new一个集合存储所有图片 List<PictureItem> allPictureList = new ArrayList<>(); // 图片目录路径和图片目录对象的映射 ArrayMap<String, PictureFolder> path2PictureFolderMap = new ArrayMap<>(); while (data.moveToNext()) { //得到图片的路径 String picturePath = data.getString(data.getColumnIndexOrThrow(MediaStore.Images.Media.DATA)); if (!TextUtils.isEmpty(picturePath)) { File pictureFile = new File(picturePath); if (pictureFile.exists() && pictureFile.length() != 0) { PictureItem pictureItem = new PictureItem(); pictureItem.pictureAbsPath = picturePath; pictureItem.pictureAddTime = data.getLong(data.getColumnIndexOrThrow(MediaStore.Images.Media.DATE_ADDED)); pictureItem.pictureHeight = data.getInt(data.getColumnIndexOrThrow(MediaStore.Images.Media.HEIGHT)); pictureItem.pictureWidth = data.getInt(data.getColumnIndexOrThrow(MediaStore.Images.Media.WIDTH)); pictureItem.pictureMimeType = data.getString(data.getColumnIndexOrThrow(MediaStore.Images.Media.MIME_TYPE)); pictureItem.pictureSize = data.getInt(data.getColumnIndexOrThrow(MediaStore.Images.Media.SIZE)); pictureItem.pictureName = data.getString(data.getColumnIndexOrThrow(MediaStore.Images.Media.DISPLAY_NAME)); //得到文件的父目录文件 File parentFile = pictureFile.getParentFile(); //得到父目录的路径并统一转为小写 String parentFilePath = parentFile.getAbsolutePath().toLowerCase(); //如果图片文件夹已经被存储 if (null != path2PictureFolderMap.get(parentFilePath)) { path2PictureFolderMap.get(parentFilePath).pictureItemList.add(pictureItem); } else { PictureFolder pictureFolder = new PictureFolder(); pictureFolder.folderName = parentFile.getName(); pictureFolder.folderAbsPath = parentFilePath; pictureFolder.pictureItemList = new ArrayList<>(); pictureFolder.pictureItemList.add(pictureItem); //因为扫描时是按照加入时间降序排序,所以第一个图片为最新的,设为封面 pictureFolder.folderCover = pictureItem; pictureFolderList.add(pictureFolder); path2PictureFolderMap.put(parentFilePath, pictureFolder); } //把此图片加到“全部图片”里 allPictureList.add(pictureItem); } } } if (allPictureList.size() > 0) { PictureFolder folder = new PictureFolder(); folder.folderName = context.getResources().getString(R.string.all_pictures); folder.pictureItemList = allPictureList; folder.folderCover = allPictureList.get(0); pictureFolderList.add(0, folder); } if (scanFinishListener != null) { scanFinishListener.onScanFinish(pictureFolderList); } } }
Example 20
Source File: TransitionManager.java From Transitions-Everywhere with Apache License 2.0 | 3 votes |
/** * Sets a specific transition to occur when the given pair of scenes is * exited/entered. * * @param fromScene The scene being exited when the given transition will * be run * @param toScene The scene being entered when the given transition will * be run * @param transition The transition that will play when the given scene is * entered. A value of null will result in the default behavior of * using the default transition instead. */ public void setTransition(@NonNull Scene fromScene, @NonNull Scene toScene, @Nullable Transition transition) { ArrayMap<Scene, Transition> sceneTransitionMap = mScenePairTransitions.get(toScene); if (sceneTransitionMap == null) { sceneTransitionMap = new ArrayMap<Scene, Transition>(); mScenePairTransitions.put(toScene, sceneTransitionMap); } sceneTransitionMap.put(fromScene, transition); }