Back to project page SoundScheduler.
The source code is released under:
GNU General Public License
If you think the Android project SoundScheduler listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
/* * Sound Scheduler// w w w . j ava2s . com * Copyright (C) 2013 Victor Kifer */ package com.victorkifer.SoundScheduler.entities; public class Rule { private long id; private long startTime; private long endTime; private boolean active; private boolean applied; private int stateBefore; private int stateToApply; private boolean[] daysRepeat; public static final int STATE_NULL = -1; public static final int STATE_NORMAL = 0; public static final int STATE_SILENT = 1; public static final int STATE_VIBRATE = 2; public static final int STATE_AIRPLANE = 3; public Rule() { daysRepeat = new boolean[7]; for(int i=0; i<7; i++) { daysRepeat[i] = false; } id = 0; startTime = 0; endTime = 0; active = false; applied = false; stateBefore = STATE_NORMAL; stateToApply = STATE_NULL; } public long getId() { return id; } public void setId(long id) { this.id = id; } public long getStartTime() { return startTime; } public void setStartTime(long startTime) { this.startTime = startTime; } public long getEndTime() { return endTime; } public void setEndTime(long endTime) { this.endTime = endTime; } public boolean isActive() { return active; } public void setActive(boolean active) { this.active = active; } public boolean isActiveOnDay(int day) { if(day>=0 && day <7) { return daysRepeat[day]; } return false; } public void setActiveOnDay(int day) { if(day>=0 && day <7) { daysRepeat[day] = true; } } public void setDaysRepeat(boolean[] repeat) { if(repeat.length == 7) { for(int i=0; i<7; i++) { daysRepeat[i] = repeat[i]; } } } public boolean[] getDaysRepeatArray() { boolean arr[] = new boolean[7]; System.arraycopy(daysRepeat, 0, arr, 0, 7); return arr; } public boolean isApplied() { return applied; } public void setApplied(boolean applied) { this.applied = applied; } @Override public String toString() { return startTime + "-" + endTime; } public int getStateBefore() { return stateBefore; } public void setStateBefore(int stateBefore) { this.stateBefore = stateBefore; } public int getStateToApply() { return stateToApply; } public void setStateToApply(int stateToApply) { this.stateToApply = stateToApply; } public String getDaysRepeatString(String[] dayNames) { String result = ""; for(int i=0; i<7; i++) { if(daysRepeat[i]) { result += dayNames[i] + ", "; } } if(!result.isEmpty()) { result = result.substring(0, result.length()-2); } return result; } public boolean isDaysRepeatEmpty() { boolean res = false; for(int i=0; i<7; i++) { if(isActiveOnDay(i)) { res = true; break; } } return !res; } }