static { SparseIntArray localSparseIntArray = new SparseIntArray(); Z = localSparseIntArray; localSparseIntArray.append(1, aau.ss); Z.append(2, aau.sr); Z.append(3, aau.sq); Z.append(16, aau.sp); Z.append(4, aau.so); Z.append(17, aau.sn); }
protected MetadataDTO generateListMetadata() { synchronized (mObjectList) { MetadataDTO metadata = new MetadataDTO(); D currentHeaderData = null; int currentHeaderDataPosition = 0; SparseIntArray headerPositions = new SparseIntArray(); // this.mHeadersPositions = new SparseIntArray(); sortList(mObjectList); for (T item : mObjectList) { if (currentHeaderData == null || compareHeadersData(currentHeaderData, getHeadersData(item)) != 0) { currentHeaderData = getHeadersData(item); metadata.getTotalItems().add(currentHeaderData); int lastCurrentHeaderDataPosition = currentHeaderDataPosition; currentHeaderDataPosition = metadata.getTotalItems().size() - 1; metadata.getViewTypesByPosition().append(currentHeaderDataPosition, VIEW_TYPE_HEADER); headerPositions.append(lastCurrentHeaderDataPosition, currentHeaderDataPosition); // mHeadersPositions.append(lastCurrentDatePosition, // currentDatePosition); metadata .getPrevHeadersPositionByIndex() .append(currentHeaderDataPosition, currentHeaderDataPosition); } metadata.getTotalItems().add(item); int position = metadata.getTotalItems().size() - 1; metadata.getViewTypesByPosition().append(position, VIEW_TYPE_ITEM); metadata.getPrevHeadersPositionByIndex().append(position, currentHeaderDataPosition); } for (int index = 0; index < metadata.getPrevHeadersPositionByIndex().size(); index++) { int key = metadata.getPrevHeadersPositionByIndex().keyAt(index); int value = metadata.getPrevHeadersPositionByIndex().valueAt(index); if (key != value) { value = headerPositions.get(value, -1); } metadata.getNextHeadersPositionByIndex().append(key, value); } return metadata; } }
@Override protected void onItemAddedToList(int position, boolean flow) { super.onItemAddedToList(position, flow); if (isHeaderOrFooterPosition(position) == false) { Column col = getNextColumn(flow, position); mItems.append(position, col.getIndex()); } }
private void createViewMetrics(Stack<ViewConstraints> springMetrics) { springMetrics.clear(); mIdToViewConstraints.clear(); if (mRootConstraints != null) { mRootConstraints.release(); for (ViewConstraints mViewConstraint : mViewConstraints) { mViewConstraint.release(); } mRootConstraints.reset(this); resizeViewConstraintsArray(getChildCount()); } else { mRootConstraints = new ViewConstraints(this, mLayoutMath); mViewConstraints = new ViewConstraints[getChildCount()]; } mRootConstraints.left.setValueObject(mLayoutMath.variable(0)); mRootConstraints.top.setValueObject(mLayoutMath.variable(0)); final int count = getChildCount(); for (int i = 0; i < count; i++) { final View v = getChildAt(i); mIdToViewConstraints.append(v.getId(), i); if (mViewConstraints[i] == null) { mViewConstraints[i] = new ViewConstraints(v, mLayoutMath); } else { mViewConstraints[i].reset(v); } } for (int i = 0; i < count; i++) { final ViewConstraints viewConstraints = mViewConstraints[i]; final LayoutParams layoutParams = (LayoutParams) viewConstraints.getView().getLayoutParams(); if (layoutParams.getWidthWeight() > 0) { viewConstraints.markAsHorizontalSpring(); } if (layoutParams.getHeightWeight() > 0) { viewConstraints.markAsVerticalSpring(); } int[] childRules = layoutParams.getRelations(); for (int relation : VALID_RELATIONS) { final ViewConstraints metrics = getViewMetrics(childRules[relation]); if (metrics != null) { metrics.updateRelation(viewConstraints, relation); } } if (viewConstraints.isHorizontalSpring() || viewConstraints.isVerticalSpring()) { springMetrics.add(viewConstraints); } } }
private int getSpokenDescriptionId( final Context context, final int code, final String resourceNameFormat) { final String resourceName = String.format(Locale.ROOT, resourceNameFormat, code); final Resources resources = context.getResources(); // Note that the resource package name may differ from the context package name. final String resourcePackageName = resources.getResourcePackageName(R.string.spoken_description_unknown); final int resId = resources.getIdentifier(resourceName, "string", resourcePackageName); if (resId != 0) { mKeyCodeMap.append(code, resId); } return resId; }
static { ORIENTATIONS.append(Surface.ROTATION_0, 90); ORIENTATIONS.append(Surface.ROTATION_90, 0); ORIENTATIONS.append(Surface.ROTATION_180, 270); ORIENTATIONS.append(Surface.ROTATION_270, 180); }
/** * Figures out whether the item at the specified position represents a stand-alone element, a * group or a group child. Also computes the corresponding cursor position. */ public void obtainPositionMetadata(PositionMetadata metadata, int position) { // If the description object already contains requested information, just return if (metadata.listPosition == position) { return; } int listPosition = 0; int cursorPosition = 0; int firstGroupToCheck = 0; // Check cache for the supplied position. What we are looking for is // the group descriptor immediately preceding the supplied position. // Once we have that, we will be able to tell whether the position // is the header of the group, a member of the group or a standalone item. if (mLastCachedListPosition != -1) { if (position <= mLastCachedListPosition) { // Have SparceIntArray do a binary search for us. int index = mPositionCache.indexOfKey(position); // If we get back a positive number, the position corresponds to // a group header. if (index < 0) { // We had a cache miss, but we did obtain valuable information anyway. // The negative number will allow us to compute the location of // the group header immediately preceding the supplied position. index = ~index - 1; if (index >= mPositionCache.size()) { index--; } } // A non-negative index gives us the position of the group header // corresponding or preceding the position, so we can // search for the group information at the supplied position // starting with the cached group we just found if (index >= 0) { listPosition = mPositionCache.keyAt(index); firstGroupToCheck = mPositionCache.valueAt(index); long descriptor = mGroupMetadata[firstGroupToCheck]; cursorPosition = (int) (descriptor & GROUP_OFFSET_MASK); } } else { // If we haven't examined groups beyond the supplied position, // we will start where we left off previously firstGroupToCheck = mLastCachedGroup; listPosition = mLastCachedListPosition; cursorPosition = mLastCachedCursorPosition; } } for (int i = firstGroupToCheck; i < mGroupCount; i++) { long group = mGroupMetadata[i]; int offset = (int) (group & GROUP_OFFSET_MASK); // Move pointers to the beginning of the group listPosition += (offset - cursorPosition); cursorPosition = offset; if (i > mLastCachedGroup) { mPositionCache.append(listPosition, i); mLastCachedListPosition = listPosition; mLastCachedCursorPosition = cursorPosition; mLastCachedGroup = i; } // Now we have several possibilities: // A) The requested position precedes the group if (position < listPosition) { metadata.itemType = ITEM_TYPE_STANDALONE; metadata.cursorPosition = cursorPosition - (listPosition - position); return; } boolean expanded = (group & EXPANDED_GROUP_MASK) != 0; int size = (int) ((group & GROUP_SIZE_MASK) >> 32); // B) The requested position is a group header if (position == listPosition) { metadata.itemType = ITEM_TYPE_GROUP_HEADER; metadata.groupPosition = i; metadata.isExpanded = expanded; metadata.childCount = size; metadata.cursorPosition = offset; return; } if (expanded) { // C) The requested position is an element in the expanded group if (position < listPosition + size + 1) { metadata.itemType = ITEM_TYPE_IN_GROUP; metadata.cursorPosition = cursorPosition + (position - listPosition) - 1; return; } // D) The element is past the expanded group listPosition += size + 1; } else { // E) The element is past the collapsed group listPosition++; } // Move cursor past the group cursorPosition += size; } // The required item is past the last group metadata.itemType = ITEM_TYPE_STANDALONE; metadata.cursorPosition = cursorPosition + (position - listPosition); }
static { orientacoes.append(Surface.ROTATION_0, 90); orientacoes.append(Surface.ROTATION_90, 0); orientacoes.append(Surface.ROTATION_180, 270); orientacoes.append(Surface.ROTATION_270, 180); }