2019-04-29 08:14:55 +00:00
|
|
|
package eu.faircode.email;
|
|
|
|
|
2019-05-04 20:49:22 +00:00
|
|
|
/*
|
|
|
|
This file is part of FairEmail.
|
|
|
|
|
|
|
|
FairEmail 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.
|
|
|
|
|
|
|
|
FairEmail 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 FairEmail. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
Copyright 2018-2019 by Marcel Bokhorst (M66B)
|
|
|
|
*/
|
|
|
|
|
2019-04-29 08:14:55 +00:00
|
|
|
public class NavMenuItem {
|
|
|
|
private int icon;
|
|
|
|
private int title;
|
|
|
|
private Integer count = null;
|
2019-04-29 09:39:24 +00:00
|
|
|
private boolean separated = false;
|
2019-04-29 08:14:55 +00:00
|
|
|
private Runnable click;
|
|
|
|
private Runnable longClick;
|
|
|
|
|
|
|
|
NavMenuItem(int icon, int title, Runnable click) {
|
|
|
|
this.icon = icon;
|
|
|
|
this.title = title;
|
|
|
|
this.click = click;
|
|
|
|
}
|
|
|
|
|
|
|
|
NavMenuItem(int icon, int title, Runnable click, Runnable longClick) {
|
|
|
|
this.icon = icon;
|
|
|
|
this.title = title;
|
|
|
|
this.click = click;
|
|
|
|
this.longClick = longClick;
|
|
|
|
}
|
|
|
|
|
2019-05-04 20:38:11 +00:00
|
|
|
void setIcon(int icon) {
|
|
|
|
this.icon = icon;
|
|
|
|
}
|
|
|
|
|
2019-04-29 08:14:55 +00:00
|
|
|
void setCount(Integer count) {
|
|
|
|
if (count != null && count == 0)
|
|
|
|
count = null;
|
|
|
|
this.count = count;
|
|
|
|
}
|
|
|
|
|
2019-04-29 09:39:24 +00:00
|
|
|
NavMenuItem setSeparated() {
|
|
|
|
this.separated = true;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2019-04-29 08:14:55 +00:00
|
|
|
int getIcon() {
|
|
|
|
return this.icon;
|
|
|
|
}
|
|
|
|
|
|
|
|
int getTitle() {
|
|
|
|
return this.title;
|
|
|
|
}
|
|
|
|
|
|
|
|
Integer getCount() {
|
|
|
|
return this.count;
|
|
|
|
}
|
|
|
|
|
2019-04-29 09:39:24 +00:00
|
|
|
boolean isSeparated() {
|
|
|
|
return this.separated;
|
|
|
|
}
|
|
|
|
|
2019-04-29 08:14:55 +00:00
|
|
|
void onClick() {
|
|
|
|
click.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
boolean onLongClick() {
|
|
|
|
if (longClick != null)
|
|
|
|
longClick.run();
|
|
|
|
return (longClick != null);
|
|
|
|
}
|
|
|
|
}
|