TransparentDividerDocumentHolder.java revision b62d4e5804d807703697ad7eeb85131a35ce4ab4
1/*
2 * Copyright (C) 2016 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 */
16
17package com.android.documentsui.dirlist;
18
19
20import android.content.Context;
21import android.database.Cursor;
22import android.widget.Space;
23
24import com.android.documentsui.R;
25import com.android.documentsui.base.State;
26
27/**
28 * The most elegant transparent blank box that spans N rows ever conceived.
29 * Used by {@link DirectoryAddonsAdapter}.
30 */
31final class TransparentDividerDocumentHolder extends MessageHolder {
32    private final int mVisibleHeight;
33    private State mState;
34
35    public TransparentDividerDocumentHolder(Context context) {
36        super(context, new Space(context));
37
38        mVisibleHeight = context.getResources().getDimensionPixelSize(
39                R.dimen.grid_section_separator_height);
40    }
41
42    public void bind(State state) {
43        mState = state;
44        bind(null, null);
45    }
46
47    @Override
48    public void bind(Cursor cursor, String modelId) {
49        if (mState.derivedMode == State.MODE_GRID) {
50            itemView.setMinimumHeight(mVisibleHeight);
51        } else {
52            itemView.setMinimumHeight(0);
53        }
54        return;
55    }
56}