Leon Scroggins | b6b7f9e | 2009-06-18 12:05:28 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2009 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.browser; |
| 18 | |
Leon Scroggins | b6b7f9e | 2009-06-18 12:05:28 -0400 | [diff] [blame] | 19 | import android.content.Context; |
Leon Scroggins | b6b7f9e | 2009-06-18 12:05:28 -0400 | [diff] [blame] | 20 | import android.widget.GridView; |
Leon Scroggins | b6b7f9e | 2009-06-18 12:05:28 -0400 | [diff] [blame] | 21 | |
| 22 | import java.util.ArrayList; |
| 23 | |
Leon Scroggins | 892df31 | 2009-07-14 14:48:02 -0400 | [diff] [blame] | 24 | public class BookmarkGridPage extends GridView { |
| 25 | private final static int SPACING = 10; |
| 26 | private BrowserBookmarksAdapter mAdapter; |
Leon Scroggins | b6b7f9e | 2009-06-18 12:05:28 -0400 | [diff] [blame] | 27 | |
Leon Scroggins | 892df31 | 2009-07-14 14:48:02 -0400 | [diff] [blame] | 28 | public BookmarkGridPage(Context context, BrowserBookmarksAdapter adapter) { |
| 29 | super(context); |
| 30 | setNumColumns(3); |
| 31 | mAdapter = adapter; |
| 32 | setAdapter(mAdapter); |
| 33 | setFocusable(true); |
| 34 | setFocusableInTouchMode(true); |
| 35 | setSelector(android.R.drawable.gallery_thumb); |
| 36 | setVerticalSpacing(SPACING); |
| 37 | setHorizontalSpacing(SPACING); |
Leon Scroggins | b6b7f9e | 2009-06-18 12:05:28 -0400 | [diff] [blame] | 38 | } |
| 39 | |
Leon Scroggins | 71bd366 | 2009-07-06 16:40:00 -0400 | [diff] [blame] | 40 | @Override |
Leon Scroggins | 892df31 | 2009-07-14 14:48:02 -0400 | [diff] [blame] | 41 | protected void onSizeChanged(int w, int h, int oldw, int oldh) { |
| 42 | int thumbHeight = (h - 2 * (SPACING + getListPaddingTop() |
| 43 | + getListPaddingBottom())) / 3; |
| 44 | mAdapter.heightChanged(thumbHeight); |
| 45 | super.onSizeChanged(w, h, oldw, oldh); |
Leon Scroggins | b6b7f9e | 2009-06-18 12:05:28 -0400 | [diff] [blame] | 46 | } |
| 47 | } |