time class changed
This commit is contained in:
parent
df68f7ca5c
commit
67a58077cc
@ -61,11 +61,11 @@ public class ActivityManageTriggerTimeFrame extends Activity
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(View v)
|
public void onClick(View v)
|
||||||
{
|
{
|
||||||
Time startTime = new Time(0);
|
TimeObject startTime = new TimeObject();
|
||||||
startTime.setHours(startPicker.getCurrentHour());
|
startTime.setHours(startPicker.getCurrentHour());
|
||||||
startTime.setMinutes(startPicker.getCurrentMinute());
|
startTime.setMinutes(startPicker.getCurrentMinute());
|
||||||
|
|
||||||
Time stopTime = new Time(0);
|
TimeObject stopTime = new TimeObject();
|
||||||
stopTime.setHours(stopPicker.getCurrentHour());
|
stopTime.setHours(stopPicker.getCurrentHour());
|
||||||
stopTime.setMinutes(stopPicker.getCurrentMinute());
|
stopTime.setMinutes(stopPicker.getCurrentMinute());
|
||||||
|
|
||||||
|
@ -490,7 +490,7 @@ public class Miscellaneous extends Service
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int compareTimes(Time time1, Time time2)
|
public static int compareTimes(TimeObject time1, TimeObject time2)
|
||||||
{
|
{
|
||||||
// Miscellaneous.logEvent("i", "TimeCompare", "To compare: " + time1.toString() + " / " + time2.toString());
|
// Miscellaneous.logEvent("i", "TimeCompare", "To compare: " + time1.toString() + " / " + time2.toString());
|
||||||
|
|
||||||
|
@ -6,8 +6,8 @@ import java.util.ArrayList;
|
|||||||
public class TimeFrame
|
public class TimeFrame
|
||||||
{
|
{
|
||||||
// Defines a timeframe
|
// Defines a timeframe
|
||||||
protected Time triggerTimeStart;
|
protected TimeObject triggerTimeStart;
|
||||||
protected Time triggerTimeStop;
|
protected TimeObject triggerTimeStop;
|
||||||
protected long repetition;
|
protected long repetition;
|
||||||
|
|
||||||
protected final static String separator = "/";
|
protected final static String separator = "/";
|
||||||
@ -34,20 +34,20 @@ public class TimeFrame
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Time getTriggerTimeStart()
|
public TimeObject getTriggerTimeStart()
|
||||||
{
|
{
|
||||||
return triggerTimeStart;
|
return triggerTimeStart;
|
||||||
}
|
}
|
||||||
public void setTriggerTimeStart(Time triggerTimeStart)
|
public void setTriggerTimeStart(TimeObject triggerTimeStart)
|
||||||
{
|
{
|
||||||
this.triggerTimeStart = triggerTimeStart;
|
this.triggerTimeStart = triggerTimeStart;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Time getTriggerTimeStop()
|
public TimeObject getTriggerTimeStop()
|
||||||
{
|
{
|
||||||
return triggerTimeStop;
|
return triggerTimeStop;
|
||||||
}
|
}
|
||||||
public void setTriggerTimeStop(Time triggerTimeStop)
|
public void setTriggerTimeStop(TimeObject triggerTimeStop)
|
||||||
{
|
{
|
||||||
this.triggerTimeStop = triggerTimeStop;
|
this.triggerTimeStop = triggerTimeStop;
|
||||||
}
|
}
|
||||||
@ -62,7 +62,7 @@ public class TimeFrame
|
|||||||
this.repetition = repetition;
|
this.repetition = repetition;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TimeFrame (Time timeStart, Time timeEnd, ArrayList<Integer> dayList2, long repetition)
|
public TimeFrame (TimeObject timeStart, TimeObject timeEnd, ArrayList<Integer> dayList2, long repetition)
|
||||||
{
|
{
|
||||||
this.setTriggerTimeStart(timeStart);
|
this.setTriggerTimeStart(timeStart);
|
||||||
this.setTriggerTimeStop(timeEnd);
|
this.setTriggerTimeStop(timeEnd);
|
||||||
@ -73,8 +73,8 @@ public class TimeFrame
|
|||||||
public TimeFrame (String fileContent)
|
public TimeFrame (String fileContent)
|
||||||
{
|
{
|
||||||
String[] dateArray = fileContent.split(separator); // example: timestart/timestop/days[int]/repetition
|
String[] dateArray = fileContent.split(separator); // example: timestart/timestop/days[int]/repetition
|
||||||
this.setTriggerTimeStart(Time.valueOf(dateArray[0]));
|
this.setTriggerTimeStart(TimeObject.valueOf(dateArray[0]));
|
||||||
this.setTriggerTimeStop(Time.valueOf(dateArray[1]));
|
this.setTriggerTimeStop(TimeObject.valueOf(dateArray[1]));
|
||||||
this.setDayListFromString(dateArray[2]);
|
this.setDayListFromString(dateArray[2]);
|
||||||
if(dateArray.length > 3) // may not exist in old config files
|
if(dateArray.length > 3) // may not exist in old config files
|
||||||
this.setRepetition(Long.parseLong(dateArray[3]));
|
this.setRepetition(Long.parseLong(dateArray[3]));
|
||||||
|
68
app/src/main/java/com/jens/automation2/TimeObject.java
Normal file
68
app/src/main/java/com/jens/automation2/TimeObject.java
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
package com.jens.automation2;
|
||||||
|
|
||||||
|
import java.sql.Time;
|
||||||
|
|
||||||
|
public class TimeObject
|
||||||
|
{
|
||||||
|
int hours, minutes, seconds;
|
||||||
|
|
||||||
|
public TimeObject()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getHours()
|
||||||
|
{
|
||||||
|
return hours;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHours(int hours)
|
||||||
|
{
|
||||||
|
this.hours = hours;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMinutes()
|
||||||
|
{
|
||||||
|
return minutes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMinutes(int minutes)
|
||||||
|
{
|
||||||
|
this.minutes = minutes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSeconds()
|
||||||
|
{
|
||||||
|
return seconds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSeconds(int seconds)
|
||||||
|
{
|
||||||
|
this.seconds = seconds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TimeObject(int hours, int minutes, int seconds)
|
||||||
|
{
|
||||||
|
this.hours = hours;
|
||||||
|
this.minutes = minutes;
|
||||||
|
this.seconds = seconds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TimeObject valueOf(String input)
|
||||||
|
{
|
||||||
|
TimeObject ro = null;
|
||||||
|
|
||||||
|
if(input.contains(":"))
|
||||||
|
{
|
||||||
|
String[] parts = input.split(":");
|
||||||
|
if(parts.length == 2)
|
||||||
|
ro = new TimeObject(Integer.parseInt(parts[0]), Integer.parseInt(parts[1]), 0);
|
||||||
|
else if(parts.length == 3)
|
||||||
|
ro = new TimeObject(Integer.parseInt(parts[0]), Integer.parseInt(parts[1]), Integer.parseInt(parts[2]));
|
||||||
|
else
|
||||||
|
Miscellaneous.logEvent("w", "TimeObject", "Invalid length for time. Input: " + input, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ro;
|
||||||
|
}
|
||||||
|
}
|
@ -934,7 +934,7 @@ public class Trigger
|
|||||||
triggeringTime = new Date();
|
triggeringTime = new Date();
|
||||||
|
|
||||||
String timeString = String.valueOf(triggeringTime.getHours()) + ":" + String.valueOf(triggeringTime.getMinutes()) + ":" + String.valueOf(triggeringTime.getSeconds());
|
String timeString = String.valueOf(triggeringTime.getHours()) + ":" + String.valueOf(triggeringTime.getMinutes()) + ":" + String.valueOf(triggeringTime.getSeconds());
|
||||||
Time nowTime = Time.valueOf(timeString);
|
TimeObject nowTime = TimeObject.valueOf(timeString);
|
||||||
Calendar calNow = Calendar.getInstance();
|
Calendar calNow = Calendar.getInstance();
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -1089,7 +1089,7 @@ public class Trigger
|
|||||||
public static Calendar getNextRepeatedExecutionAfter(Trigger trigger, Calendar now)
|
public static Calendar getNextRepeatedExecutionAfter(Trigger trigger, Calendar now)
|
||||||
{
|
{
|
||||||
Calendar calSet;
|
Calendar calSet;
|
||||||
Time setTime;
|
TimeObject setTime;
|
||||||
TimeFrame tf = new TimeFrame(trigger.getTriggerParameter2());
|
TimeFrame tf = new TimeFrame(trigger.getTriggerParameter2());
|
||||||
|
|
||||||
if(tf.getRepetition() > 0)
|
if(tf.getRepetition() > 0)
|
||||||
|
@ -14,6 +14,7 @@ import com.jens.automation2.AutomationService;
|
|||||||
import com.jens.automation2.Miscellaneous;
|
import com.jens.automation2.Miscellaneous;
|
||||||
import com.jens.automation2.Rule;
|
import com.jens.automation2.Rule;
|
||||||
import com.jens.automation2.TimeFrame;
|
import com.jens.automation2.TimeFrame;
|
||||||
|
import com.jens.automation2.TimeObject;
|
||||||
import com.jens.automation2.Trigger;
|
import com.jens.automation2.Trigger;
|
||||||
import com.jens.automation2.Trigger.Trigger_Enum;
|
import com.jens.automation2.Trigger.Trigger_Enum;
|
||||||
|
|
||||||
@ -96,7 +97,7 @@ public class DateTimeListener extends BroadcastReceiver implements AutomationLis
|
|||||||
TimeFrame tf = new TimeFrame(oneTrigger.getTriggerParameter2());
|
TimeFrame tf = new TimeFrame(oneTrigger.getTriggerParameter2());
|
||||||
|
|
||||||
Calendar calSet;
|
Calendar calSet;
|
||||||
Time setTime;
|
TimeObject setTime;
|
||||||
|
|
||||||
if(oneTrigger.getTriggerParameter())
|
if(oneTrigger.getTriggerParameter())
|
||||||
setTime = tf.getTriggerTimeStart();
|
setTime = tf.getTriggerTimeStart();
|
||||||
@ -365,7 +366,7 @@ public class DateTimeListener extends BroadcastReceiver implements AutomationLis
|
|||||||
public static Calendar getNextRepeatedExecutionAfter(Trigger trigger, Calendar now)
|
public static Calendar getNextRepeatedExecutionAfter(Trigger trigger, Calendar now)
|
||||||
{
|
{
|
||||||
Calendar calSet;
|
Calendar calSet;
|
||||||
Time setTime;
|
TimeObject setTime;
|
||||||
TimeFrame tf = new TimeFrame(trigger.getTriggerParameter2());
|
TimeFrame tf = new TimeFrame(trigger.getTriggerParameter2());
|
||||||
|
|
||||||
if(tf.getRepetition() > 0)
|
if(tf.getRepetition() > 0)
|
||||||
@ -403,26 +404,4 @@ public class DateTimeListener extends BroadcastReceiver implements AutomationLis
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class TimeObject
|
|
||||||
{
|
|
||||||
int hours, minutes, seconds;
|
|
||||||
|
|
||||||
public int getHours()
|
|
||||||
{
|
|
||||||
return hours;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setHours(int hours)
|
|
||||||
{
|
|
||||||
this.hours = hours;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TimeObject(int hours, int minutes, int seconds)
|
|
||||||
{
|
|
||||||
this.hours = hours;
|
|
||||||
this.minutes = minutes;
|
|
||||||
this.seconds = seconds;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user