Welcome to mirror list, hosted at ThFree Co, Russian Federation.

EDoneType.java « enums « model « deck « nextcloud « niedermann « it « java « main « src « app - github.com/stefan-niedermann/nextcloud-deck.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4222ee4874f3f9a91a088635f50b1cdacb59da63 (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
package it.niedermann.nextcloud.deck.model.enums;

import android.content.Context;

import androidx.annotation.NonNull;
import androidx.annotation.StringRes;

import it.niedermann.nextcloud.deck.R;

public enum EDoneType {
    NO_FILTER(1, R.string.filter_done_no_filter),
    DONE(2, R.string.filter_done_done),
    UNDONE(3, R.string.filter_done_undone);

    private final int value;
    private final int id;

    EDoneType(int id, @StringRes int value) {
        this.value = value;
        this.id = id;
    }

    public int getId() {
        return id;
    }

    public static EDoneType findById(int id) {
        for (EDoneType s : EDoneType.values()) {
            if (s.getId() == id) {
                return s;
            }
        }
        throw new IllegalArgumentException("unknown " + EDoneType.class.getSimpleName() + " key: " + id);
    }

    @NonNull
    public String toString(Context context) {
        return context.getString(this.value);
    }
}