Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 package org.chromium.chrome.browser.history; | |
| 6 | |
| 7 import android.text.TextUtils; | |
| 8 | |
| 9 import org.chromium.chrome.browser.widget.DateDividedAdapter.TimedItem; | |
| 10 | |
| 11 /** Contains information about a single browsing history item. */ | |
| 12 public class HistoryItem extends TimedItem { | |
| 13 private String mUrl; | |
|
gone
2016/12/02 19:34:37
Can any of these things be final?
Theresa
2016/12/02 20:49:32
Done.
| |
| 14 private String mDomain; | |
| 15 private String mTitle; | |
| 16 private long mTimestamp; | |
| 17 private Long mStableId; | |
| 18 | |
| 19 /** | |
| 20 * @param url The url for this item. | |
| 21 * @param domain The string to display for the item's domain. | |
| 22 * @param title The string to display for the item's title. | |
| 23 * @param timestamp The timestamp for this item. | |
| 24 */ | |
| 25 public HistoryItem(String url, String domain, String title, long timestamp) { | |
| 26 mUrl = url; | |
| 27 mDomain = domain; | |
| 28 mTitle = TextUtils.isEmpty(title) ? url : title; | |
| 29 mTimestamp = timestamp; | |
| 30 } | |
| 31 | |
| 32 /** @return The string to display for the item's domain. */ | |
| 33 public String getDomain() { | |
| 34 return mDomain; | |
| 35 } | |
| 36 | |
| 37 /** @return The string to display for the item's title. */ | |
| 38 public String getTitle() { | |
| 39 return mTitle; | |
| 40 } | |
| 41 | |
| 42 @Override | |
| 43 public long getTimestamp() { | |
| 44 return mTimestamp; | |
| 45 } | |
| 46 | |
| 47 @Override | |
| 48 public long getStableId() { | |
| 49 if (mStableId == null) { | |
| 50 // Generate a stable ID that combines the timestamp and the URL. | |
| 51 mStableId = (long) mUrl.hashCode(); | |
| 52 mStableId = (mStableId << 32) + (getTimestamp() & 0x0FFFFFFFF); | |
| 53 } | |
| 54 return mStableId; | |
| 55 } | |
| 56 } | |
| OLD | NEW |