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

NavigationItem.java « navigation « main « notes « owncloud « niedermann « it « java « main « src « app - github.com/stefan-niedermann/nextcloud-notes.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c92f04945347f7db5e904c9edab245735c08be69 (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
package it.niedermann.owncloud.notes.main.navigation;

import android.text.TextUtils;

import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import it.niedermann.owncloud.notes.shared.model.ENavigationCategoryType;

import static it.niedermann.owncloud.notes.shared.model.ENavigationCategoryType.UNCATEGORIZED;

public class NavigationItem {
    @NonNull
    public String id;
    @NonNull
    public String label;
    @DrawableRes
    public int icon;
    @Nullable
    public Integer count;
    @Nullable
    public ENavigationCategoryType type;

    public NavigationItem(@NonNull String id, @NonNull String label, @Nullable Integer count, @DrawableRes int icon) {
        this.id = id;
        this.label = label;
        this.type = TextUtils.isEmpty(label) ? UNCATEGORIZED : null;
        this.count = count;
        this.icon = icon;
    }

    public NavigationItem(@NonNull String id, @NonNull String label, @Nullable Integer count, @DrawableRes int icon, @NonNull ENavigationCategoryType type) {
        this.id = id;
        this.label = label;
        this.type = type;
        this.count = count;
        this.icon = icon;
    }

    public static class CategoryNavigationItem extends NavigationItem {
        public long accountId;
        @NonNull
        public String category;

        public CategoryNavigationItem(@NonNull String id, @NonNull String label, @Nullable Integer count, @DrawableRes int icon, long accountId, @NonNull String category) {
            super(id, label, count, icon, ENavigationCategoryType.DEFAULT_CATEGORY);
            this.accountId = accountId;
            this.category = category;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (!(o instanceof CategoryNavigationItem)) return false;
            if (!super.equals(o)) return false;

            CategoryNavigationItem that = (CategoryNavigationItem) o;

            if (accountId != that.accountId) return false;
            return category.equals(that.category);
        }

        @Override
        public int hashCode() {
            int result = super.hashCode();
            result = 31 * result + (int) (accountId ^ (accountId >>> 32));
            result = 31 * result + category.hashCode();
            return result;
        }
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof NavigationItem)) return false;

        final var that = (NavigationItem) o;

        if (icon != that.icon) return false;
        if (!id.equals(that.id)) return false;
        if (!label.equals(that.label)) return false;
        if (count != null ? !count.equals(that.count) : that.count != null) return false;
        return type == that.type;
    }

    @Override
    public int hashCode() {
        int result = id.hashCode();
        result = 31 * result + label.hashCode();
        result = 31 * result + icon;
        result = 31 * result + (count != null ? count.hashCode() : 0);
        result = 31 * result + (type != null ? type.hashCode() : 0);
        return result;
    }

    @Override
    @NonNull
    public String toString() {
        return "NavigationItem{" +
                "id='" + id + '\'' +
                ", label='" + label + '\'' +
                ", icon=" + icon +
                ", count=" + count +
                ", type=" + type +
                '}';
    }
}