| | |
| | | import android.net.ConnectivityManager; |
| | | import android.net.NetworkInfo; |
| | | import android.os.Bundle; |
| | | |
| | | import androidx.core.content.ContextCompat; |
| | | |
| | | import android.telephony.TelephonyManager; |
| | | import android.text.Html; |
| | | import android.widget.Toast; |
| | |
| | | private void getUpdateInfo() { |
| | | TelephonyManager manager = (TelephonyManager) mActivity |
| | | .getSystemService(Activity.TELEPHONY_SERVICE); |
| | | String deviceId=""; |
| | | String deviceId = ""; |
| | | if (ContextCompat.checkSelfPermission(mActivity, android.Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_GRANTED |
| | | || ContextCompat.checkSelfPermission(mActivity, android.Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_GRANTED) { |
| | | deviceId = manager.getDeviceId();// 获取deviceId |
| | | try { |
| | | deviceId = manager.getDeviceId();// 获取deviceId |
| | | } catch (Exception e) { |
| | | deviceId = ""; |
| | | } |
| | | } |
| | | int versionCode = 1;// 版本号 |
| | | int versionCode = 1;// 版本号 |
| | | try { |
| | | versionCode = mActivity.getPackageManager().getPackageInfo( |
| | | mActivity.getPackageName(), |
| | |
| | | } |
| | | defaultConfig { |
| | | applicationId "com.hanju.video" |
| | | versionCode 102 |
| | | versionName "2.0.6" |
| | | versionCode 104 |
| | | versionName "2.0.8" |
| | | multiDexEnabled = true |
| | | minSdkVersion 19 |
| | | targetSdkVersion 29 |
| | |
| | | abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64' |
| | | } |
| | | //爱韩剧 |
| | | resValue "string", "app_name", "爱韩剧播放器" |
| | | manifestPlaceholders = [app_icon : "@drawable/ic_launcher_1", |
| | | resValue "string", "app_name", "韩剧播放器" |
| | | manifestPlaceholders = [app_icon : "@drawable/ic_launcher", |
| | | JPUSH_PKGNAME: applicationId, |
| | | JPUSH_APPKEY : "461d3e0c6adb0a188e82408f", //JPush 上注册的包名对应的 Appkey. |
| | | JPUSH_CHANNEL: "developer-default", //暂时填写默认值即可. |
| | |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="center_vertical" |
| | | android:drawableLeft="@drawable/ic_back" |
| | | android:layout_marginLeft="11dp" |
| | | android:drawableLeft="@drawable/ic_login_close" |
| | | android:drawablePadding="3dp" |
| | | android:gravity="center_vertical" |
| | | android:padding="8dp" |
| | | android:text="返回" |
| | | android:textColor="@color/white" |
| | | android:textSize="16sp" /> |
| | | |
| | |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:text="注册帐号" |
| | | android:textColor="#FFFFFF" |
| | | android:textColor="@color/theme" |
| | | android:textSize="12sp" /> |
| | | |
| | | |
| | |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="right" |
| | | android:text="忘记密码" |
| | | android:textColor="#FFFFFF" |
| | | android:textColor="@color/theme" |
| | | android:textSize="12sp" /> |
| | | |
| | | </FrameLayout> |
| | |
| | | xmlns:app="http://schemas.android.com/apk/res-auto" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent" |
| | | android:background="@color/white" |
| | | android:background="@color/theme" |
| | | android:orientation="vertical"> |
| | | |
| | | <!-- <View--> |
| | |
| | | android:orientation="vertical" |
| | | android:layout_height="match_parent"> |
| | | <View |
| | | android:id="@+id/view_statusbar" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="@dimen/statusbar_view_height"></View> |
| | | |
| | |
| | | |
| | | |
| | | <com.google.android.material.appbar.AppBarLayout |
| | | app:elevation="0dp" |
| | | android:id="@+id/abl_recommend" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content"> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent"> |
| | | |
| | | <FrameLayout |
| | | android:id="@+id/fl_container" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent"> |
| | | |
| | | <com.hanju.video.app.util.x5web.X5WebView |
| | | android:id="@+id/webview" |
| | | android:layout_width="fill_parent" |
| | | android:layout_height="fill_parent" /> |
| | | |
| | | </FrameLayout> |
| | | |
| | | |
| | | <ImageView |
| | | android:id="@+id/iv_back" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_margin="10dp" |
| | | android:src="@drawable/ic_back_two"></ImageView> |
| | | |
| | | |
| | | </FrameLayout> |
| | |
| | | android:orientation="vertical"> |
| | | |
| | | <RelativeLayout |
| | | android:visibility="gone" |
| | | android:id="@+id/rl_title_item" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | |
| | | android:src="@drawable/ic_title_spread" /> |
| | | |
| | | <TextView |
| | | android:visibility="gone" |
| | | android:id="@+id/tv_category_name" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_centerVertical="true" |
| | | android:layout_toRightOf="@id/tv_category_icon" |
| | | android:text="推广" |
| | | android:textColor="#DDDDDD" |
| | | android:textSize="18sp" /> |
| | | android:textColor="#FF222222" |
| | | android:textSize="15sp" /> |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_category_name2" |
| | |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_centerVertical="true" |
| | | android:layout_marginLeft="10dp" |
| | | android:layout_toRightOf="@id/tv_category_name" |
| | | android:drawableLeft="@drawable/recommend_left" |
| | | android:visibility="gone" /> |
| | |
| | | android:id="@+id/fl_ad" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:background="@color/white" |
| | | android:layout_marginLeft="3dp" |
| | | android:layout_marginRight="3dp"> |
| | | android:background="@color/white"> |
| | | |
| | | </FrameLayout> |
| | | |
| | |
| | | android:layout_weight="95" |
| | | app:ratio="1.38"> |
| | | |
| | | <FrameLayout |
| | | <androidx.cardview.widget.CardView |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent"> |
| | | android:layout_height="match_parent" |
| | | app:cardCornerRadius="6dp"> |
| | | |
| | | <ImageView |
| | | android:id="@+id/iv_picture" |
| | | <FrameLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent" |
| | | android:scaleType="centerCrop"></ImageView> |
| | | android:layout_height="match_parent"> |
| | | |
| | | </FrameLayout> |
| | | <ImageView |
| | | android:id="@+id/iv_picture" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent" |
| | | android:scaleType="centerCrop"></ImageView> |
| | | |
| | | </FrameLayout> |
| | | |
| | | </androidx.cardview.widget.CardView> |
| | | |
| | | </com.hanju.lib.library.widget.RatioLayout> |
| | | |
| | |
| | | android:layout_height="0dp" |
| | | android:layout_weight="1"></View> |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_play" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:background="@drawable/shape_video_search_result_album_play" |
| | | android:paddingLeft="10dp" |
| | | android:paddingTop="6dp" |
| | | android:paddingRight="10dp" |
| | | android:paddingBottom="6dp" |
| | | android:text="立即播放" |
| | | android:textColor="@color/white" |
| | | android:textSize="12sp" /> |
| | | <FrameLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content"> |
| | | |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_play" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="30dp" |
| | | android:layout_gravity="right" |
| | | android:background="@drawable/shape_video_search_result_album_play" |
| | | android:paddingLeft="30dp" |
| | | android:paddingTop="6dp" |
| | | android:paddingRight="30dp" |
| | | android:paddingBottom="6dp" |
| | | android:text="立即观看" |
| | | android:textColor="@color/white" |
| | | android:textSize="12sp" /> |
| | | |
| | | </FrameLayout> |
| | | |
| | | |
| | | </LinearLayout> |
| | |
| | | <LinearLayout |
| | | android:id="@+id/ll_videos" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="30dp" |
| | | android:layout_height="41dp" |
| | | android:layout_marginTop="8dp"> |
| | | |
| | | <TextView |
| | |
| | | android:layout_weight="120" |
| | | app:ratio="0.6667"> |
| | | |
| | | <ImageView |
| | | android:id="@+id/iv_movie_cover" |
| | | <androidx.cardview.widget.CardView |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent" |
| | | android:layout_alignParentStart="true" |
| | | android:layout_alignParentLeft="true" |
| | | android:scaleType="centerCrop" /> |
| | | app:cardCornerRadius="6dp"> |
| | | |
| | | <ImageView |
| | | android:id="@+id/iv_movie_cover" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent" |
| | | android:layout_alignParentStart="true" |
| | | android:layout_alignParentLeft="true" |
| | | android:scaleType="centerCrop" /> |
| | | </androidx.cardview.widget.CardView> |
| | | |
| | | </com.hanju.lib.library.widget.RatioLayout> |
| | | |
| | |
| | | android:layout_height="48dp" |
| | | android:background="@color/theme" |
| | | android:gravity="center" |
| | | android:paddingLeft="25dp" |
| | | android:text="我的" |
| | | android:textColor="#ffffffff" |
| | | android:textSize="20sp"> |
| | |
| | | android:layout_alignParentRight="true" |
| | | android:layout_centerVertical="true" |
| | | android:layout_marginRight="5dp" |
| | | android:padding="8dp" /> |
| | | android:padding="8dp" |
| | | android:textColor="@color/page_title_text_color" /> |
| | | </RelativeLayout> |
| | | |
| | | </LinearLayout> |
| | |
| | | android:paddingRight="18dp" |
| | | android:text="取消" |
| | | android:textColor="@color/theme" |
| | | android:textSize="12sp"></TextView> |
| | | android:textSize="14sp"></TextView> |
| | | |
| | | </LinearLayout> |
| | | </LinearLayout> |
| | |
| | | android:layout_weight="1" |
| | | android:background="@null" |
| | | android:completionThreshold="1" |
| | | android:textColor="#333333" |
| | | android:textColor="#FF787878" |
| | | android:hint="请输入搜索内容" |
| | | android:imeOptions="actionSearch" |
| | | android:textColorHint="#FF787878" |
| | | android:inputType="text" |
| | | android:padding="5dp" |
| | | android:textAppearance="?android:attr/textAppearance" |
| | | android:textCursorDrawable="@null" |
| | | android:textCursorDrawable="@color/theme" |
| | | android:textSize="12sp" /> |
| | | |
| | | </LinearLayout> |
| | |
| | | android:paddingRight="18dp" |
| | | android:text="取消" |
| | | android:textColor="@color/theme" |
| | | android:textSize="12sp"></TextView> |
| | | android:textSize="14sp"></TextView> |
| | | |
| | | </LinearLayout> |
| | | |
| | |
| | | import com.hanju.video.app.util.HanJuConstant; |
| | | import com.hanju.video.app.util.UserUtil; |
| | | import com.hanju.video.app.util.ad.AdUtil; |
| | | import com.hanju.video.app.util.ad.GDTADConstant; |
| | | import com.hanju.video.app.util.ad.TTAdManagerHolder; |
| | | import com.hanju.video.app.util.common.AppConfigUtil; |
| | | import com.hanju.video.app.util.common.CrashHandler; |
| | |
| | | protected Dialog loadingDialog; |
| | | |
| | | //显示加载 |
| | | public void showLoading() { |
| | | protected void showLoading() { |
| | | if (loadingDialog != null && !loadingDialog.isShowing()) { |
| | | loadingDialog.show(); |
| | | } |
| | | } |
| | | |
| | | //隐藏加载 |
| | | public void hideLoading() { |
| | | protected void hideLoading() { |
| | | if (loadingDialog != null && loadingDialog.isShowing()) { |
| | | loadingDialog.dismiss(); |
| | | } |
| | |
| | | super.onFailure(statusCode, headers, responseString, throwable); |
| | | SingleToast.showToast(ForgetPwdActivity.this, "修改密码失败"); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void onStart() { |
| | | super.onStart(); |
| | | showLoading(); |
| | | } |
| | | |
| | | @Override |
| | | public void onFinish() { |
| | | super.onFinish(); |
| | | hideLoading(); |
| | | } |
| | | }); |
| | | } |
| | | |
| | |
| | | handler.sendEmptyMessage(1); |
| | | } |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void onStart() { |
| | | super.onStart(); |
| | | showLoading(); |
| | | } |
| | | |
| | | @Override |
| | | public void onFinish() { |
| | | super.onFinish(); |
| | | hideLoading(); |
| | | } |
| | | }); |
| | | } |
| | | |
| | |
| | | |
| | | public class LoginActivity extends BaseActivity implements OnClickListener { |
| | | public static final int RESULT_LOGIN = 10; |
| | | private ProgressDialog dialog; |
| | | private TextView tv_cancel;// 取消 |
| | | private boolean isTouchLogin;// 用户是否点击登录 |
| | | private String uid; |
| | |
| | | |
| | | tv_cancel.setOnClickListener(this); |
| | | |
| | | dialog = new ProgressDialog(this); |
| | | ll_login_content = findViewById(R.id.ll_login_content); |
| | | |
| | | int w = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); |
| | |
| | | SingleToast.showToast(this, "开始登录了"); |
| | | HttpApiUtil.emailLogin(this, uid, name, pwd, new BasicTextHttpResponseHandler() { |
| | | @Override |
| | | public void onStart() { |
| | | super.onStart(); |
| | | showLoading(); |
| | | } |
| | | |
| | | @Override |
| | | public void onFinish() { |
| | | super.onFinish(); |
| | | hideLoading(); |
| | | } |
| | | |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception { |
| | | if (jsonObject.optBoolean("IsPost")) { |
| | | Log.i("mResult", "登录后返回的值为:" + jsonObject.toString()); |
| | |
| | | edit.commit(); |
| | | UserUtil.loginSuccess(getApplicationContext(), jsonObject.getJSONObject("Data") |
| | | .getString("Id")); |
| | | SingleToast.showToast(LoginActivity.this, "登录成功" + "昵称为:" + jsonObject.optJSONObject("Data").optString("Nickname")); |
| | | finish(); |
| | | } else { |
| | | SingleToast.showToast(LoginActivity.this, "登录失败"); |
| | | SingleToast.showToast(LoginActivity.this, jsonObject.optString("Error")); |
| | | } |
| | | } |
| | | |
| | |
| | | response.getString("figureurl_qq_2"), |
| | | response.getString("gender"), response.getString("province"), response.getString("city"), loginType, |
| | | new BasicTextHttpResponseHandler() { |
| | | |
| | | @Override |
| | | public void onStart() { |
| | | super.onStart(); |
| | | showLoading(); |
| | | } |
| | | |
| | | @Override |
| | | public void onFinish() { |
| | | super.onFinish(); |
| | | hideLoading(); |
| | | } |
| | | |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, |
| | | Header[] headers, JSONObject jsonObject) |
| | |
| | | // Log.i("mResult", "上传数据到服务器成功!"); |
| | | } |
| | | |
| | | @Override |
| | | public void onFinish() { |
| | | super.onFinish(); |
| | | dialog.dismiss(); |
| | | } |
| | | }); |
| | | } catch (JSONException e) { |
| | | e.printStackTrace(); |
| | |
| | | import com.hanju.video.app.ui.dialog.InputTextDialog; |
| | | import com.hanju.video.app.ui.mine.BrowserActivity; |
| | | import com.hanju.video.app.util.HanJuConstant; |
| | | import com.hanju.video.app.util.UserUtil; |
| | | import com.hanju.video.app.util.common.PhotoCrop; |
| | | import com.hanju.video.app.util.http.BasicTextHttpResponseHandler; |
| | | import com.hanju.video.app.util.http.HttpApiUtil; |
| | | import com.hanju.video.app.util.ui.GlideCircleTransform; |
| | | import com.hanju.video.app.util.ui.StatusBarUtil; |
| | | import com.hanju.video.app.util.ui.SystemClipImageUtil; |
| | | import com.hanju.video.app.util.ui.TopBarUtil; |
| | | |
| | | import org.apache.http.Header; |
| | |
| | | import java.io.ByteArrayInputStream; |
| | | import java.io.ByteArrayOutputStream; |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.io.FileNotFoundException; |
| | | import java.io.FileOutputStream; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.util.Calendar; |
| | | |
| | | import androidx.core.app.ActivityCompat; |
| | |
| | | */ |
| | | |
| | | public class PersonInfoActivity extends BaseActivity implements View.OnClickListener { |
| | | |
| | | private static final String TAG = "PersonInfoActivity"; |
| | | |
| | | private LinearLayout ll_portrait; |
| | | private LinearLayout ll_nickName; |
| | |
| | | |
| | | private AQuery mAQuery; |
| | | |
| | | |
| | | @Override |
| | | protected void onCreate(Bundle arg0) { |
| | | super.onCreate(arg0); |
| | | setContentView(R.layout.activity_person_info); |
| | | StatusBarUtil.init(this); |
| | | |
| | | |
| | | if (StringUtils.isEmpty(UserUtil.getLoginUid(this))) { |
| | | Toast.makeText(getApplicationContext(), "请先登录", Toast.LENGTH_SHORT).show(); |
| | | finish(); |
| | | return; |
| | | } |
| | | |
| | | TopBarUtil.init(this, "个人信息", this); |
| | | mAQuery = new AQuery(this); |
| | | tv_top_bar_right = findViewById(R.id.tv_top_bar_right); |
| | |
| | | startPhotoZoom(selectedImage);//系统剪裁 |
| | | } else if (requestCode == 1002 && data != null) { |
| | | if (uriClipUri != null) { |
| | | //图库 |
| | | PhotoCrop crop = new PhotoCrop();//初始化 图片压缩 |
| | | File f = new File(uriClipUri.getPath());//获取图片 |
| | | Bitmap bitmap = crop.compressPhto(f); |
| | | if (crop.compressPhto(f, false)) {//压缩并保存成功 |
| | | Toast.makeText(getApplicationContext(), "压缩保存成功", Toast.LENGTH_SHORT).show(); |
| | | if (bitmap != null) { |
| | | if (bitmap.getByteCount() / 1024 > maxSize) { |
| | | bitmap = compressImage(bitmap); |
| | | } |
| | | String path = saveBitmapTofile(bitmap); |
| | | final File file = new File(path); |
| | | if (!file.exists()) { |
| | | return; |
| | | } |
| | | imgBase64 = bitmapToBase64(bitmap); |
| | | Log.i("mresult", "图片路劲为:" + path + "----requestcode:" + requestCode); |
| | | Glide.with(PersonInfoActivity.this).load(file).transform(new GlideCircleTransform(PersonInfoActivity.this)).into(iv_portrait); |
| | | String path = ""; |
| | | if (!StringUtils.isEmpty(uriClipUri.getAuthority())) { |
| | | try { |
| | | imgBase64 = bitmapToBase64(getContentResolver().openInputStream(uriClipUri)); |
| | | Glide.with(PersonInfoActivity.this).load(uriClipUri).transform(new GlideCircleTransform(PersonInfoActivity.this)).into(iv_portrait); |
| | | } catch (FileNotFoundException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } else { |
| | | path = uriClipUri.getPath(); |
| | | //图库 |
| | | PhotoCrop crop = new PhotoCrop();//初始化 图片压缩 |
| | | File f = new File(path);//获取图片 |
| | | if (crop.compressPhto(f, false)) {//压缩并保存成功 |
| | | imgBase64 = bitmapToBase64(f); |
| | | } |
| | | |
| | | iv_portrait.postDelayed(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | Glide.with(PersonInfoActivity.this).load(uriClipUri).transform(new GlideCircleTransform(PersonInfoActivity.this)).into(iv_portrait); |
| | | } |
| | | }, 200); |
| | | } |
| | | } |
| | | } |
| | |
| | | * @param uri |
| | | */ |
| | | public void startPhotoZoom(Uri uri) { |
| | | File storageDir = new File(android.os.Environment.getExternalStorageDirectory().getPath() + "/FLQImg/"); |
| | | File storageDir = new File(android.os.Environment.getExternalStorageDirectory().getPath() + "/HanJuImg/"); |
| | | if (!storageDir.exists()) {//没有文件夹则创建 |
| | | storageDir.mkdir(); |
| | | } |
| | | //com.android.camera.action.CROP,这个action是调用系统自带的图片裁切功能 |
| | | Intent intent = new Intent("com.android.camera.action.CROP"); |
| | | intent.setDataAndType(uri, "image/*");//裁剪的图片uri和图片类型 |
| | | intent.putExtra("crop", "true");//设置允许裁剪,如果不设置,就会跳过裁剪的过程,还可以设置putExtra("crop", "circle") |
| | | if (Build.MANUFACTURER.equals("HUAWEI")) { //华为特殊处理 不然会显示圆 |
| | | intent.putExtra("aspectX", 9998); |
| | | intent.putExtra("aspectY", 9999); |
| | | } else { |
| | | intent.putExtra("aspectX", 1);//裁剪框的 X 方向的比例,需要为整数 |
| | | intent.putExtra("aspectY", 1);//裁剪框的 Y 方向的比例,需要为整数 |
| | | } |
| | | intent.putExtra("outputX", 250);//返回数据的时候的X像素大小。 |
| | | intent.putExtra("outputY", 250);//返回数据的时候的Y像素大小。 |
| | | //裁剪时是否保留图片的比例,这里的比例是1:1 |
| | | intent.putExtra("scale", true); |
| | | //是否是圆形裁剪区域,设置了也不一定有效 |
| | | intent.putExtra("circleCrop", false); |
| | | |
| | | //uritempFile为Uri类变量,实例化uritempFile |
| | | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { |
| | | //如果是7.0的相册 |
| | | //设置裁剪的图片地址Uri |
| | | uriClipUri = Uri.parse("file://" + "/" + android.os.Environment.getExternalStorageDirectory().getPath() + "/FLQImg/" + "clip.jpg"); |
| | | } else { |
| | | uriClipUri = Uri.parse("file://" + "/" + android.os.Environment.getExternalStorageDirectory().getPath() + "/FLQImg/" + "clip.jpg"); |
| | | } |
| | | //Android 对Intent中所包含数据的大小是有限制的,一般不能超过 1M,否则会使用缩略图 ,所以我们要指定输出裁剪的图片路径 |
| | | intent.putExtra(MediaStore.EXTRA_OUTPUT, uriClipUri); |
| | | intent.putExtra("return-data", false);//是否将数据保留在Bitmap中返回 |
| | | intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());//输出格式,一般设为Bitmap格式及图片类型 |
| | | intent.putExtra("noFaceDetection", false);//人脸识别功能 |
| | | startActivityForResult(intent, 1002);//裁剪完成的标识 |
| | | uriClipUri = SystemClipImageUtil.startPhotoZoom(this, uri, System.currentTimeMillis() + "_clip.jpg", 250, 250, 1002); |
| | | } |
| | | |
| | | private String bitmapToBase64(Bitmap bitmap) { |
| | | |
| | | String result = null; |
| | | ByteArrayOutputStream baos = null; |
| | | private String bitmapToBase64(InputStream in) { |
| | | try { |
| | | if (bitmap != null) { |
| | | baos = new ByteArrayOutputStream(); |
| | | bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos); |
| | | |
| | | baos.flush(); |
| | | baos.close(); |
| | | |
| | | byte[] bitmapBytes = baos.toByteArray(); |
| | | result = Base64.encodeToString(bitmapBytes, Base64.DEFAULT); |
| | | } |
| | | byte[] bytes = new byte[in.available()]; |
| | | int length = in.read(bytes); |
| | | return Base64.encodeToString(bytes, 0, length, Base64.DEFAULT); |
| | | } catch (FileNotFoundException e) { |
| | | // TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | } catch (IOException e) { |
| | | // TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | } finally { |
| | | try { |
| | | if (baos != null) { |
| | | baos.flush(); |
| | | baos.close(); |
| | | if (in != null) { |
| | | in.close(); |
| | | } |
| | | } catch (IOException e) { |
| | | // TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | return result; |
| | | return null; |
| | | } |
| | | |
| | | private String bitmapToBase64(File file) { |
| | | try { |
| | | return bitmapToBase64(new FileInputStream(file)); |
| | | } catch (FileNotFoundException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | private String saveBitmapTofile(Bitmap bm) { |
| | |
| | | HttpApiUtil.upLoadPersonInfo(this, uid, loginUid, mSex + "", tv_birthday.getText().toString(), |
| | | tv_autograph.getText().toString(), imgBase64, tv_nickName.getText().toString(), new BasicTextHttpResponseHandler() { |
| | | @Override |
| | | public void onStart() { |
| | | super.onStart(); |
| | | showLoading(); |
| | | } |
| | | |
| | | @Override |
| | | public void onFinish() { |
| | | super.onFinish(); |
| | | hideLoading(); |
| | | } |
| | | |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception { |
| | | if (jsonObject.optBoolean("IsPost")) { |
| | | SharedPreferences sharedPreferences = getSharedPreferences("user", Context.MODE_PRIVATE); |
| | |
| | | super.onFailure(statusCode, headers, responseString, throwable); |
| | | SingleToast.showToast(RegisterActivity.this, "注册失败,请重新注册"); |
| | | } |
| | | |
| | | @Override |
| | | public void onStart() { |
| | | super.onStart(); |
| | | showLoading(); |
| | | } |
| | | |
| | | @Override |
| | | public void onFinish() { |
| | | super.onFinish(); |
| | | hideLoading(); |
| | | } |
| | | }); |
| | | } |
| | | |
| | |
| | | super.onFailure(statusCode, headers, responseString, throwable); |
| | | SingleToast.showToast(RegisterActivity.this, "登录失败"); |
| | | } |
| | | |
| | | @Override |
| | | public void onStart() { |
| | | super.onStart(); |
| | | showLoading(); |
| | | } |
| | | |
| | | @Override |
| | | public void onFinish() { |
| | | super.onFinish(); |
| | | hideLoading(); |
| | | } |
| | | }); |
| | | |
| | | } |
| | |
| | | public void onFinish() { |
| | | super.onFinish(); |
| | | tv_obtain_verfication_code.setEnabled(true); |
| | | hideLoading(); |
| | | } |
| | | |
| | | @Override |
| | | public void onStart() { |
| | | super.onStart(); |
| | | showLoading(); |
| | | } |
| | | }); |
| | | } |
| | |
| | | import android.util.Log; |
| | | import android.view.View; |
| | | |
| | | import com.androidquery.AQuery; |
| | | import com.bytedance.sdk.dp.DPSdk; |
| | | import com.bytedance.sdk.dp.DPWidgetNewsParams; |
| | | import com.bytedance.sdk.dp.IDPNewsListener; |
| | |
| | | import com.hanju.video.app.R; |
| | | import com.hanju.video.app.ui.MyRetainViewFragment; |
| | | import com.hanju.video.app.util.video.DPEventCollectUtil; |
| | | import com.video.base.ui.subview.MyRefreshLayout; |
| | | |
| | | import java.util.Map; |
| | | |
| | |
| | | */ |
| | | public class DYNewsFragment extends MyRetainViewFragment { |
| | | private static final String TAG = "DYNewsFragment"; |
| | | private FragmentManager fragmentManager; |
| | | private IDPWidget mIDPWidget; |
| | | private String channel = "__all__"; |
| | | private AQuery mAquery; |
| | | |
| | | public DYNewsFragment() { |
| | | super(); |
| | | } |
| | | |
| | | public DYNewsFragment(FragmentManager fragmentManager) { |
| | | public DYNewsFragment(String channel) { |
| | | super(); |
| | | this.fragmentManager = fragmentManager; //fragmentManager; |
| | | this.channel = channel; |
| | | } |
| | | |
| | | private Fragment fragment; |
| | |
| | | |
| | | @Override |
| | | public int getContentResource() { |
| | | return R.layout.fragment_common; |
| | | return R.layout.fragment_feed_videos; |
| | | } |
| | | |
| | | @Override |
| | |
| | | @Override |
| | | public void onCreateView(View contentView, Bundle savedInstanceState) { |
| | | Log.i(TAG, "onCreateView"); |
| | | mAquery = new AQuery(contentView); |
| | | MyRefreshLayout refreshLayout = contentView.findViewById(R.id.srl_feed); |
| | | refreshLayout.setEnabled(false); |
| | | initNewsWidget(); |
| | | } |
| | | |
| | | private void initNewsWidget() { |
| | | |
| | | |
| | | //热点 news_hot |
| | | //娱乐 news_entertainment |
| | | mIDPWidget = DPSdk.factory().createNewsOneTab(DPWidgetNewsParams.obtain().channelCategory("news_entertainment") |
| | | DPWidgetNewsParams params = DPWidgetNewsParams.obtain().channelCategory(channel) |
| | | .listener(new IDPNewsListener() { |
| | | @Override |
| | | public void onDPRefreshFinish() { |
| | |
| | | } |
| | | |
| | | |
| | | })); |
| | | }); |
| | | |
| | | |
| | | if ("__all__".equalsIgnoreCase(channel)) { |
| | | mAquery.id(R.id.view_statusbar).visibility(View.VISIBLE); |
| | | mIDPWidget = DPSdk.factory().createNewsTabs(params); |
| | | } else { |
| | | mAquery.id(R.id.view_statusbar).visibility(View.GONE); |
| | | mIDPWidget = DPSdk.factory().createNewsOneTab(params); |
| | | } |
| | | Fragment fragment = mIDPWidget.getFragment(); |
| | | if (fragment != null) { |
| | | getChildFragmentManager().beginTransaction().replace(R.id.fl_container, fragment).commitAllowingStateLoss(); |
| | |
| | | import com.hanju.lib.library.util.common.StorageUtils; |
| | | import com.hanju.lib.library.util.common.StringUtils; |
| | | import com.hanju.video.app.util.JsonUtil; |
| | | import com.hanju.video.app.util.UserUtil; |
| | | import com.hanju.video.app.util.ad.AdUtil; |
| | | import com.hanju.video.app.util.ad.CSJADConstant; |
| | | import com.hanju.video.app.util.ad.GDTADConstant; |
| | |
| | | public HomePageAdapter(FragmentManager fm) { |
| | | super(fm); |
| | | this.fm = fm; |
| | | if (AdUtil.isCanInitCSJ()) { |
| | | mDYNewsFragment = new DYNewsFragment(); |
| | | if (AdUtil.isCanInitCSJ() && !YouthUtil.isOpenYouthMode(getContext())) { |
| | | mDYNewsFragment = new DYNewsFragment("news_entertainment"); |
| | | mNovelFragment = new NovelFragment(fm); |
| | | fragments.add(mNovelFragment); |
| | | fragments.add(mDYNewsFragment); |
| | |
| | | break; |
| | | } |
| | | } |
| | | |
| | | public void onEventMainThread(VideoType type) { |
| | | getCategories(); |
| | | } |
| | |
| | | |
| | | List<HomeNav> categories = new ArrayList<>(); |
| | | int count = 1; |
| | | |
| | | private void getCategories() { |
| | | SharedPreferences preferences = pager.getContext().getSharedPreferences( |
| | | "user", Context.MODE_PRIVATE); |
| | |
| | | @Override |
| | | public void onFinish() { |
| | | super.onFinish(); |
| | | AdUtil.AD_TYPE adType = AdUtil.getAdType(getContext(), AdPositionEnum.homeInterstitial); |
| | | if (adType != null) { |
| | | //Android 5.0 |
| | | if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT_WATCH) { |
| | | adType = AdUtil.AD_TYPE.gdt; |
| | | } |
| | | |
| | | if (adType == AdUtil.AD_TYPE.csj) { |
| | | IntertitialAdUtil.showAd(getActivity(), adType, CSJADConstant.HOME_INTERSTITIALAD); |
| | | } else { |
| | | IntertitialAdUtil.showAd(getActivity(), adType, GDTADConstant.HOME_INTERSTITIALAD); |
| | | } |
| | | } |
| | | |
| | | } |
| | | }); |
| | | } |
| | |
| | | import com.hanju.video.app.util.ad.CSJADConstant; |
| | | import com.hanju.video.app.util.ad.FullVideoAdManager; |
| | | import com.hanju.video.app.util.ad.GDTADConstant; |
| | | import com.hanju.video.app.util.ad.IntertitialAdUtil; |
| | | import com.jaeger.library.StatusBarUtil; |
| | | import com.umeng.socialize.UMShareAPI; |
| | | import com.hanju.video.app.R; |
| | |
| | | list.add(new MineFragment()); |
| | | list.add(new DiscoverNowFragment()); |
| | | |
| | | |
| | | if (AdUtil.isCanInitCSJ()) { |
| | | list.add(new DYVideoFragment()); |
| | | list.add(new DYFeedFragment()); |
| | | list.add(new DYNewsFragment()); |
| | | mAQuery.id(R.id.rb_nav_category).visibility(View.GONE); |
| | | mAQuery.id(R.id.rb_nav_feed_videos).visibility(View.VISIBLE); |
| | | mAQuery.id(R.id.rb_nav_draw_video).visibility(View.VISIBLE); |
| | |
| | | break; |
| | | |
| | | case R.id.rb_nav_discover: { |
| | | mFragmentSwitchHelper |
| | | .changeFragment(DiscoverNowFragment.class); |
| | | if (AdUtil.isCanInitCSJ()) { |
| | | mFragmentSwitchHelper |
| | | .changeFragment(DYNewsFragment.class); |
| | | } else { |
| | | mFragmentSwitchHelper |
| | | .changeFragment(DiscoverNowFragment.class); |
| | | } |
| | | } |
| | | break; |
| | | case R.id.rb_nav_mine: { |
| | |
| | | .setChecked(true); |
| | | } |
| | | }); |
| | | |
| | | |
| | | rg_nav.postDelayed(intertitialRunnable, 3000); |
| | | } |
| | | |
| | | private Runnable intertitialRunnable = new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | |
| | | AdUtil.AD_TYPE adType = AdUtil.getAdType(getApplicationContext(), AdPositionEnum.homeInterstitial); |
| | | if (adType != null) { |
| | | //Android 5.0 |
| | | if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT_WATCH) { |
| | | adType = AdUtil.AD_TYPE.gdt; |
| | | } |
| | | |
| | | if (adType == AdUtil.AD_TYPE.csj) { |
| | | IntertitialAdUtil.showAd(MainActivity.this, adType, CSJADConstant.HOME_INTERSTITIALAD); |
| | | } else { |
| | | IntertitialAdUtil.showAd(MainActivity.this, adType, GDTADConstant.HOME_INTERSTITIALAD); |
| | | } |
| | | } |
| | | |
| | | } |
| | | }; |
| | | |
| | | /** |
| | | * 初始化用户登录信息 |
| | |
| | | EventBus.getDefault().unregister(this); |
| | | } |
| | | |
| | | @Override |
| | | protected void onDestroy() { |
| | | super.onDestroy(); |
| | | if (rg_nav != null && intertitialRunnable != null) { |
| | | rg_nav.removeCallbacks(intertitialRunnable); |
| | | } |
| | | } |
| | | |
| | | private String callCmd(String cmd, String filter) { |
| | | String result = ""; |
| | | String line = ""; |
| | |
| | | import com.bumptech.glide.request.target.SimpleTarget; |
| | | import com.bumptech.glide.request.transition.Transition; |
| | | import com.bytedance.sdk.openadsdk.TTAdSdk; |
| | | import com.google.gson.FieldNamingPolicy; |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.GsonBuilder; |
| | | import com.google.gson.reflect.TypeToken; |
| | | import com.hanju.video.app.ui.video.PPTVPlayFragment; |
| | | import com.hanju.video.app.ui.video.VideoPlayerFragment; |
| | | import com.hanju.video.app.ui.video.parser.VideoPlayUrlParseFragment; |
| | | import com.hanju.video.app.util.JsonUtil; |
| | | import com.hanju.video.app.util.ad.GDTADConstant; |
| | | import com.hanju.video.app.util.ad.IntertitialAdUtil; |
| | | import com.hanju.video.app.util.http.BasicTextHttpResponseHandler; |
| | | import com.hanju.video.app.util.http.HttpApiUtil; |
| | | import com.hanju.lib.library.util.SingleToast; |
| | | import com.hanju.lib.library.util.SystemCommon; |
| | | import com.hanju.lib.library.util.common.DimenUtils; |
| | | import com.hanju.lib.library.util.common.StringUtils; |
| | | import com.hanju.video.app.R; |
| | | import com.hanju.video.app.database.WatchHistoryTable; |
| | | import com.hanju.video.app.entity.ad.AdPositionEnum; |
| | | import com.hanju.video.app.entity.common.AccumulateRule; |
| | | import com.hanju.video.app.entity.user.Follow; |
| | | import com.hanju.video.app.entity.video.Play; |
| | |
| | | import com.hanju.video.app.entity.video.VideoDetailInfo; |
| | | import com.hanju.video.app.entity.video.VideoInfo; |
| | | import com.hanju.video.app.entity.video.VideoResource; |
| | | import com.hanju.video.app.entity.ad.AdPositionEnum; |
| | | import com.hanju.video.app.ui.BaseActivity; |
| | | import com.hanju.video.app.ui.ad.VideoDetailVideoAdFragment; |
| | | import com.hanju.video.app.ui.common.ShareActivity; |
| | | import com.hanju.video.app.ui.login.LoginActivity; |
| | | import com.hanju.video.app.ui.mine.FXBrowserActivity; |
| | | import com.hanju.video.app.ui.video.PPTVPlayFragment; |
| | | import com.hanju.video.app.ui.video.VideoPlayerActivity; |
| | | import com.hanju.video.app.ui.video.VideoWebPlayerFragment; |
| | | import com.hanju.video.app.ui.video.parser.VideoPlayUrlParseFragment; |
| | | import com.hanju.video.app.util.HanJuConstant; |
| | | import com.hanju.video.app.util.JsonUtil; |
| | | import com.hanju.video.app.util.UserUtil; |
| | | import com.hanju.video.app.util.video.VideoUtil; |
| | | import com.hanju.video.app.util.ad.AdUtil; |
| | | import com.hanju.video.app.util.ad.FullVideoAdManager; |
| | | import com.hanju.video.app.util.ad.GDTADConstant; |
| | | import com.hanju.video.app.util.http.BasicTextHttpResponseHandler; |
| | | import com.hanju.video.app.util.http.HttpApiUtil; |
| | | import com.hanju.video.app.util.ui.StatusBarUtil; |
| | | import com.hanju.lib.library.util.SingleToast; |
| | | import com.hanju.lib.library.util.SystemCommon; |
| | | import com.hanju.lib.library.util.common.DimenUtils; |
| | | import com.hanju.lib.library.util.common.StringUtils; |
| | | import com.qq.e.ads.cfg.VideoOption; |
| | | import com.qq.e.ads.interstitial2.UnifiedInterstitialAD; |
| | | import com.qq.e.ads.interstitial2.UnifiedInterstitialADListener; |
| | | import com.qq.e.comm.util.AdError; |
| | | import com.hanju.video.app.util.video.VideoUtil; |
| | | import com.umeng.socialize.ShareAction; |
| | | import com.umeng.socialize.UMShareAPI; |
| | | import com.umeng.socialize.UMShareListener; |
| | |
| | | |
| | | private AQuery mAquery; |
| | | |
| | | private VideoPlayerFragment mVideoPlayerFragment; |
| | | private VideoWebPlayerFragment mVideoPlayerFragment; |
| | | |
| | | @Override |
| | | protected void onSaveInstanceState(Bundle outState) { |
| | |
| | | if (playUrl == null) { |
| | | return; |
| | | } |
| | | |
| | | // |
| | | // |
| | | // if (1 > 0) |
| | |
| | | // if (playUrl.getPlayType() != 1) {//测试 |
| | | // setViewOrientation(); |
| | | // } |
| | | |
| | | for (int i = 0; i < videoInfo.getResourceList().size(); i++) { |
| | | if (playUrl.getResource().getId().equalsIgnoreCase(videoInfo.getResourceList().get(i).getId())) { |
| | | videoInfo.getResourceList().get(i).setChecked(true); |
| | |
| | | intent.putExtra("url", playUrl.getUrl()); |
| | | startActivity(intent); |
| | | } else if (playUrl.getPlayType() == 2) { |
| | | iv_select_play.setVisibility(View.GONE); |
| | | iv_background.setClickable(false); |
| | | mIQYVideoPlayerFragment = fm |
| | | .findFragmentByTag("IQYVideoFragment"); |
| | | mIQYVideoPlayerFragment = new IQYVideoFragment(); |
| | | Bundle b = new Bundle(); |
| | | b.putSerializable("playUrl", playUrl); |
| | | mIQYVideoPlayerFragment.setArguments(b); |
| | | fm.beginTransaction() |
| | | .replace(R.id.fragment_video_play_container, |
| | | mIQYVideoPlayerFragment, "IQYVideoFragment") |
| | | .commitAllowingStateLoss(); |
| | | // EventBus.getDefault().post(playUrl); |
| | | Toast.makeText(VideoDetailActivity.this, "影片加载中...", |
| | | Toast.LENGTH_LONG).show(); |
| | | //SDK播放 |
| | | playWithSDK(playUrl.getUrl()); |
| | | } |
| | | saveWatchHistory("爱奇艺"); |
| | | } |
| | |
| | | intent.putExtra("url", playUrl.getUrl()); |
| | | startActivity(intent); |
| | | saveWatchHistory("风行"); |
| | | } else if (playUrl.getPlayType() == 2) { |
| | | //SDK播放 |
| | | playWithSDK(playUrl.getUrl()); |
| | | } |
| | | } else if (playUrl.getResource().getName().contains("韩迷")) { |
| | | |
| | |
| | | mAquery.id(R.id.pb_loading).visibility(View.VISIBLE); |
| | | //开始解析视频 |
| | | String tempUrl = playUrl.getUrl(); |
| | | |
| | | List<VideoPlayUrlParseFragment.ParseParams> parseParams = new ArrayList<>(); |
| | | String js = "function parseResult(url, data) {console.log(data); try {var result =JSON.parse( data);if (result.code == 200) {return result.url.replace('/\"/g', '');}} catch (e) {if (url.indexOf('.m3u8') > -1) { " + |
| | | "return url;"+ |
| | | "}}return null;};"; |
| | | |
| | | |
| | | parseParams.add(new VideoPlayUrlParseFragment.ParseParams("^(https://){1}.*(\\.m3u8)$", js, false)); |
| | | |
| | | parseParams.add(new VideoPlayUrlParseFragment.ParseParams("^(https://jx\\.bolecdn\\.com/index2\\.php\\?url=){1}.*", js, false)); |
| | | |
| | | parseParams.add(new VideoPlayUrlParseFragment.ParseParams("^(https://chaoren\\.sc2yun\\.com/superman\\.php)", js, true)); |
| | | videoPlayUrlParseFragment.startParse(tempUrl, parseParams, new VideoPlayUrlParseFragment.IVideoParseListener() { |
| | | @Override |
| | | public void onSuccess(String result) { |
| | | runOnUiThread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | mAquery.id(R.id.pb_loading).visibility(View.GONE); |
| | | |
| | | VideoDetailInfo detailInfo = null; |
| | | if (mPosition < videoInfo.getVideoDetailList().size()) |
| | | detailInfo = videoInfo.getVideoDetailList().get(mPosition); |
| | | String videoName = videoInfo.getName(); |
| | | if (detailInfo != null && !videoName.equalsIgnoreCase(detailInfo.getTag())) { |
| | | videoName += " " + detailInfo.getTag(); |
| | | } |
| | | |
| | | if (mVideoPlayerFragment == null) { |
| | | mVideoPlayerFragment = VideoPlayerFragment.newInstance(videoName, tempUrl, result); |
| | | getSupportFragmentManager().beginTransaction().replace(R.id.fl_player, mVideoPlayerFragment).commitAllowingStateLoss(); |
| | | } else |
| | | mVideoPlayerFragment.setVideoInfo(videoName, tempUrl, result); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | @Override |
| | | public void onFail(String msg) { |
| | | |
| | | } |
| | | }); |
| | | //SDK播放 |
| | | playWithSDK(tempUrl); |
| | | saveWatchHistory(playUrl.getResource().getName()); |
| | | } |
| | | } else { |
| | |
| | | intent.putExtra("url", playUrl.getUrl()); |
| | | startActivity(intent); |
| | | saveWatchHistory(playUrl.getResource().getName()); |
| | | } else if (playUrl.getPlayType() == 2) { |
| | | playWithSDK(playUrl.getUrl()); |
| | | saveWatchHistory(playUrl.getResource().getName()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void playWithSDK(String playUrl) { |
| | | if (mVideoPlayerFragment == null) { |
| | | mVideoPlayerFragment = VideoWebPlayerFragment.newInstance("", "", playUrl); |
| | | getSupportFragmentManager().beginTransaction().replace(R.id.fl_player, mVideoPlayerFragment).commitAllowingStateLoss(); |
| | | } else |
| | | mVideoPlayerFragment.setVideoInfo("", "", playUrl); |
| | | } |
| | | |
| | | private void setViewOrientation() { |
| | | findViewById(R.id.fl_video_detail).setVisibility(View.GONE); |
| | | findViewById(R.id.v_status_bar).setVisibility(View.GONE); |
| | | setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); |
| | | android.widget.RelativeLayout.LayoutParams params = new android.widget.RelativeLayout.LayoutParams( |
| | | RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams( |
| | | LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); |
| | | findViewById(R.id.fragment_video_play_container1).setLayoutParams( |
| | | params); |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | findViewById(R.id.v_status_bar).setVisibility(View.VISIBLE); |
| | | android.widget.RelativeLayout.LayoutParams params = new android.widget.RelativeLayout.LayoutParams( |
| | | RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams( |
| | | (int) SystemCommon.getScreenWidth(this), |
| | | (int) ((SystemCommon.getScreenWidth(this) * 9) / 16)); |
| | | findViewById(R.id.fragment_video_play_container1).setLayoutParams( |
| | |
| | | } |
| | | } |
| | | |
| | | android.view.ViewGroup.LayoutParams layoutParams = findViewById( |
| | | ViewGroup.LayoutParams layoutParams = findViewById( |
| | | R.id.fragment_video_play_container1).getLayoutParams(); |
| | | layoutParams.height = android.view.ViewGroup.LayoutParams.MATCH_PARENT; |
| | | layoutParams.width = android.view.ViewGroup.LayoutParams.MATCH_PARENT; |
| | | layoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT; |
| | | layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT; |
| | | |
| | | // android.view.ViewGroup.LayoutParams layoutParams1 = findViewById( |
| | | // R.id.fl_player).getLayoutParams(); |
| | |
| | | FrameLayout layout = findViewById(R.id.fragment_video_play_container1); |
| | | if (layout == null) |
| | | return; |
| | | android.view.ViewGroup.LayoutParams layoutParams = layout |
| | | ViewGroup.LayoutParams layoutParams = layout |
| | | .getLayoutParams(); |
| | | layoutParams.height = (int) (DimenUtils.getScreenWidth(this) * 0.5625f); |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | final VideoInfo videoInfo = JsonUtil.videoGson |
| | | final VideoInfo videoInfo = JsonUtil.videoGson |
| | | .fromJson(data.toString(), |
| | | new TypeToken<VideoInfo>() { |
| | | }.getType()); |
| | |
| | | } |
| | | |
| | | //加载视频广告 |
| | | // loadFullVideoAd(); |
| | | loadFullVideoAd(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | throws Exception { |
| | | if (jsonObject.getBoolean("IsPost")) { |
| | | |
| | | VideoResource resource = JsonUtil.videoGson.fromJson( |
| | | VideoResource resource = JsonUtil.videoGson.fromJson( |
| | | jsonObject.getJSONObject("Data") |
| | | .getJSONObject("Resource") |
| | | .toString(), |
| | |
| | | } |
| | | popupWindow = new PopupWindow( |
| | | com.hanju.video.app.util.common.DimenUtils.dip2px(getApplicationContext(), 93), |
| | | android.view.WindowManager.LayoutParams.WRAP_CONTENT); |
| | | WindowManager.LayoutParams.WRAP_CONTENT); |
| | | popupWindow.setOutsideTouchable(true);// 点击外部可点击 |
| | | popupWindow.setBackgroundDrawable(new ColorDrawable(0));// 设置背景 |
| | | popupWindow.setAnimationStyle(R.style.PopupAnimation); |
| | |
| | | |
| | | GradientDrawable gd = new GradientDrawable(GradientDrawable.Orientation.LEFT_RIGHT, |
| | | new int[]{Color.parseColor("#FF999999"), Color.parseColor("#FF999999")}); |
| | | |
| | | int radius = DimenUtils.dip2px(getApplicationContext(), 5); |
| | | gd.setCornerRadii(new float[]{radius, radius, radius, radius, 0, 0, 0, 0}); |
| | | fl.setBackground(gd); |
| | |
| | | builder.create().show(); |
| | | break; |
| | | case R.id.rl_check_update:// 点击检查更新c81e728d9d4c2f636f067f89cc14862c |
| | | initialer.run(); |
| | | Toast.makeText(getApplicationContext(), "当前已是最新版本", Toast.LENGTH_SHORT).show(); |
| | | break; |
| | | case R.id.tv_top_bar_left: { |
| | | finish(); |
| | |
| | | break; |
| | | case R.id.rl_disclaimer: { |
| | | Intent intent = new Intent(this, BrowserActivity.class); |
| | | intent.putExtra("url", HanJuConstant.HOST + "/BuWan/" |
| | | + "api_disclaimer.jsp?package=" + getPackageName()); |
| | | intent.putExtra("url", HanJuConstant.DISCLAIMER); |
| | | startActivity(intent); |
| | | } |
| | | break; |
| | |
| | | public class RecommendFragment extends RetainViewFragment implements |
| | | OnClickListener { |
| | | |
| | | private static final String TAG = "RecommendFragment"; |
| | | |
| | | private MyRefreshLayout rl_recommend; |
| | | |
| | | private RecyclerView rv_recommend; |
| | |
| | | return; |
| | | if (mRecommendNewAdapter.getAdCount() == 0) { |
| | | if (adList != null && adList.size() > 0) { |
| | | mRecommendNewAdapter.addAdToPosition(adList.get(0), 3); |
| | | Log.i(TAG, "增加广告"); |
| | | mRecommendNewAdapter.addAdToPosition(adList.get(0), 0); |
| | | } |
| | | mRecommendNewAdapter.notifyDataSetChanged(); |
| | | } |
| | |
| | | try { |
| | | ExpressAdManager recommendAdManager = new ExpressAdManager(AdUtil.AD_TYPE.csj, context); |
| | | recommendAdManager.loadRecommendLargeAd(new ExpressAdManager.IAdLoadListener() { |
| | | |
| | | |
| | | @Override |
| | | public void onSuccess(final List<ExpressAdContainer> adList) { |
| | | Log.i(TAG, "获取到广告:" + adList.size()); |
| | | RecommendFragment.this.adList = new ArrayList<>(); |
| | | for (ExpressAdContainer ad : adList) { |
| | | ExpressAdManager.renderAd(getActivity(), ad, new ExpressAdManager.IAdRenderListener() { |
| | |
| | | mHomeSpecials.addAll(homeSpecials); |
| | | HomeSpecial novel = new HomeSpecial(); |
| | | novel.setName("小说"); |
| | | mHomeSpecials.add(novel); |
| | | if (AdUtil.isCanInitCSJ() && !YouthUtil.isOpenYouthMode(getContext())) { |
| | | mHomeSpecials.add(novel); |
| | | } |
| | | // mRecommendNewAdapter.notifyDataSetChanged(); |
| | | } |
| | | } |
| | |
| | | mHomeSpecials.addAll(homeSpecials); |
| | | HomeSpecial novel = new HomeSpecial(); |
| | | novel.setName("小说"); |
| | | mHomeSpecials.add(novel); |
| | | if (AdUtil.isCanInitCSJ() && !YouthUtil.isOpenYouthMode(getContext())) { |
| | | mHomeSpecials.add(novel); |
| | | } |
| | | } |
| | | setHomeSpecialData(); |
| | | // //缓存 |
| | |
| | | import com.hanju.video.app.util.ad.ExpressAdManager; |
| | | import com.hanju.video.app.util.video.DPEventCollectUtil; |
| | | import com.hanju.video.app.util.video.VideoUtil; |
| | | import com.video.youth.util.YouthUtil; |
| | | |
| | | import java.text.DecimalFormat; |
| | | import java.util.ArrayList; |
| | |
| | | |
| | | private boolean hasDYVideos() { |
| | | |
| | | return AdUtil.isCanInitCSJ(); |
| | | return AdUtil.isCanInitCSJ()&&!YouthUtil.isOpenYouthMode(mContext); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | private void loadVideoCard() { |
| | | |
| | | if (!AdUtil.isCanInitCSJ()) { |
| | | if (!AdUtil.isCanInitCSJ()||YouthUtil.isOpenYouthMode(mContext)) { |
| | | return; |
| | | } |
| | | |
| | |
| | | import android.graphics.Color; |
| | | import android.graphics.drawable.Drawable; |
| | | import android.os.Bundle; |
| | | |
| | | import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; |
| | | import androidx.recyclerview.widget.LinearLayoutManager; |
| | | import androidx.recyclerview.widget.RecyclerView; |
| | | |
| | | import android.text.Editable; |
| | | import android.text.TextUtils; |
| | | import android.text.TextWatcher; |
| | | import android.util.Log; |
| | | import android.view.KeyEvent; |
| | | import android.view.LayoutInflater; |
| | | import android.view.MotionEvent; |
| | |
| | | import com.hanju.video.app.util.ui.StatusBarUtil; |
| | | import com.video.base.ui.subview.MyRefreshLayout; |
| | | |
| | | import net.lucode.hackware.magicindicator.MagicIndicator; |
| | | import net.lucode.hackware.magicindicator.ViewPagerHelper; |
| | | import net.lucode.hackware.magicindicator.buildins.commonnavigator.CommonNavigator; |
| | | import net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.CommonNavigatorAdapter; |
| | | import net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.IPagerIndicator; |
| | | import net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.IPagerTitleView; |
| | | import net.lucode.hackware.magicindicator.buildins.commonnavigator.indicators.LinePagerIndicator; |
| | | import net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.ColorTransitionPagerTitleView; |
| | | |
| | | import org.apache.http.Header; |
| | | import org.json.JSONObject; |
| | | |
| | |
| | | public class SearchResultActivity extends BaseActivity implements |
| | | OnClickListener { |
| | | |
| | | private static final String TAG = SearchResultActivity.class.getSimpleName(); |
| | | private AutoCompleteTextView et_search_key; |
| | | |
| | | private TextView tv_search_cancel; |
| | |
| | | protected void onCreate(Bundle savedInstanceState) { |
| | | super.onCreate(savedInstanceState); |
| | | setContentView(R.layout.search_result_activity); |
| | | |
| | | StatusBarUtil.init(this); |
| | | |
| | | rl_search_result = findViewById(R.id.rl_search_result); |
| | | et_search_key = findViewById(R.id.et_search_key); |
| | |
| | | ProgressBar pb = new ProgressBar(SearchResultActivity.this); |
| | | rl_search_result.setRefreshing(true); |
| | | search(mCurrentKey, mCurrentType); |
| | | // loadAd(); |
| | | loadAd(); |
| | | } |
| | | |
| | | private void initTopBar(List<VideoType> videoTypeList) { |
| | | int p = 0; |
| | | ll_top_bar.removeAllViews(); |
| | | LayoutInflater inflater = LayoutInflater.from(getApplicationContext()); |
| | | for (int i = 0; i < videoTypeList.size(); i++) { |
| | | final View view = inflater.inflate(R.layout.item_search_result_top_bar_content, null); |
| | | TextView tv_name = view.findViewById(R.id.tv_name); |
| | | tv_name.setText(videoTypeList.get(i).getName()); |
| | | setTopBarSelect(tv_name, i == p); |
| | | ll_top_bar.addView(view); |
| | | ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) view.getLayoutParams(); |
| | | params.rightMargin = DimenUtils.dip2px(getApplicationContext(), 17); |
| | | params.leftMargin = DimenUtils.dip2px(getApplicationContext(), 10); |
| | | view.setTag(i); |
| | | view.setOnClickListener(new OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | int p = Integer.parseInt(view.getTag() + ""); |
| | | selectTopBar(p); |
| | | VideoType vt = videoTypeList.get(p); |
| | | |
| | | private List<VideoType> videoTypeList; |
| | | |
| | | private CommonNavigatorAdapter navigatorAdapter = new CommonNavigatorAdapter() { |
| | | |
| | | @Override |
| | | public int getCount() { |
| | | return videoTypeList == null ? 0 : videoTypeList.size(); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public IPagerTitleView getTitleView(final Context context, final int index) { |
| | | ColorTransitionPagerTitleView colorTransitionPagerTitleView = new ColorTransitionPagerTitleView(context) { |
| | | @Override |
| | | public void onSelected(int index, int totalCount) { |
| | | Log.i(TAG,"onSelected:"+index); |
| | | super.onSelected(index, totalCount); |
| | | getPaint().setFakeBoldText(true); |
| | | } |
| | | |
| | | @Override |
| | | public void onDeselected(int index, int totalCount) { |
| | | super.onDeselected(index, totalCount); |
| | | Log.i(TAG,"onDeselected:"+index); |
| | | getPaint().setFakeBoldText(false); |
| | | } |
| | | }; |
| | | colorTransitionPagerTitleView.setNormalColor(Color.parseColor("#FF787878")); |
| | | colorTransitionPagerTitleView.setSelectedColor(getResources().getColor(R.color.theme)); |
| | | colorTransitionPagerTitleView.setText(videoTypeList.get(index).getName()); |
| | | colorTransitionPagerTitleView.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View view) { |
| | | VideoType vt = videoTypeList.get(index); |
| | | if (StringUtils.isBlank(mCurrentType) || !mCurrentType.equalsIgnoreCase(vt.getId())) { |
| | | mMagicIndicator.onPageSelected(index); |
| | | mMagicIndicator.onPageScrolled(index, 0.0F, 0); |
| | | |
| | | mCurrentPage = 1; |
| | | mCurrentType = vt.getId(); |
| | | rl_search_result.setRefreshing(true); |
| | | search(mCurrentKey, mCurrentType); |
| | | } |
| | | |
| | | } |
| | | }); |
| | | colorTransitionPagerTitleView.setTextSize(15); |
| | | |
| | | |
| | | |
| | | return colorTransitionPagerTitleView; |
| | | } |
| | | |
| | | //此为tab指示器回调 |
| | | @Override |
| | | public IPagerIndicator getIndicator(Context context) { |
| | | Log.i(TAG,"getIndicator:"); |
| | | LinePagerIndicator indicator = new LinePagerIndicator(context); |
| | | indicator.setLineHeight(DimenUtils.dip2px(getApplicationContext(), 2)); |
| | | indicator.setColors(getResources().getColor(R.color.theme)); |
| | | indicator.setMode(LinePagerIndicator.MODE_WRAP_CONTENT); |
| | | indicator.setRoundRadius(5); |
| | | return indicator; |
| | | } |
| | | }; |
| | | |
| | | private MagicIndicator mMagicIndicator; |
| | | |
| | | private void initTopBar(List<VideoType> videoTypeList) { |
| | | ll_top_bar.removeAllViews(); |
| | | this.videoTypeList = videoTypeList; |
| | | mMagicIndicator = new MagicIndicator(this); |
| | | CommonNavigator commonNavigator = new CommonNavigator(this); |
| | | commonNavigator.setAdapter(navigatorAdapter); |
| | | commonNavigator.setAdjustMode(false); |
| | | mMagicIndicator.setNavigator(commonNavigator); |
| | | Log.i(TAG, "mCurrentType:" + mCurrentType); |
| | | mMagicIndicator.onPageSelected(0); |
| | | ll_top_bar.addView(mMagicIndicator, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, DimenUtils.spToPixels(26, getApplicationContext()))); |
| | | } |
| | | |
| | | private void setTopBarSelect(TextView tv_name, boolean selected) { |
| | | if (selected) { |
| | | tv_name.setBackgroundResource(R.drawable.vpi__tab_selected_pressed_holo); |
| | | tv_name.setTextSize(17); |
| | | tv_name.setTextColor(Color.parseColor("#FFFFFF")); |
| | | tv_name.setPadding(0, 0, 0, DimenUtils.dip2px(getApplicationContext(), 5)); |
| | | } else { |
| | | tv_name.setBackground(null); |
| | | tv_name.setTextSize(12); |
| | | tv_name.setTextColor(Color.parseColor("#999999")); |
| | | tv_name.setPadding(0, 0, 0, 0); |
| | | } |
| | | } |
| | | |
| | | private void selectTopBar(int p) { |
| | | for (int i = 0; i < ll_top_bar.getChildCount(); i++) { |
| | | TextView tv = ll_top_bar.getChildAt(i).findViewById(R.id.tv_name); |
| | | setTopBarSelect(tv, i == p); |
| | | } |
| | | } |
| | | |
| | | private void suggestSearch(String key) { |
| | | SharedPreferences preferences = getSharedPreferences("user", |
| | |
| | | if (jsonObject.getBoolean("IsPost")) { |
| | | |
| | | JSONObject rootData = jsonObject.getJSONObject("Data"); |
| | | List<VideoInfo> videoInfos = JsonUtil.videoGson.fromJson( |
| | | List<VideoInfo> videoInfos = JsonUtil.videoGson.fromJson( |
| | | |
| | | rootData.getJSONArray("data").toString(), |
| | | new TypeToken<List<VideoInfo>>() { |
| | |
| | | //设置导航栏 |
| | | if (rootData.opt("typeList") != null) { |
| | | if (typeList == null) { |
| | | typeList = JsonUtil.videoGson.fromJson( |
| | | typeList = JsonUtil.videoGson.fromJson( |
| | | rootData |
| | | .getJSONArray("typeList").toString(), |
| | | new TypeToken<List<VideoType>>() { |
New file |
| | |
| | | package com.hanju.video.app.ui.video; |
| | | |
| | | import android.content.pm.ActivityInfo; |
| | | import android.os.Bundle; |
| | | import android.util.Log; |
| | | import android.view.View; |
| | | import android.view.ViewGroup; |
| | | import android.view.WindowManager; |
| | | import android.widget.ImageView; |
| | | |
| | | import com.hanju.lib.library.RetainViewFragment; |
| | | import com.hanju.video.app.R; |
| | | import com.hanju.video.app.util.x5web.X5WebView; |
| | | import com.tencent.smtt.export.external.interfaces.ConsoleMessage; |
| | | import com.tencent.smtt.export.external.interfaces.IX5WebChromeClient; |
| | | import com.tencent.smtt.export.external.interfaces.WebResourceRequest; |
| | | import com.tencent.smtt.export.external.interfaces.WebResourceResponse; |
| | | import com.tencent.smtt.sdk.WebChromeClient; |
| | | import com.tencent.smtt.sdk.WebSettings; |
| | | import com.tencent.smtt.sdk.WebView; |
| | | import com.tencent.smtt.sdk.WebViewClient; |
| | | |
| | | /** |
| | | * 专题碎片 |
| | | */ |
| | | public class VideoWebPlayerFragment extends RetainViewFragment { |
| | | |
| | | private static final String TAG = "VideoWebPlayerFragment"; |
| | | private String playUrl; |
| | | private String url; |
| | | private String title; |
| | | |
| | | private X5WebView webview; |
| | | |
| | | private ImageView iv_back; |
| | | |
| | | public static VideoWebPlayerFragment newInstance(String title, String url, String playUrl) { |
| | | VideoWebPlayerFragment fragment = new VideoWebPlayerFragment(); |
| | | Bundle bundle = new Bundle(); |
| | | bundle.putString("url", url); |
| | | bundle.putString("title", title); |
| | | bundle.putString("playUrl", playUrl); |
| | | fragment.setArguments(bundle); |
| | | return fragment; |
| | | } |
| | | |
| | | public void setVideoInfo(String title, String url, String playUrl) { |
| | | this.title = title; |
| | | this.url = url; |
| | | this.playUrl = playUrl; |
| | | webview.loadUrl(playUrl); |
| | | } |
| | | |
| | | @Override |
| | | public int getContentResource() { |
| | | return R.layout.fragment_web_player; |
| | | } |
| | | |
| | | |
| | | private void initPlayer() { |
| | | } |
| | | |
| | | private void initX5WebView(View view) { |
| | | webview = view.findViewById(R.id.webview); |
| | | webview.setWebViewClient(new WebViewClient() { |
| | | |
| | | @Override |
| | | public boolean shouldOverrideUrlLoading(WebView webView, String s) { |
| | | return super.shouldOverrideUrlLoading(webView, s); |
| | | } |
| | | |
| | | @Override |
| | | public boolean shouldOverrideUrlLoading(WebView webView, WebResourceRequest webResourceRequest) { |
| | | return super.shouldOverrideUrlLoading(webView, webResourceRequest); |
| | | } |
| | | |
| | | @Override |
| | | public WebResourceResponse shouldInterceptRequest(WebView webView, String s) { |
| | | WebResourceResponse resourceResponse = super.shouldInterceptRequest(webView, s); |
| | | return resourceResponse; |
| | | } |
| | | |
| | | |
| | | }); |
| | | webview.setWebChromeClient(new WebChromeClient() { |
| | | |
| | | View myVideoView; |
| | | View myNormalView; |
| | | IX5WebChromeClient.CustomViewCallback callback; |
| | | |
| | | |
| | | @Override |
| | | public boolean onConsoleMessage(ConsoleMessage consoleMessage) { |
| | | Log.i(TAG, consoleMessage.message()); |
| | | return super.onConsoleMessage(consoleMessage); |
| | | } |
| | | |
| | | /** |
| | | * 全屏播放配置 |
| | | */ |
| | | @Override |
| | | public void onShowCustomView(View view, |
| | | IX5WebChromeClient.CustomViewCallback customViewCallback) { |
| | | ViewGroup viewGroup = (ViewGroup) webview.getParent(); |
| | | viewGroup.removeView(webview); |
| | | viewGroup.addView(view); |
| | | myVideoView = view; |
| | | myNormalView = webview; |
| | | callback = customViewCallback; |
| | | getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); |
| | | WindowManager.LayoutParams attrs = getActivity().getWindow().getAttributes(); |
| | | attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN; |
| | | getActivity().getWindow().setAttributes(attrs); |
| | | } |
| | | |
| | | @Override |
| | | public void onHideCustomView() { |
| | | if (callback != null) { |
| | | callback.onCustomViewHidden(); |
| | | callback = null; |
| | | } |
| | | if (myVideoView != null) { |
| | | ViewGroup viewGroup = (ViewGroup) myVideoView.getParent(); |
| | | viewGroup.removeView(myVideoView); |
| | | viewGroup.addView(myNormalView); |
| | | } |
| | | getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); |
| | | WindowManager.LayoutParams attrs = getActivity().getWindow().getAttributes(); |
| | | attrs.flags &= ~WindowManager.LayoutParams.FLAG_FULLSCREEN; |
| | | getActivity().getWindow().setAttributes(attrs); |
| | | } |
| | | |
| | | |
| | | }); |
| | | |
| | | |
| | | WebSettings webSetting = webview.getSettings(); |
| | | webSetting.setJavaScriptEnabled(true); |
| | | webSetting.setTextZoom(100); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void onCreateView(View contentView, Bundle savedInstanceState) { |
| | | |
| | | url = getArguments().getString("url", ""); |
| | | playUrl = getArguments().getString("playUrl", ""); |
| | | title = getArguments().getString("title", ""); |
| | | iv_back = contentView.findViewById(R.id.iv_back); |
| | | iv_back.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View view) { |
| | | |
| | | if (getActivity().getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) { |
| | | getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); |
| | | } else { |
| | | getActivity().finish(); |
| | | } |
| | | } |
| | | }); |
| | | initPlayer(); |
| | | initX5WebView(contentView); |
| | | webview.loadUrl(playUrl); |
| | | } |
| | | |
| | | |
| | | public void onBackPressed() { |
| | | //先返回正常状态 |
| | | if (getActivity().getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) { |
| | | iv_back.performClick(); |
| | | return; |
| | | } |
| | | //释放所有 |
| | | // videoPlayer.setVideoAllCallBack(null); |
| | | } |
| | | |
| | | @Override |
| | | public void onResume() { |
| | | super.onResume(); |
| | | webview.onResume(); |
| | | } |
| | | |
| | | @Override |
| | | public void onPause() { |
| | | super.onPause(); |
| | | webview.onPause(); |
| | | } |
| | | |
| | | @Override |
| | | public void onDestroy() { |
| | | super.onDestroy(); |
| | | } |
| | | } |
| | |
| | | //是否有开屏广告 |
| | | public final static boolean AD_SETTING_KAIPIN = true; |
| | | |
| | | public static final String USER_AGREEMENT = "http://h5.hanju.yeshitv.com/hanju/user_protocol.html"; |
| | | public static final String PRIVACY_POLICY = "http://h5.hanju.yeshitv.com/hanju/privacy.html"; |
| | | public static final String USER_AGREEMENT = "http://h5.hanju.goxcw.com/hanju/user_protocol.html"; |
| | | public static final String PRIVACY_POLICY = "http://h5.hanju.goxcw.com/hanju/privacy.html"; |
| | | public static final String DISCLAIMER = "http://h5.hanju.goxcw.com/hanju/disclaimer.html"; |
| | | |
| | | public static final String HOST = "http://bwapp.flqapp.com:8089";//正式上线版本 |
| | | |
| | | public static final String HOST = "http://api.hanju.goxcw.com:8089";//正式上线版本 |
| | | // public static final String HOST = "http://192.168.3.122:8080";//正式上线版本 |
| | | |
| | | public static final String BAICHUAN_APPKEY = "24980167"; |
| | |
| | | */ |
| | | public static boolean isCanInitCSJ() { |
| | | return Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP; |
| | | // return true; |
| | | // return false; |
| | | } |
| | | |
| | | |
| | |
| | | public class CSJADConstant { |
| | | |
| | | //首页大广告 |
| | | public static String RECOMMEND_BIG_IMG_AD = "945375047"; |
| | | public static String RECOMMEND_BIG_IMG_AD = "947511464"; |
| | | |
| | | //VIVO开屏 |
| | | public static String SPLASH_AD_VIVO = "887378583"; |
| | |
| | | String pid = null; |
| | | if (sourceType == AdUtil.AD_TYPE.csj) { |
| | | pid = CSJADConstant.RECOMMEND_BIG_IMG_AD; |
| | | height = (int) (width * 0.56); |
| | | height = (int) (width * 0.78); |
| | | } else if (sourceType == AdUtil.AD_TYPE.gdt) { |
| | | pid = HanJuConstant.GDT_RECOMMAND_NATIVE; |
| | | } else if (sourceType == AdUtil.AD_TYPE.gdt2) { |
| | |
| | | //加载大图 |
| | | String pid = null; |
| | | if (sourceType == AdUtil.AD_TYPE.csj) { |
| | | pid = "945375047"; |
| | | pid = CSJADConstant.RECOMMEND_BIG_IMG_AD; |
| | | } else if (sourceType == AdUtil.AD_TYPE.gdt) { |
| | | pid = HanJuConstant.GDT_RECOMMAND_MIN_NATIVE; |
| | | } |
| | |
| | | * @param adLoadListener |
| | | */ |
| | | private void loadCSJ(String codeId, int width, int height, int count, final ICSJAdLoadListener adLoadListener) { |
| | | Log.i(TAG,"csj获取广告CodeId:"+codeId); |
| | | count = count > 3 ? 3 : count; |
| | | AdSlot adSlot = new AdSlot.Builder() |
| | | .setCodeId(codeId) |
| | |
| | | @Override |
| | | public void onError(int i, String s) { |
| | | adLoadListener.onSuccess(null); |
| | | Log.i(TAG,"csj获取广告失败:"+s); |
| | | } |
| | | |
| | | @Override |
| | | public void onNativeExpressAdLoad(List<TTNativeExpressAd> list) { |
| | | adLoadListener.onSuccess(list); |
| | | Log.i(TAG,"csj获取广告成功:"+list.size()); |
| | | } |
| | | }); |
| | | } |
| | |
| | | //广告常量 |
| | | public class GDTADConstant { |
| | | |
| | | public static String PID_HOME_RECOMMEND_BIG_IMG="2011627548122579"; |
| | | public static String APPID = ""; |
| | | |
| | | public static String PID_VIDEO_DETAIL_PLAYER="5061928359494942"; |
| | | public static String PID_HOME_RECOMMEND_BIG_IMG = "2011627548122579"; |
| | | |
| | | public static String PID_VIDEO_DETAIL_PLAYER = "5061928359494942"; |
| | | //视频播放器下方广告位 |
| | | public static String PID_2_VIDEO_DETAIL_PLAY_EXPRESS1 = "9031528552257617"; |
| | | //相关视频下方广告位 |
| | |
| | | |
| | | public static String PID_2_VIDEO_LIST_SMALL_AD_COLUMN2 = "7001426565143389"; |
| | | |
| | | public static String PID_SPLASH="2002520811288038"; |
| | | public static String PID_SPLASH = "2002520811288038"; |
| | | |
| | | //视频详情插屏 |
| | | public static String PID_VIDEO_DETAIL_INSERT="7062649756554638"; |
| | | public static String PID_VIDEO_DETAIL_INSERT = "7062649756554638"; |
| | | |
| | | public static String HOME_INTERSTITIALAD = "6092865527203989"; |
| | | |
New file |
| | |
| | | package com.hanju.video.app.util.ui; |
| | | |
| | | import android.annotation.TargetApi; |
| | | import android.app.Activity; |
| | | import android.content.ContentResolver; |
| | | import android.content.Context; |
| | | import android.content.Intent; |
| | | import android.graphics.Bitmap; |
| | | import android.net.Uri; |
| | | import android.os.Build; |
| | | import android.os.Environment; |
| | | import android.os.FileUtils; |
| | | import android.provider.MediaStore; |
| | | import android.webkit.MimeTypeMap; |
| | | |
| | | import java.io.File; |
| | | import java.io.FileOutputStream; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.text.SimpleDateFormat; |
| | | |
| | | import androidx.core.content.FileProvider; |
| | | |
| | | /** |
| | | * 系统裁剪图片工具类 |
| | | */ |
| | | public class SystemClipImageUtil { |
| | | |
| | | /** |
| | | * 剪切图片,兼容android10以上的版本, |
| | | * 注意:需要AndroidManifest中需要配置FileProvider |
| | | * @param context |
| | | * @param uri 原图uri |
| | | * @param name 图片名称 |
| | | * @param width 剪切后的宽 |
| | | * @param height 剪切后的高 |
| | | * @param requestCode 请求码 |
| | | * @return |
| | | */ |
| | | public static Uri startPhotoZoom(Activity context, Uri uri, String name, int width, int height, int requestCode) { |
| | | if (uri == null) { |
| | | return null; |
| | | } |
| | | File cropPhoto = new File(context.getExternalCacheDir(), name); |
| | | //m_ResultImagePath = CropPhoto.getPath(); |
| | | Uri mPhotoUri = Uri.fromFile(cropPhoto); |
| | | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { |
| | | cropPhoto = uriToFileApiQ(uri, context); |
| | | mPhotoUri = FileProvider.getUriForFile(context, |
| | | context.getPackageName() + ".fileprovider", cropPhoto); |
| | | } |
| | | String headPath = cropPhoto.getPath(); |
| | | |
| | | Intent intent = new Intent("com.android.camera.action.CROP"); |
| | | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { |
| | | intent.setDataAndType(mPhotoUri, "image/*"); |
| | | } else { |
| | | intent.setDataAndType(uri, "image/*"); |
| | | } |
| | | |
| | | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { |
| | | intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); //添加这一句表示对目标应用临时授权该Uri所代表的文件 |
| | | } |
| | | intent.putExtra("crop", "true"); |
| | | intent.putExtra("scale", true); |
| | | if (Build.MANUFACTURER.equals("HUAWEI")) { |
| | | intent.putExtra("aspectX", 9998); |
| | | intent.putExtra("aspectY", 9999); |
| | | } else { |
| | | intent.putExtra("aspectX", 1); |
| | | intent.putExtra("aspectY", 1); |
| | | } |
| | | |
| | | intent.putExtra("outputX", width); |
| | | intent.putExtra("outputY", height); |
| | | intent.putExtra("return-data", false); |
| | | intent.putExtra(MediaStore.EXTRA_OUTPUT, mPhotoUri); |
| | | intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString()); |
| | | //intent.putExtra("noFaceDetection", true); // no face detection |
| | | |
| | | try { |
| | | context.startActivityForResult(intent, requestCode);//这里的RESULT_REQUEST_CODE是在startActivityForResult里使用的返回值。 |
| | | } catch (Exception e) { |
| | | // 解决截取后部分机型秒退 |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | return mPhotoUri; |
| | | } |
| | | |
| | | |
| | | @TargetApi(Build.VERSION_CODES.Q) |
| | | private static File uriToFileApiQ(Uri uri, Context context) { |
| | | File file = null; |
| | | if (uri == null) return file; |
| | | //android10以上转换 |
| | | if (uri.getScheme().equals(ContentResolver.SCHEME_FILE)) { |
| | | file = new File(uri.getPath()); |
| | | } else if (uri.getScheme().equals(ContentResolver.SCHEME_CONTENT)) { |
| | | //把文件复制到沙盒目录 |
| | | ContentResolver contentResolver = context.getContentResolver(); |
| | | String displayName = System.currentTimeMillis() + Math.round((Math.random() + 1) * 1000) |
| | | + "." + MimeTypeMap.getSingleton().getExtensionFromMimeType(contentResolver.getType(uri)); |
| | | |
| | | // 注释掉的方法可以获取到原文件的文件名,但是比较耗时 |
| | | // Cursor cursor = contentResolver.query(uri, null, null, null, null); |
| | | // if (cursor.moveToFirst()) { |
| | | // String displayName = cursor.getString(cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME));} |
| | | |
| | | try { |
| | | InputStream is = contentResolver.openInputStream(uri); |
| | | File cache = new File(context.getExternalFilesDir(Environment.DIRECTORY_PICTURES).getAbsolutePath(), displayName); |
| | | FileOutputStream fos = new FileOutputStream(cache); |
| | | FileUtils.copy(is, fos); |
| | | file = cache; |
| | | fos.close(); |
| | | is.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | return file; |
| | | } |
| | | |
| | | |
| | | } |