@SuppressLint("Wakelock")
 @Override
 protected void onDestroy() {
   Trace.d(tag, "onDestroy");
   // 解决退出无法关闭声音
   mWebContent.loadUrl("about:blank");
   mHandler.removeCallbacks(runnable);
   super.onDestroy();
 }
示例#2
0
 @Override
 public void run() {
   Trace.d(tag, "refreshRunnable");
   mHandler.removeCallbacks(refreshRunnable);
   if (AppUtils.networkAvailable(getActivity())) {
     requestNewFeedRefresh();
   } else {
     mHandler.postDelayed(refreshRunnable, mRefreshRate);
   }
 }
 @TargetApi(Build.VERSION_CODES.HONEYCOMB)
 @Override
 protected void onPause() {
   super.onPause();
   MobclickAgent.onPause(this);
   mWebContent.onPause();
   if (mWakeLock != null) {
     try {
       if (mWakeLock.isHeld()) mWakeLock.release();
     } catch (Exception e) {
       Trace.d(tag, e.getMessage());
     }
   }
 }
  @TargetApi(Build.VERSION_CODES.HONEYCOMB)
  @Override
  protected void onResume() {
    super.onResume();
    MobclickAgent.onResume(this);
    AppService.onNewsResume();

    if (mWakeLock == null)
      mWakeLock =
          ((PowerManager) getSystemService(Context.POWER_SERVICE))
              .newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, getClass().getSimpleName());
    try {
      if (!mWakeLock.isHeld()) mWakeLock.acquire();
    } catch (Exception e) {
      Trace.d(tag, e.getMessage());
    }
  }
示例#5
0
 private void initFragment(Bundle savedInstanceState) {
   if (savedInstanceState == null) {
     FragmentTransaction ft = fMgr.beginTransaction();
     mFragment = mBaseNewsFragment = new BaseNewsFragment();
     // mFragment = new BaseTournamentFragment();
     // index = 1;
     initBottomButton();
     ft.replace(R.id.fragmentRoot, mFragment);
     ft.commitAllowingStateLoss();
   } else {
     List<Fragment> fragments = fMgr.getFragments();
     if (fragments == null || fragments.isEmpty()) {
       FragmentTransaction ft = fMgr.beginTransaction();
       mFragment = mBaseNewsFragment = new BaseNewsFragment();
       ft.replace(R.id.fragmentRoot, mFragment);
       ft.commitAllowingStateLoss();
     } else {
       index = savedInstanceState.getInt("INDEX");
       initBottomButton();
       FragmentTransaction ft = fMgr.beginTransaction();
       for (Fragment fragment : fragments) {
         if (fragment == null) {
           continue;
         } else if (fragment instanceof BaseNewsFragment && index == 0) {
           mFragment = mBaseNewsFragment = (BaseNewsFragment) fragment;
         } else if (fragment instanceof BaseTournamentFragment && index == 1) {
           mFragment = fragment;
         } else if (fragment instanceof FeedFragment && index == 2) {
           mFragment = mFeedFragment = (FeedFragment) fragment;
         } else if (fragment instanceof BaseGroupFragment && index == 3) {
           mFragment = fragment;
         } else if (fragment instanceof BaseStandingsFragment && index == 4) {
           mFragment = fragment;
         } else if (!(fragment instanceof LeftSlidingMenuFragment)) {
           ft.remove(fragment);
         }
       }
       if (mFragment != null) {
         ft.show(mFragment);
       }
       Trace.d(tag, "mFragment:" + mFragment);
       ft.commitAllowingStateLoss();
     }
   }
 }