Commit 4f93c399 authored by linfeng's avatar linfeng

短视频

parent ffa7a1c7
......@@ -8,8 +8,8 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
flavorDimensions "default"
versionCode 142
versionName "1.4.2"
versionCode 143
versionName "1.4.3"
multiDexEnabled true
ndk {
......
package com.ruiwenliu.wrapper.http;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import com.ruiwenliu.wrapper.inter.UploadCallbacks;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import okhttp3.MediaType;
import okhttp3.RequestBody;
import okio.Buffer;
import okio.BufferedSink;
public class ProgressRequestBody extends RequestBody {
private File mFile;
private String mPath;
private String mMediaType;
private UploadCallbacks mListener;
private int s = -1;
private int mEachBufferSize = 1024;
public ProgressRequestBody(final File file, String mediaType, UploadCallbacks listener) {
mFile = file;
mMediaType = mediaType;
mListener = listener;
}
@Override
public MediaType contentType() {
return MediaType.parse(mMediaType);
}
@Override
public void writeTo(BufferedSink sink)
throws IOException {
if (sink instanceof Buffer) {
return;
}
long fileLength = mFile.length();
byte[] buffer = new byte[mEachBufferSize];
FileInputStream in = new FileInputStream(mFile);
long uploaded = 0;
try {
int read;
Handler handler = new Handler(Looper.getMainLooper());
while ((read = in.read(buffer)) != -1) {
// update progress on UI thread
handler.post(new ProgressUpdater(uploaded, fileLength));
uploaded += read;
sink.write(buffer, 0, read);
}
} finally {
in.close();
}
}
private class ProgressUpdater implements Runnable {
private long mUploaded;
private long mTotal;
public ProgressUpdater(long uploaded, long total) {
mUploaded = uploaded;
mTotal = total;
}
@Override
public void run() {
int i = (int) (100 * mUploaded / mTotal);
if (s != i) {
Log.i("progressrequestbody", "run:++ " + i);
mListener.onProgressUpdate(i+ 1);
s = i;
}
}
}
public interface UploadCallbacks {
void onProgressUpdate(int percentage);
}
}
\ No newline at end of file
package com.ruiwenliu.wrapper.inter;
public interface UploadCallbacks {
void onProgressUpdate(int percentage);
void onError();
void onFinish();
}
......@@ -8,6 +8,7 @@ import com.umeng.socialize.ShareAction;
import com.umeng.socialize.UMShareListener;
import com.umeng.socialize.bean.SHARE_MEDIA;
import com.umeng.socialize.media.UMImage;
import com.umeng.socialize.media.UMVideo;
import com.umeng.socialize.media.UMWeb;
import com.umeng.socialize.utils.ShareBoardlistener;
......@@ -53,15 +54,15 @@ public class ShareManager extends ShareAction {
/**
* @param activity
* @param boardListener
* @param copy
* @param download
*/
public ShareManager(Activity activity, ShareBoardlistener boardListener, String copy) {
public ShareManager(Activity activity, ShareBoardlistener boardListener, String copy, String download, String type) {
super(activity);
mActivity = activity;
this.setDisplayList(
SHARE_MEDIA.WEIXIN, SHARE_MEDIA.WEIXIN_CIRCLE, SHARE_MEDIA.WEIXIN_FAVORITE,
SHARE_MEDIA.QQ, SHARE_MEDIA.QZONE)
SHARE_MEDIA.WEIXIN, SHARE_MEDIA.WEIXIN_CIRCLE, SHARE_MEDIA.QQ)
.addButton("复制链接", copy, "rv_share_copy", "rv_share_copy")
.addButton("下载视频", download, "rv_share_download_video", "rv_share_download_video")
.setShareboardclickCallback(boardListener);
}
......@@ -103,6 +104,24 @@ public class ShareManager extends ShareAction {
shareWebContent(share_media, web, umShareListener);
}
/**
*
* @param share_media
* @param videoUrl
* @param title
* @param content
* @param imgUrl
* @param umShareListener
* @param <T>
*/
public <T extends UMShareListener> void showShareVideo(SHARE_MEDIA share_media, String videoUrl, String title, String content, String imgUrl, T umShareListener) {
UMVideo video = new UMVideo(videoUrl);
video.setTitle(title);//视频的标题
video.setThumb(new UMImage(mActivity, imgUrl));//视频的缩略图
video.setDescription(content);//视频的描述
shareWebContent(share_media, video, umShareListener);
}
/**
* 分享图片
*
......@@ -132,6 +151,13 @@ public class ShareManager extends ShareAction {
.share();
}
public void shareWebContent(SHARE_MEDIA share_media, UMVideo umVideo, UMShareListener umShareListener) {
new ShareAction(mActivity).withMedia(umVideo)
.setPlatform(share_media)
.setCallback(umShareListener)
.share();
}
public void shareWebContent(SHARE_MEDIA share_media, UMImage image, UMShareListener umShareListener) {
new ShareAction(mActivity).withMedia(image)
.setPlatform(share_media)
......
package com.rv.component.dialog;
import android.content.Context;
import android.support.annotation.NonNull;
import android.view.Gravity;
import android.view.ViewGroup;
import com.ruiwenliu.wrapper.dialog.BaseDialog;
/**
* 删除dialog
*/
public class BottomDeleteDialog extends BaseDialog {
public BottomDeleteDialog(@NonNull Context context) {
super(context);
setDialogParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.BOTTOM);
}
@Override
public int getViewLayout() {
return R.layout.dialog_prompt_bottom;
}
}
package com.rv.component.dialog;
import android.content.Context;
import android.support.annotation.NonNull;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ProgressBar;
import com.ruiwenliu.wrapper.dialog.BaseDialog;
import com.ruiwenliu.wrapper.util.ViewHolder;
/**
* 温馨提示
*/
public class ProgressBarDialog extends BaseDialog {
ProgressBar progressBar;
public ProgressBarDialog(@NonNull Context context) {
super(context);
setDialogParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.CENTER);
}
@Override
public void helper(ViewHolder helper) {
super.helper(helper);
progressBar = (ProgressBar) helper.getView(R.id.pb_show);
}
@Override
public int getViewLayout() {
return R.layout.dialog_progress_bar;
}
public void setContent(int percentage) {
if (progressBar != null) {
progressBar.setProgress(percentage);
}
}
}
<?xml version="1.0" encoding="UTF-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 设置背景色 -->
<item android:id="@android:id/background"
android:drawable="@color/text_Gray">
</item>
<!-- 设置进度条颜色 -->
<item android:id="@android:id/progress">
<clip>
<shape>
<gradient
android:endColor="#fff000"
android:startColor="#fff000" />
</shape>
</clip>
</item>
</layer-list>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="bottom"
android:orientation="vertical"
tools:ignore="MissingDefaultResource">
<LinearLayout
android:id="@+id/ll_item_delete"
android:layout_width="match_parent"
android:layout_height="@dimen/size_50"
android:background="@color/gray_F64747"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="删除"
android:textColor="@color/colorWrite"
android:textSize="16sp" />
</LinearLayout>
</LinearLayout>
\ No newline at end of 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="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/size_40"
android:layout_marginRight="@dimen/size_40"
android:background="@color/colorWrite"
android:orientation="vertical">
<ProgressBar
android:id="@+id/pb_show"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="@dimen/size_20"
android:layout_gravity="center"
android:max="100"
android:progressDrawable="@drawable/progressbar_bg"
/>
</LinearLayout>
</LinearLayout>
\ No newline at end of file
package com.rv.component.utils;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.provider.MediaStore;
import android.util.Log;
import java.io.File;
public class AlbumNotifyHelper {
public static final String TAG = AlbumNotifyHelper.class.getSimpleName();
public static void notifyScanDcim(Context context, String filePath) {
scanFile(context, filePath);
}
public static void insertVideoToMediaStore(Context context, String filePath, long dateTaken, long duration) {
insertVideoToMediaStore(context, filePath, dateTaken, 0, 0, duration);
}
public static void insertImageToMediaStore(Context context, String filePath, long createTime) {
insertImageToMediaStore(context, filePath, createTime, 0, 0);
}
///////////////////////////////////////////////////////////////////////////
// 扫描系统相册核心方法
///////////////////////////////////////////////////////////////////////////
/**
* 针对系统文夹只需要扫描,不用插入内容提供者,不然会重复
*
* @param context 上下文
* @param filePath 文件路径
*/
public static void scanFile(Context context, String filePath) {
Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
intent.setData(Uri.fromFile(new File(filePath)));
context.sendBroadcast(intent);
}
///////////////////////////////////////////////////////////////////////////
// 非系统相册像MediaContent中插入数据,核心方法
///////////////////////////////////////////////////////////////////////////
/**
* 针对非系统文件夹下的文件,使用该方法
* 插入时初始化公共字段
*
* @param filePath 文件
* @param time ms
* @return ContentValues
*/
private static ContentValues initCommonContentValues(String filePath, long time) {
ContentValues values = new ContentValues();
File saveFile = new File(filePath);
long timeMillis = getTimeWrap(time);
values.put(MediaStore.MediaColumns.TITLE, saveFile.getName());
values.put(MediaStore.MediaColumns.DISPLAY_NAME, saveFile.getName());
values.put(MediaStore.MediaColumns.DATE_MODIFIED, timeMillis);
values.put(MediaStore.MediaColumns.DATE_ADDED, timeMillis);
values.put(MediaStore.MediaColumns.DATA, saveFile.getAbsolutePath());
values.put(MediaStore.MediaColumns.SIZE, saveFile.length());
return values;
}
/**
* 保存到照片到本地,并插入MediaStore以保证相册可以查看到,这是更优化的方法,防止读取的照片获取不到宽高
*
* @param context 上下文
* @param filePath 文件路径
* @param createTime 创建时间 <=0时为当前时间 ms
* @param width 宽度
* @param height 高度
*/
public static void insertImageToMediaStore(Context context, String filePath, long createTime, int width, int height) {
createTime = getTimeWrap(createTime);
ContentValues values = initCommonContentValues(filePath, createTime);
values.put(MediaStore.Images.ImageColumns.DATE_TAKEN, createTime);
values.put(MediaStore.Images.ImageColumns.ORIENTATION, 0);
values.put(MediaStore.Images.ImageColumns.ORIENTATION, 0);
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN) {
if (width > 0) values.put(MediaStore.Images.ImageColumns.WIDTH, 0);
if (height > 0) values.put(MediaStore.Images.ImageColumns.HEIGHT, 0);
}
values.put(MediaStore.MediaColumns.MIME_TYPE, getPhotoMimeType(filePath));
context.getApplicationContext().getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
}
/**
* 保存到视频到本地,并插入MediaStore以保证相册可以查看到,这是更优化的方法,防止读取的视频获取不到宽高
*
* @param context 上下文
* @param filePath 文件路径
* @param createTime 创建时间 <=0时为当前时间 ms
* @param duration 视频长度 ms
* @param width 宽度
* @param height 高度
*/
public static void insertVideoToMediaStore(Context context, String filePath, long createTime, int width, int height, long duration) {
createTime = getTimeWrap(createTime);
ContentValues values = initCommonContentValues(filePath, createTime);
values.put(MediaStore.Video.VideoColumns.DATE_TAKEN, createTime);
if (duration > 0)
values.put(MediaStore.Video.VideoColumns.DURATION, duration);
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN) {
if (width > 0) values.put(MediaStore.Video.VideoColumns.WIDTH, width);
if (height > 0) values.put(MediaStore.Video.VideoColumns.HEIGHT, height);
}
values.put(MediaStore.MediaColumns.MIME_TYPE, getVideoMimeType(filePath));
context.getContentResolver().insert(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, values);
}
// 是不是系统相册
private static boolean isSystemDcim(String path) {
return path.toLowerCase().contains("dcim") || path.toLowerCase().contains("camera");
}
// 获取照片的mine_type
private static String getPhotoMimeType(String path) {
String lowerPath = path.toLowerCase();
if (lowerPath.endsWith("jpg") || lowerPath.endsWith("jpeg")) {
return "image/jpeg";
} else if (lowerPath.endsWith("png")) {
return "image/png";
} else if (lowerPath.endsWith("gif")) {
return "image/gif";
}
return "image/jpeg";
}
// 获取video的mine_type,暂时只支持mp4,3gp
private static String getVideoMimeType(String path) {
String lowerPath = path.toLowerCase();
if (lowerPath.endsWith("mp4") || lowerPath.endsWith("mpeg4")) {
return "video/mp4";
} else if (lowerPath.endsWith("3gp")) {
return "video/3gp";
}
return "video/mp4";
}
// 获得转化后的时间
private static long getTimeWrap(long time) {
if (time <= 0) {
return System.currentTimeMillis();
}
return time;
}
}
......@@ -189,6 +189,19 @@ public class DateUtils {
}
/**
* 将时间秒转换成yyyy-MM-dd HH:mm字符串
*
* @param time 时间戳
* @return yyyy-MM-dd HH:mm
*/
public static String timestampToString3(long time) {
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(time * 1000);//转换为毫秒
Date date = calendar.getTime();
return sdf7.format(date);
}
/**
* 获取手机当前时间戳毫秒
*
......
......@@ -13,7 +13,10 @@
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<application>
<activity android:name=".other.ShortVideoActivity"></activity>
<activity android:name=".other.SelectVideoActivity"></activity>
<activity
android:name=".other.ShortVideoActivity"
android:screenOrientation="portrait" />
<activity
android:name=".other.PatGeneratePosterActivity"
android:screenOrientation="portrait" />
......
......@@ -129,8 +129,8 @@ public class DiscoveryFragment extends BaseFragment<DiscoveryPresenter> {
List<String> list = new ArrayList<>();
list.add(_mActivity.getString(R.string.discovery_recommend));
list.add(_mActivity.getString(R.string.discovery_pat));
// list.add(_mActivity.getString(R.string.discovery_short_video));
// list.add(_mActivity.getString(R.string.discovery_question_and_answer));
list.add(_mActivity.getString(R.string.discovery_short_video));
list.add(_mActivity.getString(R.string.discovery_question_and_answer));
menuAdapter.setNewData(list);
menuAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
@Override
......@@ -174,8 +174,8 @@ public class DiscoveryFragment extends BaseFragment<DiscoveryPresenter> {
List<BaseFragment> list = new ArrayList<>();
list.add(RecommendFragment.getInstance(TYPE_RECOMMEND));
list.add(PatFragment.getInstance(TYPE_PAT));
// list.add(ShortVideoFragment.getInstance(TYPE_SHORT_VIDEO));
// list.add(QuestionAndAnswerFragment.getInstance(TYPE_QUESTION_AND_ANSWER));
list.add(ShortVideoFragment.getInstance(TYPE_SHORT_VIDEO));
list.add(QuestionAndAnswerFragment.getInstance(TYPE_QUESTION_AND_ANSWER));
return list;
}
......@@ -201,7 +201,7 @@ public class DiscoveryFragment extends BaseFragment<DiscoveryPresenter> {
int id = view.getId();
if (id == R.id.iv_discovery_content_add) {
//添加
// showPopupWindow(ivDiscoveryContentAdd);
showPopupWindow(ivDiscoveryContentAdd);
//判断是否已经登录
// if (TextUtils.isEmpty(OkGoUtil.getToken())) {
......@@ -213,7 +213,6 @@ public class DiscoveryFragment extends BaseFragment<DiscoveryPresenter> {
// .build(Constance.ACTIVITY_URL_POSTPAT)
// .navigation();
startActivity(ShortVideoActivity.getIntent(_mActivity));
}
}
......
package com.xxfc.discovery.adapter;
import android.widget.ImageView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ruiwenliu.wrapper.util.TransformationUtil;
import com.ruiwenliu.wrapper.util.glide.GlideManager;
import com.ruiwenliu.wrapper.util.glide.GlideOptions;
import com.xxfc.discovery.R;
import com.xxfc.discovery.bean.DiscoveryRecommendBean;
/**
* 拍拍
* 短视频
*/
public class DiscoveryShortVideoAdapter extends BaseQuickAdapter<String, BaseViewHolder> {
public class DiscoveryShortVideoAdapter extends BaseQuickAdapter<DiscoveryRecommendBean.DataBeanX.DataBean, BaseViewHolder> {
public DiscoveryShortVideoAdapter() {
super(R.layout.rv_item_discovery_short_video);
}
private int selectPosition;
@Override
protected void convert(BaseViewHolder helper, String item) {
protected void convert(BaseViewHolder helper, DiscoveryRecommendBean.DataBeanX.DataBean item) {
if (item == null) {
return;
}
DiscoveryRecommendBean.DataBeanX.DataBean.Body body = item.getBody();
if (body != null) {
if (body.getVideos() != null && body.getVideos().size() > 0) {
ImageView image = helper.getView(R.id.iv_icon_video);
GlideOptions options = GlideOptions.placeholderOf(com.ruiwenliu.wrapper.R.drawable.glide_icon_placeholder).
error(com.ruiwenliu.wrapper.R.drawable.glide_icon_error);
TransformationUtil utils = new TransformationUtil(image);
Glide.with(mContext)
.asBitmap()
.load(body.getVideos().get(0).getOurl())
.apply(options)
.apply(RequestOptions.bitmapTransform(new RoundedCorners(12)).override(image.getWidth(), image.getHeight()))
.into(utils);
}
helper.setText(R.id.tv_title, body.getText());
if ("4".equals(body.getType())) { //消息类型 基础属性 1=文字消息、2=图文消息、3=语音消息、4=视频消息、 5=文件消
helper.setGone(R.id.iv_isvideo, true);
} else {
helper.setGone(R.id.iv_isvideo, false);
}
}
helper.setText(R.id.tv_user_name, item.getNickname());
GlideManager.getInstance(mContext).loadImage(item.getPicUrl(), (ImageView) helper.getView(R.id.iv_user_icon));
if (item.getCount() != null) {
helper.setText(R.id.iv_like_number, item.getCount().getPraise());
}
if ("1".equals(item.getIsPraise())) { //0:未点赞 1:已点赞
helper.setImageResource(R.id.iv_like, R.drawable.icon_discovery_ask_like);
} else {
helper.setImageResource(R.id.iv_like, R.drawable.icon_discovery_ask_unlike);
}
helper.addOnClickListener(R.id.ll_item_islike);
}
}
......@@ -2,33 +2,46 @@ package com.xxfc.discovery.adapter;
import android.widget.ImageView;
import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ruiwenliu.wrapper.util.glide.GlideApp;
import com.ruiwenliu.wrapper.util.glide.GlideManager;
import com.xxfc.discovery.R;
import com.xxfc.discovery.bean.beam.VideoBean;
import com.xxfc.discovery.bean.DiscoveryRecommendBean;
/**
* 短视频
*/
public class DiscoveryVideoAdapter extends BaseQuickAdapter<VideoBean, BaseViewHolder> {
public class DiscoveryVideoAdapter extends BaseQuickAdapter<DiscoveryRecommendBean.DataBeanX.DataBean, BaseViewHolder> {
public DiscoveryVideoAdapter() {
super(R.layout.rv_item_discovery_video);
}
@Override
protected void convert(BaseViewHolder helper, VideoBean item) {
protected void convert(BaseViewHolder helper, DiscoveryRecommendBean.DataBeanX.DataBean item) {
if (item == null) {
return;
}
if (item.getBody() != null && item.getBody().getImages() != null && item.getBody().getImages().size() > 0) {
GlideApp.with(mContext)
.load(item.getThumb())
.load(item.getBody().getImages().get(0).getOurl())
.placeholder(android.R.color.white)
.into((ImageView) helper.getView(R.id.thumb));
}
GlideManager.getInstance(mContext).loadImage(item.getPicUrl(), (ImageView) helper.getView(R.id.iv_video_avatar));
if (item.getCount() != null) {
helper.setText(R.id.tv_video_islike_number, item.getCount().getPraise());
helper.setText(R.id.tv_video_comment_number, item.getCount().getComment());
helper.setText(R.id.tv_video_share_number, item.getCount().getShare());
}
if ("1".equals(item.getIsPraise())) { //0:未点赞 1:已点赞
helper.setImageResource(R.id.iv_video_islike, R.drawable.icon_discover_video_like);
} else {
helper.setImageResource(R.id.iv_video_islike, R.drawable.icon_discover_video_likeun);
}
helper.addOnClickListener(R.id.ll_item_video_comment);
helper.addOnClickListener(R.id.ll_item_video_share);
......
package com.xxfc.discovery.adapter;
import android.widget.ImageView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ruiwenliu.wrapper.util.glide.GlideApp;
import com.rv.component.utils.DateUtils;
import com.xxfc.discovery.R;
import com.xxfc.discovery.bean.beam.VideoBean;
import com.xxfc.discovery.bean.DiscoveryCommentBean;
/**
* 短视频评论
*/
public class DiscoveryVideoCommentAdapter extends BaseQuickAdapter<String, BaseViewHolder> {
public class DiscoveryVideoCommentAdapter extends BaseQuickAdapter<DiscoveryCommentBean.DataBean, BaseViewHolder> {
public DiscoveryVideoCommentAdapter() {
super(R.layout.rv_item_discovery_video_comment);
}
@Override
protected void convert(BaseViewHolder helper, String item) {
protected void convert(BaseViewHolder helper, DiscoveryCommentBean.DataBean item) {
if (item == null) {
return;
}
helper.setText(R.id.iv_video_comment_name,item.getNickname());
helper.setText(R.id.tv_video_comment_time, DateUtils.timestampToString3(item.getTime()));
helper.setText(R.id.tv_video_comment_content,item.getBody());
}
}
package com.xxfc.discovery.adapter;
import android.widget.ImageView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ruiwenliu.wrapper.util.glide.GlideManager;
import com.rv.component.utils.DateUtils;
import com.xxfc.discovery.R;
import com.xxfc.discovery.bean.DiscoveryCommentBean;
import com.xxfc.discovery.bean.VideoFile;
/**
* 短视频选择
*/
public class DiscoveryVideoSelectAdapter extends BaseQuickAdapter<VideoFile, BaseViewHolder> {
public DiscoveryVideoSelectAdapter() {
super(R.layout.rv_item_discovery_video_select);
}
@Override
protected void convert(BaseViewHolder helper, VideoFile item) {
if (item == null) {
return;
}
GlideManager.getInstance(mContext).loadImage(item.getFilePath(), (ImageView) helper.getView(R.id.iv_video_icon));
helper.setText(R.id.tv_video_date, DateUtils.timestampToString1(item.getCreateTime()));
helper.setText(R.id.tv_video_duration, item.getFileLength() + "秒");
helper.setText(R.id.tv_video_size, parserFileSize(item.getFileSize()));
}
private String parserFileSize(long size) {
float temp = size / (float) 1024;
if (temp < 1024) {
return (int) temp + "KB";
}
temp = temp / 1024;
if (temp < 1024) {
return ((int) (temp * 100)) / (float) 100 + "M";
}
temp = temp / 1024;
return ((int) (temp * 100)) / (float) 100 + "G";
}
}
......@@ -43,15 +43,20 @@ public interface DiscoveryApi extends RvFrameConfig {
String DISCOVERY_PRAISE_DELETE = IMA_BASEUSRL + "/b/circle/msg/praise/delete";
// 添加消息(拍拍、段视频)
String DISCOVERY_MSG_ADD = IMA_BASEUSRL +"/b/circle/msg/add";
String DISCOVERY_MSG_ADD = IMA_BASEUSRL + "/b/circle/msg/add";
//im登录
String DISCOVERY_IM_LOGIN = HOST + "/api/auth/jwt/imi/login";
public static String HTTP_URL_FILE_UPLOAD = RvFrameConfig.VEHICLE_UPLOAD + "file/app/unauth/upload";//文件上传
public static String HTTP_URL_FILE_UPLOAD_VIDEO = RvFrameConfig.VEHICLE_UPLOAD + "file/app/unauth/uploadVideo";//视频上传
// String HTTP_URL_FILE_UPLOADS = RvFrameConfig.VEHICLE_UPLOAD + "file/app/unauth/uploadFiles";//多张图片上传
String HTTP_URL_FILE_UPLOADS = RvFrameConfig.VEHICLE_UPLOAD + "file/app/unauth/uploads";//多张图片上传
//获取评论列表
String DISCOVERY_COMMENT_LIST = IMA_BASEUSRL + "/b/circle/msg/comment/list";
}
package com.xxfc.discovery.bean;
import com.ruiwenliu.wrapper.base.BaseBean;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
public class DiscoveryCommentBean extends BaseBean {
private List<DataBean> data;
private boolean rel;
public List<DataBean> getData() {
return data;
}
public void setData(List<DataBean> data) {
this.data = data;
}
public boolean isRel() {
return rel;
}
public void setRel(boolean rel) {
this.rel = rel;
}
public static class DataBean {
private String body;// ": "wettuu",
private String commentId;// ": "5d6f1c4c2114c043579555c9",
private String msgId;// ": "5d6e0961f5df3f76cc78cca4",
private String nickname;// ": "XX_582704",
private long time;// ": 1567562828,
private String toUserId;// ": 0,
private String userId;// ": 10000056
public String getBody() {
return body;
}
public void setBody(String body) {
this.body = body;
}
public String getCommentId() {
return commentId;
}
public void setCommentId(String commentId) {
this.commentId = commentId;
}
public String getMsgId() {
return msgId;
}
public void setMsgId(String msgId) {
this.msgId = msgId;
}
public String getNickname() {
return nickname;
}
public void setNickname(String nickname) {
this.nickname = nickname;
}
public long getTime() {
return time;
}
public void setTime(long time) {
this.time = time;
}
public String getToUserId() {
return toUserId;
}
public void setToUserId(String toUserId) {
this.toUserId = toUserId;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
}
}
......@@ -231,9 +231,18 @@ public class DiscoveryRecommendBean extends BaseBean {
private MsgId id;
private String msgId;
private Body body;
private String location;
private List<Comments> comments;
private List<praises> praises;
public String getLocation() {
return location;
}
public void setLocation(String location) {
this.location = location;
}
public String getMsgId() {
return msgId;
}
......@@ -540,6 +549,7 @@ public class DiscoveryRecommendBean extends BaseBean {
private String time;
private String type;
private List<Images> images;
private List<Videos> videos;
public String getText() {
return text;
......@@ -573,6 +583,13 @@ public class DiscoveryRecommendBean extends BaseBean {
this.images = images;
}
public List<Videos> getVideos() {
return videos;
}
public void setVideos(List<Videos> videos) {
this.videos = videos;
}
public static class Images implements Serializable {
private String length;
......@@ -630,6 +647,46 @@ public class DiscoveryRecommendBean extends BaseBean {
this.tUrl = tUrl;
}
}
public static class Videos implements Serializable {
private String length;
private String size;
private String ourl;
private String oUrl;
public String getLength() {
return length;
}
public void setLength(String length) {
this.length = length;
}
public String getSize() {
return size;
}
public void setSize(String size) {
this.size = size;
}
public String getOurl() {
return ourl;
}
public void setOurl(String ourl) {
this.ourl = ourl;
}
public String getoUrl() {
return oUrl;
}
public void setoUrl(String oUrl) {
this.oUrl = oUrl;
}
}
}
public static class Comments implements Serializable {
......@@ -755,7 +812,7 @@ public class DiscoveryRecommendBean extends BaseBean {
}
}
public static class praises implements Serializable{
public static class praises implements Serializable {
private String nickname;
private String time;
private String userId;
......
package com.xxfc.discovery.bean;
import com.ruiwenliu.wrapper.base.BaseBean;
public class UpdateVideoFile extends BaseBean {
private String data;
private boolean rel;
public String getData() {
return data;
}
public void setData(String data) {
this.data = data;
}
public boolean isRel() {
return rel;
}
public void setRel(boolean rel) {
this.rel = rel;
}
}
package com.xxfc.imcamera.bean;
package com.xxfc.discovery.bean;
import java.io.Serializable;
/**
* 本地视频文件的数据库信息
* 本地视频文件
*/
public class VideoFile {
public class VideoFile implements Serializable {
public VideoFile() {
}
private int _id;
private String ownerId; //文件所属者是哪个user
private String filePath;//文件的本地Uri
private String desc; // 文件的描述
private String createTime;// 文件创建时间
private long createTime;// 文件创建时间
private long fileSize; // 文件大小
......@@ -62,11 +59,11 @@ public class VideoFile {
this.desc = desc;
}
public String getCreateTime() {
public long getCreateTime() {
return createTime;
}
public void setCreateTime(String createTime) {
public void setCreateTime(long createTime) {
this.createTime = createTime;
}
......
......@@ -35,7 +35,6 @@ public class DiscoveryVideoDialog extends BaseDialog {
private DiscoveryVideoCommentAdapter commentAdapter;
public DiscoveryVideoDialog(@NonNull Context context) {
super(context);
this.context = context;
......@@ -70,17 +69,18 @@ public class DiscoveryVideoDialog extends BaseDialog {
}
}, R.id.ll_item_comment);
initData();
}
private void initData() {
ArrayList<String> list = new ArrayList<>();
for (int i = 0; i < 8; i++) {
list.add("3333");
helper.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
}
commentAdapter.addData(list);
}, R.id.iv_close);
}
@Override
public int getViewLayout() {
return R.layout.dialog_discovery_video;
......
package com.xxfc.discovery.event;
import com.frame.base.bus.Event;
public class PostVideoEvent extends Event {
}
......@@ -4,10 +4,15 @@ import android.graphics.Rect;
import android.os.Bundle;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.view.Display;
import android.view.View;
import com.alibaba.android.arouter.launcher.ARouter;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.frame.base.bus.Observer;
import com.frame.base.bus.RxBus;
import com.frame.base.url.Constance;
import com.ruiwenliu.wrapper.base.BaseBean;
import com.ruiwenliu.wrapper.base.BaseFragment;
import com.ruiwenliu.wrapper.weight.refresh.SimpleRefreshLayout;
......@@ -15,26 +20,31 @@ import com.ruiwenliu.wrapper.weight.refresh.SimpleRefreshView;
import com.xxfc.discovery.R;
import com.xxfc.discovery.R2;
import com.xxfc.discovery.adapter.DiscoveryRecommendAdapter;
import com.xxfc.discovery.adapter.DiscoveryShortVideoAdapter;
import com.xxfc.discovery.api.DiscoveryApi;
import com.xxfc.discovery.bean.DiscoveryRecommendBean;
import com.xxfc.discovery.event.PostPatEvent;
import com.xxfc.discovery.event.PostVideoEvent;
import com.xxfc.discovery.other.ShortVideoActivity;
import com.xxfc.discovery.presenter.DiscoveryPresenter;
import java.util.LinkedHashMap;
import java.util.Map;
import butterknife.BindView;
import io.reactivex.schedulers.Schedulers;
/**
* 短视频
*/
public class ShortVideoFragment extends BaseFragment<DiscoveryPresenter> implements BaseQuickAdapter.RequestLoadMoreListener, SimpleRefreshLayout.OnSimpleRefreshListener{
public class ShortVideoFragment extends BaseFragment<DiscoveryPresenter> implements BaseQuickAdapter.RequestLoadMoreListener, SimpleRefreshLayout.OnSimpleRefreshListener {
@BindView(R2.id.rv_content)
RecyclerView rvContent;
@BindView(R2.id.refresh)
SimpleRefreshLayout mSimpleRefreshLayout;
private DiscoveryRecommendAdapter mAdapter;
private DiscoveryShortVideoAdapter mAdapter;
private int countPage;
private int mPage;
......@@ -56,14 +66,77 @@ public class ShortVideoFragment extends BaseFragment<DiscoveryPresenter> implem
protected void initView(Bundle savedInstanceState) {
mSimpleRefreshLayout.setHeaderView(new SimpleRefreshView(_mActivity));
mSimpleRefreshLayout.setOnSimpleRefreshListener(this);
Display display = _mActivity.getWindowManager().getDefaultDisplay();
mAdapter = new DiscoveryRecommendAdapter(display);
rvContent.setLayoutManager(new GridLayoutManager(_mActivity, 2));
rvContent.addItemDecoration(new AbSpacesItemDecoration(15));// 分割线。
initRxbus();
mAdapter = new DiscoveryShortVideoAdapter();
StaggeredGridLayoutManager staggeredGridLayoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);
rvContent.setItemAnimator(null);
rvContent.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
int[] first = new int[2];
staggeredGridLayoutManager.findFirstCompletelyVisibleItemPositions(first);
if (newState == RecyclerView.SCROLL_STATE_IDLE && (first[0] == 1 || first[1] == 1)) {
recyclerView.invalidateItemDecorations();
}
}
});
rvContent.setLayoutManager(staggeredGridLayoutManager);
// rvContent.setLayoutManager(new GridLayoutManager(_mActivity, 2));
rvContent.addItemDecoration(new AbSpacesItemDecoration(20, 10));// 分割线。
rvContent.setAdapter(mAdapter);
mAdapter.bindToRecyclerView(rvContent);
mAdapter.setEnableLoadMore(true);
mAdapter.disableLoadMoreIfNotFullPage();
mAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
@Override
public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
// DiscoveryRecommendBean.DataBeanX.DataBean data = (DiscoveryRecommendBean.DataBeanX.DataBean) adapter.getData();
DiscoveryRecommendBean.DataBeanX.DataBean item = (DiscoveryRecommendBean.DataBeanX.DataBean) adapter.getItem(position);
if (item != null) {
startActivity(ShortVideoActivity.getIntent(_mActivity, item));
}
}
});
mAdapter.setOnLoadMoreListener(new BaseQuickAdapter.RequestLoadMoreListener() {
@Override
public void onLoadMoreRequested() {
if (rvContent != null) {
rvContent.postDelayed(new Runnable() {
@Override
public void run() {
if (mPage >= countPage) {
mAdapter.loadMoreEnd();
} else {
mPage++;
geDataList(mPage);
}
}
}, 200);
}
}
}, rvContent);
}
private void initRxbus() {
RxBus.tObservable(PostVideoEvent.class)
.observeOn(Schedulers.newThread())
.subscribe(new Observer<PostVideoEvent>(disposable) {
@Override
public void onNext(PostVideoEvent event) {
onFresh();
}
});
}
@Override
protected void loadData(Bundle savedInstanceState) {
onFresh();
......@@ -85,7 +158,7 @@ public class ShortVideoFragment extends BaseFragment<DiscoveryPresenter> implem
private void geDataList(int page) {
Map<String, Object> map = new LinkedHashMap<>();
map.put("page", page);
map.put("type",4);
map.put("type", 4);
mPresenter.postData(0, DiscoveryApi.DISCOVERY_UNAUTH_LIST, DiscoveryRecommendBean.class, map, page == 1 ? false : false);
}
......@@ -125,21 +198,29 @@ public class ShortVideoFragment extends BaseFragment<DiscoveryPresenter> implem
}
public class AbSpacesItemDecoration extends RecyclerView.ItemDecoration {
private int space;
private int left;
private int right;
public AbSpacesItemDecoration(int space) {
this.space = space;
public AbSpacesItemDecoration(int left, int right) {
this.left = left;
this.right = right;
}
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
outRect.left = space;
outRect.right = space;
outRect.bottom = space;
outRect.top = space;
int position = parent.getChildAdapterPosition(view);
StaggeredGridLayoutManager.LayoutParams lp = (StaggeredGridLayoutManager.LayoutParams) view.getLayoutParams();
if (lp.getSpanIndex() % 2 == 0) {
outRect.left = left;
outRect.right = right;
} else {
outRect.left = right;
outRect.right = left;
}
outRect.top = left;
}
}
}
package com.xxfc.discovery.other;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.provider.MediaStore;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.ruiwenliu.wrapper.base.BaseBean;
import com.ruiwenliu.wrapper.base.BaseStatusActivity;
import com.ruiwenliu.wrapper.weight.TitleView;
import com.xxfc.discovery.R;
import com.xxfc.discovery.R2;
import com.xxfc.discovery.adapter.DiscoveryVideoSelectAdapter;
import com.xxfc.discovery.bean.DiscoveryRecommendBean;
import com.xxfc.discovery.bean.VideoFile;
import com.xxfc.discovery.presenter.DiscoveryPresenter;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
/**
* 视频选择
*/
public class SelectVideoActivity extends BaseStatusActivity<DiscoveryPresenter> {
@BindView(R2.id.rv_video_content)
RecyclerView rvVideoContent;
private DiscoveryVideoSelectAdapter selectAdapter;
public static Intent getIntent(Context context) {
return new Intent(context, SelectVideoActivity.class);
}
@Override
protected int setLayout() {
return R.layout.activity_select_video;
}
@Override
protected void initView(Bundle savedInstanceState, TitleView titleView, Intent intent) {
titleView.setTitle("视频选择");
selectAdapter = new DiscoveryVideoSelectAdapter();
rvVideoContent.setLayoutManager(new LinearLayoutManager(mActivity, LinearLayoutManager.VERTICAL, false));
rvVideoContent.setNestedScrollingEnabled(false);
rvVideoContent.setAdapter(selectAdapter);
selectAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
@Override
public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
VideoFile item = (VideoFile) adapter.getItem(position);
getIntent().putExtra("videofile", item);
setResult(201, getIntent());
finish();
}
});
selectAdapter.addData(videoInAlbum());
}
@Override
public void onShowResult(int requestType, BaseBean result) {
}
/**
* 查系统相册中的视频,
*
* @return 查询失败返回null, 与空结果分开表示,
*/
@Nullable
private List<VideoFile> videoInAlbum() {
String[] projection = new String[]{
MediaStore.Video.Media.DATA,
MediaStore.Video.Media.DATE_ADDED,
MediaStore.Video.Media.SIZE,
MediaStore.Video.Media.DURATION
};
// 只支持mp4, 据测flv可能被搜到并出现问题,
String selection = MediaStore.Video.Media.MIME_TYPE + " = ?";
String[] selectionArgs = new String[]{
"video/mp4"
};
Cursor cursor = getContentResolver().query(
MediaStore.Video.Media.EXTERNAL_CONTENT_URI,
projection, selection, selectionArgs,
MediaStore.Video.Media.DATE_ADDED + " DESC");
if (cursor == null) {
return null;
}
List<VideoFile> list = new ArrayList<>(cursor.getCount());
while (cursor.moveToNext()) {
String filePath = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Video.Media.DATA));
if (!new File(filePath).exists()) {
// 系统相册数据库中可能没有及时同步,可能存在已经被删除了的视频的记录,
continue;
}
Long createTime = cursor.getLong(cursor.getColumnIndexOrThrow(MediaStore.Video.Media.DATE_ADDED));
Long fileSize = cursor.getLong(cursor.getColumnIndexOrThrow(MediaStore.Video.Media.SIZE));
Long timeLen = cursor.getLong(cursor.getColumnIndexOrThrow(MediaStore.Video.Media.DURATION));
if (timeLen == 0) {
continue;
}
VideoFile videoFile = new VideoFile();
// 系统相册查出来的时间单位是秒,这里要的是毫秒,所以乘以一千,
videoFile.setCreateTime(1000 * createTime);
// 系统相册查出来的时长单位是毫秒,这里要的是秒,所以除以一千,
videoFile.setFileLength(timeLen / 1000);
videoFile.setFileSize(fileSize);
videoFile.setFilePath(filePath);
list.add(videoFile);
}
cursor.close();
return list;
}
}
package com.xxfc.discovery.other;
import android.Manifest;
import android.app.Activity;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.alibaba.fastjson.JSON;
import com.baidu.location.BDAbstractLocationListener;
import com.baidu.location.BDLocation;
import com.baidu.location.Poi;
import com.baidu.mapapi.model.LatLng;
import com.frame.base.bus.RxBus;
import com.frame.base.url.Constance;
import com.frame.rv.config.RvFrameConfig;
import com.ruiwenliu.wrapper.base.BaseBean;
import com.ruiwenliu.wrapper.base.BaseStatusActivity;
import com.ruiwenliu.wrapper.http.ProgressRequestBody;
import com.ruiwenliu.wrapper.inter.UploadCallbacks;
import com.ruiwenliu.wrapper.util.LocationManager;
import com.ruiwenliu.wrapper.util.ViewHolder;
import com.ruiwenliu.wrapper.util.glide.GlideManager;
import com.ruiwenliu.wrapper.util.permission.RxPermission;
import com.ruiwenliu.wrapper.weight.TitleView;
import com.rv.component.dialog.ProgressBarDialog;
import com.rv.component.dialog.TipsDialog;
import com.rv.component.utils.DateUtils;
import com.xxfc.discovery.R;
import com.xxfc.discovery.R2;
import com.xxfc.discovery.api.DiscoveryApi;
import com.xxfc.discovery.bean.DiscoveryIMTokenBean;
import com.xxfc.discovery.bean.ImageSources;
import com.xxfc.discovery.bean.UpdateVideoFile;
import com.xxfc.discovery.bean.VideoFile;
import com.xxfc.discovery.event.PostPatEvent;
import com.xxfc.discovery.event.PostVideoEvent;
import com.xxfc.discovery.presenter.DiscoveryPresenter;
import com.yuyife.okgo.OkGoUtil;
import java.io.File;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import io.reactivex.functions.Consumer;
import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
/**
* 发短视频
......@@ -18,6 +67,25 @@ import com.xxfc.discovery.presenter.DiscoveryPresenter;
@Route(path = Constance.ACTIVITY_URL_SENDVIDEO)
public class SendVideoActivity extends BaseStatusActivity<DiscoveryPresenter> {
@BindView(R2.id.et_video_content)
EditText etVideoContent;
@BindView(R2.id.iv_video_hint)
ImageView ivVideoHint;
@BindView(R2.id.tv_video_address)
TextView tvPatAddress;
@BindView(R2.id.iv_item_delete)
ImageView ivItemDelete;
private LocationManager locationManager;
private double latLatitude = 0;
private double lonLongitude;
private LatLng mLatLng;//当前城市经纬度
private String addrStr;
private String address;
private String name;
private UpdateVideoFile videoBean;
private ArrayList<ImageSources> sourcesList;
@Override
protected int setLayout() {
return R.layout.activity_send_video;
......@@ -26,11 +94,219 @@ public class SendVideoActivity extends BaseStatusActivity<DiscoveryPresenter> {
@Override
protected void initView(Bundle savedInstanceState, TitleView titleView, Intent intent) {
titleView.setTitle("发布视频");
permissionProcess();
}
@Override
public void onShowResult(int requestType, BaseBean result) {
switch (requestType) {
case 0:
videoBean = (UpdateVideoFile) result;
break;
case 1:
DiscoveryIMTokenBean intokenBean = (DiscoveryIMTokenBean) result;
setData(intokenBean);
break;
case 2:
RxBus.post(new PostVideoEvent());
finish();
break;
}
}
private void setData(DiscoveryIMTokenBean intokenBean) {
if (intokenBean == null) {
return;
}
if (videoBean == null) {
showToast("请选择视频");
return;
}
Map<String, Object> map = new LinkedHashMap<>();
map.put("access_token", intokenBean.getData());
map.put("type", "4");
map.put("flag", "3");
map.put("visible", "1");
map.put("text", etVideoContent.getText().toString());
sourcesList = new ArrayList<>();
ImageSources sources = new ImageSources();
sources.setoUrl(videoBean.getData());
sources.settUrl(videoBean.getData());
sourcesList.add(sources);
map.put("videos", JSON.toJSONString(sourcesList));
if (!TextUtils.isEmpty(address)) {
addrStr = address;
// 纬度
map.put("latitude", String.valueOf(latLatitude));
// 经度
map.put("longitude", String.valueOf(lonLongitude));
// 位置
map.put("location", address);
}
map.put("cityId", "0");
map.put("time", DateUtils.getCurTimeMillis());
mPresenter.postData(2, DiscoveryApi.DISCOVERY_MSG_ADD, BaseBean.class, map, true);
}
@OnClick({R2.id.rl_item_select_video, R2.id.ll_item_select_address, R2.id.tv_video_ok, R2.id.iv_item_delete})
public void onViewClicked(View view) {
int id = view.getId();
if (id == R.id.rl_item_select_video) {
startActivityForResult(SelectVideoActivity.getIntent(mActivity), 109);
} else if (id == R.id.ll_item_select_address) {
ARouter.getInstance()
.build(Constance.ACTIVITY_URL_MAPLOCATION)
.withDouble("latLatitude", latLatitude)
.withDouble("lonLongitude", lonLongitude)
.withString("name", name)
.withString("addrStr", addrStr)
.navigation(this, 211);
} else if (id == R.id.tv_video_ok) {
upData();
} else if (id == R.id.iv_item_delete) {
tvPatAddress.setText("");
latLatitude = 0;
lonLongitude = 0;
address = "";
ivItemDelete.setVisibility(View.GONE);
}
}
private void upData() {
if (OkGoUtil.getToken() != null) {
Map<String, Object> headMap = new LinkedHashMap<>();
headMap.put("Authorization", OkGoUtil.getToken());
mPresenter.postData(RvFrameConfig.HOST, 1, DiscoveryApi.DISCOVERY_IM_LOGIN, DiscoveryIMTokenBean.class, headMap, headMap, true);
}
}
/**
* 上传文件
*
* @param file
*/
private void uploadFile(File file, String fileName) {
// RequestBody requestFile =
// RequestBody.create(MediaType.parse("application/otcet-stream"), file);
ProgressBarDialog progressBarDialog = new ProgressBarDialog(mActivity);
//设置点击屏幕不消失
progressBarDialog.setCanceledOnTouchOutside(false);
//设置点击返回键不消失
progressBarDialog.setCancelable(false);
progressBarDialog.show();
//实现上传进度监听
ProgressRequestBody requestFile = new ProgressRequestBody(file, "video/*", new ProgressRequestBody.UploadCallbacks() {
@Override
public void onProgressUpdate(int percentage) {
Log.i("SendVideoActivity", "run:++ " + percentage);
progressBarDialog.setContent(percentage);
if (percentage == 100 && progressBarDialog != null) {
progressBarDialog.dismiss();
}
}
});
MultipartBody.Part body =
MultipartBody.Part.createFormData("file", file.getName(), requestFile);
RequestBody description =
RequestBody.create(
MediaType.parse("multipart/form-data"), fileName);
mPresenter.getUploadFile(RvFrameConfig.VEHICLE_UPLOAD, 0, DiscoveryApi.HTTP_URL_FILE_UPLOAD_VIDEO, UpdateVideoFile.class, description, body, false);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 109 && resultCode == 201) {
VideoFile videofile = (VideoFile) data.getSerializableExtra("videofile");
GlideManager.getInstance(mActivity).loadImage(videofile.getFilePath(), ivVideoHint);
uploadFile(new File(videofile.getFilePath()), "video");
} else if (requestCode == 211 && resultCode == Activity.RESULT_OK) {
ivItemDelete.setVisibility(View.VISIBLE);
latLatitude = data.getDoubleExtra("latitude", 0);
lonLongitude = data.getDoubleExtra("longitude", 0);
address = data.getStringExtra("location");
tvPatAddress.setText(data.getStringExtra("location"));
}
}
/**
* 定位权限处理
*/
private void permissionProcess() {
/**
* 6.0以上手机做权限处理
*/
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
new RxPermission(this).request(
Manifest.permission.ACCESS_COARSE_LOCATION,
Manifest.permission.ACCESS_FINE_LOCATION
).subscribe(new Consumer<Boolean>() {
@Override
public void accept(Boolean aBoolean) throws Exception {
if (aBoolean == true) {
initGps();
} else {
finish();
}
}
});
} else {
initGps();
}
}
/**
* 初始化定位
*/
public void initGps() {
locationManager = new LocationManager(this);
locationManager.getLocationDetail(new BDAbstractLocationListener() {
@Override
public void onReceiveLocation(BDLocation location) {
//此处的BDLocation为定位结果信息类,通过它的各种get方法可获取定位相关的全部结果
//以下只列举部分获取经纬度相关(常用)的结果信息
//更多结果信息获取说明,请参照类参考中BDLocation类中的说明
//获取定位精度,默认值为0.0f
float radius = location.getRadius();
//获取经纬度坐标类型,以LocationClientOption中设置过的坐标类型为准
String coorType = location.getCoorType();
//获取定位类型、定位错误返回码,具体信息可参照类参考中BDLocation类中的说明
int errorCode = location.getLocType();
// setGpsContent("count=:",String.valueOf(count));
// setGpsContent("latitude:",String.valueOf(location.getLatitude()));
// setGpsContent("longitude:",String.valueOf(location.getLongitude()));
// setGpsContent("城市:",location.getCity());
// setGpsContent("街道:",location.getAddrStr());
// setGpsContent("当前位置:",location.getLocationDescribe());
addrStr = location.getAddrStr();
latLatitude = location.getLatitude();
lonLongitude = location.getLongitude();
List<Poi> poiList = location.getPoiList();
if (poiList != null && poiList.size() > 0) {
name = poiList.get(0).getName();
}
mLatLng = new LatLng(location.getLatitude(), location.getLongitude());
locationManager.stopLocation();
}
});
}
}
package com.xxfc.discovery.other;
import android.app.DownloadManager;
import android.app.ProgressDialog;
import android.content.BroadcastReceiver;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.support.v7.widget.OrientationHelper;
import android.os.Environment;
import android.provider.MediaStore;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewParent;
import android.view.Window;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.alibaba.android.arouter.launcher.ARouter;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.dueeeke.videoplayer.player.VideoView;
import com.frame.base.url.Constance;
import com.frame.rv.config.RvFrameConfig;
import com.ruiwenliu.wrapper.SPConstance;
import com.ruiwenliu.wrapper.base.BaseBean;
import com.ruiwenliu.wrapper.base.BaseStatusActivity;
import com.ruiwenliu.wrapper.statusbar.StatusBarUtil;
import com.ruiwenliu.wrapper.util.ViewHolder;
import com.ruiwenliu.wrapper.util.glide.GlideApp;
import com.ruiwenliu.wrapper.util.glide.GlideManager;
import com.ruiwenliu.wrapper.util.um.CustomShareListener;
import com.ruiwenliu.wrapper.util.um.ShareManager;
import com.ruiwenliu.wrapper.weight.TitleView;
import com.rv.component.utils.AlbumNotifyHelper;
import com.rv.component.utils.Cookie;
import com.rv.component.utils.IsAppInstall;
import com.rv.component.utils.StorageUtils;
import com.umeng.socialize.bean.SHARE_MEDIA;
import com.umeng.socialize.shareboard.SnsPlatform;
import com.umeng.socialize.utils.ShareBoardlistener;
import com.xxfc.discovery.R;
import com.xxfc.discovery.R2;
import com.xxfc.discovery.adapter.DiscoveryVideoAdapter;
import com.xxfc.discovery.bean.beam.DataUtil;
import com.xxfc.discovery.bean.beam.VideoBean;
import com.xxfc.discovery.dialog.DiscoveryVideoDialog;
import com.xxfc.discovery.adapter.DiscoveryVideoCommentAdapter;
import com.xxfc.discovery.api.DiscoveryApi;
import com.xxfc.discovery.bean.DiscoveryCommentBean;
import com.xxfc.discovery.bean.DiscoveryIMTokenBean;
import com.xxfc.discovery.bean.DiscoveryRecommendBean;
import com.xxfc.discovery.dialog.TrillCommentInputDialog;
import com.xxfc.discovery.presenter.DiscoveryPresenter;
import com.xxfc.discovery.widget.OnViewPagerListener;
import com.xxfc.discovery.widget.TikTokController;
import com.xxfc.discovery.widget.ViewPagerLayoutManager;
import com.yuyife.okgo.OkGoUtil;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import butterknife.BindView;
import butterknife.OnClick;
......@@ -38,129 +77,247 @@ import butterknife.OnClick;
/**
* 短视频
*/
public class ShortVideoActivity extends BaseStatusActivity<DiscoveryPresenter> {
public class ShortVideoActivity extends BaseStatusActivity<DiscoveryPresenter> implements BaseQuickAdapter.RequestLoadMoreListener {
@BindView(R2.id.rv_short_video)
RecyclerView rvShortVideo;
@BindView(R2.id.iv_item_video_play)
ImageView ivVideoPlay;
@BindView(R2.id.rv_video_comment)
RecyclerView rvVideoComment;
@BindView(R2.id.ll_comment_show)
LinearLayout llCommentShow;
@BindView(R2.id.tv_video_comment_all)
TextView tvVideoCommentAll;
@BindView(R2.id.container)
FrameLayout container;
@BindView(R2.id.thumb)
ImageView thumb;
@BindView(R2.id.iv_video_avatar)
ImageView ivVideoAvatar;
@BindView(R2.id.iv_video_islike)
ImageView ivVideoIslike;
@BindView(R2.id.ll_item_video_islike)
LinearLayout llItemVideoIslike;
@BindView(R2.id.tv_video_islike_number)
TextView tvVideoIslikeNumber;
@BindView(R2.id.iv_video_comment)
ImageView ivVideoComment;
@BindView(R2.id.ll_item_video_comment)
LinearLayout llItemVideoComment;
@BindView(R2.id.tv_video_comment_number)
TextView tvVideoCommentNumber;
@BindView(R2.id.ll_item_video_share)
LinearLayout llItemVideoShare;
@BindView(R2.id.tv_video_share_number)
TextView tvVideoShareNumber;
@BindView(R2.id.tv_video_address_name)
TextView tvVideoAddressName;
@BindView(R2.id.tv_video_address)
TextView tvVideoAddress;
private VideoView mVideoView;
private TikTokController mTikTokController;
private int mCurrentPosition;
private List<VideoBean> mVideoList;
private DiscoveryVideoCommentAdapter commentAdapter;
private DiscoveryRecommendBean.DataBeanX.DataBean dataBean;
private List<DiscoveryRecommendBean.DataBeanX.DataBean> dataBeanList;
private int mPage;
private int countPage;
private String content;
private String isPraise;
private ShareManager shareManager;
private ClipboardManager myClipboard;
public static Intent getIntent(Context context) {
return new Intent(context, ShortVideoActivity.class);
public static Intent getIntent(Context context, DiscoveryRecommendBean.DataBeanX.DataBean bean) {
return new Intent(context, ShortVideoActivity.class)
.putExtra("bean", bean);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
StatusBarUtil.setRootViewFitsSystemWindows(mActivity, false);
}
@Override
protected int setLayout() {
return R.layout.activity_short_video;
}
@Override
protected void initView(Bundle savedInstanceState, TitleView titleView, Intent intent) {
showTitle(false);
dataBean = (DiscoveryRecommendBean.DataBeanX.DataBean) intent.getSerializableExtra("bean");
dataBeanList = new ArrayList();
mVideoView = new VideoView(this);
mVideoView.setLooping(true);
mTikTokController = new TikTokController(this);
mVideoView.setVideoController(mTikTokController);
commentAdapter = new DiscoveryVideoCommentAdapter();
rvVideoComment.setLayoutManager(new LinearLayoutManager(mActivity, LinearLayoutManager.VERTICAL, false));
rvVideoComment.setNestedScrollingEnabled(false);
rvVideoComment.setAdapter(commentAdapter);
DiscoveryVideoAdapter tikTokAdapter = new DiscoveryVideoAdapter();
ViewPagerLayoutManager layoutManager = new ViewPagerLayoutManager(this, OrientationHelper.VERTICAL);
rvShortVideo.setLayoutManager(layoutManager);
rvShortVideo.setAdapter(tikTokAdapter);
initData();
layoutManager.setOnViewPagerListener(new OnViewPagerListener() {
@Override
public void onInitComplete() {
//自动播放第一条
startPlay(0);
initShare(dataBean.getBody().getVideos().get(0).getOurl(), " ", " ", dataBean.getBody().getVideos().get(0).getOurl());
}
@Override
public void onPageRelease(boolean isNext, int position) {
if (mCurrentPosition == position) {
mVideoView.release();
private void initData() {
if (dataBean.getCount() != null) {
tvVideoCommentAll.setText("全部评论" + dataBean.getCount().getComment() + "条");
if (dataBean.getBody() != null && dataBean.getBody().getImages() != null && dataBean.getBody().getImages().size() > 0) {
GlideApp.with(mActivity)
.load(dataBean.getBody().getImages().get(0).getOurl())
.placeholder(android.R.color.white)
.into(thumb);
}
GlideManager.getInstance(mActivity).loadCircleImage(dataBean.getPicUrl(), ivVideoAvatar);
if (!TextUtils.isEmpty(dataBean.getLocation())) {
tvVideoAddress.setVisibility(View.VISIBLE);
tvVideoAddress.setText(dataBean.getLocation());
}
@Override
public void onPageSelected(int position, boolean isBottom) {
if (mCurrentPosition == position) return;
startPlay(position);
mCurrentPosition = position;
if (dataBean.getCount() != null) {
tvVideoIslikeNumber.setText(dataBean.getCount().getPraise());
tvVideoCommentNumber.setText(dataBean.getCount().getComment());
tvVideoShareNumber.setText(dataBean.getCount().getShare());
}
isPraise = dataBean.getIsPraise();
if ("1".equals(dataBean.getIsPraise())) { //0:未点赞 1:已点赞
ivVideoIslike.setImageResource(R.drawable.icon_discover_video_like);
} else {
ivVideoIslike.setImageResource(R.drawable.icon_discover_video_likeun);
}
}
});
startPlay();
}
tikTokAdapter.setOnItemChildClickListener(new BaseQuickAdapter.OnItemChildClickListener() {
@Override
public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
int id = view.getId();
if (id == R.id.ll_item_video_comment) {
showCommentDialog();
} else if (id == R.id.ll_item_video_share) {
private void startPlay() {
if (dataBean != null && dataBean.getBody() != null) {
if (dataBean.getBody().getVideos() != null && dataBean.getBody().getVideos().size() > 0) {
GlideApp.with(this)
.load(dataBean.getBody().getVideos().get(0).getOurl())
.placeholder(android.R.color.white)
.into(mTikTokController.getThumb());
}
ViewParent parent = mVideoView.getParent();
if (parent instanceof FrameLayout) {
((FrameLayout) parent).removeView(mVideoView);
}
container.addView(mVideoView);
if (dataBean.getBody().getVideos() != null && dataBean.getBody().getVideos().size() > 0) {
mVideoView.setUrl(dataBean.getBody().getVideos().get(0).getOurl());
mVideoView.setScreenScale(VideoView.SCREEN_SCALE_CENTER_CROP);
mVideoView.start();
}
}
}
});
mVideoList = DataUtil.getTikTokVideoList();
tikTokAdapter.addData(mVideoList);
@Override
protected void loadData(Bundle savedInstanceState, Intent intent) {
super.loadData(savedInstanceState, intent);
}
/**
* 评论
* IM token
*/
private void showCommentDialog() {
new DiscoveryVideoDialog(mActivity) {
@Override
public void helper(ViewHolder helper) {
super.helper(helper);
private void getImToken(int position) {
if (OkGoUtil.getToken() != null) {
Map<String, Object> headMap = new LinkedHashMap<>();
headMap.put("Authorization", OkGoUtil.getToken());
mPresenter.postData(RvFrameConfig.HOST, position, DiscoveryApi.DISCOVERY_IM_LOGIN, DiscoveryIMTokenBean.class, headMap, headMap, false);
}
}.show();
}
@Override
protected int setLayout() {
return R.layout.activity_short_video;
/**
* 获取评论
*/
private void commentData(String token) {
Map<String, Object> map = new LinkedHashMap<>();
map.put("access_token", token);
map.put("messageId", dataBean.getMsgId());
map.put("pageIndex", mPage);
mPresenter.postData(1, DiscoveryApi.DISCOVERY_COMMENT_LIST, DiscoveryCommentBean.class, map, mPage == 1 ? false : false);
}
@Override
protected void initView(Bundle savedInstanceState, TitleView titleView, Intent intent) {
showTitle(false);
public void onShowResult(int requestType, BaseBean result) {
switch (requestType) {
case 0:
DiscoveryIMTokenBean intokenBean = (DiscoveryIMTokenBean) result;
commentData(intokenBean.getData());
break;
case 1:
DiscoveryCommentBean commentBean = (DiscoveryCommentBean) result;
setCommentData(commentBean);
break;
case 2:
DiscoveryIMTokenBean intokenBean2 = (DiscoveryIMTokenBean) result;
upCommentData(intokenBean2.getData());
break;
case 3:
getImToken(0);
break;
case 4:
DiscoveryIMTokenBean intokenBean3 = (DiscoveryIMTokenBean) result;
upLikeData(intokenBean3.getData());
break;
case 5:
isPraise = "1";
ivVideoIslike.setImageResource(R.drawable.icon_discover_video_like);
break;
case 6:
isPraise = "0";
ivVideoIslike.setImageResource(R.drawable.icon_discover_video_likeun);
break;
}
}
private void startPlay(int position) {
View itemView = rvShortVideo.getChildAt(0);
FrameLayout frameLayout = itemView.findViewById(R.id.container);
GlideApp.with(this)
.load(mVideoList.get(position).getThumb())
.placeholder(android.R.color.white)
.into(mTikTokController.getThumb());
ViewParent parent = mVideoView.getParent();
if (parent instanceof FrameLayout) {
((FrameLayout) parent).removeView(mVideoView);
private void upLikeData(String data) {
if ("0".equals(isPraise)) {//0:未点赞 1:已点赞
Map<String, Object> map = new LinkedHashMap<>();
map.put("access_token", data);
map.put("messageId", dataBean.getMsgId());
mPresenter.postData(5, DiscoveryApi.DISCOVERY_PRAISE_ADD, BaseBean.class, map, false);
} else {
Map<String, Object> map = new LinkedHashMap<>();
map.put("access_token", data);
map.put("messageId", dataBean.getMsgId());
mPresenter.postData(6, DiscoveryApi.DISCOVERY_PRAISE_DELETE, BaseBean.class, map, false);
}
frameLayout.addView(mVideoView);
mVideoView.setUrl(mVideoList.get(position).getUrl());
mVideoView.setScreenScale(VideoView.SCREEN_SCALE_CENTER_CROP);
mVideoView.start();
}
/**
* 评论列表
*
* @param commentBean
*/
private void setCommentData(DiscoveryCommentBean commentBean) {
commentAdapter.setNewData(commentBean.getData());
@Override
public void onShowResult(int requestType, BaseBean result) {
}
/**
* 更新评论
*/
private void upCommentData(String token) {
Map<String, Object> map = new LinkedHashMap<>();
map.put("access_token", token);
map.put("messageId", dataBean.getMsgId());
map.put("body", content);
mPresenter.postData(3, DiscoveryApi.DISCOVERY_COMMENT_ADD, BaseBean.class, map, true);
}
......@@ -182,17 +339,178 @@ public class ShortVideoActivity extends BaseStatusActivity<DiscoveryPresenter> {
mVideoView.release();
}
@OnClick(R2.id.iv_item_video_play)
@OnClick({R2.id.iv_item_video_play, R2.id.iv_item_video_close, R2.id.v_comment_show_bg, R2.id.ll_item_comment
, R2.id.ll_item_video_islike, R2.id.ll_item_video_comment, R2.id.ll_item_video_share, R2.id.rl_item_video})
public void onViewClicked(View v) {
int id = v.getId();
if (id == R.id.iv_item_video_play) {
// if (mVideoView.isPlaying()) {
// mVideoView.pause();
// ivVideoPlay.animate().alpha(1.0f).start();
if (id == R.id.rl_item_video || id == R.id.iv_item_video_play) {
if (mVideoView.isPlaying()) {
mVideoView.pause();
ivVideoPlay.animate().alpha(1.0f).start();
} else {
mVideoView.resume();
ivVideoPlay.animate().alpha(0f).start();
}
} else if (id == R.id.ll_item_video_islike) {
//点赞
getImToken(4);
} else if (id == R.id.ll_item_video_comment) {
//评论
getImToken(0);
llCommentShow.setVisibility(View.VISIBLE);
} else if (id == R.id.ll_item_video_share) {
//分享
if (shareManager != null) {
shareManager.open();
}
} else if (id == R.id.iv_item_video_close || id == R.id.v_comment_show_bg) {
llCommentShow.setVisibility(View.GONE);
} else if (id == R.id.ll_item_comment) {
TrillCommentInputDialog trillCommentInputDialog = new TrillCommentInputDialog(mActivity, new TrillCommentInputDialog.OnSendCommentListener() {
@Override
public void sendComment(String str) {
content = str;
getImToken(2);
}
});
Window window = trillCommentInputDialog.getWindow();
if (window != null) {
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);// 软键盘弹起
trillCommentInputDialog.show();
}
}
}
@Override
public void onLoadMoreRequested() {
// if (mPage >= countPage) {
// commentAdapter.loadMoreEnd();
// } else {
// mVideoView.resume();
// ivVideoPlay.animate().alpha(0f).start();
// mPage++;
// getImToken(0);
// }
}
/**
* 刷新数据
*/
private void onRefresh() {
// mPage = 1;
// getImToken(0);
}
/**
* 初始化分享
*/
private void initShare(final String videoUrl, final String name, final String content, final String logo) {
shareManager = new ShareManager(this, new ShareBoardlistener() {
@Override
public void onclick(SnsPlatform snsPlatform, SHARE_MEDIA share_media) {
if (snsPlatform.mShowWord.equals("下载视频")) {
downMp4(videoUrl);
} else if (snsPlatform.mShowWord.equals("复制链接")) {
copyText();
} else if (snsPlatform.mShowWord.contains("微信")) {
if (!IsAppInstall.isWeixinAvilible(mActivity)) {
showToast("亲,您微信还没有安装呢");
return;
}
} else if (snsPlatform.mShowWord.contains("QQ")) {
if (!IsAppInstall.isQQClientAvailable(mActivity)) {
showToast("亲,您QQ还没有安装呢");
return;
}
}
shareManager.showShareVideo(share_media, videoUrl, name, content, logo, new CustomShareListener(mActivity) {
@Override
public void onResult(SHARE_MEDIA platform) {
super.onResult(platform);
if (platform != SHARE_MEDIA.MORE && platform != SHARE_MEDIA.SMS
&& platform != SHARE_MEDIA.EMAIL
&& platform != SHARE_MEDIA.FLICKR
&& platform != SHARE_MEDIA.FOURSQUARE
&& platform != SHARE_MEDIA.TUMBLR
&& platform != SHARE_MEDIA.POCKET
&& platform != SHARE_MEDIA.PINTEREST
&& platform != SHARE_MEDIA.INSTAGRAM
&& platform != SHARE_MEDIA.GOOGLEPLUS
&& platform != SHARE_MEDIA.YNOTE
&& platform != SHARE_MEDIA.EVERNOTE) {
showToast(platform + "分享成功啦");
}
}
});
}
}, "rv_um_share_bill", "rv_share_download_video", "");
}
/**
* 复制
*/
private void copyText() {
if (myClipboard == null) {
myClipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
}
ClipData myClip = ClipData.newPlainText("text", dataBean.getBody().getVideos().get(0).getOurl());
myClipboard.setPrimaryClip(myClip);
showToast("复制成功!");
}
private DownloadManager downloadManager;
private long reference;
private CompleteReceiver completeReceiver;
private void downMp4(String urlVideo) {
//下载任务
String serviceString = Context.DOWNLOAD_SERVICE;
//直接使用系统的下载管理器。是不是非常方便
downloadManager = (DownloadManager) getBaseContext().getSystemService(serviceString);
//可以是视频也可以是图片,分享时要填写正确的type类型,在下面我会列出各种类型
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(urlVideo));
request.setShowRunningNotification(false);//不显示通知栏(若不显示就不需要写上面的内容)
request.setVisibleInDownloadsUi(true);
//下载到那个文件夹下,以及命名
request.setDestinationInExternalPublicDir(StorageUtils.getPhotoSavePath(mActivity), System.currentTimeMillis() + ".mp4");
//下载的唯一标识,可以用这个标识来控制这个下载的任务enqueue()开始执行这个任务
reference = downloadManager.enqueue(request);
/** 注册下载监听的广播 **/
completeReceiver = new CompleteReceiver();
IntentFilter filter = new IntentFilter();
filter.addAction(DownloadManager.ACTION_NOTIFICATION_CLICKED);
filter.addAction(DownloadManager.ACTION_DOWNLOAD_COMPLETE);
registerReceiver(completeReceiver, filter);
}
//下载监听
class CompleteReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
//下载完成之后监听
String action = intent.getAction();
//下载完成的监听
if (action.equals(DownloadManager.ACTION_DOWNLOAD_COMPLETE)) {
showToast("下载完成");
// AlbumNotifyHelper.insertVideoToMediaStore(mActivity, StorageUtils.getPhotoSavePath(mActivity), System.currentTimeMillis(), 0);
}
//点击通知栏,取消下载任务
if (action.equals(DownloadManager.ACTION_NOTIFICATION_CLICKED)) {
downloadManager.remove((Long) reference);
}
}
}
}
......@@ -9,11 +9,13 @@ import android.widget.ImageView;
import com.dueeeke.videoplayer.controller.BaseVideoController;
import com.dueeeke.videoplayer.player.VideoView;
import com.dueeeke.videoplayer.util.L;
import com.ruiwenliu.wrapper.dialog.LoadingDialog;
import com.xxfc.discovery.R;
public class TikTokController extends BaseVideoController {
private ImageView thumb;
public TikTokController(@NonNull Context context) {
super(context);
}
......@@ -34,6 +36,7 @@ public class TikTokController extends BaseVideoController {
@Override
protected void initView() {
super.initView();
thumb = mControllerView.findViewById(R.id.iv_thumb);
}
......@@ -45,6 +48,7 @@ public class TikTokController extends BaseVideoController {
case VideoView.STATE_IDLE:
L.e("STATE_IDLE");
thumb.setVisibility(VISIBLE);
break;
case VideoView.STATE_PLAYING:
L.e("STATE_PLAYING");
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".other.SelectVideoActivity">
<android.support.v7.widget.RecyclerView
android:id="@+id/rv_video_content"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</android.support.v7.widget.RecyclerView>
</LinearLayout>
\ No newline at end of file
......@@ -12,7 +12,7 @@
android:orientation="vertical">
<EditText
android:id="@+id/et_content"
android:id="@+id/et_video_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
......@@ -28,13 +28,16 @@
android:textSize="@dimen/text_14" />
<RelativeLayout
android:id="@+id/rl_item_select_video"
android:layout_width="@dimen/size_100"
android:layout_height="@dimen/size_100"
android:layout_marginLeft="@dimen/size_15">
<ImageView
android:id="@+id/iv_video_hint"
android:layout_width="@dimen/size_100"
android:layout_height="@dimen/size_100"
android:scaleType="centerCrop"
android:src="@drawable/icon_send_video_button_hint"/>
</RelativeLayout>
......@@ -53,7 +56,7 @@
android:src="@drawable/campsite_icon_citylocation_hint" />
<TextView
android:id="@+id/tv_pat_address"
android:id="@+id/tv_video_address"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/size_5"
......@@ -64,6 +67,14 @@
android:textColor="@color/colorGray"
android:textSize="@dimen/text_12" />
<ImageView
android:id="@+id/iv_item_delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="@dimen/size_8"
android:visibility="gone"
android:src="@drawable/common_icon_circle_delete" />
</LinearLayout>
<View
......@@ -82,7 +93,7 @@
android:layout_height="wrap_content">
<TextView
android:id="@+id/tv_pat_ok"
android:id="@+id/tv_video_ok"
android:layout_width="match_parent"
android:layout_height="@dimen/size_45"
android:layout_marginLeft="@dimen/size_15"
......
......@@ -5,11 +5,27 @@
android:layout_height="match_parent"
tools:context=".other.ShortVideoActivity">
<android.support.v7.widget.RecyclerView
android:id="@+id/rv_short_video"
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/thumb"
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_height="match_parent"
android:scaleType="centerCrop" />
</FrameLayout>
<RelativeLayout
android:id="@+id/rl_item_video"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/iv_item_video_play"
......@@ -21,4 +37,222 @@
android:focusable="true"
android:src="@drawable/icon_live_profile_paly"
android:tint="#f2f2f2" />
</RelativeLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_marginRight="@dimen/size_20"
android:layout_marginBottom="@dimen/size_70"
android:gravity="center_horizontal"
android:orientation="vertical">
<ImageView
android:id="@+id/iv_video_avatar"
android:layout_width="@dimen/size_60"
android:layout_height="@dimen/size_60"
android:src="@drawable/aa_dis11" />
<LinearLayout
android:id="@+id/ll_item_video_islike"
android:layout_width="@dimen/size_45"
android:layout_height="@dimen/size_45"
android:layout_marginTop="@dimen/size_30"
android:background="@drawable/shape_rv_bg_black_half"
android:gravity="center">
<ImageView
android:id="@+id/iv_video_islike"
android:layout_width="@dimen/size_20"
android:layout_height="@dimen/size_20"
android:src="@drawable/icon_discover_video_likeun" />
</LinearLayout>
<TextView
android:id="@+id/tv_video_islike_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/size_3"
android:text=""
android:textColor="@color/colorWrite"
android:textSize="@dimen/text_12" />
<LinearLayout
android:id="@+id/ll_item_video_comment"
android:layout_width="@dimen/size_45"
android:layout_height="@dimen/size_45"
android:layout_marginTop="@dimen/size_15"
android:background="@drawable/shape_rv_bg_black_half"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:id="@+id/iv_video_comment"
android:layout_width="@dimen/size_20"
android:layout_height="@dimen/size_20"
android:src="@drawable/icon_discover_video_commentun" />
</LinearLayout>
<TextView
android:id="@+id/tv_video_comment_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/size_3"
android:text=""
android:textColor="@color/colorWrite"
android:textSize="@dimen/text_12" />
<LinearLayout
android:id="@+id/ll_item_video_share"
android:layout_width="@dimen/size_45"
android:layout_height="@dimen/size_45"
android:layout_marginTop="@dimen/size_15"
android:background="@drawable/shape_rv_bg_black_half"
android:gravity="center"
android:orientation="horizontal">
<ImageView
android:layout_width="@dimen/size_20"
android:layout_height="@dimen/size_20"
android:src="@drawable/icon_discover_video_share" />
</LinearLayout>
<TextView
android:id="@+id/tv_video_share_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/size_3"
android:text=""
android:textColor="@color/colorWrite"
android:textSize="@dimen/text_12" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginLeft="@dimen/size_15"
android:layout_marginBottom="@dimen/size_15"
android:orientation="vertical">
<TextView
android:id="@+id/tv_video_address_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textColor="@color/colorWrite"
android:textSize="@dimen/text_14" />
<TextView
android:visibility="gone"
android:id="@+id/tv_video_address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginTop="@dimen/size_10"
android:drawableLeft="@drawable/icon_discover_video_location"
android:drawablePadding="@dimen/size_5"
android:text=""
android:textColor="@color/colorWrite"
android:textSize="@dimen/text_10" />
</LinearLayout>
</RelativeLayout>
<LinearLayout
android:id="@+id/ll_comment_show"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:visibility="gone">
<View
android:id="@+id/v_comment_show_bg"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@color/gray_30000000" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_alignParentBottom="true"
android:layout_weight="2"
android:background="@color/colorWrite"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/size_10"
android:layout_marginBottom="@dimen/size_10">
<TextView
android:id="@+id/tv_video_comment_all"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="全部评论45条"
android:textColor="@color/textGray"
android:textSize="@dimen/text_14" />
<ImageView
android:id="@+id/iv_item_video_close"
android:layout_width="@dimen/size_30"
android:layout_height="@dimen/size_30"
android:layout_alignParentRight="true"
android:layout_marginTop="@dimen/size_10"
android:layout_marginRight="@dimen/size_10"
android:padding="@dimen/size_5"
android:src="@drawable/common_btn_close" />
</RelativeLayout>
<include layout="@layout/common_line" />
<android.support.v7.widget.RecyclerView
android:id="@+id/rv_video_comment"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"></android.support.v7.widget.RecyclerView>
<LinearLayout
android:id="@+id/ll_item_comment"
android:layout_width="match_parent"
android:layout_height="@dimen/size_60"
android:layout_marginLeft="@dimen/size_15"
android:layout_marginRight="@dimen/size_15"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="@dimen/size_40"
android:layout_weight="1"
android:background="@drawable/shape_rv_textview_home_search"
android:gravity="center_vertical"
android:paddingLeft="@dimen/size_15"
android:text="说点什么吧..."
android:textColor="@color/colorGray"
android:textSize="@dimen/text_14" />
<TextView
android:layout_width="@dimen/size_60"
android:layout_height="@dimen/size_40"
android:layout_marginLeft="@dimen/size_15"
android:background="@drawable/shape_rv_bg_yellow"
android:gravity="center"
android:text="评论"
android:textColor="@color/colorWrite"
android:textSize="@dimen/text_14" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
\ No newline at end of file
......@@ -7,34 +7,18 @@
android:orientation="vertical"
tools:context=".fragment.ShortVideoFragment">
<com.ruiwenliu.wrapper.weight.refresh.SimpleRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
<com.ruiwenliu.wrapper.weight.refresh.SimpleRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/refresh"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="@dimen/size_80"
android:scaleType="centerCrop"
android:src="@drawable/icon_fragment_discovery_hint" />
<android.support.v7.widget.RecyclerView
android:id="@+id/rv_content"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</android.support.v7.widget.RecyclerView>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</com.ruiwenliu.wrapper.weight.refresh.SimpleRefreshLayout>
</LinearLayout>
\ No newline at end of file
......@@ -11,18 +11,34 @@
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/iv_activity"
android:id="@+id/iv_icon_video"
android:layout_width="match_parent"
android:layout_height="@dimen/size_180"
android:scaleType="centerCrop" />
android:layout_height="wrap_content" />
<ImageView
android:id="@+id/iv_isvideo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="@drawable/icon_fragment_video_hint"/>
</RelativeLayout>
<TextView
android:id="@+id/tv_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/size_5"
android:paddingLeft="@dimen/size_5"
android:paddingRight="@dimen/size_5"
android:maxLines="2"
android:ellipsize="end"
android:text="行摄川西邂逅生命中未知的精彩"
android:textColor="@color/colorMain"
android:textSize="@dimen/text_14" />
......@@ -32,8 +48,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/size_5"
android:layout_marginBottom="@dimen/size_10"
android:paddingLeft="@dimen/size_5"
android:paddingRight="@dimen/size_5">
android:paddingLeft="@dimen/size_5">
<LinearLayout
android:layout_width="wrap_content"
......@@ -41,12 +56,14 @@
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
<com.base.utils.ui.image.round.RoundImageView
android:id="@+id/iv_user_icon"
android:layout_width="@dimen/size_15"
android:layout_height="@dimen/size_15"
android:src="@drawable/aa_dis11" />
<TextView
android:id="@+id/tv_user_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/size_3"
......@@ -55,24 +72,31 @@
</LinearLayout>
<LinearLayout
android:id="@+id/ll_item_islike"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="@dimen/size_15"
android:paddingTop="@dimen/size_5"
android:paddingBottom="@dimen/size_5"
android:paddingRight="@dimen/size_15"
android:layout_alignParentRight="true"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:id="@+id/iv_like"
android:layout_width="@dimen/size_15"
android:layout_height="@dimen/size_15"
android:padding="@dimen/size_1"
android:src="@drawable/common_icon_like_selected" />
android:src="@drawable/icon_discovery_ask_unlike" />
<TextView
android:id="@+id/iv_like_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/size_3"
android:text="10589"
android:textColor="#FFB74B"
android:textColor="@color/textGray"
android:textSize="@dimen/text_8" />
</LinearLayout>
</RelativeLayout>
......
......@@ -27,12 +27,14 @@
android:orientation="vertical">
<ImageView
android:id="@+id/iv_video_avatar"
android:layout_width="@dimen/size_60"
android:layout_height="@dimen/size_60"
android:src="@drawable/aa_dis11" />
<LinearLayout
android:id="@+id/ll_item_video_islike"
android:layout_width="@dimen/size_45"
android:layout_height="@dimen/size_45"
android:layout_marginTop="@dimen/size_30"
......@@ -40,6 +42,7 @@
android:gravity="center">
<ImageView
android:id="@+id/iv_video_islike"
android:layout_width="@dimen/size_20"
android:layout_height="@dimen/size_20"
android:src="@drawable/icon_discover_video_likeun" />
......@@ -47,6 +50,7 @@
</LinearLayout>
<TextView
android:id="@+id/tv_video_islike_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/size_3"
......@@ -64,6 +68,7 @@
android:orientation="vertical">
<ImageView
android:id="@+id/iv_video_comment"
android:layout_width="@dimen/size_20"
android:layout_height="@dimen/size_20"
android:src="@drawable/icon_discover_video_commentun" />
......@@ -71,6 +76,7 @@
</LinearLayout>
<TextView
android:id="@+id/tv_video_comment_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/size_3"
......@@ -95,6 +101,7 @@
</LinearLayout>
<TextView
android:id="@+id/tv_video_share_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/size_3"
......@@ -113,6 +120,7 @@
android:orientation="vertical">
<TextView
android:id="@+id/tv_video_address_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="中蒙界湖-贝尔湖"
......@@ -120,6 +128,7 @@
android:textSize="@dimen/text_14" />
<TextView
android:id="@+id/tv_video_address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
......
......@@ -14,11 +14,13 @@
android:orientation="horizontal">
<ImageView
android:id="@+id/iv_video_comment_avatar"
android:layout_width="@dimen/size_25"
android:layout_height="@dimen/size_25"
android:src="@drawable/aa_dis11" />
<TextView
android:id="@+id/iv_video_comment_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/size_10"
......@@ -28,6 +30,7 @@
android:textSize="@dimen/text_14" />
<TextView
android:id="@+id/tv_video_comment_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2019-06-05 12:00"
......@@ -36,6 +39,7 @@
</LinearLayout>
<TextView
android:id="@+id/tv_video_comment_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/size_10"
......@@ -45,6 +49,6 @@
android:textColor="@color/textGray"
android:textSize="@dimen/text_12" />
<include layout="@layout/common_line"/>
<include layout="@layout/common_line" />
</LinearLayout>
\ No newline at end of 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="wrap_content"
android:orientation="vertical"
android:paddingLeft="@dimen/size_15"
android:paddingRight="@dimen/size_15">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/size_15"
android:layout_marginBottom="@dimen/size_10"
android:gravity="center_vertical"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="@dimen/size_100"
android:layout_height="@dimen/size_100">
<ImageView
android:id="@+id/iv_video_icon"
android:layout_width="@dimen/size_100"
android:layout_height="@dimen/size_100"
android:scaleType="centerCrop" />
<ImageView
android:id="@+id/iv_isvideo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="@drawable/icon_fragment_video_hint" />
</RelativeLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/size_10"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/tv_video_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2019-06-26 11:29:59"
android:textColor="@color/textGray"
android:textSize="@dimen/text_16" />
<TextView
android:id="@+id/tv_video_duration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/size_10"
android:text="8秒"
android:textColor="@color/textGray"
android:textSize="@dimen/text_16" />
<TextView
android:id="@+id/tv_video_size"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/size_10"
android:text="13.85M"
android:textColor="@color/textGray"
android:textSize="@dimen/text_16" />
</LinearLayout>
</LinearLayout>
<include layout="@layout/common_line" />
</LinearLayout>
\ No newline at end of file
......@@ -3,6 +3,7 @@
package="com.rv.rvmine">
<application>
<activity android:name=".fragment.MyReleasePatFragment"></activity>
<activity
android:name=".personal.IDCardCertificationShowActivity"
android:screenOrientation="portrait" />
......
......@@ -11,16 +11,17 @@ import com.ruiwenliu.wrapper.util.TransformationUtil;
import com.ruiwenliu.wrapper.util.glide.GlideOptions;
import com.rv.home.rv.module.ui.main.home.bean.HomeRecommendBean;
import com.rv.rvmine.R;
import com.rv.rvmine.bean.MyReleaseBean;
public class MyReleasePatAdapter extends BaseQuickAdapter<HomeRecommendBean.DataBeanX.DataBean, BaseGlideHolder> {
public class MyReleasePatAdapter extends BaseQuickAdapter<MyReleaseBean.DataBeanX.DataBean, BaseGlideHolder> {
public MyReleasePatAdapter() {
super(R.layout.rv_item_rv_release_pat);
}
@Override
protected void convert(BaseGlideHolder helper, HomeRecommendBean.DataBeanX.DataBean item) {
HomeRecommendBean.DataBeanX.DataBean.Body body = item.getBody();
protected void convert(BaseGlideHolder helper, MyReleaseBean.DataBeanX.DataBean item) {
MyReleaseBean.DataBeanX.DataBean.Body body = item.getBody();
if (body != null) {
if (body.getImages() != null && body.getImages().size() > 0) {
......
package com.rv.rvmine.adapter;
import android.widget.ImageView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.ruiwenliu.wrapper.util.BaseGlideHolder;
import com.ruiwenliu.wrapper.util.TransformationUtil;
import com.ruiwenliu.wrapper.util.glide.GlideOptions;
import com.rv.home.rv.module.ui.main.home.bean.HomeRecommendBean;
import com.rv.rvmine.R;
import com.rv.rvmine.bean.MyReleaseBean;
/**
* 短视频
*/
public class MyReleaseVideoAdapter extends BaseQuickAdapter<MyReleaseBean.DataBeanX.DataBean, BaseGlideHolder> {
public MyReleaseVideoAdapter() {
super(R.layout.rv_item_rv_release_video);
}
@Override
protected void convert(BaseGlideHolder helper, MyReleaseBean.DataBeanX.DataBean item) {
MyReleaseBean.DataBeanX.DataBean.Body body = item.getBody();
if (body != null) {
if (body.getVideos() != null && body.getVideos().size() > 0) {
// GlideManager.getInstance(mContext).loadRoundImage2(body.getImages().get(0).getOurl(), (ImageView) helper.getView(R.id.iv_icon_pat),8);
ImageView image = helper.getView(R.id.iv_icon_pat);
GlideOptions options = GlideOptions.placeholderOf(com.ruiwenliu.wrapper.R.drawable.glide_icon_placeholder).
error(com.ruiwenliu.wrapper.R.drawable.glide_icon_error);
TransformationUtil utils = new TransformationUtil(image);
Glide.with(mContext)
.asBitmap()
.load(body.getVideos().get(0).getOurl())
.apply(options)
.apply(RequestOptions.bitmapTransform(new RoundedCorners(12)).override(image.getWidth(), image.getHeight()))
.into(utils);
}
helper.setText(R.id.tv_title, body.getText());
// helper.setText(R.id.tv_address, body);
if ("4".equals(body.getType())) { //消息类型 基础属性 1=文字消息、2=图文消息、3=语音消息、4=视频消息、 5=文件消
helper.setGone(R.id.iv_isvideo, true);
} else {
helper.setGone(R.id.iv_isvideo, false);
}
}
}
}
package com.rv.rvmine.bean;
import com.ruiwenliu.wrapper.base.BaseBean;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
public class MyReleaseBean extends BaseBean {
private DataBeanX data;
private boolean rel;
public DataBeanX getData() {
return data;
}
public void setData(DataBeanX data) {
this.data = data;
}
public boolean isRel() {
return rel;
}
public void setRel(boolean rel) {
this.rel = rel;
}
public static class DataBeanX {
private int totalCount;
private int totalPage;
private int pageNum;
private int pageSize;
private int total;
private int size;
private int startRow;
private int endRow;
private int pages;
private int prePage;
private int nextPage;
private boolean isFirstPage;
private boolean isLastPage;
private boolean hasPreviousPage;
private boolean hasNextPage;
private int navigatePages;
private ArrayList<Integer> navigatepageNums;
private int navigateFirstPage;
private int navigateLastPage;
private List<DataBean> data;
public int getTotalCount() {
return totalCount;
}
public void setTotalCount(int totalCount) {
this.totalCount = totalCount;
}
public int getTotalPage() {
return totalPage;
}
public void setTotalPage(int totalPage) {
this.totalPage = totalPage;
}
public int getPageNum() {
return pageNum;
}
public void setPageNum(int pageNum) {
this.pageNum = pageNum;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public int getTotal() {
return total;
}
public void setTotal(int total) {
this.total = total;
}
public int getSize() {
return size;
}
public void setSize(int size) {
this.size = size;
}
public int getStartRow() {
return startRow;
}
public void setStartRow(int startRow) {
this.startRow = startRow;
}
public int getEndRow() {
return endRow;
}
public void setEndRow(int endRow) {
this.endRow = endRow;
}
public int getPages() {
return pages;
}
public void setPages(int pages) {
this.pages = pages;
}
public int getPrePage() {
return prePage;
}
public void setPrePage(int prePage) {
this.prePage = prePage;
}
public int getNextPage() {
return nextPage;
}
public void setNextPage(int nextPage) {
this.nextPage = nextPage;
}
public boolean isFirstPage() {
return isFirstPage;
}
public void setFirstPage(boolean firstPage) {
isFirstPage = firstPage;
}
public boolean isLastPage() {
return isLastPage;
}
public void setLastPage(boolean lastPage) {
isLastPage = lastPage;
}
public boolean isHasPreviousPage() {
return hasPreviousPage;
}
public void setHasPreviousPage(boolean hasPreviousPage) {
this.hasPreviousPage = hasPreviousPage;
}
public boolean isHasNextPage() {
return hasNextPage;
}
public void setHasNextPage(boolean hasNextPage) {
this.hasNextPage = hasNextPage;
}
public int getNavigatePages() {
return navigatePages;
}
public void setNavigatePages(int navigatePages) {
this.navigatePages = navigatePages;
}
public ArrayList<Integer> getNavigatepageNums() {
return navigatepageNums;
}
public void setNavigatepageNums(ArrayList<Integer> navigatepageNums) {
this.navigatepageNums = navigatepageNums;
}
public int getNavigateFirstPage() {
return navigateFirstPage;
}
public void setNavigateFirstPage(int navigateFirstPage) {
this.navigateFirstPage = navigateFirstPage;
}
public int getNavigateLastPage() {
return navigateLastPage;
}
public void setNavigateLastPage(int navigateLastPage) {
this.navigateLastPage = navigateLastPage;
}
public List<DataBean> getData() {
return data;
}
public void setData(List<DataBean> data) {
this.data = data;
}
public static class DataBean implements Serializable {
private String cityId;
private String flag;
private double latitude;
private double longitude;
private String model;
private String nickname;
private String picUrl;
private String time;
private String userId;
private String visible;
private String isPraise; //0:未点赞 1:已点赞
private String isCollect;
private String state;
private String isAllowComment;
private Count count;
private MsgId id;
private String msgId;
private Body body;
private List<Comments> comments;
private List<praises> praises;
public String getMsgId() {
return msgId;
}
public void setMsgId(String msgId) {
this.msgId = msgId;
}
public String getCityId() {
return cityId;
}
public void setCityId(String cityId) {
this.cityId = cityId;
}
public String getFlag() {
return flag;
}
public void setFlag(String flag) {
this.flag = flag;
}
public double getLatitude() {
return latitude;
}
public void setLatitude(double latitude) {
this.latitude = latitude;
}
public double getLongitude() {
return longitude;
}
public void setLongitude(double longitude) {
this.longitude = longitude;
}
public String getModel() {
return model;
}
public void setModel(String model) {
this.model = model;
}
public String getNickname() {
return nickname;
}
public void setNickname(String nickname) {
this.nickname = nickname;
}
public String getPicUrl() {
return picUrl;
}
public void setPicUrl(String picUrl) {
this.picUrl = picUrl;
}
public String getTime() {
return time;
}
public void setTime(String time) {
this.time = time;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getVisible() {
return visible;
}
public void setVisible(String visible) {
this.visible = visible;
}
public String getIsPraise() {
return isPraise;
}
public void setIsPraise(String isPraise) {
this.isPraise = isPraise;
}
public String getIsCollect() {
return isCollect;
}
public void setIsCollect(String isCollect) {
this.isCollect = isCollect;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public String getIsAllowComment() {
return isAllowComment;
}
public void setIsAllowComment(String isAllowComment) {
this.isAllowComment = isAllowComment;
}
public Count getCount() {
return count;
}
public void setCount(Count count) {
this.count = count;
}
public MsgId getId() {
return id;
}
public void setId(MsgId id) {
this.id = id;
}
public Body getBody() {
return body;
}
public void setBody(Body body) {
this.body = body;
}
public List<Comments> getComments() {
return comments;
}
public void setComments(List<Comments> comments) {
this.comments = comments;
}
public List<DataBean.praises> getPraises() {
return praises;
}
public void setPraises(List<DataBean.praises> praises) {
this.praises = praises;
}
public static class Count implements Serializable {
private String collect;
private String comment;
private String forward;
private String money;
private String play;
private String praise;
private String share;
private String total;
public String getCollect() {
return collect;
}
public void setCollect(String collect) {
this.collect = collect;
}
public String getComment() {
return comment;
}
public void setComment(String comment) {
this.comment = comment;
}
public String getForward() {
return forward;
}
public void setForward(String forward) {
this.forward = forward;
}
public String getMoney() {
return money;
}
public void setMoney(String money) {
this.money = money;
}
public String getPlay() {
return play;
}
public void setPlay(String play) {
this.play = play;
}
public String getPraise() {
return praise;
}
public void setPraise(String praise) {
this.praise = praise;
}
public String getShare() {
return share;
}
public void setShare(String share) {
this.share = share;
}
public String getTotal() {
return total;
}
public void setTotal(String total) {
this.total = total;
}
}
public static class MsgId implements Serializable {
private String timestamp;// ": 16,
private String machineIdentifier;// ": 16,
private String processIdentifier;// ": 16,
private String counter;// ": 16,
private String time;// ": 16,
private String date;// ": 16,
private String timeSecond;// ": 16,
public String getTimestamp() {
return timestamp;
}
public void setTimestamp(String timestamp) {
this.timestamp = timestamp;
}
public String getMachineIdentifier() {
return machineIdentifier;
}
public void setMachineIdentifier(String machineIdentifier) {
this.machineIdentifier = machineIdentifier;
}
public String getProcessIdentifier() {
return processIdentifier;
}
public void setProcessIdentifier(String processIdentifier) {
this.processIdentifier = processIdentifier;
}
public String getCounter() {
return counter;
}
public void setCounter(String counter) {
this.counter = counter;
}
public String getTime() {
return time;
}
public void setTime(String time) {
this.time = time;
}
public String getDate() {
return date;
}
public void setDate(String date) {
this.date = date;
}
public String getTimeSecond() {
return timeSecond;
}
public void setTimeSecond(String timeSecond) {
this.timeSecond = timeSecond;
}
}
public static class Body implements Serializable {
private String text;
private String time;
private String type;
private List<Images> images;
private List<Videos> videos;
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public String getTime() {
return time;
}
public void setTime(String time) {
this.time = time;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public List<Images> getImages() {
return images;
}
public void setImages(List<Images> images) {
this.images = images;
}
public List<Videos> getVideos() {
return videos;
}
public void setVideos(List<Videos> videos) {
this.videos = videos;
}
public static class Images implements Serializable {
private String length;
private String size;
private String turl;
private String ourl;
private String oUrl;
private String tUrl;
public String getLength() {
return length;
}
public void setLength(String length) {
this.length = length;
}
public String getSize() {
return size;
}
public void setSize(String size) {
this.size = size;
}
public String getTurl() {
return turl;
}
public void setTurl(String turl) {
this.turl = turl;
}
public String getOurl() {
return ourl;
}
public void setOurl(String ourl) {
this.ourl = ourl;
}
public String getoUrl() {
return oUrl;
}
public void setoUrl(String oUrl) {
this.oUrl = oUrl;
}
public String gettUrl() {
return tUrl;
}
public void settUrl(String tUrl) {
this.tUrl = tUrl;
}
}
public static class Videos implements Serializable {
private String length;
private String size;
private String ourl;
private String oUrl;
public String getLength() {
return length;
}
public void setLength(String length) {
this.length = length;
}
public String getSize() {
return size;
}
public void setSize(String size) {
this.size = size;
}
public String getOurl() {
return ourl;
}
public void setOurl(String ourl) {
this.ourl = ourl;
}
public String getoUrl() {
return oUrl;
}
public void setoUrl(String oUrl) {
this.oUrl = oUrl;
}
}
}
public static class Comments implements Serializable {
private String body;
private String nickname;
private String time;
private String toUserId;
private String userId;
private MsgId msgId;
public String getBody() {
return body;
}
public void setBody(String body) {
this.body = body;
}
public String getNickname() {
return nickname;
}
public void setNickname(String nickname) {
this.nickname = nickname;
}
public String getTime() {
return time;
}
public void setTime(String time) {
this.time = time;
}
public String getToUserId() {
return toUserId;
}
public void setToUserId(String toUserId) {
this.toUserId = toUserId;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public MsgId getMsgId() {
return msgId;
}
public void setMsgId(MsgId msgId) {
this.msgId = msgId;
}
public static class MsgId implements Serializable {
private String timestamp;
private String machineIdentifier;
private String processIdentifier;
private String counter;
private String time;
private String date;
private String timeSecond;
public String getTimestamp() {
return timestamp;
}
public void setTimestamp(String timestamp) {
this.timestamp = timestamp;
}
public String getMachineIdentifier() {
return machineIdentifier;
}
public void setMachineIdentifier(String machineIdentifier) {
this.machineIdentifier = machineIdentifier;
}
public String getProcessIdentifier() {
return processIdentifier;
}
public void setProcessIdentifier(String processIdentifier) {
this.processIdentifier = processIdentifier;
}
public String getCounter() {
return counter;
}
public void setCounter(String counter) {
this.counter = counter;
}
public String getTime() {
return time;
}
public void setTime(String time) {
this.time = time;
}
public String getDate() {
return date;
}
public void setDate(String date) {
this.date = date;
}
public String getTimeSecond() {
return timeSecond;
}
public void setTimeSecond(String timeSecond) {
this.timeSecond = timeSecond;
}
}
}
public static class praises implements Serializable{
private String nickname;
private String time;
private String userId;
private MsgId msgId;
public String getNickname() {
return nickname;
}
public void setNickname(String nickname) {
this.nickname = nickname;
}
public String getTime() {
return time;
}
public void setTime(String time) {
this.time = time;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public MsgId getMsgId() {
return msgId;
}
public void setMsgId(MsgId msgId) {
this.msgId = msgId;
}
}
}
}
}
package com.rv.rvmine.fragment;
import android.graphics.Rect;
import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.view.View;
import com.alibaba.android.arouter.launcher.ARouter;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.frame.base.url.Constance;
import com.frame.rv.config.RvFrameConfig;
import com.ruiwenliu.wrapper.base.BaseBean;
import com.ruiwenliu.wrapper.base.BaseFragment;
import com.ruiwenliu.wrapper.base.presenter.CommonPresenter;
import com.ruiwenliu.wrapper.weight.refresh.SimpleRefreshLayout;
import com.ruiwenliu.wrapper.weight.refresh.SimpleRefreshView;
import com.rv.home.rv.module.ApiConfig;
import com.rv.home.rv.module.ui.main.home.bean.HomeRecommendBean;
import com.rv.rvmine.R;
import com.rv.rvmine.R2;
import com.rv.rvmine.adapter.MyReleasePatAdapter;
import com.rv.rvmine.bean.MyReleaseBean;
import com.yuyife.okgo.OkGoUtil;
import java.util.LinkedHashMap;
import java.util.Map;
import butterknife.BindView;
/**
* 问答
*/
public class MyReleaseAskFragment extends BaseFragment<CommonPresenter> implements SimpleRefreshLayout.OnSimpleRefreshListener {
@BindView(R2.id.rv_content)
RecyclerView rvContent;
@BindView(R2.id.refresh)
SimpleRefreshLayout mSimpleRefreshLayout;
private int countPage;
private int mPage;
private MyReleasePatAdapter mAdapter;
public static MyReleaseAskFragment getInstance(int type) {
Bundle bundl = new Bundle();
bundl.putInt("type", type);
MyReleaseAskFragment fragment = new MyReleaseAskFragment();
fragment.setArguments(bundl);
return fragment;
}
@Override
public int getViewLayout() {
return R.layout.fragment_my_release_pat;
}
@Override
protected void initView(Bundle savedInstanceState) {
mSimpleRefreshLayout.setHeaderView(new SimpleRefreshView(_mActivity));
mSimpleRefreshLayout.setOnSimpleRefreshListener(this);
mAdapter = new MyReleasePatAdapter();
final StaggeredGridLayoutManager staggeredGridLayoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);
rvContent.setItemAnimator(null);
rvContent.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
int[] first = new int[2];
staggeredGridLayoutManager.findFirstCompletelyVisibleItemPositions(first);
if (newState == RecyclerView.SCROLL_STATE_IDLE && (first[0] == 1 || first[1] == 1)) {
recyclerView.invalidateItemDecorations();
}
}
});
rvContent.setLayoutManager(staggeredGridLayoutManager);
rvContent.addItemDecoration(new AbSpacesItemDecoration(20, 10));// 分割线。
rvContent.setAdapter(mAdapter);
mAdapter.bindToRecyclerView(rvContent);
mAdapter.setEnableLoadMore(true);
mAdapter.disableLoadMoreIfNotFullPage();
mAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
@Override
public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
MyReleaseBean.DataBeanX.DataBean item = (MyReleaseBean.DataBeanX.DataBean) adapter.getItem(position);
if (item != null) {
ARouter.getInstance()
.build(Constance.ACTIVITY_URL_DETAILPAT)
.withString("id", item.getMsgId())
.withString("title", item.getBody().getText())
.withString("iconUrl", item.getBody().getImages().get(0).getOurl())
.withString("userName", item.getNickname())
.withString("userUrl", item.getPicUrl())
.navigation();
}
}
});
mAdapter.setOnLoadMoreListener(new BaseQuickAdapter.RequestLoadMoreListener() {
@Override
public void onLoadMoreRequested() {
if (rvContent != null) {
rvContent.postDelayed(new Runnable() {
@Override
public void run() {
if (mPage >= countPage) {
mAdapter.loadMoreEnd();
} else {
mPage++;
geDataList(mPage);
}
}
}, 200);
}
}
}, rvContent);
}
@Override
protected void loadData(Bundle savedInstanceState) {
onFresh();
}
@Override
public void onShowResult(int requestType, BaseBean result) {
mSimpleRefreshLayout.onRefreshComplete();
switch (requestType) {
case 0:
processData((MyReleaseBean) result);
break;
}
}
private void processData(MyReleaseBean bean) {
if (mPage == 1) {
countPage = bean.getData().getPageSize();
mAdapter.setNewData(bean.getData().getData());
if (bean.getData().getTotalCount() == 0) {
mAdapter.setEmptyView(getEmptyView(rvContent, -1, "暂无发布的数据"));
mAdapter.notifyDataSetChanged();
}
} else {
mAdapter.addData(bean.getData().getData());
mAdapter.loadMoreComplete();
}
}
@Override
public void onRefresh() {
onFresh();
}
/**
* 刷新
*/
private void onFresh() {
mPage = 1;
geDataList(mPage);
}
/**
* 请求数据
*
* @param page
*/
private void geDataList(int page) {
Map<String, Object> headMap = new LinkedHashMap<>();
if (OkGoUtil.getToken() != null) {
headMap.put("Authorization", OkGoUtil.getToken());
}
Map<String, Object> map = new LinkedHashMap<>();
map.put("page", page);
map.put("type", "5");
mPresenter.getData(RvFrameConfig.HOST, 0, ApiConfig.RVENTHUSIAST_GETBYUSERID_LIST, MyReleaseBean.class, map, headMap, page == 1 ? true : false);
}
public class AbSpacesItemDecoration extends RecyclerView.ItemDecoration {
private int left;
private int right;
public AbSpacesItemDecoration(int left, int right) {
this.left = left;
this.right = right;
}
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
int position = parent.getChildAdapterPosition(view);
StaggeredGridLayoutManager.LayoutParams lp = (StaggeredGridLayoutManager.LayoutParams) view.getLayoutParams();
if (lp.getSpanIndex() % 2 == 0) {
outRect.left = left;
outRect.right = right;
} else {
outRect.left = right;
outRect.right = left;
}
outRect.top = left;
}
}
}
package com.rv.rvmine.fragment;
import android.content.Intent;
import android.graphics.Rect;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.view.View;
import com.alibaba.android.arouter.launcher.ARouter;
import com.baidu.mapapi.model.LatLng;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.frame.base.url.Constance;
import com.frame.rv.config.RvFrameConfig;
import com.ruiwenliu.wrapper.base.BaseBean;
import com.ruiwenliu.wrapper.base.BaseFragment;
import com.ruiwenliu.wrapper.base.presenter.CommonPresenter;
import com.ruiwenliu.wrapper.util.MapUtil;
import com.ruiwenliu.wrapper.util.ViewHolder;
import com.ruiwenliu.wrapper.weight.refresh.SimpleRefreshLayout;
import com.ruiwenliu.wrapper.weight.refresh.SimpleRefreshView;
import com.rv.component.dialog.BottomDeleteDialog;
import com.rv.component.dialog.BottomPromptDialog;
import com.rv.component.utils.LocationRecord;
import com.rv.home.rv.module.ApiConfig;
import com.rv.home.rv.module.ui.main.home.bean.HomeRecommendBean;
import com.rv.rvmine.R;
import com.rv.rvmine.R2;
import com.rv.rvmine.adapter.MyReleasePatAdapter;
import com.rv.rvmine.bean.MyReleaseBean;
import com.rv.rvmine.traveler.MyReleaseActivity;
import com.xxrv.coupon.fragment.ExpiredCouponFragment;
import com.yuyife.okgo.OkGoUtil;
import java.util.LinkedHashMap;
import java.util.Map;
import butterknife.BindView;
/**
* 拍拍
*/
public class MyReleasePatFragment extends BaseFragment<CommonPresenter> implements SimpleRefreshLayout.OnSimpleRefreshListener {
@BindView(R2.id.rv_content)
RecyclerView rvContent;
@BindView(R2.id.refresh)
SimpleRefreshLayout mSimpleRefreshLayout;
private int countPage;
private int mPage;
private MyReleasePatAdapter mAdapter;
public static MyReleasePatFragment getInstance(int type) {
Bundle bundl = new Bundle();
bundl.putInt("type", type);
MyReleasePatFragment fragment = new MyReleasePatFragment();
fragment.setArguments(bundl);
return fragment;
}
@Override
public int getViewLayout() {
return R.layout.fragment_my_release_pat;
}
@Override
protected void initView(Bundle savedInstanceState) {
mSimpleRefreshLayout.setHeaderView(new SimpleRefreshView(_mActivity));
mSimpleRefreshLayout.setOnSimpleRefreshListener(this);
mAdapter = new MyReleasePatAdapter();
final StaggeredGridLayoutManager staggeredGridLayoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);
rvContent.setItemAnimator(null);
rvContent.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
int[] first = new int[2];
staggeredGridLayoutManager.findFirstCompletelyVisibleItemPositions(first);
if (newState == RecyclerView.SCROLL_STATE_IDLE && (first[0] == 1 || first[1] == 1)) {
recyclerView.invalidateItemDecorations();
}
}
});
rvContent.setLayoutManager(staggeredGridLayoutManager);
rvContent.addItemDecoration(new AbSpacesItemDecoration(20, 10));// 分割线。
rvContent.setAdapter(mAdapter);
mAdapter.bindToRecyclerView(rvContent);
mAdapter.setEnableLoadMore(true);
mAdapter.disableLoadMoreIfNotFullPage();
mAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
@Override
public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
MyReleaseBean.DataBeanX.DataBean item = (MyReleaseBean.DataBeanX.DataBean) adapter.getItem(position);
if (item != null) {
ARouter.getInstance()
.build(Constance.ACTIVITY_URL_DETAILPAT)
.withString("id", item.getMsgId())
.withString("title", item.getBody().getText())
.withString("iconUrl", item.getBody().getImages().get(0).getOurl())
.withString("userName", item.getNickname())
.withString("userUrl", item.getPicUrl())
.navigation();
}
}
});
mAdapter.setOnItemChildLongClickListener(new BaseQuickAdapter.OnItemChildLongClickListener() {
@Override
public boolean onItemChildLongClick(BaseQuickAdapter adapter, View view, int position) {
return true;
}
});
mAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
@Override
public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
showDeleteDialgo();
}
});
mAdapter.setOnLoadMoreListener(new BaseQuickAdapter.RequestLoadMoreListener() {
@Override
public void onLoadMoreRequested() {
if (rvContent != null) {
rvContent.postDelayed(new Runnable() {
@Override
public void run() {
if (mPage >= countPage) {
mAdapter.loadMoreEnd();
} else {
mPage++;
geDataList(mPage);
}
}
}, 200);
}
}
}, rvContent);
}
@Override
protected void loadData(Bundle savedInstanceState) {
onFresh();
}
@Override
public void onShowResult(int requestType, BaseBean result) {
mSimpleRefreshLayout.onRefreshComplete();
switch (requestType) {
case 0:
processData((MyReleaseBean) result);
break;
}
}
private void processData(MyReleaseBean bean) {
if (mPage == 1) {
countPage = bean.getData().getPageSize();
mAdapter.setNewData(bean.getData().getData());
if (bean.getData().getTotalCount() == 0) {
mAdapter.setEmptyView(getEmptyView(rvContent, -1, "暂无发布的数据"));
mAdapter.notifyDataSetChanged();
}
} else {
mAdapter.addData(bean.getData().getData());
mAdapter.loadMoreComplete();
}
}
@Override
public void onRefresh() {
onFresh();
}
/**
* 刷新
*/
private void onFresh() {
mPage = 1;
geDataList(mPage);
}
/**
* 请求数据
*
* @param page
*/
private void geDataList(int page) {
Map<String, Object> headMap = new LinkedHashMap<>();
if (OkGoUtil.getToken() != null) {
headMap.put("Authorization", OkGoUtil.getToken());
}
Map<String, Object> map = new LinkedHashMap<>();
map.put("page", page);
map.put("type", "2");
mPresenter.getData(RvFrameConfig.HOST, 0, ApiConfig.RVENTHUSIAST_GETBYUSERID_LIST, MyReleaseBean.class, map, headMap, page == 1 ? true : false);
}
public void showDeleteDialgo() {
new BottomDeleteDialog(_mActivity) {
@Override
public void helper(ViewHolder helper) {
super.helper(helper);
helper.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int i = v.getId();
if (i == R.id.ll_item_delete) {
dismiss();
}
}
}, R.id.ll_item_delete);
}
}.show();
}
public class AbSpacesItemDecoration extends RecyclerView.ItemDecoration {
private int left;
private int right;
public AbSpacesItemDecoration(int left, int right) {
this.left = left;
this.right = right;
}
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
int position = parent.getChildAdapterPosition(view);
StaggeredGridLayoutManager.LayoutParams lp = (StaggeredGridLayoutManager.LayoutParams) view.getLayoutParams();
if (lp.getSpanIndex() % 2 == 0) {
outRect.left = left;
outRect.right = right;
} else {
outRect.left = right;
outRect.right = left;
}
outRect.top = left;
}
}
}
package com.rv.rvmine.fragment;
import android.graphics.Rect;
import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.view.View;
import com.alibaba.android.arouter.launcher.ARouter;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.frame.base.url.Constance;
import com.frame.rv.config.RvFrameConfig;
import com.ruiwenliu.wrapper.base.BaseBean;
import com.ruiwenliu.wrapper.base.BaseFragment;
import com.ruiwenliu.wrapper.base.presenter.CommonPresenter;
import com.ruiwenliu.wrapper.weight.refresh.SimpleRefreshLayout;
import com.ruiwenliu.wrapper.weight.refresh.SimpleRefreshView;
import com.rv.home.rv.module.ApiConfig;
import com.rv.home.rv.module.ui.main.home.bean.HomeRecommendBean;
import com.rv.rvmine.R;
import com.rv.rvmine.R2;
import com.rv.rvmine.adapter.MyReleasePatAdapter;
import com.rv.rvmine.adapter.MyReleaseVideoAdapter;
import com.rv.rvmine.bean.MyReleaseBean;
import com.yuyife.okgo.OkGoUtil;
import java.util.LinkedHashMap;
import java.util.Map;
import butterknife.BindView;
/**
* 短视频
*/
public class MyReleaseVideoFragment extends BaseFragment<CommonPresenter> implements SimpleRefreshLayout.OnSimpleRefreshListener {
@BindView(R2.id.rv_content)
RecyclerView rvContent;
@BindView(R2.id.refresh)
SimpleRefreshLayout mSimpleRefreshLayout;
private int countPage;
private int mPage;
private MyReleaseVideoAdapter mAdapter;
public static MyReleaseVideoFragment getInstance(int type) {
Bundle bundl = new Bundle();
bundl.putInt("type", type);
MyReleaseVideoFragment fragment = new MyReleaseVideoFragment();
fragment.setArguments(bundl);
return fragment;
}
@Override
public int getViewLayout() {
return R.layout.fragment_my_release_pat;
}
@Override
protected void initView(Bundle savedInstanceState) {
mSimpleRefreshLayout.setHeaderView(new SimpleRefreshView(_mActivity));
mSimpleRefreshLayout.setOnSimpleRefreshListener(this);
mAdapter = new MyReleaseVideoAdapter();
final StaggeredGridLayoutManager staggeredGridLayoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);
rvContent.setItemAnimator(null);
rvContent.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
int[] first = new int[2];
staggeredGridLayoutManager.findFirstCompletelyVisibleItemPositions(first);
if (newState == RecyclerView.SCROLL_STATE_IDLE && (first[0] == 1 || first[1] == 1)) {
recyclerView.invalidateItemDecorations();
}
}
});
rvContent.setLayoutManager(staggeredGridLayoutManager);
rvContent.addItemDecoration(new AbSpacesItemDecoration(20, 10));// 分割线。
rvContent.setAdapter(mAdapter);
mAdapter.bindToRecyclerView(rvContent);
mAdapter.setEnableLoadMore(true);
mAdapter.disableLoadMoreIfNotFullPage();
mAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
@Override
public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
MyReleaseBean.DataBeanX.DataBean item = (MyReleaseBean.DataBeanX.DataBean) adapter.getItem(position);
if (item != null) {
// ARouter.getInstance()
// .build(Constance.ACTIVITY_URL_DETAILPAT)
// .withString("id", item.getMsgId())
// .withString("title", item.getBody().getText())
// .withString("iconUrl", item.getBody().getImages().get(0).getOurl())
// .withString("userName", item.getNickname())
// .withString("userUrl", item.getPicUrl())
// .navigation();
}
}
});
mAdapter.setOnLoadMoreListener(new BaseQuickAdapter.RequestLoadMoreListener() {
@Override
public void onLoadMoreRequested() {
if (rvContent != null) {
rvContent.postDelayed(new Runnable() {
@Override
public void run() {
if (mPage >= countPage) {
mAdapter.loadMoreEnd();
} else {
mPage++;
geDataList(mPage);
}
}
}, 200);
}
}
}, rvContent);
}
@Override
protected void loadData(Bundle savedInstanceState) {
onFresh();
}
@Override
public void onShowResult(int requestType, BaseBean result) {
mSimpleRefreshLayout.onRefreshComplete();
switch (requestType) {
case 0:
processData((MyReleaseBean) result);
break;
}
}
private void processData(MyReleaseBean bean) {
if (mPage == 1) {
countPage = bean.getData().getPageSize();
mAdapter.setNewData(bean.getData().getData());
if (bean.getData().getTotalCount() == 0) {
mAdapter.setEmptyView(getEmptyView(rvContent, -1, "暂无发布的数据"));
mAdapter.notifyDataSetChanged();
}
} else {
mAdapter.addData(bean.getData().getData());
mAdapter.loadMoreComplete();
}
}
@Override
public void onRefresh() {
onFresh();
}
/**
* 刷新
*/
private void onFresh() {
mPage = 1;
geDataList(mPage);
}
/**
* 请求数据
*
* @param page
*/
private void geDataList(int page) {
Map<String, Object> headMap = new LinkedHashMap<>();
if (OkGoUtil.getToken() != null) {
headMap.put("Authorization", OkGoUtil.getToken());
}
Map<String, Object> map = new LinkedHashMap<>();
map.put("page", page);
map.put("type", "4");
mPresenter.getData(RvFrameConfig.HOST, 0, ApiConfig.RVENTHUSIAST_GETBYUSERID_LIST, MyReleaseBean.class, map, headMap, page == 1 ? true : false);
}
public class AbSpacesItemDecoration extends RecyclerView.ItemDecoration {
private int left;
private int right;
public AbSpacesItemDecoration(int left, int right) {
this.left = left;
this.right = right;
}
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
int position = parent.getChildAdapterPosition(view);
StaggeredGridLayoutManager.LayoutParams lp = (StaggeredGridLayoutManager.LayoutParams) view.getLayoutParams();
if (lp.getSpanIndex() % 2 == 0) {
outRect.left = left;
outRect.right = right;
} else {
outRect.left = right;
outRect.right = left;
}
outRect.top = left;
}
}
}
......@@ -2,47 +2,53 @@ package com.rv.rvmine.traveler;
import android.content.Context;
import android.content.Intent;
import android.graphics.Rect;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.view.View;
import com.alibaba.android.arouter.launcher.ARouter;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.frame.base.url.Constance;
import com.frame.rv.config.RvFrameConfig;
import com.ruiwenliu.wrapper.adapter.TabAdapter;
import com.ruiwenliu.wrapper.base.BaseBean;
import com.ruiwenliu.wrapper.base.BaseFragment;
import com.ruiwenliu.wrapper.base.BaseStatusActivity;
import com.ruiwenliu.wrapper.weight.TitleView;
import com.ruiwenliu.wrapper.weight.refresh.SimpleRefreshLayout;
import com.ruiwenliu.wrapper.weight.refresh.SimpleRefreshView;
import com.rv.home.rv.module.ApiConfig;
import com.ruiwenliu.wrapper.base.presenter.CommonPresenter;
import com.rv.home.rv.module.ui.main.home.bean.HomeRecommendBean;
import com.ruiwenliu.wrapper.weight.TitleView;
import com.ruiwenliu.wrapper.weight.horizontal.GallerySnapHelper;
import com.ruiwenliu.wrapper.weight.horizontal.SpaceItemDecoration;
import com.rv.rvmine.R;
import com.rv.rvmine.R2;
import com.rv.rvmine.adapter.MyReleasePatAdapter;
import com.yuyife.okgo.OkGoUtil;
import com.rv.rvmine.fragment.MyReleaseAskFragment;
import com.rv.rvmine.fragment.MyReleasePatFragment;
import com.rv.rvmine.fragment.MyReleaseVideoFragment;
import com.xxrv.coupon.adapter.CouponMenuAdapter;
import com.xxrv.coupon.fragment.ExpiredCouponFragment;
import com.xxrv.coupon.fragment.UsedCouponFragment;
import com.xxrv.coupon.fragment.WaitCouponFragment;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
/**
* 我的发布
*/
public class MyReleaseActivity extends BaseStatusActivity<CommonPresenter> implements SimpleRefreshLayout.OnSimpleRefreshListener {
public class MyReleaseActivity extends BaseStatusActivity<CommonPresenter> {
@BindView(R2.id.rv_content)
RecyclerView rvContent;
@BindView(R2.id.refresh)
SimpleRefreshLayout mSimpleRefreshLayout;
private int countPage;
private int mPage;
@BindView(R2.id.recyclerView)
RecyclerView recyclerView;
@BindView(R2.id.release_viewPager)
ViewPager mViewPager;
private MyReleasePatAdapter mAdapter;
private CouponMenuAdapter menuAdapter;
private TabAdapter mAdapter;
public final static int TYPE_PAT = 0;
public final static int TYPE_VIDEO = 1;
public final static int TYPE_ASK = 2;
public static Intent getIntent(Context context) {
return new Intent(context, MyReleaseActivity.class);
......@@ -56,152 +62,83 @@ public class MyReleaseActivity extends BaseStatusActivity<CommonPresenter> imple
@Override
protected void initView(Bundle savedInstanceState, TitleView titleView, Intent intent) {
titleView.setTitle("我的发布");
mSimpleRefreshLayout.setHeaderView(new SimpleRefreshView(mActivity));
mSimpleRefreshLayout.setOnSimpleRefreshListener(this);
mAdapter = new MyReleasePatAdapter();
final StaggeredGridLayoutManager staggeredGridLayoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);
rvContent.setItemAnimator(null);
rvContent.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
int[] first = new int[2];
staggeredGridLayoutManager.findFirstCompletelyVisibleItemPositions(first);
if (newState == RecyclerView.SCROLL_STATE_IDLE && (first[0] == 1 || first[1] == 1)) {
recyclerView.invalidateItemDecorations();
}
}
});
rvContent.setLayoutManager(staggeredGridLayoutManager);
rvContent.addItemDecoration(new AbSpacesItemDecoration(20, 10));// 分割线。
rvContent.setAdapter(mAdapter);
mAdapter.bindToRecyclerView(rvContent);
mAdapter.setEnableLoadMore(true);
mAdapter.disableLoadMoreIfNotFullPage();
mAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
@Override
public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
HomeRecommendBean.DataBeanX.DataBean item = (HomeRecommendBean.DataBeanX.DataBean) adapter.getItem(position);
if (item != null) {
ARouter.getInstance()
.build(Constance.ACTIVITY_URL_DETAILPAT)
.withString("id", item.getMsgId())
.withString("title",item.getBody().getText())
.withString("iconUrl",item.getBody().getImages().get(0).getOurl())
.withString("userName",item.getNickname())
.withString("userUrl",item.getPicUrl())
.navigation();
}
}
});
mAdapter.setOnLoadMoreListener(new BaseQuickAdapter.RequestLoadMoreListener() {
@Override
public void onLoadMoreRequested() {
if (rvContent != null) {
rvContent.postDelayed(new Runnable() {
@Override
public void run() {
if (mPage >= countPage) {
mAdapter.loadMoreEnd();
} else {
mPage++;
geDataList(mPage);
}
}
}, 200);
}
}
}, rvContent);
initRecyclerView();
initViewpager();
}
@Override
protected void loadData(Bundle savedInstanceState, Intent intent) {
super.loadData(savedInstanceState, intent);
onFresh();
}
@Override
public void onShowResult(int requestType, BaseBean result) {
mSimpleRefreshLayout.onRefreshComplete();
switch (requestType) {
case 0:
processData((HomeRecommendBean) result);
break;
}
}
private void processData(HomeRecommendBean bean) {
if (mPage == 1) {
countPage = bean.getData().getPageSize();
mAdapter.setNewData(bean.getData().getList());
if (bean.getData().getTotalCount() == 0) {
mAdapter.setEmptyView(getEmptyView(rvContent, -1, "暂无发布的数据"));
mAdapter.notifyDataSetChanged();
}
} else {
mAdapter.addData(bean.getData().getList());
mAdapter.loadMoreComplete();
/**
* 初始化RecyclerView
*/
private void initRecyclerView() {
recyclerView.setLayoutManager(new GridLayoutManager(mActivity, 3));
menuAdapter = new CouponMenuAdapter();
recyclerView.setAdapter(menuAdapter);
recyclerView.addItemDecoration(new SpaceItemDecoration(5));
GallerySnapHelper snapHelper = new GallerySnapHelper();
snapHelper.attachToRecyclerView(recyclerView);
List<String> list = new ArrayList<>();
list.add("我的拍拍");
list.add("我的短视频");
list.add("我的问答");
menuAdapter.setNewData(list);
menuAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
@Override
public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
menuAdapter.setSelectItem(position);
mViewPager.setCurrentItem(position);
}
});
}
/**
* 初始化Viewpager
*/
private void initViewpager() {
mAdapter = new TabAdapter(getSupportFragmentManager(), getListFragment());
mViewPager.setAdapter(mAdapter);
mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onRefresh() {
onFresh();
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
/**
* 刷新
*/
private void onFresh() {
mPage = 1;
geDataList(mPage);
@Override
public void onPageSelected(int position) {
menuAdapter.setSelectItem(position);
}
/**
* 请求数据
*
* @param page
*/
private void geDataList(int page) {
Map<String, Object> headMap = new LinkedHashMap<>();
if (OkGoUtil.getToken() != null) {
headMap.put("Authorization", OkGoUtil.getToken());
@Override
public void onPageScrollStateChanged(int state) {
}
Map<String, Object> map = new LinkedHashMap<>();
map.put("page", page);
mPresenter.getData(RvFrameConfig.HOST, 0, ApiConfig.RVENTHUSIAST_GETBYUSERID_LIST, HomeRecommendBean.class, map, headMap, page == 1 ? true : false);
});
mViewPager.setOffscreenPageLimit(mAdapter.getCount());
menuAdapter.setSelectItem(0);
mViewPager.setCurrentItem(0);
}
public class AbSpacesItemDecoration extends RecyclerView.ItemDecoration {
private int left;
private int right;
public AbSpacesItemDecoration(int left, int right) {
this.left = left;
this.right = right;
private List<BaseFragment> getListFragment() {
List<BaseFragment> list = new ArrayList<>();
list.add(MyReleasePatFragment.getInstance(TYPE_PAT));
list.add(MyReleaseVideoFragment.getInstance(TYPE_VIDEO));
list.add(MyReleaseAskFragment.getInstance(TYPE_ASK));
return list;
}
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
int position = parent.getChildAdapterPosition(view);
StaggeredGridLayoutManager.LayoutParams lp = (StaggeredGridLayoutManager.LayoutParams) view.getLayoutParams();
if (lp.getSpanIndex() % 2 == 0) {
outRect.left = left;
outRect.right = right;
} else {
outRect.left = right;
outRect.right = left;
}
outRect.top = left;
}
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
mAdapter.getCurrentFragment().onActivityResult(requestCode, resultCode, data);
}
}
......@@ -367,7 +367,7 @@ public class PersonalInformationActivity extends BaseStatusActivity<PickerPresen
RequestBody.create(
MediaType.parse("multipart/form-data"), fileName);
// // 创建 RequestBody,用于封装构建RequestBody
// // 创建 RequestBody,用于封装构建RequestBody uploadVideo
// RequestBody requestFile =
// RequestBody.create(MediaType.parse("multipart/form-data"), file);
// MultipartBody.Part body =
......
......@@ -3,24 +3,19 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/gray_f5f5f5"
android:orientation="vertical">
<com.ruiwenliu.wrapper.weight.refresh.SimpleRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/refresh"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/rv_content"
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:background="@color/colorWrite" />
</android.support.v7.widget.RecyclerView>
<include layout="@layout/common_line" />
</com.ruiwenliu.wrapper.weight.refresh.SimpleRefreshLayout>
<android.support.v4.view.ViewPager
android:id="@+id/release_viewPager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/gray_f5f5f5"
android:orientation="vertical">
<com.ruiwenliu.wrapper.weight.refresh.SimpleRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/refresh"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/rv_content"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</android.support.v7.widget.RecyclerView>
</com.ruiwenliu.wrapper.weight.refresh.SimpleRefreshLayout>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ll_item_rv_enthusiast"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/iv_icon_pat"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<ImageView
android:id="@+id/iv_isvideo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="@drawable/icon_fragment_video_hint"/>
</RelativeLayout>
<TextView
android:id="@+id/tv_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/size_5"
android:paddingLeft="@dimen/size_5"
android:paddingRight="@dimen/size_5"
android:maxLines="2"
android:ellipsize="end"
android:text="行摄川西邂逅生命中未知的精彩"
android:textColor="@color/colorMain"
android:textSize="@dimen/text_14" />
<TextView
android:id="@+id/tv_address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/size_5"
android:layout_marginBottom="@dimen/size_10"
android:paddingLeft="@dimen/size_5"
android:textColor="@color/colorMain"
android:textSize="@dimen/text_12" />
</LinearLayout>
</LinearLayout>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment