blob: 6c1b984baee0549e06cbf23d8bdd8a098bb05b56 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
/*
* Copyright © 2020. Daniel Schaal <daniel@schaal.email>
*
* This file is part of ocreader.
*
* ocreader is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ocreader is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
*/
package email.schaal.ocreader.database.model
import email.schaal.ocreader.R
import io.realm.Realm
import io.realm.Sort
import io.realm.kotlin.where
class StarredFolder: SpecialFolder(R.string.starred_items) {
companion object {
const val ID: Long = -11
}
override fun treeItemId(): Long {
return ID
}
override fun getIcon(): Int {
return R.drawable.ic_star_outline
}
override fun getCount(realm: Realm): Int {
return realm.where<Item>().equalTo(Item.STARRED, true).count().toInt()
}
override fun getFeeds(realm: Realm, onlyUnread: Boolean): List<Feed> {
return realm.where<Feed>().greaterThan(Feed::starredCount.name, 0).sort(Feed::name.name, Sort.ASCENDING).findAll()
}
override fun getItems(realm: Realm, onlyUnread: Boolean): List<Item> {
return realm.where<Item>().equalTo(Item.STARRED, true).findAll()
}
}
|