Skip to content

Commit

Permalink
Fixed: NetEase#33 app crashed when move the floating window after sto…
Browse files Browse the repository at this point in the history
…p test
  • Loading branch information
andrewleo committed Dec 31, 2014
1 parent 8d1cba6 commit f24c641
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/com/netease/qa/emmagee/service/EmmageeService.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public class EmmageeService extends Service {
private final static String LOG_TAG = "Emmagee-" + EmmageeService.class.getSimpleName();

private static final String BLANK_STRING = "";

private WindowManager windowManager = null;
private WindowManager.LayoutParams wmParams = null;
private View viFloatingWindow;
Expand Down Expand Up @@ -354,7 +354,7 @@ public void run() {
if (!isServiceStop) {
dataRefresh();
handler.postDelayed(this, delaytime);
if (isFloating) {
if (isFloating && viFloatingWindow != null) {
windowManager.updateViewLayout(viFloatingWindow, wmParams);
}
// get app start time from logcat on every task running
Expand Down Expand Up @@ -484,7 +484,9 @@ private void dataRefresh() {
private void updateViewPosition() {
wmParams.x = (int) (x - mTouchStartX);
wmParams.y = (int) (y - mTouchStartY);
windowManager.updateViewLayout(viFloatingWindow, wmParams);
if (viFloatingWindow != null) {
windowManager.updateViewLayout(viFloatingWindow, wmParams);
}
}

/**
Expand All @@ -509,8 +511,10 @@ public void closeOpenedStream() {
@Override
public void onDestroy() {
Log.i(LOG_TAG, "service onDestroy");
if (windowManager != null)
if (windowManager != null) {
windowManager.removeView(viFloatingWindow);
viFloatingWindow = null;
}
handler.removeCallbacks(task);
closeOpenedStream();
// replace the start time in file
Expand Down

0 comments on commit f24c641

Please sign in to comment.