package com.ubt.jimu.widgets.player; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.graphics.Bitmap; import android.graphics.drawable.BitmapDrawable; import android.os.Bundle; import android.text.TextUtils; import android.view.View; import android.view.ViewStub; import android.widget.ImageView; import android.widget.TextView; import com.ubt.jimu.R; import com.ubt.jimu.ScreenRotationManageActivity; import com.ubt.jimu.base.entities.Constant; import com.ubt.jimu.utils.BitmapUtils; import com.ubt.jimu.utils.LogUtils; import com.ubt.jimu.widgets.player.UbtPlayerView; /* loaded from: classes2.dex */ public class UbtPlayer extends ScreenRotationManageActivity implements UbtPlayerView.VideoErrorListener, View.OnClickListener { private UbtPlayerView a; private View b; private ViewStub c; private View d; private ImageView e; private ImageView f; private boolean g; private String h = ""; private void initData() { Intent intent = getIntent(); this.h = intent.getStringExtra(Constant.Publish.VIDEO_PATH_KEY); String stringExtra = intent.getStringExtra(Constant.Publish.VIDEO_TITLE_KEY); this.g = intent.getBooleanExtra(Constant.Publish.IS_SHOW_CONFIRM_KEY, false); this.f.setVisibility(this.g ? 0 : 8); if (!TextUtils.isEmpty(stringExtra)) { this.a.setTitle(stringExtra); } LogUtils.c("视频播放路径:" + this.h); if (TextUtils.isEmpty(this.h)) { return; } this.a.setVideoPath(this.h); this.a.f(); LogUtils.c("设置视频路径:" + this.h); } private void initView() { this.a = (UbtPlayerView) findViewById(R.id.ubt_player); this.c = (ViewStub) findViewById(R.id.vs_load_failure); this.e = (ImageView) findViewById(R.id.im_back); this.f = (ImageView) findViewById(R.id.im_publish_confirm); this.a.setVideoErrorListener(this); this.e.setOnClickListener(this); this.f.setOnClickListener(this); } @Override // com.ubt.jimu.widgets.player.UbtPlayerView.VideoErrorListener public void j(final int i) { LogUtils.c("视频播放失败errorCode:" + i); this.a.post(new Runnable() { // from class: com.ubt.jimu.widgets.player.UbtPlayer.1 @Override // java.lang.Runnable public void run() { UbtPlayer ubtPlayer = UbtPlayer.this; Bitmap a = BitmapUtils.a(ubtPlayer, ubtPlayer.b); if (UbtPlayer.this.d == null) { UbtPlayer ubtPlayer2 = UbtPlayer.this; ubtPlayer2.d = ubtPlayer2.c.inflate(); UbtPlayer.this.d.setOnClickListener(UbtPlayer.this); } else { UbtPlayer.this.d.setVisibility(0); } ImageView imageView = (ImageView) UbtPlayer.this.d.findViewById(R.id.im_error_icon); TextView textView = (TextView) UbtPlayer.this.d.findViewById(R.id.tv_load_failed_hint); imageView.setOnClickListener(UbtPlayer.this); if (a != null) { new BitmapDrawable(a); UbtPlayer.this.d.setBackgroundColor(UbtPlayer.this.getResources().getColor(R.color.video_error_shade)); } int i2 = i; if (i2 == -10000) { imageView.setBackgroundResource(R.drawable.ic_network_error); textView.setText(R.string.video_network_error); } else { if (i2 != 12345) { return; } imageView.setBackgroundResource(R.drawable.community_bg_content); textView.setText(R.string.video_failed); } } }); } @Override // android.view.View.OnClickListener public void onClick(View view) { int id = view.getId(); if (id == R.id.im_back) { if (this.g) { c(0, this.h); return; } else { finish(); return; } } if (id != R.id.im_error_icon) { if (id != R.id.im_publish_confirm) { return; } c(-1, this.h); return; } View view2 = this.d; if (view2 != null) { view2.setVisibility(8); } UbtPlayerView ubtPlayerView = this.a; if (ubtPlayerView != null) { ubtPlayerView.getCurrentPosition(); this.a.e(); } } @Override // com.ubt.jimu.ScreenRotationManageActivity, androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity, androidx.core.app.ComponentActivity, android.app.Activity protected void onCreate(Bundle bundle) { super.onCreate(bundle); requestWindowFeature(1); getWindow().requestFeature(12); this.b = View.inflate(this, R.layout.activity_ubtplayer, null); setContentView(this.b); initView(); initData(); } @Override // com.ubt.jimu.ScreenRotationManageActivity, androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity, android.app.Activity protected void onDestroy() { super.onDestroy(); this.a.g(); } @Override // com.ubt.jimu.ScreenRotationManageActivity, androidx.fragment.app.FragmentActivity, android.app.Activity protected void onPause() { super.onPause(); this.a.b(); } @Override // android.app.Activity protected void onRestart() { super.onRestart(); this.a.c(); } @Override // com.ubt.jimu.ScreenRotationManageActivity, androidx.fragment.app.FragmentActivity, android.app.Activity protected void onResume() { super.onResume(); this.a.d(); } private void c(int i, String str) { Intent intent = new Intent(); intent.putExtra("url", str); setResult(i, intent); this.a.g(); finish(); } public static void a(Context context, String str, String str2) { Intent intent = new Intent(context, (Class) UbtPlayer.class); intent.putExtra(Constant.Publish.VIDEO_PATH_KEY, str2); intent.putExtra(Constant.Publish.VIDEO_TITLE_KEY, str); context.startActivity(intent); } public static void a(Activity activity, int i, String str, String str2, boolean z) { Intent intent = new Intent(activity, (Class) UbtPlayer.class); intent.putExtra(Constant.Publish.VIDEO_PATH_KEY, str2); intent.putExtra(Constant.Publish.VIDEO_TITLE_KEY, str); intent.putExtra(Constant.Publish.IS_SHOW_CONFIRM_KEY, z); activity.startActivityForResult(intent, i); } }