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