InfoStoreTrojan.java revision b31c3281d870e9abb673db239234d580dcc4feff
1/*
2 * Copyright 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package androidx.recyclerview.widget;
17
18import androidx.recyclerview.widget.ViewInfoStore;
19
20/**
21 * Helper class for tests to check internals of ViewInfoStore
22 */
23public class InfoStoreTrojan {
24    static int sizeOfPreLayout(ViewInfoStore store) {
25        return sizeOf(store, ViewInfoStore.InfoRecord.FLAG_PRE);
26    }
27    static int sizeOfPostLayout(ViewInfoStore store) {
28        return sizeOf(store, ViewInfoStore.InfoRecord.FLAG_POST);
29    }
30    static int sizeOf(ViewInfoStore store, int flags) {
31        int cnt = 0;
32        final int size = store.mLayoutHolderMap.size();
33        for (int i = 0; i < size; i ++) {
34            ViewInfoStore.InfoRecord record = store.mLayoutHolderMap.valueAt(i);
35            if ((record.flags & flags) != 0) {
36                cnt ++;
37            }
38        }
39        return cnt;
40    }
41}
42