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