PageRenderTime 18ms CodeModel.GetById 9ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/WebVox/src/com/marvin/webvox/HistoryItem.java

http://eyes-free.googlecode.com/
Java | 85 lines | 37 code | 10 blank | 38 comment | 0 complexity | 542dc71f971818b9be804b27172f6663 MD5 | raw file
 1/*
 2 * Copyright (C) 2008 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 
18package com.marvin.webvox;
19
20import com.marvin.webvox.R;
21
22import android.content.Context;
23import android.graphics.Bitmap;
24import android.provider.Browser;
25import android.view.View;
26import android.widget.CompoundButton;
27import android.widget.ImageView;
28import android.widget.TextView;
29
30/**
31 *  Layout representing a history item in the classic history viewer.
32 */
33/* package */ class HistoryItem extends BookmarkItem {
34
35    private CompoundButton  mStar;      // Star for bookmarking
36    private CompoundButton.OnCheckedChangeListener  mListener;
37    /**
38     *  Create a new HistoryItem.
39     *  @param context  Context for this HistoryItem.
40     */
41    /* package */ HistoryItem(Context context) {
42        super(context);
43
44        mStar = (CompoundButton) findViewById(R.id.star);
45        mStar.setVisibility(View.VISIBLE);
46        mListener = new CompoundButton.OnCheckedChangeListener() {
47            public void onCheckedChanged(CompoundButton buttonView,
48                    boolean isChecked) {
49/*
50                if (isChecked) {
51                    Bookmarks.addBookmark(mContext,
52                            mContext.getContentResolver(), mUrl, getName(), null, true);
53                } else {
54                    Bookmarks.removeFromBookmarks(mContext,
55                            mContext.getContentResolver(), mUrl, getName());
56                }
57*/                
58            }
59        };
60    }
61    
62    /* package */ void copyTo(HistoryItem item) {
63        item.mTextView.setText(mTextView.getText());
64        item.mUrlText.setText(mUrlText.getText());
65        item.setIsBookmark(mStar.isChecked());
66        item.mImageView.setImageDrawable(mImageView.getDrawable());
67    }
68
69    /**
70     * Whether or not this item represents a bookmarked site
71     */
72    /* package */ boolean isBookmark() {
73        return mStar.isChecked();
74    }
75
76    /**
77     *  Set whether or not this represents a bookmark, and make sure the star
78     *  behaves appropriately.
79     */
80    /* package */ void setIsBookmark(boolean isBookmark) {
81        mStar.setOnCheckedChangeListener(null);
82        mStar.setChecked(isBookmark);
83        mStar.setOnCheckedChangeListener(mListener);
84    }
85}