]> git.ktnx.net Git - mobile-ledger.git/blob - app/src/main/java/net/ktnx/mobileledger/ui/profiles/dummy/DummyContent.java
4100c511f5ac515a3a8aea9a8f05a83661182574
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / ui / profiles / dummy / DummyContent.java
1 /*
2  * Copyright © 2019 Damyan Ivanov.
3  *  This file is part of MoLe.
4  *  MoLe is free software: you can distribute it and/or modify it
5  *  under the term of the GNU General Public License as published by
6  *  the Free Software Foundation, either version 3 of the License, or
7  *  (at your opinion), any later version.
8  *
9  *  MoLe is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  *  GNU General Public License terms for details.
13  *
14  *  You should have received a copy of the GNU General Public License
15  *  along with Mobile-Ledger. If not, see <https://www.gnu.org/licenses/>.
16  */
17
18 package net.ktnx.mobileledger.ui.profiles.dummy;
19
20 import java.util.ArrayList;
21 import java.util.HashMap;
22 import java.util.List;
23 import java.util.Map;
24
25 /**
26  * Helper class for providing sample content for user interfaces created by
27  * Android template wizards.
28  * <p>
29  * TODO: Replace all uses of this class before publishing your app.
30  */
31 public class DummyContent {
32
33     /**
34      * An array of sample (dummy) items.
35      */
36     public static final List<DummyItem> ITEMS = new ArrayList<DummyItem>();
37
38     /**
39      * A map of sample (dummy) items, by ID.
40      */
41     public static final Map<String, DummyItem> ITEM_MAP = new HashMap<String, DummyItem>();
42
43     private static final int COUNT = 25;
44
45     static {
46         // Add some sample items.
47         for (int i = 1; i <= COUNT; i++) {
48             addItem(createDummyItem(i));
49         }
50     }
51
52     private static void addItem(DummyItem item) {
53         ITEMS.add(item);
54         ITEM_MAP.put(item.id, item);
55     }
56
57     private static DummyItem createDummyItem(int position) {
58         return new DummyItem(String.valueOf(position), "Item " + position, makeDetails(position));
59     }
60
61     private static String makeDetails(int position) {
62         StringBuilder builder = new StringBuilder();
63         builder.append("Details about Item: ").append(position);
64         for (int i = 0; i < position; i++) {
65             builder.append("\nMore details information here.");
66         }
67         return builder.toString();
68     }
69
70     /**
71      * A dummy item representing a piece of content.
72      */
73     public static class DummyItem {
74         public final String id;
75         public final String content;
76         public final String details;
77
78         public DummyItem(String id, String content, String details) {
79             this.id = id;
80             this.content = content;
81             this.details = details;
82         }
83
84         @Override
85         public String toString() {
86             return content;
87         }
88     }
89 }