1 | /* This file is part of Aard Dictionary for Android <http://aarddict.org>. |
2 | * |
3 | * This program is free software: you can redistribute it and/or modify |
4 | * it under the terms of the GNU General Public License version 3 |
5 | * as published by the Free Software Foundation. |
6 | * |
7 | * This program is distributed in the hope that it will be useful, |
8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
10 | * GNU General Public License <http://www.gnu.org/licenses/gpl-3.0.txt> |
11 | * for more details. |
12 | * |
13 | * Copyright (C) 2010 Igor Tkach |
14 | */ |
15 | |
16 | package aarddict.android; |
17 | |
18 | import java.io.Serializable; |
19 | import java.util.ArrayList; |
20 | import java.util.List; |
21 | |
22 | import aarddict.Article; |
23 | import aarddict.Entry; |
24 | |
25 | final class HistoryItem implements Serializable { |
26 | List<Entry> entries; |
27 | int entryIndex; |
28 | Article article; |
29 | |
30 | HistoryItem(Entry entry) { |
31 | this.entries = new ArrayList<Entry>(); |
32 | this.entries.add(entry); |
33 | this.entryIndex = -1; |
34 | } |
35 | |
36 | HistoryItem(List<Entry> entries) { |
37 | this.entries = entries; |
38 | this.entryIndex = -1; |
39 | } |
40 | |
41 | HistoryItem(HistoryItem that) { |
42 | this.entries = that.entries; |
43 | this.entryIndex = that.entryIndex; |
44 | if (that.article != null) { |
45 | this.article = new Article(that.article); |
46 | } |
47 | } |
48 | |
49 | boolean hasNext() { |
50 | return entryIndex < entries.size() - 1; |
51 | } |
52 | |
53 | Entry next() { |
54 | entryIndex ++; |
55 | return current(); |
56 | } |
57 | |
58 | Entry current() { |
59 | return entries.get(entryIndex); |
60 | } |
61 | } |