Ben Lin | 7b38f34 | 2016-12-14 11:52:35 -0800 | [diff] [blame] | 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 | |
| 17 | package com.android.documentsui.dirlist; |
| 18 | |
Ben Lin | b62d4e5 | 2016-12-19 12:01:11 -0800 | [diff] [blame] | 19 | |
Ben Lin | 7b38f34 | 2016-12-14 11:52:35 -0800 | [diff] [blame] | 20 | import android.content.Context; |
| 21 | import android.database.Cursor; |
| 22 | import android.widget.Space; |
| 23 | |
| 24 | import com.android.documentsui.R; |
| 25 | import 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 Lin | b62d4e5 | 2016-12-19 12:01:11 -0800 | [diff] [blame] | 31 | final class TransparentDividerDocumentHolder extends MessageHolder { |
Ben Lin | 7b38f34 | 2016-12-14 11:52:35 -0800 | [diff] [blame] | 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 | } |