-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
846425567
committed
Aug 1, 2015
1 parent
8b0280a
commit 53c61da
Showing
12 changed files
with
447 additions
and
200 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
42 changes: 42 additions & 0 deletions
42
src/main/java/cn/sdu/online/findteam/resource/FrameAnimationController.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,42 @@ | ||
package cn.sdu.online.findteam.resource; | ||
import android.os.Handler; | ||
import android.os.Message; | ||
|
||
public class FrameAnimationController { | ||
private static final int MSG_ANIMATE = 1000; | ||
|
||
public static final int ANIMATION_FRAME_DURATION = 1000 / 60; | ||
|
||
private static final Handler mHandler = new AnimationHandler(); | ||
|
||
private FrameAnimationController() { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
public static void requestAnimationFrame(Runnable runnable) { | ||
Message message = new Message(); | ||
message.what = MSG_ANIMATE; | ||
message.obj = runnable; | ||
mHandler.sendMessageDelayed(message, ANIMATION_FRAME_DURATION); | ||
} | ||
|
||
public static void requestFrameDelay(Runnable runnable, long delay) { | ||
Message message = new Message(); | ||
message.what = MSG_ANIMATE; | ||
message.obj = runnable; | ||
mHandler.sendMessageDelayed(message, delay); | ||
} | ||
|
||
private static class AnimationHandler extends Handler { | ||
public void handleMessage(Message m) { | ||
switch (m.what) { | ||
case MSG_ANIMATE: | ||
if (m.obj != null) { | ||
((Runnable) m.obj).run(); | ||
} | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
|
Oops, something went wrong.