-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added option to delay handling onclick events in activities (see #106)
- Loading branch information
Showing
18 changed files
with
193 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
.../src/main/java/org/cmucreatelab/android/flutterprek/activities/DelayedOnClickHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package org.cmucreatelab.android.flutterprek.activities; | ||
|
||
import org.cmucreatelab.android.flutterprek.BackgroundTimer; | ||
|
||
/** | ||
* Handles timer for setting the onclick listeners for an activity. | ||
*/ | ||
public class DelayedOnClickHandler implements BackgroundTimer.TimeExpireListener { | ||
|
||
private static final long SET_ONCLICK_LISTENER_DELAY_IN_MILLISECONDS = 1000; | ||
|
||
private final BackgroundTimer backgroundTimer; | ||
private final AbstractActivity activity; | ||
private boolean delayIsFinished = false; | ||
|
||
|
||
public DelayedOnClickHandler(AbstractActivity activity) { | ||
this.activity = activity; | ||
backgroundTimer = new BackgroundTimer(SET_ONCLICK_LISTENER_DELAY_IN_MILLISECONDS, this); | ||
} | ||
|
||
|
||
public void onResumeActivity() { | ||
delayIsFinished = false; | ||
backgroundTimer.startTimer(); | ||
} | ||
|
||
|
||
public void onPauseActivity() { | ||
backgroundTimer.stopTimer(); | ||
delayIsFinished = false; | ||
} | ||
|
||
|
||
public boolean delayIsFinished() { | ||
return delayIsFinished; | ||
} | ||
|
||
|
||
@Override | ||
public void timerExpired() { | ||
delayIsFinished = true; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.