我的里面信息修改修复,添加umeng事件统计,优化搜索结果页广告
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <shape xmlns:android="http://schemas.android.com/apk/res/android"> |
| | | <corners android:bottomLeftRadius="20dp" /> |
| | | <solid android:color="#656565" /> |
| | | |
| | | </shape> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <shape xmlns:android="http://schemas.android.com/apk/res/android"> |
| | | <corners android:bottomRightRadius="20dp" /> |
| | | <solid android:color="#0052F6" /> |
| | | |
| | | </shape> |
| | |
| | | android:background="@color/register_gray" |
| | | android:orientation="vertical"> |
| | | |
| | | <TextView |
| | | android:id="@+id/textView2" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="center" |
| | | android:background="@color/white" |
| | | android:gravity="center" |
| | | android:padding="5dp" |
| | | android:text="生日选择" |
| | | android:textSize="18sp" /> |
| | | |
| | | <DatePicker |
| | | android:id="@+id/datePicker" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="center_horizontal" |
| | | android:background="@color/white" /> |
| | | |
| | | <LinearLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:layout_marginTop="5dp"> |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_cancel" |
| | | android:layout_width="0dp" |
| | | android:layout_height="38dp" |
| | | android:layout_gravity="center" |
| | | android:layout_weight="1" |
| | | android:background="@color/white" |
| | | android:gravity="center" |
| | | android:text="取消" /> |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_confirm" |
| | | android:layout_width="0dp" |
| | | android:layout_height="38dp" |
| | | android:layout_gravity="center" |
| | | android:layout_marginLeft="5dp" |
| | | android:layout_weight="1" |
| | | android:background="@color/white" |
| | | android:gravity="center" |
| | | android:text="确认" /> |
| | | </LinearLayout> |
| | | </LinearLayout> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent" |
| | | android:background="@color/transparent" |
| | | android:orientation="horizontal"> |
| | | |
| | | |
| | | <TextView |
| | | android:layout_width="0dp" |
| | | android:layout_height="wrap_content" |
| | | android:layout_weight="1" |
| | | android:background="@drawable/shape_dialog_bottom_btn_left_bg" |
| | | android:gravity="center" |
| | | android:padding="10dp" |
| | | android:text="取消" |
| | | android:textColor="@color/white" |
| | | android:textSize="16sp"></TextView> |
| | | |
| | | <TextView |
| | | android:layout_width="0dp" |
| | | android:layout_height="wrap_content" |
| | | android:layout_weight="1" |
| | | android:background="@drawable/shape_dialog_bottom_btn_right_bg" |
| | | android:gravity="center" |
| | | android:padding="10dp" |
| | | android:text="确定" |
| | | android:textColor="@color/white" |
| | | android:textSize="16sp"> |
| | | |
| | | </TextView> |
| | | |
| | | </LinearLayout> |
| | |
| | | android:textStyle="bold" /> |
| | | |
| | | <EditText |
| | | android:gravity="start" |
| | | android:id="@+id/et_dialog_message" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="150dp" |
| | |
| | | android:padding="8dp" /> |
| | | |
| | | <LinearLayout |
| | | android:visibility="gone" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="38dp"> |
| | | |
| | |
| | | android:layout_width="0dp" |
| | | android:layout_height="match_parent" |
| | | android:layout_weight="1" |
| | | android:gravity="center_vertical" |
| | | android:background="@drawable/shape_search_bg"> |
| | | android:background="@drawable/shape_search_bg" |
| | | android:gravity="center_vertical"> |
| | | |
| | | |
| | | <ImageView |
| | |
| | | android:paddingRight="10dp"></android.support.v7.widget.RecyclerView> |
| | | </android.support.v4.widget.SwipeRefreshLayout> |
| | | |
| | | <LinearLayout |
| | | android:id="@+id/ll_empty" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="0dp" |
| | | android:layout_weight="1" |
| | | android:gravity="center" |
| | | android:orientation="vertical" |
| | | android:visibility="gone"> |
| | | |
| | | <ImageView |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:src="@drawable/ic_empty"></ImageView> |
| | | |
| | | <TextView |
| | | android:layout_marginTop="12dp" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:text="抱歉,暂未搜索到相关内容..." |
| | | android:textColor="@color/white"></TextView> |
| | | |
| | | |
| | | </LinearLayout> |
| | | |
| | | <FrameLayout |
| | | android:id="@+id/fl_advertisement" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content"> |
| | | android:layout_height="wrap_content" |
| | | android:visibility="gone"> |
| | | |
| | | <ImageView |
| | | android:id="@+id/iv_search_result_ad" |
| | |
| | | } |
| | | |
| | | public static void getVideoDetail(Context context, String uid, |
| | | String ResourceId, String videoId, Integer position, String loginid, String type, |
| | | String ResourceId, String videoId, Integer position, String loginid, String type, String from, |
| | | ResponseHandlerInterface handler) { |
| | | LinkedHashMap<String, String> params = new LinkedHashMap<String, String>(); |
| | | params.put("Method", "getVideoDetail"); |
| | |
| | | params.put("VideoId", videoId); |
| | | if (position != null) { |
| | | params.put("Position", position + ""); |
| | | } |
| | | |
| | | if (from != null) { |
| | | params.put("From", from + ""); |
| | | } |
| | | params.put("ResourceId", ResourceId); |
| | | params.put("Type", type); |
| | |
| | | for (Iterator<String> its = params.keySet().iterator(); its.hasNext(); ) { |
| | | String key = its.next(); |
| | | if (params.get(key) != null) { |
| | | newParams.put(key,params.get(key)); |
| | | newParams.put(key, params.get(key)); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | private String tag; |
| | | |
| | | private String from; |
| | | |
| | | public VideoInfo getVideoInfo() { |
| | | return videoInfo; |
| | | } |
| | |
| | | public void setTag(String tag) { |
| | | this.tag = tag; |
| | | } |
| | | |
| | | |
| | | public String getFrom() { |
| | | return from; |
| | | } |
| | | |
| | | public void setFrom(String from) { |
| | | this.from = from; |
| | | } |
| | | } |
| | |
| | | import android.widget.Toast; |
| | | |
| | | import com.androidquery.AQuery; |
| | | import com.baidu.mobads.nativecpu.IBasicCPUData; |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.reflect.TypeToken; |
| | | import com.viewpagerindicator.FoundTabPageIndicator; |
| | |
| | | import com.weikou.beibeivideo.BeibeiVideoAPI; |
| | | import com.weikou.beibeivideo.BeibeiVideoApplication; |
| | | import com.weikou.beibeivideo.ui.MyRetainViewFragment; |
| | | import com.weikou.beibeivideo.util.UmengEventUtil; |
| | | import com.weikou.beibeivideo.util.ad.AdUtil; |
| | | import com.weikou.beibeivideo.util.cache.DiskLruCacheManager; |
| | | import com.weikou.beibeivideo.util.downutil.StringUtils; |
| | | import com.yeshi.ec.library_baiducpu.R; |
| | | import com.yeshi.ec.library_baiducpu.adapter.BaiduCPUContentAdapter; |
| | | import com.yeshi.ec.library_baiducpu.entity.BaiDuCPUType; |
| | | import com.yeshi.ec.library_baiducpu.fragment.BaiDuCPUContentFragment; |
| | | |
| | |
| | | |
| | | @Override |
| | | public Fragment getItem(int position) { |
| | | Fragment fragment = BaiDuCPUContentFragment.newInstance(mlist.get(position), BaiDuCPUContentFragment.VIEW_TYPE_NEWS, AdUtil.getAdPid(getContext(), AdUtil.POSITION_SPLASH) != null); |
| | | Fragment fragment = BaiDuCPUContentFragment.newInstance(mlist.get(position), BaiDuCPUContentFragment.VIEW_TYPE_NEWS, AdUtil.getAdPid(getContext(), AdUtil.POSITION_SPLASH) != null, new BaiduCPUContentAdapter.IBaiDuCPUItemClickListener() { |
| | | |
| | | @Override |
| | | public void onClick(IBasicCPUData nrAd) { |
| | | UmengEventUtil.baiduCpuClick(getContext(), "news"); |
| | | } |
| | | }); |
| | | return fragment; |
| | | } |
| | | |
| | |
| | | import android.widget.Toast; |
| | | |
| | | import com.androidquery.AQuery; |
| | | import com.baidu.mobads.nativecpu.IBasicCPUData; |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.reflect.TypeToken; |
| | | import com.viewpagerindicator.FoundTabPageIndicator; |
| | |
| | | import com.weikou.beibeivideo.BeibeiVideoAPI; |
| | | import com.weikou.beibeivideo.BeibeiVideoApplication; |
| | | import com.weikou.beibeivideo.ui.MyRetainViewFragment; |
| | | import com.weikou.beibeivideo.util.UmengEventUtil; |
| | | import com.weikou.beibeivideo.util.ad.AdUtil; |
| | | import com.weikou.beibeivideo.util.cache.DiskLruCacheManager; |
| | | import com.weikou.beibeivideo.util.downutil.StringUtils; |
| | | import com.yeshi.ec.library_baiducpu.R; |
| | | import com.yeshi.ec.library_baiducpu.adapter.BaiduCPUContentAdapter; |
| | | import com.yeshi.ec.library_baiducpu.entity.BaiDuCPUType; |
| | | import com.yeshi.ec.library_baiducpu.fragment.BaiDuCPUContentFragment; |
| | | import com.yeshi.ec.library_baiducpu.fragment.BaiDuShortVideosFragment; |
| | |
| | | if (mlist.get(position).getId() == 1085) |
| | | return BaiDuShortVideosFragment.newInstance(mlist.get(position)); |
| | | else |
| | | return BaiDuCPUContentFragment.newInstance(mlist.get(position), mlist.get(position).getId() == 1085 ? BaiDuCPUContentFragment.VIEW_TYPE_SMALLVIDEO : BaiDuCPUContentFragment.VIEW_TYPE_VIDEO, AdUtil.getAdPid(getContext(), AdUtil.POSITION_SPLASH) != null); |
| | | return BaiDuCPUContentFragment.newInstance(mlist.get(position), mlist.get(position).getId() == 1085 ? BaiDuCPUContentFragment.VIEW_TYPE_SMALLVIDEO : BaiDuCPUContentFragment.VIEW_TYPE_VIDEO, AdUtil.getAdPid(getContext(), AdUtil.POSITION_SPLASH) != null, new BaiduCPUContentAdapter.IBaiDuCPUItemClickListener() { |
| | | @Override |
| | | public void onClick(IBasicCPUData nrAd) { |
| | | UmengEventUtil.baiduCpuClick(getContext(), "videos"); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | @Override |
| | |
| | | Intent intent = new Intent(v.getContext(), VideoDetailActivity2.class); |
| | | intent.putExtra("video_info", mHomeAds.get(position) |
| | | .getVideoInfo()); |
| | | intent.putExtra("from", "recommendCategory"); |
| | | v.getContext().startActivity(intent); |
| | | } |
| | | } |
| | |
| | | if (videoType.getName().contains("电影") || videoType.getName().contains("电视剧") || videoType.getName().contains("综艺") || videoType.getName().contains("动漫")) |
| | | column = 3; |
| | | } |
| | | VideoColumn2Adapter adapter = new VideoColumn2Adapter(mContext, mContext.getApplicationContext(), mVideoList, true, column, null); |
| | | VideoColumn2Adapter adapter = new VideoColumn2Adapter(mContext, mContext.getApplicationContext(), mVideoList, true, column, "categoryRecommend", null); |
| | | if (column == 3) |
| | | adapter.initRecyclerViewDisplayWidthColumn3(viewHolder.rv); |
| | | else |
| | |
| | | .findViewById(R.id.specific_detail_introduction); |
| | | |
| | | mVideoInfos = new ArrayList<>(); |
| | | mSpecificMovieAdapter = new VideoCloumn1Adapter(getActivity(), mVideoInfos); |
| | | mSpecificMovieAdapter = new VideoCloumn1Adapter(getActivity(), mVideoInfos,"special"); |
| | | mSpecificMovieAdapter.setHeaderView(specifi_detail_top); |
| | | rl_specific_detail.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { |
| | | @Override |
| | |
| | | .findViewById(R.id.star_detail_works); |
| | | |
| | | mVideoInfos = new ArrayList<>(); |
| | | mAdapter = new VideoCloumn1Adapter(getActivity(), mVideoInfos); |
| | | mAdapter = new VideoCloumn1Adapter(getActivity(), mVideoInfos,"star"); |
| | | mAdapter.setHeaderView(star_Detail_min_Top); |
| | | rv_Star_Detail.setAdapter(mAdapter); |
| | | ProgressBar pb = new ProgressBar(rv_Star_Detail.getContext()); |
| | |
| | | intent.putExtra("ThirdType", "0"); |
| | | intent.putExtra("ResourceId", ""); |
| | | intent.putExtra("DetailId", ""); |
| | | intent.putExtra("from", "follow"); |
| | | v.getContext().startActivity(intent); |
| | | } |
| | | }); |
| | |
| | | intent.putExtra("ThirdType", "0"); |
| | | intent.putExtra("ResourceId", ""); |
| | | intent.putExtra("DetailId", ""); |
| | | intent.putExtra("from", "follow"); |
| | | v.getContext().startActivity(intent); |
| | | } |
| | | }); |
| | |
| | | columns = 3; |
| | | } |
| | | |
| | | adapter = new VideoColumn2Adapter(getActivity(), getActivity().getApplicationContext(), mVideoInfos, false, columns, null); |
| | | adapter = new VideoColumn2Adapter(getActivity(), getActivity().getApplicationContext(), mVideoInfos, false, columns,"list", null); |
| | | if (columns == 2) |
| | | adapter.initRecyclerViewDisplayWidthColumn2(rv_category_video); |
| | | else |
| | |
| | | import android.view.WindowManager; |
| | | import android.widget.ImageView; |
| | | import android.widget.TextView; |
| | | import android.widget.Toast; |
| | | |
| | | import com.androidquery.AQuery; |
| | | import com.umeng.socialize.ShareAction; |
| | | import com.umeng.socialize.UMShareAPI; |
| | | import com.umeng.socialize.UMShareListener; |
| | | import com.umeng.socialize.bean.SHARE_MEDIA; |
| | | import com.umeng.socialize.media.UMWeb; |
| | | import com.weikou.beibeivideo.R; |
| | |
| | | String shareTitle = context.getResources().getString(R.string.app_name); |
| | | web.setTitle(shareTitle); |
| | | web.setDescription(shareContent); |
| | | new ShareAction(context).withText(shareContent).setPlatform(media).withMedia(web).share(); |
| | | new ShareAction(context).setCallback(new UMShareListener() { |
| | | @Override |
| | | public void onStart(SHARE_MEDIA share_media) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onResult(SHARE_MEDIA share_media) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onError(SHARE_MEDIA share_media, Throwable throwable) { |
| | | |
| | | if (!UMShareAPI.get(context).isInstall(context, share_media)) { |
| | | Toast.makeText(context, share_media == SHARE_MEDIA.QQ ? "没有安装QQ" : "没有安装微信", Toast.LENGTH_LONG).show(); |
| | | } else { |
| | | Toast.makeText(context, "分享出错!", Toast.LENGTH_LONG).show(); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onCancel(SHARE_MEDIA share_media) { |
| | | |
| | | } |
| | | }).withText(shareContent).setPlatform(media).withMedia(web).share(); |
| | | } |
| | | |
| | | public ShareAPPDialog create() { |
| | |
| | | package com.weikou.beibeivideo.ui.login; |
| | | |
| | | import android.Manifest; |
| | | import android.annotation.SuppressLint; |
| | | import android.app.Activity; |
| | | import android.app.AlertDialog; |
| | | import android.app.Dialog; |
| | | import android.content.ActivityNotFoundException; |
| | | import android.content.Context; |
| | | import android.content.DialogInterface; |
| | | import android.content.Intent; |
| | |
| | | import android.graphics.Bitmap; |
| | | import android.graphics.BitmapFactory; |
| | | import android.graphics.Color; |
| | | import android.net.Uri; |
| | | import android.os.Build; |
| | | import android.os.Bundle; |
| | | import android.provider.MediaStore; |
| | | import android.support.annotation.NonNull; |
| | | import android.util.Base64; |
| | | import android.util.Log; |
| | | import android.view.LayoutInflater; |
| | |
| | | import com.google.gson.Gson; |
| | | import com.lcjian.library.dialog.DialogUtil; |
| | | import com.lcjian.library.util.Environment; |
| | | import com.lcjian.library.permission.PermissionHelper; |
| | | import com.lcjian.library.permission.PermissionInterface; |
| | | import com.lcjian.library.util.SingleToast; |
| | | import com.lcjian.library.util.common.StringUtils; |
| | | import com.tencent.mm.opensdk.modelmsg.SendAuth; |
| | |
| | | import com.weikou.beibeivideo.ui.BaseActivity; |
| | | import com.weikou.beibeivideo.ui.dialog.LoadingDialogUtil; |
| | | import com.weikou.beibeivideo.util.BeibeiConstant; |
| | | import com.weikou.beibeivideo.util.FileUtils; |
| | | import com.weikou.beibeivideo.util.GlideCircleTransform; |
| | | import com.weikou.beibeivideo.util.SelectPicUtil; |
| | | import com.weikou.beibeivideo.R; |
| | | import com.weikou.beibeivideo.util.UserUtil; |
| | | |
| | |
| | | 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 java.util.Map; |
| | | |
| | |
| | | * Created by weikou2015 on 2016/10/27. |
| | | */ |
| | | |
| | | public class PersonInfoActivity extends BaseActivity implements View.OnClickListener { |
| | | public class PersonInfoActivity extends BaseActivity implements View.OnClickListener, PermissionInterface { |
| | | |
| | | private String TAG = PersonInfoActivity.class.getSimpleName(); |
| | | |
| | |
| | | tv_bind_qq.setOnClickListener(this); |
| | | tv_bind_wx.setOnClickListener(this); |
| | | tv_bind_phone.setOnClickListener(this); |
| | | mPermissionsChecker = new PermissionHelper(this, this);//权限 |
| | | |
| | | } |
| | | |
| | |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 权限请求码 |
| | | * |
| | | * @return |
| | | */ |
| | | @Override |
| | | public int getPermissionsRequestCode() { |
| | | return 1001; |
| | | } |
| | | |
| | | /** |
| | | * 请求权限 |
| | | * |
| | | * @return |
| | | */ |
| | | @Override |
| | | public String[] getPermissions() { |
| | | return new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE}; |
| | | } |
| | | |
| | | /** |
| | | * 权限请求成功 |
| | | */ |
| | | @Override |
| | | public void requestPermissionsSuccess() { |
| | | ll_portrait.performClick(); |
| | | } |
| | | |
| | | /** |
| | | * 权限请求失败 |
| | | */ |
| | | @Override |
| | | public void requestPermissionsFail() { |
| | | // Toast.makeText(this, "你以拒绝权限", Toast.LENGTH_SHORT).show(); |
| | | } |
| | | |
| | | /** |
| | | * 请求权限结果 |
| | | * |
| | | * @param requestCode |
| | | * @param permissions |
| | | * @param grantResults |
| | | */ |
| | | @Override |
| | | public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { |
| | | if (mPermissionsChecker.requestPermissionsResult(requestCode, permissions, grantResults)) { |
| | | //权限请求结果,并已经处理了该回调 |
| | | return; |
| | | } |
| | | super.onRequestPermissionsResult(requestCode, permissions, grantResults); |
| | | } |
| | | |
| | | |
| | | String imgBase64 = ""; |
| | | |
| | | private Uri uriClipUri;//剪裁图片路径 |
| | | |
| | | @Override |
| | | protected void onActivityResult(int requestCode, int resultCode, Intent data) { |
| | | super.onActivityResult(requestCode, resultCode, data); |
| | | UMShareAPI.get(this).onActivityResult(requestCode, resultCode, data); |
| | | if (resultCode == Activity.RESULT_OK) { |
| | | Bitmap bm = null; |
| | | bm = SelectPicUtil.onActivityResult(this, requestCode, |
| | | resultCode, data, imgWidth, imgHeight, imgWidth, |
| | | imgHeight); |
| | | |
| | | if (bm != null) { |
| | | if (bm.getByteCount() / 1024 > maxSize) { |
| | | bm = compressImage(bm); |
| | | //图库 |
| | | if (resultCode == RESULT_OK && resultCode != RESULT_CANCELED && requestCode == 1001 && data != null) {//相册 |
| | | Uri selectedImage = data.getData(); |
| | | startPhotoZoom(selectedImage);//系统剪裁 |
| | | } else if (resultCode == RESULT_OK && requestCode == 1002 && data != null) {//剪裁完成 |
| | | if (uriClipUri != null) { |
| | | //图库 |
| | | Photo_crop crop = new Photo_crop();//初始化 图片压缩 |
| | | File f = new File(uriClipUri.getPath());//获取图片 |
| | | if (crop.compressPhto(f, false)) {//压缩并保存成功 |
| | | Uri uri = Uri.parse("file://" + "/" + android.os.Environment.getExternalStorageDirectory().getPath() + "/YSDQImg/" + "avatar.png"); |
| | | f = new File(uri.getPath()); |
| | | 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); |
| | | //上传 |
| | | updatePersonInfo(null, null, null, imgBase64, null); |
| | | } |
| | | String path = saveBitmapTofile(bm); |
| | | final File file = new File(path); |
| | | if (!file.exists()) { |
| | | return; |
| | | } |
| | | imgBase64 = bitmapToBase64(bm); |
| | | Log.i("mresult", "图片路劲为:" + path + "----requestcode:" + requestCode); |
| | | Glide.with(PersonInfoActivity.this).load(file).transform(new GlideCircleTransform(PersonInfoActivity.this)).into(iv_portrait); |
| | | //上传 |
| | | updatePersonInfo(null, null, null, imgBase64, null); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private String bitmapToBase64(Bitmap bitmap) { |
| | | /** |
| | | * 获取相册图片 |
| | | * |
| | | * @param uri |
| | | */ |
| | | public void startPhotoZoom(Uri uri) { |
| | | File storageDir = new File(android.os.Environment.getExternalStorageDirectory().getPath() + "/YSDQImg/"); |
| | | 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); |
| | | |
| | | String result = null; |
| | | ByteArrayOutputStream baos = null; |
| | | //uritempFile为Uri类变量,实例化uritempFile |
| | | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { |
| | | //如果是7.0的相册 |
| | | //设置裁剪的图片地址Uri |
| | | uriClipUri = Uri.parse("file://" + "/" + android.os.Environment.getExternalStorageDirectory().getPath() + "/YSDQImg/" + System.currentTimeMillis() + "_clip.jpg"); |
| | | } else { |
| | | uriClipUri = Uri.parse("file://" + "/" + android.os.Environment.getExternalStorageDirectory().getPath() + "/YSDQImg/" + System.currentTimeMillis() + "_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);//裁剪完成的标识 |
| | | } |
| | | |
| | | private String bitmapToBase64(File file) { |
| | | String base64 = null; |
| | | InputStream in = null; |
| | | 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); |
| | | } |
| | | in = new FileInputStream(file); |
| | | byte[] bytes = new byte[in.available()]; |
| | | int length = in.read(bytes); |
| | | base64 = 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 base64; |
| | | |
| | | } |
| | | |
| | | private String saveBitmapTofile(Bitmap bm) { |
| | |
| | | return bitmap; |
| | | } |
| | | |
| | | private PermissionHelper mPermissionsChecker; // 权限检测器 检测是否有储存卡写入读取权限 |
| | | |
| | | @Override |
| | | public void onClick(View v) { |
| | | switch (v.getId()) { |
| | |
| | | finish(); |
| | | break; |
| | | case R.id.ll_portrait_select: |
| | | SelectPicUtil.getByAlbum(PersonInfoActivity.this); |
| | | if (mPermissionsChecker.lacksPermissions(getPermissions())) {//检测是否有写入的权限 |
| | | mPermissionsChecker.showNormalDialog(); |
| | | } else { |
| | | Intent picture = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); |
| | | try { |
| | | startActivityForResult(picture, 1001); |
| | | } catch (ActivityNotFoundException exception) { |
| | | Toast.makeText(this, "no activity", Toast.LENGTH_SHORT).show(); |
| | | } |
| | | } |
| | | break; |
| | | case R.id.ll_nickName: |
| | | getNickName(); |
| | |
| | | String loginUid = UserUtil.getLoginUid(this); |
| | | BeibeiVideoAPI.upLoadPersonInfo(this, uid, loginUid, sex, birthday, |
| | | personSign, portrait, nickName, new BasicTextHttpResponseHandler() { |
| | | |
| | | @Override |
| | | public void onStart() { |
| | | super.onStart(); |
| | | if (portrait != null) |
| | | DialogUtil.show(loadingDialog); |
| | | } |
| | | |
| | | @Override |
| | | public void onFinish() { |
| | | super.onFinish(); |
| | | DialogUtil.dismiss(loadingDialog); |
| | | } |
| | | |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception { |
| | | if (jsonObject.optBoolean("IsPost")) { |
| | |
| | | |
| | | private void getAutograph() { |
| | | View v = LayoutInflater.from(this).inflate(R.layout.item_edit_dialog, null); |
| | | if (isFinishing()) |
| | | return; |
| | | final AlertDialog alertDialog = new AlertDialog.Builder(PersonInfoActivity.this).setView(v).create(); |
| | | alertDialog.show(); |
| | | TextView tv_title = (TextView) v.findViewById(R.id.tv_dialog_title); |
| | | tv_title.setText("个性签名"); |
| | | tv_title.setVisibility(View.GONE); |
| | | final EditText et_msg = (EditText) v.findViewById(R.id.et_dialog_message); |
| | | TextView tv_cancel = (TextView) v.findViewById(R.id.tv_cancel); |
| | | TextView tv_confirm = (TextView) v.findViewById(R.id.tv_confirm); |
| | | et_msg.setText(sign); |
| | | et_msg.setSelection(et_msg.getText().length()); |
| | | tv_cancel.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | alertDialog.dismiss(); |
| | | } |
| | | }); |
| | | |
| | | tv_confirm.setOnClickListener(new View.OnClickListener() { |
| | | if (isFinishing()) |
| | | return; |
| | | final AlertDialog alertDialog = new AlertDialog.Builder(PersonInfoActivity.this).setTitle("个性签名").setView(v).setNegativeButton("取消", new DialogInterface.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | public void onClick(DialogInterface dialog, int which) { |
| | | dialog.dismiss(); |
| | | } |
| | | }).setPositiveButton("确定", new DialogInterface.OnClickListener() { |
| | | @Override |
| | | public void onClick(DialogInterface dialog, int which) { |
| | | String str = et_msg.getText().toString(); |
| | | if (StringUtils.isEmpty(str)) { |
| | | SingleToast.showToast(PersonInfoActivity.this, "个性签名不能为空"); |
| | |
| | | } else { |
| | | tv_autograph.setText(str); |
| | | updatePersonInfo(null, null, str, null, null); |
| | | alertDialog.dismiss(); |
| | | dialog.dismiss(); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | }).create(); |
| | | alertDialog.show(); |
| | | et_msg.setText(sign); |
| | | et_msg.setSelection(et_msg.getText().length()); |
| | | } |
| | | |
| | | private void getNickName() { |
| | | final EditText et_msg = new EditText(this); |
| | | et_msg.setBackground(null); |
| | | if (isFinishing()) |
| | | return; |
| | | if (tv_nickName.getText() != null) { |
| | | et_msg.setText(tv_nickName.getText() + ""); |
| | | et_msg.setSelection(tv_nickName.getText().length()); |
| | | } |
| | | AlertDialog alertDialog = new AlertDialog.Builder(PersonInfoActivity.this).setView(et_msg).setTitle("昵称修改") |
| | | .setPositiveButton("确定", new DialogInterface.OnClickListener() { |
| | | @Override |
| | |
| | | View view = LayoutInflater.from(this).inflate(R.layout.item_datepicker, null); |
| | | if (isFinishing()) |
| | | return; |
| | | final AlertDialog alertDialog = new AlertDialog.Builder(PersonInfoActivity.this).setView(view).create(); |
| | | final AlertDialog alertDialog = new AlertDialog.Builder(PersonInfoActivity.this).setView(view).setNegativeButton("取消", new DialogInterface.OnClickListener() { |
| | | @Override |
| | | public void onClick(DialogInterface dialog, int which) { |
| | | dialog.dismiss(); |
| | | } |
| | | }).setPositiveButton("确定", new DialogInterface.OnClickListener() { |
| | | @Override |
| | | public void onClick(DialogInterface dialog, int which) { |
| | | tv_birthday.setText(date); |
| | | updatePersonInfo(null, date, null, null, null); |
| | | dialog.dismiss(); |
| | | } |
| | | }).setTitle("生日选择").create(); |
| | | alertDialog.show(); |
| | | DatePicker datePicker = (DatePicker) view.findViewById(R.id.datePicker); |
| | | TextView tv_cancel = (TextView) view.findViewById(R.id.tv_cancel); |
| | |
| | | date = year + "/" + (monthOfYear + 1) + "/" + dayOfMonth; |
| | | } |
| | | }); |
| | | tv_cancel.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | alertDialog.dismiss(); |
| | | } |
| | | }); |
| | | tv_confirm.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | tv_birthday.setText(date); |
| | | updatePersonInfo(null, date, null, null, null); |
| | | alertDialog.dismiss(); |
| | | } |
| | | }); |
| | | |
| | | } |
| | | |
| | | @Override |
| | |
| | | getPersonInfo(); |
| | | } |
| | | |
| | | @Override |
| | | protected void onDestroy() { |
| | | super.onDestroy(); |
| | | String filePath = android.os.Environment.getExternalStorageDirectory().getPath() + "/YSDQImg/"; |
| | | if (new File(filePath).exists()) { |
| | | FileUtils.deleteDirectory(filePath); |
| | | } |
| | | } |
| | | |
| | | class Photo_crop { |
| | | /** |
| | | * 获取相册图片 |
| | | * |
| | | * @param uri |
| | | */ |
| | | public Uri startPhotoZoom(Uri uri, Context mContext) { |
| | | Uri uriClipUri = null; |
| | | //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", 600);//返回数据的时候的X像素大小。 |
| | | intent.putExtra("outputY", 600);//返回数据的时候的Y像素大小。 |
| | | //裁剪时是否保留图片的比例,这里的比例是1:1 |
| | | intent.putExtra("scale", true); |
| | | //是否是圆形裁剪区域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() + "/YSDQImg/" + "clip.jpg"); |
| | | } else { |
| | | uriClipUri = Uri.parse("file://" + "/" + android.os.Environment.getExternalStorageDirectory().getPath() + "/YSDQImg/" + "clip.jpg"); |
| | | } |
| | | Log.e("uriClipUri=====", "" + uriClipUri); |
| | | //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);//人脸识别功能 |
| | | ((Activity) mContext).startActivityForResult(intent, 1002);//裁剪完成的标识 |
| | | return uriClipUri; |
| | | } |
| | | |
| | | /** |
| | | * 图片压缩的方法(只是内存减少,避免oom,图片本身在disk盘体积不变) |
| | | * 显示的Bitmap占用的内存少一点,还是需要去设置加载的像素长度和宽度(变成缩略图) |
| | | * |
| | | * @param mFile |
| | | * @param crop 是否剪裁圆形图片 true 是 false 否 |
| | | * @return |
| | | */ |
| | | public boolean compressPhto(File mFile, boolean crop) { |
| | | // BitmapFactory这个类就提供了多个解析方法(decodeResource、decodeStream、decodeFile等)用于创建Bitmap。 |
| | | // 比如如果图片来源于网络,就可以使用decodeStream方法; |
| | | // 如果是sd卡里面的图片,就可以选择decodeFile方法; |
| | | // 如果是资源文件里面的图片,就可以使用decodeResource方法等 |
| | | BitmapFactory.Options options = new BitmapFactory.Options(); |
| | | options.inJustDecodeBounds = true; // 获取当前图片的边界大小 |
| | | //BitmapFactory.decodeResource(getResources(), R.drawable.bg, options); |
| | | BitmapFactory.decodeFile(mFile.getAbsolutePath(), options); |
| | | int outHeight = options.outHeight; //获取图片本身的高像素 |
| | | int outWidth = options.outWidth;//获取图片本身的宽的像素 |
| | | String outMimeType = options.outMimeType; |
| | | options.inJustDecodeBounds = false; |
| | | //inSampleSize的作用就是可以把图片的长短缩小inSampleSize倍,所占内存缩小inSampleSize的平方 |
| | | //对于inSampleSize值的大小有要求,最好是整数且2的倍数 |
| | | options.inSampleSize = caculateSampleSize(options, 500, 500); |
| | | //etPath()得到的是构造file的时候的路径。getAbsolutePath()得到的是全路径 |
| | | String path = mFile.getPath(); |
| | | String absPath = mFile.getAbsolutePath(); |
| | | Bitmap bitmap = BitmapFactory.decodeFile(absPath, options); |
| | | try { |
| | | return saveBitmap(bitmap, "avatar.png", crop);//保存成功 |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | return false; |
| | | } |
| | | // ivUserPhoto.setImageBitmap(bitmap); |
| | | // //尺寸压缩结果 |
| | | // ivSize.setImageBitmap(bitmap); |
| | | } |
| | | |
| | | /** |
| | | * 计算出所需要压缩的大小 |
| | | * |
| | | * @param options |
| | | * @param reqWidth 希望的图片宽大小 |
| | | * @param reqHeight 希望的图片高大小 |
| | | * @return |
| | | */ |
| | | private int caculateSampleSize(BitmapFactory.Options options, int reqWidth, int reqHeight) { |
| | | int sampleSize = 1; |
| | | int picWidth = options.outWidth; |
| | | int picHeight = options.outHeight; |
| | | if (picWidth > reqWidth || picHeight > reqHeight) { |
| | | int halfPicWidth = picWidth / 2; |
| | | int halfPicHeight = picHeight / 2; |
| | | while (halfPicWidth / sampleSize > reqWidth || halfPicHeight / sampleSize > reqHeight) { |
| | | sampleSize *= 2; |
| | | } |
| | | } |
| | | return sampleSize; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 保存文件, |
| | | * |
| | | * @param bitmap |
| | | * @param bitName 文件名 |
| | | * @param crop |
| | | * @return |
| | | * @throws IOException |
| | | */ |
| | | private boolean saveBitmap(Bitmap bitmap, String bitName, boolean crop) throws IOException { |
| | | boolean save = false; |
| | | File storageDir = new File(Environment.getExternalStorageDirectory().getPath() + "/YSDQImg/"); |
| | | if (!storageDir.exists()) {//没有文件夹则创建 |
| | | storageDir.mkdir(); |
| | | } |
| | | String fileName; |
| | | File file; |
| | | fileName = Environment.getExternalStorageDirectory().getPath() + "/YSDQImg/" + bitName; |
| | | file = new File(fileName); |
| | | if (bitmap != null) { |
| | | if (file.exists()) { |
| | | file.delete(); |
| | | } |
| | | FileOutputStream out; |
| | | |
| | | out = new FileOutputStream(file); |
| | | // 格式为 JPEG,照相机拍出的图片为JPEG格式的,PNG格式的不能显示在相册中 |
| | | if (bitmap.compress(Bitmap.CompressFormat.JPEG, 90, out)) { |
| | | out.flush(); |
| | | out.close(); |
| | | } |
| | | save = true;//保存成功 |
| | | } |
| | | return save; |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | import com.google.gson.reflect.TypeToken; |
| | | import com.lcjian.library.util.FragmentSwitchHelper; |
| | | import com.lcjian.library.util.MarketUtils; |
| | | import com.lcjian.library.util.common.ClipboardUtil; |
| | | import com.lcjian.library.util.common.StringUtils; |
| | | import com.mozillaonline.providers.downloads.DownloadService; |
| | | import com.qq.e.ads.cfg.VideoOption; |
| | |
| | | import com.weikou.beibeivideo.BeibeiVideoAPI; |
| | | import com.weikou.beibeivideo.R; |
| | | import com.weikou.beibeivideo.db.MessageTable; |
| | | import com.weikou.beibeivideo.entity.JumpDetail; |
| | | import com.weikou.beibeivideo.entity.NewComment; |
| | | import com.weikou.beibeivideo.entity.VideoInfo; |
| | | import com.weikou.beibeivideo.ui.BaseActivity; |
| | |
| | | import com.weikou.beibeivideo.ui.mine.WatchHistoryActivity; |
| | | import com.weikou.beibeivideo.ui.push.PushOpenClickActivity; |
| | | import com.weikou.beibeivideo.ui.recommend.SearchActivity; |
| | | import com.weikou.beibeivideo.util.AlibcTradeUtil; |
| | | import com.weikou.beibeivideo.util.BeibeiConstant; |
| | | import com.weikou.beibeivideo.util.ExitDialog; |
| | | import com.weikou.beibeivideo.util.JumpActivityUtil; |
| | | import com.weikou.beibeivideo.util.LoginFirstDialog; |
| | | import com.weikou.beibeivideo.util.UserUtil; |
| | | import com.weikou.beibeivideo.util.ad.manager.SearchResultAdManager; |
| | | import com.weikou.beibeivideo.util.browser.BWJavaInterface; |
| | | import com.yeshi.appupdate.AppUpdate; |
| | | |
| | | import org.apache.http.Header; |
| | |
| | | |
| | | private int episodePage = 2;//当前页 |
| | | |
| | | private String fromName = null; |
| | | |
| | | public static DisplayImageOptions option = new DisplayImageOptions.Builder() |
| | | .showImageForEmptyUri(R.drawable.from_other) |
| | | .showImageOnFail(R.drawable.from_other) |
| | |
| | | .build(); |
| | | |
| | | public static EpisodeFragment newInstance(VideoInfo videoInfo, |
| | | int playingPosition, int start, int end) { |
| | | int playingPosition, int start, int end,String from) { |
| | | EpisodeFragment episodeFragment = new EpisodeFragment(); |
| | | Bundle args = new Bundle(); |
| | | args.putSerializable("video_info", videoInfo); |
| | | args.putInt("playing_position", playingPosition); |
| | | args.putInt("start", start); |
| | | args.putInt("end", end); |
| | | args.putString("from", from); |
| | | episodeFragment.setArguments(args); |
| | | return episodeFragment; |
| | | } |
| | |
| | | Bundle bundle = getArguments(); |
| | | mVideoInfo = (VideoInfo) bundle |
| | | .getSerializable("video_info"); |
| | | fromName = bundle |
| | | .getString("from", ""); |
| | | |
| | | mPlayingPosition = bundle.getInt("playing_position"); |
| | | mStart = bundle.getInt("start"); |
| | | mEnd = bundle.getInt("end"); |
| | |
| | | pd.show(); |
| | | getVideoDetail(mVideoInfo.getId(), urlList |
| | | .get(position).getId(), mVideoInfo |
| | | .getThirdType(), true); |
| | | .getThirdType(), true,fromName); |
| | | } |
| | | selectedUrl = urlList.get(position); |
| | | if (selectedUrl == null || selectedUrl.getPicture() == null) { |
| | |
| | | } |
| | | |
| | | private void getVideoDetail(String videoId, final String resourceId, |
| | | String videoThirdType, final boolean isSetup) { |
| | | String videoThirdType, final boolean isSetup, final String from) { |
| | | SharedPreferences preferences = getContext().getSharedPreferences( |
| | | "user", Context.MODE_PRIVATE); |
| | | String uid = preferences.getString("uid", ""); |
| | | String loginid = preferences.getString("LoginUid", ""); |
| | | BeibeiVideoAPI.getVideoDetail(getContext(), uid, resourceId, videoId,null, loginid, |
| | | videoThirdType, new BasicTextHttpResponseHandler() { |
| | | BeibeiVideoAPI.getVideoDetail(getContext(), uid, resourceId, videoId, null, loginid, |
| | | videoThirdType, from, new BasicTextHttpResponseHandler() { |
| | | |
| | | @Override |
| | | public void onStart() { |
| | |
| | | }.getType()); |
| | | if (videoInfo != null) { |
| | | |
| | | VideoUtil.saveVideoEpisodeList(BeibeiVideoApplication.application,videoInfo.getVideoDetailList(),false); |
| | | VideoUtil.saveVideoEpisodeList(BeibeiVideoApplication.application, videoInfo.getVideoDetailList(), false); |
| | | |
| | | } |
| | | // 附加字段 |
| | |
| | | rv_episode.getAdapter().notifyDataSetChanged(); |
| | | // videoInfo.setSave(jsonObject.getJSONObject("Data").optBoolean("Save")); |
| | | if (isSetup) { |
| | | VideoUtil.saveVideoEpisodeList(BeibeiVideoApplication.application,videoInfo.getVideoDetailList(),false); |
| | | VideoUtil.saveVideoEpisodeList(BeibeiVideoApplication.application, videoInfo.getVideoDetailList(), false); |
| | | |
| | | EventBus.getDefault().post(videoInfo); |
| | | int position = 0; |
| | |
| | | }.getType()); |
| | | if (list != null && list.size() > 0) { |
| | | episodePage++; |
| | | VideoUtil.saveVideoEpisodeList(BeibeiVideoApplication.application,list,true); |
| | | VideoUtil.saveVideoEpisodeList(BeibeiVideoApplication.application, list, true); |
| | | rv_episode.getAdapter().notifyDataSetChanged(); |
| | | } |
| | | } |
| | |
| | | |
| | | private int mPlayingPosition; |
| | | |
| | | private String fromName; |
| | | |
| | | public EpisodePagerAdapter(FragmentManager fm, VideoInfo videoInfo, |
| | | int playingPosition) { |
| | | int playingPosition, String from) { |
| | | super(fm); |
| | | this.mVideoInfo = videoInfo; |
| | | this.mPlayingPosition = playingPosition; |
| | | this.fromName = from; |
| | | } |
| | | |
| | | @Override |
| | |
| | | end = VideoUtil.videoEpisodeList.size(); |
| | | } |
| | | return EpisodeFragment.newInstance(mVideoInfo, getPlayingPosition(), start, |
| | | end); |
| | | end, fromName); |
| | | } |
| | | |
| | | @Override |
| | |
| | | String uid = preferences.getString("uid", ""); |
| | | String loginid = preferences.getString("LoginUid", ""); |
| | | BeibeiVideoAPI.getVideoDetail(context, uid, resourceId, videoId,null, loginid, |
| | | videoThirdType, new BasicTextHttpResponseHandler() { |
| | | videoThirdType,"", new BasicTextHttpResponseHandler() { |
| | | |
| | | @Override |
| | | public void onStart() { |
| | |
| | | import com.weikou.beibeivideo.ui.video.FunshionPlayerFragment; |
| | | import com.weikou.beibeivideo.ui.video.VideoPlayerActivity; |
| | | import com.weikou.beibeivideo.util.BeibeiConstant; |
| | | import com.weikou.beibeivideo.util.UmengEventUtil; |
| | | import com.weikou.beibeivideo.util.VideoUtil; |
| | | import com.weikou.beibeivideo.util.ad.FullVideoAdManager; |
| | | import com.weikou.beibeivideo.util.ui.IPageEventListener; |
| | |
| | | |
| | | private boolean playerLock;//播放器是否锁屏 |
| | | |
| | | private String from; |
| | | |
| | | @Override |
| | | protected void onSaveInstanceState(Bundle outState) { |
| | | outState.putString("flash exit", "VideoDetailActivity"); |
| | |
| | | "video_info"); |
| | | if (videoInfo != null) |
| | | videoInfo.setVideoDetailList(null); |
| | | |
| | | from = getIntent().getStringExtra("from"); |
| | | UmengEventUtil.videoDetail(getApplicationContext(), from); |
| | | |
| | | if (getIntent().getBooleanExtra("isFromWatchHistory", false)) { |
| | | Cursor cursor = getContentResolver().query( |
| | | WatchHistoryTable.CONTENT_URI, null, |
| | |
| | | if (!progressDialog.isShowing()) { |
| | | progressDialog.show(); |
| | | } |
| | | getVideoDetail(this, videoInfo.getId(), videoInfo.getThirdType(), false); |
| | | getVideoDetail(this, videoInfo.getId(), videoInfo.getThirdType(), false, changeVideoEvent.getFrom()); |
| | | } |
| | | |
| | | public void onEventMainThread(Play info) { |
| | |
| | | } |
| | | |
| | | private void getVideoDetail(final Context context, String videoId, |
| | | String videoThirdType, final boolean isSetup) { |
| | | String videoThirdType, final boolean isSetup, final String fromName) { |
| | | int position = getIntent().getIntExtra( |
| | | "playing_position", 0); |
| | | SharedPreferences preferences = context.getSharedPreferences("user", |
| | |
| | | String uid = preferences.getString("uid", ""); |
| | | String loginid = preferences.getString("LoginUid", ""); |
| | | BeibeiVideoAPI.getVideoDetail(context, uid, resourceId, videoId, position, loginid, |
| | | videoThirdType, new BasicTextHttpResponseHandler() { |
| | | videoThirdType, fromName, new BasicTextHttpResponseHandler() { |
| | | |
| | | @Override |
| | | public void onStart() { |
| | |
| | | JSONObject data = jsonObject.optJSONObject("Data"); |
| | | boolean pptv = data.optBoolean("pptv", false); |
| | | if (pptv) { |
| | | UmengEventUtil.pptvPlay(getApplicationContext()); |
| | | String playUrl = data.optString("playUrl"); |
| | | fl_pptv.setVisibility(View.VISIBLE); |
| | | ll_other.setVerticalGravity(View.GONE); |
| | |
| | | if (VideoUtil.videoEpisodeList == null |
| | | || VideoUtil.videoEpisodeList.isEmpty()) { |
| | | getVideoDetail(this, videoInfo.getId(), videoInfo.getThirdType(), |
| | | true); |
| | | true, from); |
| | | } else { |
| | | findViewById(android.R.id.content).postDelayed(new Runnable() { |
| | | |
| | |
| | | |
| | | |
| | | final String TAG = "VideoEpisodeFragment"; |
| | | private String from; |
| | | |
| | | public static VideoEpisodeFragment newInstance(VideoInfo videoInfo, |
| | | int playingPostion) { |
| | | int playingPostion, String from) { |
| | | VideoEpisodeFragment videoEpisodeFragment = new VideoEpisodeFragment(); |
| | | Bundle args = new Bundle(); |
| | | args.putSerializable("video_info", videoInfo); |
| | | args.putInt("playing_position", playingPostion); |
| | | args.putString("from", from); |
| | | videoEpisodeFragment.setArguments(args); |
| | | return videoEpisodeFragment; |
| | | } |
| | |
| | | return; |
| | | |
| | | mEpisodePagerAdapter = new EpisodePagerAdapter( |
| | | getChildFragmentManager(), mVideoInfo, mPlayingPosition); |
| | | getChildFragmentManager(), mVideoInfo, mPlayingPosition, from); |
| | | // |
| | | vp_episode.setAdapter(mEpisodePagerAdapter); |
| | | // 指示当前播放页---hxh |
| | |
| | | ll_relative_video.setVisibility(View.GONE); |
| | | } else { |
| | | ll_relative_video.setVisibility(View.VISIBLE); |
| | | final VideoColumn2Adapter adapter = new VideoColumn2Adapter(getActivity(), getContext(), videoInfos, false, 2, new IVideoClickListener() { |
| | | final VideoColumn2Adapter adapter = new VideoColumn2Adapter(getActivity(), getContext(), videoInfos, false, 2,"relative", new IVideoClickListener() { |
| | | @Override |
| | | public void onClick(VideoInfo video) { |
| | | ChangeVideoEvent changeVideoEvent = new ChangeVideoEvent(); |
| | | changeVideoEvent.setVideoInfo(video); |
| | | changeVideoEvent.setTag("VideoPlayerFragment"); |
| | | changeVideoEvent.setFrom("relative"); |
| | | EventBus.getDefault().post(changeVideoEvent); |
| | | } |
| | | }); |
| | |
| | | .getJSONArray("data").toString(), |
| | | new TypeToken<List<VideoInfo>>() { |
| | | }.getType()); |
| | | final VideoColumn2Adapter adapter = new VideoColumn2Adapter(getActivity(), getContext(), videoInfos, false, 2, new IVideoClickListener() { |
| | | final VideoColumn2Adapter adapter = new VideoColumn2Adapter(getActivity(), getContext(), videoInfos, false, 2,"guessLike", new IVideoClickListener() { |
| | | @Override |
| | | public void onClick(VideoInfo video) { |
| | | ChangeVideoEvent changeVideoEvent = new ChangeVideoEvent(); |
| | | changeVideoEvent.setVideoInfo(video); |
| | | changeVideoEvent.setTag("VideoPlayerFragment"); |
| | | changeVideoEvent.setFrom("guessLike"); |
| | | EventBus.getDefault().post(changeVideoEvent); |
| | | } |
| | | }); |
| | |
| | | super.onResume(); |
| | | EventBus.getDefault().register(this); |
| | | MobclickAgent.onPageStart("播放详情—选集"); |
| | | Log.i(TAG,"onResume"); |
| | | Log.i(TAG, "onResume"); |
| | | } |
| | | |
| | | @Override |
| | |
| | | isShowMore = false; |
| | | page_varietyshow = 0; |
| | | MobclickAgent.onPageEnd("播放详情—选集"); |
| | | Log.i(TAG,"onPause"); |
| | | Log.i(TAG, "onPause"); |
| | | } |
| | | |
| | | public void onEventMainThread(VideoInfo info) { |
| | |
| | | mPlayingPosition = playingPosition; |
| | | } |
| | | mEpisodePagerAdapter = new EpisodePagerAdapter( |
| | | getChildFragmentManager(), info, mPlayingPosition); |
| | | getChildFragmentManager(), info, mPlayingPosition, from); |
| | | // |
| | | vp_episode.setAdapter(mEpisodePagerAdapter); |
| | | } |
| | |
| | | if (rv_video_related_video != null && adRunnable != null) |
| | | rv_video_related_video.removeCallbacks(adRunnable); |
| | | super.onDestroy(); |
| | | Log.i(TAG,"onDestroy"); |
| | | Log.i(TAG, "onDestroy"); |
| | | } |
| | | |
| | | @Override |
| | | public void onDestroyView() { |
| | | super.onDestroyView(); |
| | | Log.i(TAG,"onDestroyView"); |
| | | Log.i(TAG, "onDestroyView"); |
| | | } |
| | | } |
| | |
| | | bundle.putString("DetailId", params[3]); |
| | | bundle.putString("Share", "0"); |
| | | bundle.putString("ThirdType", "0"); |
| | | intent.putExtra("from", "web"); |
| | | intent.putExtras(bundle); |
| | | startActivity(intent); |
| | | } |
| | |
| | | public void onClick(View arg0) { |
| | | Intent intent = new Intent(arg0.getContext(), VideoDetailActivity2.class); |
| | | intent.putExtra("video_info", mInfo.getComment().getVideo()); |
| | | intent.putExtra("from", "commentMsg"); |
| | | arg0.getContext().startActivity(intent); |
| | | } |
| | | }); |
| | |
| | | intent.putExtra("video_info", videoInfo); |
| | | intent.putExtra("playing_position", |
| | | playingPosition); |
| | | intent.putExtra("from", "download"); |
| | | con.startActivity(intent); |
| | | } else { |
| | | if (!ConnectionUtils.isNetworkAvailable(v |
| | |
| | | intent.putExtra("video_info", videoInfo); |
| | | intent.putExtra("playing_position", |
| | | playingPosition); |
| | | intent.putExtra("from", "download"); |
| | | v.getContext().startActivity(intent); |
| | | } |
| | | } |
| | |
| | | } |
| | | Intent intent = new Intent(con, |
| | | VideoDetailActivity2.class); |
| | | intent.putExtra("from", "download"); |
| | | if (!TextUtils.isEmpty(DownloadUtils |
| | | .getOfflinePath(con, videoId, |
| | | videoDetailId))) { |
| | |
| | | intent.putExtra("video_info", info); |
| | | intent.putExtra("playing_position", playingPosition); |
| | | intent.putExtra("isFromWatchHistory", true); |
| | | intent.putExtra("from", "watchHistory"); |
| | | v.getContext().startActivity(intent); |
| | | } |
| | | |
| | |
| | | import android.support.v4.widget.SwipeRefreshLayout; |
| | | import android.support.v7.widget.LinearLayoutManager; |
| | | import android.support.v7.widget.RecyclerView; |
| | | import android.support.v7.widget.SimpleItemAnimator; |
| | | import android.view.LayoutInflater; |
| | | import android.view.View; |
| | | import android.widget.AbsListView; |
| | |
| | | fl_ad.setPadding(0, DimenUtils.dip2px(rl_cate_recommed.getContext(), 10), 0, 0); |
| | | fl_ad.setLayoutParams(params); |
| | | |
| | | |
| | | rv_category.setLayoutManager(new LinearLayoutManager(getContext())); |
| | | mVideoInfos = new ArrayList<>(); |
| | | |
| | | adapter = new CategoryRecommendAdapter(homeAds, mVideoInfos,type, getActivity()); |
| | | adapter = new CategoryRecommendAdapter(homeAds, mVideoInfos, type, getActivity()); |
| | | rv_category.setAdapter(adapter); |
| | | rl_cate_recommed.setRefreshing(true); |
| | | |
| | |
| | | getHomeAd(); |
| | | } |
| | | }); |
| | | |
| | | |
| | | } |
| | | |
| | | @Override |
| | |
| | | if (info.getAdView() == null) { |
| | | Intent intent = new Intent(v.getContext(), VideoDetailActivity2.class); |
| | | intent.putExtra("video_info", info); |
| | | intent.putExtra("from", "guessLike"); |
| | | v.getContext().startActivity(intent); |
| | | } |
| | | } |
| | |
| | | // } else { |
| | | Intent intent = new Intent(v.getContext(), VideoDetailActivity2.class); |
| | | intent.putExtra("video_info", info); |
| | | intent.putExtra("from", "recommend"); |
| | | v.getContext().startActivity(intent); |
| | | // } |
| | | } |
| | |
| | | VideoColumn2Adapter adapter = null; |
| | | |
| | | if (isFirst) {//第一排为小视频 |
| | | adapter = new VideoColumn2Adapter(mContext, mContext, homeType.getVideoInfoList(), true, Integer.MAX_VALUE, null, new ExpressAdManager.IAdShowListener() { |
| | | adapter = new VideoColumn2Adapter(mContext, mContext, homeType.getVideoInfoList(), true, Integer.MAX_VALUE, "recommend", null, new ExpressAdManager.IAdShowListener() { |
| | | @Override |
| | | public void show() { |
| | | holder.rv_content.scrollToPosition(0); |
| | |
| | | }); |
| | | adapter.initRecyclerViewDisplayWidthRow1(holder.rv_content); |
| | | } else { |
| | | adapter = new VideoColumn2Adapter(mContext, mContext, homeType.getVideoInfoList(), false, homeType.getColumns(), null); |
| | | adapter = new VideoColumn2Adapter(mContext, mContext, homeType.getVideoInfoList(), false, homeType.getColumns(), "recommend", null); |
| | | if (homeType.getColumns() == 2) |
| | | adapter.initRecyclerViewDisplayWidthColumn2(holder.rv_content); |
| | | else if (homeType.getColumns() == 3) |
| | |
| | | private void myClick(VideoInfo info, final View v) { |
| | | Intent intent = new Intent(v.getContext(), VideoDetailActivity2.class); |
| | | intent.putExtra("video_info", info); |
| | | intent.putExtra("from", "recommend"); |
| | | v.getContext().startActivity(intent); |
| | | } |
| | | |
| | |
| | | VideoDetailActivity2.class); |
| | | intent.putExtra("video_info", mHomeAds.get(position) |
| | | .getVideo()); |
| | | intent.putExtra("from", "homeAd"); |
| | | } else if (mHomeAds.get(position).getLinkType() == 5) { |
| | | try { |
| | | JSONObject object = new JSONObject(mHomeAds |
| | |
| | | import com.weikou.beibeivideo.ui.video.SuggestKeysAdapter; |
| | | import com.weikou.beibeivideo.ui.video.VideoCloumn1Adapter; |
| | | import com.weikou.beibeivideo.util.DimenUtils; |
| | | import com.weikou.beibeivideo.util.UmengEventUtil; |
| | | import com.weikou.beibeivideo.util.ad.ExpressAdManager; |
| | | import com.weikou.beibeivideo.util.ad.manager.SearchResultAdManager; |
| | | import com.weikou.beibeivideo.util.ui.DividerItemDecoration; |
| | |
| | | |
| | | List<VideoType> typeList; |
| | | |
| | | private LinearLayout ll_empty; |
| | | |
| | | @Override |
| | | protected void onCreate(Bundle savedInstanceState) { |
| | | super.onCreate(savedInstanceState); |
| | |
| | | tv_search_cancel = findViewById(R.id.tv_search_cancel); |
| | | rv_video_search = findViewById(R.id.rv_video_search); |
| | | ll_top_bar = findViewById(R.id.ll_top_bar); |
| | | ll_empty = findViewById(R.id.ll_empty); |
| | | |
| | | tv_search_cancel.setOnClickListener(this); |
| | | et_search_key.addTextChangedListener(new TextWatcher() { |
| | |
| | | private List<ExpressAdContainer> adList = new ArrayList<>(); |
| | | |
| | | private void search(String key, String videoType) { |
| | | |
| | | UmengEventUtil.search(getApplicationContext(), videoType); |
| | | |
| | | SharedPreferences preferences = getSharedPreferences("user", |
| | | Context.MODE_PRIVATE); |
| | | String uid = preferences.getString("uid", ""); |
| | |
| | | mVideoInfos.addAll(videoContentList); |
| | | adapter.notifyDataSetChanged(); |
| | | |
| | | if (mVideoInfos != null && mVideoInfos.size() > 0) { |
| | | //有值 |
| | | ll_empty.setVisibility(View.GONE); |
| | | rl_search_result.setVisibility(View.VISIBLE); |
| | | } else { |
| | | //无值 |
| | | ll_empty.setVisibility(View.VISIBLE); |
| | | rl_search_result.setVisibility(View.GONE); |
| | | } |
| | | |
| | | //加载下一次要用的广告 |
| | | if (videoInfos.size() > 0) { |
| | | if (adList.size() < 1) |
| | |
| | | import com.weikou.beibeivideo.entity.VideoResource; |
| | | import com.weikou.beibeivideo.entity.video.FunshionPlayInfo; |
| | | import com.weikou.beibeivideo.util.FunshionConstant; |
| | | import com.weikou.beibeivideo.util.UmengEventUtil; |
| | | import com.weikou.beibeivideo.util.UserUtil; |
| | | import com.weikou.beibeivideo.util.VideoUtil; |
| | | import com.weikou.beibeivideo.util.downutil.StringUtils; |
| | |
| | | VideoUtil.loadVideoEpisodeListCache(BeibeiVideoApplication.application); |
| | | } |
| | | //风行视频播放 |
| | | MobclickAgent.onEventObject(BeibeiVideoApplication.application, "funtv-play", new HashMap<>()); |
| | | UmengEventUtil.funtvPlay(getContext()); |
| | | |
| | | Log.i(TAG, "onEventMainThread:FunshionPlayInfo"); |
| | | mCurrentPosition = info.getPosition(); |
| | |
| | | intent.putExtra("video_info", info); |
| | | if (p > 0) |
| | | intent.putExtra("playing_position", p); |
| | | intent.putExtra("from", "search"); |
| | | v.getContext().startActivity(intent); |
| | | } |
| | | |
| | |
| | | |
| | | private View footerView; |
| | | |
| | | private String from; |
| | | |
| | | |
| | | private final static int TYPE_HEADER = 10001; |
| | | private final static int TYPE_FOOTER = 10002; |
| | |
| | | this.footerView = footerView; |
| | | } |
| | | |
| | | public VideoCloumn1Adapter(Activity context, List<VideoContent> contentList) { |
| | | public VideoCloumn1Adapter(Activity context, List<VideoContent> contentList, String from) { |
| | | this.contentList = contentList; |
| | | mContext = context; |
| | | inflater = LayoutInflater.from(context); |
| | | this.from = from; |
| | | } |
| | | |
| | | @NonNull |
| | |
| | | private void myClick(VideoInfo info, final View v) { |
| | | Intent intent = new Intent(v.getContext(), VideoDetailActivity2.class); |
| | | intent.putExtra("video_info", info); |
| | | intent.putExtra("from", from); |
| | | v.getContext().startActivity(intent); |
| | | } |
| | | |
| | |
| | | private final static int TYPE_HEADER = 10001; |
| | | private final static int TYPE_FOOTER = 10002; |
| | | |
| | | private String from; |
| | | |
| | | |
| | | public void setHeaderView(View headerView) { |
| | | this.headerView = headerView; |
| | |
| | | this.columns = columns; |
| | | } |
| | | |
| | | public VideoColumn2Adapter(final Activity activity, Context context, List<VideoInfo> videoList, boolean needAd, int columns, IVideoClickListener itemClickListener) { |
| | | this(activity, context, videoList, needAd, columns, itemClickListener, null); |
| | | public VideoColumn2Adapter(final Activity activity, Context context, List<VideoInfo> videoList, boolean needAd, int columns, String from, IVideoClickListener itemClickListener) { |
| | | this(activity, context, videoList, needAd, columns, from, itemClickListener, null); |
| | | } |
| | | |
| | | |
| | | public VideoColumn2Adapter(final Activity activity, Context context, List<VideoInfo> videoList, boolean needAd, int columns, IVideoClickListener itemClickListener, ExpressAdManager.IAdShowListener showListener) { |
| | | public VideoColumn2Adapter(final Activity activity, Context context, List<VideoInfo> videoList, boolean needAd, int columns, String from, IVideoClickListener itemClickListener, ExpressAdManager.IAdShowListener showListener) { |
| | | if (activity == null || context == null) |
| | | return; |
| | | this.mContext = context; |
| | |
| | | this.itemClickListener = itemClickListener; |
| | | this.columns = columns; |
| | | this.showListener = showListener; |
| | | this.from = from; |
| | | |
| | | for (VideoInfo video : videoList) { |
| | | contentList.add(VideoContent.createVideoContent(video)); |
| | |
| | | void addAdToPosition(int position, ExpressAdContainer ad) { |
| | | if (position >= 0 && position < contentList.size() && ad != null) { |
| | | contentList.add(position, VideoContent.createAdContent(ad)); |
| | | notifyItemInserted(position); |
| | | notifyItemRangeChanged(0, contentList.size()); |
| | | notifyDataSetChanged(); |
| | | // notifyItemInserted(position); |
| | | // notifyItemRangeChanged(0, contentList.size()); |
| | | if (showListener != null) |
| | | showListener.show(); |
| | | |
| | |
| | | private void myClick(VideoInfo info, final View v) { |
| | | Intent intent = new Intent(v.getContext(), VideoDetailActivity2.class); |
| | | intent.putExtra("video_info", info); |
| | | intent.putExtra("from", from); |
| | | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| | | v.getContext().startActivity(intent); |
| | | } |
| | |
| | | bundle.putString("DetailId", params[3]); |
| | | bundle.putString("Share", "0"); |
| | | bundle.putString("ThirdType", "0"); |
| | | intent.putExtra("from", "web"); |
| | | intent.putExtras(bundle); |
| | | startActivity(intent); |
| | | } |
| | |
| | | // 广点通Banner 退出Dialog |
| | | public static String GDT_EXIT_DIALOG = "1070555737534382"; |
| | | // 广点通 原生搜索结果页原生 |
| | | public static String GDT_SEARCH_RESULT_MIN_NATIVE = "7010050786367146"; |
| | | public static String GDT_SEARCH_RESULT_MIN_NATIVE = "9091067601481758"; |
| | | // 广点通Banner 播放详情页 |
| | | public static String GDT_PLAYER_DETAIL = "5060312614831459"; |
| | | // 广点通Banner 播放详情页 |
New file |
| | |
| | | package com.weikou.beibeivideo.util; |
| | | |
| | | import android.content.Context; |
| | | |
| | | import com.umeng.analytics.MobclickAgent; |
| | | import com.weikou.beibeivideo.BeibeiVideoApplication; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | public class UmengEventUtil { |
| | | |
| | | private static void event(Context context, String key, Map<String, Object> params) { |
| | | if (params == null) |
| | | params = new HashMap<>(); |
| | | if (context != null) |
| | | MobclickAgent.onEventObject(context, key, params); |
| | | } |
| | | |
| | | //播放风行视频 |
| | | public static void funtvPlay(Context context) { |
| | | event(context, "funtv-play", null); |
| | | } |
| | | |
| | | //播放pptv |
| | | public static void pptvPlay(Context context) { |
| | | event(context, "pptv-play", null); |
| | | } |
| | | |
| | | /** |
| | | * 搜索 |
| | | * |
| | | * @param context |
| | | */ |
| | | public static void search(Context context, String videoType) { |
| | | Map<String, Object> params = new HashMap<>(); |
| | | params.put("video-type", videoType); |
| | | event(context, "search", params); |
| | | } |
| | | |
| | | //进入视频详情 |
| | | public static void videoDetail(Context context, String from) { |
| | | Map<String, Object> params = new HashMap<>(); |
| | | params.put("from", from); |
| | | event(context, "video-detail", params); |
| | | } |
| | | |
| | | //百度CPU内容进入 |
| | | public static void baiduCpuClick(Context context, String type) { |
| | | Map<String, Object> params = new HashMap<>(); |
| | | params.put("type", type); |
| | | event(context, "baidu-cpu-detail", params); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | String pid = null; |
| | | if (sourceType == AdUtil.AD_TYPE.csj) { |
| | | pid = "945379581"; |
| | | } else if (sourceType == AdUtil.AD_TYPE.gdt) { |
| | | } else if (sourceType == AdUtil.AD_TYPE.gdt2) { |
| | | pid = BeibeiConstant.GDT_SEARCH_RESULT_MIN_NATIVE; |
| | | } |
| | | //获取屏幕的宽 |
| | |
| | | public SearchResultAdManager(Context context) { |
| | | mContext = context; |
| | | if (expressAdManager == null) |
| | | expressAdManager = new ExpressAdManager(AdUtil.AD_TYPE.gdt, mContext); |
| | | expressAdManager = new ExpressAdManager(AdUtil.AD_TYPE.gdt2, mContext); |
| | | } |
| | | |
| | | public static SearchResultAdManager getInstance(Context context) { |
| | |
| | | private final int TYPE_CONTENT = 2; |
| | | private int viewType; |
| | | |
| | | public BaiduCPUContentAdapter(Context context, int viewType, List<IBasicCPUData> nrAdList) { |
| | | private IBaiDuCPUItemClickListener baiDuCPUItemClickListener; |
| | | |
| | | public BaiduCPUContentAdapter(Context context, int viewType, List<IBasicCPUData> nrAdList, IBaiDuCPUItemClickListener baiDuCPUItemClickListener) { |
| | | inflater = LayoutInflater.from(context); |
| | | aq = new AQuery(context); |
| | | this.nrAdList = nrAdList; |
| | | this.mContext = context; |
| | | this.viewType = viewType; |
| | | this.baiDuCPUItemClickListener = baiDuCPUItemClickListener; |
| | | } |
| | | |
| | | public void setFooterView(View footerView) { |
| | |
| | | viewHolder.view.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View view) { |
| | | if (baiDuCPUItemClickListener != null) { |
| | | baiDuCPUItemClickListener.onClick(nrAd); |
| | | } |
| | | nrAd.handleClick(view); |
| | | } |
| | | }); |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | public interface IBaiDuCPUItemClickListener { |
| | | public void onClick(IBasicCPUData nrAd); |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | private boolean showAd; |
| | | |
| | | private BaiduCPUContentAdapter.IBaiDuCPUItemClickListener baiDuCPUItemClickListener; |
| | | |
| | | public static BaiDuCPUContentFragment newInstance(BaiDuCPUType spinnerItem, int viewType, boolean showAd) { |
| | | public void setBaiDuCPUItemClickListener(BaiduCPUContentAdapter.IBaiDuCPUItemClickListener baiDuCPUItemClickListener) { |
| | | this.baiDuCPUItemClickListener = baiDuCPUItemClickListener; |
| | | } |
| | | |
| | | |
| | | public static BaiDuCPUContentFragment newInstance(BaiDuCPUType spinnerItem, int viewType, boolean showAd, BaiduCPUContentAdapter.IBaiDuCPUItemClickListener baiDuCPUItemClickListener) { |
| | | BaiDuCPUContentFragment fragment = new BaiDuCPUContentFragment(); |
| | | Bundle bundle = new Bundle(); |
| | | bundle.putSerializable("item", spinnerItem); |
| | | bundle.putInt("viewType", viewType); |
| | | bundle.putBoolean("showAd", showAd); |
| | | fragment.setArguments(bundle); |
| | | fragment.setBaiDuCPUItemClickListener(baiDuCPUItemClickListener); |
| | | return fragment; |
| | | } |
| | | |
| | |
| | | */ |
| | | mCpuManager.setLpFontSize(CpuLpFontSize.SMALL); |
| | | mCpuManager.setLpDarkMode(true); |
| | | adapter = new BaiduCPUContentAdapter(getContext(), viewType, nrAdList); |
| | | adapter = new BaiduCPUContentAdapter(getContext(), viewType, nrAdList, baiDuCPUItemClickListener); |
| | | rv_news.setAdapter(adapter); |
| | | |
| | | if (viewType == VIEW_TYPE_SMALLVIDEO) { |
New file |
| | |
| | | package com.lcjian.library.permission; |
| | | |
| | | import android.app.Activity; |
| | | import android.app.AlertDialog; |
| | | import android.content.Context; |
| | | import android.content.DialogInterface; |
| | | import android.content.Intent; |
| | | import android.content.pm.PackageManager; |
| | | import android.net.Uri; |
| | | import android.os.Build; |
| | | import android.provider.Settings; |
| | | import android.support.annotation.NonNull; |
| | | import android.support.v4.app.ActivityCompat; |
| | | import android.support.v4.content.ContextCompat; |
| | | |
| | | import java.util.ArrayList; |
| | | |
| | | public class PermissionHelper { |
| | | |
| | | private Activity mActivity;//当前activity |
| | | private PermissionInterface mPermissionInterface;//权限返回接口 |
| | | |
| | | public PermissionHelper(@NonNull Activity activity, @NonNull PermissionInterface permissionInterface) { |
| | | mActivity = activity; |
| | | mPermissionInterface = permissionInterface; |
| | | } |
| | | |
| | | /** |
| | | * 开始请求权限。 |
| | | * 方法内部已经对Android M 或以上版本进行了判断,外部使用不再需要重复判断。 |
| | | * 如果设备还不是M或以上版本,则也会回调到requestPermissionsSuccess方法。 |
| | | */ |
| | | public void requestPermissions() { |
| | | //获取要请求的权限 |
| | | String[] deniedPermissions = getDeniedPermissions(mActivity, mPermissionInterface.getPermissions()); |
| | | //deniedPermissions不为空长度大于0表示有未请求的权限 |
| | | if (deniedPermissions != null && deniedPermissions.length > 0) { |
| | | //弹出权限请求框 |
| | | requestPermissions(mActivity, deniedPermissions, mPermissionInterface.getPermissionsRequestCode()); |
| | | } else { |
| | | //权限请求成功 |
| | | mPermissionInterface.requestPermissionsSuccess(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 弹出对话框请求权限 |
| | | * |
| | | * @param activity |
| | | * @param permissions |
| | | * @param requestCode |
| | | */ |
| | | public static void requestPermissions(Activity activity, String[] permissions, int requestCode) { |
| | | // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { |
| | | // 请求权限兼容低版本 |
| | | ActivityCompat.requestPermissions(activity, permissions, requestCode); |
| | | // } |
| | | } |
| | | |
| | | /** |
| | | * 在Activity中的onRequestPermissionsResult中调用 |
| | | * 请求权限结果 回调权限是否请求成功 |
| | | * |
| | | * @param requestCode 权限请求码 |
| | | * @param permissions 申请的权限 |
| | | * @param grantResults |
| | | * @return true 代表对该requestCode感兴趣,并已经处理掉了。false 对该requestCode不感兴趣,不处理。 |
| | | */ |
| | | public boolean requestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { |
| | | //权限请求码一致 |
| | | if (requestCode == mPermissionInterface.getPermissionsRequestCode()) { |
| | | boolean isAllGranted = true;//是否全部权限已授权 |
| | | for (int result : grantResults) { |
| | | //未授权权限 |
| | | if (result == PackageManager.PERMISSION_DENIED) { |
| | | isAllGranted = false; |
| | | break; |
| | | } |
| | | } |
| | | if (isAllGranted) { |
| | | //已全部授权 |
| | | mPermissionInterface.requestPermissionsSuccess(); |
| | | } else { |
| | | //权限有缺失 |
| | | mPermissionInterface.requestPermissionsFail(); |
| | | showSettingDialog();//弹出设置框 |
| | | } |
| | | return isAllGranted; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 返回缺失的权限 |
| | | * |
| | | * @param context |
| | | * @param permissions |
| | | * @return 返回缺少的权限,null 意味着没有缺少权限 |
| | | */ |
| | | public static String[] getDeniedPermissions(Context context, String[] permissions) { |
| | | //Android M 以上申请权限 |
| | | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { |
| | | ArrayList<String> deniedPermissionList = new ArrayList<>(); |
| | | for (String permission : permissions) { |
| | | //权限未许可则记录权限 |
| | | if (context.checkSelfPermission(permission) != PackageManager.PERMISSION_GRANTED) { |
| | | deniedPermissionList.add(permission); |
| | | } |
| | | } |
| | | int size = deniedPermissionList.size(); |
| | | //返回String数组权限 |
| | | if (size > 0) { |
| | | return deniedPermissionList.toArray(new String[deniedPermissionList.size()]); |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | // 判断权限集合 是否授权 false授权 true未授权 |
| | | public boolean lacksPermissions(String... permissions) { |
| | | for (String permission : permissions) { |
| | | if (lacksPermission(permission)) { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | // 判断是否缺少权限 |
| | | private boolean lacksPermission(String permission) { |
| | | //权限未授权 |
| | | return ContextCompat.checkSelfPermission(mActivity, permission) == PackageManager.PERMISSION_DENIED; |
| | | } |
| | | |
| | | /** |
| | | * 弹出权限请求通知框(更具需求 不需要知道了弹窗直接弹权限申请) |
| | | */ |
| | | public void showNormalDialog() { |
| | | requestPermissions();//开始请求权限。 |
| | | } |
| | | |
| | | /** |
| | | * 弹出权限设置通知框 |
| | | */ |
| | | public void showSettingDialog() { |
| | | |
| | | AlertDialog dialog = new AlertDialog.Builder(mActivity).setTitle("温馨提示").setMessage("权限已被拒绝如要正常使用,请设置相关权限").setNegativeButton("不用了", new DialogInterface.OnClickListener() { |
| | | @Override |
| | | public void onClick(DialogInterface dialog, int which) { |
| | | dialog.dismiss(); |
| | | } |
| | | }).setPositiveButton("去设置", new DialogInterface.OnClickListener() { |
| | | @Override |
| | | public void onClick(DialogInterface dialog, int which) { |
| | | startAppSettings();//打开设置 |
| | | dialog.dismiss(); |
| | | } |
| | | }).create(); |
| | | dialog.show(); |
| | | } |
| | | |
| | | private static final String PACKAGE_URL_SCHEME = "package:"; // 方案 |
| | | |
| | | // 启动应用的设置 |
| | | private void startAppSettings() { |
| | | Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); |
| | | intent.setData(Uri.parse(PACKAGE_URL_SCHEME + mActivity.getPackageName())); |
| | | mActivity.startActivity(intent); |
| | | } |
| | | } |
New file |
| | |
| | | package com.lcjian.library.permission; |
| | | |
| | | public interface PermissionInterface { |
| | | /** |
| | | * 置请求权限码 |
| | | */ |
| | | int getPermissionsRequestCode(); |
| | | |
| | | /** |
| | | * 设置请求权限 |
| | | */ |
| | | String[] getPermissions(); |
| | | |
| | | /** |
| | | * 权限请求成功 |
| | | */ |
| | | void requestPermissionsSuccess(); |
| | | |
| | | /** |
| | | * 权限请求失败 |
| | | */ |
| | | void requestPermissionsFail(); |
| | | } |