| | |
| | | import android.app.Notification; |
| | | import android.app.NotificationChannel; |
| | | import android.app.NotificationManager; |
| | | import android.content.ActivityNotFoundException; |
| | | import android.content.Intent; |
| | | import android.content.pm.ActivityInfo; |
| | | import android.content.res.Configuration; |
| | |
| | | import android.graphics.BitmapFactory; |
| | | import android.graphics.Color; |
| | | import android.graphics.PixelFormat; |
| | | import android.net.Uri; |
| | | import android.net.http.SslError; |
| | | import android.os.Build; |
| | | import android.os.Bundle; |
| | |
| | | import android.widget.TextView; |
| | | import android.widget.Toast; |
| | | |
| | | import com.androidquery.AQuery; |
| | | import com.lcjian.library.util.ManifestDataUtil; |
| | | import com.lcjian.library.util.common.ClipboardUtil; |
| | | import com.lcjian.library.util.common.StringUtils; |
| | | import com.umeng.analytics.MobclickAgent; |
| | | import com.weikou.beibeivideo.R; |
| | | import com.weikou.beibeivideo.ui.BaseActivity; |
| | | import com.weikou.beibeivideo.ui.media.VideoDetailActivity2; |
| | | import com.weikou.beibeivideo.util.ConfigUtil; |
| | | import com.weikou.beibeivideo.util.browser.BWJavaInterface; |
| | | import com.weikou.beibeivideo.util.downutil.DownFiles; |
| | | import com.weikou.beibeivideo.util.downutil.DownFiles.IProgress; |
| | | import com.weikou.beibeivideo.util.ui.TopStatusSettings; |
| | | import com.weikou.beibeivideo.widget.CustomWebView; |
| | | import com.yeshi.video.player.util.PlayerFullScreenUtil; |
| | | |
| | | import java.util.Set; |
| | | |
| | | public class VideoPlayerBrowserActivity extends BaseActivity implements OnClickListener { |
| | | |
| | |
| | | |
| | | private Runnable playerJSRunnable = null; |
| | | |
| | | private AQuery query; |
| | | |
| | | @Override |
| | | protected void onCreate(Bundle savedInstanceState) { |
| | | super.onCreate(savedInstanceState); |
| | | getWindow().setFormat(PixelFormat.TRANSLUCENT); |
| | | setContentView(R.layout.browser_fengxing_activity); |
| | | /* |
| | | * 计算状态栏高度并设置 |
| | | */ |
| | | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { |
| | | int result = 0; |
| | | int resourceId = getResources().getIdentifier("status_bar_height", |
| | | "dimen", "android"); |
| | | if (resourceId > 0) { |
| | | result = getResources().getDimensionPixelSize(resourceId); |
| | | } |
| | | LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, |
| | | result); |
| | | findViewById(R.id.v_status_bar).setLayoutParams(params); |
| | | } else { |
| | | findViewById(R.id.v_status_bar).setVisibility(View.GONE); |
| | | } |
| | | query = new AQuery(this); |
| | | TopStatusSettings.setStatusViewAndDeepColor(this); |
| | | |
| | | tv_top_bar_left = findViewById(R.id.tv_top_bar_left); |
| | | tv_url = findViewById(R.id.tv_url); |
| | | tv_title = findViewById(R.id.tv_title); |
| | | tv_right = findViewById(R.id.tv_right); |
| | | tv_right.setOnClickListener(this); |
| | | query.id(R.id.tv_more).clicked(this); |
| | | query.id(R.id.fl_menu).clicked(new OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | hiddenMenu(); |
| | | } |
| | | }); |
| | | |
| | | query.id(R.id.tv_refresh).clicked(new OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | hiddenMenu(); |
| | | webview.reload(); |
| | | } |
| | | }); |
| | | |
| | | query.id(R.id.tv_copy).clicked(new OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | hiddenMenu(); |
| | | ClipboardUtil.copy(getApplicationContext(), tv_url.getText().toString()); |
| | | Toast.makeText(VideoPlayerBrowserActivity.this, "复制成功", Toast.LENGTH_SHORT).show(); |
| | | } |
| | | }); |
| | | |
| | | query.id(R.id.tv_open).clicked(new OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | hiddenMenu(); |
| | | String url = tv_url.getText().toString(); |
| | | try { |
| | | Uri uri = Uri.parse(url); |
| | | Intent intent = new Intent(Intent.ACTION_VIEW, uri); |
| | | startActivity(intent); |
| | | } catch (ActivityNotFoundException e) { |
| | | Toast.makeText(VideoPlayerBrowserActivity.this, "无法找到浏览器", Toast.LENGTH_SHORT).show(); |
| | | } catch (Exception e) { |
| | | |
| | | } |
| | | } |
| | | }); |
| | | |
| | | |
| | | fl_webview = findViewById(R.id.fl_webview); |
| | |
| | | bundle.putString("DetailId", params[3]); |
| | | bundle.putString("Share", "0"); |
| | | bundle.putString("ThirdType", "0"); |
| | | intent.putExtra("from", "web"); |
| | | intent.putExtras(bundle); |
| | | startActivity(intent); |
| | | } |
| | | return true; |
| | | } else if (url.contains("/tbopen/") || url.startsWith("tbopen://")) { |
| | | return true; |
| | | } else if (!url.startsWith("http")) |
| | | } else if (!url.startsWith("http")) { |
| | | Set<String> prefixSet = ConfigUtil.getPlayerJumpOutProtocolPrefix(getApplicationContext()); |
| | | prefixSet.add("tenvideo2://"); |
| | | prefixSet.add("iqiyi://"); |
| | | prefixSet.add("youku://"); |
| | | prefixSet.add("imgotv://"); |
| | | |
| | | for (String prefix : prefixSet) { |
| | | if (url.startsWith(prefix)) { |
| | | try { |
| | | Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); |
| | | startActivity(intent); |
| | | } catch (Exception e) { |
| | | } |
| | | return true; |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | |
| | | return super.shouldOverrideUrlLoading(view, request); |
| | | } |
| | |
| | | public void onPageFinished(WebView webView, String s) { |
| | | super.onPageFinished(webView, s); |
| | | Log.i(TAG, "onPageFinished:" + s); |
| | | if (playerJSRunnable != null) |
| | | if (playerJSRunnable != null && webview != null) |
| | | webview.removeCallbacks(playerJSRunnable); |
| | | playerJSRunnable = new Runnable() { |
| | | @Override |
| | |
| | | } |
| | | } |
| | | }; |
| | | if (playerJSRunnable != null) |
| | | if (playerJSRunnable != null && webview != null) |
| | | webview.postDelayed(playerJSRunnable, 1000); |
| | | } |
| | | |
| | |
| | | public void onReceivedTitle(WebView view, String title) { |
| | | super.onReceivedTitle(view, title); |
| | | tv_title.setText(title); |
| | | tv_url.setText(view.getUrl()); |
| | | } |
| | | |
| | | /** |
| | |
| | | // loadHander.sendEmptyMessage(0); |
| | | String url = getIntent().getStringExtra("url"); |
| | | webview.loadUrl(url); |
| | | tv_url.setText(url); |
| | | } |
| | | |
| | | private void hiddenMenu() { |
| | | query.id(R.id.fl_menu).visibility(View.GONE); |
| | | } |
| | | |
| | | private void showMenu() { |
| | | query.id(R.id.fl_menu).visibility(View.VISIBLE); |
| | | } |
| | | |
| | | // 文件下载监听 |
| | |
| | | @Override |
| | | public void onResume() { |
| | | super.onResume(); |
| | | MobclickAgent.onPageStart("网页"); |
| | | } |
| | | |
| | | @Override |
| | | public void onPause() { |
| | | super.onPause(); |
| | | MobclickAgent.onPageEnd("网页"); |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | break; |
| | | case R.id.tv_right: { |
| | | setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); |
| | | findViewById(R.id.v_status_bar).setVisibility(View.GONE); |
| | | findViewById(R.id.top).setVisibility(View.GONE); |
| | | if (query.id(R.id.fl_menu).getView().getVisibility() == View.VISIBLE) |
| | | hiddenMenu(); |
| | | else |
| | | showMenu(); |
| | | } |
| | | break; |
| | | |
| | | default: |
| | | break; |
| | | } |