Fixed issue where stopping took to long
This commit is contained in:
parent
bb84e2188f
commit
1c35a97240
3 changed files with 19 additions and 14 deletions
|
|
@ -19,7 +19,7 @@ public abstract class UeBehaviour implements Serializable{
|
|||
/**
|
||||
* Starts to run the behaviour, this method will block until the execution is done
|
||||
*/
|
||||
public synchronized void run(){
|
||||
public void run(){
|
||||
running = true;
|
||||
|
||||
if(execListener != null) execListener.executionStarted();
|
||||
|
|
@ -36,7 +36,7 @@ public abstract class UeBehaviour implements Serializable{
|
|||
/**
|
||||
* Will stop the currently running behaviour
|
||||
*/
|
||||
public synchronized void terminate(){
|
||||
public void terminate(){
|
||||
running = false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -97,11 +97,13 @@ public class UeControlExecutor implements Runnable, UeBehaviour.DataHandledListe
|
|||
log.info("Running behaviour: " + currentlyActive.getName());
|
||||
currentlyActive.run();
|
||||
|
||||
int index = behaviours.indexOf(currentlyActive) +1;
|
||||
if(index < behaviours.size())
|
||||
currentlyActive = behaviours.get(index);
|
||||
else
|
||||
currentlyActive = null;
|
||||
if(isRunning()) {
|
||||
int index = behaviours.indexOf(currentlyActive) + 1;
|
||||
if (index < behaviours.size())
|
||||
currentlyActive = behaviours.get(index);
|
||||
else
|
||||
currentlyActive = null;
|
||||
}
|
||||
}
|
||||
log.info("Execution completed");
|
||||
}
|
||||
|
|
@ -127,8 +129,10 @@ public class UeControlExecutor implements Runnable, UeBehaviour.DataHandledListe
|
|||
}
|
||||
protected boolean setRealDataUsage(){
|
||||
boolean ret = false;
|
||||
long currentRxBytes = TrafficStats.getUidRxBytes(MainActivity.getUID());
|
||||
long currentTxBytes = TrafficStats.getUidTxBytes(MainActivity.getUID());
|
||||
//long currentRxBytes = TrafficStats.getUidRxBytes(MainActivity.getUID());
|
||||
//long currentTxBytes = TrafficStats.getUidTxBytes(MainActivity.getUID());
|
||||
long currentRxBytes = TrafficStats.getTotalRxBytes();
|
||||
long currentTxBytes = TrafficStats.getTotalTxBytes();
|
||||
|
||||
if (currentRxBytes != TrafficStats.UNSUPPORTED && currentTxBytes != TrafficStats.UNSUPPORTED
|
||||
&& previousRxBytes != TrafficStats.UNSUPPORTED && previousTxBytes != TrafficStats.UNSUPPORTED){
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@ import java.util.regex.Pattern;
|
|||
*/
|
||||
public class UeBehaviourVideoStreaming extends UeBehaviour implements MediaPlayer.OnErrorListener{
|
||||
private static final Logger log = Logger.getLogger(UeBehaviourVideoStreaming.class);
|
||||
private static final Pattern YOUTUBE_VIDEOURL_PATTERN = Pattern.compile(".*youtube.*[&\\?]v=([\\w-]*)[&#]?");
|
||||
private static final Pattern YOUTUBE_VIDEOID_PATTERN = Pattern.compile("^[\\w-]*$");
|
||||
protected static final String YOUTUBE_FEED_URL = "http://gdata.youtube.com/feeds/api/videos/";
|
||||
|
||||
@Configurable("Streaming URL")
|
||||
|
|
@ -65,15 +67,14 @@ public class UeBehaviourVideoStreaming extends UeBehaviour implements MediaPlaye
|
|||
}
|
||||
|
||||
protected static boolean isYouTubeUrl(String url){
|
||||
return Pattern.matches("youtube\\.com.*v=", url) ||
|
||||
Pattern.matches("^[\\w-]*$", url);
|
||||
return YOUTUBE_VIDEOURL_PATTERN.matcher(url).matches() ||
|
||||
YOUTUBE_VIDEOID_PATTERN.matcher(url).matches();
|
||||
}
|
||||
protected static String getYoutubeVideoId(String url){
|
||||
if(Pattern.matches("^[\\w-]*$", url))
|
||||
if(YOUTUBE_VIDEOID_PATTERN.matcher(url).matches())
|
||||
return url;
|
||||
|
||||
Pattern pattern = Pattern.compile("v=([\\w-]*)[&#]?");
|
||||
Matcher match = pattern.matcher(url);
|
||||
Matcher match = YOUTUBE_VIDEOURL_PATTERN.matcher(url);
|
||||
if(match.find())
|
||||
return match.group(1);
|
||||
return null;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue