Commit 081191f9 authored by linfeng's avatar linfeng

Merge branch 'master-video' of http://113.105.137.151:22280/lify/rvapp into master-invoice

parents 68d59747 4b6d048c
......@@ -6,4 +6,6 @@ public final class ImageUrl {
public static final String IMG_BG_BILL = "https://mgmt.dfangche.com/image/app/bg_bill.png";
public static final String IMG_BG_BANNER_SIGN = "https://mgmt.dfangche.com/image/app/banner_sign.png";
public static final String IMG_BG_LOGO = "https://mgmt.dfangche.com/image/admin/2019-11-27/66.png";
}
......@@ -70,7 +70,7 @@ public class ShareManager extends ShareAction {
super(activity);
mActivity = activity;
this.setDisplayList(
SHARE_MEDIA.WEIXIN, SHARE_MEDIA.WEIXIN_CIRCLE, SHARE_MEDIA.QQ)
SHARE_MEDIA.WEIXIN)
.addButton("复制链接", copy, "rv_share_copy", "rv_share_copy")
.addButton("下载视频", download, "rv_share_download_video", "rv_share_download_video")
.setShareboardclickCallback(boardListener);
......
......@@ -39,6 +39,17 @@
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsTranslucent">true</item>
</style>
<style name="Alert_Dialog_Style2" parent="@android:style/Theme.Dialog">
<item name="android:windowBackground">@color/colorMain</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowFrame">@null</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsTranslucent">true</item>
</style>
<!--Dialog样式-->
<style name="AlertTipsDialogTheme" parent="android:Theme.Dialog">
<item name="android:windowIsFloating">true</item>
......
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 android.widget.TextView;
import com.ruiwenliu.wrapper.dialog.BaseDialog;
import com.ruiwenliu.wrapper.util.ViewHolder;
/**
* 温馨提示
*/
public class DownloadLoadingDialog extends BaseDialog {
TextView tv;
ProgressBar pb;
public DownloadLoadingDialog(@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);
tv = (TextView) helper.getView(R.id.rv_hint);
pb = (ProgressBar) helper.getView(R.id.pb_load);
}
@Override
public int getViewLayout() {
return R.layout.dialog_download_loading;
}
public void setContent(int percentage) {
if (tv != null) {
tv.setText("下载中..." + percentage + "%");
if (percentage ==100){
pb.setVisibility(View.GONE);
tv.setText("已保存到相册,快去分享吧!");
}
}
}
}
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="@dimen/size_60"
android:layout_centerInParent="true"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="@dimen/size_60"
android:background="@color/colorMain"
android:gravity="center"
android:orientation="horizontal"
android:paddingLeft="@dimen/size_15"
android:paddingRight="@dimen/size_15">
<ProgressBar
android:id="@+id/pb_load"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_centerInParent="true"
android:layout_gravity="center"
android:indeterminate="true"
android:indeterminateDrawable="@drawable/bg_progressbar_loading" />
<!--</RelativeLayout>-->
<TextView
android:id="@+id/rv_hint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/size_10"
android:text="下载中..."
android:textColor="@color/colorWrite"
android:textSize="@dimen/text_14" />
</LinearLayout>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/common_icon_bg_positive_check" android:state_checked="true" />
<item android:drawable="@drawable/common_icon_bg_positive_uncheck" android:state_checked="false" />
</selector>
\ No newline at end of file
......@@ -24,20 +24,21 @@ import com.baidu.mapapi.map.MyLocationData;
import com.baidu.mapapi.map.OverlayOptions;
import com.baidu.mapapi.model.LatLng;
import com.frame.base.url.Constance;
import com.frame.base.url.ImageUrl;
import com.frame.rv.config.RvFrameConfig;
import com.ruiwenliu.wrapper.base.BaseBean;
import com.ruiwenliu.wrapper.base.BaseStatusActivity;
import com.ruiwenliu.wrapper.base.presenter.CommonPresenter;
import com.ruiwenliu.wrapper.util.LocationManager;
import com.ruiwenliu.wrapper.util.MapUtil;
import com.ruiwenliu.wrapper.util.ViewHolder;
import com.ruiwenliu.wrapper.util.glide.GlideManager;
import com.ruiwenliu.wrapper.weight.TitleView;
import com.rv.component.dialog.PickerDialog;
import com.rv.component.utils.LocationRecord;
import com.rv.home.R;
import com.rv.home.R2;
import com.ruiwenliu.wrapper.util.ViewHolder;
import com.ruiwenliu.wrapper.weight.TitleView;
import com.rv.home.rv.module.ApiConfig;
import com.rv.component.dialog.PickerDialog;
import com.ruiwenliu.wrapper.base.presenter.CommonPresenter;
import com.rv.home.rv.module.ui.main.home.bean.ShopListBean;
import java.util.ArrayList;
......@@ -46,6 +47,7 @@ import java.util.List;
import java.util.Map;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import io.reactivex.Observable;
import io.reactivex.observers.DisposableObserver;
......@@ -67,6 +69,8 @@ public class ShopShowActivity extends BaseStatusActivity<CommonPresenter> {
LinearLayout rlVisible;
@BindView(R2.id.tv_phone)
TextView tvPhone;
@BindView(R2.id.iv_icon)
ImageView ivIcon;
private LocationManager locationManager;
BaiduMap mBaiduMap;
......@@ -95,6 +99,8 @@ public class ShopShowActivity extends BaseStatusActivity<CommonPresenter> {
showTitle(false);
mLat = intent.getDoubleExtra("lat", 0);
mLon = intent.getDoubleExtra("lon", 0);
GlideManager.getInstance(mActivity).loadImage(ImageUrl.IMG_BG_LOGO, ivIcon);
initMap();
}
......@@ -173,7 +179,7 @@ public class ShopShowActivity extends BaseStatusActivity<CommonPresenter> {
private void getShopList(int page) {
Map<String, Object> map = new LinkedHashMap<>();
map.put("page", page);
map.put("limit", 1000);
map.put("limit", 1500);
if (mLat > 0) {
map.put("lat", mLat);
map.put("lon", mLon);
......@@ -389,6 +395,12 @@ public class ShopShowActivity extends BaseStatusActivity<CommonPresenter> {
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// TODO: add setContentView(...) invocation
ButterKnife.bind(this);
}
}
......@@ -7,6 +7,8 @@ import android.support.v7.widget.RecyclerView;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.TextView;
import com.ruiwenliu.wrapper.dialog.BaseDialog;
......@@ -31,12 +33,14 @@ public class CheckPriceDialog extends BaseDialog {
setDialogParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.BOTTOM);
}
@Override
public void helper(ViewHolder helper) {
super.helper(helper);
final TextView tvCash = (TextView) helper.getView(R.id.tv_item_use_cash);
final TextView tvMember = (TextView) helper.getView(R.id.tv_item_use_member);
final RecyclerView rvContent = (RecyclerView) helper.getView(R.id.rv_content);
CheckBox isUseMember = (CheckBox) helper.getView(R.id.cb_use_member);
tvCash.setSelected(true);
tvCash.setTextColor(getContext().getResources().getColor(R.color.colorWrite));
......@@ -44,6 +48,20 @@ public class CheckPriceDialog extends BaseDialog {
rvContent.setLayoutManager(new GridLayoutManager(getContext(), 7));
rvContent.setNestedScrollingEnabled(false);
rvContent.setAdapter(adapter);
isUseMember.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
adapter.setType(true);
adapter.notifyDataSetChanged();
} else {
adapter.setType(false);
adapter.notifyDataSetChanged();
}
}
});
helper.setOnClickListener(new View.OnClickListener() {
@Override
......@@ -54,15 +72,13 @@ public class CheckPriceDialog extends BaseDialog {
tvCash.setTextColor(getContext().getResources().getColor(R.color.colorWrite));
tvMember.setSelected(false);
tvMember.setTextColor(getContext().getResources().getColor(R.color.gray_FFB74B));
adapter.setType(false);
adapter.notifyDataSetChanged();
} else if (id == R.id.tv_item_use_member) {
tvCash.setSelected(false);
tvCash.setTextColor(getContext().getResources().getColor(R.color.gray_FFB74B));
tvMember.setSelected(true);
tvMember.setTextColor(getContext().getResources().getColor(R.color.colorWrite));
adapter.setType(true);
adapter.notifyDataSetChanged();
}
}
}, R.id.tv_item_use_cash, R.id.tv_item_use_member);
......
......@@ -4,11 +4,13 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".rv.module.ui.main.home.ShopShowActivity">
<com.baidu.mapapi.map.MapView
android:id="@+id/bmapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true" />
<ImageView
android:id="@+id/iv_back"
android:layout_width="@dimen/size_40"
......@@ -21,9 +23,9 @@
<ImageView
android:id="@+id/iv_location"
android:layout_alignParentRight="true"
android:layout_width="@dimen/size_50"
android:layout_height="@dimen/size_50"
android:layout_alignParentRight="true"
android:layout_marginLeft="@dimen/size_5"
android:layout_marginTop="@dimen/size_10"
android:layout_marginRight="@dimen/size_15"
......@@ -31,82 +33,94 @@
android:src="@drawable/rv_location" />
<!--<ImageView-->
<!--android:layout_width="wrap_content"-->
<!--android:id="@+id/iv_center"-->
<!--android:visibility="gone"-->
<!--android:layout_centerInParent="true"-->
<!--android:layout_height="wrap_content"-->
<!--android:src="@drawable/im_map_button_pres"-->
<!--/>-->
<!--android:layout_width="wrap_content"-->
<!--android:id="@+id/iv_center"-->
<!--android:visibility="gone"-->
<!--android:layout_centerInParent="true"-->
<!--android:layout_height="wrap_content"-->
<!--android:src="@drawable/im_map_button_pres"-->
<!--/>-->
<LinearLayout
android:id="@+id/ll_visible"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginLeft="@dimen/size_30"
android:layout_marginRight="@dimen/size_30"
android:layout_alignParentBottom="true"
android:layout_marginBottom="@dimen/size_30"
android:layout_width="match_parent"
android:padding="@dimen/size_15"
android:visibility="gone"
android:id="@+id/ll_visible"
android:background="@color/colorWrite"
android:orientation="horizontal"
android:layout_height="wrap_content">
<RelativeLayout
android:padding="@dimen/size_15"
android:visibility="gone">
android:layout_weight="1"
android:paddingRight="@dimen/size_10"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/textMain"
android:textSize="@dimen/text_18"
android:drawablePadding="@dimen/size_5"
android:drawableLeft="@drawable/rv_common_icon_logo"
android:id="@+id/tv_name"
android:text=""
/>
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:paddingRight="@dimen/size_10">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/iv_icon"
android:layout_width="@dimen/size_25"
android:layout_height="@dimen/size_25" />
<TextView
android:id="@+id/tv_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/size_5"
android:layout_toRightOf="@+id/iv_icon"
android:text=""
android:textColor="@color/textMain"
android:textSize="@dimen/text_18" />
</LinearLayout>
<TextView
android:layout_marginTop="@dimen/size_8"
android:id="@+id/tv_address"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/textGray"
android:textSize="@dimen/text_14"
android:layout_below="@id/tv_name"
android:id="@+id/tv_address"
android:layout_marginTop="@dimen/size_8"
android:text=""
/>
android:textColor="@color/textGray"
android:textSize="@dimen/text_14" />
<TextView
android:id="@+id/tv_phone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/textGray"
android:textSize="@dimen/text_14"
android:layout_below="@id/tv_address"
android:id="@+id/tv_phone"
android:text=""
/>
</RelativeLayout>
android:textColor="@color/textGray"
android:textSize="@dimen/text_14" />
</LinearLayout>
<RelativeLayout
android:id="@+id/rl_navigation"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:layout_centerHorizontal="true"
android:src="@drawable/rv_rentingcar_icon_gps"
android:layout_width="@dimen/size_30"
android:layout_height="@dimen/size_30"
/>
<TextView
android:textColor="@color/textMain"
android:textSize="@dimen/text_12"
android:layout_centerHorizontal="true"
android:text="去这里"
android:src="@drawable/rv_rentingcar_icon_gps" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="@dimen/size_35"
/>
android:text="去这里"
android:textColor="@color/textMain"
android:textSize="@dimen/text_12" />
</RelativeLayout>
</LinearLayout>
......
......@@ -4,9 +4,9 @@
android:layout_height="wrap_content"
android:background="@color/colorWrite"
android:orientation="vertical"
android:paddingBottom="@dimen/size_10"
android:paddingLeft="@dimen/size_15"
android:paddingRight="@dimen/size_15">
android:paddingRight="@dimen/size_15"
android:paddingBottom="@dimen/size_10">
<LinearLayout
android:layout_width="match_parent"
......@@ -20,14 +20,25 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="价格明细表"
android:text="每日价格"
android:textColor="@color/colorMain"
android:textSize="@dimen/text_16" />
<CheckBox
android:id="@+id/cb_use_member"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:button="@drawable/selector_rv_positive_check"
android:paddingLeft="@dimen/size_10"
android:text="会员天数抵扣"
android:textColor="@color/colorMain"
android:textSize="@dimen/text_14" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
android:orientation="horizontal"
android:visibility="gone">
<TextView
android:id="@+id/tv_item_use_cash"
......@@ -131,7 +142,6 @@
<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>
android:layout_height="wrap_content"></android.support.v7.widget.RecyclerView>
</LinearLayout>
\ No newline at end of file
......@@ -60,6 +60,7 @@ dependencies {
api project(':RvWrapper')
api project(':component_resource')
api project(':component_utils')
api project(':component_dialog')
api project(':plugin_opengl')
api project(':plugin_imcamera')
api project(':jcvideoplayer-lib')
......
package com.xxrv.video.activity;
import android.app.ProgressDialog;
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.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.provider.MediaStore;
import android.support.annotation.NonNull;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.PagerSnapHelper;
......@@ -14,19 +21,20 @@ import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.LinearLayout;
import com.alibaba.fastjson.JSON;
import com.danikula.videocache.HttpProxyCacheServer;
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.http.ProgressRequestBody;
import com.ruiwenliu.wrapper.statusbar.StatusBarUtil;
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.Cookie;
import com.rv.component.dialog.DownloadLoadingDialog;
import com.rv.component.utils.IsAppInstall;
import com.umeng.socialize.UMShareAPI;
import com.umeng.socialize.bean.SHARE_MEDIA;
......@@ -34,7 +42,6 @@ import com.umeng.socialize.shareboard.SnsPlatform;
import com.umeng.socialize.utils.ShareBoardlistener;
import com.xxrv.video.R;
import com.xxrv.video.R2;
import com.xxrv.video.adapter.ListVideoAdapter;
import com.xxrv.video.api.VideoApi;
import com.xxrv.video.base.BaseRecAdapter;
import com.xxrv.video.base.BaseRecViewHolder;
......@@ -43,9 +50,16 @@ import com.xxrv.video.bean.circle.DiscoveryDataBean;
import com.xxrv.video.bean.circle.DiscoveryVideoBean;
import com.xxrv.video.bean.circle.VideoIMTokenBean;
import com.xxrv.video.presenter.VideoPresenter;
import com.xxrv.video.util.DownloadVideo;
import com.xxrv.video.weight.JcvTrillVideo;
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.LinkedHashMap;
import java.util.List;
import java.util.Map;
......@@ -247,32 +261,20 @@ public class TriListActivity extends BaseStatusActivity<VideoPresenter> {
shareManager = new ShareManager(this, new ShareBoardlistener() {
@Override
public void onclick(SnsPlatform snsPlatform, SHARE_MEDIA share_media) {
// if (snsPlatform.mShowWord.equals("生成海报")) {
// ARouter.getInstance()
// .build(Constance.ACTIVITY_URL_PATGENERATEPOSTER)
// .withString("iconUrl", iconUrl)
// .withString("content", title)
// .withString("url", webUrl + "&shareType=app&code=" + code)
// .withString("userName", userName)
// .withString("userUrl", userUrl)
// .navigation();
// } else
if (snsPlatform.mShowWord.equals("复制链接")) {
if (snsPlatform.mShowWord.equals("下载视频")) {
DownloadVideo.getInstance().downMp4(sVideoUrl, mActivity);
} else if (snsPlatform.mShowWord.equals("复制链接")) {
ClipboardManager myClipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
ClipData myClip = ClipData.newPlainText("text", sVideoUrl);
myClipboard.setPrimaryClip(myClip);
showToast("复制成功!");
showToast("链接已复制快去分享吧!");
} 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, sVideoUrl, title, " ", imageUrl
......@@ -282,32 +284,25 @@ public class TriListActivity extends BaseStatusActivity<VideoPresenter> {
public void onResult(SHARE_MEDIA platform) {
super.onResult(platform);
if (platform.name().equals("WEIXIN_FAVORITE")) {
showToast(" 收藏成功啦");
} else {
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("分享成功啦");
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("分享成功啦");
// sharingSuccess();
}
}
}
});
}
}, "rv_um_share_copy");
}, "rv_um_share_copy", "rv_share_download_video", "1");
if (shareManager != null) {
......@@ -388,4 +383,6 @@ public class TriListActivity extends BaseStatusActivity<VideoPresenter> {
mPresenter.getData(3, VideoApi.DISCOVERY_PLAYAMOUNT_ADD, VideoIMTokenBean.class, map, false);
}
}
}
package com.xxrv.video.util;
import android.app.Activity;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Environment;
import android.os.Handler;
import android.os.Looper;
import android.provider.MediaStore;
import com.rv.component.dialog.DownloadLoadingDialog;
import com.xxrv.video.activity.TriListActivity;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
/******
* 下载视频
*/
public class DownloadVideo {
private static DownloadVideo instance = null;
private DownloadVideo() {
}
public static <T> DownloadVideo getInstance() {
if (instance == null) {
synchronized (DownloadVideo.class) {
if (instance == null) {
instance = new DownloadVideo();
}
}
}
return instance;
}
public void downMp4(String url, Activity mActivity) {
final DownloadLoadingDialog pd; // 进度条对话框
pd = new DownloadLoadingDialog(mActivity);
//设置点击屏幕不消失
pd.setCanceledOnTouchOutside(false);
//设置点击返回键不消失
pd.setCancelable(false);
pd.show();
new Thread() {
@Override
public void run() {
try {
File file = getFileFromServer(url, pd);
ContentResolver localContentResolver = mActivity.getContentResolver();
ContentValues localContentValues = getVideoContentValues(mActivity, file, System.currentTimeMillis());
Uri localUri = localContentResolver.insert(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, localContentValues);
mActivity.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, localUri));
sleep(1000);
pd.dismiss(); // 结束掉进度条对话框
} catch (Exception e) {
e.printStackTrace();
}
}
}.start();
}
/**
* 视频存在本地
*
* @param paramContext
* @param paramFile
* @param paramLong
* @return
*/
public static ContentValues getVideoContentValues(Context paramContext, File paramFile, long paramLong) {
ContentValues localContentValues = new ContentValues();
localContentValues.put("title", paramFile.getName());
localContentValues.put("_display_name", paramFile.getName());
localContentValues.put("mime_type", "video/3gp");
localContentValues.put("datetaken", Long.valueOf(paramLong));
localContentValues.put("date_modified", Long.valueOf(paramLong));
localContentValues.put("date_added", Long.valueOf(paramLong));
localContentValues.put("_data", paramFile.getAbsolutePath());
localContentValues.put("_size", Long.valueOf(paramFile.length()));
return localContentValues;
}
public File getFileFromServer(String path, DownloadLoadingDialog pd) throws Exception {
// 如果相等的话表示当前的sdcard挂载在手机上并且是可用的
if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
URL url = new URL(path);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setConnectTimeout(5000);
// 获取到文件的大小
// pd.setMax(conn.getContentLength());
InputStream is = conn.getInputStream();
File sd1 = Environment.getExternalStorageDirectory();
String path1 = sd1.getPath() + "/lfmf";
File myfile1 = new File(path1);
if (!myfile1.exists()) {
myfile1.mkdir();
}
File file = new File(myfile1, System.currentTimeMillis() + ".mp4");
FileOutputStream fos = new FileOutputStream(file);
BufferedInputStream bis = new BufferedInputStream(is);
byte[] buffer = new byte[1024];
int len;
int total = 0;
Handler handler = new Handler(Looper.getMainLooper());
while ((len = bis.read(buffer)) != -1) {
fos.write(buffer, 0, len);
total += len;
handler.post(new ProgressUpdater(total, pd, conn.getContentLength()));
// 获取当前下载量
}
fos.close();
bis.close();
is.close();
return file;
} else {
return null;
}
}
private class ProgressUpdater implements Runnable {
private int total;
private DownloadLoadingDialog pd;
private int contentLength;
public ProgressUpdater(int total, DownloadLoadingDialog pd, int contentLength) {
this.total = total;
this.pd = pd;
this.contentLength = contentLength;
}
@Override
public void run() {
int i = (int) (100 * total / contentLength);
pd.setContent(i);
}
}
}
......@@ -286,7 +286,7 @@ public class JcvTrillVideo extends FrameLayout implements BaseView, View.OnClick
mLikeCount = bean.getPraiseCount();
tvCommCount.setText(formatCount(mCommCount));
tvlikesCount.setText(formatCount(mLikeCount));
tvShare.setText(formatCount(bean.getCount().getForward()));
// tvShare.setText(formatCount(bean.getCount().getForward()));
tvPlay.setText(formatCount(bean.getCount().getPlay()));
mCommDialog = TrillCommDialog.getInstance();// 创建评论窗口
......
......@@ -159,7 +159,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="7.7w"
android:text="分享"
android:textColor="#FFFFFF"
android:textSize="@dimen/text_12" />
......
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