Added stopped and ended listeners to behaviours
This commit is contained in:
parent
b18e5cc649
commit
6216afd36b
3 changed files with 25 additions and 12 deletions
|
|
@ -40,9 +40,14 @@ public abstract class UeBehaviour implements Serializable{
|
|||
}
|
||||
execTime = System.currentTimeMillis() - startTime;
|
||||
|
||||
executor = null;
|
||||
if(execListener != null)
|
||||
execListener.executionStopped(execTime);
|
||||
|
||||
if(execListener != null) {
|
||||
if(!isRunning()) // Has execution been stopped prematurely
|
||||
execListener.executionStopped();
|
||||
else
|
||||
execListener.executionEnded(execTime);
|
||||
}
|
||||
terminate();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -113,7 +118,8 @@ public abstract class UeBehaviour implements Serializable{
|
|||
public static interface BehaviourExecutionListener {
|
||||
public void executionStarted();
|
||||
public void progressChanged(float progress);
|
||||
public void executionStopped(long executionTime);
|
||||
public void executionStopped();
|
||||
public void executionEnded(long executionTime);
|
||||
public void exception(Exception e);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,13 +32,11 @@ public class BehaviourListAdapter extends StableArrayAdapter<UeBehaviour>{
|
|||
|
||||
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
View vi = convertView;
|
||||
if(convertView==null)
|
||||
vi = inflater.inflate(VIEW_RESOURCE, null);
|
||||
final View vi = (convertView!=null ? convertView : inflater.inflate(VIEW_RESOURCE, null));
|
||||
|
||||
ImageView draggable = (ImageView)vi.findViewById(R.id.draggable);
|
||||
TextView title = (TextView)vi.findViewById(R.id.title);
|
||||
TextView description = (TextView)vi.findViewById(R.id.description);
|
||||
final ImageView draggable = (ImageView)vi.findViewById(R.id.draggable);
|
||||
final TextView title = (TextView)vi.findViewById(R.id.title);
|
||||
final TextView description = (TextView)vi.findViewById(R.id.description);
|
||||
final ImageView warning = (ImageView) vi.findViewById(R.id.warning);
|
||||
final ProgressBar active = (ProgressBar)vi.findViewById(R.id.active);
|
||||
final ProgressBar progress = (ProgressBar) vi.findViewById(R.id.progress);
|
||||
|
|
@ -60,6 +58,7 @@ public class BehaviourListAdapter extends StableArrayAdapter<UeBehaviour>{
|
|||
public void executionStarted() {
|
||||
progress.post(new Runnable() {
|
||||
public void run() {
|
||||
vi.setAlpha(1f);
|
||||
time.setVisibility(View.INVISIBLE);
|
||||
active.setVisibility(View.VISIBLE);
|
||||
progress.setVisibility(View.VISIBLE);
|
||||
|
|
@ -73,7 +72,15 @@ public class BehaviourListAdapter extends StableArrayAdapter<UeBehaviour>{
|
|||
executionStarted();
|
||||
progress.setProgress((int) (p * 100));
|
||||
}
|
||||
public void executionStopped(final long execTime) {
|
||||
public void executionStopped() {
|
||||
progress.post(new Runnable() {
|
||||
public void run() {
|
||||
active.setVisibility(View.INVISIBLE);
|
||||
vi.setAlpha(0.5f);
|
||||
}
|
||||
});
|
||||
}
|
||||
public void executionEnded(final long execTime) {
|
||||
progress.post(new Runnable() {
|
||||
public void run() {
|
||||
active.setVisibility(View.INVISIBLE);
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@
|
|||
|
||||
<ProgressBar
|
||||
android:id="@+id/progress"
|
||||
style="?android:attr/progressBarStyleHorizontal"
|
||||
style="@android:style/Widget.DeviceDefault.Light.ProgressBar.Horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/description"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue