@Override
        public void callback(final MediaPlayer player, final String url) {
          Trace.e(tag, "callback:" + url);
          if (init) {
            init = false;
            if (!TextUtils.isEmpty(url)) {
              mUrl = url;
            }
            mHandler.removeCallbacks(runnable);
            mHandler.postDelayed(runnable, 800);
            return;
          }
          mHandler.removeCallbacks(runnable);
          if (!TextUtils.isEmpty(url) && player != null && (mUrl == null || !mUrl.equals(url))) {
            mUrl = url;
            player.reset();

            Intent intent = VideoActivity.getIntent(context, mUrl, title);
            intent.putExtra(IS_FROM_PLAYER_ON_LINE_VIDEO_ACTIVITY, true);
            startActivityForResult(intent, REQUEST_PLAYER_ONLINE_VIDEO_ACTIVITY);
            finish();
          } else {
            mHandler.postDelayed(runnable, 800);
          }
        }
 @Override
 public void onLoadResource(WebView view, String url) {
   Trace.e(tag, "onLoadResource  =  " + url);
   if (!isFromVideoActivity) {
     playVideo(url);
   }
   super.onLoadResource(view, url);
 }
Esempio n. 3
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    AppUtils.switchLanguage(getApplicationContext());
    exitWithUserOption = false;
    EventBus.getDefault().register(this);
    initSlidingMenu();
    setContentView(R.layout.activity_main);
    Trace.e(tag, getString(R.string.lang));
    fMgr = getSupportFragmentManager();
    imageLoader = BaseApplication.getImageLoader(this);
    options =
        new DisplayImageOptions.Builder()
            .bitmapConfig(Bitmap.Config.RGB_565)
            .showStubImage(R.drawable.tab_center_normal)
            .showImageForEmptyUri(R.drawable.tab_center_normal)
            .showImageOnFail(R.drawable.tab_center_normal)
            .cacheInMemory(true)
            .cacheOnDisc(true)
            .build();
    if (AppUtils.isLogin(this)) majorTeamGsonModel = AppSharePreferences.getMajorTeam(this);
    mTitleView = (TitleView) findViewById(R.id.titlebar_layout);
    mTitleView.initTitleBar(null, 0, 0);
    mTitleView.setRightMenuButton();
    mTitleView.setTitleViewListener(mTitleViewListener);
    dealBottomButtonsClickEvent();
    initFragment(savedInstanceState);
    if (majorTeamGsonModel != null && !TextUtils.isEmpty(majorTeamGsonModel.avatar)) {
      File file = DiskCacheUtils.findInCache(majorTeamGsonModel.avatar, imageLoader.getDiskCache());
      if (file == null || !file.exists()) {
        imageLoader.displayImage(majorTeamGsonModel.avatar, majorImageView, options);
      } else {
        majorImageView.setImageBitmap(BitmapFactory.decodeFile(file.getAbsolutePath()));
      }
    } else {
      if (AppSharePreferences.getFollowFlag(getApplicationContext())) {
        majorImageView.setImageResource(R.drawable.tab_center_notset_normal);
      } else {
        majorImageView.setImageResource(R.drawable.tab_center_normal);
      }
    }

    mWindowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE);

    AppService.startCheckVersion(this, false);
    mDownloadReceiver = new DownloadCompleteReceiver();
    registerReceiver(mDownloadReceiver, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
    FeedbackAgent agent = new FeedbackAgent(this);
    agent.sync();

    /*
     * if
     * (AppSharePreferences.getDefault().getBoolean("MAIN_TOURNAMENT_GUIDE",
     * true)) { startActivity(new Intent(MainActivity.this,
     * GuideActivity.class)); }
     */

  }
 private void playVideo(String url) {
   if ("youku".equalsIgnoreCase(type) && matchOnLiveVideoUrl(url)) {
     Intent intent = VideoActivity.getIntent(this, url, title);
     intent.putExtra(IS_FROM_PLAYER_ON_LINE_VIDEO_ACTIVITY, true);
     startActivityForResult(intent, REQUEST_PLAYER_ONLINE_VIDEO_ACTIVITY);
     this.finish();
   } else if (matchOnLiveVideoUrl(url)) {
     Trace.e("video", "startActivity...");
     Intent intent = VideoActivity.getIntent(this, url, title);
     intent.putExtra(IS_FROM_PLAYER_ON_LINE_VIDEO_ACTIVITY, true);
     startActivityForResult(intent, REQUEST_PLAYER_ONLINE_VIDEO_ACTIVITY);
     this.finish();
   }
 }
 @TargetApi(Build.VERSION_CODES.HONEYCOMB)
 @Override
 public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
   Trace.e(tag, "shouldInterceptRequest:" + url);
   WebResourceResponse webResourceResponse = null;
   try {
     if (url.startsWith("http://mf.atm.youku.com/")
         || url.startsWith("https://mf.atm.youku.com/")) {
       String s = "{\"SKIP\":1,\"P\":7,\"BAK\":[{}],\"VAL\":[]}";
       webResourceResponse =
           new WebResourceResponse(
               "application/json", "UTF-8", new ByteArrayInputStream(s.getBytes()));
     } else if (url.startsWith("http://api.letv.com/mms/out/video/")) {
       String s = "{\"SKIP\":1,\"P\":7,\"BAK\":[{}],\"VAL\":[]}";
       webResourceResponse =
           new WebResourceResponse(
               "application/json", "UTF-8", new ByteArrayInputStream(s.getBytes()));
     }
   } catch (Exception e) {
     Trace.e(tag, e.getMessage().toString());
   }
   return webResourceResponse;
 }
Esempio n. 6
0
  @Override
  protected void onDestroy() {
    Trace.e("MainActivity", "onDestroy");
    EventBus.getDefault().unregister(this);
    BaseApplication.setMainActivityState(BaseApplication.FLAG_MAIN_STATE_NOMAL);

    unregisterReceiver(mDownloadReceiver);
    if (exitWithUserOption) {
      MobclickAgent.onKillProcess(this);
      WebviewService.exit(this);
      System.exit(0);
    }
    super.onDestroy();
  }
 @Override
 public void onProgressChanged(WebView view, int newProgress) {
   Trace.e(tag, "onProgressChanged:" + newProgress);
   if (progressDrawable != null) progressDrawable.setProgress((newProgress * 1.0f) / 100f);
   super.onProgressChanged(view, newProgress);
 }