blob: 44efd8090e15f409852a24fc8521747790fbf0c1 [file] [log] [blame]
Ben Lin7b38f342016-12-14 11:52:35 -08001/*
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
Ben Linb62d4e52016-12-19 12:01:11 -080019
Ben Lin7b38f342016-12-14 11:52:35 -080020import 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 */
Ben Linb62d4e52016-12-19 12:01:11 -080031final class TransparentDividerDocumentHolder extends MessageHolder {
Ben Lin7b38f342016-12-14 11:52:35 -080032 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}