33
This commit is contained in:
+1685
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,718 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.GridView;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.gyf.immersionbar.ImmersionBar;
|
||||
import com.lidroid.xutils.exception.HttpException;
|
||||
import com.lidroid.xutils.http.RequestParams;
|
||||
import com.lidroid.xutils.http.ResponseInfo;
|
||||
import com.lidroid.xutils.http.callback.RequestCallBack;
|
||||
import com.lidroid.xutils.http.client.HttpRequest;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import cn.shangyu.gdxzExpert.R;
|
||||
import cn.shangyu.gdxzExpert.base.BaseActivity;
|
||||
import cn.shangyu.gdxzExpert.bean.ListSeriesTypeBean;
|
||||
import cn.shangyu.gdxzExpert.bean.TagList;
|
||||
import cn.shangyu.gdxzExpert.http.HttpHelper;
|
||||
import cn.shangyu.gdxzExpert.http.OnCallBackFromNet;
|
||||
import cn.shangyu.gdxzExpert.polyvplayer.adapter.ExchangeAdapter;
|
||||
import cn.shangyu.gdxzExpert.polyvplayer.adapter.MyListSeriesAdapter;
|
||||
import cn.shangyu.gdxzExpert.pulltorefreshview.PullToRefreshBase;
|
||||
import cn.shangyu.gdxzExpert.pulltorefreshview.PullToRefreshListView;
|
||||
import cn.shangyu.gdxzExpert.ui.CustomProgressDialog;
|
||||
import cn.shangyu.gdxzExpert.utils.CommonUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.DialogUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.GsonTools;
|
||||
import cn.shangyu.gdxzExpert.utils.LogUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.SharePrefUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.StringUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.ToastUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.UIUtils;
|
||||
import cn.shangyu.gdxzExpert.utils.Url;
|
||||
import cn.shangyu.gdxzExpert.view.DrawableCenterButtonR;
|
||||
import cn.shangyu.gdxzExpert.widget.LoadingPage;
|
||||
|
||||
/**
|
||||
* Created by WANGChengXin on 2019/3/25.
|
||||
*/
|
||||
|
||||
public class ExchangeAreaActivity extends BaseActivity implements OnCallBackFromNet{
|
||||
|
||||
public static final int EXCHANGE=1;
|
||||
private PullToRefreshListView lv_exchange;
|
||||
private PullToRefreshListView lv_exchange_my;//以兑换的list
|
||||
private ListSeriesTypeBean listFreeBean;
|
||||
private DrawableCenterButtonR dcb_sort;
|
||||
private LinearLayout ll_sort,ll_new,ll_hot,ll_time;
|
||||
private RelativeLayout rl_pop_screen;
|
||||
private DrawableCenterButtonR bt_screen,cb_yiduihuan;
|
||||
private boolean ischange;
|
||||
private TextView tv_new,tv_hot,tv_time;
|
||||
private ImageView iv_new,iv_hot,iv_time;
|
||||
private String sort;
|
||||
private final static int MYLIST = 2;
|
||||
private ListSeriesTypeBean listSeriesTypeBean;
|
||||
private View ll_empty;
|
||||
private TextView tv_empty_msg;
|
||||
private TagList mTagList;
|
||||
private ScreenAdapter mAdapter2;
|
||||
private GridView mGv_screen;
|
||||
private List<String> TagPosition = null;
|
||||
private Button mBt_sure, mBt_reset;
|
||||
private ArrayList<String> Tags;
|
||||
private int freePage = 1;
|
||||
private int mySerPage = 1;
|
||||
private String keywords ="";
|
||||
private ExchangeAdapter adapter;
|
||||
private List<ListSeriesTypeBean.DataBean.ListBean> data = new ArrayList<>();
|
||||
private MyListSeriesAdapter exchangeAdapter;
|
||||
private List<ListSeriesTypeBean.DataBean.ListBean> data1 = new ArrayList<>();
|
||||
private View line3;
|
||||
|
||||
@Override
|
||||
public void setTitle() {
|
||||
top_title.setText("兑换专区");
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateSuccessedView() {
|
||||
ImmersionBar.with(this).keyboardEnable(true).statusBarDarkFont(true).titleBar(mToolbar).init();
|
||||
View view = UIUtils.inflate(R.layout.activity_exchangearea);
|
||||
initView(view);
|
||||
initOnClick();
|
||||
sort = "2";
|
||||
getData();
|
||||
return view;
|
||||
}
|
||||
|
||||
private void initOnClick() {
|
||||
dcb_sort.setOnClickListener(this);
|
||||
bt_screen.setOnClickListener(this);
|
||||
cb_yiduihuan.setOnClickListener(this);
|
||||
ll_new.setOnClickListener(this);
|
||||
ll_hot.setOnClickListener(this);
|
||||
ll_time.setOnClickListener(this);
|
||||
mBt_sure.setOnClickListener(this);
|
||||
lv_exchange.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
if (ll_sort.getVisibility()==View.VISIBLE){
|
||||
ll_sort.setVisibility(View.GONE);
|
||||
return;
|
||||
}
|
||||
if (rl_pop_screen.getVisibility()==View.VISIBLE){
|
||||
return;
|
||||
}
|
||||
position --;
|
||||
Intent intent = PolyvPlayerActivity.newIntent(ExchangeAreaActivity.this, PolyvPlayerActivity.PlayMode.portrait, "");
|
||||
intent.putExtra("isVlmsOnline", false);
|
||||
intent.putExtra("series_type_uuid", data.get(position).getUuid());
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
lv_exchange_my.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
if (ll_sort.getVisibility()==View.VISIBLE){
|
||||
ll_sort.setVisibility(View.GONE);
|
||||
return;
|
||||
}
|
||||
if (rl_pop_screen.getVisibility()==View.VISIBLE){
|
||||
return;
|
||||
}
|
||||
position --;
|
||||
Intent intent = PolyvPlayerActivity.newIntent(ExchangeAreaActivity.this, PolyvPlayerActivity.PlayMode.portrait, "");
|
||||
intent.putExtra("isVlmsOnline", false);
|
||||
intent.putExtra("series_type_uuid",data1.get(position).getUuid());
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
mGv_screen.setOnItemClickListener( new AdapterView.OnItemClickListener() {
|
||||
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view,
|
||||
int position, long id) {
|
||||
// TODO Auto-generated method stub
|
||||
if (TagPosition == null) {
|
||||
TagPosition = new ArrayList<String>();
|
||||
}
|
||||
if (TagPosition.contains(position + "")) {
|
||||
TagPosition.remove(position + "");
|
||||
} else {
|
||||
if (TagPosition.size() < 3) {
|
||||
TagPosition.add(position + "");
|
||||
} else {
|
||||
ToastUtil.showMessage("最多选择三个标签");
|
||||
}
|
||||
}
|
||||
mAdapter2.notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
mBt_reset.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// TODO Auto-generated method stub
|
||||
if (TagPosition == null) {
|
||||
return;
|
||||
} else {
|
||||
TagPosition.clear();
|
||||
mAdapter2.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
});
|
||||
lv_exchange.setMode(PullToRefreshBase.Mode.BOTH);
|
||||
lv_exchange_my.setMode(PullToRefreshBase.Mode.BOTH);
|
||||
lv_exchange.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener2() {
|
||||
|
||||
@Override
|
||||
public void onPullDownToRefresh(PullToRefreshBase refreshView) {
|
||||
|
||||
freePage = 1;
|
||||
getData();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPullUpToRefresh(PullToRefreshBase refreshView) {
|
||||
|
||||
freePage++;
|
||||
getData();
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
lv_exchange_my.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener2() {
|
||||
|
||||
@Override
|
||||
public void onPullDownToRefresh(PullToRefreshBase refreshView) {
|
||||
|
||||
|
||||
mySerPage = 1;
|
||||
getMySeriesType();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPullUpToRefresh(PullToRefreshBase refreshView) {
|
||||
|
||||
mySerPage++;
|
||||
getMySeriesType();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void initView(View view) {
|
||||
lv_exchange = view.findViewById(R.id.lv_exchange);
|
||||
lv_exchange_my = view.findViewById(R.id.lv_exchange_my);
|
||||
dcb_sort = view.findViewById(R.id.dcb_sort);
|
||||
ll_sort = view.findViewById(R.id.ll_sort);
|
||||
rl_pop_screen = view.findViewById(R.id.rl_pop_screen);
|
||||
bt_screen = view.findViewById(R.id.bt_screen);
|
||||
cb_yiduihuan = view.findViewById(R.id.cb_yiduihuan);
|
||||
ll_new = view.findViewById(R.id.ll_new);
|
||||
ll_hot = view.findViewById(R.id.ll_hot);
|
||||
ll_time = view.findViewById(R.id.ll_time);
|
||||
tv_new = view.findViewById(R.id.tv_new);
|
||||
tv_hot = view.findViewById(R.id.tv_hot);
|
||||
tv_time = view.findViewById(R.id.tv_time);
|
||||
iv_new = view.findViewById(R.id.iv_new);
|
||||
iv_hot = view.findViewById(R.id.iv_hot);
|
||||
iv_time = view.findViewById(R.id.iv_time);
|
||||
ll_empty = view.findViewById(R.id.ll_empty);
|
||||
tv_empty_msg = view.findViewById(R.id.tv_empty_msg);
|
||||
mGv_screen = (GridView) view.findViewById(R.id.gv_teach);
|
||||
mBt_sure = (Button) view.findViewById(R.id.bt_sure);
|
||||
mBt_reset = (Button) view.findViewById(R.id.bt_reset);
|
||||
line3 = view.findViewById(R.id.line3);
|
||||
dialog = (CustomProgressDialog) DialogUtil.createProgressDialog(this,
|
||||
"加载中");
|
||||
dialog.show();
|
||||
ll_time.setVisibility(View.GONE);
|
||||
line3.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
private void getData() {
|
||||
lv_exchange_my.setVisibility(View.GONE);
|
||||
Map<String,String> map = new HashMap<>();
|
||||
map.put("page",freePage+"");
|
||||
map.put("title","");
|
||||
map.put("keywords",keywords);
|
||||
map.put("sort",sort);
|
||||
sendJsonPostParamtoNetSignMD5(Url.listSeriesType,map,EXCHANGE,this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoadingPage.ResultState onLoad() {
|
||||
return LoadingPage.ResultState.STATE_SUCCESSED;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void processClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.dcb_sort://最新
|
||||
if (ischange){
|
||||
cb_yiduihuan.setTextColor(getResources().getColor(
|
||||
R.color.tab_text_nor));
|
||||
ischange = false;
|
||||
}
|
||||
if (ll_sort.getVisibility() == View.VISIBLE) {
|
||||
ll_sort.setVisibility(View.GONE);
|
||||
return;
|
||||
}
|
||||
if (rl_pop_screen.getVisibility() == View.VISIBLE) {
|
||||
rl_pop_screen.setVisibility(View.GONE);
|
||||
return;
|
||||
}
|
||||
if (ll_sort.getVisibility()== View.GONE){
|
||||
ll_sort.setVisibility(View.VISIBLE);
|
||||
}else {
|
||||
ll_sort.setVisibility(View.GONE);
|
||||
}
|
||||
break;
|
||||
case R.id.bt_screen://筛选
|
||||
if (ischange){
|
||||
cb_yiduihuan.setTextColor(getResources().getColor(
|
||||
R.color.tab_text_nor));
|
||||
ischange = false;
|
||||
}
|
||||
if (rl_pop_screen.getVisibility() == View.VISIBLE) {
|
||||
rl_pop_screen.setVisibility(View.GONE);
|
||||
return;
|
||||
}
|
||||
if (ll_sort.getVisibility() == View.VISIBLE) {
|
||||
ll_sort.setVisibility(View.GONE);
|
||||
return;
|
||||
}
|
||||
if (mTagList == null) {
|
||||
getTagList();
|
||||
}
|
||||
if (rl_pop_screen.getVisibility() == View.GONE) {
|
||||
rl_pop_screen.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
rl_pop_screen.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
break;
|
||||
case R.id.cb_yiduihuan://已兑换
|
||||
|
||||
if (rl_pop_screen.getVisibility() == View.VISIBLE) {
|
||||
rl_pop_screen.setVisibility(View.GONE);
|
||||
// return;
|
||||
}
|
||||
if (ll_sort.getVisibility() == View.VISIBLE) {
|
||||
ll_sort.setVisibility(View.GONE);
|
||||
// return;
|
||||
}
|
||||
if (!ischange) {//已兑换
|
||||
cb_yiduihuan.setTextColor(getResources().getColor(
|
||||
R.color.top_title));
|
||||
ischange = true;
|
||||
lv_exchange.setVisibility(View.GONE);
|
||||
lv_exchange_my.setVisibility(View.VISIBLE);
|
||||
if (listSeriesTypeBean == null){
|
||||
dialog.show();
|
||||
mySerPage = 1;
|
||||
getMySeriesType();
|
||||
}else if (listSeriesTypeBean.getData().getList().size()==0){
|
||||
ll_empty.setVisibility(View.VISIBLE);
|
||||
}
|
||||
} else {
|
||||
cb_yiduihuan.setTextColor(getResources().getColor(
|
||||
R.color.tab_text_nor));
|
||||
ischange = false;
|
||||
lv_exchange_my.setVisibility(View.GONE);
|
||||
lv_exchange.setVisibility(View.VISIBLE);
|
||||
ll_empty.setVisibility(View.GONE);
|
||||
// getData();
|
||||
}
|
||||
break;
|
||||
|
||||
case R.id.ll_new:
|
||||
tv_hot.setTextColor(getResources().getColor(
|
||||
R.color.text_color));
|
||||
tv_time.setTextColor(getResources().getColor(
|
||||
R.color.text_color));
|
||||
tv_new.setTextColor(getResources().getColor(
|
||||
R.color.top_title));
|
||||
iv_new.setVisibility(View.VISIBLE);
|
||||
iv_hot.setVisibility(View.GONE);
|
||||
iv_time.setVisibility(View.GONE);
|
||||
dcb_sort.setText(getResources().getString(R.string.zuixin));
|
||||
chengeImg(dcb_sort);
|
||||
ll_sort.setVisibility(View.GONE);
|
||||
sort = "2";
|
||||
freePage = 1;
|
||||
lv_exchange_my.setVisibility(View.GONE);
|
||||
lv_exchange.setVisibility(View.VISIBLE);
|
||||
getData();
|
||||
break;
|
||||
case R.id.ll_hot:
|
||||
|
||||
tv_new.setTextColor(getResources().getColor(
|
||||
R.color.text_color));
|
||||
tv_time.setTextColor(getResources().getColor(
|
||||
R.color.text_color));
|
||||
tv_hot.setTextColor(getResources().getColor(
|
||||
R.color.top_title));
|
||||
iv_hot.setVisibility(View.VISIBLE);
|
||||
iv_new.setVisibility(View.GONE);
|
||||
iv_time.setVisibility(View.GONE);
|
||||
dcb_sort.setText(getResources().getString(R.string.zuire));
|
||||
chengeImg(dcb_sort);
|
||||
ll_sort.setVisibility(View.GONE);
|
||||
sort = "1";
|
||||
freePage = 1;
|
||||
lv_exchange_my.setVisibility(View.GONE);
|
||||
lv_exchange.setVisibility(View.VISIBLE);
|
||||
getData();
|
||||
break;
|
||||
case R.id.ll_time:
|
||||
tv_new.setTextColor(getResources().getColor(
|
||||
R.color.text_color));
|
||||
tv_time.setTextColor(getResources().getColor(
|
||||
R.color.top_title));
|
||||
tv_hot.setTextColor(getResources().getColor(
|
||||
R.color.text_color));
|
||||
iv_hot.setVisibility(View.GONE);
|
||||
iv_new.setVisibility(View.GONE);
|
||||
iv_time.setVisibility(View.VISIBLE);
|
||||
dcb_sort.setText(getResources().getString(R.string.shichang));
|
||||
chengeImg(dcb_sort);
|
||||
ll_sort.setVisibility(View.GONE);
|
||||
sort = "3";
|
||||
freePage = 1;
|
||||
lv_exchange_my.setVisibility(View.GONE);
|
||||
lv_exchange.setVisibility(View.VISIBLE);
|
||||
getData();
|
||||
break;
|
||||
case R.id.bt_sure:
|
||||
if (Tags == null) {
|
||||
Tags = new ArrayList<String>();
|
||||
}
|
||||
Tags.clear();
|
||||
if (TagPosition != null) {
|
||||
for (int i = 0; i < TagPosition.size(); i++) {
|
||||
int positon = Integer.parseInt(TagPosition.get(i));
|
||||
Tags.add(mTagList.data.get(positon).getNAME());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
rl_pop_screen.setVisibility(View.GONE);
|
||||
if (TagPosition != null && TagPosition.size() != 0) {
|
||||
Drawable drawable = getResources().getDrawable(
|
||||
R.drawable.cb_screen_yes);
|
||||
drawable.setBounds(0, 0, drawable.getMinimumWidth(),
|
||||
drawable.getMinimumHeight()); // 设置边界
|
||||
bt_screen.setCompoundDrawables(null, null, drawable, null);
|
||||
bt_screen.setTextColor(getResources().getColor(
|
||||
R.color.tab_text_sel));
|
||||
} else {
|
||||
Drawable drawable = getResources().getDrawable(
|
||||
R.drawable.cb_screen_no);
|
||||
drawable.setBounds(0, 0, drawable.getMinimumWidth(),
|
||||
drawable.getMinimumHeight()); // 设置边界
|
||||
bt_screen.setCompoundDrawables(null, null, drawable, null);
|
||||
bt_screen.setTextColor(getResources().getColor(
|
||||
R.color.tab_text_nor));
|
||||
}
|
||||
freePage = 1;
|
||||
mySerPage = 1;
|
||||
StringBuilder keywords = new StringBuilder();
|
||||
if (Tags != null && Tags.size() > 0) {
|
||||
for (int i = 0; i < Tags.size(); i++) {
|
||||
keywords.append(Tags.get(i) + ",");
|
||||
}
|
||||
|
||||
}
|
||||
ExchangeAreaActivity.this.keywords = keywords.toString();
|
||||
lv_exchange_my.setVisibility(View.GONE);
|
||||
lv_exchange.setVisibility(View.VISIBLE);
|
||||
getData();
|
||||
break;
|
||||
}
|
||||
}
|
||||
private void getTagList() {
|
||||
RequestParams params = new RequestParams();
|
||||
params.addBodyParameter("type", "7");
|
||||
HttpHelper.loadData(HttpRequest.HttpMethod.POST, Url.getTagList, params,
|
||||
new RequestCallBack<String>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(ResponseInfo<String> info) {
|
||||
LogUtil.i("getLibraryList.onSuccess info.result = "
|
||||
+ info.result);
|
||||
SharePrefUtil.saveString(ExchangeAreaActivity.this, Url.getTagList,
|
||||
info.result);
|
||||
processTage(info.result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(HttpException arg0, String arg1) {
|
||||
LogUtil.i("getLibraryList.onFailure = " + arg1);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
private void processTage(String result) {
|
||||
rl_pop_screen.setVisibility(View.VISIBLE);
|
||||
try {
|
||||
mTagList = GsonTools.fromGsonToBean(result, TagList.class);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (mTagList != null) {
|
||||
if (StringUtil.isOneToCode(mTagList.code)) {
|
||||
ToastUtil.showToast(mTagList.message);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
ToastUtil.showToast("服务器异常");
|
||||
}
|
||||
if (mAdapter2 == null) {
|
||||
mAdapter2 = new ScreenAdapter();
|
||||
mGv_screen.setAdapter(mAdapter2);
|
||||
}
|
||||
}
|
||||
|
||||
public class ScreenAdapter extends BaseAdapter {
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
// TODO Auto-generated method stub
|
||||
return mTagList.data.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
// TODO Auto-generated method stub
|
||||
return mTagList.data.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
// TODO Auto-generated method stub
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
// TODO Auto-generated method stub
|
||||
View view = UIUtils.inflate(R.layout.gv_item_screen);
|
||||
TextView tv_item = (TextView) view
|
||||
.findViewById(R.id.tv_gv_item_screen);
|
||||
tv_item.setText(mTagList.data.get(position).getNAME());
|
||||
if (TagPosition != null && TagPosition.contains(position + "")) {
|
||||
tv_item.setEnabled(true);
|
||||
} else {
|
||||
tv_item.setEnabled(false);
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void getMySeriesType() {
|
||||
Map<String,String> map = new HashMap<>();
|
||||
map.put("page",mySerPage+"");
|
||||
sendJsonPostParamtoNetSignMD5(Url.listMySeriesType,map,MYLIST,this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCallbackFromThread(String resultJson) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCallBackFromThread(String resultJson, int resultCode) {
|
||||
|
||||
switch (resultCode){
|
||||
case EXCHANGE:
|
||||
dialog.dismiss();
|
||||
LogUtil.i("EXCHANGE = "+resultJson);
|
||||
Gson gson = new Gson();
|
||||
ll_empty.setVisibility(View.GONE);
|
||||
listFreeBean = gson.fromJson(resultJson, ListSeriesTypeBean.class);
|
||||
// 判断是下拉刷新还是加载更多
|
||||
if (freePage == 1) {
|
||||
data.clear();
|
||||
if (listFreeBean.getData() == null || listFreeBean.getData().getList().size()==0) {
|
||||
// 显示空布局
|
||||
lv_exchange.setVisibility(View.GONE);
|
||||
ll_empty.setVisibility(View.VISIBLE);
|
||||
tv_empty_msg.setText("暂无视频");
|
||||
// 完成刷新
|
||||
onLoaded();
|
||||
return;
|
||||
} else {
|
||||
lv_exchange.setVisibility(View.VISIBLE);
|
||||
data.addAll(listFreeBean.getData().getList());
|
||||
}
|
||||
} else {
|
||||
data.addAll(listFreeBean.getData().getList());
|
||||
}
|
||||
if (adapter == null){
|
||||
adapter = new ExchangeAdapter(ExchangeAreaActivity.this,data);
|
||||
lv_exchange.setAdapter(adapter);
|
||||
}else {
|
||||
// lv_exchange.setAdapter(adapter);
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
// 完成刷新
|
||||
onLoaded();
|
||||
|
||||
if (freePage > 1) {
|
||||
// 是否有更多
|
||||
if (listFreeBean.getData() == null || listFreeBean.getData().getList().size()==0) {// 由于暂时虚构没数据,所以加载更多也没数据
|
||||
ToastUtil.showMessage("没有更多了");
|
||||
lv_exchange.setMode(PullToRefreshBase.Mode.PULL_FROM_START);
|
||||
if (freePage > 1)
|
||||
freePage--;
|
||||
} else {
|
||||
lv_exchange.setMode(PullToRefreshBase.Mode.BOTH);
|
||||
}
|
||||
} else if (freePage == 1) {
|
||||
// 得到总页码数
|
||||
int totalPage = listFreeBean.getData().getTotal();
|
||||
if (totalPage <= 1 || totalPage < freePage) {
|
||||
lv_exchange.setMode(PullToRefreshBase.Mode.PULL_FROM_START);
|
||||
} else {
|
||||
lv_exchange.setMode(PullToRefreshBase.Mode.BOTH);
|
||||
}
|
||||
} else {
|
||||
lv_exchange.setMode(PullToRefreshBase.Mode.BOTH);
|
||||
}
|
||||
|
||||
// 设置刷新的时间
|
||||
setLastUpdateTime();
|
||||
|
||||
// if (listFreeBean!=null&&listFreeBean.getData().getList()!=null&&listFreeBean.getData().getList().size()>0){
|
||||
// FreeAdapter adapter = new FreeAdapter(FreeAreaActivity.this,listFreeBean.getData().getList());
|
||||
// lv_exchange.setAdapter(adapter);
|
||||
// ll_empty.setVisibility(View.GONE);
|
||||
// }else{
|
||||
// ll_empty.setVisibility(View.VISIBLE);
|
||||
// tv_empty_msg.setText("暂无视频");
|
||||
// }
|
||||
break;
|
||||
case MYLIST:
|
||||
dialog.dismiss();
|
||||
LogUtil.i("MYLIST = "+resultJson);
|
||||
ll_empty.setVisibility(View.GONE);
|
||||
Gson gson1 = new Gson();
|
||||
listSeriesTypeBean = gson1.fromJson(resultJson, ListSeriesTypeBean.class);
|
||||
|
||||
// 判断是下拉刷新还是加载更多
|
||||
if (mySerPage == 1) {
|
||||
data1.clear();
|
||||
if (listSeriesTypeBean.getData() == null || listSeriesTypeBean.getData().getList().size()==0) {
|
||||
// 显示空布局
|
||||
lv_exchange_my.setVisibility(View.GONE);
|
||||
ll_empty.setVisibility(View.VISIBLE);
|
||||
tv_empty_msg.setText("暂无视频");
|
||||
// 完成刷新
|
||||
onLoaded();
|
||||
return;
|
||||
} else {
|
||||
lv_exchange_my.setVisibility(View.VISIBLE);
|
||||
data1.addAll(listSeriesTypeBean.getData().getList());
|
||||
}
|
||||
} else {
|
||||
data1.addAll(listSeriesTypeBean.getData().getList());
|
||||
}
|
||||
if (exchangeAdapter == null){
|
||||
exchangeAdapter = new MyListSeriesAdapter(ExchangeAreaActivity.this,data1);
|
||||
lv_exchange_my.setAdapter(exchangeAdapter);
|
||||
}else {
|
||||
// lv_exchange.setAdapter(exchangeAdapter);
|
||||
exchangeAdapter.notifyDataSetChanged();
|
||||
|
||||
}
|
||||
// 完成刷新
|
||||
onLoaded();
|
||||
|
||||
if (mySerPage > 1) {
|
||||
// 是否有更多
|
||||
if (listSeriesTypeBean.getData() == null || listSeriesTypeBean.getData().getList().size()==0) {// 由于暂时虚构没数据,所以加载更多也没数据
|
||||
ToastUtil.showMessage("没有更多了");
|
||||
lv_exchange_my.setMode(PullToRefreshBase.Mode.PULL_FROM_START);
|
||||
if (mySerPage > 1)
|
||||
mySerPage--;
|
||||
} else {
|
||||
lv_exchange_my.setMode(PullToRefreshBase.Mode.BOTH);
|
||||
}
|
||||
} else if (mySerPage == 1) {
|
||||
// 得到总页码数
|
||||
int totalPage = listSeriesTypeBean.getData().getTotal();
|
||||
if (totalPage <= 1 || totalPage < mySerPage) {
|
||||
lv_exchange_my.setMode(PullToRefreshBase.Mode.PULL_FROM_START);
|
||||
} else {
|
||||
lv_exchange_my.setMode(PullToRefreshBase.Mode.BOTH);
|
||||
}
|
||||
} else {
|
||||
lv_exchange_my.setMode(PullToRefreshBase.Mode.BOTH);
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
private void onLoaded() {
|
||||
dismissLoadingProgress();
|
||||
if (lv_exchange != null) {
|
||||
lv_exchange.onRefreshComplete();
|
||||
}
|
||||
if (lv_exchange_my != null) {
|
||||
lv_exchange_my.onRefreshComplete();
|
||||
}
|
||||
|
||||
}
|
||||
private void setLastUpdateTime() {
|
||||
String text = CommonUtil.getStringDate();
|
||||
lv_exchange.getLoadingLayoutProxy().setLastUpdatedLabel(text);
|
||||
lv_exchange_my.getLoadingLayoutProxy().setLastUpdatedLabel(text);
|
||||
|
||||
}
|
||||
public void chengeImg(DrawableCenterButtonR mDb_sort){
|
||||
Drawable icon_new = UIUtils.getDrawable(R.drawable.triangle_green_theme);
|
||||
icon_new.setBounds(0, 0, icon_new.getMinimumWidth(),
|
||||
icon_new.getMinimumHeight());
|
||||
mDb_sort.setCompoundDrawables(null, null, icon_new,
|
||||
null);
|
||||
mDb_sort.setTextColor(ExchangeAreaActivity.this.getResources().getColor(
|
||||
R.color.top_title));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,699 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.GridView;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.gyf.immersionbar.ImmersionBar;
|
||||
import com.lidroid.xutils.exception.HttpException;
|
||||
import com.lidroid.xutils.http.RequestParams;
|
||||
import com.lidroid.xutils.http.ResponseInfo;
|
||||
import com.lidroid.xutils.http.callback.RequestCallBack;
|
||||
import com.lidroid.xutils.http.client.HttpRequest;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import cn.shangyu.gdxzExpert.R;
|
||||
import cn.shangyu.gdxzExpert.base.BaseActivity;
|
||||
import cn.shangyu.gdxzExpert.bean.ListFreeBean;
|
||||
import cn.shangyu.gdxzExpert.bean.ListSeriesTypeBean;
|
||||
import cn.shangyu.gdxzExpert.bean.TagList;
|
||||
import cn.shangyu.gdxzExpert.http.HttpHelper;
|
||||
import cn.shangyu.gdxzExpert.http.OnCallBackFromNet;
|
||||
import cn.shangyu.gdxzExpert.polyvplayer.adapter.FreeAdapter;
|
||||
import cn.shangyu.gdxzExpert.polyvplayer.adapter.MyListSeriesAdapter;
|
||||
import cn.shangyu.gdxzExpert.pulltorefreshview.PullToRefreshBase;
|
||||
import cn.shangyu.gdxzExpert.pulltorefreshview.PullToRefreshListView;
|
||||
import cn.shangyu.gdxzExpert.ui.CustomProgressDialog;
|
||||
import cn.shangyu.gdxzExpert.utils.CommonUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.DialogUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.GsonTools;
|
||||
import cn.shangyu.gdxzExpert.utils.LogUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.SharePrefUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.StringUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.ToastUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.UIUtils;
|
||||
import cn.shangyu.gdxzExpert.utils.Url;
|
||||
import cn.shangyu.gdxzExpert.view.DrawableCenterButtonR;
|
||||
import cn.shangyu.gdxzExpert.widget.LoadingPage;
|
||||
|
||||
/**
|
||||
* Created by wangchengxin on 2019/4/1.
|
||||
*/
|
||||
|
||||
public class FreeAreaActivity extends BaseActivity implements OnCallBackFromNet{
|
||||
public static final int FREE=1;
|
||||
private PullToRefreshListView lv_exchange;
|
||||
private PullToRefreshListView lv_exchange_my ;
|
||||
private ListFreeBean listFreeBean;
|
||||
private DrawableCenterButtonR dcb_sort;
|
||||
private LinearLayout ll_sort,ll_new,ll_hot,ll_time;
|
||||
private RelativeLayout rl_pop_screen;
|
||||
private DrawableCenterButtonR bt_screen,cb_yiduihuan;
|
||||
private boolean ischange;
|
||||
private TextView tv_new,tv_hot,tv_time;
|
||||
private ImageView iv_new,iv_hot,iv_time;
|
||||
private String sort;
|
||||
private final static int MYLIST = 2;
|
||||
private ListSeriesTypeBean listSeriesTypeBean;
|
||||
private View ll_empty;
|
||||
private TextView tv_empty_msg;
|
||||
private TagList mTagList;
|
||||
private ScreenAdapter mAdapter2;
|
||||
private GridView mGv_screen;
|
||||
private List<String> TagPosition = null;
|
||||
private Button mBt_sure, mBt_reset;
|
||||
private ArrayList<String> Tags;
|
||||
private int freePage = 1;
|
||||
private int mySerPage = 1;
|
||||
private String keywords1 ="";
|
||||
private FreeAdapter adapter;
|
||||
private List<ListFreeBean.DataBean.ListBean> data = new ArrayList<>();
|
||||
private MyListSeriesAdapter exchangeAdapter;
|
||||
private List<ListSeriesTypeBean.DataBean.ListBean> data1 = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void setTitle() {
|
||||
top_title.setText("免费专区");
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateSuccessedView() {
|
||||
ImmersionBar.with(this).keyboardEnable(true).statusBarDarkFont(true).titleBar(mToolbar).init();
|
||||
View view = UIUtils.inflate(R.layout.activity_exchangearea);
|
||||
initView(view);
|
||||
initOnClick();
|
||||
sort = "2";
|
||||
getData();
|
||||
return view;
|
||||
}
|
||||
|
||||
private void initOnClick() {
|
||||
dcb_sort.setOnClickListener(this);
|
||||
bt_screen.setOnClickListener(this);
|
||||
cb_yiduihuan.setOnClickListener(this);
|
||||
ll_new.setOnClickListener(this);
|
||||
ll_hot.setOnClickListener(this);
|
||||
ll_time.setOnClickListener(this);
|
||||
mBt_sure.setOnClickListener(this);
|
||||
lv_exchange.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
if (ll_sort.getVisibility()==View.VISIBLE){
|
||||
ll_sort.setVisibility(View.GONE);
|
||||
return;
|
||||
}
|
||||
if (rl_pop_screen.getVisibility()==View.VISIBLE){
|
||||
return;
|
||||
}
|
||||
position --;
|
||||
Intent intent1 = PolyvPlayerActivity.newIntent(FreeAreaActivity.this, PolyvPlayerActivity.PlayMode.portrait, data.get(position).getPolyv_uuid());
|
||||
intent1.putExtra("startNow", true);
|
||||
intent1.putExtra("isVlmsOnline", false);
|
||||
intent1.putExtra("series_type_uuid",data.get(position).getSeries_type_uuid());
|
||||
intent1.putExtra("uuid",data.get(position).getUuid());
|
||||
startActivity(intent1);
|
||||
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
lv_exchange_my.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
if (ll_sort.getVisibility()==View.VISIBLE){
|
||||
ll_sort.setVisibility(View.GONE);
|
||||
return;
|
||||
}
|
||||
if (rl_pop_screen.getVisibility()==View.VISIBLE){
|
||||
return;
|
||||
}
|
||||
position --;
|
||||
Intent intent = PolyvPlayerActivity.newIntent(FreeAreaActivity.this, PolyvPlayerActivity.PlayMode.portrait, "");
|
||||
intent.putExtra("isVlmsOnline", false);
|
||||
intent.putExtra("series_type_uuid", data1.get(position).getUuid());
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
mGv_screen.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view,
|
||||
int position, long id) {
|
||||
// TODO Auto-generated method stub
|
||||
if (TagPosition == null) {
|
||||
TagPosition = new ArrayList<String>();
|
||||
}
|
||||
if (TagPosition.contains(position + "")) {
|
||||
TagPosition.remove(position + "");
|
||||
} else {
|
||||
if (TagPosition.size() < 3) {
|
||||
TagPosition.add(position + "");
|
||||
} else {
|
||||
ToastUtil.showMessage("最多选择三个标签");
|
||||
}
|
||||
}
|
||||
mAdapter2.notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
mBt_reset.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// TODO Auto-generated method stub
|
||||
if (TagPosition == null) {
|
||||
return;
|
||||
} else {
|
||||
TagPosition.clear();
|
||||
mAdapter2.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
});
|
||||
lv_exchange.setMode(PullToRefreshBase.Mode.BOTH);
|
||||
lv_exchange_my.setMode(PullToRefreshBase.Mode.BOTH);
|
||||
lv_exchange.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener2() {
|
||||
|
||||
@Override
|
||||
public void onPullDownToRefresh(PullToRefreshBase refreshView) {
|
||||
|
||||
freePage = 1;
|
||||
getData();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPullUpToRefresh(PullToRefreshBase refreshView) {
|
||||
|
||||
freePage++;
|
||||
getData();
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
lv_exchange_my.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener2() {
|
||||
|
||||
@Override
|
||||
public void onPullDownToRefresh(PullToRefreshBase refreshView) {
|
||||
|
||||
|
||||
mySerPage = 1;
|
||||
getMySeriesType();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPullUpToRefresh(PullToRefreshBase refreshView) {
|
||||
|
||||
mySerPage++;
|
||||
getMySeriesType();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void initView(View view) {
|
||||
lv_exchange = view.findViewById(R.id.lv_exchange);
|
||||
lv_exchange_my = view.findViewById(R.id.lv_exchange_my);
|
||||
dcb_sort = view.findViewById(R.id.dcb_sort);
|
||||
ll_sort = view.findViewById(R.id.ll_sort);
|
||||
rl_pop_screen = view.findViewById(R.id.rl_pop_screen);
|
||||
bt_screen = view.findViewById(R.id.bt_screen);
|
||||
cb_yiduihuan = view.findViewById(R.id.cb_yiduihuan);
|
||||
ll_new = view.findViewById(R.id.ll_new);
|
||||
ll_hot = view.findViewById(R.id.ll_hot);
|
||||
ll_time = view.findViewById(R.id.ll_time);
|
||||
tv_new = view.findViewById(R.id.tv_new);
|
||||
tv_hot = view.findViewById(R.id.tv_hot);
|
||||
tv_time = view.findViewById(R.id.tv_time);
|
||||
iv_new = view.findViewById(R.id.iv_new);
|
||||
iv_hot = view.findViewById(R.id.iv_hot);
|
||||
iv_time = view.findViewById(R.id.iv_time);
|
||||
ll_empty = view.findViewById(R.id.ll_empty);
|
||||
tv_empty_msg = view.findViewById(R.id.tv_empty_msg);
|
||||
mGv_screen = (GridView) view.findViewById(R.id.gv_teach);
|
||||
mBt_sure = (Button) view.findViewById(R.id.bt_sure);
|
||||
mBt_reset = (Button) view.findViewById(R.id.bt_reset);
|
||||
dialog = (CustomProgressDialog) DialogUtil.createProgressDialog(this,
|
||||
"加载中");
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
private void getData() {
|
||||
lv_exchange_my.setVisibility(View.GONE);
|
||||
Map<String,String> map = new HashMap<>();
|
||||
map.put("page",freePage+"");
|
||||
map.put("title","");
|
||||
map.put("keywords",keywords1);
|
||||
map.put("sort",sort);
|
||||
sendJsonPostParamtoNetSignMD5(Url.listFree,map,FREE,this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoadingPage.ResultState onLoad() {
|
||||
return LoadingPage.ResultState.STATE_SUCCESSED;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void processClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.dcb_sort://最新
|
||||
if (ischange){
|
||||
cb_yiduihuan.setTextColor(getResources().getColor(
|
||||
R.color.tab_text_nor));
|
||||
ischange = false;
|
||||
}
|
||||
if (ll_sort.getVisibility() == View.VISIBLE) {
|
||||
ll_sort.setVisibility(View.GONE);
|
||||
return;
|
||||
}
|
||||
if (rl_pop_screen.getVisibility() == View.VISIBLE) {
|
||||
rl_pop_screen.setVisibility(View.GONE);
|
||||
return;
|
||||
}
|
||||
if (ll_sort.getVisibility()== View.GONE){
|
||||
ll_sort.setVisibility(View.VISIBLE);
|
||||
}else {
|
||||
ll_sort.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
break;
|
||||
case R.id.bt_screen://筛选
|
||||
if (ischange){
|
||||
cb_yiduihuan.setTextColor(getResources().getColor(
|
||||
R.color.tab_text_nor));
|
||||
ischange = false;
|
||||
}
|
||||
if (ll_sort.getVisibility() == View.VISIBLE) {
|
||||
ll_sort.setVisibility(View.GONE);
|
||||
return;
|
||||
}
|
||||
if (mTagList == null) {
|
||||
getTagList();
|
||||
}
|
||||
if (rl_pop_screen.getVisibility() == View.GONE) {
|
||||
rl_pop_screen.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
rl_pop_screen.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
break;
|
||||
case R.id.cb_yiduihuan://已兑换
|
||||
if (rl_pop_screen.getVisibility() == View.VISIBLE) {
|
||||
rl_pop_screen.setVisibility(View.GONE);
|
||||
}
|
||||
if (ll_sort.getVisibility() == View.VISIBLE) {
|
||||
ll_sort.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if (!ischange) {//已兑换
|
||||
cb_yiduihuan.setTextColor(getResources().getColor(
|
||||
R.color.top_title));
|
||||
ischange = true;
|
||||
lv_exchange.setVisibility(View.GONE);
|
||||
lv_exchange_my.setVisibility(View.VISIBLE);
|
||||
if (listSeriesTypeBean == null){
|
||||
dialog.show();
|
||||
mySerPage = 1;
|
||||
getMySeriesType();
|
||||
}else if (listSeriesTypeBean.getData().getList().size()==0){
|
||||
ll_empty.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
} else {
|
||||
cb_yiduihuan.setTextColor(getResources().getColor(
|
||||
R.color.tab_text_nor));
|
||||
ischange = false;
|
||||
lv_exchange_my.setVisibility(View.GONE);
|
||||
lv_exchange.setVisibility(View.VISIBLE);
|
||||
ll_empty.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case R.id.ll_new:
|
||||
tv_hot.setTextColor(getResources().getColor(
|
||||
R.color.text_color));
|
||||
tv_time.setTextColor(getResources().getColor(
|
||||
R.color.text_color));
|
||||
tv_new.setTextColor(getResources().getColor(
|
||||
R.color.top_title));
|
||||
iv_new.setVisibility(View.VISIBLE);
|
||||
iv_hot.setVisibility(View.GONE);
|
||||
iv_time.setVisibility(View.GONE);
|
||||
dcb_sort.setText(getResources().getString(R.string.zuixin));
|
||||
chengeImg(dcb_sort);
|
||||
ll_sort.setVisibility(View.GONE);
|
||||
sort = "2";
|
||||
freePage = 1;
|
||||
lv_exchange_my.setVisibility(View.GONE);
|
||||
lv_exchange.setVisibility(View.VISIBLE);
|
||||
getData();
|
||||
break;
|
||||
case R.id.ll_hot:
|
||||
tv_new.setTextColor(getResources().getColor(
|
||||
R.color.text_color));
|
||||
tv_time.setTextColor(getResources().getColor(
|
||||
R.color.text_color));
|
||||
tv_hot.setTextColor(getResources().getColor(
|
||||
R.color.top_title));
|
||||
iv_hot.setVisibility(View.VISIBLE);
|
||||
iv_new.setVisibility(View.GONE);
|
||||
iv_time.setVisibility(View.GONE);
|
||||
dcb_sort.setText(getResources().getString(R.string.zuire));
|
||||
chengeImg(dcb_sort);
|
||||
ll_sort.setVisibility(View.GONE);
|
||||
sort = "1";
|
||||
freePage = 1;
|
||||
lv_exchange_my.setVisibility(View.GONE);
|
||||
lv_exchange.setVisibility(View.VISIBLE);
|
||||
getData();
|
||||
break;
|
||||
case R.id.ll_time:
|
||||
tv_new.setTextColor(getResources().getColor(
|
||||
R.color.text_color));
|
||||
tv_time.setTextColor(getResources().getColor(
|
||||
R.color.top_title));
|
||||
tv_hot.setTextColor(getResources().getColor(
|
||||
R.color.text_color));
|
||||
iv_hot.setVisibility(View.GONE);
|
||||
iv_new.setVisibility(View.GONE);
|
||||
iv_time.setVisibility(View.VISIBLE);
|
||||
dcb_sort.setText(getResources().getString(R.string.shichang));
|
||||
chengeImg(dcb_sort);
|
||||
ll_sort.setVisibility(View.GONE);
|
||||
sort = "3";
|
||||
freePage = 1;
|
||||
lv_exchange_my.setVisibility(View.GONE);
|
||||
lv_exchange.setVisibility(View.VISIBLE);
|
||||
getData();
|
||||
break;
|
||||
case R.id.bt_sure:
|
||||
if (Tags == null) {
|
||||
Tags = new ArrayList<String>();
|
||||
}
|
||||
Tags.clear();
|
||||
if (TagPosition != null) {
|
||||
for (int i = 0; i < TagPosition.size(); i++) {
|
||||
int positon = Integer.parseInt(TagPosition.get(i));
|
||||
Tags.add(mTagList.data.get(positon).getNAME());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
rl_pop_screen.setVisibility(View.GONE);
|
||||
if (TagPosition != null && TagPosition.size() != 0) {
|
||||
Drawable drawable = getResources().getDrawable(
|
||||
R.drawable.cb_screen_yes);
|
||||
drawable.setBounds(0, 0, drawable.getMinimumWidth(),
|
||||
drawable.getMinimumHeight()); // 设置边界
|
||||
bt_screen.setCompoundDrawables(null, null, drawable, null);
|
||||
bt_screen.setTextColor(getResources().getColor(
|
||||
R.color.tab_text_sel));
|
||||
} else {
|
||||
Drawable drawable = getResources().getDrawable(
|
||||
R.drawable.cb_screen_no);
|
||||
drawable.setBounds(0, 0, drawable.getMinimumWidth(),
|
||||
drawable.getMinimumHeight()); // 设置边界
|
||||
bt_screen.setCompoundDrawables(null, null, drawable, null);
|
||||
bt_screen.setTextColor(getResources().getColor(
|
||||
R.color.tab_text_nor));
|
||||
}
|
||||
freePage = 1;
|
||||
mySerPage = 1;
|
||||
StringBuilder keywords = new StringBuilder();
|
||||
if (Tags != null && Tags.size() > 0) {
|
||||
for (int i = 0; i < Tags.size(); i++) {
|
||||
keywords.append(Tags.get(i) + ",");
|
||||
}
|
||||
|
||||
}
|
||||
keywords1 = keywords.toString();
|
||||
lv_exchange_my.setVisibility(View.GONE);
|
||||
lv_exchange.setVisibility(View.VISIBLE);
|
||||
getData();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void getTagList() {
|
||||
RequestParams params = new RequestParams();
|
||||
params.addBodyParameter("type", "7");
|
||||
HttpHelper.loadData(HttpRequest.HttpMethod.POST, Url.getTagList, params,
|
||||
new RequestCallBack<String>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(ResponseInfo<String> info) {
|
||||
LogUtil.i("getLibraryList.onSuccess info.result = "
|
||||
+ info.result);
|
||||
SharePrefUtil.saveString(FreeAreaActivity.this, Url.getTagList,
|
||||
info.result);
|
||||
processTage(info.result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(HttpException arg0, String arg1) {
|
||||
LogUtil.i("getLibraryList.onFailure = " + arg1);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void processTage(String result) {
|
||||
try {
|
||||
mTagList = GsonTools.fromGsonToBean(result, TagList.class);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (mTagList != null) {
|
||||
if (StringUtil.isOneToCode(mTagList.code)) {
|
||||
ToastUtil.showToast(mTagList.message);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
ToastUtil.showToast("服务器异常");
|
||||
}
|
||||
if (mAdapter2 == null) {
|
||||
mAdapter2 = new ScreenAdapter();
|
||||
mGv_screen.setAdapter(mAdapter2);
|
||||
}
|
||||
}
|
||||
|
||||
public class ScreenAdapter extends BaseAdapter {
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
// TODO Auto-generated method stub
|
||||
return mTagList.data.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
// TODO Auto-generated method stub
|
||||
return mTagList.data.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
// TODO Auto-generated method stub
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
// TODO Auto-generated method stub
|
||||
View view = UIUtils.inflate(R.layout.gv_item_screen);
|
||||
TextView tv_item = (TextView) view
|
||||
.findViewById(R.id.tv_gv_item_screen);
|
||||
tv_item.setText(mTagList.data.get(position).getNAME());
|
||||
if (TagPosition != null && TagPosition.contains(position + "")) {
|
||||
tv_item.setEnabled(true);
|
||||
} else {
|
||||
tv_item.setEnabled(false);
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void getMySeriesType() {
|
||||
Map<String,String> map = new HashMap<>();
|
||||
map.put("page",mySerPage+"");
|
||||
sendJsonPostParamtoNetSignMD5(Url.listMySeriesType,map,MYLIST,this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCallbackFromThread(String resultJson) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCallBackFromThread(String resultJson, int resultCode) {
|
||||
|
||||
switch (resultCode){
|
||||
case FREE:
|
||||
dialog.dismiss();
|
||||
LogUtil.i("FREE = "+resultJson);
|
||||
Gson gson = new Gson();
|
||||
ll_empty.setVisibility(View.GONE);
|
||||
listFreeBean = gson.fromJson(resultJson, ListFreeBean.class);
|
||||
|
||||
// 判断是下拉刷新还是加载更多
|
||||
if (freePage == 1) {
|
||||
data.clear();
|
||||
if (listFreeBean.getData() == null || listFreeBean.getData().getList().size()==0) {
|
||||
// 显示空布局
|
||||
lv_exchange.setVisibility(View.GONE);
|
||||
ll_empty.setVisibility(View.VISIBLE);
|
||||
tv_empty_msg.setText("暂无视频");
|
||||
// 完成刷新
|
||||
onLoaded();
|
||||
return;
|
||||
} else {
|
||||
lv_exchange.setVisibility(View.VISIBLE);
|
||||
data.addAll(listFreeBean.getData().getList());
|
||||
}
|
||||
} else {
|
||||
data.addAll(listFreeBean.getData().getList());
|
||||
}
|
||||
if (adapter == null){
|
||||
adapter = new FreeAdapter(FreeAreaActivity.this,data);
|
||||
lv_exchange.setAdapter(adapter);
|
||||
}else {
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
// 完成刷新
|
||||
onLoaded();
|
||||
|
||||
if (freePage > 1) {
|
||||
// 是否有更多
|
||||
if (listFreeBean.getData() == null || listFreeBean.getData().getList().size()==0) {// 由于暂时虚构没数据,所以加载更多也没数据
|
||||
ToastUtil.showMessage("没有更多了");
|
||||
lv_exchange.setMode(PullToRefreshBase.Mode.PULL_FROM_START);
|
||||
if (freePage > 1)
|
||||
freePage--;
|
||||
} else {
|
||||
lv_exchange.setMode(PullToRefreshBase.Mode.BOTH);
|
||||
}
|
||||
} else if (freePage == 1) {
|
||||
// 得到总页码数
|
||||
int totalPage = listFreeBean.getData().getTotal();
|
||||
if (totalPage <= 1 || totalPage < freePage) {
|
||||
lv_exchange.setMode(PullToRefreshBase.Mode.PULL_FROM_START);
|
||||
} else {
|
||||
lv_exchange.setMode(PullToRefreshBase.Mode.BOTH);
|
||||
}
|
||||
} else {
|
||||
lv_exchange.setMode(PullToRefreshBase.Mode.BOTH);
|
||||
}
|
||||
|
||||
// 设置刷新的时间
|
||||
setLastUpdateTime();
|
||||
|
||||
|
||||
break;
|
||||
case MYLIST:
|
||||
dialog.dismiss();
|
||||
LogUtil.i("MYLIST = "+resultJson);
|
||||
ll_empty.setVisibility(View.GONE);
|
||||
Gson gson1 = new Gson();
|
||||
listSeriesTypeBean = gson1.fromJson(resultJson, ListSeriesTypeBean.class);
|
||||
|
||||
|
||||
// 判断是下拉刷新还是加载更多
|
||||
if (mySerPage == 1) {
|
||||
data1.clear();
|
||||
if (listSeriesTypeBean.getData() == null || listSeriesTypeBean.getData().getList().size()==0) {
|
||||
// 显示空布局
|
||||
lv_exchange_my.setVisibility(View.GONE);
|
||||
ll_empty.setVisibility(View.VISIBLE);
|
||||
tv_empty_msg.setText("暂无视频");
|
||||
// 完成刷新
|
||||
onLoaded();
|
||||
return;
|
||||
} else {
|
||||
lv_exchange_my.setVisibility(View.VISIBLE);
|
||||
data1.addAll(listSeriesTypeBean.getData().getList());
|
||||
}
|
||||
} else {
|
||||
data1.addAll(listSeriesTypeBean.getData().getList());
|
||||
}
|
||||
if (exchangeAdapter == null){
|
||||
exchangeAdapter = new MyListSeriesAdapter(FreeAreaActivity.this,data1);
|
||||
lv_exchange_my.setAdapter(exchangeAdapter);
|
||||
}else {
|
||||
exchangeAdapter.notifyDataSetChanged();
|
||||
}
|
||||
// 完成刷新
|
||||
onLoaded();
|
||||
|
||||
if (mySerPage > 1) {
|
||||
// 是否有更多
|
||||
if (listSeriesTypeBean.getData() == null || listSeriesTypeBean.getData().getList().size()==0) {// 由于暂时虚构没数据,所以加载更多也没数据
|
||||
ToastUtil.showMessage("没有更多了");
|
||||
lv_exchange_my.setMode(PullToRefreshBase.Mode.PULL_FROM_START);
|
||||
if (mySerPage > 1)
|
||||
mySerPage--;
|
||||
} else {
|
||||
lv_exchange_my.setMode(PullToRefreshBase.Mode.BOTH);
|
||||
}
|
||||
} else if (mySerPage == 1) {
|
||||
// 得到总页码数
|
||||
int totalPage = listSeriesTypeBean.getData().getTotal();
|
||||
if (totalPage <= 1 || totalPage < mySerPage) {
|
||||
lv_exchange_my.setMode(PullToRefreshBase.Mode.PULL_FROM_START);
|
||||
} else {
|
||||
lv_exchange_my.setMode(PullToRefreshBase.Mode.BOTH);
|
||||
}
|
||||
} else {
|
||||
lv_exchange_my.setMode(PullToRefreshBase.Mode.BOTH);
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
private void onLoaded() {
|
||||
dismissLoadingProgress();
|
||||
if (lv_exchange != null) {
|
||||
lv_exchange.onRefreshComplete();
|
||||
}
|
||||
if (lv_exchange_my != null) {
|
||||
lv_exchange_my.onRefreshComplete();
|
||||
}
|
||||
}
|
||||
private void setLastUpdateTime() {
|
||||
String text = CommonUtil.getStringDate();
|
||||
lv_exchange.getLoadingLayoutProxy().setLastUpdatedLabel(text);
|
||||
lv_exchange_my.getLoadingLayoutProxy().setLastUpdatedLabel(text);
|
||||
}
|
||||
public void chengeImg(DrawableCenterButtonR mDb_sort){
|
||||
Drawable icon_new = UIUtils.getDrawable(R.drawable.triangle_green_theme);
|
||||
icon_new.setBounds(0, 0, icon_new.getMinimumWidth(),
|
||||
icon_new.getMinimumHeight());
|
||||
mDb_sort.setCompoundDrawables(null, null, icon_new,
|
||||
null);
|
||||
mDb_sort.setTextColor(FreeAreaActivity.this.getResources().getColor(
|
||||
R.color.top_title));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.view.View;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import com.gyf.immersionbar.ImmersionBar;
|
||||
|
||||
import cn.shangyu.gdxzExpert.R;
|
||||
import cn.shangyu.gdxzExpert.base.BaseActivity;
|
||||
import cn.shangyu.gdxzExpert.utils.CommonUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.UIUtils;
|
||||
import cn.shangyu.gdxzExpert.widget.LoadingPage;
|
||||
|
||||
/**
|
||||
* Created by WANGChengXin on 2019/10/29.
|
||||
*/
|
||||
|
||||
public class MyDownLoadVideoActivity extends BaseActivity {
|
||||
private View view;
|
||||
private MyDownLoadVideoActivity mActivity;
|
||||
private RelativeLayout rl_1,rl_2;
|
||||
|
||||
@Override
|
||||
public void setTitle() {
|
||||
top_title.setText("我的视频");
|
||||
if(CommonUtil.BigModule())
|
||||
{
|
||||
top_title.setTextSize(23);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateSuccessedView() {
|
||||
ImmersionBar.with(this).keyboardEnable(true).statusBarDarkFont(true).titleBar(mToolbar).init();
|
||||
if(CommonUtil.BigModule())
|
||||
{
|
||||
view = UIUtils.inflate(R.layout.activity_my_down_loadvideo_big);
|
||||
}
|
||||
else
|
||||
{
|
||||
view = UIUtils.inflate(R.layout.activity_my_down_loadvideo);
|
||||
}
|
||||
rl_1 = view.findViewById(R.id.rl_1);
|
||||
rl_2 = view.findViewById(R.id.rl_2);
|
||||
rl_1.setOnClickListener(this);
|
||||
rl_2.setOnClickListener(this);
|
||||
mActivity = this;
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
needreportPage("我的视频");
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoadingPage.ResultState onLoad() {
|
||||
return LoadingPage.ResultState.STATE_SUCCESSED;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void processClick(View v) {
|
||||
switch (v.getId()){
|
||||
case R.id.rl_1:
|
||||
startActivity(new Intent(MyDownLoadVideoActivity.this, VideohistoryActivity.class));
|
||||
break;
|
||||
case R.id.rl_2:
|
||||
startActivity(new Intent(MyDownLoadVideoActivity.this, PolyvDownloadActivity.class));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,347 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.gyf.immersionbar.ImmersionBar;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import cn.shangyu.gdxzExpert.R;
|
||||
import cn.shangyu.gdxzExpert.base.BaseActivity;
|
||||
import cn.shangyu.gdxzExpert.bean.VideoOrderBean;
|
||||
import cn.shangyu.gdxzExpert.http.OnCallBackFromNet;
|
||||
import cn.shangyu.gdxzExpert.pointsmall.BuyIntegerActivty;
|
||||
import cn.shangyu.gdxzExpert.utils.Constant;
|
||||
import cn.shangyu.gdxzExpert.utils.LogUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.SharePrefUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.ToastUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.UIUtils;
|
||||
import cn.shangyu.gdxzExpert.utils.Url;
|
||||
import cn.shangyu.gdxzExpert.widget.ECAlertDialog;
|
||||
import cn.shangyu.gdxzExpert.widget.LoadingPage;
|
||||
|
||||
/**
|
||||
* Created by WANGChengXin on 2019/3/27.
|
||||
*/
|
||||
|
||||
public class OnlineVideoExchangeActivity extends BaseActivity implements OnCallBackFromNet,View.OnClickListener{
|
||||
|
||||
private TextView tv_exchange;
|
||||
private String series_type_uuid;
|
||||
private Dialog dialog;
|
||||
private String title;
|
||||
private String paid_num;
|
||||
private String price;
|
||||
private String order_uuid;
|
||||
private Intent intent;
|
||||
private ECAlertDialog dilaog2;
|
||||
public static final int GETWELFARENUM = 201;
|
||||
public static final int USEWELFARENUM = 202;
|
||||
public static final int CREATESERIESVIDEOORDER = 101;
|
||||
public static final int PAYSERIESVIDEOORDER = 102;
|
||||
private int welfareNum;
|
||||
private AlertDialog dialog1;
|
||||
private boolean is_welfareNum;
|
||||
|
||||
@Override
|
||||
public void setTitle() {
|
||||
top_title.setText("在线兑换");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateSuccessedView() {
|
||||
ImmersionBar.with(this).keyboardEnable(true).statusBarDarkFont(true).titleBar(mToolbar).init();
|
||||
View view = UIUtils.inflate(R.layout.activity_onlinevideoexchange);
|
||||
TextView tv_name = view.findViewById(R.id.tv_name);
|
||||
TextView tv_jifen = view.findViewById(R.id.tv_jifen);
|
||||
TextView tv_duihuan = view.findViewById(R.id.tv_duihuan);
|
||||
TextView tv_needpoint = view.findViewById(R.id.tv_needpoint);
|
||||
intent = getIntent();
|
||||
series_type_uuid = getIntent().getStringExtra("series_type_uuid");
|
||||
title = getIntent().getStringExtra("title");
|
||||
paid_num = getIntent().getStringExtra("paid_num");
|
||||
price = getIntent().getStringExtra("price");
|
||||
tv_exchange = view.findViewById(R.id.tv_exchange);
|
||||
|
||||
tv_name.setText(title);
|
||||
if ("0".equals(paid_num)){
|
||||
tv_duihuan.setVisibility(View.GONE);
|
||||
}else {
|
||||
tv_duihuan.setText(paid_num);
|
||||
}
|
||||
tv_jifen.setText(price);
|
||||
tv_needpoint.setText(price);
|
||||
tv_exchange.setOnClickListener(this);
|
||||
getWelfareNum();
|
||||
return view;
|
||||
}
|
||||
//查询福利剩余次数
|
||||
//参数type (1视频2课件3精品4万方5U盘)
|
||||
private void getWelfareNum() {
|
||||
Map<String,String> map = new HashMap<>();
|
||||
map.put("type","3");
|
||||
sendJsonPostParamtoNetSignMD5(Url.getWelfareNum,map,GETWELFARENUM,this);
|
||||
}
|
||||
|
||||
//使用福利操作
|
||||
private void useWelfareNum() {
|
||||
Map<String,String> map = new HashMap<>();
|
||||
map.put("type","3");
|
||||
map.put("other_uuid",order_uuid);
|
||||
sendJsonPostParamtoNetSignMD5(Url.useWelfareNum,map,USEWELFARENUM,this);
|
||||
}
|
||||
//创建订单
|
||||
private void createSeriesVideoOrder() {
|
||||
Map<String,String> map = new HashMap<>();
|
||||
map.put("series_type_uuid",series_type_uuid);
|
||||
sendJsonPostParamtoNetSignMD5(Url.createSeriesVideoOrder,map,CREATESERIESVIDEOORDER,OnlineVideoExchangeActivity.this);
|
||||
}
|
||||
@Override
|
||||
public LoadingPage.ResultState onLoad() {
|
||||
return LoadingPage.ResultState.STATE_SUCCESSED;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void processClick(View v) {
|
||||
switch (v.getId()){
|
||||
case R.id.tv_exchange:
|
||||
if (welfareNum>0){
|
||||
LayoutInflater inflater = LayoutInflater.from(this);
|
||||
RelativeLayout layout = (RelativeLayout) inflater.inflate(R.layout.dailog_videoexcheng, null);
|
||||
dialog1 = new AlertDialog.Builder(OnlineVideoExchangeActivity.this).create();
|
||||
TextView tv_infotitle = layout.findViewById(R.id.tv_infotitle);
|
||||
TextView tv_1 = layout.findViewById(R.id.tv_1);
|
||||
TextView tv_2 = layout.findViewById(R.id.tv_2);
|
||||
TextView tv_3 = layout.findViewById(R.id.tv_3);
|
||||
Button btn_sure1 = (Button) layout.findViewById(R.id.btn_sure);
|
||||
Button btn_cancel1 = (Button) layout.findViewById(R.id.btn_cancel);
|
||||
tv_infotitle.setText("温馨提示");
|
||||
tv_1.setText("您还可以免费下载精品课程"+welfareNum+"次,本次是否使用免费下载?");
|
||||
tv_2.setVisibility(View.GONE);
|
||||
tv_3.setVisibility(View.GONE);
|
||||
dialog1.show();
|
||||
Window window =dialog1.getWindow();
|
||||
// window.setGravity(Gravity.CENTER);
|
||||
WindowManager.LayoutParams layoutParams = window.getAttributes();
|
||||
layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
|
||||
layoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
|
||||
window.setAttributes(layoutParams);
|
||||
dialog1.getWindow().setContentView(layout);
|
||||
|
||||
btn_sure1.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
is_welfareNum = true;
|
||||
createSeriesVideoOrder();
|
||||
dialog1.dismiss();
|
||||
}
|
||||
});
|
||||
btn_cancel1.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
createSeriesVideoOrder();
|
||||
dialog1.dismiss();
|
||||
}
|
||||
});
|
||||
}else {
|
||||
createSeriesVideoOrder();
|
||||
}
|
||||
|
||||
break;
|
||||
case R.id.btn_sure:
|
||||
Map<String,String> map1 = new HashMap<>();
|
||||
map1.put("order_uuid",order_uuid);
|
||||
sendJsonPostParamtoNetSignMD5(Url.paySeriesVideoOrder,map1,PAYSERIESVIDEOORDER,OnlineVideoExchangeActivity.this);
|
||||
break;
|
||||
case R.id.btn_cancel:
|
||||
// Map<String,String> map2 = new HashMap<>();
|
||||
// map2.put("order_uuid",order_uuid);
|
||||
// sendJsonPostParamtoNetSignMD5(Url.cancleSeriesVideoOrder,map2,3,OnlineVideoExchangeActivity.this);
|
||||
//
|
||||
dialog.dismiss();
|
||||
// setResult(1,intent);
|
||||
// Intent intent2 = PolyvPlayerActivity.newIntent(OnlineVideoExchangeActivity.this, PolyvPlayerActivity.PlayMode.portrait, "");
|
||||
// intent2.putExtra("isVlmsOnline", false);
|
||||
// intent2.putExtra("series_type_uuid", series_type_uuid);
|
||||
// startActivity(intent2);
|
||||
// OnlineVideoExchangeActivity.this.finish();
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onCallbackFromThread(String resultJson) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCallBackFromThread(String resultJson, int resultCode) {
|
||||
Gson gson = new Gson();
|
||||
VideoOrderBean videoOrderBean = gson.fromJson(resultJson, VideoOrderBean.class);
|
||||
|
||||
switch (resultCode){
|
||||
case CREATESERIESVIDEOORDER://106积分不足
|
||||
LogUtil.i("CREATESERIESVIDEOORDER = "+resultJson);
|
||||
if (videoOrderBean.getCode().equals("200")){
|
||||
order_uuid = videoOrderBean.getOrder_uuid();
|
||||
if (is_welfareNum){
|
||||
useWelfareNum();
|
||||
}else {
|
||||
LayoutInflater inflater = LayoutInflater.from(this);
|
||||
RelativeLayout layout = (RelativeLayout) inflater.inflate(R.layout.dailog_videoexcheng, null);
|
||||
dialog = new AlertDialog.Builder(OnlineVideoExchangeActivity.this).create();
|
||||
TextView tv_2 = layout.findViewById(R.id.tv_2);
|
||||
Button btn_sure = (Button) layout.findViewById(R.id.btn_sure);
|
||||
Button btn_cancel = (Button) layout.findViewById(R.id.btn_cancel);
|
||||
tv_2.setText(price.replace("积分",""));
|
||||
dialog.show();
|
||||
Window window =dialog.getWindow();
|
||||
// window.setGravity(Gravity.CENTER);
|
||||
WindowManager.LayoutParams layoutParams = window.getAttributes();
|
||||
layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
|
||||
layoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
|
||||
window.setAttributes(layoutParams);
|
||||
dialog.getWindow().setContentView(layout);
|
||||
btn_sure.setOnClickListener(this);
|
||||
btn_cancel.setOnClickListener(this);
|
||||
}
|
||||
}else if (videoOrderBean.getCode().equals("106")){
|
||||
|
||||
dilaog2 = ECAlertDialog.buildAlert(OnlineVideoExchangeActivity.this,
|
||||
"您的积分不足,是否购买积分?", "取消", "确定", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dilaog2.dismiss();
|
||||
}
|
||||
}, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dilaog2.dismiss();
|
||||
startActivity(new Intent(OnlineVideoExchangeActivity.this,BuyIntegerActivty.class));
|
||||
}
|
||||
});
|
||||
dilaog2.setTitle("温馨提示");
|
||||
dilaog2.setCancelable(false);
|
||||
dilaog2.getWindow();
|
||||
dilaog2.show();
|
||||
// ToastUtil.showMessage("积分不足");
|
||||
}else {
|
||||
ToastUtil.showMessage("创建订单失败");
|
||||
}
|
||||
break;
|
||||
case PAYSERIESVIDEOORDER:
|
||||
LogUtil.i("PAYSERIESVIDEOORDER = "+resultJson);
|
||||
dialog.dismiss();
|
||||
if (videoOrderBean.getCode().equals("200")){
|
||||
Constant.fragmentHeight1=0;
|
||||
Constant.fragmentHeight2=0;
|
||||
Constant.fragmentHeight3=0;
|
||||
SharePrefUtil.saveInt(OnlineVideoExchangeActivity.this,"fragmentHeight1",0);
|
||||
LogUtil.i("SharePrefUtil OnlineVideoExchangeActivity = 0");
|
||||
setResult(1,intent);
|
||||
Intent intent2 = PolyvPlayerActivity.newIntent(OnlineVideoExchangeActivity.this, PolyvPlayerActivity.PlayMode.portrait, "");
|
||||
intent2.putExtra("isVlmsOnline", false);
|
||||
intent2.putExtra("series_type_uuid", series_type_uuid);
|
||||
startActivity(intent2);
|
||||
OnlineVideoExchangeActivity.this.finish();
|
||||
ToastUtil.showMessage("兑换成功");
|
||||
}else if (videoOrderBean.getCode().equals("106")) {
|
||||
dilaog2 = ECAlertDialog.buildAlert(OnlineVideoExchangeActivity.this,
|
||||
"您的积分不足,是否购买积分?", "取消", "确定", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dilaog2.dismiss();
|
||||
}
|
||||
}, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dilaog2.dismiss();
|
||||
startActivity(new Intent(OnlineVideoExchangeActivity.this,BuyIntegerActivty.class));
|
||||
}
|
||||
});
|
||||
dilaog2.setTitle("温馨提示");
|
||||
dilaog2.setCancelable(false);
|
||||
dilaog2.getWindow();
|
||||
dilaog2.show();
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
// LogUtil.i("取消订单 = "+resultJson);
|
||||
// if (videoOrderBean.getCode().equals("200")){
|
||||
// dialog.dismiss();
|
||||
// }
|
||||
break;
|
||||
case USEWELFARENUM://{"code":"1","message":"使用成功"}
|
||||
LogUtil.i("USEWELFARENUM = "+resultJson);
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject(resultJson);
|
||||
String code = jsonObject.optString("code");
|
||||
if("1".equals(code)){
|
||||
LogUtil.i("USEWELFARENUM = "+resultJson);
|
||||
Constant.fragmentHeight1=0;
|
||||
Constant.fragmentHeight2=0;
|
||||
Constant.fragmentHeight3=0;
|
||||
SharePrefUtil.saveInt(OnlineVideoExchangeActivity.this,"fragmentHeight1",0);
|
||||
LogUtil.i("SharePrefUtil OnlineVideoExchangeActivity = 0");
|
||||
setResult(1,intent);
|
||||
Intent intent2 = PolyvPlayerActivity.newIntent(OnlineVideoExchangeActivity.this, PolyvPlayerActivity.PlayMode.portrait, "");
|
||||
intent2.putExtra("isVlmsOnline", false);
|
||||
intent2.putExtra("series_type_uuid", series_type_uuid);
|
||||
startActivity(intent2);
|
||||
ToastUtil.showMessage("兑换成功");
|
||||
OnlineVideoExchangeActivity.this.finish();
|
||||
}else {
|
||||
ToastUtil.showMessage(jsonObject.optString("message"));
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
break;
|
||||
case GETWELFARENUM://{"WelfareNum":0,"code":"1","message":"查询成功"}
|
||||
LogUtil.i("GETWELFARENUM = "+resultJson);
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject(resultJson);
|
||||
welfareNum = jsonObject.optInt("WelfareNum");
|
||||
if(welfareNum>0){
|
||||
tv_exchange.setText("我要兑换"+"(剩余免费下载"+welfareNum+"次)");
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||
Map<String,String> map2 = new HashMap<>();
|
||||
map2.put("order_uuid",series_type_uuid);
|
||||
sendJsonPostParamtoNetSignMD5(Url.cancleSeriesVideoOrder,map2,3,OnlineVideoExchangeActivity.this);
|
||||
}
|
||||
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
import com.gyf.immersionbar.ImmersionBar;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import cn.shangyu.gdxzExpert.R;
|
||||
import cn.shangyu.gdxzExpert.polyvplayer.adapter.PolyvPlayerFragmentAdapter;
|
||||
import cn.shangyu.gdxzExpert.polyvplayer.fragment.PolyvDownloadFragment;
|
||||
import cn.shangyu.gdxzExpert.utils.CommonUtil;
|
||||
|
||||
/**
|
||||
* 离线缓存
|
||||
* */
|
||||
public class PolyvDownloadActivity extends FragmentActivity {
|
||||
private ViewPager vp_download;
|
||||
private List<Fragment> downloadFragments;
|
||||
private PolyvPlayerFragmentAdapter downloadAdapter;
|
||||
// 返回按钮
|
||||
private ImageView iv_finish;
|
||||
private TextView tv_downloaded, tv_downloading;
|
||||
|
||||
private PolyvDownloadFragment downloadedFragment;//已完成
|
||||
private PolyvDownloadFragment downloadingFragment;//缓存中
|
||||
private CheckBox top_right_text;
|
||||
|
||||
private void findIdAndNew() {
|
||||
vp_download = (ViewPager) findViewById(R.id.vp_download);
|
||||
iv_finish = (ImageView) findViewById(R.id.iv_finish);
|
||||
tv_downloaded = (TextView) findViewById(R.id.tv_downloaded);
|
||||
tv_downloading = (TextView) findViewById(R.id.tv_downloading);
|
||||
top_right_text = (CheckBox) findViewById(R.id.top_right_text);
|
||||
downloadFragments = new ArrayList<>();
|
||||
}
|
||||
|
||||
public PolyvDownloadFragment getDownloadedFragment() {
|
||||
return downloadedFragment;
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
Bundle bundle = new Bundle();
|
||||
downloadedFragment = new PolyvDownloadFragment(top_right_text);
|
||||
bundle.putBoolean("isFinished", true);
|
||||
downloadedFragment.setArguments(bundle);
|
||||
|
||||
downloadingFragment = new PolyvDownloadFragment(top_right_text);
|
||||
bundle = new Bundle();
|
||||
bundle.putBoolean("isFinished", false);
|
||||
downloadingFragment.setArguments(bundle);
|
||||
downloadFragments.add(downloadedFragment);
|
||||
downloadFragments.add(downloadingFragment);
|
||||
downloadAdapter = new PolyvPlayerFragmentAdapter(getSupportFragmentManager(), downloadFragments);
|
||||
vp_download.setAdapter(downloadAdapter);
|
||||
vp_download.setOffscreenPageLimit(1);
|
||||
vp_download.setPageMargin(30);
|
||||
vp_download.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
||||
@Override
|
||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageSelected(int position) {
|
||||
tv_downloading.setSelected(false);
|
||||
tv_downloaded.setSelected(false);
|
||||
if (position == 0) {
|
||||
tv_downloaded.setSelected(true);
|
||||
} else if (position == 1) {
|
||||
tv_downloading.setSelected(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageScrollStateChanged(int state) {
|
||||
}
|
||||
});
|
||||
|
||||
iv_finish.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent();
|
||||
setResult(101,intent);
|
||||
finish();
|
||||
}
|
||||
});
|
||||
tv_downloaded.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
vp_download.setCurrentItem(0);
|
||||
}
|
||||
});
|
||||
tv_downloading.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
vp_download.setCurrentItem(1);
|
||||
}
|
||||
});
|
||||
|
||||
final boolean isStarting = getIntent().getBooleanExtra("isStarting", false);
|
||||
if (isStarting) {
|
||||
tv_downloading.setSelected(true);
|
||||
} else {
|
||||
tv_downloaded.setSelected(true);
|
||||
}
|
||||
vp_download.setCurrentItem(isStarting ? 1 : 0);
|
||||
|
||||
top_right_text.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
if (isChecked){
|
||||
top_right_text.setText("取消");
|
||||
downloadedFragment.setEdit(true);
|
||||
downloadingFragment.setEdit(true);
|
||||
}else {
|
||||
top_right_text.setText("编辑");
|
||||
downloadedFragment.setEdit(false);
|
||||
downloadingFragment.setEdit(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (keyCode==KeyEvent.KEYCODE_BACK){
|
||||
Intent intent = new Intent();
|
||||
setResult(101,intent);
|
||||
}
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if(CommonUtil.BigModule())
|
||||
{
|
||||
setContentView(R.layout.polyv_activity_downlaod_big);
|
||||
}
|
||||
else
|
||||
{
|
||||
setContentView(R.layout.polyv_activity_downlaod);
|
||||
}
|
||||
Toolbar toolbar=findViewById(R.id.toolbar);
|
||||
ImmersionBar.with(this).keyboardEnable(true).statusBarDarkFont(true).titleBar(toolbar).init();
|
||||
findIdAndNew();
|
||||
initView();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,221 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer;
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.provider.Settings;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
||||
/**
|
||||
* Polyv权限
|
||||
* targetSdkVersion 设置了23或以上需要实现运行时权限功能,否则无法播放视频
|
||||
*/
|
||||
public class PolyvPermission {
|
||||
private ResponseCallback responseCallback = null;
|
||||
private Activity activity = null;
|
||||
|
||||
public enum OperationType {
|
||||
play(100),
|
||||
download(101),
|
||||
upload(102),
|
||||
playAndDownload(103),
|
||||
readImei(104);
|
||||
|
||||
private final int num;
|
||||
private OperationType(int num) {
|
||||
this.num = num;
|
||||
}
|
||||
|
||||
public int getNum() {
|
||||
return num;
|
||||
}
|
||||
|
||||
public static OperationType getOperationType(int num) {
|
||||
if (num == play.getNum()) {
|
||||
return play;
|
||||
} else if (num == download.getNum()) {
|
||||
return download;
|
||||
} else if (num == readImei.getNum()) {
|
||||
return readImei;
|
||||
} else if (num == upload.getNum()) {
|
||||
return upload;
|
||||
} else if (num == playAndDownload.getNum()) {
|
||||
return playAndDownload;
|
||||
}
|
||||
|
||||
return play;
|
||||
}
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.M)
|
||||
public void applyPermission(Activity activity, OperationType type) {
|
||||
this.activity = activity;
|
||||
if (!canMakeSmores()) {
|
||||
if (responseCallback != null) {
|
||||
responseCallback.callback(type);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
ArrayList<String> permissions = new ArrayList<>();
|
||||
int resultCode = 0;
|
||||
switch (type) {
|
||||
case play:
|
||||
//播放视频需要的权限
|
||||
permissions.add(Manifest.permission.READ_PHONE_STATE);
|
||||
//投屏功能在android9.0获取wifi名称及搜索设备所需的权限
|
||||
permissions.add(Manifest.permission.ACCESS_COARSE_LOCATION);
|
||||
permissions.add(Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
resultCode = OperationType.play.getNum();
|
||||
break;
|
||||
case readImei:
|
||||
permissions.add(Manifest.permission.READ_PHONE_STATE);
|
||||
resultCode = OperationType.readImei.getNum();
|
||||
break;
|
||||
case download:
|
||||
//下载需要的权限
|
||||
permissions.add(Manifest.permission.READ_PHONE_STATE);
|
||||
permissions.add(Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
resultCode = OperationType.download.getNum();
|
||||
break;
|
||||
case upload:
|
||||
//上传需要的权限
|
||||
permissions.add(Manifest.permission.READ_PHONE_STATE);
|
||||
permissions.add(Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
resultCode = OperationType.upload.getNum();
|
||||
break;
|
||||
case playAndDownload:
|
||||
//播放视频和下载需要的权限
|
||||
permissions.add(Manifest.permission.READ_PHONE_STATE);
|
||||
permissions.add(Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
resultCode = OperationType.playAndDownload.getNum();
|
||||
break;
|
||||
}
|
||||
|
||||
//筛选出我们已经接受的权限
|
||||
/* 请求的权限列表 */
|
||||
ArrayList<String> permissionsToRequest = findUnAskedPermissions(permissions);
|
||||
//get the permissions we have asked for before but are not granted..
|
||||
//we will store this in a global list to access later.
|
||||
/* 拒绝的权限列表 */
|
||||
ArrayList<String> permissionsRejected = findRejectedPermissions(permissions);
|
||||
|
||||
if(permissionsToRequest.size()>0){//we need to ask for permissions
|
||||
//but have we already asked for them?
|
||||
activity.requestPermissions(permissionsToRequest.toArray(new String[permissionsToRequest.size()]), resultCode);
|
||||
}else{
|
||||
if(permissionsRejected.size()>0){
|
||||
for (int i = 0; i < permissionsRejected.size() ; i++) {
|
||||
if (!ActivityCompat.shouldShowRequestPermissionRationale(activity, permissionsRejected.get(i))) {
|
||||
Toast.makeText(activity, "点击权限,并打开全部权限", Toast.LENGTH_LONG).show();
|
||||
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
|
||||
intent.setData(Uri.fromParts("package", activity.getPackageName(), null));
|
||||
activity.startActivityForResult(intent, type.getNum());
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (responseCallback != null) {
|
||||
responseCallback.callback(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean operationHasPermission(int num) {
|
||||
OperationType operationType = OperationType.getOperationType(num);
|
||||
if (operationType == null) return false;
|
||||
switch (operationType) {
|
||||
case play:
|
||||
return hasPermission(Manifest.permission.READ_PHONE_STATE)
|
||||
&& hasPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
case download:
|
||||
return hasPermission(Manifest.permission.READ_PHONE_STATE)
|
||||
&& hasPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
case upload:
|
||||
return hasPermission(Manifest.permission.READ_PHONE_STATE)
|
||||
&& hasPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
case playAndDownload:
|
||||
return hasPermission(Manifest.permission.READ_PHONE_STATE)
|
||||
&& hasPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* method that will return whether the permission is accepted. By default it is true if the user is using a device below
|
||||
* version 23
|
||||
* @param permission
|
||||
* @return
|
||||
*/
|
||||
@TargetApi(Build.VERSION_CODES.M)
|
||||
private boolean hasPermission(String permission) {
|
||||
if (canMakeSmores()) {
|
||||
return(activity.checkSelfPermission(permission)== PackageManager.PERMISSION_GRANTED);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is used to determine the permissions we do not have accepted yet and ones that we have not already
|
||||
* bugged the user about. This comes in handle when you are asking for multiple permissions at once.
|
||||
* @param wanted
|
||||
* @return
|
||||
*/
|
||||
private ArrayList<String> findUnAskedPermissions(ArrayList<String> wanted) {
|
||||
ArrayList<String> result = new ArrayList<>();
|
||||
for (String perm : wanted) {
|
||||
if (!hasPermission(perm)) {
|
||||
result.add(perm);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* this will return us all the permissions we have previously asked for but
|
||||
* currently do not have permission to use. This may be because they declined us
|
||||
* or later revoked our permission. This becomes useful when you want to tell the user
|
||||
* what permissions they declined and why they cannot use a feature.
|
||||
* @param wanted
|
||||
* @return
|
||||
*/
|
||||
private ArrayList<String> findRejectedPermissions(ArrayList<String> wanted) {
|
||||
ArrayList<String> result = new ArrayList<>();
|
||||
for (String perm : wanted) {
|
||||
if (!hasPermission(perm)) {
|
||||
result.add(perm);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Just a check to see if we have marshmallows (version 23)
|
||||
* @return
|
||||
*/
|
||||
public static boolean canMakeSmores() {
|
||||
return(Build.VERSION.SDK_INT>Build.VERSION_CODES.LOLLIPOP_MR1);
|
||||
}
|
||||
|
||||
public void setResponseCallback(ResponseCallback responseCallback) {
|
||||
this.responseCallback = responseCallback;
|
||||
}
|
||||
|
||||
public interface ResponseCallback {
|
||||
void callback(@NonNull OperationType type);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,337 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.gyf.immersionbar.ImmersionBar;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import cn.shangyu.gdxzExpert.R;
|
||||
import cn.shangyu.gdxzExpert.base.BaseActivity;
|
||||
import cn.shangyu.gdxzExpert.bean.ListFreeBean;
|
||||
import cn.shangyu.gdxzExpert.bean.ListSeriesTypeBean;
|
||||
import cn.shangyu.gdxzExpert.bean.SeriesVideoNewsListBean;
|
||||
import cn.shangyu.gdxzExpert.big.activity.BigPointsMallActivity;
|
||||
import cn.shangyu.gdxzExpert.http.OnCallBackFromNet;
|
||||
import cn.shangyu.gdxzExpert.pointsmall.BuyIntegerActivty;
|
||||
import cn.shangyu.gdxzExpert.pointsmall.IntegralTicketActivity;
|
||||
import cn.shangyu.gdxzExpert.pointsmall.PointsMallActivity;
|
||||
import cn.shangyu.gdxzExpert.polyvplayer.adapter.ExchangeAdapter;
|
||||
import cn.shangyu.gdxzExpert.pulltorefreshview.PullToRefreshListView;
|
||||
import cn.shangyu.gdxzExpert.ui.CustomProgressDialog;
|
||||
import cn.shangyu.gdxzExpert.utils.CommonUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.LogUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.ToastUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.UIUtils;
|
||||
import cn.shangyu.gdxzExpert.utils.Url;
|
||||
import cn.shangyu.gdxzExpert.view.RollViewPager;
|
||||
import cn.shangyu.gdxzExpert.widget.LoadingPage;
|
||||
|
||||
import static cn.shangyu.gdxzExpert.utils.CommonUtil.BigModule;
|
||||
|
||||
/**
|
||||
* Created by WANGChengXin on 2019/3/25.
|
||||
*/
|
||||
|
||||
public class QualityCourseActivity extends BaseActivity implements OnCallBackFromNet{
|
||||
private CustomProgressDialog pd;
|
||||
private LinearLayout top_news_viewpager;
|
||||
private LinearLayout dots_ll;
|
||||
private PullToRefreshListView lv_exchange;
|
||||
private LinearLayout headerView;
|
||||
public static final int FREE=1;
|
||||
public static final int EXCHANGE=2;
|
||||
public static final int NEWS=3;
|
||||
private RelativeLayout rl_exchange,rl_free;
|
||||
private ListSeriesTypeBean listSeriesTypeBean;
|
||||
private ListFreeBean listFreeBean;
|
||||
private LinearLayout ll_free2,ll_free1;
|
||||
private TextView tv_free1,tv_free2;
|
||||
private SeriesVideoNewsListBean seriesVideoNewsListBean;
|
||||
private RollViewPager mViewPager;
|
||||
private ArrayList<View> dotList;
|
||||
private View free_line;
|
||||
private LinearLayout ll_jifenshop,ll_integraltickit,ll_buy_point;
|
||||
@Override
|
||||
public void setTitle() {
|
||||
top_title.setText("精品课程");
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateSuccessedView() {
|
||||
ImmersionBar.with(this).keyboardEnable(true).statusBarDarkFont(true).titleBar(mToolbar).init();
|
||||
View view = UIUtils.inflate(R.layout.activity_qualitycourse);
|
||||
lv_exchange = view.findViewById(R.id.lv_exchange);
|
||||
ll_jifenshop = view.findViewById(R.id.ll_point_shop);
|
||||
ll_integraltickit = view.findViewById(R.id.ll_integraltickit);
|
||||
ll_buy_point = view.findViewById(R.id.ll_buy_point);
|
||||
headerView = (LinearLayout) getLayoutInflater().inflate(R.layout.activity_qualitycourse_header, null);
|
||||
initView(headerView);
|
||||
ListView refreshableView = lv_exchange.getRefreshableView();
|
||||
refreshableView.addHeaderView(headerView);
|
||||
pd = new CustomProgressDialog(this, "请稍候");
|
||||
pd.show();
|
||||
initOnClick();
|
||||
getData();
|
||||
return view;
|
||||
}
|
||||
|
||||
private void initOnClick() {
|
||||
rl_exchange.setOnClickListener(this);
|
||||
rl_free.setOnClickListener(this);
|
||||
ll_free1.setOnClickListener(this);
|
||||
ll_free2.setOnClickListener(this);
|
||||
ll_jifenshop.setOnClickListener(this);
|
||||
ll_buy_point.setOnClickListener(this);
|
||||
ll_integraltickit.setOnClickListener(this);
|
||||
lv_exchange.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
int i = position - 2;
|
||||
String uuid = listSeriesTypeBean.getData().getList().get(i).getUuid();
|
||||
Intent intent = PolyvPlayerActivity.newIntent(QualityCourseActivity.this, PolyvPlayerActivity.PlayMode.portrait, "");
|
||||
intent.putExtra("isVlmsOnline", false);
|
||||
intent.putExtra("series_type_uuid", uuid);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void getData() {
|
||||
Map<String,String> map = new HashMap<>();
|
||||
map.put("page","1");
|
||||
map.put("title","");
|
||||
map.put("keywords","");
|
||||
map.put("sort","");
|
||||
sendJsonPostParamtoNetSignMD5(Url.listSeriesType,map,EXCHANGE,this);
|
||||
|
||||
Map<String,String> map1 = new HashMap<>();
|
||||
map1.put("page","1");
|
||||
map1.put("title","");
|
||||
map1.put("keywords","");
|
||||
map1.put("sort","2");
|
||||
sendJsonPostParamtoNetSignMD5(Url.listFree,map1,FREE,this);
|
||||
|
||||
|
||||
Map<String,String> map2 = new HashMap<>();
|
||||
sendJsonPostParamtoNetSignMD5(Url.SeriesVideoNewsList,map2,NEWS,this);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void initView(View view) {
|
||||
top_news_viewpager = (LinearLayout) view.findViewById(R.id.top_news_viewpager);
|
||||
dots_ll = (LinearLayout) view.findViewById(R.id.dots_ll);
|
||||
rl_exchange = view.findViewById(R.id.rl_exchange);
|
||||
rl_free = view.findViewById(R.id.rl_free);
|
||||
ll_free2 = view.findViewById(R.id.ll_free2);
|
||||
ll_free1 = view.findViewById(R.id.ll_free1);
|
||||
tv_free1 = view.findViewById(R.id.tv_free1);
|
||||
tv_free2 = view.findViewById(R.id.tv_free2);
|
||||
free_line = view.findViewById(R.id.free_line);
|
||||
|
||||
top_news_viewpager.setFocusable(true);
|
||||
top_news_viewpager.setFocusableInTouchMode(true);
|
||||
top_news_viewpager.requestFocus();
|
||||
int width =getResources().getDisplayMetrics().widthPixels;
|
||||
// int height = CommonUtil.dip2px(mActivity, 180);
|
||||
int height = width * 320 / 640;
|
||||
if (width < 720) {
|
||||
height = width * 7 / 16 - 10;
|
||||
// height = width/2;
|
||||
|
||||
}
|
||||
android.view.ViewGroup.LayoutParams ivLp = top_news_viewpager
|
||||
.getLayoutParams();
|
||||
ivLp.width = width;
|
||||
ivLp.height = height;
|
||||
top_news_viewpager.setLayoutParams(ivLp);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoadingPage.ResultState onLoad() {
|
||||
return LoadingPage.ResultState.STATE_SUCCESSED;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void processClick(View v) {
|
||||
switch (v.getId()){
|
||||
case R.id.rl_exchange:
|
||||
Intent intent = new Intent(QualityCourseActivity.this, ExchangeAreaActivity.class);
|
||||
startActivity(intent);
|
||||
break;
|
||||
case R.id.rl_free:
|
||||
startActivity(new Intent(QualityCourseActivity.this,FreeAreaActivity.class));
|
||||
break;
|
||||
case R.id.ll_free1:
|
||||
intent = PolyvPlayerActivity.newIntent(QualityCourseActivity.this, PolyvPlayerActivity.PlayMode.portrait, listFreeBean.getData().getList().get(0).getPolyv_uuid());
|
||||
intent.putExtra("startNow", true);
|
||||
intent.putExtra("isVlmsOnline", false);
|
||||
intent.putExtra("series_type_uuid", listFreeBean.getData().getList().get(0).getSeries_type_uuid());
|
||||
intent.putExtra("uuid", listFreeBean.getData().getList().get(0).getUuid());
|
||||
startActivity(intent);
|
||||
break;
|
||||
case R.id.ll_free2:
|
||||
intent = PolyvPlayerActivity.newIntent(QualityCourseActivity.this, PolyvPlayerActivity.PlayMode.portrait,listFreeBean.getData().getList().get(1).getPolyv_uuid());
|
||||
intent.putExtra("isVlmsOnline", false);
|
||||
intent.putExtra("startNow", true);
|
||||
intent.putExtra("series_type_uuid", listFreeBean.getData().getList().get(1).getSeries_type_uuid());
|
||||
intent.putExtra("uuid", listFreeBean.getData().getList().get(1).getUuid());
|
||||
startActivity(intent);
|
||||
break;
|
||||
case R.id.ll_point_shop://积分商城
|
||||
if(BigModule())
|
||||
{
|
||||
Intent intent3 = new Intent(QualityCourseActivity.this, BigPointsMallActivity.class);
|
||||
startActivity(intent3);
|
||||
}
|
||||
else
|
||||
{
|
||||
Intent intent3 = new Intent(QualityCourseActivity.this, PointsMallActivity.class);
|
||||
startActivity(intent3);
|
||||
}
|
||||
|
||||
break;
|
||||
case R.id.ll_integraltickit://积分券
|
||||
Intent intent1 = new Intent(QualityCourseActivity.this, IntegralTicketActivity.class);
|
||||
startActivity(intent1);
|
||||
break;
|
||||
case R.id.ll_buy_point://购买积分
|
||||
Intent intent2 = new Intent(QualityCourseActivity.this, BuyIntegerActivty.class);
|
||||
startActivity(intent2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCallbackFromThread(String resultJson) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCallBackFromThread(String resultJson, int resultCode) {
|
||||
pd.dismiss();
|
||||
switch (resultCode){
|
||||
case EXCHANGE:
|
||||
LogUtil.i("EXCHANGE = "+resultJson);
|
||||
Gson gson = new Gson();
|
||||
listSeriesTypeBean = gson.fromJson(resultJson, ListSeriesTypeBean.class);
|
||||
if (listSeriesTypeBean.getData()!=null){
|
||||
|
||||
ExchangeAdapter adapter = null;
|
||||
if (listSeriesTypeBean.getData().getList().size()>=3){
|
||||
List<ListSeriesTypeBean.DataBean.ListBean> list = new ArrayList<>();
|
||||
for (int i = 0;i<3;i++){
|
||||
list.add(listSeriesTypeBean.getData().getList().get(i));
|
||||
adapter = new ExchangeAdapter(QualityCourseActivity.this,list);
|
||||
}
|
||||
}else {
|
||||
adapter = new ExchangeAdapter(QualityCourseActivity.this,listSeriesTypeBean.getData().getList());
|
||||
}
|
||||
|
||||
lv_exchange.setAdapter(adapter);
|
||||
}
|
||||
break;
|
||||
case FREE:
|
||||
LogUtil.i("FREE = "+resultJson);
|
||||
Gson gson1 = new Gson();
|
||||
listFreeBean = gson1.fromJson(resultJson, ListFreeBean.class);
|
||||
if (listFreeBean.getData()!=null){
|
||||
if (listFreeBean.getData().getList().size()==0){
|
||||
rl_free.setVisibility(View.GONE);
|
||||
ll_free2.setVisibility(View.GONE);
|
||||
ll_free1.setVisibility(View.GONE);
|
||||
free_line.setVisibility(View.GONE);
|
||||
}else if (listFreeBean.getData().getList().size()>1){
|
||||
ll_free2.setVisibility(View.VISIBLE);
|
||||
tv_free1.setText(listFreeBean.getData().getList().get(0).getTitle());
|
||||
tv_free2.setText(listFreeBean.getData().getList().get(1).getTitle());
|
||||
}else {
|
||||
tv_free1.setText(listFreeBean.getData().getList().get(0).getTitle());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
case NEWS:
|
||||
LogUtil.i("NEWS = "+resultJson);
|
||||
Gson gson3 = new Gson();
|
||||
seriesVideoNewsListBean = gson3.fromJson(resultJson, SeriesVideoNewsListBean.class);
|
||||
if (seriesVideoNewsListBean!=null&&"200".equals(seriesVideoNewsListBean.getCode())&&seriesVideoNewsListBean.getData().size()!=0) {
|
||||
// 轮播图的点
|
||||
initDot(seriesVideoNewsListBean.getData().size());
|
||||
mViewPager = new RollViewPager(QualityCourseActivity.this, dotList,
|
||||
R.drawable.dot_white, R.drawable.dot_normal,
|
||||
// 轮播图点击事件
|
||||
new RollViewPager.OnPagerClickCallback() {
|
||||
@Override
|
||||
public void onPagerClick(int position) {
|
||||
Intent intent = PolyvPlayerActivity.newIntent(QualityCourseActivity.this, PolyvPlayerActivity.PlayMode.portrait, "");
|
||||
intent.putExtra("isVlmsOnline", false);
|
||||
intent.putExtra("series_type_uuid",seriesVideoNewsListBean.getData().get(position).getUuid());
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
mViewPager.setLayoutParams(new LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
|
||||
// top图片地址
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
for (int i = 0; i < seriesVideoNewsListBean.getData().size(); i++) {
|
||||
list.add(Url.urlHtml+seriesVideoNewsListBean.getData().get(i).getImg());
|
||||
}
|
||||
mViewPager.setUriList(list);
|
||||
// 开始滚动
|
||||
mViewPager.startRoll();
|
||||
// top标题
|
||||
// mViewPager.setTitle(topNewsTitle, seriesVideoNewsListBean);
|
||||
// 加载到布局
|
||||
top_news_viewpager.removeAllViews();
|
||||
top_news_viewpager.addView(mViewPager);
|
||||
|
||||
}else {
|
||||
ToastUtil.showMessage("请求失败");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 实例化轮播图点 initDot
|
||||
*
|
||||
* @param size
|
||||
* void
|
||||
*/
|
||||
private void initDot(int size) {
|
||||
dotList = new ArrayList<View>();
|
||||
dots_ll.removeAllViews();
|
||||
for (int i = 0; i < size; i++) {
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
|
||||
CommonUtil.dip2px(this, 6), CommonUtil.dip2px(
|
||||
this, 6));
|
||||
params.setMargins(10, 0, 5, 0);
|
||||
View m = new View(this);
|
||||
if (i == 0) {
|
||||
m.setBackgroundResource(R.drawable.dot_white);
|
||||
} else {
|
||||
m.setBackgroundResource(R.drawable.dot_normal);
|
||||
}
|
||||
m.setLayoutParams(params);
|
||||
dots_ll.addView(m);
|
||||
dotList.add(m);
|
||||
}
|
||||
}
|
||||
}
|
||||
+3995
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,468 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer;
|
||||
|
||||
|
||||
import android.content.Intent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.gyf.immersionbar.ImmersionBar;
|
||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import cn.shangyu.gdxzExpert.R;
|
||||
import cn.shangyu.gdxzExpert.base.BaseActivity;
|
||||
import cn.shangyu.gdxzExpert.bean.BaseBean;
|
||||
import cn.shangyu.gdxzExpert.bean.VideoWatchRecordBean;
|
||||
import cn.shangyu.gdxzExpert.http.OnCallBackFromNet;
|
||||
import cn.shangyu.gdxzExpert.pulltorefreshview.PullToRefreshBase;
|
||||
import cn.shangyu.gdxzExpert.pulltorefreshview.PullToRefreshListView;
|
||||
import cn.shangyu.gdxzExpert.ui.CustomProgressDialog;
|
||||
import cn.shangyu.gdxzExpert.utils.CommonUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.DialogUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.ImageOptions;
|
||||
import cn.shangyu.gdxzExpert.utils.LogUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.StringUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.ToastUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.UIUtils;
|
||||
import cn.shangyu.gdxzExpert.utils.Url;
|
||||
import cn.shangyu.gdxzExpert.view.RoundImageView;
|
||||
import cn.shangyu.gdxzExpert.widget.LoadingPage;
|
||||
|
||||
/**
|
||||
* Created by WANGChengXin on 2019/10/30.
|
||||
* 观看历史
|
||||
*/
|
||||
|
||||
public class VideohistoryActivity extends BaseActivity implements OnCallBackFromNet,AdapterView.OnItemClickListener{
|
||||
private View view;
|
||||
private PullToRefreshListView lv_exchange;
|
||||
private int page = 1;
|
||||
public static final int VIDEOWATCHRECORD = 200;
|
||||
public static final int DELETERECORD = 201;
|
||||
private VideoWatchRecordBean videoWatchRecordBean;
|
||||
private List<VideoWatchRecordBean.DataBean.ListBean> data = new ArrayList<VideoWatchRecordBean.DataBean.ListBean>();
|
||||
private VideoHistoryAdapter adapter;
|
||||
private RelativeLayout rl_bot;
|
||||
private boolean flag;
|
||||
private TextView tv_all;
|
||||
private TextView tv_deleteall;
|
||||
private View ll_empty;
|
||||
|
||||
@Override
|
||||
public void setTitle() {
|
||||
top_title.setText("观看历史");
|
||||
top_right_text.setText("编辑");
|
||||
top_right_text.setVisibility(View.VISIBLE);
|
||||
if(CommonUtil.BigModule())
|
||||
{
|
||||
top_title.setTextSize(23);
|
||||
top_right_text.setTextSize(18);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateSuccessedView() {
|
||||
ImmersionBar.with(this).keyboardEnable(true).statusBarDarkFont(true).titleBar(mToolbar).init();
|
||||
if(CommonUtil.BigModule())
|
||||
{
|
||||
view = UIUtils.inflate(R.layout.activity_videohistory_big);
|
||||
}
|
||||
else
|
||||
{
|
||||
view = UIUtils.inflate(R.layout.activity_videohistory);
|
||||
}
|
||||
lv_exchange = view.findViewById(R.id.lv_exchange);
|
||||
rl_bot = view.findViewById(R.id.rl_bot);
|
||||
tv_all = view.findViewById(R.id.tv_all);
|
||||
tv_deleteall = view.findViewById(R.id.tv_deleteall);
|
||||
lv_exchange.setMode(PullToRefreshBase.Mode.BOTH);
|
||||
TextView tv_empty_msg = (TextView) view.findViewById(R.id.tv_empty_msg);
|
||||
tv_empty_msg.setText("暂无观看历史");
|
||||
ll_empty = view.findViewById(R.id.ll_empty);
|
||||
lv_exchange.getRefreshableView().setEmptyView(ll_empty);
|
||||
dialog = (CustomProgressDialog) DialogUtil.createProgressDialog(this,
|
||||
"加载中");
|
||||
|
||||
tv_all.setOnClickListener(this);
|
||||
tv_deleteall.setOnClickListener(this);
|
||||
getVideoWatchRecord();
|
||||
lv_exchange.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener2() {
|
||||
|
||||
@Override
|
||||
public void onPullDownToRefresh(PullToRefreshBase refreshView) {
|
||||
|
||||
|
||||
page = 1;
|
||||
getVideoWatchRecord();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPullUpToRefresh(PullToRefreshBase refreshView) {
|
||||
|
||||
page++;
|
||||
getVideoWatchRecord();
|
||||
|
||||
}
|
||||
});
|
||||
lv_exchange.setOnItemClickListener(this);
|
||||
return view;
|
||||
}
|
||||
|
||||
private void getVideoWatchRecord() {
|
||||
dialog.show();
|
||||
Map<String,String> map = new HashMap<>();
|
||||
map.put("page",page+"");
|
||||
sendJsonPostParamtoNetSignMD5(Url.VideoWatchRecord,map,VIDEOWATCHRECORD,VideohistoryActivity.this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoadingPage.ResultState onLoad() {
|
||||
return LoadingPage.ResultState.STATE_SUCCESSED;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void processClick(View v) {
|
||||
switch (v.getId()){
|
||||
case R.id.top_right_text:
|
||||
if(flag){
|
||||
top_right_text.setText("编辑");
|
||||
flag = false;
|
||||
rl_bot.setVisibility(View.GONE);
|
||||
}else {
|
||||
top_right_text.setText("取消");
|
||||
for (int i = 0;i<data.size();i++){
|
||||
data.get(i).setStatus(98);
|
||||
}
|
||||
tv_deleteall.setText("删除");
|
||||
tv_all.setText("全选");
|
||||
flag = true;
|
||||
rl_bot.setVisibility(View.VISIBLE);
|
||||
}
|
||||
adapter.notifyDataSetChanged();
|
||||
break;
|
||||
case R.id.tv_all:
|
||||
if ("全选".equals(tv_all.getText().toString())){
|
||||
for (int i = 0;i<data.size();i++){
|
||||
data.get(i).setStatus(99);
|
||||
}
|
||||
tv_deleteall.setText("删除("+data.size()+")");
|
||||
tv_all.setText("取消全选");
|
||||
}else {
|
||||
for (int i = 0;i<data.size();i++){
|
||||
data.get(i).setStatus(98);
|
||||
}
|
||||
tv_deleteall.setText("删除");
|
||||
tv_all.setText("全选");
|
||||
}
|
||||
|
||||
adapter.notifyDataSetChanged();
|
||||
break;
|
||||
case R.id.tv_deleteall:
|
||||
|
||||
StringBuffer uuid = new StringBuffer();
|
||||
for(int i = 0;i<data.size();i++){
|
||||
if (data.get(i).getStatus()==99){
|
||||
|
||||
if (StringUtil.isEmpty(uuid.toString())){
|
||||
uuid.append(data.get(i).getVideo_uuid());
|
||||
}else {
|
||||
uuid.append(","+data.get(i).getVideo_uuid());
|
||||
}
|
||||
}
|
||||
}
|
||||
LogUtil.i("video_uuid = "+uuid.toString());
|
||||
if (!StringUtil.isEmpty(uuid.toString())){
|
||||
Map<String,String> map = new HashMap<>();
|
||||
map.put("video_uuid",uuid.toString());
|
||||
sendJsonPostParamtoNetSignMD5(Url.deleteRecord,map,DELETERECORD,VideohistoryActivity.this);
|
||||
}else{
|
||||
ToastUtil.showMessage("请选择需要删除的记录");
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCallbackFromThread(String resultJson) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCallBackFromThread(String resultJson, int resultCode) {
|
||||
dialog.dismiss();
|
||||
switch (resultCode){
|
||||
case VIDEOWATCHRECORD:
|
||||
LogUtil.i("VIDEOWATCHRECORD = "+resultJson);
|
||||
Gson gsonuse = new Gson();
|
||||
videoWatchRecordBean = gsonuse.fromJson(resultJson, VideoWatchRecordBean.class);
|
||||
if ("200".equals(videoWatchRecordBean.getCode())){
|
||||
// 判断是下拉刷新还是加载更多
|
||||
if (page == 1) {
|
||||
data.clear();
|
||||
if (videoWatchRecordBean.getData() == null || videoWatchRecordBean.getData().getList().size()==0) {
|
||||
// 显示空布局
|
||||
ll_empty.setVisibility(View.VISIBLE);
|
||||
top_right_text.setVisibility(View.GONE);
|
||||
// 完成刷新
|
||||
onLoaded();
|
||||
return;
|
||||
} else {
|
||||
lv_exchange.setVisibility(View.VISIBLE);
|
||||
data.addAll(videoWatchRecordBean.getData().getList());
|
||||
}
|
||||
} else {
|
||||
data.addAll(videoWatchRecordBean.getData().getList());
|
||||
}
|
||||
int k = 0;
|
||||
for (int i = 0;i<data.size();i++){
|
||||
if (data.get(i).getStatus()==99){
|
||||
k++;
|
||||
}
|
||||
}
|
||||
if (k==0){
|
||||
tv_deleteall.setText("删除");
|
||||
}else{
|
||||
tv_deleteall.setText("删除("+k+")");
|
||||
}
|
||||
if (adapter == null){
|
||||
adapter = new VideoHistoryAdapter();
|
||||
lv_exchange.setAdapter(adapter);
|
||||
}else {
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
// 完成刷新
|
||||
onLoaded();
|
||||
|
||||
if (page > 1) {
|
||||
// 是否有更多
|
||||
if (videoWatchRecordBean.getData() == null || videoWatchRecordBean.getData().getList().size()==0) {// 由于暂时虚构没数据,所以加载更多也没数据
|
||||
ToastUtil.showMessage("没有更多了");
|
||||
lv_exchange.setMode(PullToRefreshBase.Mode.PULL_FROM_START);
|
||||
if (page > 1)
|
||||
page--;
|
||||
} else {
|
||||
lv_exchange.setMode(PullToRefreshBase.Mode.BOTH);
|
||||
}
|
||||
} else if (page == 1) {
|
||||
// 得到总页码数
|
||||
int totalPage = videoWatchRecordBean.getData().getTotal();
|
||||
if (totalPage <= 1 || totalPage < page) {
|
||||
lv_exchange.setMode(PullToRefreshBase.Mode.PULL_FROM_START);
|
||||
} else {
|
||||
lv_exchange.setMode(PullToRefreshBase.Mode.BOTH);
|
||||
}
|
||||
} else {
|
||||
lv_exchange.setMode(PullToRefreshBase.Mode.BOTH);
|
||||
}
|
||||
|
||||
// 设置刷新的时间
|
||||
setLastUpdateTime();
|
||||
}
|
||||
break;
|
||||
case DELETERECORD:
|
||||
LogUtil.i("DELETERECORD = "+resultJson);
|
||||
Gson gsonuse1 = new Gson();
|
||||
BaseBean baseBean = gsonuse1.fromJson(resultJson, BaseBean.class);
|
||||
if ("200".equals(baseBean.code)){
|
||||
getVideoWatchRecord();
|
||||
top_right_text.setText("编辑");
|
||||
flag = false;
|
||||
rl_bot.setVisibility(View.GONE);
|
||||
}
|
||||
ToastUtil.showMessage(baseBean.message);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void setLastUpdateTime() {
|
||||
String text = CommonUtil.getStringDate();
|
||||
lv_exchange.getLoadingLayoutProxy().setLastUpdatedLabel(text);
|
||||
}
|
||||
|
||||
private void onLoaded() {
|
||||
dismissLoadingProgress();
|
||||
if (lv_exchange != null) {
|
||||
lv_exchange.onRefreshComplete();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
// Intent intent = VideoDetailPolyvPlayerActivity.newIntent(VideohistoryActivity.this, VideoDetailPolyvPlayerActivity.PlayMode.portrait, "");
|
||||
// intent.putExtra("startNow", false);
|
||||
// intent.putExtra("isVlmsOnline", false);
|
||||
// intent.putExtra("uuid", data.get(position - 1).getVideo_uuid());
|
||||
// startActivity(intent);
|
||||
}
|
||||
|
||||
class VideoHistoryAdapter extends BaseAdapter{
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return data.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
return data.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
final Holder holder;
|
||||
if (convertView == null) {
|
||||
holder = new Holder();
|
||||
if(CommonUtil.BigModule())
|
||||
{
|
||||
convertView = UIUtils.inflate(R.layout.item_video_history_big);
|
||||
}
|
||||
else
|
||||
{
|
||||
convertView = UIUtils.inflate(R.layout.item_video_history);
|
||||
}
|
||||
holder.iv_start = convertView.findViewById(R.id.iv_start);
|
||||
holder.tv_author = convertView.findViewById(R.id.tv_author);
|
||||
holder.tv_title = convertView.findViewById(R.id.tv_title);
|
||||
holder.cb_check = convertView.findViewById(R.id.cb_check);
|
||||
holder.ll_history = convertView.findViewById(R.id.ll_history);
|
||||
|
||||
convertView.setTag(holder);
|
||||
} else {
|
||||
holder = (Holder) convertView.getTag();
|
||||
}
|
||||
if (flag){
|
||||
holder.cb_check.setVisibility(View.VISIBLE);
|
||||
}else {
|
||||
holder.cb_check.setVisibility(View.GONE);
|
||||
}
|
||||
final VideoWatchRecordBean.DataBean.ListBean listBean = data.get(position);
|
||||
|
||||
if (listBean.getStatus()==99){
|
||||
if(CommonUtil.BigModule())
|
||||
{
|
||||
holder.cb_check.setImageResource(R.drawable.check_video_true_big);
|
||||
}
|
||||
else
|
||||
{
|
||||
holder.cb_check.setImageResource(R.drawable.check_video_true);
|
||||
}
|
||||
}else {
|
||||
if(CommonUtil.BigModule())
|
||||
{
|
||||
holder.cb_check.setImageResource(R.drawable.check_video_false_big);
|
||||
}
|
||||
else
|
||||
{
|
||||
holder.cb_check.setImageResource(R.drawable.check_video_false);
|
||||
}
|
||||
}
|
||||
|
||||
holder.ll_history.setOnClickListener(new LlHistoryListener(holder.cb_check,listBean));
|
||||
|
||||
|
||||
ImageLoader.getInstance().displayImage(
|
||||
Url.urlHtml+listBean.getImgpath(), holder.iv_start,
|
||||
ImageOptions.getImageOptions(R.drawable.default_news_iv));
|
||||
holder.tv_author.setText(listBean.getPublic_name());
|
||||
holder.tv_title.setText(listBean.getVideo_name());
|
||||
return convertView;
|
||||
}
|
||||
|
||||
class Holder {
|
||||
ImageView cb_check;
|
||||
RoundImageView iv_start;
|
||||
TextView tv_title, tv_author;
|
||||
LinearLayout ll_history;
|
||||
}
|
||||
}
|
||||
|
||||
private class LlHistoryListener implements View.OnClickListener{
|
||||
|
||||
private ImageView cb_check;
|
||||
private VideoWatchRecordBean.DataBean.ListBean listBean;
|
||||
public LlHistoryListener(ImageView cb_check, VideoWatchRecordBean.DataBean.ListBean listBean) {
|
||||
this.cb_check = cb_check;
|
||||
this.listBean = listBean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (flag){
|
||||
int status = listBean.getStatus();
|
||||
if (status==98||status==1){
|
||||
listBean.setStatus(99);
|
||||
if(CommonUtil.BigModule())
|
||||
{
|
||||
cb_check.setImageResource(R.drawable.check_video_true_big);
|
||||
}
|
||||
else
|
||||
{
|
||||
cb_check.setImageResource(R.drawable.check_video_true);
|
||||
}
|
||||
// cb_check.setImageResource(R.drawable.check_video_true);
|
||||
}else {
|
||||
listBean.setStatus(98);
|
||||
if(CommonUtil.BigModule())
|
||||
{
|
||||
cb_check.setImageResource(R.drawable.check_video_false_big);
|
||||
}
|
||||
else
|
||||
{
|
||||
cb_check.setImageResource(R.drawable.check_video_false);
|
||||
}
|
||||
// cb_check.setImageResource(R.drawable.check_video_false);
|
||||
|
||||
}
|
||||
int k = 0;
|
||||
for (int i = 0;i<data.size();i++){
|
||||
if (data.get(i).getStatus()==99){
|
||||
k++;
|
||||
}
|
||||
}
|
||||
if (k==0){
|
||||
tv_deleteall.setText("删除");
|
||||
tv_all.setText("全选");
|
||||
}else if (k==data.size()){
|
||||
tv_deleteall.setText("删除("+k+")");
|
||||
tv_all.setText("取消全选");
|
||||
}else {
|
||||
tv_deleteall.setText("删除("+k+")");
|
||||
tv_all.setText("全选");
|
||||
}
|
||||
}else {
|
||||
Intent intent = VideoDetailPolyvPlayerActivity.newIntent(VideohistoryActivity.this, VideoDetailPolyvPlayerActivity.PlayMode.portrait, "");
|
||||
intent.putExtra("startNow", false);
|
||||
intent.putExtra("isVlmsOnline", false);
|
||||
intent.putExtra("uuid", listBean.getVideo_uuid());
|
||||
if("2".equals(listBean.getVideo_type()))
|
||||
{
|
||||
intent.putExtra("ispatientvideo",true);
|
||||
}
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
+140
@@ -0,0 +1,140 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.annotation.IdRes;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
//import android.support.v7.widget.RecyclerView;
|
||||
|
||||
|
||||
public abstract class AbsRecyclerViewAdapter extends
|
||||
RecyclerView.Adapter<AbsRecyclerViewAdapter.ClickableViewHolder> {
|
||||
|
||||
private Context context;
|
||||
|
||||
protected RecyclerView mRecyclerView;
|
||||
|
||||
private List<RecyclerView.OnScrollListener> mListeners = new ArrayList<>();
|
||||
|
||||
|
||||
public AbsRecyclerViewAdapter(RecyclerView recyclerView) {
|
||||
|
||||
this.mRecyclerView = recyclerView;
|
||||
this.mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
|
||||
@Override
|
||||
public void onScrollStateChanged(RecyclerView rv, int newState) {
|
||||
|
||||
for (RecyclerView.OnScrollListener listener : mListeners) {
|
||||
listener.onScrollStateChanged(rv, newState);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onScrolled(RecyclerView rv, int dx, int dy) {
|
||||
|
||||
for (RecyclerView.OnScrollListener listener : mListeners) {
|
||||
listener.onScrolled(rv, dx, dy);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void addOnScrollListener(RecyclerView.OnScrollListener listener) {
|
||||
|
||||
mListeners.add(listener);
|
||||
}
|
||||
|
||||
|
||||
public interface OnItemClickListener {
|
||||
|
||||
void onItemClick(int position, ClickableViewHolder holder);
|
||||
}
|
||||
|
||||
interface OnItemLongClickListener {
|
||||
|
||||
boolean onItemLongClick(int position, ClickableViewHolder holder);
|
||||
}
|
||||
|
||||
private OnItemClickListener itemClickListener;
|
||||
|
||||
private OnItemLongClickListener itemLongClickListener;
|
||||
|
||||
|
||||
public void setOnItemClickListener(OnItemClickListener listener) {
|
||||
|
||||
this.itemClickListener = listener;
|
||||
}
|
||||
|
||||
|
||||
public void setOnItemLongClickListener(OnItemLongClickListener listener) {
|
||||
|
||||
this.itemLongClickListener = listener;
|
||||
}
|
||||
|
||||
|
||||
public void bindContext(Context context) {
|
||||
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
|
||||
public Context getContext() {
|
||||
|
||||
return this.context;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(final ClickableViewHolder holder, final int position) {
|
||||
|
||||
holder.getParentView().setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (itemClickListener != null) {
|
||||
itemClickListener.onItemClick(position, holder);
|
||||
}
|
||||
}
|
||||
});
|
||||
holder.getParentView().setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
return itemLongClickListener != null
|
||||
&& itemLongClickListener.onItemLongClick(position, holder);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public static class ClickableViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private View parentView;
|
||||
|
||||
|
||||
public ClickableViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
this.parentView = itemView;
|
||||
}
|
||||
|
||||
|
||||
View getParentView() {
|
||||
|
||||
return parentView;
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends View> T $(@IdRes int id) {
|
||||
|
||||
return (T) parentView.findViewById(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import cn.shangyu.gdxzExpert.R;
|
||||
import cn.shangyu.gdxzExpert.bean.ListSeriesVideoByTypeBean;
|
||||
import cn.shangyu.gdxzExpert.utils.DateUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.LogUtil;
|
||||
|
||||
/**
|
||||
* Created by WANGChengXin on 2019/3/26.
|
||||
*/
|
||||
|
||||
public class CurriculumAdapter extends BaseAdapter{
|
||||
private Context mContent;
|
||||
private List<ListSeriesVideoByTypeBean.DataBean.ListBean> list;
|
||||
private int isPlayingPosition = 99;
|
||||
public int num;
|
||||
|
||||
public CurriculumAdapter(Context mContent, List<ListSeriesVideoByTypeBean.DataBean.ListBean> list) {
|
||||
super();
|
||||
this.mContent = mContent;
|
||||
this.list = list;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return list.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
return list.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
|
||||
final Holder holder;
|
||||
|
||||
if (convertView == null) {
|
||||
holder = new Holder();
|
||||
convertView = View.inflate(mContent, R.layout.item_curriculum,null);
|
||||
holder.tv_time = convertView.findViewById(R.id.tv_time);
|
||||
holder.tv_name = convertView.findViewById(R.id.tv_name);
|
||||
holder.tv_data = convertView.findViewById(R.id.tv_data);
|
||||
holder.tv_play = convertView.findViewById(R.id.tv_play);
|
||||
|
||||
convertView.setTag(holder);
|
||||
} else {
|
||||
holder = (Holder) convertView.getTag();
|
||||
}
|
||||
holder.tv_time.setText("时长 "+list.get(position).getTime());
|
||||
holder.tv_name.setText(list.get(position).getTitle());
|
||||
|
||||
|
||||
String day = DateUtil.timestamp2Date(list.get(position).getCreate_date()+"","yyyy-MM-dd");
|
||||
holder.tv_data.setText(day);
|
||||
if ("1".equals(list.get(position).getType())){
|
||||
holder.tv_play.setText("免费");
|
||||
holder.tv_play.setVisibility(View.VISIBLE);
|
||||
}else if ("2".equals(list.get(position).getType())){
|
||||
holder.tv_play.setText("试播");
|
||||
holder.tv_play.setVisibility(View.VISIBLE);
|
||||
}else {
|
||||
holder.tv_play.setVisibility(View.GONE);
|
||||
}
|
||||
if (isPlayingPosition!=99){
|
||||
if (isPlayingPosition==position){
|
||||
holder.tv_name.setTextColor(mContent.getResources().getColor(R.color.doctor_theme));
|
||||
}else {
|
||||
holder.tv_name.setTextColor(mContent.getResources().getColor(R.color.c333333));
|
||||
}
|
||||
}
|
||||
return convertView;
|
||||
}
|
||||
|
||||
public void setPlayingPosition(int position) {
|
||||
isPlayingPosition = position;
|
||||
}
|
||||
|
||||
class Holder {
|
||||
TextView tv_name,tv_data,tv_time,tv_play;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Paint;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import cn.shangyu.gdxzExpert.R;
|
||||
import cn.shangyu.gdxzExpert.bean.ListSeriesTypeBean;
|
||||
import cn.shangyu.gdxzExpert.polyvplayer.FreeAreaActivity;
|
||||
import cn.shangyu.gdxzExpert.utils.ImageOptions;
|
||||
import cn.shangyu.gdxzExpert.utils.Url;
|
||||
import cn.shangyu.gdxzExpert.view.RoundImageView;
|
||||
|
||||
|
||||
/**
|
||||
* Created by WANGChengXin on 2019/3/25.
|
||||
*/
|
||||
|
||||
public class ExchangeAdapter extends BaseAdapter {
|
||||
|
||||
private Context mContent;
|
||||
private List<ListSeriesTypeBean.DataBean.ListBean> list;
|
||||
private boolean b;//是否已兑换
|
||||
|
||||
|
||||
public ExchangeAdapter(Context mContent, List<ListSeriesTypeBean.DataBean.ListBean> list) {
|
||||
super();
|
||||
this.mContent = mContent;
|
||||
this.list = list;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return list.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
return list.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
Holder holder;
|
||||
|
||||
if (convertView == null) {
|
||||
holder = new Holder();
|
||||
convertView = View.inflate(mContent, R.layout.item_exchange,null);
|
||||
holder.tv_exchange_title = convertView.findViewById(R.id.tv_exchange_title);
|
||||
holder.iv_exchange_video = convertView.findViewById(R.id.iv_exchange_video);
|
||||
holder.tv_exchange_title2 = convertView.findViewById(R.id.tv_exchange_title2);
|
||||
holder.tv_red1 = convertView.findViewById(R.id.tv_red1);
|
||||
holder.tv_red2 = convertView.findViewById(R.id.tv_red2);
|
||||
holder.tv_red3 = convertView.findViewById(R.id.tv_red3);
|
||||
|
||||
convertView.setTag(holder);
|
||||
} else {
|
||||
holder = (Holder) convertView.getTag();
|
||||
}
|
||||
holder.tv_exchange_title.setText(list.get(position).getTitle());
|
||||
holder.tv_exchange_title2.setText(list.get(position).getSlogan());
|
||||
double discount = list.get(position).getDiscount();
|
||||
if (discount==1){//不打折
|
||||
holder.tv_red1.setText(list.get(position).getPrice()+"积分");
|
||||
holder.tv_red2.setVisibility(View.GONE);
|
||||
holder.tv_red3.setVisibility(View.GONE);
|
||||
}else if (discount>0){//打折不免费
|
||||
int v = (int) (list.get(position).getPrice() * discount);
|
||||
holder.tv_red1.setText(v+"积分");
|
||||
holder.tv_red3.setText(list.get(position).getPrice()+"积分");
|
||||
holder.tv_red3.getPaint().setFlags(Paint. STRIKE_THRU_TEXT_FLAG );
|
||||
holder.tv_red2.setVisibility(View.VISIBLE);
|
||||
holder.tv_red3.setVisibility(View.VISIBLE);
|
||||
}else if (discount == 0){//限时优惠 免费
|
||||
holder.tv_red1.setText("免费");
|
||||
holder.tv_red2.setVisibility(View.VISIBLE);
|
||||
holder.tv_red3.setText(list.get(position).getPrice()+"积分");
|
||||
holder.tv_red3.setVisibility(View.VISIBLE);
|
||||
holder.tv_red3.getPaint().setFlags(Paint. STRIKE_THRU_TEXT_FLAG );
|
||||
}
|
||||
ImageLoader.getInstance().displayImage(
|
||||
Url.urlHtml+list.get(position).getImg(), holder.iv_exchange_video,
|
||||
ImageOptions.getImageOptions(R.drawable.default_news_iv));
|
||||
|
||||
|
||||
return convertView;
|
||||
|
||||
}
|
||||
class Holder {
|
||||
RoundImageView iv_exchange_video;
|
||||
TextView tv_exchange_title,tv_exchange_title2,tv_red1,tv_red2,tv_red3;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Paint;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import cn.shangyu.gdxzExpert.R;
|
||||
import cn.shangyu.gdxzExpert.bean.ListFreeBean;
|
||||
import cn.shangyu.gdxzExpert.polyvplayer.FreeAreaActivity;
|
||||
import cn.shangyu.gdxzExpert.utils.ImageOptions;
|
||||
import cn.shangyu.gdxzExpert.utils.Url;
|
||||
import cn.shangyu.gdxzExpert.view.RoundImageView;
|
||||
|
||||
/**
|
||||
* Created by wangchengxin on 2019/4/1.
|
||||
*/
|
||||
|
||||
public class FreeAdapter extends BaseAdapter{
|
||||
|
||||
private Context mContent;
|
||||
private List<ListFreeBean.DataBean.ListBean> list;
|
||||
public FreeAdapter(Context mContent, List<ListFreeBean.DataBean.ListBean> list) {
|
||||
this.mContent = mContent;
|
||||
this.list = list;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return list.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
return list.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
Holder holder;
|
||||
if (convertView == null) {
|
||||
holder = new Holder();
|
||||
convertView = View.inflate(mContent, R.layout.item_free,null);
|
||||
holder.tv_exchange_title = convertView.findViewById(R.id.tv_exchange_title);
|
||||
holder.iv_exchange_video = convertView.findViewById(R.id.iv_exchange_video);
|
||||
holder.tv_exchange_title2 = convertView.findViewById(R.id.tv_exchange_title2);
|
||||
holder.tv_watchtime = convertView.findViewById(R.id.tv_watchtime);
|
||||
|
||||
|
||||
convertView.setTag(holder);
|
||||
} else {
|
||||
holder = (Holder) convertView.getTag();
|
||||
}
|
||||
holder.tv_exchange_title.setText(list.get(position).getTitle());
|
||||
holder.tv_exchange_title2.setText(list.get(position).getTime());
|
||||
holder.tv_watchtime.setText(list.get(position).getReadnum()+"观看");
|
||||
ImageLoader.getInstance().displayImage(
|
||||
Url.urlHtml+list.get(position).getImg(), holder.iv_exchange_video,
|
||||
ImageOptions.getImageOptions(R.drawable.default_news_iv));
|
||||
// double discount = list.get(position).getDiscount();
|
||||
// discount = 0.8;
|
||||
// if (discount!=1){
|
||||
// holder.tv_red2.setVisibility(View.VISIBLE);
|
||||
// holder.tv_red3.setVisibility(View.VISIBLE);
|
||||
// double v = list.get(position).getPrice() / discount;
|
||||
// holder.tv_red3.setText(v+"积分");
|
||||
// holder.tv_red3.getPaint().setFlags(Paint. STRIKE_THRU_TEXT_FLAG );
|
||||
// }else {
|
||||
// holder.tv_red2.setVisibility(View.GONE);
|
||||
// holder.tv_red3.setVisibility(View.GONE);
|
||||
// }
|
||||
// ImageLoader.getInstance().displayImage(
|
||||
// list.get(position).get(), holder.iv_exchange_video,
|
||||
// ImageOptions.getImageOptions(R.drawable.default_news_iv));
|
||||
|
||||
return convertView;
|
||||
|
||||
}
|
||||
class Holder {
|
||||
RoundImageView iv_exchange_video;
|
||||
TextView tv_exchange_title,tv_exchange_title2,tv_watchtime,tv_red2,tv_red3;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Paint;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import cn.shangyu.gdxzExpert.R;
|
||||
import cn.shangyu.gdxzExpert.bean.ListSeriesTypeBean;
|
||||
import cn.shangyu.gdxzExpert.utils.ImageOptions;
|
||||
import cn.shangyu.gdxzExpert.utils.Url;
|
||||
import cn.shangyu.gdxzExpert.view.RoundImageView;
|
||||
|
||||
/**
|
||||
* Created by wangchengxin on 2019/4/4.
|
||||
*/
|
||||
|
||||
public class MyListSeriesAdapter extends BaseAdapter {
|
||||
|
||||
private Context mContent;
|
||||
private List<ListSeriesTypeBean.DataBean.ListBean> list;
|
||||
private boolean b;//是否已兑换
|
||||
|
||||
|
||||
public MyListSeriesAdapter(Context mContent, List<ListSeriesTypeBean.DataBean.ListBean> list) {
|
||||
super();
|
||||
this.mContent = mContent;
|
||||
this.list = list;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return list.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
return list.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
Holder holder;
|
||||
|
||||
if (convertView == null) {
|
||||
holder = new Holder();
|
||||
convertView = View.inflate(mContent, R.layout.item_mylistseries,null);
|
||||
holder.tv_exchange_title = convertView.findViewById(R.id.tv_exchange_title);
|
||||
holder.iv_exchange_video = convertView.findViewById(R.id.iv_exchange_video);
|
||||
holder.tv_exchange_title2 = convertView.findViewById(R.id.tv_exchange_title2);
|
||||
holder.tv_red1 = convertView.findViewById(R.id.tv_red1);
|
||||
holder.tv_red2 = convertView.findViewById(R.id.tv_red2);
|
||||
holder.tv_red3 = convertView.findViewById(R.id.tv_red3);
|
||||
|
||||
convertView.setTag(holder);
|
||||
} else {
|
||||
holder = (Holder) convertView.getTag();
|
||||
}
|
||||
holder.tv_exchange_title.setText(list.get(position).getTitle());
|
||||
holder.tv_exchange_title2.setText(list.get(position).getSlogan());
|
||||
|
||||
ImageLoader.getInstance().displayImage(
|
||||
Url.urlHtml+list.get(position).getImg(), holder.iv_exchange_video,
|
||||
ImageOptions.getImageOptions(R.drawable.default_news_iv));
|
||||
|
||||
|
||||
return convertView;
|
||||
|
||||
}
|
||||
class Holder {
|
||||
RoundImageView iv_exchange_video;
|
||||
TextView tv_exchange_title,tv_exchange_title2,tv_red1,tv_red2,tv_red3;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+804
@@ -0,0 +1,804 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer.adapter;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.easefun.polyvsdk.PolyvDownloader;
|
||||
import com.easefun.polyvsdk.PolyvDownloaderErrorReason;
|
||||
import com.easefun.polyvsdk.PolyvDownloaderManager;
|
||||
import com.easefun.polyvsdk.download.listener.IPolyvDownloaderProgressListener;
|
||||
import com.easefun.polyvsdk.download.listener.IPolyvDownloaderSpeedListener;
|
||||
import com.easefun.polyvsdk.download.listener.IPolyvDownloaderStartListener;
|
||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.List;
|
||||
|
||||
import cn.shangyu.gdxzExpert.R;
|
||||
import cn.shangyu.gdxzExpert.bean.PolyvDownloadInfo;
|
||||
import cn.shangyu.gdxzExpert.polyvplayer.VideoDetailPolyvPlayerActivity;
|
||||
import cn.shangyu.gdxzExpert.polyvplayer.database.PolyvDownloadSQLiteHelper;
|
||||
import cn.shangyu.gdxzExpert.polyvplayer.util.PolyvErrorMessageUtils;
|
||||
import cn.shangyu.gdxzExpert.utils.CommonUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.FileUtils;
|
||||
import cn.shangyu.gdxzExpert.utils.ImageOptions;
|
||||
import cn.shangyu.gdxzExpert.utils.LogUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.ToastUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.Url;
|
||||
import cn.shangyu.gdxzExpert.view.RoundImageView;
|
||||
|
||||
import static cn.shangyu.gdxzExpert.polyvplayer.fragment.PolyvDownloadFragment.DOWNEND;
|
||||
import static cn.shangyu.gdxzExpert.polyvplayer.fragment.PolyvDownloadFragment.DOWNING;
|
||||
|
||||
public class PolyvDownloadListViewAdapter extends BaseAdapter {
|
||||
private static final String TAG = PolyvDownloadListViewAdapter.class.getSimpleName();
|
||||
private static final String DOWNLOADED = "已下载";
|
||||
private static final String DOWNLOADING = "正在下载";
|
||||
private static final String PAUSEED = "暂停下载";
|
||||
private static final String WAITED = "等待下载";
|
||||
private static PolyvDownloadSQLiteHelper downloadSQLiteHelper;
|
||||
private static Context appContext;
|
||||
private Context context;
|
||||
private ListView lv_download;
|
||||
private List<PolyvDownloadInfo> lists;
|
||||
private LayoutInflater inflater;
|
||||
private ViewHolder viewHolder;
|
||||
private boolean isEdit;
|
||||
private Handler mHandler;
|
||||
public PolyvDownloadListViewAdapter(List<PolyvDownloadInfo> lists, Context context, ListView lv_download, Handler mHandler) {
|
||||
this.lists = lists;
|
||||
this.context = context;
|
||||
appContext = context.getApplicationContext();
|
||||
this.inflater = LayoutInflater.from(this.context);
|
||||
this.lv_download = lv_download;
|
||||
downloadSQLiteHelper = PolyvDownloadSQLiteHelper.getInstance(this.context);
|
||||
init();
|
||||
this.mHandler = mHandler;
|
||||
}
|
||||
|
||||
private void init() {
|
||||
for (int i = 0; i < lists.size(); i++) {
|
||||
PolyvDownloadInfo downloadInfo = lists.get(i);
|
||||
String vid = downloadInfo.getVid();
|
||||
int bitrate = downloadInfo.getBitrate();
|
||||
PolyvDownloaderManager.getPolyvDownloader(vid, bitrate);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除选中任务
|
||||
*/
|
||||
public void deleteAllTask() {
|
||||
for (int i = 0; i < lists.size(); i++) {
|
||||
PolyvDownloadInfo downloadInfo = lists.get(i);
|
||||
if (downloadInfo.isCheck()){
|
||||
|
||||
//移除任务
|
||||
PolyvDownloader downloader = PolyvDownloaderManager.clearPolyvDownload(downloadInfo.getVid(), downloadInfo.getBitrate());
|
||||
//删除文件
|
||||
downloader.deleteVideo();
|
||||
//移除数据库的下载信息
|
||||
downloadSQLiteHelper.delete(downloadInfo);
|
||||
lists.remove(i--);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return lists.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
return lists.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
|
||||
if (convertView == null) {
|
||||
viewHolder = new ViewHolder();
|
||||
if(CommonUtil.BigModule())
|
||||
{
|
||||
convertView = LayoutInflater.from(context).inflate(R.layout.polyv_listview_download_item_big, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
convertView = LayoutInflater.from(context).inflate(R.layout.polyv_listview_download_item, null);
|
||||
}
|
||||
viewHolder.iv_start = (RoundImageView) convertView.findViewById(R.id.iv_start);
|
||||
viewHolder.tv_size = (TextView) convertView.findViewById(R.id.tv_size);
|
||||
viewHolder.tv_speed = (TextView) convertView.findViewById(R.id.tv_speed);
|
||||
viewHolder.tv_status = (TextView) convertView.findViewById(R.id.tv_status);
|
||||
viewHolder.tv_title = (TextView) convertView.findViewById(R.id.tv_title);
|
||||
viewHolder.pb_progress = (ProgressBar) convertView.findViewById(R.id.pb_progress);
|
||||
viewHolder.tv_video_long = (TextView) convertView.findViewById(R.id.tv_video_long);
|
||||
viewHolder.tv_author = (TextView) convertView.findViewById(R.id.tv_author);
|
||||
viewHolder.iv_video_Long = (ImageView) convertView.findViewById(R.id.iv_video_Long);
|
||||
viewHolder.sl_download = (RelativeLayout) convertView.findViewById(R.id.sl_download);
|
||||
viewHolder.cb_check = (ImageView) convertView.findViewById(R.id.cb_check);
|
||||
viewHolder.rl_check = (RelativeLayout) convertView.findViewById(R.id.rl_check);
|
||||
convertView.setTag(viewHolder);
|
||||
} else {
|
||||
viewHolder = (ViewHolder) convertView.getTag();
|
||||
}
|
||||
final PolyvDownloadInfo downloadInfo = lists.get(position);
|
||||
String vid = downloadInfo.getVid();
|
||||
int bitrate = downloadInfo.getBitrate();
|
||||
long percent = downloadInfo.getPercent();
|
||||
long total = downloadInfo.getTotal();
|
||||
String title = downloadInfo.getTitle();
|
||||
long filesize = downloadInfo.getFilesize();
|
||||
String duration = downloadInfo.getDuration();
|
||||
String author = downloadInfo.getAuthor();
|
||||
String img = downloadInfo.getHeadImg();
|
||||
final boolean check = downloadInfo.isCheck();
|
||||
// 已下载的百分比
|
||||
int progress = 0;
|
||||
if (total != 0) {
|
||||
progress = (int) (percent * 100 / total);
|
||||
}
|
||||
/**
|
||||
* 编辑/取消
|
||||
* */
|
||||
if (isEdit){
|
||||
viewHolder.rl_check.setVisibility(View.VISIBLE);
|
||||
}else {
|
||||
viewHolder.rl_check.setVisibility(View.GONE);
|
||||
}
|
||||
if (check){
|
||||
if(CommonUtil.BigModule())
|
||||
{
|
||||
viewHolder.cb_check.setBackgroundResource(R.drawable.check_video_true_big);
|
||||
}
|
||||
else
|
||||
{
|
||||
viewHolder.cb_check.setBackgroundResource(R.drawable.check_video_true);
|
||||
}
|
||||
|
||||
}else {
|
||||
if(CommonUtil.BigModule())
|
||||
{
|
||||
viewHolder.cb_check.setBackgroundResource(R.drawable.check_video_false_big);
|
||||
}
|
||||
else
|
||||
{
|
||||
viewHolder.cb_check.setBackgroundResource(R.drawable.check_video_false);
|
||||
}
|
||||
}
|
||||
viewHolder.rl_check.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (check){
|
||||
downloadInfo.setCheck(false);
|
||||
if(CommonUtil.BigModule())
|
||||
{
|
||||
viewHolder.cb_check.setBackgroundResource(R.drawable.check_video_false_big);
|
||||
}
|
||||
else
|
||||
{
|
||||
viewHolder.cb_check.setBackgroundResource(R.drawable.check_video_false);
|
||||
}
|
||||
|
||||
}else {
|
||||
downloadInfo.setCheck(true);
|
||||
if(CommonUtil.BigModule())
|
||||
{
|
||||
viewHolder.cb_check.setBackgroundResource(R.drawable.check_video_true_big);
|
||||
}
|
||||
else
|
||||
{
|
||||
viewHolder.cb_check.setBackgroundResource(R.drawable.check_video_true);
|
||||
}
|
||||
}
|
||||
mHandler.sendEmptyMessage(0);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
PolyvDownloader downloader = PolyvDownloaderManager.getPolyvDownloader(vid, bitrate);
|
||||
viewHolder.pb_progress.setVisibility(View.GONE);//VISIBLE
|
||||
viewHolder.tv_speed.setVisibility(View.VISIBLE);
|
||||
viewHolder.tv_status.setSelected(false);
|
||||
viewHolder.tv_author.setText(author);
|
||||
ImageLoader.getInstance().displayImage(
|
||||
Url.urlHtml+img, viewHolder.iv_start,
|
||||
ImageOptions.getImageOptions(R.drawable.default_news_iv));
|
||||
if (progress == 100) {
|
||||
int i = duration.length() - 2;
|
||||
String substring = duration.substring(0, i);
|
||||
viewHolder.tv_video_long.setText(""+getTime(Integer.parseInt(substring)));
|
||||
// viewHolder.iv_start.setImageResource(R.drawable.polyv_btn_play);
|
||||
viewHolder.tv_status.setText(DOWNLOADED);
|
||||
if(CommonUtil.BigModule())
|
||||
{
|
||||
viewHolder.iv_video_Long.setImageResource(R.drawable.video_long_big);
|
||||
}
|
||||
else
|
||||
{
|
||||
viewHolder.iv_video_Long.setImageResource(R.drawable.video_long);
|
||||
}
|
||||
viewHolder.pb_progress.setVisibility(View.GONE);
|
||||
viewHolder.tv_speed.setVisibility(View.GONE);
|
||||
} else if (downloader.isDownloading()) {
|
||||
// viewHolder.iv_start.setImageResource(R.drawable.polyv_btn_dlpause);
|
||||
viewHolder.tv_status.setText(DOWNLOADING);
|
||||
viewHolder.tv_video_long.setText("停止");
|
||||
if(CommonUtil.BigModule())
|
||||
{
|
||||
viewHolder.iv_video_Long.setImageResource(R.drawable.down_false_big);
|
||||
}
|
||||
else
|
||||
{
|
||||
viewHolder.iv_video_Long.setImageResource(R.drawable.down_false);
|
||||
}
|
||||
// viewHolder.tv_speed.setText("0.00B/S");
|
||||
} else if (PolyvDownloaderManager.isWaitingDownload(vid, bitrate)) {
|
||||
// viewHolder.iv_start.setImageResource(R.drawable.polyv_btn_download);
|
||||
viewHolder.tv_status.setText(WAITED);
|
||||
viewHolder.tv_video_long.setText("等待");
|
||||
viewHolder.iv_video_Long.setImageResource(R.drawable.video_long);
|
||||
viewHolder.tv_status.setSelected(true);
|
||||
viewHolder.tv_speed.setText(FileUtils.formatFileSize(filesize * progress / 100)+"/");
|
||||
} else {
|
||||
// viewHolder.iv_start.setImageResource(R.drawable.polyv_btn_download);
|
||||
viewHolder.tv_status.setText(PAUSEED);
|
||||
viewHolder.tv_status.setSelected(true);
|
||||
viewHolder.tv_video_long.setText("继续");
|
||||
if(CommonUtil.BigModule())
|
||||
{
|
||||
viewHolder.iv_video_Long.setImageResource(R.drawable.down_true_big);
|
||||
}
|
||||
else
|
||||
{
|
||||
viewHolder.iv_video_Long.setImageResource(R.drawable.down_true);
|
||||
}
|
||||
|
||||
viewHolder.tv_speed.setText(FileUtils.formatFileSize(filesize * progress / 100)+"/");
|
||||
}
|
||||
|
||||
viewHolder.tv_title.setText(title);
|
||||
viewHolder.tv_size.setText(FileUtils.formatFileSize(filesize));
|
||||
// viewHolder.pb_progress.setProgress(progress);
|
||||
viewHolder.sl_download.setOnClickListener(new DownloadOnClickListener(downloadInfo, viewHolder.iv_start, viewHolder.tv_status, viewHolder.tv_speed, viewHolder.tv_video_long,viewHolder.iv_video_Long));
|
||||
viewHolder.setDownloadListener(downloader, downloadInfo, position, lists,mHandler);
|
||||
return convertView;
|
||||
}
|
||||
|
||||
|
||||
// @Override
|
||||
// public View getView(int position, ViewGroup parent) {
|
||||
// View view = LayoutInflater.from(context).inflate(R.layout.polyv_listview_download_item, null);
|
||||
//// SwipeLayout swipeLayout = (SwipeLayout) view.findViewById(getSwipeLayoutResourceId(position));
|
||||
//// swipeLayout.setShowMode(SwipeLayout.ShowMode.LayDown);
|
||||
//// swipeLayout.addDrag(SwipeLayout.DragEdge.Right, swipeLayout.findViewWithTag("ll_delete"));
|
||||
//// swipeLayout.setSwipeEnabled(false);
|
||||
// viewHolder = new ViewHolder();
|
||||
// viewHolder.iv_start = (RoundImageView) view.findViewById(R.id.iv_start);
|
||||
// viewHolder.tv_size = (TextView) view.findViewById(R.id.tv_size);
|
||||
// viewHolder.tv_speed = (TextView) view.findViewById(R.id.tv_speed);
|
||||
// viewHolder.tv_status = (TextView) view.findViewById(R.id.tv_status);
|
||||
// viewHolder.tv_title = (TextView) view.findViewById(R.id.tv_title);
|
||||
// viewHolder.pb_progress = (ProgressBar) view.findViewById(R.id.pb_progress);
|
||||
// viewHolder.tv_video_long = (TextView) view.findViewById(R.id.tv_video_long);
|
||||
// viewHolder.tv_author = (TextView) view.findViewById(R.id.tv_author);
|
||||
// viewHolder.iv_video_Long = (ImageView) view.findViewById(R.id.iv_video_Long);
|
||||
// viewHolder.sl_download = (SwipeLayout) view.findViewById(R.id.sl_download);
|
||||
// viewHolder.cb_check = (ImageView) view.findViewById(R.id.cb_check);
|
||||
// viewHolder.rl_check = (RelativeLayout) view.findViewById(R.id.rl_check);
|
||||
// view.setTag(viewHolder);
|
||||
// return view;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void fillValues(final int position, View convertView) {
|
||||
// viewHolder = (ViewHolder) convertView.getTag();
|
||||
//
|
||||
// final PolyvDownloadInfo downloadInfo = lists.get(position);
|
||||
// String vid = downloadInfo.getVid();
|
||||
// int bitrate = downloadInfo.getBitrate();
|
||||
// long percent = downloadInfo.getPercent();
|
||||
// long total = downloadInfo.getTotal();
|
||||
// String title = downloadInfo.getTitle();
|
||||
// long filesize = downloadInfo.getFilesize();
|
||||
// String duration = downloadInfo.getDuration();
|
||||
// String author = downloadInfo.getAuthor();
|
||||
// String img = downloadInfo.getHeadImg();
|
||||
// final boolean check = downloadInfo.isCheck();
|
||||
// // 已下载的百分比
|
||||
// int progress = 0;
|
||||
// if (total != 0) {
|
||||
// progress = (int) (percent * 100 / total);
|
||||
// }
|
||||
// /**
|
||||
// * 编辑/取消
|
||||
// * */
|
||||
// if (isEdit){
|
||||
// viewHolder.rl_check.setVisibility(View.VISIBLE);
|
||||
// }else {
|
||||
// viewHolder.rl_check.setVisibility(View.GONE);
|
||||
// }
|
||||
// if (check){
|
||||
// viewHolder.cb_check.setBackgroundResource(R.drawable.check_video_true);
|
||||
// }else {
|
||||
// viewHolder.cb_check.setBackgroundResource(R.drawable.check_video_false);
|
||||
// }
|
||||
// viewHolder.rl_check.setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View v) {
|
||||
// if (check){
|
||||
// downloadInfo.setCheck(false);
|
||||
// viewHolder.cb_check.setBackgroundResource(R.drawable.check_video_false);
|
||||
// }else {
|
||||
// downloadInfo.setCheck(true);
|
||||
// viewHolder.cb_check.setBackgroundResource(R.drawable.check_video_true);
|
||||
// }
|
||||
// mHandler.sendEmptyMessage(0);
|
||||
// }
|
||||
// });
|
||||
//
|
||||
//
|
||||
// PolyvDownloader downloader = PolyvDownloaderManager.getPolyvDownloader(vid, bitrate);
|
||||
// viewHolder.pb_progress.setVisibility(View.GONE);//VISIBLE
|
||||
// viewHolder.tv_speed.setVisibility(View.VISIBLE);
|
||||
// viewHolder.tv_status.setSelected(false);
|
||||
// viewHolder.tv_author.setText(author);
|
||||
// ImageLoader.getInstance().displayImage(
|
||||
// Url.urlHtml+img, viewHolder.iv_start,
|
||||
// ImageOptions.getImageOptions(R.drawable.default_news_iv));
|
||||
// if (progress == 100) {
|
||||
// int i = duration.length() - 2;
|
||||
// String substring = duration.substring(0, i);
|
||||
// viewHolder.tv_video_long.setText(""+getTime(Integer.parseInt(substring)));
|
||||
//// viewHolder.iv_start.setImageResource(R.drawable.polyv_btn_play);
|
||||
// viewHolder.tv_status.setText(DOWNLOADED);
|
||||
// viewHolder.iv_video_Long.setImageResource(R.drawable.video_long);
|
||||
// viewHolder.pb_progress.setVisibility(View.GONE);
|
||||
// viewHolder.tv_speed.setVisibility(View.GONE);
|
||||
// } else if (downloader.isDownloading()) {
|
||||
//// viewHolder.iv_start.setImageResource(R.drawable.polyv_btn_dlpause);
|
||||
// viewHolder.tv_status.setText(DOWNLOADING);
|
||||
// viewHolder.tv_video_long.setText("停止");
|
||||
// viewHolder.iv_video_Long.setImageResource(R.drawable.down_false);
|
||||
//// viewHolder.tv_speed.setText("0.00B/S");
|
||||
// } else if (PolyvDownloaderManager.isWaitingDownload(vid, bitrate)) {
|
||||
//// viewHolder.iv_start.setImageResource(R.drawable.polyv_btn_download);
|
||||
// viewHolder.tv_status.setText(WAITED);
|
||||
// viewHolder.tv_video_long.setText("继续");
|
||||
// viewHolder.iv_video_Long.setImageResource(R.drawable.down_true);
|
||||
// viewHolder.tv_status.setSelected(true);
|
||||
// viewHolder.tv_speed.setText(Formatter.formatFileSize(context, filesize * progress / 100)+"/");
|
||||
// } else {
|
||||
//// viewHolder.iv_start.setImageResource(R.drawable.polyv_btn_download);
|
||||
// viewHolder.tv_status.setText(PAUSEED);
|
||||
// viewHolder.tv_status.setSelected(true);
|
||||
// viewHolder.tv_video_long.setText("继续");
|
||||
// viewHolder.iv_video_Long.setImageResource(R.drawable.down_true);
|
||||
// viewHolder.tv_speed.setText(Formatter.formatFileSize(context, filesize * progress / 100)+"/");
|
||||
// }
|
||||
//
|
||||
// viewHolder.tv_title.setText(title);
|
||||
// viewHolder.tv_size.setText(Formatter.formatFileSize(context, filesize));
|
||||
//// viewHolder.pb_progress.setProgress(progress);
|
||||
// viewHolder.sl_download.setOnClickListener(new DownloadOnClickListener(downloadInfo, viewHolder.iv_start, viewHolder.tv_status, viewHolder.tv_speed, viewHolder.tv_video_long,viewHolder.iv_video_Long));
|
||||
// viewHolder.setDownloadListener(downloader, downloadInfo, position, lists);
|
||||
//
|
||||
// }
|
||||
public static String getTime(int second) {
|
||||
if (second < 10) {
|
||||
return "00:00:0" + second;
|
||||
}
|
||||
if (second < 60) {
|
||||
return "00:00:" + second;
|
||||
}
|
||||
if (second < 3600) {
|
||||
int minute = second / 60;
|
||||
second = second - minute * 60;
|
||||
if (minute < 10) {
|
||||
if (second < 10) {
|
||||
return "00:0" + minute + ":0" + second;
|
||||
}
|
||||
return "00:0" + minute + ":" + second;
|
||||
}
|
||||
if (second < 10) {
|
||||
return "00:"+minute + ":0" + second;
|
||||
}
|
||||
return "00:"+minute + ":" + second;
|
||||
}
|
||||
int hour = second / 3600;
|
||||
int minute = (second - hour * 3600) / 60;
|
||||
second = second - hour * 3600 - minute * 60;
|
||||
if (hour < 10) {
|
||||
if (minute < 10) {
|
||||
if (second < 10) {
|
||||
return "0" + hour + ":0" + minute + ":0" + second;
|
||||
}
|
||||
return "0" + hour + ":0" + minute + ":" + second;
|
||||
}
|
||||
if (second < 10) {
|
||||
return "0" + hour +":"+ minute + ":0" + second;
|
||||
}
|
||||
return "0" + hour +":"+ minute + ":" + second;
|
||||
}
|
||||
if (minute < 10) {
|
||||
if (second < 10) {
|
||||
return hour + ":0" + minute + ":0" + second;
|
||||
}
|
||||
return hour + ":0" + minute + ":" + second;
|
||||
}
|
||||
if (second < 10) {
|
||||
return hour +":"+ minute + ":0" + second;
|
||||
}
|
||||
return hour +":"+ minute + ":" + second;
|
||||
}
|
||||
|
||||
public void setEditData(boolean b) {
|
||||
this.isEdit = b;
|
||||
}
|
||||
|
||||
public interface DownloadSuccessListener {
|
||||
void onDownloadSuccess(PolyvDownloadInfo downloadInfo);
|
||||
}
|
||||
|
||||
private static DownloadSuccessListener downloadSuccessListener;
|
||||
|
||||
public void setDownloadSuccessListener(DownloadSuccessListener downloadSuccessListener) {
|
||||
this.downloadSuccessListener = downloadSuccessListener;
|
||||
}
|
||||
|
||||
private static class MyDownloadListener implements IPolyvDownloaderProgressListener {
|
||||
private WeakReference<Context> contextWeakReference;
|
||||
private WeakReference<ListView> wr_lv_download;
|
||||
private WeakReference<ViewHolder> viewHolder1;
|
||||
private PolyvDownloadInfo downloadInfo;
|
||||
private List<PolyvDownloadInfo> lists;
|
||||
private Handler handlerListener;
|
||||
private int position;
|
||||
private long total;
|
||||
|
||||
MyDownloadListener(Context context, ListView lv_download, ViewHolder viewHolder, PolyvDownloadInfo downloadInfo, int position, List<PolyvDownloadInfo> lists,Handler handlerListener) {
|
||||
this.contextWeakReference = new WeakReference<>(context);
|
||||
this.wr_lv_download = new WeakReference<>(lv_download);
|
||||
this.viewHolder1 = new WeakReference<>(viewHolder);
|
||||
this.downloadInfo = downloadInfo;
|
||||
this.position = position;
|
||||
this.lists = lists;
|
||||
this.handlerListener = handlerListener;
|
||||
}
|
||||
|
||||
private boolean canUpdateView() {
|
||||
ListView lv_download = wr_lv_download.get();
|
||||
return lv_download != null && viewHolder1.get() != null && lv_download.getChildAt(position - lv_download.getFirstVisiblePosition()) != null;
|
||||
}
|
||||
|
||||
private void removeToDownloadedQueue(int position) {
|
||||
if (position>=lists.size()){//防止数组越界
|
||||
position = 0;
|
||||
PolyvDownloadInfo downloadInfo = lists.remove(position);
|
||||
((BaseAdapter) wr_lv_download.get().getAdapter()).notifyDataSetChanged();
|
||||
if (downloadSuccessListener != null) {
|
||||
downloadSuccessListener.onDownloadSuccess(downloadInfo);
|
||||
}
|
||||
}else {
|
||||
PolyvDownloadInfo downloadInfo = lists.remove(position);
|
||||
((BaseAdapter) wr_lv_download.get().getAdapter()).notifyDataSetChanged();
|
||||
if (downloadSuccessListener != null) {
|
||||
downloadSuccessListener.onDownloadSuccess(downloadInfo);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDownload(long current, long total) {
|
||||
this.total = total;
|
||||
downloadInfo.setPercent(current);
|
||||
downloadInfo.setTotal(total);
|
||||
downloadSQLiteHelper.update(downloadInfo, current, total);
|
||||
if (canUpdateView()) {
|
||||
// 已下载的百分比
|
||||
int progress = (int) (current * 100 / total);
|
||||
viewHolder1.get().pb_progress.setProgress(progress);
|
||||
String s = viewHolder1.get().tv_size.getText().toString();
|
||||
String substring = s.substring(0, s.length() - 1);
|
||||
double v = Double.parseDouble(substring);
|
||||
double v1 = v * progress/100;
|
||||
DecimalFormat df = new DecimalFormat("0.00");//格式化,区小数后两位
|
||||
final String format = df.format(v1);
|
||||
viewHolder1.get().tv_speed.setText(format+"M"+"/");
|
||||
viewHolder1.get().tv_video_long.setText("停止");
|
||||
if(CommonUtil.BigModule())
|
||||
{
|
||||
viewHolder1.get().iv_video_Long.setImageResource(R.drawable.down_false_big);
|
||||
}
|
||||
else
|
||||
{
|
||||
viewHolder1.get().iv_video_Long.setImageResource(R.drawable.down_false);
|
||||
}
|
||||
handlerListener.sendEmptyMessage(DOWNING);
|
||||
// showPauseSpeeView(downloadInfo, viewHolder1.get().tv_speed);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDownloadSuccess() {
|
||||
if (total == 0)
|
||||
total = 1;
|
||||
downloadInfo.setPercent(total);
|
||||
downloadInfo.setTotal(total);
|
||||
downloadSQLiteHelper.update(downloadInfo, total, total);
|
||||
if (canUpdateView()) {
|
||||
viewHolder1.get().tv_status.setText(DOWNLOADED);
|
||||
viewHolder1.get().tv_status.setSelected(false);
|
||||
viewHolder1.get().tv_video_long.setText("继续");
|
||||
if(CommonUtil.BigModule())
|
||||
{
|
||||
viewHolder1.get().iv_video_Long.setImageResource(R.drawable.video_long_big);
|
||||
}
|
||||
else
|
||||
{
|
||||
viewHolder1.get().iv_video_Long.setImageResource(R.drawable.video_long);
|
||||
}
|
||||
viewHolder1.get().pb_progress.setVisibility(View.GONE);
|
||||
viewHolder1.get().tv_speed.setVisibility(View.GONE);
|
||||
ToastUtil.showMessage(downloadInfo.getTitle()+ "下载成功");
|
||||
Message obtain = Message.obtain();
|
||||
obtain.obj = downloadInfo.getVid();
|
||||
obtain.what = DOWNEND;
|
||||
handlerListener.sendMessage(obtain);
|
||||
removeToDownloadedQueue(position);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDownloadFail(@NonNull PolyvDownloaderErrorReason errorReason) {
|
||||
if (canUpdateView()) {
|
||||
viewHolder1.get().tv_status.setText(PAUSEED);
|
||||
viewHolder1.get().tv_status.setSelected(true);
|
||||
showPauseSpeeView(downloadInfo, viewHolder1.get().tv_speed);
|
||||
String message = "第" + (position + 1) + "个任务";
|
||||
message += PolyvErrorMessageUtils.getDownloaderErrorMessage(errorReason.getType());
|
||||
viewHolder1.get().tv_video_long.setText("继续");
|
||||
if(CommonUtil.BigModule())
|
||||
{
|
||||
viewHolder1.get().iv_video_Long.setImageResource(R.drawable.down_true_big);
|
||||
}
|
||||
else
|
||||
{
|
||||
viewHolder1.get().iv_video_Long.setImageResource(R.drawable.down_true);
|
||||
}
|
||||
|
||||
handlerListener.sendEmptyMessage(DOWNING);
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(contextWeakReference.get());
|
||||
builder.setTitle("错误");
|
||||
builder.setMessage(message);
|
||||
builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
try{
|
||||
builder.show();
|
||||
}catch (Exception e){
|
||||
ToastUtil.showMessage(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class MyDownloadSpeedListener implements IPolyvDownloaderSpeedListener {
|
||||
private WeakReference<ListView> wr_lv_download;
|
||||
private WeakReference<ViewHolder> viewHolder;
|
||||
private PolyvDownloader downloader;
|
||||
private int position;
|
||||
|
||||
public MyDownloadSpeedListener(ListView lv_download, ViewHolder viewHolder, PolyvDownloader downloader, int position) {
|
||||
this.wr_lv_download = new WeakReference<ListView>(lv_download);
|
||||
this.viewHolder = new WeakReference<ViewHolder>(viewHolder);
|
||||
this.downloader = downloader;
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
private boolean canUpdateView() {
|
||||
ListView lv_download = wr_lv_download.get();
|
||||
return lv_download != null && viewHolder.get() != null && lv_download.getChildAt(position - lv_download.getFirstVisiblePosition()) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSpeed(int speed) {
|
||||
LogUtil.e("下载速度"+speed);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private static class MyDownloaderStartListener implements IPolyvDownloaderStartListener {
|
||||
private WeakReference<ListView> wr_lv_download;
|
||||
private WeakReference<ViewHolder> viewHolder;
|
||||
private int position;
|
||||
|
||||
public MyDownloaderStartListener(ListView lv_download, ViewHolder viewHolder, int position) {
|
||||
this.wr_lv_download = new WeakReference<ListView>(lv_download);
|
||||
this.viewHolder = new WeakReference<ViewHolder>(viewHolder);
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
private boolean canUpdateView() {
|
||||
ListView lv_download = wr_lv_download.get();
|
||||
return lv_download != null && viewHolder.get() != null && lv_download.getChildAt(position - lv_download.getFirstVisiblePosition()) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
if (canUpdateView()) {
|
||||
viewHolder.get().tv_status.setText(DOWNLOADING);
|
||||
viewHolder.get().tv_status.setSelected(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void showPauseSpeeView(PolyvDownloadInfo downloadInfo, TextView tv_speed) {
|
||||
long percent = downloadInfo.getPercent();
|
||||
long total = downloadInfo.getTotal();
|
||||
int progress = 0;
|
||||
if (total != 0)
|
||||
progress = (int) (percent * 100 / total);
|
||||
// 已下载的文件大小
|
||||
long downloaded = downloadInfo.getFilesize() * progress / 100;
|
||||
tv_speed.setText(FileUtils.formatFileSize( downloaded)+"/");
|
||||
}
|
||||
|
||||
private class ViewHolder {
|
||||
RoundImageView iv_start;
|
||||
ImageView iv_video_Long;
|
||||
TextView tv_title, tv_size, tv_status, tv_speed;
|
||||
ProgressBar pb_progress;
|
||||
TextView tv_video_long;
|
||||
TextView tv_author;
|
||||
RelativeLayout sl_download;
|
||||
ImageView cb_check;
|
||||
RelativeLayout rl_check;
|
||||
|
||||
public void setDownloadListener(PolyvDownloader downloader, final PolyvDownloadInfo downloadInfo, final int position, List<PolyvDownloadInfo> lists,Handler handler) {
|
||||
downloader.setPolyvDownloadSpeedListener(new MyDownloadSpeedListener(lv_download, this, downloader, position));
|
||||
downloader.setPolyvDownloadProressListener(new MyDownloadListener(context, lv_download, this, downloadInfo, position, lists,handler));
|
||||
downloader.setPolyvDownloadStartListener(new MyDownloaderStartListener(lv_download, this, position));
|
||||
}
|
||||
}
|
||||
|
||||
private class DownloadOnClickListener implements View.OnClickListener {
|
||||
private PolyvDownloadInfo downloadInfo;
|
||||
private ImageView iv_start;
|
||||
private TextView tv_status;
|
||||
private TextView tv_speed;
|
||||
private TextView tv_video_long;
|
||||
private ImageView iv_video_long;
|
||||
|
||||
public DownloadOnClickListener(PolyvDownloadInfo downloadInfo, ImageView iv_start, TextView tv_status, TextView tv_speed,TextView tv_video_long,ImageView iv_video_long) {
|
||||
this.downloadInfo = downloadInfo;
|
||||
this.iv_start = iv_start;
|
||||
this.tv_status = tv_status;
|
||||
this.tv_speed = tv_speed;
|
||||
this.tv_video_long = tv_video_long;
|
||||
this.iv_video_long = iv_video_long;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
boolean check = downloadInfo.isCheck();
|
||||
if (!isEdit){
|
||||
String vid = downloadInfo.getVid();
|
||||
int bitrate = downloadInfo.getBitrate();
|
||||
|
||||
final PolyvDownloader downloader = PolyvDownloaderManager.getPolyvDownloader(vid, bitrate);
|
||||
if (tv_status.getText().equals(DOWNLOADED)) {//已下载
|
||||
Intent intent = VideoDetailPolyvPlayerActivity.newIntent(context, VideoDetailPolyvPlayerActivity.PlayMode.portrait,vid);
|
||||
// 在线视频和下载的视频播放的时候只显示播放器窗口,用该参数来控制
|
||||
intent.putExtra("startNow", true);
|
||||
intent.putExtra("isVlmsOnline", false);
|
||||
intent.putExtra("uuid",downloadInfo.getUuid());
|
||||
intent.putExtra("mustplay",true);
|
||||
context.startActivity(intent);
|
||||
|
||||
} else if (tv_status.getText().equals(DOWNLOADING) || tv_status.getText().equals(WAITED)) {
|
||||
tv_status.setText(PAUSEED);
|
||||
tv_status.setSelected(true);
|
||||
tv_video_long.setText("继续");
|
||||
if(CommonUtil.BigModule())
|
||||
{
|
||||
iv_video_long.setImageResource(R.drawable.down_true_big);
|
||||
}
|
||||
else
|
||||
{
|
||||
iv_video_long.setImageResource(R.drawable.down_true);
|
||||
}
|
||||
downloader.stop();
|
||||
showPauseSpeeView(downloadInfo, tv_speed);
|
||||
} else {
|
||||
tv_status.setText(DOWNLOADING);
|
||||
tv_status.setSelected(false);
|
||||
tv_video_long.setText("停止");
|
||||
if(CommonUtil.BigModule())
|
||||
{
|
||||
iv_video_long.setImageResource(R.drawable.down_false_big);
|
||||
}
|
||||
else
|
||||
{
|
||||
iv_video_long.setImageResource(R.drawable.down_false);
|
||||
}
|
||||
|
||||
downloader.start(context);
|
||||
if (!downloader.isDownloading() && PolyvDownloaderManager.isWaitingDownload(vid, bitrate)) {
|
||||
tv_status.setText(WAITED);
|
||||
tv_video_long.setText("等待");
|
||||
if(CommonUtil.BigModule())
|
||||
{
|
||||
iv_video_long.setImageResource(R.drawable.video_long_big);
|
||||
}
|
||||
else
|
||||
{
|
||||
iv_video_long.setImageResource(R.drawable.video_long);
|
||||
}
|
||||
tv_status.setSelected(true);
|
||||
}
|
||||
}
|
||||
}else {
|
||||
if (check){
|
||||
downloadInfo.setCheck(false);
|
||||
if(CommonUtil.BigModule())
|
||||
{
|
||||
viewHolder.cb_check.setBackgroundResource(R.drawable.check_video_false_big);
|
||||
}
|
||||
else
|
||||
{
|
||||
viewHolder.cb_check.setBackgroundResource(R.drawable.check_video_false);
|
||||
}
|
||||
|
||||
}else {
|
||||
downloadInfo.setCheck(true);
|
||||
if(CommonUtil.BigModule())
|
||||
{
|
||||
viewHolder.cb_check.setBackgroundResource(R.drawable.check_video_true_big);
|
||||
}
|
||||
else
|
||||
{
|
||||
viewHolder.cb_check.setBackgroundResource(R.drawable.check_video_true);
|
||||
}
|
||||
|
||||
}
|
||||
mHandler.sendEmptyMessage(0);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer.adapter;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentPagerAdapter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PolyvPlayerFragmentAdapter extends FragmentPagerAdapter {
|
||||
List<Fragment> fragmentList = new ArrayList<Fragment>();
|
||||
|
||||
public PolyvPlayerFragmentAdapter(FragmentManager fm) {
|
||||
super(fm);
|
||||
}
|
||||
|
||||
public PolyvPlayerFragmentAdapter(FragmentManager fm, List<Fragment> fragmentList) {
|
||||
super(fm);
|
||||
this.fragmentList = fragmentList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Fragment getItem(int position) {
|
||||
return fragmentList.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return fragmentList.size();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer.cast;
|
||||
|
||||
public interface PolyvIUIUpdateListener {
|
||||
|
||||
int STATE_SEARCH_SUCCESS = 1;
|
||||
int STATE_SEARCH_ERROR = 2;
|
||||
int STATE_SEARCH_NO_RESULT = 3;
|
||||
int STATE_CONNECT_SUCCESS = 10;
|
||||
int STATE_DISCONNECT = 11;// 连接断开
|
||||
int STATE_CONNECT_FAILURE = 12;// 连接失败
|
||||
int STATE_PLAY = 20;
|
||||
int STATE_PAUSE = 21;
|
||||
int STATE_COMPLETION = 22;
|
||||
int STATE_STOP = 23;
|
||||
int STATE_SEEK = 24;
|
||||
int STATE_POSITION_UPDATE = 25;
|
||||
int STATE_PLAY_ERROR = 26;
|
||||
int STATE_LOADING = 27;
|
||||
int STATE_INPUT_SCREENCODE = 28;
|
||||
int RELEVANCE_DATA_UNSUPPORT = 29;
|
||||
|
||||
void onUpdateState(int state, Object object);
|
||||
|
||||
void onUpdateText(String msg);
|
||||
|
||||
}
|
||||
+161
@@ -0,0 +1,161 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer.database;
|
||||
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import cn.shangyu.gdxzExpert.bean.PolyvDownloadInfo;
|
||||
|
||||
|
||||
public class PolyvDownloadSQLiteHelper extends SQLiteOpenHelper {
|
||||
private static PolyvDownloadSQLiteHelper sqLiteHelper;
|
||||
private static final String DATABASENAME = "downloadlist.db";
|
||||
private static final int VERSION = 6;
|
||||
|
||||
public static PolyvDownloadSQLiteHelper getInstance(Context context) {
|
||||
if (sqLiteHelper == null) {
|
||||
synchronized (PolyvDownloadSQLiteHelper.class) {
|
||||
if (sqLiteHelper == null)
|
||||
sqLiteHelper = new PolyvDownloadSQLiteHelper(context.getApplicationContext(), DATABASENAME, null, VERSION);
|
||||
}
|
||||
}
|
||||
return sqLiteHelper;
|
||||
}
|
||||
|
||||
private PolyvDownloadSQLiteHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
|
||||
super(context, name, factory, version);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(SQLiteDatabase db) {
|
||||
db.execSQL(
|
||||
"create table if not exists downloadlist(vid varchar(20),title varchar(100),duration varchar(20),filesize int,bitrate int,percent int default 0,total int default 0,img varchar(100),author varchar(20),uuid varchar(100),primary key (vid, bitrate))");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||
db.execSQL("drop table if exists downloadlist");
|
||||
onCreate(db);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加下载信息至数据库
|
||||
* @param info
|
||||
*/
|
||||
public void insert(PolyvDownloadInfo info) {
|
||||
SQLiteDatabase db = getWritableDatabase();
|
||||
String sql = "insert into downloadlist(vid,title,duration,filesize,bitrate,img,author,uuid) values(?,?,?,?,?,?,?,?)";
|
||||
db.execSQL(sql, new Object[]{info.getVid(), info.getTitle(), info.getDuration(),info.getFilesize(), info.getBitrate(),info.getHeadImg(),info.getAuthor(),info.getUuid()});
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除下载信息从数据库中
|
||||
* @param info
|
||||
*/
|
||||
public void delete(PolyvDownloadInfo info) {
|
||||
SQLiteDatabase db = getWritableDatabase();
|
||||
String sql = "delete from downloadlist where vid=? and bitrate=?";
|
||||
db.execSQL(sql, new Object[]{info.getVid(), info.getBitrate()});
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新下载的进度至数据库
|
||||
* @param info
|
||||
* @param percent
|
||||
* @param total
|
||||
*/
|
||||
public void update(PolyvDownloadInfo info, long percent, long total) {
|
||||
SQLiteDatabase db = getWritableDatabase();
|
||||
String sql = "update downloadlist set percent=?,total=? where vid=? and bitrate=?";
|
||||
db.execSQL(sql, new Object[]{percent, total, info.getVid(), info.getBitrate()});
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断该下载信息是否已以添加过
|
||||
* @param info
|
||||
* @return
|
||||
*/
|
||||
public boolean isAdd(PolyvDownloadInfo info) {
|
||||
SQLiteDatabase db = getWritableDatabase();
|
||||
String sql = "select vid ,duration,filesize,bitrate from downloadlist where vid=? and bitrate=?";
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
cursor = db.rawQuery(sql, new String[]{info.getVid(), info.getBitrate() + ""});
|
||||
return cursor.getCount() == 1 ? true : false;
|
||||
} finally {
|
||||
if (cursor != null)
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有的下载信息对象
|
||||
* @return
|
||||
*/
|
||||
public LinkedList<PolyvDownloadInfo> getAll() {
|
||||
LinkedList<PolyvDownloadInfo> infos = new LinkedList<PolyvDownloadInfo>();
|
||||
SQLiteDatabase db = getWritableDatabase();
|
||||
String sql = "select vid,title,duration,filesize,bitrate,percent,total,img,author,uuid from downloadlist";
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
cursor = db.rawQuery(sql, null);
|
||||
while (cursor.moveToNext()) {
|
||||
String vid = cursor.getString(cursor.getColumnIndex("vid"));
|
||||
String title = cursor.getString(cursor.getColumnIndex("title"));
|
||||
String duration = cursor.getString(cursor.getColumnIndex("duration"));
|
||||
long filesize = cursor.getInt(cursor.getColumnIndex("filesize"));
|
||||
int bitrate = cursor.getInt(cursor.getColumnIndex("bitrate"));
|
||||
long percent = cursor.getInt(cursor.getColumnIndex("percent"));
|
||||
long total = cursor.getInt(cursor.getColumnIndex("total"));
|
||||
String img = cursor.getString(cursor.getColumnIndex("img"));
|
||||
String author = cursor.getString(cursor.getColumnIndex("author"));
|
||||
String uuid = cursor.getString(cursor.getColumnIndex("uuid"));
|
||||
PolyvDownloadInfo info = new PolyvDownloadInfo(vid, duration, filesize, bitrate, title,img,author,uuid);
|
||||
info.setPercent(percent);
|
||||
info.setTotal(total);
|
||||
infos.addLast(info);
|
||||
}
|
||||
} finally {
|
||||
if (cursor != null)
|
||||
cursor.close();
|
||||
}
|
||||
return infos;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取某个的下载信息对象
|
||||
* @return
|
||||
*/
|
||||
public LinkedList<PolyvDownloadInfo> getloadInfo(String vid1) {
|
||||
LinkedList<PolyvDownloadInfo> infos = new LinkedList<PolyvDownloadInfo>();
|
||||
SQLiteDatabase db = getWritableDatabase();
|
||||
String sql = "select vid,title,duration,filesize,bitrate,percent,total,img,author,uuid from downloadlist where vid=?";
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
cursor = db.rawQuery(sql, new String[]{vid1});
|
||||
while (cursor.moveToNext()) {
|
||||
String vid = cursor.getString(cursor.getColumnIndex("vid"));
|
||||
String title = cursor.getString(cursor.getColumnIndex("title"));
|
||||
String duration = cursor.getString(cursor.getColumnIndex("duration"));
|
||||
long filesize = cursor.getInt(cursor.getColumnIndex("filesize"));
|
||||
int bitrate = cursor.getInt(cursor.getColumnIndex("bitrate"));
|
||||
long percent = cursor.getInt(cursor.getColumnIndex("percent"));
|
||||
long total = cursor.getInt(cursor.getColumnIndex("total"));
|
||||
String img = cursor.getString(cursor.getColumnIndex("img"));
|
||||
String author = cursor.getString(cursor.getColumnIndex("author"));
|
||||
String uuid = cursor.getString(cursor.getColumnIndex("uuid"));
|
||||
PolyvDownloadInfo info = new PolyvDownloadInfo(vid, duration, filesize, bitrate, title,img,author,uuid);
|
||||
info.setPercent(percent);
|
||||
info.setTotal(total);
|
||||
infos.addLast(info);
|
||||
}
|
||||
} finally {
|
||||
if (cursor != null)
|
||||
cursor.close();
|
||||
}
|
||||
return infos;
|
||||
}
|
||||
}
|
||||
+135
@@ -0,0 +1,135 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer.database;
|
||||
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import cn.shangyu.gdxzExpert.bean.PolyvUploadInfo;
|
||||
|
||||
|
||||
public class PolyvUploadSQLiteHelper extends SQLiteOpenHelper{
|
||||
private static PolyvUploadSQLiteHelper sqLiteHelper;
|
||||
private static final String DATABASENAME = "uploadlist.db";
|
||||
private static final int VERSION = 6;
|
||||
|
||||
public static PolyvUploadSQLiteHelper getInstance(Context context) {
|
||||
if (sqLiteHelper == null) {
|
||||
synchronized (PolyvUploadSQLiteHelper.class) {
|
||||
if (sqLiteHelper == null)
|
||||
sqLiteHelper = new PolyvUploadSQLiteHelper(context.getApplicationContext(), DATABASENAME, null, VERSION);
|
||||
}
|
||||
}
|
||||
return sqLiteHelper;
|
||||
}
|
||||
|
||||
private PolyvUploadSQLiteHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
|
||||
super(context, name, factory, version);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(SQLiteDatabase db) {
|
||||
db.execSQL(
|
||||
"create table if not exists uploadlist(title varchar(100),filepath varchar(120),desc varchar(20),filesize int,percent int default 0,total int default 0,cataid varchar(20),primary key (filepath))");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||
db.execSQL("drop table if exists uploadlist");
|
||||
onCreate(db);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加上传信息至数据库
|
||||
* @param info
|
||||
*/
|
||||
public void insert(PolyvUploadInfo info) {
|
||||
SQLiteDatabase db = getWritableDatabase();
|
||||
String sql = "insert into uploadlist(title,desc,filesize,filepath,cataid) values(?,?,?,?,?)";
|
||||
db.execSQL(sql, new Object[] {info.getTitle(), info.getDesc(), info.getFilesize(),
|
||||
info.getFilepath(),info.getCataid() });
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除上传信息从数据库中
|
||||
* @param info
|
||||
*/
|
||||
public void delete(PolyvUploadInfo info) {
|
||||
SQLiteDatabase db = getWritableDatabase();
|
||||
String sql = "delete from uploadlist where filepath=?";
|
||||
db.execSQL(sql, new Object[] { info.getFilepath() });
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新上传的分类id至数据库
|
||||
* @param info
|
||||
*/
|
||||
public void updateCataid(PolyvUploadInfo info) {
|
||||
SQLiteDatabase db = getWritableDatabase();
|
||||
String sql = "update uploadlist set cataid=? where filepath=?";
|
||||
db.execSQL(sql, new Object[]{ info.getCataid(), info.getFilepath() });
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新上传的进度至数据库
|
||||
* @param info
|
||||
* @param percent
|
||||
* @param total
|
||||
*/
|
||||
public void update(PolyvUploadInfo info, long percent, long total) {
|
||||
SQLiteDatabase db = getWritableDatabase();
|
||||
String sql = "update uploadlist set percent=?,total=? where filepath=?";
|
||||
db.execSQL(sql, new Object[] { percent, total, info.getFilepath() });
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断该上传信息是否已以添加过
|
||||
* @param info
|
||||
* @return
|
||||
*/
|
||||
public boolean isAdd(PolyvUploadInfo info) {
|
||||
SQLiteDatabase db = getWritableDatabase();
|
||||
String sql = "select filepath ,title,desc from uploadlist where filepath=?";
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
cursor = db.rawQuery(sql, new String[] { info.getFilepath() });
|
||||
return cursor.getCount() == 1 ? true : false;
|
||||
} finally {
|
||||
if (cursor != null)
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有的上传信息对象
|
||||
* @return
|
||||
*/
|
||||
public LinkedList<PolyvUploadInfo> getAll() {
|
||||
LinkedList<PolyvUploadInfo> infos = new LinkedList<PolyvUploadInfo>();
|
||||
SQLiteDatabase db = getWritableDatabase();
|
||||
String sql = "select title,filepath,desc,filesize,percent,total,cataid from uploadlist";
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
cursor = db.rawQuery(sql, null);
|
||||
while (cursor.moveToNext()) {
|
||||
String title = cursor.getString(cursor.getColumnIndex("title"));
|
||||
String filepath = cursor.getString(cursor.getColumnIndex("filepath"));
|
||||
String desc = cursor.getString(cursor.getColumnIndex("desc"));
|
||||
long filesize = cursor.getLong(cursor.getColumnIndex("filesize"));
|
||||
long percent = cursor.getInt(cursor.getColumnIndex("percent"));
|
||||
long total = cursor.getInt(cursor.getColumnIndex("total"));
|
||||
String cataid = cursor.getString(cursor.getColumnIndex("cataid"));
|
||||
PolyvUploadInfo info = new PolyvUploadInfo(title, desc, filesize, filepath, cataid);
|
||||
info.setPercent(percent);
|
||||
info.setTotal(total);
|
||||
infos.addLast(info);
|
||||
}
|
||||
} finally {
|
||||
if (cursor != null)
|
||||
cursor.close();
|
||||
}
|
||||
return infos;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer.fragment;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.os.Bundle;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import android.text.TextPaint;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import cn.shangyu.gdxzExpert.R;
|
||||
import cn.shangyu.gdxzExpert.bean.ListSeriesVideoByTypeBean;
|
||||
import cn.shangyu.gdxzExpert.polyvplayer.PolyvPlayerActivity;
|
||||
import cn.shangyu.gdxzExpert.polyvplayer.adapter.CurriculumAdapter;
|
||||
import cn.shangyu.gdxzExpert.utils.StringUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.ToastUtil;
|
||||
|
||||
|
||||
/**
|
||||
* Created by WANGChengXin on 2019/3/25.
|
||||
*/
|
||||
|
||||
@SuppressLint("ValidFragment")
|
||||
public class CurriculumFragment extends Fragment implements AdapterView.OnItemClickListener{
|
||||
private View view;
|
||||
private ListView lv_curriculum;
|
||||
private TextView tv_mulu_title;
|
||||
private PolyvPlayerActivity polyvPlayerActivity;
|
||||
private List<ListSeriesVideoByTypeBean.DataBean.ListBean> list;
|
||||
private String title;
|
||||
private CurriculumAdapter adapter;
|
||||
private int is_paid;
|
||||
private int is_white;
|
||||
private String vid;
|
||||
|
||||
|
||||
@SuppressLint("ValidFragment")
|
||||
public CurriculumFragment(PolyvPlayerActivity polyvPlayerActivity, List<ListSeriesVideoByTypeBean.DataBean.ListBean> list, String title, int is_paid, int is_white, String vid) {
|
||||
this.polyvPlayerActivity = polyvPlayerActivity;
|
||||
this.list = list;
|
||||
this.title = title;
|
||||
this.is_paid = is_paid;
|
||||
this.is_white = is_white;
|
||||
this.vid = vid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
super.onCreateView(inflater, container, savedInstanceState);
|
||||
if (view == null)
|
||||
view = inflater.inflate(R.layout.fragment_curriculum, container, false);
|
||||
lv_curriculum = view.findViewById(R.id.lv_curriculum);
|
||||
tv_mulu_title = view.findViewById(R.id.tv_mulu_title);
|
||||
tv_mulu_title.setText(title);
|
||||
TextPaint tp = tv_mulu_title.getPaint();
|
||||
tp.setFakeBoldText(true);
|
||||
adapter = new CurriculumAdapter(getActivity(),list);
|
||||
lv_curriculum.setAdapter(adapter);
|
||||
lv_curriculum.setOnItemClickListener(this);
|
||||
|
||||
for (int i = 0;i<list.size();i++){
|
||||
if (!StringUtil.isEmpty(vid)&&list.get(i).getPolyv_uuid().equals(vid)){
|
||||
adapter.setPlayingPosition(i);
|
||||
lv_curriculum.setSelection(i);
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
if (is_white==1 || is_paid == 1||"1".equals(list.get(position).getType())||"2".equals(list.get(position).getType())){
|
||||
polyvPlayerActivity.getVidlistener(list.get(position).getPolyv_uuid(),list.get(position).getUuid());
|
||||
adapter.setPlayingPosition(position);
|
||||
adapter.notifyDataSetChanged();
|
||||
|
||||
|
||||
}else {
|
||||
ToastUtil.showMessage("请兑换后再点击观看");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer.fragment;
|
||||
|
||||
import static cn.shangyu.gdxzExpert.utils.Constant.fragmentHeight3;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.JavascriptInterface;
|
||||
import android.webkit.WebResourceError;
|
||||
import android.webkit.WebResourceRequest;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import cn.shangyu.gdxzExpert.R;
|
||||
import cn.shangyu.gdxzExpert.polyvplayer.PolyvPlayerActivity;
|
||||
import cn.shangyu.gdxzExpert.ui.CustomProgressDialog;
|
||||
import cn.shangyu.gdxzExpert.utils.LogUtil;
|
||||
import cn.shangyu.gdxzExpert.view.X5WebView;
|
||||
|
||||
/**
|
||||
* Created by WANGChengXin on 2019/3/25.
|
||||
*/
|
||||
|
||||
@SuppressLint("ValidFragment")
|
||||
public class ExchangeFragment extends Fragment {
|
||||
private View view;
|
||||
private WebSettings settings;
|
||||
private X5WebView wv;
|
||||
Mobile mobile = new Mobile();
|
||||
private String note_url;
|
||||
private PolyvPlayerActivity polyvPlayerActivity;
|
||||
private CustomProgressDialog dialog;
|
||||
private boolean isVisibleToUser;
|
||||
@SuppressLint("ValidFragment")
|
||||
public ExchangeFragment(PolyvPlayerActivity polyvPlayerActivity) {
|
||||
this.polyvPlayerActivity = polyvPlayerActivity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
super.onCreateView(inflater, container, savedInstanceState);
|
||||
if (view == null)
|
||||
view = inflater.inflate(R.layout.fragment_summary, container, false);
|
||||
X5WebView.initHardwareAccelerate(getActivity());
|
||||
wv = view.findViewById(R.id.wb);
|
||||
wv.loadUrl("http://doc.igandan.com/app/seriesvideo/notice.html");
|
||||
settings = wv.getSettings();
|
||||
settings.setJavaScriptEnabled(true);//支持js
|
||||
wv.setWebViewClient(mClient);
|
||||
wv.addJavascriptInterface(mobile, "mobile");
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
public void setUserVisibleHint(boolean isVisibleToUser) {
|
||||
super.setUserVisibleHint(isVisibleToUser);
|
||||
this.isVisibleToUser = isVisibleToUser;
|
||||
LogUtil.i("isVisibleToUser = "+isVisibleToUser);
|
||||
if (isVisibleToUser){
|
||||
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if (this.isVisibleToUser) {
|
||||
|
||||
}
|
||||
}
|
||||
private class Mobile {
|
||||
@JavascriptInterface
|
||||
public void onGetWebContentHeight() {
|
||||
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
wv.measure(0, 0);
|
||||
int measuredHeight = wv.getMeasuredHeight();
|
||||
LogUtil.i("measuredHeight32 = "+measuredHeight);
|
||||
if (fragmentHeight3==0){
|
||||
fragmentHeight3 =measuredHeight;
|
||||
if (isVisibleToUser){
|
||||
polyvPlayerActivity.getheightListenr(fragmentHeight3);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}, 300);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static int px2dip(Context context, float pxValue) {
|
||||
final float scale = context.getResources().getDisplayMetrics().density;
|
||||
return (int) (pxValue / scale + 0.5f);
|
||||
}
|
||||
|
||||
|
||||
private WebViewClient mClient = new WebViewClient() {
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onPageFinished(WebView view, String url) {
|
||||
mobile.onGetWebContentHeight();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadResource(WebView view, String url) {
|
||||
|
||||
super.onLoadResource(view, url);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) {
|
||||
super.onReceivedError(view, request, error);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer.fragment;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
/**
|
||||
* Fragment预加载问题的解决方案:
|
||||
* 1.可以懒加载的Fragment
|
||||
* 2.切换到其他页面时停止加载数据(可选)
|
||||
* Created by yuandl on 2016-11-17.
|
||||
* blog :http://blog.csdn.net/linglongxin24/article/details/53205878
|
||||
*/
|
||||
|
||||
public abstract class LazyLoadFragment extends Fragment {
|
||||
/**
|
||||
* 视图是否已经初初始化
|
||||
*/
|
||||
protected boolean isInit = false;
|
||||
protected boolean isLoad = false;
|
||||
protected final String TAG = "LazyLoadFragment";
|
||||
private View view;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
view = inflater.inflate(setContentView(), container, false);
|
||||
isInit = true;
|
||||
/**初始化的时候去加载数据**/
|
||||
isCanLoadData();
|
||||
return view;
|
||||
}
|
||||
|
||||
/**
|
||||
* 视图是否已经对用户可见,系统的方法
|
||||
*/
|
||||
@Override
|
||||
public void setUserVisibleHint(boolean isVisibleToUser) {
|
||||
super.setUserVisibleHint(isVisibleToUser);
|
||||
isCanLoadData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否可以加载数据
|
||||
* 可以加载数据的条件:
|
||||
* 1.视图已经初始化
|
||||
* 2.视图对用户可见
|
||||
*/
|
||||
private void isCanLoadData() {
|
||||
if (!isInit) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (getUserVisibleHint()) {
|
||||
lazyLoad();
|
||||
isLoad = true;
|
||||
} else {
|
||||
if (isLoad) {
|
||||
stopLoad();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 视图销毁的时候讲Fragment是否初始化的状态变为false
|
||||
*/
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
isInit = false;
|
||||
isLoad = false;
|
||||
|
||||
}
|
||||
|
||||
protected void showToast(String message) {
|
||||
if (!TextUtils.isEmpty(message)) {
|
||||
Toast.makeText(getContext(), message, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置Fragment要显示的布局
|
||||
*
|
||||
* @return 布局的layoutId
|
||||
*/
|
||||
protected abstract int setContentView();
|
||||
|
||||
/**
|
||||
* 获取设置的布局
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected View getContentView() {
|
||||
return view;
|
||||
}
|
||||
|
||||
/**
|
||||
* 找出对应的控件
|
||||
*
|
||||
* @param id
|
||||
* @param <T>
|
||||
* @return
|
||||
*/
|
||||
protected <T extends View> T findViewById(int id) {
|
||||
|
||||
return (T) getContentView().findViewById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 当视图初始化并且对用户可见的时候去真正的加载数据
|
||||
*/
|
||||
protected abstract void lazyLoad();
|
||||
|
||||
/**
|
||||
* 当视图已经对用户不可见并且加载过数据,如果需要在切换到其他页面时停止加载数据,可以覆写此方法
|
||||
*/
|
||||
protected void stopLoad() {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+269
@@ -0,0 +1,269 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer.fragment;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.ListView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import cn.shangyu.gdxzExpert.R;
|
||||
import cn.shangyu.gdxzExpert.bean.PolyvDownloadInfo;
|
||||
import cn.shangyu.gdxzExpert.polyvplayer.PolyvDownloadActivity;
|
||||
import cn.shangyu.gdxzExpert.polyvplayer.adapter.PolyvDownloadListViewAdapter;
|
||||
import cn.shangyu.gdxzExpert.polyvplayer.database.PolyvDownloadSQLiteHelper;
|
||||
import cn.shangyu.gdxzExpert.utils.CommonUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.MemoryTools;
|
||||
import cn.shangyu.gdxzExpert.utils.ToastUtil;
|
||||
import cn.shangyu.gdxzExpert.widget.ECAlertDialog;
|
||||
|
||||
/**
|
||||
* 已完成/缓存中
|
||||
* */
|
||||
@SuppressLint("ValidFragment")
|
||||
public class PolyvDownloadFragment extends Fragment {
|
||||
private View view;
|
||||
private ListView lv_download;
|
||||
private List<PolyvDownloadInfo> downloadInfos;//已完成/缓冲中的集合
|
||||
private PolyvDownloadListViewAdapter downloadAdapter;
|
||||
|
||||
private RelativeLayout rl_bot;
|
||||
// 底部下载全部按钮
|
||||
// private LinearLayout ll_downloadall, ll_deleteall;
|
||||
// // 下载全部的文本控件
|
||||
// private TextView tv_downloadall;
|
||||
private ECAlertDialog buildAlert;
|
||||
private TextView tv_deleteall;
|
||||
private TextView tv_all;
|
||||
private TextView tv_zong;
|
||||
private TextView tv_zong2;
|
||||
private CheckBox top_right_text;
|
||||
public static final int DOWNING = 1;
|
||||
public static final int DOWNEND = 2;
|
||||
Handler mHandler = new Handler() {
|
||||
public void handleMessage(Message msg) {
|
||||
if (msg != null) {
|
||||
int i = msg.what;
|
||||
switch (i){
|
||||
case 0:
|
||||
int k = 0;
|
||||
for (int j = 0;j<downloadInfos.size();j++){
|
||||
if (downloadInfos.get(j).isCheck()){
|
||||
k++;
|
||||
}
|
||||
}
|
||||
if (k!=0){
|
||||
tv_deleteall.setText("删除("+k+")");
|
||||
}else {
|
||||
tv_deleteall.setText("删除");
|
||||
}
|
||||
if (k==downloadInfos.size()){
|
||||
tv_all.setText("取消全选");
|
||||
}else {
|
||||
tv_all.setText("全选");
|
||||
}
|
||||
downloadAdapter.notifyDataSetChanged();
|
||||
break;
|
||||
case DOWNING:
|
||||
downloadAdapter.notifyDataSetChanged();
|
||||
break;
|
||||
case DOWNEND:
|
||||
LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance(getActivity());
|
||||
Intent intent = new Intent("LOADEND");
|
||||
intent.putExtra("vid",(String) msg.obj);
|
||||
//发送本地广播
|
||||
localBroadcastManager.sendBroadcast(intent);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@SuppressLint("ValidFragment")
|
||||
public PolyvDownloadFragment(CheckBox top_right_text) {
|
||||
this.top_right_text = top_right_text;
|
||||
}
|
||||
public PolyvDownloadFragment(){
|
||||
super();
|
||||
}
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
if(view == null )
|
||||
{
|
||||
if(CommonUtil.BigModule())
|
||||
{
|
||||
view = inflater.inflate(R.layout.polyv_fragment_download_big, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
view = inflater.inflate(R.layout.polyv_fragment_download, null);
|
||||
}
|
||||
}
|
||||
return view;
|
||||
// return view == null ? view = inflater.inflate(R.layout.polyv_fragment_download, null) : view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
initView();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
boolean isFinished = getArguments().getBoolean("isFinished");
|
||||
lv_download = (ListView) view.findViewById(R.id.lv_download);
|
||||
downloadInfos = new ArrayList<>();
|
||||
downloadInfos.addAll(getTask(PolyvDownloadSQLiteHelper.getInstance(getContext()).getAll(), isFinished));
|
||||
downloadAdapter = new PolyvDownloadListViewAdapter(downloadInfos, getContext(), lv_download,mHandler);
|
||||
if (!isFinished) {
|
||||
downloadAdapter.setDownloadSuccessListener(new PolyvDownloadListViewAdapter.DownloadSuccessListener() {
|
||||
@Override
|
||||
public void onDownloadSuccess(PolyvDownloadInfo downloadInfo) {
|
||||
((PolyvDownloadActivity) getActivity()).getDownloadedFragment().addTask(downloadInfo);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
lv_download.setAdapter(downloadAdapter);
|
||||
TextView tv_empty_msg = (TextView) view.findViewById(R.id.tv_empty_msg);
|
||||
tv_empty_msg.setText("暂无视频");
|
||||
lv_download.setEmptyView(view.findViewById(R.id.ll_empty));
|
||||
|
||||
rl_bot = (RelativeLayout) view.findViewById(R.id.rl_bot);
|
||||
|
||||
tv_deleteall = (TextView) view.findViewById(R.id.tv_deleteall);
|
||||
tv_zong = (TextView) view.findViewById(R.id.tv_zong);
|
||||
tv_zong2 = (TextView) view.findViewById(R.id.tv_zong2);
|
||||
tv_all = (TextView) view.findViewById(R.id.tv_all);
|
||||
// DrawableCompat.setTint(DrawableCompat.wrap(((ImageView) view.findViewById(R.id.iv_trash)).getDrawable().mutate()), getResources().getColor(R.color.center_bottom_text_color_red));
|
||||
|
||||
tv_all.setOnClickListener(new View.OnClickListener() {//全选
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if ("全选".equals(tv_all.getText().toString())){
|
||||
for (int i = 0;i<downloadInfos.size();i++){
|
||||
downloadInfos.get(i).setCheck(true);
|
||||
}
|
||||
tv_deleteall.setText("删除("+downloadInfos.size()+")");
|
||||
tv_all.setText("取消全选");
|
||||
}else {
|
||||
for (int i = 0;i<downloadInfos.size();i++){
|
||||
downloadInfos.get(i).setCheck(false);
|
||||
}
|
||||
tv_deleteall.setText("删除");
|
||||
tv_all.setText("全选");
|
||||
}
|
||||
downloadAdapter.notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
tv_deleteall.setOnClickListener(new View.OnClickListener() {//删除
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (downloadInfos.size() == 0) {
|
||||
return;
|
||||
}
|
||||
if ("删除".equals(tv_deleteall.getText().toString())){
|
||||
ToastUtil.showMessage("请选择视频");
|
||||
}else {
|
||||
buildAlert = ECAlertDialog.buildAlert(getActivity(), "是否要删除选中的视频?", "取消", "确认",
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
// TODO Auto-generated method stub
|
||||
buildAlert.dismiss();
|
||||
}
|
||||
}, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
downloadAdapter.deleteAllTask();
|
||||
downloadAdapter.setEditData(false);
|
||||
rl_bot.setVisibility(View.GONE);
|
||||
top_right_text.setText("编辑");
|
||||
top_right_text.setChecked(false);
|
||||
tv_deleteall.setText("删除");
|
||||
|
||||
}
|
||||
});
|
||||
buildAlert.setTitle("温馨提示");
|
||||
buildAlert.show();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
tv_zong.setText(MemoryTools.getInternalToatalSpace(getActivity()));
|
||||
tv_zong2.setText(MemoryTools.getInternalfreeSpace(getActivity()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void addTask(PolyvDownloadInfo downloadInfo) {
|
||||
downloadInfos.add(downloadInfo);
|
||||
downloadAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
private List<PolyvDownloadInfo> getTask(List<PolyvDownloadInfo> downloadInfos, boolean isFinished) {
|
||||
if (downloadInfos == null) {
|
||||
return null;
|
||||
}
|
||||
List<PolyvDownloadInfo> infos = new ArrayList<>();
|
||||
for (PolyvDownloadInfo downloadInfo : downloadInfos) {
|
||||
long percent = downloadInfo.getPercent();
|
||||
long total = downloadInfo.getTotal();
|
||||
// 已下载的百分比
|
||||
int progress = 0;
|
||||
if (total != 0) {
|
||||
progress = (int) (percent * 100 / total);
|
||||
}
|
||||
if (progress == 100) {
|
||||
if (isFinished) {
|
||||
infos.add(downloadInfo);
|
||||
}
|
||||
} else if (!isFinished) {
|
||||
infos.add(downloadInfo);
|
||||
}
|
||||
}
|
||||
return infos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
downloadAdapter.setDownloadSuccessListener(null);
|
||||
}
|
||||
|
||||
public void setEdit(boolean b) {
|
||||
if (b){
|
||||
downloadAdapter.setEditData(true);
|
||||
rl_bot.setVisibility(View.VISIBLE);
|
||||
}else {
|
||||
downloadAdapter.setEditData(false);
|
||||
for (int i = 0;i<downloadInfos.size();i++){
|
||||
downloadInfos.get(i).setCheck(false);
|
||||
}
|
||||
tv_deleteall.setText("删除");
|
||||
tv_all.setText("全选");
|
||||
rl_bot.setVisibility(View.GONE);
|
||||
}
|
||||
downloadAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
}
|
||||
+145
@@ -0,0 +1,145 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer.fragment;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import cn.shangyu.gdxzExpert.R;
|
||||
import cn.shangyu.gdxzExpert.bean.ListSeriesVideoByTypeBean;
|
||||
import cn.shangyu.gdxzExpert.polyvplayer.util.PolyvScreenUtils;
|
||||
import cn.shangyu.gdxzExpert.utils.StringUtil;
|
||||
|
||||
|
||||
public class PolyvPlayerTabFragment extends Fragment implements View.OnClickListener {
|
||||
//fragmentView
|
||||
private View view;
|
||||
//viewpagerFragment
|
||||
private PolyvPlayerViewPagerFragment viewPagerFragment;
|
||||
// tab文本的TextView,用于改变颜色
|
||||
private TextView tv_cur, tv_sum, tv_talk;
|
||||
// tab的导航线
|
||||
private View v_line;
|
||||
private int screenWidth;
|
||||
private int length;
|
||||
private int eLength;
|
||||
private RelativeLayout.LayoutParams lp;
|
||||
private String vid;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
if (view == null)
|
||||
view = inflater.inflate(R.layout.polyv_fragment_player_tab, container, false);
|
||||
return view;
|
||||
}
|
||||
|
||||
private void findIdAndNew() {
|
||||
tv_cur = (TextView) view.findViewById(R.id.tv_cur);
|
||||
tv_sum = (TextView) view.findViewById(R.id.tv_sum);
|
||||
tv_talk = (TextView) view.findViewById(R.id.tv_talk);
|
||||
v_line = view.findViewById(R.id.v_line);
|
||||
viewPagerFragment = (PolyvPlayerViewPagerFragment) getActivity().getSupportFragmentManager().findFragmentById(R.id.fl_viewpager);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
Bundle bundle =this.getArguments();//得到从Activity传来的数据
|
||||
ListSeriesVideoByTypeBean listSeriesVideoByTypeBean = (ListSeriesVideoByTypeBean) bundle.getSerializable("listSeriesVideoByTypeBean");
|
||||
vid = bundle.getString("vid");
|
||||
|
||||
initLineSetting();
|
||||
tv_cur.setSelected(true);
|
||||
tv_cur.setOnClickListener(this);
|
||||
tv_sum.setOnClickListener(this);
|
||||
tv_talk.setOnClickListener(this);
|
||||
}
|
||||
|
||||
private void initLineSetting() {
|
||||
lp = (RelativeLayout.LayoutParams) v_line.getLayoutParams();
|
||||
v_line.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
@Override
|
||||
public void onGlobalLayout() {
|
||||
final DisplayMetrics dm = new DisplayMetrics();
|
||||
getActivity().getWindow().getWindowManager().getDefaultDisplay().getMetrics(dm);
|
||||
if(PolyvScreenUtils.isLandscape(getContext()))
|
||||
screenWidth = dm.heightPixels;
|
||||
else
|
||||
screenWidth = dm.widthPixels;
|
||||
length = v_line.getWidth();
|
||||
int sLength = screenWidth / 3;
|
||||
eLength = (sLength - length) / 2;
|
||||
if (viewPagerFragment.getCurrentIndex() == 0)
|
||||
resetViewStatus(0);
|
||||
if (!StringUtil.isEmpty(vid)){
|
||||
resetViewStatus(1);
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= 16)
|
||||
getView().getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
||||
else
|
||||
getView().getViewTreeObserver().removeGlobalOnLayoutListener(this);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void resetViewStatus(int arg0) {
|
||||
tv_cur.setSelected(false);
|
||||
tv_sum.setSelected(false);
|
||||
tv_talk.setSelected(false);
|
||||
tv_cur.setTextColor(Color.parseColor("#999999"));
|
||||
tv_sum.setTextColor(Color.parseColor("#999999"));
|
||||
tv_talk.setTextColor(Color.parseColor("#999999"));
|
||||
switch (arg0) {
|
||||
case 0:
|
||||
tv_cur.setSelected(true);
|
||||
tv_cur.setTextColor(getResources().getColor(R.color.polyv_tab_text_color));
|
||||
lp.leftMargin = (int) (arg0 * (length)) + 1 * eLength;
|
||||
break;
|
||||
case 1:
|
||||
tv_sum.setSelected(true);
|
||||
tv_sum.setTextColor(getResources().getColor(R.color.polyv_tab_text_color));
|
||||
lp.leftMargin = (int) (arg0 * (length)) + 3 * eLength;
|
||||
break;
|
||||
case 2:
|
||||
tv_talk.setSelected(true);
|
||||
tv_talk.setTextColor(getResources().getColor(R.color.polyv_tab_text_color));
|
||||
lp.leftMargin = (int) (arg0 * (length)) + 5 * eLength;
|
||||
break;
|
||||
}
|
||||
v_line.setLayoutParams(lp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
findIdAndNew();
|
||||
initView();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
switch (view.getId()) {
|
||||
case R.id.tv_talk:
|
||||
viewPagerFragment.setCurrentItem(2);
|
||||
break;
|
||||
case R.id.tv_sum:
|
||||
viewPagerFragment.setCurrentItem(1);
|
||||
break;
|
||||
case R.id.tv_cur:
|
||||
viewPagerFragment.setCurrentItem(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
+166
@@ -0,0 +1,166 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer.fragment;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
import cn.shangyu.gdxzExpert.R;
|
||||
import cn.shangyu.gdxzExpert.bean.ListSeriesVideoByTypeBean;
|
||||
import cn.shangyu.gdxzExpert.polyvplayer.PolyvPlayerActivity;
|
||||
import cn.shangyu.gdxzExpert.polyvplayer.adapter.PolyvPlayerFragmentAdapter;
|
||||
import cn.shangyu.gdxzExpert.utils.LogUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.StringUtil;
|
||||
|
||||
import static cn.shangyu.gdxzExpert.utils.Constant.fragmentHeight1;
|
||||
import static cn.shangyu.gdxzExpert.utils.Constant.fragmentHeight2;
|
||||
import static cn.shangyu.gdxzExpert.utils.Constant.fragmentHeight3;
|
||||
|
||||
@SuppressLint("ValidFragment")
|
||||
public class PolyvPlayerViewPagerFragment extends Fragment {
|
||||
//fragmentView
|
||||
private View view;
|
||||
// 播放页的viewPager
|
||||
private ViewPager vp_player;
|
||||
private PolyvPlayerFragmentAdapter adapter;
|
||||
// 当前的索引
|
||||
private int currentIndex;
|
||||
private List<Fragment> lists;
|
||||
// 播放页viewpager的fragment
|
||||
private Fragment curFragment, sumFragment, talkFragment;
|
||||
private PolyvPlayerTabFragment tabFragment;
|
||||
private PolyvPlayerActivity polyvPlayerActivity;
|
||||
private TextView tv_name;
|
||||
|
||||
|
||||
@SuppressLint("ValidFragment")
|
||||
public PolyvPlayerViewPagerFragment(PolyvPlayerActivity polyvPlayerActivity) {
|
||||
this.polyvPlayerActivity = polyvPlayerActivity;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
if (view == null)
|
||||
view = inflater.inflate(R.layout.polyv_fragment_player_viewpager, container, false);
|
||||
return view;
|
||||
}
|
||||
|
||||
private void findIdAndNew() {
|
||||
vp_player = (ViewPager) view.findViewById(R.id.vp_player);
|
||||
tabFragment = (PolyvPlayerTabFragment) getActivity().getSupportFragmentManager().findFragmentById(R.id.fl_tab);
|
||||
lists = new ArrayList<Fragment>();
|
||||
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
Bundle bundle =this.getArguments();//得到从Activity传来的数据
|
||||
ListSeriesVideoByTypeBean listSeriesVideoByTypeBean = (ListSeriesVideoByTypeBean) bundle.getSerializable("listSeriesVideoByTypeBean");
|
||||
String vid = bundle.getString("vid");
|
||||
/**计算fragmentHeight2高度**/
|
||||
for (int i = 0;i<listSeriesVideoByTypeBean.getData().getList().size();i++){
|
||||
if (listSeriesVideoByTypeBean.getData().getList().get(i).getTitle().length()>13){
|
||||
fragmentHeight2 = fragmentHeight2+getResources().getDimensionPixelOffset(R.dimen.dp_103);
|
||||
}else {
|
||||
fragmentHeight2 = fragmentHeight2+getResources().getDimensionPixelOffset(R.dimen.dp_78);
|
||||
}
|
||||
|
||||
}
|
||||
fragmentHeight2 = fragmentHeight2+getResources().getDimensionPixelOffset(R.dimen.dp_78);
|
||||
if (!StringUtil.isEmpty(vid)){
|
||||
LogUtil.i("vid 不为空");
|
||||
polyvPlayerActivity.getheightListenr(fragmentHeight2);
|
||||
}
|
||||
sumFragment = new SummaryFragment(polyvPlayerActivity,listSeriesVideoByTypeBean.getSeriesType().getNote_url(),vid);
|
||||
curFragment = new CurriculumFragment(polyvPlayerActivity,listSeriesVideoByTypeBean.getData().getList(),listSeriesVideoByTypeBean.getSeriesType().getTitle(),listSeriesVideoByTypeBean.getSeriesType().getIs_paid(),listSeriesVideoByTypeBean.getSeriesType().getIs_white(),vid);
|
||||
talkFragment = new ExchangeFragment(polyvPlayerActivity);
|
||||
|
||||
lists.add(sumFragment);
|
||||
lists.add(curFragment);
|
||||
lists.add(talkFragment);
|
||||
for (int i = 0; i < lists.size(); i++)
|
||||
lists.get(i).setArguments(getActivity().getIntent().getExtras());
|
||||
adapter = new PolyvPlayerFragmentAdapter(getActivity().getSupportFragmentManager(), lists);
|
||||
vp_player.setAdapter(adapter);
|
||||
if (!StringUtil.isEmpty(vid)){
|
||||
vp_player.setCurrentItem(1);
|
||||
currentIndex = 1;
|
||||
}else {
|
||||
vp_player.setCurrentItem(0);
|
||||
currentIndex = 0;
|
||||
}
|
||||
|
||||
vp_player.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
||||
|
||||
@Override
|
||||
// arg0:移动后的位置
|
||||
public void onPageSelected(int arg0) {
|
||||
currentIndex = arg0;
|
||||
tabFragment.resetViewStatus(arg0);
|
||||
switch (arg0){
|
||||
case 0:
|
||||
polyvPlayerActivity.getheightListenr(fragmentHeight1);
|
||||
break;
|
||||
case 1:
|
||||
polyvPlayerActivity.getheightListenr(fragmentHeight2);
|
||||
break;
|
||||
case 2:
|
||||
// polyvPlayerActivity.getheightListenr(fragmentHeight3);
|
||||
if (fragmentHeight3>getResources().getDimensionPixelOffset(R.dimen.dp_700)){
|
||||
polyvPlayerActivity.getheightListenr(fragmentHeight3);
|
||||
}else
|
||||
polyvPlayerActivity.getheightListenr(getResources().getDimensionPixelOffset(R.dimen.dp_700));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
// arg0:当前位置(右移)/下一位置(左移)
|
||||
// arg1:页面偏移百分比
|
||||
// arg2:页面偏移像素
|
||||
public void onPageScrolled(int arg0, float arg1, int arg2) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
// arg0:移动状态
|
||||
public void onPageScrollStateChanged(int arg0) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
//改变viewpager的当前页
|
||||
public void setCurrentItem(int index) {
|
||||
vp_player.setCurrentItem(index);
|
||||
}
|
||||
|
||||
public int getCurrentIndex() {
|
||||
return currentIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
findIdAndNew();
|
||||
initView();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
fragmentHeight1 = 0;
|
||||
fragmentHeight2 = 0;
|
||||
fragmentHeight3 = 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer.fragment;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.JavascriptInterface;
|
||||
import android.webkit.WebResourceError;
|
||||
import android.webkit.WebResourceRequest;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
|
||||
import cn.shangyu.gdxzExpert.R;
|
||||
import cn.shangyu.gdxzExpert.polyvplayer.PolyvPlayerActivity;
|
||||
import cn.shangyu.gdxzExpert.utils.Constant;
|
||||
import cn.shangyu.gdxzExpert.utils.SharePrefUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.StringUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.Url;
|
||||
import cn.shangyu.gdxzExpert.view.X5WebView;
|
||||
|
||||
|
||||
/**
|
||||
* Created by WANGChengXin on 2019/3/25.
|
||||
*/
|
||||
|
||||
@SuppressLint("ValidFragment")
|
||||
public class SummaryFragment extends Fragment {
|
||||
private View view;
|
||||
private PolyvPlayerActivity polyvPlayerActivity;
|
||||
private WebSettings settings;
|
||||
private WebSettings settings1;
|
||||
private X5WebView wv;
|
||||
private WebView wv1;
|
||||
Mobile mobile = new Mobile();
|
||||
|
||||
private String note_url;
|
||||
private String vid;
|
||||
@SuppressLint("ValidFragment")
|
||||
public SummaryFragment(PolyvPlayerActivity polyvPlayerActivity, String note_url,String vid) {
|
||||
this.polyvPlayerActivity = polyvPlayerActivity;
|
||||
this.note_url = note_url;
|
||||
this.vid = vid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
super.onCreateView(inflater, container, savedInstanceState);
|
||||
if (view == null)
|
||||
view = inflater.inflate(R.layout.fragment_summary, container, false);
|
||||
X5WebView.initHardwareAccelerate(getActivity());
|
||||
wv = view.findViewById(R.id.wb);
|
||||
|
||||
wv.loadUrl(Url.urlHtml+note_url);
|
||||
settings = wv.getSettings();
|
||||
|
||||
|
||||
settings.setJavaScriptEnabled(true);//支持js
|
||||
|
||||
wv.setWebViewClient(mClient);
|
||||
|
||||
wv.addJavascriptInterface(mobile, "mobile");
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
private class Mobile {
|
||||
@JavascriptInterface
|
||||
public void onGetWebContentHeight() {
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
wv.measure(0, 0);
|
||||
int measuredHeight = wv.getMeasuredHeight();
|
||||
int fragmentHeight1 = SharePrefUtil.getInt(getActivity(), "fragmentHeight1", 0);
|
||||
if (fragmentHeight1 == 0|| Constant.fragmentHeight1 == 0){
|
||||
SharePrefUtil.saveInt(getActivity(), "fragmentHeight1", measuredHeight);
|
||||
Constant.fragmentHeight1 =measuredHeight;
|
||||
if (StringUtil.isEmpty(vid)){
|
||||
polyvPlayerActivity.getheightListenr(Constant.fragmentHeight1);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private WebViewClient mClient = new WebViewClient() {
|
||||
|
||||
|
||||
@Override
|
||||
public void onPageFinished(WebView view, String url) {
|
||||
mobile.onGetWebContentHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadResource(WebView view, String url) {
|
||||
|
||||
super.onLoadResource(view, url);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) {
|
||||
super.onReceivedError(view, request, error);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer.fragment;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.os.Bundle;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import android.text.method.ScrollingMovementMethod;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import cn.shangyu.gdxzExpert.R;
|
||||
import cn.shangyu.gdxzExpert.view.X5WebView;
|
||||
|
||||
/**
|
||||
* Created by WANGChengXin on 2019/10/28.
|
||||
*/
|
||||
|
||||
@SuppressLint("ValidFragment")
|
||||
public class VideoCurriculumFragment extends Fragment {
|
||||
private View view;
|
||||
private String info;
|
||||
|
||||
@SuppressLint("ValidFragment")
|
||||
public VideoCurriculumFragment(String info) {
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
if (view == null)
|
||||
view = inflater.inflate(R.layout.fragment_summary, container, false);
|
||||
X5WebView.initHardwareAccelerate(getActivity());
|
||||
view.findViewById(R.id.wb).setVisibility(View.GONE);
|
||||
TextView tv_info = view.findViewById(R.id.tv_info);
|
||||
tv_info.setVisibility(View.VISIBLE);
|
||||
tv_info.setText(info);
|
||||
tv_info.setMovementMethod(ScrollingMovementMethod.getInstance());
|
||||
return view;
|
||||
}
|
||||
}
|
||||
+149
@@ -0,0 +1,149 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer.fragment;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import cn.shangyu.gdxzExpert.R;
|
||||
import cn.shangyu.gdxzExpert.bean.ListSeriesVideoByTypeBean;
|
||||
import cn.shangyu.gdxzExpert.polyvplayer.util.PolyvScreenUtils;
|
||||
import cn.shangyu.gdxzExpert.utils.StringUtil;
|
||||
|
||||
|
||||
public class VideoDetailPolyvPlayerTabFragment extends Fragment implements View.OnClickListener {
|
||||
//fragmentView
|
||||
private View view;
|
||||
//viewpagerFragment
|
||||
private VideoDetailPolyvPlayerViewPagerFragment viewPagerFragment;
|
||||
// tab文本的TextView,用于改变颜色
|
||||
private TextView tv_cur, tv_sum, tv_talk;
|
||||
// tab的导航线
|
||||
private View v_line;
|
||||
private int screenWidth;
|
||||
private int length;
|
||||
private int eLength;
|
||||
private RelativeLayout.LayoutParams lp;
|
||||
private String vid;
|
||||
private LinearLayout ll_down;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
if (view == null)
|
||||
view = inflater.inflate(R.layout.polyv_fragment_videodetailplayer_tab, container, false);
|
||||
return view;
|
||||
}
|
||||
|
||||
private void findIdAndNew() {
|
||||
tv_cur = (TextView) view.findViewById(R.id.tv_cur);
|
||||
tv_sum = (TextView) view.findViewById(R.id.tv_sum);
|
||||
tv_talk = (TextView) view.findViewById(R.id.tv_talk);
|
||||
ll_down = (LinearLayout) view.findViewById(R.id.ll_down);
|
||||
v_line = view.findViewById(R.id.v_line);
|
||||
viewPagerFragment = (VideoDetailPolyvPlayerViewPagerFragment) getActivity().getSupportFragmentManager().findFragmentById(R.id.fl_viewpager);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
Bundle bundle =this.getArguments();//得到从Activity传来的数据
|
||||
ListSeriesVideoByTypeBean listSeriesVideoByTypeBean = (ListSeriesVideoByTypeBean) bundle.getSerializable("listSeriesVideoByTypeBean");
|
||||
vid = bundle.getString("vid");
|
||||
|
||||
initLineSetting();
|
||||
tv_cur.setSelected(true);
|
||||
tv_cur.setOnClickListener(this);
|
||||
tv_sum.setOnClickListener(this);
|
||||
ll_down.setOnClickListener(this);
|
||||
}
|
||||
|
||||
private void initLineSetting() {
|
||||
lp = (RelativeLayout.LayoutParams) v_line.getLayoutParams();
|
||||
v_line.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
@Override
|
||||
public void onGlobalLayout() {
|
||||
final DisplayMetrics dm = new DisplayMetrics();
|
||||
getActivity().getWindow().getWindowManager().getDefaultDisplay().getMetrics(dm);
|
||||
if(PolyvScreenUtils.isLandscape(getContext()))
|
||||
screenWidth = dm.heightPixels;
|
||||
else
|
||||
screenWidth = dm.widthPixels;
|
||||
length = v_line.getWidth();
|
||||
int sLength = screenWidth / 3;
|
||||
eLength = (sLength - length) / 2;
|
||||
if (viewPagerFragment.getCurrentIndex() == 0)
|
||||
resetViewStatus(0);
|
||||
if (!StringUtil.isEmpty(vid)){
|
||||
resetViewStatus(1);
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= 16)
|
||||
getView().getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
||||
else
|
||||
getView().getViewTreeObserver().removeGlobalOnLayoutListener(this);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void resetViewStatus(int arg0) {
|
||||
tv_cur.setSelected(false);
|
||||
tv_sum.setSelected(false);
|
||||
ll_down.setSelected(false);
|
||||
tv_cur.setTextColor(Color.parseColor("#999999"));
|
||||
tv_sum.setTextColor(Color.parseColor("#999999"));
|
||||
tv_talk.setTextColor(Color.parseColor("#999999"));
|
||||
switch (arg0) {
|
||||
case 0:
|
||||
tv_cur.setSelected(true);
|
||||
tv_cur.setTextColor(getResources().getColor(R.color.polyv_tab_text_color));
|
||||
lp.leftMargin = (int) (arg0 * (length)) + 1 * eLength;
|
||||
break;
|
||||
case 1:
|
||||
tv_sum.setSelected(true);
|
||||
tv_sum.setTextColor(getResources().getColor(R.color.polyv_tab_text_color));
|
||||
lp.leftMargin = (int) (arg0 * (length)) + 3 * eLength;
|
||||
break;
|
||||
case 2:
|
||||
tv_talk.setSelected(true);
|
||||
tv_talk.setText("下载中");
|
||||
tv_talk.setTextColor(getResources().getColor(R.color.polyv_tab_text_color));
|
||||
lp.leftMargin = (int) (arg0 * (length)) + 5 * eLength;
|
||||
break;
|
||||
}
|
||||
v_line.setLayoutParams(lp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
findIdAndNew();
|
||||
initView();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
switch (view.getId()) {
|
||||
case R.id.ll_down:
|
||||
viewPagerFragment.setCurrentItem(2);
|
||||
break;
|
||||
case R.id.tv_sum:
|
||||
viewPagerFragment.setCurrentItem(1);
|
||||
break;
|
||||
case R.id.tv_cur:
|
||||
viewPagerFragment.setCurrentItem(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
+132
@@ -0,0 +1,132 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer.fragment;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
import cn.shangyu.gdxzExpert.R;
|
||||
import cn.shangyu.gdxzExpert.bean.ListSeriesVideoByTypeBean;
|
||||
import cn.shangyu.gdxzExpert.polyvplayer.VideoDetailPolyvPlayerActivity;
|
||||
import cn.shangyu.gdxzExpert.polyvplayer.adapter.PolyvPlayerFragmentAdapter;
|
||||
|
||||
import static cn.shangyu.gdxzExpert.utils.Constant.fragmentHeight1;
|
||||
import static cn.shangyu.gdxzExpert.utils.Constant.fragmentHeight2;
|
||||
import static cn.shangyu.gdxzExpert.utils.Constant.fragmentHeight3;
|
||||
|
||||
@SuppressLint("ValidFragment")
|
||||
public class VideoDetailPolyvPlayerViewPagerFragment extends Fragment {
|
||||
//fragmentView
|
||||
private View view;
|
||||
// 播放页的viewPager
|
||||
private ViewPager vp_player;
|
||||
private PolyvPlayerFragmentAdapter adapter;
|
||||
// 当前的索引
|
||||
private int currentIndex;
|
||||
private List<Fragment> lists;
|
||||
// 播放页viewpager的fragment
|
||||
private Fragment curFragment, sumFragment, talkFragment;
|
||||
private VideoDetailPolyvPlayerTabFragment tabFragment;
|
||||
private VideoDetailPolyvPlayerActivity polyvPlayerActivity;
|
||||
private TextView tv_name;
|
||||
private String info;//视频简介
|
||||
|
||||
|
||||
@SuppressLint("ValidFragment")
|
||||
public VideoDetailPolyvPlayerViewPagerFragment(VideoDetailPolyvPlayerActivity polyvPlayerActivity) {
|
||||
this.polyvPlayerActivity = polyvPlayerActivity;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
if (view == null)
|
||||
view = inflater.inflate(R.layout.polyv_fragment_player_viewpager, container, false);
|
||||
return view;
|
||||
}
|
||||
|
||||
private void findIdAndNew() {
|
||||
vp_player = (ViewPager) view.findViewById(R.id.vp_player);
|
||||
tabFragment = (VideoDetailPolyvPlayerTabFragment) getActivity().getSupportFragmentManager().findFragmentById(R.id.fl_tab);
|
||||
lists = new ArrayList<Fragment>();
|
||||
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
Bundle bundle =this.getArguments();//得到从Activity传来的数据
|
||||
ListSeriesVideoByTypeBean listSeriesVideoByTypeBean = (ListSeriesVideoByTypeBean) bundle.getSerializable("listSeriesVideoByTypeBean");
|
||||
String vid = bundle.getString("vid");
|
||||
|
||||
sumFragment = new VideoInfoFragment(info);
|
||||
curFragment = new VideoCurriculumFragment(info);
|
||||
talkFragment = new VideoCurriculumFragment(info);
|
||||
|
||||
lists.add(sumFragment);
|
||||
lists.add(curFragment);
|
||||
lists.add(talkFragment);
|
||||
for (int i = 0; i < lists.size(); i++)
|
||||
lists.get(i).setArguments(getActivity().getIntent().getExtras());
|
||||
adapter = new PolyvPlayerFragmentAdapter(getActivity().getSupportFragmentManager(), lists);
|
||||
vp_player.setAdapter(adapter);
|
||||
vp_player.setCurrentItem(0);
|
||||
currentIndex = 0;
|
||||
|
||||
vp_player.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
||||
|
||||
@Override
|
||||
// arg0:移动后的位置
|
||||
public void onPageSelected(int arg0) {
|
||||
currentIndex = arg0;
|
||||
tabFragment.resetViewStatus(arg0);
|
||||
}
|
||||
|
||||
@Override
|
||||
// arg0:当前位置(右移)/下一位置(左移)
|
||||
// arg1:页面偏移百分比
|
||||
// arg2:页面偏移像素
|
||||
public void onPageScrolled(int arg0, float arg1, int arg2) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
// arg0:移动状态
|
||||
public void onPageScrollStateChanged(int arg0) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
//改变viewpager的当前页
|
||||
public void setCurrentItem(int index) {
|
||||
vp_player.setCurrentItem(index);
|
||||
}
|
||||
|
||||
public int getCurrentIndex() {
|
||||
return currentIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
findIdAndNew();
|
||||
initView();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
fragmentHeight1 = 0;
|
||||
fragmentHeight2 = 0;
|
||||
fragmentHeight3 = 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer.fragment;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.os.Bundle;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import android.text.method.ScrollingMovementMethod;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import cn.shangyu.gdxzExpert.R;
|
||||
import cn.shangyu.gdxzExpert.view.X5WebView;
|
||||
|
||||
/**
|
||||
* Created by WANGChengXin on 2019/10/28.
|
||||
*/
|
||||
|
||||
@SuppressLint("ValidFragment")
|
||||
public class VideoInfoFragment extends Fragment {
|
||||
private View view;
|
||||
private String info;
|
||||
|
||||
@SuppressLint("ValidFragment")
|
||||
public VideoInfoFragment(String info) {
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
if (view == null)
|
||||
view = inflater.inflate(R.layout.fragment_summary, container, false);
|
||||
X5WebView.initHardwareAccelerate(getActivity());
|
||||
view.findViewById(R.id.wb).setVisibility(View.GONE);
|
||||
TextView tv_info = view.findViewById(R.id.tv_info);
|
||||
tv_info.setVisibility(View.VISIBLE);
|
||||
tv_info.setText(info);
|
||||
tv_info.setMovementMethod(ScrollingMovementMethod.getInstance());
|
||||
return view;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer.listener;
|
||||
|
||||
/**
|
||||
* Created by WANGChengXin on 2019/3/27.
|
||||
*/
|
||||
|
||||
public interface GetHeightListener {
|
||||
public void getheightListenr(int height);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer.listener;
|
||||
|
||||
/**
|
||||
* Created by wangchengxin on 2019/3/28.
|
||||
*/
|
||||
|
||||
public interface GetVidListener {
|
||||
void getVidlistener(String vid,String uuid);
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer.player;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer;
|
||||
import com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public class PolyvAnimateFirstDisplayListener extends SimpleImageLoadingListener {
|
||||
boolean cacheFound;
|
||||
public static List<String> displayedImages = Collections.synchronizedList(new LinkedList<String>());
|
||||
|
||||
@Override
|
||||
public void onLoadingStarted(String imageUri, View view){
|
||||
|
||||
}
|
||||
@Override
|
||||
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage){
|
||||
if (loadedImage != null){
|
||||
ImageView imageView = (ImageView) view;
|
||||
boolean firstDisplay = !displayedImages.contains(imageUri);
|
||||
if (firstDisplay){
|
||||
FadeInBitmapDisplayer.animate(imageView, 500);
|
||||
displayedImages.add(imageUri);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+165
@@ -0,0 +1,165 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer.player;
|
||||
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.net.Uri;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.animation.LinearInterpolator;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.easefun.polyvsdk.util.PolyvDownloadDirUtil;
|
||||
import com.easefun.polyvsdk.video.PolyvVideoView;
|
||||
import com.easefun.polyvsdk.vo.PolyvVideoVO;
|
||||
import com.nostra13.universalimageloader.core.DisplayImageOptions;
|
||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import cn.shangyu.gdxzExpert.R;
|
||||
import cn.shangyu.gdxzExpert.polyvplayer.util.PolyvScreenUtils;
|
||||
|
||||
|
||||
public class PolyvPlayerAudioCoverView extends FrameLayout {
|
||||
/**
|
||||
* 播放音频时的封面图
|
||||
*/
|
||||
private ImageView iv_audio_cover = null;
|
||||
private ImageView iv_audio_cover_m = null;
|
||||
private FrameLayout fl_cover = null;
|
||||
private ObjectAnimator animator;
|
||||
private float currentValue;
|
||||
private String currentMode;
|
||||
|
||||
private boolean isShowFilm;
|
||||
|
||||
public PolyvPlayerAudioCoverView(@NonNull Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public PolyvPlayerAudioCoverView(@NonNull Context context, @Nullable AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
|
||||
public PolyvPlayerAudioCoverView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.PolyvPlayerAudioCoverView);
|
||||
isShowFilm = typedArray.getBoolean(R.styleable.PolyvPlayerAudioCoverView_show_film, true);
|
||||
typedArray.recycle();
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
LayoutInflater.from(getContext()).inflate(R.layout.polyv_player_audio_cover, this);
|
||||
iv_audio_cover = (ImageView) findViewById(R.id.iv_audio_cover);
|
||||
iv_audio_cover_m = (ImageView) findViewById(R.id.iv_audio_cover_m);
|
||||
fl_cover = (FrameLayout) findViewById(R.id.fl_cover);
|
||||
if (!isShowFilm) {
|
||||
iv_audio_cover_m.setScaleType(ImageView.ScaleType.FIT_CENTER);
|
||||
fl_cover.setVisibility(View.GONE);
|
||||
} else {
|
||||
iv_audio_cover_m.setAlpha(0.4f);
|
||||
}
|
||||
}
|
||||
|
||||
private void showCover(PolyvVideoView videoView, ImageView imageView, boolean isRotateView) {
|
||||
imageView.setImageBitmap(null);
|
||||
imageView.setVisibility(View.VISIBLE);
|
||||
PolyvVideoVO videoVO = videoView.getVideo();
|
||||
if (videoVO != null)
|
||||
if (!videoView.isLocalPlay()) {
|
||||
ImageLoader.getInstance().displayImage(videoVO.getFirstImage(), imageView
|
||||
, new DisplayImageOptions.Builder().cacheInMemory(true).cacheOnDisk(true)
|
||||
.showImageForEmptyUri(isRotateView ? R.drawable.polyv_rotate_cover_default : R.drawable.polyv_bg_cover_default)//显示默认的图片
|
||||
.showImageOnFail(isRotateView ? R.drawable.polyv_rotate_cover_default : R.drawable.polyv_bg_cover_default).build()
|
||||
, new PolyvAnimateFirstDisplayListener());
|
||||
} else {
|
||||
int index = 0;
|
||||
if (videoVO.getFirstImage().contains("/")) {
|
||||
index = videoVO.getFirstImage().lastIndexOf("/");
|
||||
}
|
||||
String fileName = videoVO.getFirstImage().substring(index);
|
||||
File file = PolyvDownloadDirUtil.getFileFromExtraResourceDir(videoVO.getVid(), fileName);
|
||||
if (file != null)
|
||||
imageView.setImageURI(Uri.parse(file.getAbsolutePath()));
|
||||
else
|
||||
imageView.setImageResource(isRotateView ? R.drawable.polyv_rotate_cover_default : R.drawable.polyv_bg_cover_default);//显示默认的图片
|
||||
}
|
||||
else
|
||||
imageView.setImageResource(isRotateView ? R.drawable.polyv_rotate_cover_default : R.drawable.polyv_bg_cover_default);//显示默认的图片
|
||||
}
|
||||
|
||||
//用于音视频切换
|
||||
public void changeModeFitCover(PolyvVideoView videoView, String changedMode) {
|
||||
this.currentMode = changedMode;
|
||||
if (PolyvVideoVO.MODE_AUDIO.equals(changedMode)) {
|
||||
currentValue = 0;
|
||||
startAnimation();
|
||||
fl_cover.setVisibility(View.VISIBLE);
|
||||
showCover(videoView, iv_audio_cover_m, false);
|
||||
showCover(videoView, iv_audio_cover, true);
|
||||
} else {
|
||||
hide();
|
||||
}
|
||||
}
|
||||
|
||||
public void hide() {
|
||||
if (animator != null)
|
||||
animator.cancel();
|
||||
fl_cover.setVisibility(View.GONE);
|
||||
iv_audio_cover.setVisibility(View.GONE);
|
||||
iv_audio_cover_m.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
//用于mp3源文件播放
|
||||
public void onlyShowCover(PolyvVideoView videoView) {
|
||||
showCover(videoView, iv_audio_cover_m, false);
|
||||
}
|
||||
|
||||
public void stopAnimation() {
|
||||
if (PolyvVideoVO.MODE_AUDIO.equals(currentMode)) {
|
||||
if (animator != null)
|
||||
animator.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
public void startAnimation() {
|
||||
stopAnimation();
|
||||
if (PolyvVideoVO.MODE_AUDIO.equals(currentMode)) {
|
||||
animator = ObjectAnimator.ofFloat(fl_cover, "rotation", currentValue - 360, currentValue);
|
||||
animator.setDuration(15000);
|
||||
animator.setRepeatMode(ValueAnimator.RESTART);
|
||||
animator.setRepeatCount(ValueAnimator.INFINITE);
|
||||
animator.setInterpolator(new LinearInterpolator());
|
||||
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
|
||||
@Override
|
||||
public void onAnimationUpdate(ValueAnimator animation) {
|
||||
currentValue = (float) animation.getAnimatedValue();
|
||||
}
|
||||
});
|
||||
animator.start();
|
||||
}
|
||||
}
|
||||
public void fitLocationChange(boolean isInMainScreen) {
|
||||
if (fl_cover == null)
|
||||
return;
|
||||
RelativeLayout.LayoutParams rlp = (RelativeLayout.LayoutParams) fl_cover.getLayoutParams();
|
||||
if (isInMainScreen) {
|
||||
rlp.width = PolyvScreenUtils.dip2px(getContext(), 150);
|
||||
rlp.height = PolyvScreenUtils.dip2px(getContext(),150);
|
||||
} else {
|
||||
rlp.width = PolyvScreenUtils.dip2px(getContext(), 70);
|
||||
rlp.height = PolyvScreenUtils.dip2px(getContext(), 70);
|
||||
}
|
||||
fl_cover.setLayoutParams(rlp);
|
||||
}
|
||||
|
||||
}
|
||||
+147
@@ -0,0 +1,147 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer.player;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.net.Uri;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import com.easefun.polyvsdk.video.PolyvVideoView;
|
||||
import com.easefun.polyvsdk.vo.PolyvADMatterVO;
|
||||
import com.nostra13.universalimageloader.core.DisplayImageOptions;
|
||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
||||
import com.nostra13.universalimageloader.core.assist.ImageScaleType;
|
||||
import com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
import cn.shangyu.gdxzExpert.R;
|
||||
|
||||
|
||||
/**
|
||||
* 图片广告和图片片头视图,视频广告和视频片头在{@link PolyvVideoView}中已经处理
|
||||
* @author TanQu 2016-11-15
|
||||
*/
|
||||
public class PolyvPlayerAuxiliaryView extends RelativeLayout {
|
||||
private Context mContext = null;
|
||||
private PolyvVideoView mVideoView = null;
|
||||
private ImageView mAdvertisementImage = null;
|
||||
private ImageButton mStartBtn = null;
|
||||
private DisplayImageOptions mOptions = null;
|
||||
private PolyvADMatterVO mADMatter = null;
|
||||
|
||||
public PolyvPlayerAuxiliaryView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public PolyvPlayerAuxiliaryView(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
|
||||
public PolyvPlayerAuxiliaryView(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
mContext = context;
|
||||
initViews();
|
||||
}
|
||||
|
||||
|
||||
private void initViews() {
|
||||
LayoutInflater.from(getContext()).inflate(R.layout.polyv_player_auxiliary_view, this);
|
||||
mAdvertisementImage = (ImageView) findViewById(R.id.advertisement_image);
|
||||
mAdvertisementImage.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (mADMatter == null) return;
|
||||
String path = mADMatter.getAddrUrl();
|
||||
if (TextUtils.isEmpty(path) == false) {
|
||||
try {
|
||||
new URL(path);
|
||||
} catch (MalformedURLException e) {
|
||||
return;
|
||||
}
|
||||
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.setData(Uri.parse(path));
|
||||
mContext.startActivity(intent);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mStartBtn = (ImageButton) findViewById(R.id.advertisement_start_btn);
|
||||
mStartBtn.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mVideoView.start();
|
||||
// danmuFragment.resume();
|
||||
hide();
|
||||
}
|
||||
});
|
||||
|
||||
if (mOptions == null) {
|
||||
mOptions = new DisplayImageOptions.Builder().showImageOnLoading(R.drawable.polyv_avatar_def) // 设置图片在下载期间显示的图片
|
||||
.showImageForEmptyUri(R.drawable.polyv_avatar_def)// 设置图片Uri为空或是错误的时候显示的图片
|
||||
.showImageOnFail(R.drawable.polyv_avatar_def) // 设置图片加载/解码过程中错误时候显示的图片
|
||||
.bitmapConfig(Bitmap.Config.RGB_565)// 设置图片的解码类型
|
||||
.cacheInMemory(true)// 设置下载的图片是否缓存在内存中
|
||||
.cacheOnDisk(true)// 设置下载的图片是否缓存在SD卡中
|
||||
.displayer(new FadeInBitmapDisplayer(100))// 是否图片加载好后渐入的动画时间
|
||||
.imageScaleType(ImageScaleType.IN_SAMPLE_INT).build();// 构建完成
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置图片并显示
|
||||
* @param adMatter
|
||||
*/
|
||||
public void show(PolyvADMatterVO adMatter) {
|
||||
mADMatter = adMatter;
|
||||
ImageLoader.getInstance().displayImage(mADMatter.getMatterUrl(), mAdvertisementImage, mOptions, new PolyvAnimateFirstDisplayListener());
|
||||
|
||||
//暂停图片广告不需要倒计时,是点击开始按钮继续
|
||||
if (PolyvADMatterVO.LOCATION_PAUSE.equals(adMatter.getLocation())) {
|
||||
mStartBtn.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
mStartBtn.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置图片并显示
|
||||
* @param url
|
||||
*/
|
||||
public void show(String url) {
|
||||
mADMatter = null;
|
||||
ImageLoader.getInstance().displayImage(url, mAdvertisementImage, mOptions, new PolyvAnimateFirstDisplayListener());
|
||||
mStartBtn.setVisibility(View.GONE);
|
||||
setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
public boolean isPauseAdvert() {
|
||||
return mADMatter != null && PolyvADMatterVO.LOCATION_PAUSE.equals(mADMatter.getLocation());
|
||||
}
|
||||
|
||||
/**
|
||||
* 隐藏
|
||||
*/
|
||||
public void hide() {
|
||||
setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
super.onTouchEvent(event);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer.player;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import cn.shangyu.gdxzExpert.R;
|
||||
|
||||
|
||||
public class PolyvPlayerLightView extends FrameLayout {
|
||||
//lightView
|
||||
private View view;
|
||||
private RelativeLayout rl_center_light;
|
||||
private TextView tv_light;
|
||||
|
||||
public PolyvPlayerLightView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public PolyvPlayerLightView(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
|
||||
public PolyvPlayerLightView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
this.view = LayoutInflater.from(context).inflate(R.layout.polyv_player_media_center_light, this);
|
||||
findIdAndNew();
|
||||
}
|
||||
|
||||
private void findIdAndNew() {
|
||||
rl_center_light = (RelativeLayout) view.findViewById(R.id.rl_center_light);
|
||||
tv_light = (TextView) view.findViewById(R.id.tv_light);
|
||||
}
|
||||
|
||||
public void hide() {
|
||||
if (rl_center_light != null)
|
||||
rl_center_light.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
public void setViewLightValue(int brightness, boolean end) {
|
||||
if (end)
|
||||
rl_center_light.setVisibility(View.GONE);
|
||||
else
|
||||
rl_center_light.setVisibility(View.VISIBLE);
|
||||
tv_light.setText(brightness + "%");
|
||||
}
|
||||
}
|
||||
+1922
File diff suppressed because it is too large
Load Diff
+179
@@ -0,0 +1,179 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer.player;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.easefun.polyvsdk.PolyvSDKUtil;
|
||||
import com.easefun.polyvsdk.util.PolyvDownloadDirUtil;
|
||||
import com.easefun.polyvsdk.vo.PolyvVideoVO;
|
||||
import com.nostra13.universalimageloader.core.DisplayImageOptions;
|
||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
||||
import com.nostra13.universalimageloader.core.assist.ImageScaleType;
|
||||
import com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import cn.shangyu.gdxzExpert.R;
|
||||
import cn.shangyu.gdxzExpert.utils.ImageOptions;
|
||||
|
||||
|
||||
/**
|
||||
* 预览图视图
|
||||
* @author Lion 2016-3-3
|
||||
*/
|
||||
public class PolyvPlayerPreviewView extends RelativeLayout {
|
||||
private static final String TAG = PolyvPlayerPreviewView.class.getSimpleName();
|
||||
private Context mContext = null;
|
||||
private ImageView mPreviewImage = null;
|
||||
private ImageButton mStartBtn = null;
|
||||
private Callback mCallback = null;
|
||||
private DisplayImageOptions mOptions = null;
|
||||
private TextView tv_mina=null;
|
||||
private RelativeLayout r_mb=null;
|
||||
|
||||
public PolyvPlayerPreviewView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public PolyvPlayerPreviewView(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
|
||||
public PolyvPlayerPreviewView(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
mContext = context;
|
||||
initViews();
|
||||
}
|
||||
|
||||
private void initViews() {
|
||||
LayoutInflater.from(getContext()).inflate(R.layout.polyv_player_preview_view, this);
|
||||
mPreviewImage = (ImageView) findViewById(R.id.preview_image);
|
||||
mStartBtn = (ImageButton) findViewById(R.id.start_btn);
|
||||
tv_mina =findViewById(R.id.tv_mina);
|
||||
r_mb=findViewById(R.id.r_mb);
|
||||
mStartBtn.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (mCallback != null) {
|
||||
mCallback.onClickStart();
|
||||
}
|
||||
|
||||
hide();
|
||||
}
|
||||
});
|
||||
|
||||
if (mOptions == null) {
|
||||
mOptions = new DisplayImageOptions.Builder().showImageOnLoading(R.drawable.polyv_avatar_def) // 设置图片在下载期间显示的图片
|
||||
.showImageForEmptyUri(R.drawable.polyv_avatar_def)// 设置图片Uri为空或是错误的时候显示的图片
|
||||
.showImageOnFail(R.drawable.polyv_avatar_def) // 设置图片加载/解码过程中错误时候显示的图片
|
||||
.bitmapConfig(Bitmap.Config.RGB_565)// 设置图片的解码类型
|
||||
.cacheInMemory(true)// 设置下载的图片是否缓存在内存中
|
||||
.cacheOnDisk(true)// 设置下载的图片是否缓存在SD卡中
|
||||
.displayer(new FadeInBitmapDisplayer(100))// 是否图片加载好后渐入的动画时间
|
||||
.imageScaleType(ImageScaleType.IN_SAMPLE_INT).build();// 构建完成
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置图片并显示
|
||||
* @param vid
|
||||
*/
|
||||
public void show(String vid) {
|
||||
new LoadVideoJson(vid).execute();
|
||||
setVisibility(View.VISIBLE);
|
||||
}
|
||||
public void show(String vid,String b) {
|
||||
new LoadVideoJson(vid).execute();
|
||||
tv_mina.setVisibility(VISIBLE);
|
||||
mStartBtn.setVisibility(VISIBLE);
|
||||
r_mb.setVisibility(VISIBLE);
|
||||
setVisibility(View.VISIBLE);
|
||||
}
|
||||
public void show(String url,int a)
|
||||
{
|
||||
ImageLoader.getInstance().displayImage(url, mPreviewImage, ImageOptions.getImageOptions(R.drawable.default_news_iv));
|
||||
tv_mina.setVisibility(GONE);
|
||||
mStartBtn.setVisibility(GONE);
|
||||
r_mb.setVisibility(GONE);
|
||||
setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
private class LoadVideoJson extends AsyncTask<String, Void, PolyvVideoVO> {
|
||||
|
||||
private final String mVid;
|
||||
|
||||
LoadVideoJson(String vid) {
|
||||
mVid = vid;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PolyvVideoVO doInBackground(String... params) {
|
||||
PolyvVideoVO video = null;
|
||||
try {
|
||||
video = PolyvSDKUtil.loadVideoJSON2Video(mVid);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return video;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(PolyvVideoVO v) {
|
||||
super.onPostExecute(v);
|
||||
if (v == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (TextUtils.isEmpty(v.getFirstImage())) {
|
||||
return;
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
if (v.getFirstImage().contains("/")) {
|
||||
index = v.getFirstImage().lastIndexOf("/");
|
||||
}
|
||||
|
||||
String fileName = v.getFirstImage().substring(index);
|
||||
File file = PolyvDownloadDirUtil.getFileFromExtraResourceDir(mVid, fileName);
|
||||
if (file != null) {
|
||||
mPreviewImage.setImageURI(Uri.parse(file.getAbsolutePath()));
|
||||
} else {
|
||||
ImageLoader.getInstance().displayImage(v.getFirstImage(), mPreviewImage, mOptions, new PolyvAnimateFirstDisplayListener());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 隐藏
|
||||
*/
|
||||
public void hide() {
|
||||
setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
super.onTouchEvent(event);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setCallback(Callback callback) {
|
||||
mCallback = callback;
|
||||
}
|
||||
|
||||
public interface Callback {
|
||||
public void onClickStart();
|
||||
}
|
||||
}
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer.player;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import cn.shangyu.gdxzExpert.R;
|
||||
import cn.shangyu.gdxzExpert.polyvplayer.util.PolyvTimeUtils;
|
||||
|
||||
|
||||
public class PolyvPlayerProgressView extends FrameLayout {
|
||||
//progressView
|
||||
private View view;
|
||||
private RelativeLayout rl_center_progress;
|
||||
private TextView tv_curtime, tv_tottime;
|
||||
private ImageView iv_left, iv_right;
|
||||
|
||||
public PolyvPlayerProgressView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public PolyvPlayerProgressView(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
|
||||
public PolyvPlayerProgressView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
this.view = LayoutInflater.from(context).inflate(R.layout.polyv_player_media_center_progress, this);
|
||||
findIdAndNew();
|
||||
}
|
||||
|
||||
private void findIdAndNew() {
|
||||
rl_center_progress = (RelativeLayout) view.findViewById(R.id.rl_center_progress);
|
||||
tv_curtime = (TextView) view.findViewById(R.id.tv_curtime);
|
||||
tv_tottime = (TextView) view.findViewById(R.id.tv_tottime);
|
||||
iv_left = (ImageView) view.findViewById(R.id.iv_left);
|
||||
iv_right = (ImageView) view.findViewById(R.id.iv_right);
|
||||
}
|
||||
|
||||
public void hide() {
|
||||
if (rl_center_progress != null)
|
||||
rl_center_progress.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
public void resetMaxValue() {
|
||||
setViewMaxValue(0);
|
||||
}
|
||||
|
||||
public void setViewMaxValue(int totaltime) {
|
||||
tv_tottime.setText(PolyvTimeUtils.generateTime(totaltime));
|
||||
}
|
||||
|
||||
public void setViewProgressValue(int fastForwardPos, int totaltime, boolean end, boolean isRightSwipe) {
|
||||
if (end)
|
||||
rl_center_progress.setVisibility(View.GONE);
|
||||
else
|
||||
rl_center_progress.setVisibility(View.VISIBLE);
|
||||
if (isRightSwipe) {
|
||||
iv_left.setVisibility(View.GONE);
|
||||
iv_right.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
iv_left.setVisibility(View.VISIBLE);
|
||||
iv_right.setVisibility(View.GONE);
|
||||
}
|
||||
if (fastForwardPos < 0)
|
||||
fastForwardPos = 0;
|
||||
if (fastForwardPos > totaltime)
|
||||
fastForwardPos = totaltime;
|
||||
tv_curtime.setText(PolyvTimeUtils.generateTime(fastForwardPos));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer.player;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import cn.shangyu.gdxzExpert.R;
|
||||
|
||||
|
||||
public class PolyvPlayerVolumeView extends FrameLayout {
|
||||
//volumeView
|
||||
private View view;
|
||||
private RelativeLayout rl_center_volume;
|
||||
private TextView tv_volume;
|
||||
|
||||
public PolyvPlayerVolumeView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public PolyvPlayerVolumeView(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
|
||||
public PolyvPlayerVolumeView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
this.view = LayoutInflater.from(context).inflate(R.layout.polyv_player_media_center_volume, this);
|
||||
findIdAndNew();
|
||||
}
|
||||
|
||||
private void findIdAndNew() {
|
||||
rl_center_volume = (RelativeLayout) view.findViewById(R.id.rl_center_volume);
|
||||
tv_volume = (TextView) view.findViewById(R.id.tv_volume);
|
||||
}
|
||||
|
||||
public void hide() {
|
||||
if (rl_center_volume != null)
|
||||
rl_center_volume.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
public void setViewVolumeValue(int volume, boolean end) {
|
||||
if (end)
|
||||
rl_center_volume.setVisibility(View.GONE);
|
||||
else
|
||||
rl_center_volume.setVisibility(View.VISIBLE);
|
||||
tv_volume.setText(volume + "%");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer.ppt;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.easefun.polyvsdk.po.ppt.PolyvPptInfo;
|
||||
import com.easefun.polyvsdk.po.ppt.PolyvPptPageInfo;
|
||||
import com.easefun.polyvsdk.video.PolyvVideoView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import cn.shangyu.gdxzExpert.R;
|
||||
import cn.shangyu.gdxzExpert.polyvplayer.util.PolyvImageLoader;
|
||||
import cn.shangyu.gdxzExpert.polyvplayer.view.PolyvCircleProgressView;
|
||||
|
||||
/**
|
||||
* 三分屏布局的ppt控件
|
||||
*/
|
||||
public class PolyvPPTView extends FrameLayout {
|
||||
private PolyvCircleProgressView loadView;
|
||||
private TextView textView;
|
||||
private ImageView imageView;
|
||||
private PolyvVideoView currentVideoView;
|
||||
private String currentImg;
|
||||
private String currentVid;
|
||||
private PolyvPptInfo currentPPTVO;
|
||||
|
||||
private int preloadCount = 2;
|
||||
|
||||
private Handler handler = new Handler(Looper.getMainLooper()) {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
if (msg.what == 1) {
|
||||
int position = Math.max(0, currentVideoView.getCurrentPosition() / 1000);
|
||||
PolyvPptPageInfo pageBean = findClosestPPT(position, currentPPTVO.getPages());
|
||||
if (pageBean != null && pageBean.getImg() != null && !pageBean.getImg().equals(currentImg)) {
|
||||
PolyvImageLoader.getInstance().loadImageOrigin(getContext(), currentImg = pageBean.getImg(), imageView, imageView.getDrawable());
|
||||
if (Build.VERSION.SDK_INT <29){
|
||||
for (int i = 1; i <= preloadCount; i++) {
|
||||
if (pageBean.getIndex() + i < currentPPTVO.getPages().size()) {
|
||||
PolyvImageLoader.getInstance().preloadImage(getContext(), currentPPTVO.getPages().get(pageBean.getIndex() + i).getImg());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
handler.sendEmptyMessageDelayed(1, 1000);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public PolyvPPTView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public PolyvPPTView(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
|
||||
public PolyvPPTView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
addView(LayoutInflater.from(context).inflate(R.layout.polyv_ppt_content, this, false));
|
||||
imageView = (ImageView) findViewById(R.id.ppt_img);
|
||||
textView = (TextView) findViewById(R.id.no_ppt);
|
||||
loadView = (PolyvCircleProgressView) findViewById(R.id.load_view);
|
||||
}
|
||||
|
||||
public Bitmap getImg() {
|
||||
if (imageView != null) {
|
||||
return drawableToBitmap(imageView.getDrawable());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Bitmap drawableToBitmap(Drawable drawable) {
|
||||
int w = drawable.getIntrinsicWidth();
|
||||
int h = drawable.getIntrinsicHeight();
|
||||
Bitmap.Config config = drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888
|
||||
: Bitmap.Config.RGB_565;
|
||||
Bitmap bitmap = Bitmap.createBitmap(w, h, config);
|
||||
//注意,下面三行代码要用到,否则在View或者SurfaceView里的canvas.drawBitmap会看不到图
|
||||
Canvas canvas = new Canvas(bitmap);
|
||||
drawable.setBounds(0, 0, w, h);
|
||||
drawable.draw(canvas);
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
public void acceptProgress(int loadPPTProgress) {
|
||||
if (loadView != null) {
|
||||
loadView.setVisibility(View.VISIBLE);
|
||||
loadView.setmCurrent(loadPPTProgress);
|
||||
}
|
||||
if (textView != null) {
|
||||
textView.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
public void acceptPPTCallback(final PolyvVideoView videoView, String vid, boolean hasPPT, PolyvPptInfo pptvo) {
|
||||
handler.removeMessages(1);
|
||||
if (currentVid != null && !currentVid.equals(vid) || (hasPPT && pptvo == null)) {
|
||||
imageView.setImageDrawable(null);
|
||||
loadView.setVisibility(View.GONE);
|
||||
textView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
currentVid = vid;
|
||||
if (videoView != null && hasPPT && pptvo != null) {
|
||||
textView.setVisibility(View.GONE);
|
||||
loadView.setVisibility(View.GONE);
|
||||
currentVideoView = videoView;
|
||||
currentPPTVO = pptvo;
|
||||
|
||||
handler.sendEmptyMessage(1);
|
||||
}
|
||||
}
|
||||
|
||||
private PolyvPptPageInfo findClosestPPT(int position, ArrayList<PolyvPptPageInfo> page) {
|
||||
PolyvPptPageInfo closestPageBean = null;
|
||||
int closestSec = -1;
|
||||
if (page != null) {
|
||||
for (int i = 0; i < page.size(); i++) {
|
||||
PolyvPptPageInfo pageBean = page.get(i);
|
||||
if (pageBean.getSec() == position) {
|
||||
return pageBean;
|
||||
} else if (pageBean.getSec() < position) {
|
||||
if (closestSec == -1 || position - pageBean.getSec() < closestSec) {
|
||||
closestSec = position - pageBean.getSec();
|
||||
closestPageBean = pageBean;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (closestPageBean == null && page.size() > 0) {
|
||||
closestPageBean = page.get(0);
|
||||
}
|
||||
}
|
||||
return closestPageBean;
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
handler.removeMessages(1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,293 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer.ppt;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Color;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.GestureDetector;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.easefun.polyvsdk.po.ppt.PolyvPptInfo;
|
||||
import com.easefun.polyvsdk.video.PolyvVideoView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import cn.shangyu.gdxzExpert.polyvplayer.player.PolyvPlayerAudioCoverView;
|
||||
import cn.shangyu.gdxzExpert.polyvplayer.util.PolyvScreenUtils;
|
||||
import cn.shangyu.gdxzExpert.polyvplayer.view.PolyvLoadingLayout;
|
||||
|
||||
/**
|
||||
* 三分屏的副屏布局
|
||||
*/
|
||||
public class PolyvViceScreenLayout extends FrameLayout {
|
||||
// 点击的位置
|
||||
private float lastX, lastY;
|
||||
private static int width = 125, height = 70;
|
||||
private boolean isFromUserHide;
|
||||
private boolean isPPTInMinScreen;
|
||||
|
||||
private Runnable configChangedTask;
|
||||
|
||||
private GestureDetector gestureDetector;
|
||||
|
||||
|
||||
private PolyvVideoView videoView;
|
||||
private PolyvPPTView pptView;
|
||||
|
||||
//横/竖屏位置
|
||||
private static int portraitTopMargin = -1, portraitLeftMargin = -1, landscapeTopMargin = -1, landscapeLeftMargin = -1;
|
||||
|
||||
public PolyvViceScreenLayout(@NonNull Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public PolyvViceScreenLayout(@NonNull Context context, @Nullable AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
|
||||
public PolyvViceScreenLayout(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
gestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {
|
||||
@Override
|
||||
public boolean onSingleTapUp(MotionEvent e) {
|
||||
switchLocation();
|
||||
return super.onSingleTapUp(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static PolyvViceScreenLayout addViceLayoutInWindow(Activity activity, int marginTop) {
|
||||
//add ViceScreenLayout
|
||||
ViewGroup contentView = (ViewGroup) activity.findViewById(Window.ID_ANDROID_CONTENT);
|
||||
PolyvViceScreenLayout viceScreenLayout = new PolyvViceScreenLayout(activity);
|
||||
viceScreenLayout.setBackgroundColor(Color.BLACK);
|
||||
LayoutParams mlp = new LayoutParams(PolyvScreenUtils.dip2px(activity, width), PolyvScreenUtils.dip2px(activity, height));
|
||||
if (PolyvScreenUtils.isPortrait(activity)) {
|
||||
mlp.topMargin = portraitTopMargin = marginTop;
|
||||
mlp.leftMargin = portraitLeftMargin = contentView.getWidth() - PolyvScreenUtils.dip2px(activity, width);
|
||||
} else {
|
||||
mlp.topMargin = landscapeTopMargin = 0;
|
||||
mlp.leftMargin = landscapeLeftMargin = 0;//contentView.getWidth() - PolyvScreenUtils.dip2px(activity, width);
|
||||
}
|
||||
viceScreenLayout.setLayoutParams(mlp);
|
||||
contentView.addView(viceScreenLayout);
|
||||
//hide
|
||||
viceScreenLayout.hide();
|
||||
return viceScreenLayout;
|
||||
}
|
||||
|
||||
public void acceptPPTCallback(String vid, boolean hasPPT, PolyvPptInfo pptvo) {
|
||||
if (hasPPT) {
|
||||
if (!isFromUserHide) {
|
||||
show();
|
||||
}
|
||||
if (pptView != null) {
|
||||
pptView.acceptPPTCallback(videoView, vid, hasPPT, pptvo);
|
||||
}
|
||||
} else {
|
||||
hide();
|
||||
if (isPPTInMinScreen) {
|
||||
switchLocation(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void bindView(PolyvVideoView videoView, PolyvPPTView pptView) {
|
||||
this.videoView = videoView;
|
||||
this.pptView = pptView;
|
||||
}
|
||||
|
||||
public PolyvPPTView getPPTView() {
|
||||
return pptView;
|
||||
}
|
||||
|
||||
public boolean isPPTInMinScreen() {
|
||||
return isPPTInMinScreen;
|
||||
}
|
||||
|
||||
/**
|
||||
* 切换主副屏的位置
|
||||
*/
|
||||
public void switchLocation() {
|
||||
switchLocation(!isPPTInMinScreen);
|
||||
}
|
||||
|
||||
/**
|
||||
* 切换主副屏的位置
|
||||
*
|
||||
* @param isPPTInMinScreen 是否把ppt切到主屏
|
||||
*/
|
||||
public void switchLocation(boolean isPPTInMinScreen) {
|
||||
if (this.isPPTInMinScreen == isPPTInMinScreen || pptView == null || videoView == null)
|
||||
return;
|
||||
this.isPPTInMinScreen = isPPTInMinScreen;
|
||||
|
||||
List<View> pptChilds = new ArrayList<>();
|
||||
for (int i = 0; i < pptView.getChildCount(); i++) {
|
||||
pptChilds.add(pptView.getChildAt(i));
|
||||
}
|
||||
pptView.removeAllViews();
|
||||
List<View> videoChilds = new ArrayList<>();
|
||||
for (int i = 0; i < videoView.getChildCount(); i++) {
|
||||
videoChilds.add(videoView.getChildAt(i));
|
||||
}
|
||||
videoView.removeAllViews();
|
||||
|
||||
for (int i = 0; i < pptChilds.size(); i++) {
|
||||
videoView.addView(pptChilds.get(i));
|
||||
}
|
||||
for (int i = 0; i < videoChilds.size(); i++) {
|
||||
pptView.addView(videoChilds.get(i));
|
||||
}
|
||||
|
||||
//适配主副屏里的控件大小
|
||||
pptChilds.addAll(videoChilds);
|
||||
for (View view : pptChilds) {
|
||||
if (view instanceof PolyvPlayerAudioCoverView) {
|
||||
((PolyvPlayerAudioCoverView)view).fitLocationChange(!isPPTInMinScreen);
|
||||
} else if (view instanceof PolyvLoadingLayout) {
|
||||
((PolyvLoadingLayout) view).fitLocationChange(!isPPTInMinScreen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 隐藏副屏
|
||||
*/
|
||||
public void hide() {
|
||||
setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过用户点击按钮的方式隐藏副屏
|
||||
*/
|
||||
public void fromUserHide() {
|
||||
isFromUserHide = true;
|
||||
hide();
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过用户点击按钮的方式显示副屏
|
||||
*/
|
||||
public void fromUserShow() {
|
||||
isFromUserHide = false;
|
||||
show();
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示副屏
|
||||
*/
|
||||
public void show() {
|
||||
setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否显示
|
||||
*/
|
||||
public boolean isVisibible() {
|
||||
return getVisibility() == View.VISIBLE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 销毁
|
||||
*/
|
||||
public void destroy() {
|
||||
if (pptView != null) {
|
||||
pptView.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onConfigurationChanged(final Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
if (getHandler() != null) {
|
||||
getHandler().removeCallbacks(configChangedTask);
|
||||
}
|
||||
post(configChangedTask = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
if (landscapeLeftMargin != -1 && landscapeTopMargin != -1) {
|
||||
setLocation(landscapeTopMargin, landscapeLeftMargin);
|
||||
} else {
|
||||
landscapeTopMargin = 0;
|
||||
landscapeLeftMargin = 0;//((Activity) getContext()).findViewById(Window.ID_ANDROID_CONTENT).getWidth() - PolyvScreenUtils.dip2px(getContext(), width);
|
||||
setLocation(landscapeTopMargin, landscapeLeftMargin);
|
||||
}
|
||||
} else {
|
||||
if (portraitLeftMargin != -1 && portraitTopMargin != -1) {
|
||||
setLocation(portraitTopMargin, portraitLeftMargin);
|
||||
} else {
|
||||
if (videoView != null) {
|
||||
portraitTopMargin = videoView.getBottom();
|
||||
portraitLeftMargin = ((Activity) getContext()).findViewById(Window.ID_ANDROID_CONTENT).getWidth() - PolyvScreenUtils.dip2px(getContext(), width);
|
||||
setLocation(portraitTopMargin, portraitLeftMargin);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setLocation(int marginTop, int marginLeft) {
|
||||
LayoutParams mlp = (LayoutParams) getLayoutParams();
|
||||
mlp.leftMargin = marginLeft;
|
||||
mlp.topMargin = marginTop;
|
||||
setLayoutParams(mlp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
//子view为invisible时(即非visible)不要拦截点击事件
|
||||
boolean firstChildIsVisible = getChildAt(0) == null || (getChildAt(0).getVisibility() == View.VISIBLE);
|
||||
if (/*getVisibility() != View.VISIBLE || */!firstChildIsVisible)
|
||||
return super.onTouchEvent(event);
|
||||
|
||||
gestureDetector.onTouchEvent(event);
|
||||
|
||||
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
lastX = event.getX();
|
||||
lastY = event.getY();
|
||||
}
|
||||
if (event.getAction() == MotionEvent.ACTION_MOVE) {
|
||||
// 计算移动的距离
|
||||
float x = event.getX();
|
||||
float y = event.getY();
|
||||
// 偏移量
|
||||
int offX = (int) (x - lastX);
|
||||
int offY = (int) (y - lastY);
|
||||
View view = this;
|
||||
int left = view.getLeft() + offX;
|
||||
int top = view.getTop() + offY;
|
||||
int parentWidth = ((View) view.getParent()).getMeasuredWidth();
|
||||
int parentHeight = ((View) view.getParent()).getMeasuredHeight();
|
||||
if (offX < 0 && left < 0)
|
||||
left = 0;
|
||||
if (offY < 0 && top < 0)
|
||||
top = 0;
|
||||
if (offX > 0 && view.getRight() + offX > parentWidth)
|
||||
left = view.getLeft() + (parentWidth - view.getRight());
|
||||
if (offY > 0 && view.getBottom() + offY > parentHeight)
|
||||
top = view.getTop() + (parentHeight - view.getBottom());
|
||||
|
||||
MarginLayoutParams rlp = (MarginLayoutParams) view.getLayoutParams();
|
||||
rlp.leftMargin = left;
|
||||
rlp.topMargin = top;
|
||||
view.setLayoutParams(rlp);
|
||||
}
|
||||
if (event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_CANCEL) {
|
||||
lastX = 0;
|
||||
lastY = 0;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer.server;
|
||||
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import cn.shangyu.gdxzExpert.polyvplayer.server.request.PolyvGetByUploader;
|
||||
import cn.shangyu.gdxzExpert.polyvplayer.server.request.PolyvPlayTimes;
|
||||
import cn.shangyu.gdxzExpert.polyvplayer.server.vo.PolyvGetByUploaderResult;
|
||||
import cn.shangyu.gdxzExpert.polyvplayer.server.vo.PolyvPlayTimesResult;
|
||||
|
||||
|
||||
/**
|
||||
* 点播业务接口,本类主要是演示POLYV服务业务接口的使用,开发者需要根据自己的业务逻辑调整代码。
|
||||
* @author Lionel 2018-11-7
|
||||
*/
|
||||
public class PolyvVodBusinessServer {
|
||||
private static final String TAG = "PolyvVodBusinessServer";
|
||||
|
||||
private static final String USER_ID = "";
|
||||
private static final String SECRET_KEY = "";
|
||||
|
||||
/**
|
||||
* 获取某分类下某子账号的视频列表,接口文档
|
||||
* http://dev.polyv.net/2018/videoproduct/v-api/v-api-vmanage/v-api-vmanage-list/get-by-uploader/
|
||||
* @param page 页码
|
||||
* @return 失败返回null,成功返回结果对象
|
||||
*/
|
||||
@Nullable
|
||||
public static PolyvGetByUploaderResult getByUploader(int page) {
|
||||
ArrayList<String> exceptionList = new ArrayList<>();
|
||||
PolyvGetByUploaderResult result = null;
|
||||
//3次重试,容错网络抖动
|
||||
for (int i = 0, length = 3 ; i < length ; i++) {
|
||||
result = PolyvGetByUploader.requestGetByUploader(USER_ID, SECRET_KEY, page, PolyvGetByUploader.ORDER_TYPE_PTIME_ASC, false, exceptionList);
|
||||
if (result != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (result == null) {
|
||||
for (String error : exceptionList) {
|
||||
Log.e(TAG, error);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量获取视频播放次数,接口文档
|
||||
* http://dev.polyv.net/2017/videoproduct/v-api/v-api-vmanage/v-api-vmanage-info/getplaytimes/
|
||||
* @param vids 视频ID列表
|
||||
* @return 失败返回null,成功返回结果对象
|
||||
*/
|
||||
@Nullable
|
||||
public static PolyvPlayTimesResult playTimes(@NonNull ArrayList<String> vids) {
|
||||
if (vids.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ArrayList<String> exceptionList = new ArrayList<>();
|
||||
PolyvPlayTimesResult result = null;
|
||||
//3次重试,容错网络抖动
|
||||
for (int i = 0, length = 3 ; i < length ; i++) {
|
||||
result = PolyvPlayTimes.requestPlayTimes(USER_ID, SECRET_KEY, vids, exceptionList);
|
||||
if (result != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (result == null) {
|
||||
for (String error : exceptionList) {
|
||||
Log.e(TAG, error);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer.server.request;
|
||||
|
||||
import androidx.annotation.IntDef;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.easefun.polyvsdk.PolyvSDKUtil;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
|
||||
import cn.shangyu.gdxzExpert.polyvplayer.server.vo.PolyvGetByUploaderResult;
|
||||
|
||||
|
||||
/**
|
||||
* 获取某分类下某子账号的视频列表,接口文档
|
||||
* http://dev.polyv.net/2018/videoproduct/v-api/v-api-vmanage/v-api-vmanage-list/get-by-uploader/
|
||||
* @author Lionel 2018-11-8
|
||||
*/
|
||||
public class PolyvGetByUploader {
|
||||
private static final String TAG = "PolyvGetByUploader";
|
||||
|
||||
/** ptime升序 */
|
||||
public static final int ORDER_TYPE_PTIME_ASC = 1;
|
||||
/** ptime降序 */
|
||||
public static final int ORDER_TYPE_PTIME_DESC = 2;
|
||||
/** times升序 */
|
||||
public static final int ORDER_TYPE_TIMES_ASC = 3;
|
||||
/** times降序 */
|
||||
public static final int ORDER_TYPE_TIMES_DESC = 4;
|
||||
|
||||
@IntDef({
|
||||
ORDER_TYPE_PTIME_ASC,
|
||||
ORDER_TYPE_PTIME_DESC,
|
||||
ORDER_TYPE_TIMES_ASC,
|
||||
ORDER_TYPE_TIMES_DESC
|
||||
})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface OrderType {}
|
||||
|
||||
/**
|
||||
* 获取某分类下某子账号的视频列表,详细请看
|
||||
* http://dev.polyv.net/2018/videoproduct/v-api/v-api-vmanage/v-api-vmanage-list/get-by-uploader/
|
||||
*/
|
||||
private static final String GET_BY_UPLOADER_URL = "http://api.polyv.net/v2/video/%s/get-by-uploader";
|
||||
|
||||
/**
|
||||
* 获取某分类下某子账号的视频列表,接口文档
|
||||
* http://dev.polyv.net/2018/videoproduct/v-api/v-api-vmanage/v-api-vmanage-list/get-by-uploader/
|
||||
* @param userId 用户ID
|
||||
* @param secretKey key
|
||||
* @param page 页码
|
||||
* @param orderType 排序类型
|
||||
* @param containSubCata 是否包含子分类
|
||||
* @return 失败返回null,成功返回结果对象
|
||||
*/
|
||||
@Nullable
|
||||
public static PolyvGetByUploaderResult requestGetByUploader(@NonNull String userId, @NonNull String secretKey, int page, @OrderType int orderType, boolean containSubCata, @NonNull ArrayList<String> exceptionList) {
|
||||
int containSubCataType = containSubCata ? 1 : 0;
|
||||
long ptime = System.currentTimeMillis();
|
||||
String signParam = "containSubCata=" + containSubCataType + "&" +
|
||||
"orderType=" + orderType + "&" +
|
||||
"page=" + page + "&" +
|
||||
"ptime=" + ptime +
|
||||
secretKey;
|
||||
|
||||
String sign = PolyvSDKUtil.sha1(signParam).toUpperCase();
|
||||
String url = String.format(Locale.getDefault(), GET_BY_UPLOADER_URL, userId) + "?" +
|
||||
"&containSubCata=" + containSubCataType +
|
||||
"&orderType=" + orderType +
|
||||
"&page=" + page +
|
||||
"&ptime=" + ptime +
|
||||
"&sign=" + sign;
|
||||
|
||||
String body = PolyvSDKUtil.getUrl2String(url, 6000, 6000, exceptionList);
|
||||
if (TextUtils.isEmpty(body)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Gson gson = new Gson();
|
||||
PolyvGetByUploaderResult result = gson.fromJson(body, PolyvGetByUploaderResult.class);
|
||||
if (result == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
//返回码看接口文档中的响应说明
|
||||
if (result.getCode() != PolyvGetByUploaderResult.OK) {
|
||||
Log.e(TAG, result.toString());
|
||||
exceptionList.add(result.toString());
|
||||
return null;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer.server.request;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.easefun.polyvsdk.PolyvSDKUtil;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
|
||||
import cn.shangyu.gdxzExpert.polyvplayer.server.vo.PolyvPlayTimesResult;
|
||||
|
||||
|
||||
/**
|
||||
* 批量获取视频播放次数,接口文档
|
||||
* http://dev.polyv.net/2017/videoproduct/v-api/v-api-vmanage/v-api-vmanage-info/getplaytimes/
|
||||
* @author Lionel 2018-11-12
|
||||
*/
|
||||
public class PolyvPlayTimes {
|
||||
private static final String TAG = "PolyvPlayTimes";
|
||||
|
||||
/**
|
||||
* 批量获取视频播放次数,详细请看
|
||||
* http://dev.polyv.net/2017/videoproduct/v-api/v-api-vmanage/v-api-vmanage-info/getplaytimes/
|
||||
*/
|
||||
private static final String PLAY_TIMES_URL = "http://api.polyv.net/v2/data/%s/play-times";
|
||||
|
||||
public static PolyvPlayTimesResult requestPlayTimes(@NonNull String userId, @NonNull String secretKey, @NonNull ArrayList<String> vids, @NonNull ArrayList<String> exceptionList) {
|
||||
String vidsStr = TextUtils.join(",", vids);
|
||||
long ptime = System.currentTimeMillis();
|
||||
String signParam = "ptime=" + ptime + "&" +
|
||||
"realTime=" + "1" + "&" +
|
||||
"vids=" + vidsStr +
|
||||
secretKey;
|
||||
|
||||
String sign = PolyvSDKUtil.sha1(signParam).toUpperCase();
|
||||
String url = String.format(Locale.getDefault(), PLAY_TIMES_URL, userId) + "?" +
|
||||
"&ptime=" + ptime +
|
||||
"&realTime=" + "1" +
|
||||
"&sign=" + sign +
|
||||
"&vids=" + vidsStr;
|
||||
|
||||
String body = PolyvSDKUtil.getUrl2String(url, 6000, 6000, exceptionList);
|
||||
if (TextUtils.isEmpty(body)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
JSONObject jsonObject;
|
||||
try {
|
||||
jsonObject = new JSONObject(body);
|
||||
} catch (JSONException e) {
|
||||
exceptionList.add(PolyvSDKUtil.getExceptionFullMessage(e, -1));
|
||||
return null;
|
||||
}
|
||||
|
||||
int code = jsonObject.optInt("code", 0);
|
||||
//返回码看接口文档中的响应说明
|
||||
if (code == PolyvPlayTimesResult.OK) {
|
||||
Gson gson = new Gson();
|
||||
return gson.fromJson(body, PolyvPlayTimesResult.class);
|
||||
}
|
||||
|
||||
Log.e(TAG, body);
|
||||
exceptionList.add(body);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+229
@@ -0,0 +1,229 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer.server.vo;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* 获取某分类下某子账号的视频列表结果,接口文档
|
||||
* http://dev.polyv.net/2018/videoproduct/v-api/v-api-vmanage/v-api-vmanage-list/get-by-uploader/
|
||||
* @author Lionel 2018-11-7
|
||||
*/
|
||||
public class PolyvGetByUploaderResult {
|
||||
/** success */
|
||||
public static final int OK = 200;
|
||||
|
||||
private int code;
|
||||
private String status;
|
||||
private String message;
|
||||
private Data data;
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public Data getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(Data data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PolyvGetByUploaderResult{" +
|
||||
"code=" + code +
|
||||
", status='" + status + '\'' +
|
||||
", message='" + message + '\'' +
|
||||
", data=" + data +
|
||||
'}';
|
||||
}
|
||||
|
||||
public class Data {
|
||||
private int pageSize;
|
||||
private int pageNumber;
|
||||
private int totalItems;
|
||||
private ArrayList<Content> contents;
|
||||
|
||||
public int getPageSize() {
|
||||
return pageSize;
|
||||
}
|
||||
|
||||
public void setPageSize(int pageSize) {
|
||||
this.pageSize = pageSize;
|
||||
}
|
||||
|
||||
public int getPageNumber() {
|
||||
return pageNumber;
|
||||
}
|
||||
|
||||
public void setPageNumber(int pageNumber) {
|
||||
this.pageNumber = pageNumber;
|
||||
}
|
||||
|
||||
public int getTotalItems() {
|
||||
return totalItems;
|
||||
}
|
||||
|
||||
public void setTotalItems(int totalItems) {
|
||||
this.totalItems = totalItems;
|
||||
}
|
||||
|
||||
public ArrayList<Content> getContents() {
|
||||
return contents;
|
||||
}
|
||||
|
||||
public void setContents(ArrayList<Content> contents) {
|
||||
this.contents = contents;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Data{" +
|
||||
"pageSize=" + pageSize +
|
||||
", pageNumber=" + pageNumber +
|
||||
", totalItems=" + totalItems +
|
||||
", contents=" + contents +
|
||||
'}';
|
||||
}
|
||||
|
||||
public class Content {
|
||||
private String vid;
|
||||
private long cataid;
|
||||
private String title;
|
||||
private String context;
|
||||
private int times;
|
||||
private String firstImage;
|
||||
private String tag;
|
||||
private String aacLink;
|
||||
private String status;
|
||||
private String uploaderEmail;
|
||||
private long ptime;
|
||||
|
||||
public String getVid() {
|
||||
return vid;
|
||||
}
|
||||
|
||||
public void setVid(String vid) {
|
||||
this.vid = vid;
|
||||
}
|
||||
|
||||
public long getCataid() {
|
||||
return cataid;
|
||||
}
|
||||
|
||||
public void setCataid(long cataid) {
|
||||
this.cataid = cataid;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
public void setContext(String context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public int getTimes() {
|
||||
return times;
|
||||
}
|
||||
|
||||
public void setTimes(int times) {
|
||||
this.times = times;
|
||||
}
|
||||
|
||||
public String getFirstImage() {
|
||||
return firstImage;
|
||||
}
|
||||
|
||||
public void setFirstImage(String firstImage) {
|
||||
this.firstImage = firstImage;
|
||||
}
|
||||
|
||||
public String getTag() {
|
||||
return tag;
|
||||
}
|
||||
|
||||
public void setTag(String tag) {
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
public String getAacLink() {
|
||||
return aacLink;
|
||||
}
|
||||
|
||||
public void setAacLink(String aacLink) {
|
||||
this.aacLink = aacLink;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getUploaderEmail() {
|
||||
return uploaderEmail;
|
||||
}
|
||||
|
||||
public void setUploaderEmail(String uploaderEmail) {
|
||||
this.uploaderEmail = uploaderEmail;
|
||||
}
|
||||
|
||||
public long getPtime() {
|
||||
return ptime;
|
||||
}
|
||||
|
||||
public void setPtime(long ptime) {
|
||||
this.ptime = ptime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Content{" +
|
||||
"vid='" + vid + '\'' +
|
||||
", cataid=" + cataid +
|
||||
", title='" + title + '\'' +
|
||||
", context='" + context + '\'' +
|
||||
", times=" + times +
|
||||
", firstImage='" + firstImage + '\'' +
|
||||
", tag='" + tag + '\'' +
|
||||
", aacLink='" + aacLink + '\'' +
|
||||
", status='" + status + '\'' +
|
||||
", uploaderEmail='" + uploaderEmail + '\'' +
|
||||
", ptime=" + ptime +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer.server.vo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* 批量获取视频播放次数结果,接口文档
|
||||
* http://dev.polyv.net/2017/videoproduct/v-api/v-api-vmanage/v-api-vmanage-info/getplaytimes/
|
||||
* @author Lionel 2018-11-12
|
||||
*/
|
||||
public class PolyvPlayTimesResult {
|
||||
/** success */
|
||||
public static final int OK = 200;
|
||||
|
||||
private int code;
|
||||
private String status;
|
||||
private String message;
|
||||
private ArrayList<Data> data;
|
||||
|
||||
public static int getOK() {
|
||||
return OK;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public ArrayList<Data> getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(ArrayList<Data> data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public class Data {
|
||||
private String vid;
|
||||
private int times;
|
||||
|
||||
public String getVid() {
|
||||
return vid;
|
||||
}
|
||||
|
||||
public void setVid(String vid) {
|
||||
this.vid = vid;
|
||||
}
|
||||
|
||||
public int getTimes() {
|
||||
return times;
|
||||
}
|
||||
|
||||
public void setTimes(int times) {
|
||||
this.times = times;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Data{" +
|
||||
"vid='" + vid + '\'' +
|
||||
", times=" + times +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PolyvPlayTimesResult{" +
|
||||
"code=" + code +
|
||||
", status='" + status + '\'' +
|
||||
", message='" + message + '\'' +
|
||||
", data=" + data +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
+96
@@ -0,0 +1,96 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer.service;
|
||||
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.Service;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
import android.os.Binder;
|
||||
import android.os.Build;
|
||||
import android.os.IBinder;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.app.NotificationCompat;
|
||||
|
||||
import cn.shangyu.gdxzExpert.polyvplayer.CourseDetailPolyvPlayerActivity;
|
||||
|
||||
|
||||
/**
|
||||
* 后台播放服务
|
||||
*/
|
||||
public class PolyvBackgroundPlayService extends Service {
|
||||
public static final String TAG = "PolyvBgPlayService";
|
||||
public static final String CHANNEL_ID = "bgPlayChannel";
|
||||
public static final String CHANNEL_NAME = "后台播放服务";
|
||||
public static final int NOTIFICATION_ID = 0x111;
|
||||
public static final int REQUEST_CODE_PLAY_ACTIVITY = 0x222;
|
||||
|
||||
public static void bindService(Context context, ServiceConnection serviceConnection) {
|
||||
|
||||
Intent intent = new Intent();
|
||||
intent.setClass(context, PolyvBackgroundPlayService.class);
|
||||
context.bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE);
|
||||
}
|
||||
|
||||
public static void startService(Context context) {
|
||||
Intent intent = new Intent(context, PolyvBackgroundPlayService.class);
|
||||
context.startService(intent);//startForegroundService 5s
|
||||
}
|
||||
|
||||
public class PlayBinder extends Binder {
|
||||
public void start(String title, String text, int icon) {
|
||||
startForeground(NOTIFICATION_ID, createNotification(title, text, icon));
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
stopForeground(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
NotificationChannel channel = new NotificationChannel(CHANNEL_ID, CHANNEL_NAME, NotificationManager.IMPORTANCE_DEFAULT);
|
||||
channel.setLockscreenVisibility(Notification.VISIBILITY_SECRET);
|
||||
if (notificationManager != null) {
|
||||
// 注册通道,注册后除非卸载再安装否则不改变
|
||||
notificationManager.createNotificationChannel(channel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Notification createNotification(String title, String text, int icon) {
|
||||
Intent intent = new Intent(this, CourseDetailPolyvPlayerActivity.class);
|
||||
PendingIntent pendingIntent = PendingIntent.getActivity(this, REQUEST_CODE_PLAY_ACTIVITY, intent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, CHANNEL_ID);
|
||||
builder.setContentIntent(pendingIntent);
|
||||
builder.setShowWhen(false);
|
||||
builder.setSmallIcon(icon);
|
||||
builder.setContentTitle(title);
|
||||
builder.setContentText(text);
|
||||
builder.setPriority(NotificationCompat.PRIORITY_DEFAULT);
|
||||
builder.setVisibility(NotificationCompat.VISIBILITY_SECRET);
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
return Service.START_NOT_STICKY;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
return new PlayBinder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer.service;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
|
||||
import com.easefun.polyvsdk.server.AndroidService;
|
||||
|
||||
/**
|
||||
* 播放视频已改版,不再需要service来播放视频
|
||||
*/
|
||||
@Deprecated
|
||||
public class PolyvPlayService extends AndroidService {
|
||||
|
||||
private static final String TAG = PolyvPlayService.class.getSimpleName();
|
||||
|
||||
// 无参数构造函数,调用父类的super(String name)
|
||||
public PolyvPlayService() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart(Intent intent, int startId) {
|
||||
// TODO Auto-generated method stub
|
||||
super.onStart(intent, startId);
|
||||
// Log.i("TAG","service started");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
// TODO Auto-generated method stub
|
||||
// Log.i("TAG","service onStartCommand");
|
||||
return super.onStartCommand(intent, flags, startId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
// TODO Auto-generated method stub
|
||||
super.onCreate();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onHandleIntent(Intent intent) {
|
||||
super.onHandleIntent(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
// TODO Auto-generated method stub
|
||||
super.onDestroy();
|
||||
Log.i(TAG, "server destory");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,315 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer.util;
|
||||
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.easefun.polyvsdk.PolyvDownloaderErrorReason;
|
||||
import com.easefun.polyvsdk.video.PolyvPlayErrorReason;
|
||||
|
||||
|
||||
/**
|
||||
* 错误类型转成错误信息工具类
|
||||
* @author Lion 2017-8-3
|
||||
*/
|
||||
public class PolyvErrorMessageUtils {
|
||||
/**
|
||||
* 获取下载错误信息
|
||||
* @param type 下载错误类型
|
||||
* @return 错误信息字符串
|
||||
*/
|
||||
@NonNull
|
||||
public static String getDownloaderErrorMessage(PolyvDownloaderErrorReason.ErrorType type) {
|
||||
switch (type) {
|
||||
case VID_IS_NULL:
|
||||
return "视频id不正确,请设置正确的视频id进行下载";
|
||||
|
||||
case NOT_PERMISSION:
|
||||
return "非法下载,请向管理员反馈";
|
||||
|
||||
case RUNTIME_EXCEPTION:
|
||||
return "当前视频无法下载,请向管理员反馈";
|
||||
|
||||
case VIDEO_STATUS_ERROR:
|
||||
return "视频状态异常,无法下载";
|
||||
|
||||
case M3U8_NOT_DATA:
|
||||
return "视频数据加载失败,请重新下载";
|
||||
|
||||
case QUESTION_NOT_DATA:
|
||||
return "视频问答数据加载失败,请重新下载";
|
||||
|
||||
case MULTIMEDIA_LIST_EMPTY:
|
||||
return "当前视频无法下载,请向管理员反馈";
|
||||
|
||||
case CAN_NOT_MKDIR:
|
||||
return "当前视频无法下载,请重启手机再次下载或者向管理员反馈";
|
||||
|
||||
case DOWNLOAD_TS_ERROR:
|
||||
return "视频文件下载失败,请重新下载";
|
||||
|
||||
case MULTIMEDIA_EMPTY:
|
||||
return "当前视频无法下载,请向管理员反馈";
|
||||
|
||||
case NOT_CREATE_DIR:
|
||||
return "当前视频无法下载,请重启手机再次下载或者向管理员反馈";
|
||||
|
||||
case VIDEO_LOAD_FAILURE:
|
||||
return "当前视频无法下载,请向管理员反馈";
|
||||
|
||||
case VIDEO_NULL:
|
||||
return "视频信息加载失败,请重新下载";
|
||||
|
||||
case DIR_SPACE_LACK:
|
||||
return "检测到移动设备存储空间不足,请清除存储空间再重新下载";
|
||||
|
||||
case DOWNLOAD_DIR_IS_NUll:
|
||||
return "检测到存储目录未设置,请先设置存储目录再重新下载";
|
||||
|
||||
case HLS_15X_URL_ERROR:
|
||||
return "当前视频无法下载,请向管理员反馈";
|
||||
|
||||
case HLS_SPEED_TYPE_IS_NULL:
|
||||
return "视频速度类型错误,请设置了速度类型后重新下载";
|
||||
|
||||
case HLS_15X_ERROR:
|
||||
return "当前视频无法下载,请向管理员反馈";
|
||||
|
||||
case GET_VIDEO_INFO_ERROR:
|
||||
return "视频信息加载失败,请重新下载";
|
||||
|
||||
case WRITE_EXTERNAL_STORAGE_DENIED:
|
||||
return "检测到拒绝写入存储设备,请先为应用程序分配权限,再重新下载";
|
||||
|
||||
case VID_ERROR:
|
||||
return "视频id不正确,请设置正确的视频id进行下载";
|
||||
|
||||
case EXTRA_DIR_IS_NUll:
|
||||
return "检测到资源目录未设置,请先设置存储目录再重新下载";
|
||||
|
||||
case NOT_CREATE_EXTRA_DIR:
|
||||
return "当前视频无法下载,请重启手机再次下载或者向管理员反馈";
|
||||
|
||||
case CREATE_NOMEDIA_ERROR:
|
||||
return "当前视频无法下载,请重启手机再次下载或者向管理员反馈";
|
||||
|
||||
case URL_IS_EMPTY:
|
||||
return "当前视频无法下载,请向管理员反馈";
|
||||
|
||||
case CREATE_M3U8_FILE_ERROR:
|
||||
return "当前视频无法下载,请重启手机再次下载或者向管理员反馈";
|
||||
|
||||
case WRITE_M3U8_FILE_ERROR:
|
||||
return "当前视频无法下载,请重启手机再次下载或者向管理员反馈";
|
||||
|
||||
case CREATE_VIDEO_JSON_ERROR:
|
||||
return "当前视频无法下载,请重启手机再次下载或者向管理员反馈";
|
||||
|
||||
case WRITE_VIDEO_JSON_ERROR:
|
||||
return "当前视频无法下载,请重启手机再次下载或者向管理员反馈";
|
||||
|
||||
case QUESTION_FORMAT_JSON_ERROR:
|
||||
return "当前视频无法下载,请重新下载或者切换网络重新下载或者向管理员反馈";
|
||||
|
||||
case DELETE_ZIP_FILE_ERROR:
|
||||
return "当前视频无法下载,请重启手机再次下载或者向管理员反馈";
|
||||
|
||||
case CREATE_VIDEO_TMP_FILE_ERROR:
|
||||
return "当前视频无法下载,请重启手机再次下载或者向管理员反馈";
|
||||
|
||||
case DOWNLOAD_VIDEO_FILE_LENGTH_ERROR:
|
||||
return "当前视频无法下载,请重新下载或者切换网络重新下载或者向管理员反馈";
|
||||
|
||||
case VIDEO_HTTP_CODE_ERROR:
|
||||
return "当前视频无法下载,请重新下载或者切换网络重新下载或者向管理员反馈";
|
||||
|
||||
case VIDEO_DOWNLOAD_ERROR:
|
||||
return "当前视频下载出错,请点击停止/继续下载或删除重新下载";// 当前视频无法下载,请删除后重新下载或者切换网络重新下载或者向管理员反馈
|
||||
|
||||
case VIDEO_RENAME_ERROR:
|
||||
return "当前视频无法下载,请重启手机再次下载或者向管理员反馈";
|
||||
|
||||
case UNZIP_FILE_ERROR:
|
||||
return "当前视频解压失败,请尝试删除视频再次下载或者切换网络再次下载或者向管理员反馈";
|
||||
|
||||
case CREATE_ZIP_TMP_FILE_ERROR:
|
||||
return "当前视频无法下载,请重启手机再次下载或者向管理员反馈";
|
||||
|
||||
case CREATE_UNZIP_DIR_ERROR:
|
||||
return "当前视频无法下载,请重启手机再次下载或者向管理员反馈";
|
||||
|
||||
case DOWNLOAD_ZIP_FILE_LENGTH_ERROR:
|
||||
return "当前视频无法下载,请重新下载或者切换网络重新下载或者向管理员反馈";
|
||||
|
||||
case ZIP_HTTP_CODE_ERROR:
|
||||
return "当前视频无法下载,请重新下载或者切换网络重新下载或者向管理员反馈";
|
||||
|
||||
case ZIP_DOWNLOAD_ERROR:
|
||||
return "当前视频下载出错,请删除后重新下载或者切换网络重新下载或者向管理员反馈";
|
||||
|
||||
case ZIP_RENAME_ERROR:
|
||||
return "当前视频无法下载,请重启手机再次下载或者向管理员反馈";
|
||||
|
||||
case NETWORK_DENIED:
|
||||
return "无法连接网络,请连接网络后下载";
|
||||
|
||||
case MEDIA_UNKNOWN:
|
||||
return "SD卡不可用,请重启手机或者更换SD卡或者向管理员反馈";
|
||||
|
||||
case MEDIA_REMOVED:
|
||||
return "SD卡被移除,请重启手机或者向管理员反馈";
|
||||
|
||||
case MEDIA_UNMOUNTED:
|
||||
return "SD卡存在但未安装,请重新安装SD卡或者向管理员反馈";
|
||||
|
||||
case MEDIA_CHECKING:
|
||||
return "SD卡正在进行磁盘检查中,请稍后下载或者重启手机或者向管理员反馈";
|
||||
|
||||
case MEDIA_NOFS:
|
||||
return "SD卡空白或正在使用不受支持的文件系统,请重启手机或者更换SD卡或者向管理员反馈";
|
||||
|
||||
case MEDIA_MOUNTED_READ_ONLY:
|
||||
return "SD卡不能写入,请重启手机或者向管理员反馈";
|
||||
|
||||
case MEDIA_SHARED:
|
||||
return "SD卡不可用,请重启手机或者更换SD卡或者向管理员反馈";
|
||||
|
||||
case MEDIA_BAD_REMOVAL:
|
||||
return "SD卡不可用,请重启手机或者更换SD卡或者向管理员反馈";
|
||||
|
||||
case MEDIA_UNMOUNTABLE:
|
||||
return "SD卡不可用,请重启手机或者更换SD卡或者向管理员反馈";
|
||||
|
||||
case MEDIA_EJECTING:
|
||||
return "SD卡不可用,请重启手机或者更换SD卡或者向管理员反馈";
|
||||
|
||||
case VIDEO_BITRATE_NOT_EXIST:
|
||||
return "当前视频下载出错,请尝试切换码率进行下载或者向管理员反馈";
|
||||
|
||||
default:
|
||||
return "当前视频无法下载,请向管理员反馈";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取播放错误信息
|
||||
* @param playErrorReason 播放错误类型
|
||||
* @return 错误信息字符串
|
||||
*/
|
||||
public static String getPlayErrorMessage(@PolyvPlayErrorReason.PlayErrorReason int playErrorReason) {
|
||||
switch (playErrorReason) {
|
||||
case PolyvPlayErrorReason.VIDEO_ERROR:
|
||||
return "当前视频无法播放,请尝试切换网络重新播放或者向管理员反馈";
|
||||
|
||||
case PolyvPlayErrorReason.NETWORK_DENIED:
|
||||
return "无法连接网络,请连接网络后播放";
|
||||
|
||||
case PolyvPlayErrorReason.OUT_FLOW:
|
||||
return "流量超标,请向管理员反馈";
|
||||
|
||||
case PolyvPlayErrorReason.TIMEOUT_FLOW:
|
||||
return "账号过期,请向管理员反馈";
|
||||
|
||||
case PolyvPlayErrorReason.LOCAL_AUDIO_ERROR:
|
||||
return "本地视频文件损坏,请重新下载";
|
||||
|
||||
case PolyvPlayErrorReason.START_ERROR:
|
||||
return "播放异常,请重新播放";
|
||||
|
||||
case PolyvPlayErrorReason.NOT_PERMISSION:
|
||||
return "非法播放,请向管理员反馈";
|
||||
|
||||
case PolyvPlayErrorReason.USER_TOKEN_ERROR:
|
||||
return "请先设置播放凭证,再进行播放";
|
||||
|
||||
case PolyvPlayErrorReason.VIDEO_STATUS_ERROR:
|
||||
return "视频状态异常,无法播放,请向管理员反馈";
|
||||
|
||||
case PolyvPlayErrorReason.VID_ERROR:
|
||||
return "视频id不正确,请设置正确的视频id进行播放";
|
||||
|
||||
case PolyvPlayErrorReason.BITRATE_ERROR:
|
||||
return "清晰度不正确,请设置正确的清晰度进行播放";
|
||||
|
||||
case PolyvPlayErrorReason.VIDEO_NULL:
|
||||
return "视频信息加载失败,请尝试切换网络重新播放";
|
||||
|
||||
case PolyvPlayErrorReason.MP4_LINK_NUM_ERROR:
|
||||
return "当前视频无法播放,请向管理员反馈";
|
||||
|
||||
case PolyvPlayErrorReason.M3U8_LINK_NUM_ERROR:
|
||||
return "当前视频无法播放,请向管理员反馈";
|
||||
|
||||
case PolyvPlayErrorReason.HLS_SPEED_TYPE_NULL:
|
||||
return "播放速度不正确,请设置正确的播放速度进行播放";
|
||||
|
||||
case PolyvPlayErrorReason.NOT_LOCAL_VIDEO:
|
||||
return "找不到缓存的视频文件,请连网后重新下载";
|
||||
|
||||
case PolyvPlayErrorReason.HLS_15X_INDEX_EMPTY:
|
||||
return "当前视频无法播放,请向管理员反馈";
|
||||
|
||||
case PolyvPlayErrorReason.HLS_15X_ERROR:
|
||||
return "当前视频无法播放,请向管理员反馈";
|
||||
|
||||
case PolyvPlayErrorReason.HLS_15X_URL_ERROR:
|
||||
return "当前视频无法播放,请向管理员反馈";
|
||||
|
||||
case PolyvPlayErrorReason.M3U8_15X_LINK_NUM_ERROR:
|
||||
return "当前视频无法播放,请向管理员反馈";
|
||||
|
||||
case PolyvPlayErrorReason.CHANGE_EQUAL_HLS_SPEED:
|
||||
return "切换播放速度相同,请选择其它播放速度";
|
||||
|
||||
case PolyvPlayErrorReason.CAN_NOT_CHANGE_BITRATE:
|
||||
return "未开始播放视频不能切换清晰度,请先播放视频";
|
||||
|
||||
case PolyvPlayErrorReason.CAN_NOT_CHANGE_HLS_SPEED:
|
||||
return "未开始播放视频不能切换播放速度,请先播放视频";
|
||||
|
||||
case PolyvPlayErrorReason.QUESTION_ERROR:
|
||||
return "视频问答数据加载失败,请重新播放或者切换网络重新播放";
|
||||
|
||||
case PolyvPlayErrorReason.CHANGE_BITRATE_NOT_EXIST:
|
||||
return "视频没有这个清晰度,请切换其它清晰度";
|
||||
|
||||
case PolyvPlayErrorReason.HLS_URL_ERROR:
|
||||
return "当前视频无法播放,请向管理员反馈";
|
||||
|
||||
case PolyvPlayErrorReason.LOADING_VIDEO_ERROR:
|
||||
return "当前视频无法播放,请向管理员反馈";
|
||||
|
||||
case PolyvPlayErrorReason.HLS2_URL_ERROR:
|
||||
return "当前视频无法播放,请向管理员反馈";
|
||||
|
||||
case PolyvPlayErrorReason.TOKEN_NULL:
|
||||
return "播放授权获取失败,请重新播放或者切换网络重新播放或者向管理员反馈";
|
||||
|
||||
case PolyvPlayErrorReason.WRITE_EXTERNAL_STORAGE_DENIED:
|
||||
return "检测到拒绝读取存储设备,请先为应用程序分配权限,再重新播放";
|
||||
|
||||
case PolyvPlayErrorReason.SOURCE_URL_EMPTY:
|
||||
return "当前视频无法播放,请向管理员反馈";
|
||||
|
||||
case PolyvPlayErrorReason.AUDIO_URL_EMPTY:
|
||||
return "当前音频无法播放,请向管理员反馈";
|
||||
|
||||
case PolyvPlayErrorReason.NOT_LOCAL_AUDIO:
|
||||
return "找不到缓存的音频文件,请连网后重新下载";
|
||||
|
||||
case PolyvPlayErrorReason.CAN_NOT_CHANGE_AUDIO:
|
||||
return "未开始播放不能切换到音频,请先开始播放";
|
||||
|
||||
case PolyvPlayErrorReason.CAN_NOT_CHANGE_VIDEO:
|
||||
return "未开始播放不能切换到视频,请先开始播放";
|
||||
|
||||
case PolyvPlayErrorReason.LOCAL_VIDEO_ERROR:
|
||||
return "本地音频文件损坏,请重新下载";
|
||||
|
||||
case PolyvPlayErrorReason.LOAD_TIMEOUT:
|
||||
return "加载超时,请重新播放";
|
||||
|
||||
default:
|
||||
return "当前视频无法播放,请向管理员反馈";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.annotation.DrawableRes;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
||||
import com.bumptech.glide.load.resource.bitmap.CircleCrop;
|
||||
import com.bumptech.glide.request.RequestOptions;
|
||||
import com.bumptech.glide.request.target.Target;
|
||||
|
||||
/**
|
||||
* 图片二次加载框架
|
||||
*/
|
||||
public class PolyvImageLoader {
|
||||
|
||||
|
||||
// <editor-fold defaultstate="collapsed" desc="单例">
|
||||
private static PolyvImageLoader INSTANCE;
|
||||
|
||||
private PolyvImageLoader() {/**/}
|
||||
|
||||
public static PolyvImageLoader getInstance() {
|
||||
if (INSTANCE == null) {
|
||||
synchronized (PolyvImageLoader.class) {
|
||||
if (INSTANCE == null) {
|
||||
INSTANCE = new PolyvImageLoader();
|
||||
}
|
||||
}
|
||||
}
|
||||
return INSTANCE;
|
||||
}
|
||||
// </editor-fold>
|
||||
|
||||
|
||||
/**
|
||||
* 加载图片
|
||||
*/
|
||||
public void loadImage(Context context, String url, ImageView imageView) {
|
||||
Glide.with(context)
|
||||
.load(url)
|
||||
.into(imageView);
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载图片
|
||||
*/
|
||||
public void loadImage(Context context, @DrawableRes Integer resourceId, ImageView imageView) {
|
||||
Glide.with(context)
|
||||
.load(resourceId)
|
||||
.into(imageView);
|
||||
}
|
||||
|
||||
/**
|
||||
* 预加载
|
||||
* @param context
|
||||
* @param url
|
||||
*/
|
||||
public void preloadImage(Context context, String url){
|
||||
RequestOptions imgOptions = new RequestOptions()
|
||||
.diskCacheStrategy(DiskCacheStrategy.ALL)
|
||||
.override(Target.SIZE_ORIGINAL);
|
||||
Glide.with(context).load(url).apply(imgOptions).preload();
|
||||
}
|
||||
|
||||
/**
|
||||
* 原始尺寸加载图片
|
||||
* @param context
|
||||
* @param url
|
||||
* @param imageView
|
||||
*/
|
||||
public void loadImageOrigin(Context context, String url, ImageView imageView, @DrawableRes int placeHolderId) {
|
||||
RequestOptions options = new RequestOptions().override(Target.SIZE_ORIGINAL)
|
||||
.placeholder(placeHolderId)
|
||||
.skipMemoryCache(true)
|
||||
.diskCacheStrategy(DiskCacheStrategy.RESOURCE);
|
||||
loadImageWithOptions(context, url, imageView, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* 原始尺寸加载图片
|
||||
* @param context
|
||||
* @param url
|
||||
* @param imageView
|
||||
*/
|
||||
public void loadImageOrigin(Context context, String url, ImageView imageView, Drawable drawable) {
|
||||
RequestOptions options = new RequestOptions().override(Target.SIZE_ORIGINAL)
|
||||
.placeholder(drawable)
|
||||
.skipMemoryCache(true)
|
||||
.diskCacheStrategy(DiskCacheStrategy.RESOURCE);
|
||||
loadImageWithOptions(context, url, imageView, options);
|
||||
}
|
||||
|
||||
public void loadImageOriginCircle(Context context, String url, ImageView imageView, @DrawableRes int placeHolderId){
|
||||
RequestOptions options = new RequestOptions()
|
||||
.placeholder(placeHolderId)
|
||||
.bitmapTransform(new CircleCrop())
|
||||
.override(Target.SIZE_ORIGINAL).skipMemoryCache(true).diskCacheStrategy(DiskCacheStrategy.RESOURCE);
|
||||
loadImageWithOptions(context, url, imageView, options);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 加载图片,开启自动缓存策略
|
||||
* @param context
|
||||
* @param url
|
||||
* @param imageView
|
||||
*/
|
||||
public void loadImageWithCache(Context context, String url, ImageView imageView, @DrawableRes int placeHolderId) {
|
||||
RequestOptions options = new RequestOptions().dontAnimate()
|
||||
.placeholder(placeHolderId)
|
||||
.diskCacheStrategy(DiskCacheStrategy.AUTOMATIC);
|
||||
loadImageWithOptions(context, url, imageView, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载图片,关闭缓存策略
|
||||
* @param context
|
||||
* @param url
|
||||
* @param imageView
|
||||
*/
|
||||
public void loadImageNoCache(Context context, String url, ImageView imageView, @DrawableRes int placeHolderId) {
|
||||
RequestOptions options = new RequestOptions().dontAnimate()
|
||||
.placeholder(placeHolderId)
|
||||
.skipMemoryCache(true)
|
||||
.diskCacheStrategy(DiskCacheStrategy.NONE);
|
||||
loadImageWithOptions(context, url, imageView, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载图片,自定义配置
|
||||
* @param context
|
||||
* @param url
|
||||
* @param imageView
|
||||
* @param options 自定义配置
|
||||
*/
|
||||
public void loadImageWithOptions(Context context, String url, ImageView imageView, RequestOptions options){
|
||||
Glide.with(context)
|
||||
.load(url)
|
||||
.apply(options)
|
||||
.into(imageView);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.EditText;
|
||||
|
||||
/**
|
||||
* 软键盘工具类
|
||||
*/
|
||||
public class PolyvKeyBoardUtils
|
||||
{
|
||||
|
||||
|
||||
public static void openKeybord(EditText mEditText, Context mContext)
|
||||
{
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) mContext
|
||||
.getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
imm.showSoftInput(mEditText, InputMethodManager.RESULT_SHOWN);
|
||||
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED,
|
||||
InputMethodManager.HIDE_IMPLICIT_ONLY);
|
||||
}
|
||||
|
||||
|
||||
public static void closeKeybord(EditText mEditText, Context mContext)
|
||||
{
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) mContext
|
||||
.getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
imm.hideSoftInputFromWindow(mEditText.getWindowToken(), 0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,230 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.telephony.TelephonyManager;
|
||||
|
||||
public class PolyvNetworkUtils {
|
||||
|
||||
private PolyvNetworkUtils() {
|
||||
}
|
||||
|
||||
public static final int NETWORK_WIFI = 1; // wifi network
|
||||
public static final int NETWORK_4G = 4; // "4G" networks
|
||||
public static final int NETWORK_3G = 3; // "3G" networks
|
||||
public static final int NETWORK_2G = 2; // "2G" networks
|
||||
public static final int NETWORK_UNKNOWN = 5; // unknown network
|
||||
public static final int NETWORK_NO = -1; // no network
|
||||
|
||||
private static final int NETWORK_TYPE_GSM = 16;
|
||||
private static final int NETWORK_TYPE_TD_SCDMA = 17;
|
||||
private static final int NETWORK_TYPE_IWLAN = 18;
|
||||
|
||||
/**
|
||||
* 打开网络设置界面
|
||||
* <p>3.0以下打开设置界面</p>
|
||||
*
|
||||
* @param context 上下文
|
||||
*/
|
||||
public static void openWirelessSettings(Context context) {
|
||||
if (android.os.Build.VERSION.SDK_INT > 10) {
|
||||
context.startActivity(new Intent(android.provider.Settings.ACTION_SETTINGS));
|
||||
} else {
|
||||
context.startActivity(new Intent(android.provider.Settings.ACTION_WIRELESS_SETTINGS));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取活动网路信息
|
||||
*
|
||||
* @param context 上下文
|
||||
* @return NetworkInfo
|
||||
*/
|
||||
private static NetworkInfo getActiveNetworkInfo(Context context) {
|
||||
ConnectivityManager cm = (ConnectivityManager) context
|
||||
.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
return cm.getActiveNetworkInfo();
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断网络是否可用
|
||||
* <p>需添加权限 android.permission.ACCESS_NETWORK_STATE</p>
|
||||
*/
|
||||
public static boolean isAvailable(Context context) {
|
||||
NetworkInfo info = getActiveNetworkInfo(context);
|
||||
return info != null && info.isAvailable();
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断网络是否连接
|
||||
* <p>需添加权限 android.permission.ACCESS_NETWORK_STATE</p>
|
||||
*
|
||||
* @param context 上下文
|
||||
* @return true: 是<br>false: 否
|
||||
*/
|
||||
public static boolean isConnected(Context context) {
|
||||
NetworkInfo info = getActiveNetworkInfo(context);
|
||||
return info != null && info.isConnected();
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断网络是否是4G
|
||||
* <p>需添加权限 android.permission.ACCESS_NETWORK_STATE</p>
|
||||
*
|
||||
* @param context 上下文
|
||||
* @return true: 是<br>false: 不是
|
||||
*/
|
||||
public static boolean is4G(Context context) {
|
||||
NetworkInfo info = getActiveNetworkInfo(context);
|
||||
return info != null && info.isAvailable() && info.getSubtype() == TelephonyManager.NETWORK_TYPE_LTE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断wifi是否连接状态
|
||||
* <p>需添加权限 android.permission.ACCESS_NETWORK_STATE</p>
|
||||
*
|
||||
* @param context 上下文
|
||||
* @return true: 连接<br>false: 未连接
|
||||
*/
|
||||
public static boolean isWifiConnected(Context context) {
|
||||
ConnectivityManager cm = (ConnectivityManager) context
|
||||
.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
return cm != null && cm.getActiveNetworkInfo().getType() == ConnectivityManager.TYPE_WIFI;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取移动网络运营商名称
|
||||
* <p>如中国联通、中国移动、中国电信</p>
|
||||
*
|
||||
* @param context 上下文
|
||||
* @return 移动网络运营商名称
|
||||
*/
|
||||
public static String getNetworkOperatorName(Context context) {
|
||||
TelephonyManager tm = (TelephonyManager) context
|
||||
.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
return tm != null ? tm.getNetworkOperatorName() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取移动终端类型
|
||||
*
|
||||
* @param context 上下文
|
||||
* @return 手机制式
|
||||
* <ul>
|
||||
* <li>PHONE_TYPE_NONE : 0 手机制式未知</li>
|
||||
* <li>PHONE_TYPE_GSM : 1 手机制式为GSM,移动和联通</li>
|
||||
* <li>PHONE_TYPE_CDMA : 2 手机制式为CDMA,电信</li>
|
||||
* <li>PHONE_TYPE_SIP : 3</li>
|
||||
* </ul>
|
||||
*/
|
||||
public static int getPhoneType(Context context) {
|
||||
TelephonyManager tm = (TelephonyManager) context
|
||||
.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
return tm != null ? tm.getPhoneType() : -1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取当前的网络类型(WIFI,2G,3G,4G)
|
||||
* <p>需添加权限 android.permission.ACCESS_NETWORK_STATE</p>
|
||||
*
|
||||
* @param context 上下文
|
||||
* @return 网络类型
|
||||
* <ul>
|
||||
* <li>NETWORK_WIFI = 1;</li>
|
||||
* <li>NETWORK_4G = 4;</li>
|
||||
* <li>NETWORK_3G = 3;</li>
|
||||
* <li>NETWORK_2G = 2;</li>
|
||||
* <li>NETWORK_UNKNOWN = 5;</li>
|
||||
* <li>NETWORK_NO = -1;</li>
|
||||
* </ul>
|
||||
*/
|
||||
public static int getNetWorkType(Context context) {
|
||||
int netType = NETWORK_NO;
|
||||
NetworkInfo info = getActiveNetworkInfo(context);
|
||||
if (info != null && info.isAvailable()) {
|
||||
|
||||
if (info.getType() == ConnectivityManager.TYPE_WIFI) {
|
||||
netType = NETWORK_WIFI;
|
||||
} else if (info.getType() == ConnectivityManager.TYPE_MOBILE) {
|
||||
switch (info.getSubtype()) {
|
||||
|
||||
case NETWORK_TYPE_GSM:
|
||||
case TelephonyManager.NETWORK_TYPE_GPRS:
|
||||
case TelephonyManager.NETWORK_TYPE_CDMA:
|
||||
case TelephonyManager.NETWORK_TYPE_EDGE:
|
||||
case TelephonyManager.NETWORK_TYPE_1xRTT:
|
||||
case TelephonyManager.NETWORK_TYPE_IDEN:
|
||||
netType = NETWORK_2G;
|
||||
break;
|
||||
|
||||
case NETWORK_TYPE_TD_SCDMA:
|
||||
case TelephonyManager.NETWORK_TYPE_EVDO_A:
|
||||
case TelephonyManager.NETWORK_TYPE_UMTS:
|
||||
case TelephonyManager.NETWORK_TYPE_EVDO_0:
|
||||
case TelephonyManager.NETWORK_TYPE_HSDPA:
|
||||
case TelephonyManager.NETWORK_TYPE_HSUPA:
|
||||
case TelephonyManager.NETWORK_TYPE_HSPA:
|
||||
case TelephonyManager.NETWORK_TYPE_EVDO_B:
|
||||
case TelephonyManager.NETWORK_TYPE_EHRPD:
|
||||
case TelephonyManager.NETWORK_TYPE_HSPAP:
|
||||
netType = NETWORK_3G;
|
||||
break;
|
||||
|
||||
case NETWORK_TYPE_IWLAN:
|
||||
case TelephonyManager.NETWORK_TYPE_LTE:
|
||||
netType = NETWORK_4G;
|
||||
break;
|
||||
default:
|
||||
|
||||
String subtypeName = info.getSubtypeName();
|
||||
if (subtypeName.equalsIgnoreCase("TD-SCDMA")
|
||||
|| subtypeName.equalsIgnoreCase("WCDMA")
|
||||
|| subtypeName.equalsIgnoreCase("CDMA2000")) {
|
||||
netType = NETWORK_3G;
|
||||
} else {
|
||||
netType = NETWORK_UNKNOWN;
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
netType = NETWORK_UNKNOWN;
|
||||
}
|
||||
}
|
||||
return netType;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前的网络类型(WIFI,2G,3G,4G)
|
||||
* <p>依赖上面的方法</p>
|
||||
*
|
||||
* @param context 上下文
|
||||
* @return 网络类型名称
|
||||
* <ul>
|
||||
* <li>NETWORK_WIFI </li>
|
||||
* <li>NETWORK_4G </li>
|
||||
* <li>NETWORK_3G </li>
|
||||
* <li>NETWORK_2G </li>
|
||||
* <li>NETWORK_UNKNOWN</li>
|
||||
* <li>NETWORK_NO </li>
|
||||
* </ul>
|
||||
*/
|
||||
public static String getNetWorkTypeName(Context context) {
|
||||
switch (getNetWorkType(context)) {
|
||||
case NETWORK_WIFI:
|
||||
return "NETWORK_WIFI";
|
||||
case NETWORK_4G:
|
||||
return "NETWORK_4G";
|
||||
case NETWORK_3G:
|
||||
return "NETWORK_3G";
|
||||
case NETWORK_2G:
|
||||
return "NETWORK_2G";
|
||||
case NETWORK_NO:
|
||||
return "NETWORK_NO";
|
||||
default:
|
||||
return "NETWORK_UNKNOWN";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer.util;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.ActivityManager;
|
||||
import android.content.Context;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Point;
|
||||
import android.os.Build;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 与屏幕相关的工具类
|
||||
*/
|
||||
public class PolyvScreenUtils {
|
||||
private static int height16_9;
|
||||
|
||||
// 生成竖屏下w:h=16:9的高
|
||||
public static int generateHeight16_9(Activity activity) {
|
||||
return height16_9 != 0 ? height16_9 : (height16_9 = getNormalWH(activity)[isPortrait(activity) ? 0 : 1] * 9 / 16);
|
||||
}
|
||||
|
||||
// 获取竖屏下w:h=16:9的高
|
||||
public static int getHeight16_9() {
|
||||
return height16_9;
|
||||
}
|
||||
|
||||
|
||||
// 是否竖屏
|
||||
public static boolean isPortrait(Context context) {
|
||||
return context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;
|
||||
}
|
||||
|
||||
// 是否横屏
|
||||
public static boolean isLandscape(Context context) {
|
||||
return context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
|
||||
}
|
||||
|
||||
// 设置竖屏
|
||||
public static void setPortrait(Activity activity) {
|
||||
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
|
||||
}
|
||||
|
||||
// 设置横屏
|
||||
public static void setLandscape(Activity activity) {
|
||||
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取包含状态栏的屏幕宽度和高度
|
||||
*
|
||||
* @param activity
|
||||
* @return {宽,高}
|
||||
*/
|
||||
public static int[] getNormalWH(Activity activity) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
|
||||
DisplayMetrics dm = new DisplayMetrics();
|
||||
activity.getWindowManager().getDefaultDisplay().getMetrics(dm);
|
||||
return new int[] { dm.widthPixels, dm.heightPixels };
|
||||
} else {
|
||||
Point point = new Point();
|
||||
WindowManager wm = activity.getWindowManager();
|
||||
wm.getDefaultDisplay().getSize(point);
|
||||
return new int[] { point.x, point.y };
|
||||
}
|
||||
}
|
||||
|
||||
// 重置状态栏
|
||||
public static void reSetStatusBar(Activity activity) {
|
||||
if (isLandscape(activity)) {
|
||||
hideStatusBar(activity);
|
||||
} else {
|
||||
setDecorVisible(activity);
|
||||
}
|
||||
}
|
||||
|
||||
// 隐藏状态栏
|
||||
public static void hideStatusBar(Activity activity) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
|
||||
activity.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
} else {
|
||||
View decorView = activity.getWindow().getDecorView();
|
||||
activity.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
||||
| View.SYSTEM_UI_FLAG_IMMERSIVE | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
|
||||
decorView.setSystemUiVisibility(uiOptions);
|
||||
}
|
||||
}
|
||||
|
||||
// 恢复为不全屏状态
|
||||
public static void setDecorVisible(Activity activity) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
|
||||
activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
} else {
|
||||
View decorView = activity.getWindow().getDecorView();
|
||||
activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
int uiOptions = View.SYSTEM_UI_FLAG_VISIBLE;
|
||||
decorView.setSystemUiVisibility(uiOptions);
|
||||
}
|
||||
}
|
||||
|
||||
public static int dip2px(Context context, float dpValue) {
|
||||
final float scale = context.getResources().getDisplayMetrics().density;
|
||||
return (int) (dpValue * scale + 0.5f);
|
||||
}
|
||||
|
||||
public static int px2dip(Context context, float dpValue) {
|
||||
final float scale = context.getResources().getDisplayMetrics().density;
|
||||
return (int) (dpValue / scale + 0.5f);
|
||||
}
|
||||
//由于画中画的activity为singleInstance模式,如果需要在画中画的activity退出时退出singleInstance模式,那么可以调用该方法
|
||||
public static void removePIPSingleInstanceTask(Context context, String pipActivityName, boolean isInPictureInPictureMode) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
ActivityManager activityManager = (ActivityManager) context.getSystemService(Activity.ACTIVITY_SERVICE);
|
||||
if (activityManager == null)
|
||||
return;
|
||||
List<ActivityManager.AppTask> tasks = activityManager.getAppTasks();
|
||||
if (tasks == null)
|
||||
return;
|
||||
for (ActivityManager.AppTask task : tasks) {
|
||||
ActivityManager.RecentTaskInfo info = task.getTaskInfo();
|
||||
if (info != null && info.baseIntent != null && info.baseIntent.getComponent() != null) {
|
||||
if (pipActivityName.equals(info.baseIntent.getComponent().getClassName())) {
|
||||
if (isInPictureInPictureMode || info.numActivities == 0) {
|
||||
task.finishAndRemoveTask();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer.util;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.view.OrientationEventListener;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
public class PolyvSensorHelper {
|
||||
private OrientationEventListener eventListener;
|
||||
private boolean switchFlag;
|
||||
private boolean isLandscape;
|
||||
|
||||
public PolyvSensorHelper(final Activity activity) {
|
||||
final WeakReference<Activity> wr_activity = new WeakReference<Activity>(activity);
|
||||
eventListener = new OrientationEventListener(activity.getApplicationContext()) {
|
||||
@Override
|
||||
public void onOrientationChanged(int orientation) {
|
||||
Activity activity1 = wr_activity.get();
|
||||
if (activity1 != null) {
|
||||
boolean isPortrait = PolyvScreenUtils.isPortrait(activity1);
|
||||
if ((orientation > -1 && orientation <= 10) || orientation >= 350 || (orientation <= 190 && orientation >= 170)) {
|
||||
if (!isPortrait && switchFlag && !isLandscape)
|
||||
PolyvScreenUtils.setPortrait(activity1);
|
||||
if (isPortrait && !isLandscape)
|
||||
isLandscape = !isLandscape;
|
||||
} else if ((orientation <= 100 && orientation >= 80) || (orientation <= 280 && orientation >= 260)) {
|
||||
if (isPortrait && switchFlag && isLandscape)
|
||||
PolyvScreenUtils.setLandscape(activity1);
|
||||
if (!isPortrait && isLandscape)
|
||||
isLandscape = !isLandscape;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// 开启监听
|
||||
public void enable() {
|
||||
eventListener.enable();
|
||||
}
|
||||
|
||||
// 关闭监听
|
||||
public void disable() {
|
||||
eventListener.disable();
|
||||
}
|
||||
|
||||
/**
|
||||
* 屏幕方向切换之后,是否开启随手势自动切换屏幕方向
|
||||
*
|
||||
* @param switchFlag 是否开启自动切换
|
||||
* @param isLandscape 屏幕切换之后的方向(非自动切换,屏幕方向需要和手动切换之后的方向一致之后,自动切换才会再次生效)
|
||||
*/
|
||||
public void toggle(boolean switchFlag, boolean isLandscape) {
|
||||
this.switchFlag = switchFlag;
|
||||
this.isLandscape = isLandscape;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
|
||||
/**
|
||||
* 存储工具类
|
||||
* @author Lionel 2018-6-12
|
||||
*/
|
||||
public class PolyvStorageUtils {
|
||||
|
||||
private final static String MOUNTED = "mounted";
|
||||
|
||||
/**
|
||||
* 获取可使用的外部存储目录<br/>
|
||||
* 列表中的第一个条目被视为外部主存储,当Android API 大于等于19时,列表中包含了可移除的存储介质(例如 SD 卡)的路径。
|
||||
* 当用户卸载您的应用时,此目录列表中的目录及其内容将被删除。
|
||||
* 详细请看:https://developer.android.com/guide/topics/data/data-storage?hl=zh-cn#filesExternal
|
||||
* @param context
|
||||
* @return 外部存储目录列表
|
||||
*/
|
||||
@NonNull
|
||||
public static ArrayList<File> getExternalFilesDirs(@NonNull Context context) {
|
||||
File[] files;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
//列表中包含了可移除的存储介质(例如 SD 卡)的路径。
|
||||
files = context.getExternalFilesDirs(null);
|
||||
} else {
|
||||
files = ContextCompat.getExternalFilesDirs(context, null);
|
||||
}
|
||||
|
||||
ArrayList<File> storageList = new ArrayList<>();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
//判断存储设备可用性
|
||||
for (File file : files) {
|
||||
if (file != null) {
|
||||
String state = Environment.getExternalStorageState(file);
|
||||
if (MOUNTED.equals(state)) {
|
||||
storageList.add(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
storageList.addAll(Arrays.asList(files));
|
||||
}
|
||||
|
||||
return storageList;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer.util;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* 常用时间工具类
|
||||
*/
|
||||
public class PolyvTimeUtils {
|
||||
private static SimpleDateFormat formatDate = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault());
|
||||
private static SimpleDateFormat formatDateTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
|
||||
|
||||
/**
|
||||
* 解析日期
|
||||
*/
|
||||
private static Date parseDateTime(String datetime) {
|
||||
|
||||
Date mDate = null;
|
||||
try {
|
||||
mDate = formatDateTime.parse(datetime);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return mDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* 以友好的方式显示时间
|
||||
*/
|
||||
public static String friendlyTime(String sdate) {
|
||||
|
||||
Date time = parseDateTime(sdate);
|
||||
if (time == null) {
|
||||
return "Unknown";
|
||||
}
|
||||
String ftime = "";
|
||||
Calendar cal = Calendar.getInstance();
|
||||
|
||||
// 判断是否是同一天
|
||||
String curDate = formatDate.format(cal.getTime());
|
||||
String paramDate = formatDate.format(time);
|
||||
if (curDate.equals(paramDate)) {
|
||||
int hour = (int) ((cal.getTimeInMillis() - time.getTime()) / 3600000);
|
||||
if (hour == 0) {
|
||||
ftime = Math.max(
|
||||
(cal.getTimeInMillis() - time.getTime()) / 60000, 1)
|
||||
+ "分钟前";
|
||||
} else {
|
||||
ftime = hour + "小时前";
|
||||
}
|
||||
return ftime;
|
||||
}
|
||||
|
||||
long lt = time.getTime() / 86400000;
|
||||
long ct = cal.getTimeInMillis() / 86400000;
|
||||
int days = (int) (ct - lt);
|
||||
if (days == 0) {
|
||||
int hour = (int) ((cal.getTimeInMillis() - time.getTime()) / 3600000);
|
||||
if (hour == 0) {
|
||||
ftime = Math.max(
|
||||
(cal.getTimeInMillis() - time.getTime()) / 60000, 1)
|
||||
+ "分钟前";
|
||||
} else {
|
||||
ftime = hour + "小时前";
|
||||
}
|
||||
} else if (days == 1) {
|
||||
ftime = "昨天";
|
||||
} else if (days == 2) {
|
||||
ftime = "前天";
|
||||
} else if (days > 2 && days <= 5) {
|
||||
ftime = days + "天前";
|
||||
} else if (days > 5) {
|
||||
ftime = formatDate.format(time);
|
||||
}
|
||||
return ftime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 以友好的方式显示视频时间
|
||||
*/
|
||||
public static String generateTime(long millisecond) {
|
||||
return generateTime(millisecond, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 以友好的方式显示视频时间
|
||||
*
|
||||
* @param millisecond 毫秒
|
||||
* @param fit 小时是否适配"00"
|
||||
* @return
|
||||
*/
|
||||
public static String generateTime(long millisecond, boolean fit) {
|
||||
int totalSeconds = (int) (millisecond / 1000);
|
||||
|
||||
int seconds = totalSeconds % 60;
|
||||
int minutes = (totalSeconds / 60) % 60;
|
||||
int hours = totalSeconds / 3600;
|
||||
|
||||
if (fit || hours > 0)
|
||||
return String.format(Locale.getDefault(), "%02d:%02d:%02d", hours, minutes, seconds);
|
||||
else
|
||||
return String.format(Locale.getDefault(), "%02d:%02d", minutes, seconds);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,431 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
/**
|
||||
* A simple extension of a regular linear layout that supports the divider API
|
||||
* of Android 4.0+. The dividers are added adjacent to the children by changing
|
||||
* their layout params. If you need to rely on the margins which fall in the
|
||||
* same orientation as the layout you should wrap the child in a simple
|
||||
* {@link android.widget.FrameLayout} so it can receive the margin.
|
||||
*/
|
||||
public class IcsLinearLayout extends LinearLayout {
|
||||
private static final int[] R_styleable_LinearLayout = new int[] {
|
||||
/* 0 */ android.R.attr.divider,
|
||||
/* 1 */ android.R.attr.measureWithLargestChild,
|
||||
/* 2 */ android.R.attr.showDividers,
|
||||
/* 3 */ android.R.attr.dividerPadding,
|
||||
};
|
||||
private static final int LinearLayout_divider = 0;
|
||||
private static final int LinearLayout_measureWithLargestChild = 1;
|
||||
private static final int LinearLayout_showDividers = 2;
|
||||
private static final int LinearLayout_dividerPadding = 3;
|
||||
|
||||
/**
|
||||
* Don't show any dividers.
|
||||
*/
|
||||
public static final int SHOW_DIVIDER_NONE = 0;
|
||||
/**
|
||||
* Show a divider at the beginning of the group.
|
||||
*/
|
||||
public static final int SHOW_DIVIDER_BEGINNING = 1;
|
||||
/**
|
||||
* Show dividers between each item in the group.
|
||||
*/
|
||||
public static final int SHOW_DIVIDER_MIDDLE = 2;
|
||||
/**
|
||||
* Show a divider at the end of the group.
|
||||
*/
|
||||
public static final int SHOW_DIVIDER_END = 4;
|
||||
|
||||
|
||||
private static final boolean IS_HONEYCOMB = Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB;
|
||||
|
||||
|
||||
private Drawable mDivider;
|
||||
protected int mDividerWidth;
|
||||
protected int mDividerHeight;
|
||||
private int mShowDividers;
|
||||
private int mDividerPadding;
|
||||
private boolean mClipDivider;
|
||||
|
||||
private boolean mUseLargestChild;
|
||||
|
||||
public IcsLinearLayout(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
||||
TypedArray a = context.obtainStyledAttributes(attrs, /*com.android.internal.R.styleable.*/R_styleable_LinearLayout);
|
||||
|
||||
setDividerDrawable(a.getDrawable(/*com.android.internal.R.styleable.*/LinearLayout_divider));
|
||||
mShowDividers = a.getInt(/*com.android.internal.R.styleable.*/LinearLayout_showDividers, SHOW_DIVIDER_NONE);
|
||||
mDividerPadding = a.getDimensionPixelSize(/*com.android.internal.R.styleable.*/LinearLayout_dividerPadding, 0);
|
||||
mUseLargestChild = a.getBoolean(/*com.android.internal.R.styleable.*/LinearLayout_measureWithLargestChild, false);
|
||||
|
||||
a.recycle();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set how dividers should be shown between items in this layout
|
||||
*
|
||||
* @param showDividers One or more of {@link #SHOW_DIVIDER_BEGINNING},
|
||||
* {@link #SHOW_DIVIDER_MIDDLE}, or {@link #SHOW_DIVIDER_END},
|
||||
* or {@link #SHOW_DIVIDER_NONE} to show no dividers.
|
||||
*/
|
||||
public void setShowDividers(int showDividers) {
|
||||
if (showDividers != mShowDividers) {
|
||||
requestLayout();
|
||||
invalidate(); //XXX This is required if you are toggling a divider off
|
||||
}
|
||||
mShowDividers = showDividers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A flag set indicating how dividers should be shown around items.
|
||||
* @see #setShowDividers(int)
|
||||
*/
|
||||
public int getShowDividers() {
|
||||
return mShowDividers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a drawable to be used as a divider between items.
|
||||
* @param divider Drawable that will divide each item.
|
||||
* @see #setShowDividers(int)
|
||||
*/
|
||||
public void setDividerDrawable(Drawable divider) {
|
||||
if (divider == mDivider) {
|
||||
return;
|
||||
}
|
||||
mDivider = divider;
|
||||
mClipDivider = divider instanceof ColorDrawable;
|
||||
if (divider != null) {
|
||||
mDividerWidth = divider.getIntrinsicWidth();
|
||||
mDividerHeight = divider.getIntrinsicHeight();
|
||||
} else {
|
||||
mDividerWidth = 0;
|
||||
mDividerHeight = 0;
|
||||
}
|
||||
setWillNotDraw(divider == null);
|
||||
requestLayout();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set padding displayed on both ends of dividers.
|
||||
*
|
||||
* @param padding Padding value in pixels that will be applied to each end
|
||||
*
|
||||
* @see #setShowDividers(int)
|
||||
* @see #setDividerDrawable(Drawable)
|
||||
* @see #getDividerPadding()
|
||||
*/
|
||||
public void setDividerPadding(int padding) {
|
||||
mDividerPadding = padding;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the padding size used to inset dividers in pixels
|
||||
*
|
||||
* @see #setShowDividers(int)
|
||||
* @see #setDividerDrawable(Drawable)
|
||||
* @see #setDividerPadding(int)
|
||||
*/
|
||||
public int getDividerPadding() {
|
||||
return mDividerPadding;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the width of the current divider drawable.
|
||||
*
|
||||
* @hide Used internally by framework.
|
||||
*/
|
||||
public int getDividerWidth() {
|
||||
return mDividerWidth;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void measureChildWithMargins(View child, int parentWidthMeasureSpec, int widthUsed, int parentHeightMeasureSpec, int heightUsed) {
|
||||
final int index = indexOfChild(child);
|
||||
final int orientation = getOrientation();
|
||||
final LayoutParams params = (LayoutParams) child.getLayoutParams();
|
||||
if (hasDividerBeforeChildAt(index)) {
|
||||
if (orientation == VERTICAL) {
|
||||
//Account for the divider by pushing everything up
|
||||
params.topMargin = mDividerHeight;
|
||||
} else {
|
||||
//Account for the divider by pushing everything left
|
||||
params.leftMargin = mDividerWidth;
|
||||
}
|
||||
}
|
||||
|
||||
final int count = getChildCount();
|
||||
if (index == count - 1) {
|
||||
if (hasDividerBeforeChildAt(count)) {
|
||||
if (orientation == VERTICAL) {
|
||||
params.bottomMargin = mDividerHeight;
|
||||
} else {
|
||||
params.rightMargin = mDividerWidth;
|
||||
}
|
||||
}
|
||||
}
|
||||
super.measureChildWithMargins(child, parentWidthMeasureSpec, widthUsed, parentHeightMeasureSpec, heightUsed);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
if (mDivider != null) {
|
||||
if (getOrientation() == VERTICAL) {
|
||||
drawDividersVertical(canvas);
|
||||
} else {
|
||||
drawDividersHorizontal(canvas);
|
||||
}
|
||||
}
|
||||
super.onDraw(canvas);
|
||||
}
|
||||
|
||||
void drawDividersVertical(Canvas canvas) {
|
||||
final int count = getChildCount();
|
||||
for (int i = 0; i < count; i++) {
|
||||
final View child = getChildAt(i);
|
||||
|
||||
if (child != null && child.getVisibility() != GONE) {
|
||||
if (hasDividerBeforeChildAt(i)) {
|
||||
final LayoutParams lp = (LayoutParams) child.getLayoutParams();
|
||||
final int top = child.getTop() - lp.topMargin/* - mDividerHeight*/;
|
||||
drawHorizontalDivider(canvas, top);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (hasDividerBeforeChildAt(count)) {
|
||||
final View child = getChildAt(count - 1);
|
||||
int bottom = 0;
|
||||
if (child == null) {
|
||||
bottom = getHeight() - getPaddingBottom() - mDividerHeight;
|
||||
} else {
|
||||
//final LayoutParams lp = (LayoutParams) child.getLayoutParams();
|
||||
bottom = child.getBottom()/* + lp.bottomMargin*/;
|
||||
}
|
||||
drawHorizontalDivider(canvas, bottom);
|
||||
}
|
||||
}
|
||||
|
||||
void drawDividersHorizontal(Canvas canvas) {
|
||||
final int count = getChildCount();
|
||||
for (int i = 0; i < count; i++) {
|
||||
final View child = getChildAt(i);
|
||||
|
||||
if (child != null && child.getVisibility() != GONE) {
|
||||
if (hasDividerBeforeChildAt(i)) {
|
||||
final LayoutParams lp = (LayoutParams) child.getLayoutParams();
|
||||
final int left = child.getLeft() - lp.leftMargin/* - mDividerWidth*/;
|
||||
drawVerticalDivider(canvas, left);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (hasDividerBeforeChildAt(count)) {
|
||||
final View child = getChildAt(count - 1);
|
||||
int right = 0;
|
||||
if (child == null) {
|
||||
right = getWidth() - getPaddingRight() - mDividerWidth;
|
||||
} else {
|
||||
//final LayoutParams lp = (LayoutParams) child.getLayoutParams();
|
||||
right = child.getRight()/* + lp.rightMargin*/;
|
||||
}
|
||||
drawVerticalDivider(canvas, right);
|
||||
}
|
||||
}
|
||||
|
||||
void drawHorizontalDivider(Canvas canvas, int top) {
|
||||
if(mClipDivider && !IS_HONEYCOMB) {
|
||||
canvas.save();
|
||||
canvas.clipRect(getPaddingLeft() + mDividerPadding, top,
|
||||
getWidth() - getPaddingRight() - mDividerPadding, top + mDividerHeight);
|
||||
mDivider.draw(canvas);
|
||||
canvas.restore();
|
||||
} else {
|
||||
mDivider.setBounds(getPaddingLeft() + mDividerPadding, top,
|
||||
getWidth() - getPaddingRight() - mDividerPadding, top + mDividerHeight);
|
||||
mDivider.draw(canvas);
|
||||
}
|
||||
}
|
||||
|
||||
void drawVerticalDivider(Canvas canvas, int left) {
|
||||
if(mClipDivider && !IS_HONEYCOMB) {
|
||||
canvas.save();
|
||||
canvas.clipRect(left, getPaddingTop() + mDividerPadding,
|
||||
left + mDividerWidth, getHeight() - getPaddingBottom() - mDividerPadding);
|
||||
mDivider.draw(canvas);
|
||||
canvas.restore();
|
||||
} else {
|
||||
mDivider.setBounds(left, getPaddingTop() + mDividerPadding,
|
||||
left + mDividerWidth, getHeight() - getPaddingBottom() - mDividerPadding);
|
||||
mDivider.draw(canvas);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines where to position dividers between children.
|
||||
*
|
||||
* @param childIndex Index of child to check for preceding divider
|
||||
* @return true if there should be a divider before the child at childIndex
|
||||
* @hide Pending API consideration. Currently only used internally by the system.
|
||||
*/
|
||||
protected boolean hasDividerBeforeChildAt(int childIndex) {
|
||||
if (childIndex == 0) {
|
||||
return (mShowDividers & SHOW_DIVIDER_BEGINNING) != 0;
|
||||
} else if (childIndex == getChildCount()) {
|
||||
return (mShowDividers & SHOW_DIVIDER_END) != 0;
|
||||
} else if ((mShowDividers & SHOW_DIVIDER_MIDDLE) != 0) {
|
||||
boolean hasVisibleViewBefore = false;
|
||||
for (int i = childIndex - 1; i >= 0; i--) {
|
||||
if (getChildAt(i).getVisibility() != GONE) {
|
||||
hasVisibleViewBefore = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return hasVisibleViewBefore;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* When true, all children with a weight will be considered having
|
||||
* the minimum size of the largest child. If false, all children are
|
||||
* measured normally.
|
||||
*
|
||||
* @return True to measure children with a weight using the minimum
|
||||
* size of the largest child, false otherwise.
|
||||
*
|
||||
* @attr ref android.R.styleable#LinearLayout_measureWithLargestChild
|
||||
*/
|
||||
public boolean isMeasureWithLargestChildEnabled() {
|
||||
return mUseLargestChild;
|
||||
}
|
||||
|
||||
/**
|
||||
* When set to true, all children with a weight will be considered having
|
||||
* the minimum size of the largest child. If false, all children are
|
||||
* measured normally.
|
||||
*
|
||||
* Disabled by default.
|
||||
*
|
||||
* @param enabled True to measure children with a weight using the
|
||||
* minimum size of the largest child, false otherwise.
|
||||
*
|
||||
* @attr ref android.R.styleable#LinearLayout_measureWithLargestChild
|
||||
*/
|
||||
public void setMeasureWithLargestChildEnabled(boolean enabled) {
|
||||
mUseLargestChild = enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
|
||||
if (mUseLargestChild) {
|
||||
final int orientation = getOrientation();
|
||||
switch (orientation) {
|
||||
case HORIZONTAL:
|
||||
useLargestChildHorizontal();
|
||||
break;
|
||||
|
||||
case VERTICAL:
|
||||
useLargestChildVertical();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void useLargestChildHorizontal() {
|
||||
final int childCount = getChildCount();
|
||||
|
||||
// Find largest child width
|
||||
int largestChildWidth = 0;
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
final View child = getChildAt(i);
|
||||
largestChildWidth = Math.max(child.getMeasuredWidth(), largestChildWidth);
|
||||
}
|
||||
|
||||
int totalWidth = 0;
|
||||
// Re-measure childs
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
final View child = getChildAt(i);
|
||||
|
||||
if (child == null || child.getVisibility() == View.GONE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final LayoutParams lp =
|
||||
(LayoutParams) child.getLayoutParams();
|
||||
|
||||
float childExtra = lp.weight;
|
||||
if (childExtra > 0) {
|
||||
child.measure(
|
||||
MeasureSpec.makeMeasureSpec(largestChildWidth,
|
||||
MeasureSpec.EXACTLY),
|
||||
MeasureSpec.makeMeasureSpec(child.getMeasuredHeight(),
|
||||
MeasureSpec.EXACTLY));
|
||||
totalWidth += largestChildWidth;
|
||||
|
||||
} else {
|
||||
totalWidth += child.getMeasuredWidth();
|
||||
}
|
||||
|
||||
totalWidth += lp.leftMargin + lp.rightMargin;
|
||||
}
|
||||
|
||||
totalWidth += getPaddingLeft() + getPaddingRight();
|
||||
setMeasuredDimension(totalWidth, getMeasuredHeight());
|
||||
}
|
||||
|
||||
private void useLargestChildVertical() {
|
||||
final int childCount = getChildCount();
|
||||
|
||||
// Find largest child width
|
||||
int largestChildHeight = 0;
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
final View child = getChildAt(i);
|
||||
largestChildHeight = Math.max(child.getMeasuredHeight(), largestChildHeight);
|
||||
}
|
||||
|
||||
int totalHeight = 0;
|
||||
// Re-measure childs
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
final View child = getChildAt(i);
|
||||
|
||||
if (child == null || child.getVisibility() == View.GONE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final LayoutParams lp =
|
||||
(LayoutParams) child.getLayoutParams();
|
||||
|
||||
float childExtra = lp.weight;
|
||||
if (childExtra > 0) {
|
||||
child.measure(
|
||||
MeasureSpec.makeMeasureSpec(child.getMeasuredWidth(),
|
||||
MeasureSpec.EXACTLY),
|
||||
MeasureSpec.makeMeasureSpec(largestChildHeight,
|
||||
MeasureSpec.EXACTLY));
|
||||
totalHeight += largestChildHeight;
|
||||
|
||||
} else {
|
||||
totalHeight += child.getMeasuredHeight();
|
||||
}
|
||||
|
||||
totalHeight += lp.leftMargin + lp.rightMargin;
|
||||
}
|
||||
|
||||
totalHeight += getPaddingLeft() + getPaddingRight();
|
||||
setMeasuredDimension(getMeasuredWidth(), totalHeight);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,356 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.database.DataSetObserver;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.SoundEffectConstants;
|
||||
import android.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ListAdapter;
|
||||
|
||||
import cn.shangyu.gdxzExpert.R;
|
||||
|
||||
|
||||
/**
|
||||
* An extension of a linear layout that supports the divider API of Android
|
||||
* 4.0+. You can populate this layout with data that comes from a
|
||||
* {@link ListAdapter}
|
||||
*/
|
||||
public class LinearListView extends IcsLinearLayout {
|
||||
|
||||
private static final int[] R_styleable_LinearListView = new int[] {
|
||||
/* 0 */android.R.attr.entries,
|
||||
/* 1 */R.attr.dividerThickness
|
||||
};
|
||||
|
||||
private static final int LinearListView_entries = 0;
|
||||
private static final int LinearListView_dividerThickness = 1;
|
||||
|
||||
private View mEmptyView;
|
||||
private ListAdapter mAdapter;
|
||||
private boolean mAreAllItemsSelectable;
|
||||
private OnItemClickListener mOnItemClickListener;
|
||||
private OnItemLongClickListener mOnItemLongClickListener;
|
||||
private DataSetObserver mDataObserver = new DataSetObserver() {
|
||||
|
||||
@Override
|
||||
public void onChanged() {
|
||||
setupChildren();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInvalidated() {
|
||||
setupChildren();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
public LinearListView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public LinearListView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
||||
TypedArray a = context.obtainStyledAttributes(attrs,
|
||||
R_styleable_LinearListView);
|
||||
|
||||
// Use the thickness specified, zero being the default
|
||||
final int thickness = a.getDimensionPixelSize(
|
||||
LinearListView_dividerThickness, 0);
|
||||
if (thickness != 0) {
|
||||
setDividerThickness(thickness);
|
||||
}
|
||||
|
||||
CharSequence[] entries = a.getTextArray(LinearListView_entries);
|
||||
if (entries != null) {
|
||||
setAdapter(new ArrayAdapter<CharSequence>(context,
|
||||
android.R.layout.simple_list_item_1, entries));
|
||||
}
|
||||
|
||||
a.recycle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOrientation(int orientation) {
|
||||
if (orientation != getOrientation()) {
|
||||
int tmp = mDividerHeight;
|
||||
mDividerHeight = mDividerWidth;
|
||||
mDividerWidth = tmp;
|
||||
}
|
||||
super.setOrientation(orientation);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the divider thickness size in pixel. That means setting the divider
|
||||
* height if the layout has an HORIZONTAL orientation and setting the
|
||||
* divider width otherwise.
|
||||
*
|
||||
* @param thickness
|
||||
* The divider thickness in pixel.
|
||||
*/
|
||||
public void setDividerThickness(int thickness) {
|
||||
if (getOrientation() == VERTICAL) {
|
||||
mDividerHeight = thickness;
|
||||
} else {
|
||||
mDividerWidth = thickness;
|
||||
}
|
||||
requestLayout();
|
||||
}
|
||||
|
||||
public ListAdapter getAdapter() {
|
||||
return mAdapter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the data behind this LinearListView.
|
||||
*
|
||||
* @param adapter
|
||||
* The ListAdapter which is responsible for maintaining the data
|
||||
* backing this list and for producing a view to represent an
|
||||
* item in that data set.
|
||||
*
|
||||
* @see #getAdapter()
|
||||
*/
|
||||
public void setAdapter(ListAdapter adapter) {
|
||||
if (mAdapter != null) {
|
||||
mAdapter.unregisterDataSetObserver(mDataObserver);
|
||||
}
|
||||
|
||||
mAdapter = adapter;
|
||||
|
||||
if (mAdapter != null) {
|
||||
mAdapter.registerDataSetObserver(mDataObserver);
|
||||
mAreAllItemsSelectable = mAdapter.areAllItemsEnabled();
|
||||
}
|
||||
|
||||
setupChildren();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface definition for a callback to be invoked when an item in this
|
||||
* LinearListView has been clicked.
|
||||
*/
|
||||
public interface OnItemClickListener {
|
||||
|
||||
/**
|
||||
* Callback method to be invoked when an item in this LinearListView has
|
||||
* been clicked.
|
||||
* <p>
|
||||
* Implementers can call getItemAtPosition(position) if they need to
|
||||
* access the data associated with the selected item.
|
||||
*
|
||||
* @param parent
|
||||
* The LinearListView where the click happened.
|
||||
* @param view
|
||||
* The view within the LinearListView that was clicked (this
|
||||
* will be a view provided by the adapter)
|
||||
* @param position
|
||||
* The position of the view in the adapter.
|
||||
* @param id
|
||||
* The row id of the item that was clicked.
|
||||
*/
|
||||
void onItemClick(LinearListView parent, View view, int position, long id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a callback to be invoked when an item in this LinearListView has
|
||||
* been clicked.
|
||||
*
|
||||
* @param listener
|
||||
* The callback that will be invoked.
|
||||
*/
|
||||
public void setOnItemClickListener(OnItemClickListener listener) {
|
||||
mOnItemClickListener = listener;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The callback to be invoked with an item in this LinearListView has
|
||||
* been clicked, or null id no callback has been set.
|
||||
*/
|
||||
public final OnItemClickListener getOnItemClickListener() {
|
||||
return mOnItemClickListener;
|
||||
}
|
||||
|
||||
/**
|
||||
* Call the OnItemClickListener, if it is defined.
|
||||
*
|
||||
* @param view
|
||||
* The view within the LinearListView that was clicked.
|
||||
* @param position
|
||||
* The position of the view in the adapter.
|
||||
* @param id
|
||||
* The row id of the item that was clicked.
|
||||
* @return True if there was an assigned OnItemClickListener that was
|
||||
* called, false otherwise is returned.
|
||||
*/
|
||||
public boolean performItemClick(View view, int position, long id) {
|
||||
if (mOnItemClickListener != null) {
|
||||
playSoundEffect(SoundEffectConstants.CLICK);
|
||||
mOnItemClickListener.onItemClick(this, view, position, id);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the view to show if the adapter is empty
|
||||
*/
|
||||
public void setEmptyView(View emptyView) {
|
||||
mEmptyView = emptyView;
|
||||
|
||||
final ListAdapter adapter = getAdapter();
|
||||
final boolean empty = ((adapter == null) || adapter.isEmpty());
|
||||
updateEmptyStatus(empty);
|
||||
}
|
||||
|
||||
/**
|
||||
* When the current adapter is empty, the LinearListView can display a special
|
||||
* view call the empty view. The empty view is used to provide feedback to
|
||||
* the user that no data is available in this LinearListView.
|
||||
*
|
||||
* @return The view to show if the adapter is empty.
|
||||
*/
|
||||
public View getEmptyView() {
|
||||
return mEmptyView;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the status of the list based on the empty parameter. If empty is
|
||||
* true and we have an empty view, display it. In all the other cases, make
|
||||
* sure that the layout is VISIBLE and that the empty view is GONE (if
|
||||
* it's not null).
|
||||
*/
|
||||
private void updateEmptyStatus(boolean empty) {
|
||||
if (empty) {
|
||||
if (mEmptyView != null) {
|
||||
mEmptyView.setVisibility(View.VISIBLE);
|
||||
setVisibility(View.GONE);
|
||||
} else {
|
||||
// If the caller just removed our empty view, make sure the list
|
||||
// view is visible
|
||||
setVisibility(View.VISIBLE);
|
||||
}
|
||||
} else {
|
||||
if (mEmptyView != null)
|
||||
mEmptyView.setVisibility(View.GONE);
|
||||
setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
private void setupChildren() {
|
||||
|
||||
removeAllViews();
|
||||
|
||||
updateEmptyStatus((mAdapter == null) || mAdapter.isEmpty());
|
||||
|
||||
if (mAdapter == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < mAdapter.getCount(); i++) {
|
||||
// adapter 要使用inflate(layoutId, parent, false);
|
||||
View child = mAdapter.getView(i, null, this);
|
||||
if (mAreAllItemsSelectable || mAdapter.isEnabled(i)) {
|
||||
child.setOnClickListener(new InternalOnClickListener(i));
|
||||
child.setOnLongClickListener(new InternalOnLongClickListener(i));
|
||||
}
|
||||
addViewInLayout(child, -1, child.getLayoutParams(), true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal OnClickListener that this view associate of each of its children
|
||||
* so that they can respond to OnItemClick listener's events. Avoid setting
|
||||
* an OnClickListener manually. If you need it you can wrap the child in a
|
||||
* simple {@link android.widget.FrameLayout}.
|
||||
*/
|
||||
private class InternalOnClickListener implements OnClickListener {
|
||||
|
||||
int mPosition;
|
||||
|
||||
public InternalOnClickListener(int position) {
|
||||
mPosition = position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if ((mOnItemClickListener != null) && (mAdapter != null)) {
|
||||
mOnItemClickListener.onItemClick(LinearListView.this, v,
|
||||
mPosition, mAdapter.getItemId(mPosition));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal OnClickListener that this view associate of each of its children
|
||||
* so that they can respond to OnItemClick listener's events. Avoid setting
|
||||
* an OnClickListener manually. If you need it you can wrap the child in a
|
||||
* simple {@link android.widget.FrameLayout}.
|
||||
*/
|
||||
private class InternalOnLongClickListener implements OnLongClickListener {
|
||||
|
||||
int mPosition;
|
||||
|
||||
public InternalOnLongClickListener(int position) {
|
||||
mPosition = position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
if ((mOnItemLongClickListener != null) && (mAdapter != null)) {
|
||||
return mOnItemLongClickListener.onItemLongClick(LinearListView.this, v,
|
||||
mPosition, mAdapter.getItemId(mPosition));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface definition for a callback to be invoked when an item in this
|
||||
* LinearListView has been clicked.
|
||||
*/
|
||||
public interface OnItemLongClickListener {
|
||||
|
||||
/**
|
||||
* Callback method to be invoked when an item in this LinearListView has
|
||||
* been clicked.
|
||||
* <p>
|
||||
* Implementers can call getItemAtPosition(position) if they need to
|
||||
* access the data associated with the selected item.
|
||||
*
|
||||
* @param parent
|
||||
* The LinearListView where the click happened.
|
||||
* @param view
|
||||
* The view within the LinearListView that was clicked (this
|
||||
* will be a view provided by the adapter)
|
||||
* @param position
|
||||
* The position of the view in the adapter.
|
||||
* @param id
|
||||
* The row id of the item that was clicked.
|
||||
*/
|
||||
boolean onItemLongClick(LinearListView parent, View view, int position, long id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a callback to be invoked when an item in this LinearListView has
|
||||
* been clicked.
|
||||
*
|
||||
* @param listener
|
||||
* The callback that will be invoked.
|
||||
*/
|
||||
public void setOnItemLongClickListener(OnItemLongClickListener listener) {
|
||||
mOnItemLongClickListener = listener;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The callback to be invoked with an item in this LinearListView has
|
||||
* been clicked, or null id no callback has been set.
|
||||
*/
|
||||
public final OnItemLongClickListener getOnItemLongClickListener() {
|
||||
return mOnItemLongClickListener;
|
||||
}
|
||||
}
|
||||
+156
@@ -0,0 +1,156 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.RectF;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import cn.shangyu.gdxzExpert.R;
|
||||
|
||||
|
||||
/**
|
||||
* Created by zhuyong on 2017/6/22.
|
||||
*/
|
||||
|
||||
public class PolyvCircleProgressView extends View {
|
||||
|
||||
private int mCurrent;//当前进度
|
||||
private Paint mPaintOut;
|
||||
private Paint mPaintCurrent;
|
||||
private Paint mPaintText;
|
||||
private float mPaintWidth;//画笔宽度
|
||||
private int mPaintColor = Color.RED;//画笔颜色
|
||||
private int mTextColor = Color.BLACK;//字体颜色
|
||||
private float mTextSize;//字体大小
|
||||
private int location;//从哪个位置开始
|
||||
private float startAngle;//开始角度
|
||||
|
||||
private OnLoadingCompleteListener mLoadingCompleteListener;
|
||||
|
||||
public PolyvCircleProgressView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public PolyvCircleProgressView(Context context, @Nullable AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
|
||||
public PolyvCircleProgressView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
//获取属性值
|
||||
TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.CircleProgressView);
|
||||
location = array.getInt(R.styleable.CircleProgressView_location, 1);
|
||||
mPaintWidth = array.getDimension(R.styleable.CircleProgressView_progress_paint_width, dip2px(context, 4));//默认4dp
|
||||
mPaintColor = array.getColor(R.styleable.CircleProgressView_progress_paint_color, mPaintColor);
|
||||
mTextSize = array.getDimension(R.styleable.CircleProgressView_progress_text_size, dip2px(context, 18));//默认18sp
|
||||
mTextColor = array.getColor(R.styleable.CircleProgressView_progress_text_color, mTextColor);
|
||||
array.recycle();
|
||||
|
||||
//画笔->背景圆弧
|
||||
mPaintOut = new Paint();
|
||||
mPaintOut.setAntiAlias(true);
|
||||
mPaintOut.setStrokeWidth(mPaintWidth);
|
||||
mPaintOut.setStyle(Paint.Style.STROKE);
|
||||
mPaintOut.setColor(Color.parseColor("#1F1F1F"));
|
||||
mPaintOut.setStrokeCap(Paint.Cap.ROUND);
|
||||
//画笔->进度圆弧
|
||||
mPaintCurrent = new Paint();
|
||||
mPaintCurrent.setAntiAlias(true);
|
||||
mPaintCurrent.setStrokeWidth(mPaintWidth);
|
||||
mPaintCurrent.setStyle(Paint.Style.STROKE);
|
||||
mPaintCurrent.setColor(mPaintColor);
|
||||
// mPaintCurrent.setStrokeCap(Paint.Cap.ROUND);
|
||||
//画笔->绘制字体
|
||||
mPaintText = new Paint();
|
||||
mPaintText.setAntiAlias(true);
|
||||
mPaintText.setStyle(Paint.Style.FILL);
|
||||
mPaintText.setColor(mTextColor);
|
||||
mPaintText.setTextSize(mTextSize);
|
||||
|
||||
if (location == 1) {//默认从左侧开始
|
||||
startAngle = -180;
|
||||
} else if (location == 2) {
|
||||
startAngle = -90;
|
||||
} else if (location == 3) {
|
||||
startAngle = 0;
|
||||
} else if (location == 4) {
|
||||
startAngle = 90;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
int width = MeasureSpec.getSize(widthMeasureSpec);
|
||||
int height = MeasureSpec.getSize(heightMeasureSpec);
|
||||
int size = width > height ? height : width;
|
||||
setMeasuredDimension(size, size);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
super.onDraw(canvas);
|
||||
//绘制背景圆弧,因为画笔有一定的宽度,所有画圆弧的范围要比View本身的大小稍微小一些,不然画笔画出来的东西会显示不完整
|
||||
RectF rectF = new RectF(mPaintWidth / 2, mPaintWidth / 2, getWidth() - mPaintWidth / 2, getHeight() - mPaintWidth / 2);
|
||||
canvas.drawArc(rectF, 0, 360, false, mPaintOut);
|
||||
|
||||
//绘制当前进度
|
||||
float sweepAngle = 360 * mCurrent / 100;
|
||||
canvas.drawArc(rectF, startAngle, sweepAngle, false, mPaintCurrent);
|
||||
|
||||
// //绘制进度数字
|
||||
// String text = mCurrent + "%";
|
||||
// //获取文字宽度
|
||||
// float textWidth = mPaintText.measureText(text, 0, text.length());
|
||||
// float dx = getWidth() / 2 - textWidth / 2;
|
||||
// Paint.FontMetricsInt fontMetricsInt = mPaintText.getFontMetricsInt();
|
||||
// float dy = (fontMetricsInt.bottom - fontMetricsInt.top) / 2 - fontMetricsInt.bottom;
|
||||
// float baseLine = getHeight() / 2 + dy;
|
||||
// canvas.drawText(text, dx, baseLine, mPaintText);
|
||||
|
||||
if (mLoadingCompleteListener != null && mCurrent == 100) {
|
||||
mLoadingCompleteListener.complete();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前进度值
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getmCurrent() {
|
||||
return mCurrent;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置当前进度并重新绘制界面
|
||||
*
|
||||
* @param mCurrent
|
||||
*/
|
||||
public void setmCurrent(int mCurrent) {
|
||||
this.mCurrent = mCurrent;
|
||||
invalidate();
|
||||
}
|
||||
|
||||
public void setOnLoadingCompleteListener(OnLoadingCompleteListener loadingCompleteListener) {
|
||||
this.mLoadingCompleteListener = loadingCompleteListener;
|
||||
}
|
||||
|
||||
public interface OnLoadingCompleteListener {
|
||||
void complete();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据手机的分辨率从 dp 的单位 转成为 px(像素)
|
||||
*/
|
||||
public static int dip2px(Context context, float dpValue) {
|
||||
final float scale = context.getResources().getDisplayMetrics().density;
|
||||
return (int) (dpValue * scale + 0.5f);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer.view;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import cn.shangyu.gdxzExpert.R;
|
||||
|
||||
|
||||
@SuppressLint("AppCompatCustomView")
|
||||
public class PolyvGrayImageView extends ImageView {
|
||||
|
||||
public PolyvGrayImageView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
public PolyvGrayImageView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public PolyvGrayImageView(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
super.onDraw(canvas);
|
||||
if (isPressed())
|
||||
// canvas.drawColor(0x33000000);
|
||||
canvas.drawColor(getResources().getColor(R.color.commom_click_color_gray_half));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dispatchSetPressed(boolean pressed) {
|
||||
super.dispatchSetPressed(pressed);
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.easefun.polyvsdk.video.PolyvVideoView;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import cn.shangyu.gdxzExpert.R;
|
||||
import cn.shangyu.gdxzExpert.polyvplayer.util.PolyvScreenUtils;
|
||||
|
||||
public class PolyvLoadingLayout extends FrameLayout {
|
||||
private ProgressBar loadingProgress;
|
||||
private TextView loadingSpeed;
|
||||
|
||||
private PolyvVideoView videoView;
|
||||
|
||||
private Handler handler = new Handler(Looper.getMainLooper()) {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
if (msg.what == 1) {
|
||||
if (videoView != null && !videoView.isLocalPlay()) {
|
||||
loadingSpeed.setVisibility(View.VISIBLE);
|
||||
loadingSpeed.setText(formatedSpeed(videoView.getTcpSpeed(), 1000));
|
||||
|
||||
handler.sendEmptyMessageDelayed(1, 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private static String formatedSpeed(long bytes, long elapsed_milli) {
|
||||
if (elapsed_milli <= 0) {
|
||||
return "0 B/S";
|
||||
}
|
||||
|
||||
if (bytes <= 0) {
|
||||
return "0 B/S";
|
||||
}
|
||||
|
||||
float bytes_per_sec = ((float) bytes) * 1000.f / elapsed_milli;
|
||||
if (bytes_per_sec >= 1000 * 1000) {
|
||||
return String.format(Locale.US, "%.2f MB/S", ((float) bytes_per_sec) / 1000 / 1000);
|
||||
} else if (bytes_per_sec >= 1000) {
|
||||
return String.format(Locale.US, "%.2f KB/S", ((float) bytes_per_sec) / 1000);
|
||||
} else {
|
||||
return String.format(Locale.US, "%d B/S", (long) bytes_per_sec);
|
||||
}
|
||||
}
|
||||
|
||||
public PolyvLoadingLayout(@NonNull Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public PolyvLoadingLayout(@NonNull Context context, @Nullable AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
|
||||
public PolyvLoadingLayout(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
LayoutInflater.from(context).inflate(R.layout.polyv_player_loading_layout, this);
|
||||
initView();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
loadingProgress = (ProgressBar) findViewById(R.id.loading_progress);
|
||||
loadingSpeed = (TextView) findViewById(R.id.loading_speed);
|
||||
}
|
||||
|
||||
public void bindVideoView(PolyvVideoView videoView) {
|
||||
this.videoView = videoView;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
handler.removeCallbacksAndMessages(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
acceptVisibilityChange(getVisibility());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVisibility(int visibility) {
|
||||
super.setVisibility(visibility);
|
||||
acceptVisibilityChange(visibility);
|
||||
}
|
||||
|
||||
private void acceptVisibilityChange(int visibility) {
|
||||
handler.removeCallbacksAndMessages(null);
|
||||
if (visibility == View.VISIBLE) {
|
||||
handler.sendEmptyMessage(1);
|
||||
} else {
|
||||
loadingSpeed.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
public void fitLocationChange(boolean isInMainScreen) {
|
||||
if (loadingProgress == null)
|
||||
return;
|
||||
MarginLayoutParams rlp = (MarginLayoutParams) loadingProgress.getLayoutParams();
|
||||
if (isInMainScreen) {
|
||||
rlp.width = MarginLayoutParams.WRAP_CONTENT;
|
||||
rlp.height = MarginLayoutParams.WRAP_CONTENT;
|
||||
} else {
|
||||
rlp.width = PolyvScreenUtils.dip2px(getContext(), 32);
|
||||
rlp.height = PolyvScreenUtils.dip2px(getContext(), 32);
|
||||
}
|
||||
loadingProgress.setLayoutParams(rlp);
|
||||
}
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.AbsListView;
|
||||
|
||||
public class PolyvSimpleSwipeRefreshLayout extends SwipeRefreshLayout {
|
||||
// 包含的View
|
||||
private View view;
|
||||
|
||||
public PolyvSimpleSwipeRefreshLayout(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public PolyvSimpleSwipeRefreshLayout(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public void setChildView(View view) {
|
||||
this.view = view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canChildScrollUp() {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
|
||||
if (view instanceof AbsListView) {
|
||||
final AbsListView absListView = (AbsListView) view;
|
||||
return absListView.getChildCount() > 0 && (absListView.getFirstVisiblePosition() > 0
|
||||
|| absListView.getChildAt(0).getTop() < absListView.getPaddingTop());
|
||||
} else {
|
||||
return view.getScrollY() > 0;
|
||||
}
|
||||
} else {
|
||||
return ViewCompat.canScrollVertically(view, -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,283 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import androidx.appcompat.widget.AppCompatSeekBar;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import cn.shangyu.gdxzExpert.polyvplayer.util.PolyvScreenUtils;
|
||||
|
||||
|
||||
public class PolyvTickSeekBar extends AppCompatSeekBar {
|
||||
private int height, width;
|
||||
//画笔
|
||||
private Paint mStockPaint;
|
||||
private List<TickData> mTickDataList;
|
||||
private boolean isMoved;
|
||||
private int moveCount;
|
||||
private float fingerRadius;//触摸点的px范围的点视为点中打点
|
||||
|
||||
public PolyvTickSeekBar(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public PolyvTickSeekBar(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
|
||||
public PolyvTickSeekBar(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
initStrokePaint();
|
||||
|
||||
fingerRadius = PolyvScreenUtils.dip2px(getContext(), 16);
|
||||
}
|
||||
|
||||
//初始化画笔
|
||||
private void initStrokePaint() {
|
||||
mStockPaint = new Paint();
|
||||
mStockPaint.setStyle(Paint.Style.FILL_AND_STROKE);
|
||||
mStockPaint.setAntiAlias(true);
|
||||
}
|
||||
|
||||
private void initSeekBarInfo() {
|
||||
height = getHeight();
|
||||
width = getWidth();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
super.onDraw(canvas);
|
||||
initSeekBarInfo();
|
||||
drawTicks(canvas);
|
||||
}
|
||||
|
||||
private void drawTicks(Canvas canvas) {
|
||||
if (mTickDataList == null || mTickDataList.size() == 0) {
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < mTickDataList.size(); i++) {
|
||||
TickData tickData = mTickDataList.get(i);
|
||||
if (tickData.progress > getMax() || tickData.progress < 0)
|
||||
continue;
|
||||
mStockPaint.setColor(tickData.color);
|
||||
int thumbHeight = height - getPaddingTop() - getPaddingBottom();//thumb的高度
|
||||
float cy = thumbHeight / 2.0f + getPaddingTop() - getPaddingBottom();//打点的圆心y轴位置
|
||||
float percent = tickData.progress / (getMax() * 1.0f);
|
||||
float cx = (width - getPaddingLeft() - getPaddingRight()) * percent;//打点的圆心x轴位置
|
||||
cx += getPaddingLeft();
|
||||
float radius = thumbHeight / 3.6f;//打点的半径
|
||||
//圆心在端点上
|
||||
// if (cx < getPaddingLeft())
|
||||
// cx = getPaddingLeft();
|
||||
// else if (cx > width - getPaddingRight())
|
||||
// cx = width - getPaddingRight();
|
||||
//圆心在端点内
|
||||
if (cx < getPaddingLeft() + radius)
|
||||
cx = getPaddingLeft() + radius;
|
||||
else if (cx > width - getPaddingRight() - radius)
|
||||
cx = width - getPaddingRight() - radius;
|
||||
//调整两端的位置
|
||||
if (cx + getPaddingLeft() < radius)
|
||||
cx = radius - getPaddingLeft();
|
||||
else if (width - cx + getPaddingRight() < radius)
|
||||
cx = cx - (radius - (width - cx) - getPaddingRight());
|
||||
tickData.cx = cx;//设置打点的圆心位置
|
||||
canvas.drawCircle(cx, cy, radius, mStockPaint);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
boolean hasTick = mTickDataList != null && mTickDataList.size() > 0;
|
||||
switch (event.getActionMasked()) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
isMoved = false;
|
||||
moveCount = 0;
|
||||
return hasTick || super.onTouchEvent(event);
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
if (++moveCount >= 7) {
|
||||
isMoved = true;
|
||||
} else {
|
||||
return hasTick || super.onTouchEvent(event);
|
||||
}
|
||||
break;
|
||||
case MotionEvent.ACTION_UP:
|
||||
case MotionEvent.ACTION_CANCEL:
|
||||
if (!isMoved) {
|
||||
float ex = event.getX();
|
||||
//查找点击的附近是否有打点
|
||||
int fitPosition;
|
||||
if (hasTick && (fitPosition = halfSearch(mTickDataList, 0, mTickDataList.size() - 1, ex, fingerRadius)) != -1) {
|
||||
if (onTickClickListener != null) {
|
||||
onTickClickListener.onTickClick(mTickDataList.get(fitPosition));
|
||||
}
|
||||
} else {
|
||||
if (onTickClickListener != null) {
|
||||
boolean result = onTickClickListener.onSeekBarClick();
|
||||
return hasTick ? (result ? super.onTouchEvent(event) : !result) : super.onTouchEvent(event);
|
||||
}
|
||||
}
|
||||
return hasTick || super.onTouchEvent(event);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return super.onTouchEvent(event);
|
||||
}
|
||||
|
||||
private int findCloserPoint(List<TickData> tickDataList, int position, float ex, boolean isFirst, float fingerRadius) {
|
||||
if (position < 0 || position > tickDataList.size() - 1) {
|
||||
return -1;
|
||||
}
|
||||
float cxExDistance = Math.abs(tickDataList.get(position).cx - ex);
|
||||
if (cxExDistance <= fingerRadius) {//满足条件,继续查找是否有离触摸点更近的打点
|
||||
int preMiddle = position - 1;
|
||||
int sufMiddle = position + 1;
|
||||
int fitPosition = position;
|
||||
if (preMiddle >= 0) {
|
||||
float preCxExDistance = Math.abs(tickDataList.get(preMiddle).cx - ex);
|
||||
if (preCxExDistance < cxExDistance) {
|
||||
cxExDistance = preCxExDistance;
|
||||
fitPosition = preMiddle;
|
||||
}
|
||||
}
|
||||
if (sufMiddle <= tickDataList.size() - 1) {
|
||||
float sufCxExDistance = Math.abs(tickDataList.get(sufMiddle).cx - ex);
|
||||
if (sufCxExDistance <= cxExDistance) {//相同位置的两点,取后续的
|
||||
fitPosition = sufMiddle;
|
||||
}
|
||||
}
|
||||
if (fitPosition != position) {
|
||||
return findCloserPoint(tickDataList, fitPosition, ex, false, fingerRadius);
|
||||
}
|
||||
} else if (isFirst) {//第一次查找不满足条件时返回-1
|
||||
return -1;
|
||||
}
|
||||
return position;
|
||||
}
|
||||
|
||||
private int halfSearch(List<TickData> tickDataList, int startPosition, int endPosition, float ex, float fingerRadius) {
|
||||
if (tickDataList == null || tickDataList.size() == 0) {
|
||||
return -1;
|
||||
}
|
||||
int length = tickDataList.size();
|
||||
if (length < startPosition || length < endPosition || startPosition > endPosition)
|
||||
return -1;
|
||||
while (startPosition <= endPosition) {
|
||||
int middle = startPosition + ((endPosition - startPosition) >> 1);//偶数middle取前面的
|
||||
float cx = tickDataList.get(middle).cx;
|
||||
int fitPosition;
|
||||
if ((fitPosition = findCloserPoint(tickDataList, middle, ex, true, fingerRadius)) != -1) {
|
||||
return fitPosition;
|
||||
} else if (ex - cx > 0) {//中间点在触摸点的前面
|
||||
startPosition = middle + 1;
|
||||
} else {//中间点在触摸点的后面
|
||||
endPosition = middle - 1;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
//设置时间点
|
||||
public void setTicks(List<TickData> tickDataList) {
|
||||
this.mTickDataList = tickDataList;
|
||||
Collections.sort(this.mTickDataList, new Comparator<TickData>() {
|
||||
@Override
|
||||
public int compare(TickData lhs, TickData rhs) {
|
||||
return (int) (lhs.progress - rhs.progress);//自然排序
|
||||
}
|
||||
});
|
||||
invalidate();
|
||||
}
|
||||
|
||||
public interface OnTickClickListener {
|
||||
void onTickClick(TickData tickData);
|
||||
|
||||
/**
|
||||
* @return 有打点数据时,点击非打点处抬起(中途没有移动),是否会触发onProgressChanged
|
||||
*/
|
||||
boolean onSeekBarClick();
|
||||
}
|
||||
|
||||
private OnTickClickListener onTickClickListener;
|
||||
|
||||
public void setOnTickClickListener(OnTickClickListener l) {
|
||||
this.onTickClickListener = l;
|
||||
}
|
||||
|
||||
public static class TickData {
|
||||
private int keyTime;
|
||||
private float progress;
|
||||
private int color;
|
||||
private Object tag;
|
||||
//位置
|
||||
private float cx;
|
||||
|
||||
public TickData(float progress, int color, Object tag) {
|
||||
this((int) progress, progress, color, tag);
|
||||
}
|
||||
|
||||
public TickData(int keyTime, float progress, int color, Object tag) {
|
||||
this.keyTime = keyTime;
|
||||
this.progress = progress;
|
||||
this.color = color;
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
public int getKeyTime() {
|
||||
return keyTime;
|
||||
}
|
||||
|
||||
public void setKeyTime(int keyTime) {
|
||||
this.keyTime = keyTime;
|
||||
}
|
||||
|
||||
public float getProgress() {
|
||||
return progress;
|
||||
}
|
||||
|
||||
public void setProgress(float progress) {
|
||||
this.progress = progress;
|
||||
}
|
||||
|
||||
public int getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public void setColor(int color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public Object getTag() {
|
||||
return tag;
|
||||
}
|
||||
|
||||
public void setTag(Object tag) {
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
public float getCx() {
|
||||
return cx;
|
||||
}
|
||||
|
||||
public void setCx(float cx) {
|
||||
this.cx = cx;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TickData{" +
|
||||
"keyTime=" + keyTime +
|
||||
", progress=" + progress +
|
||||
", color=" + color +
|
||||
", tag=" + tag +
|
||||
", cx=" + cx +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
package cn.shangyu.gdxzExpert.polyvplayer.view;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.easefun.polyvsdk.vo.PolyvVideoVO;
|
||||
|
||||
import cn.shangyu.gdxzExpert.R;
|
||||
|
||||
|
||||
public class PolyvTickTips extends FrameLayout {
|
||||
private View view;
|
||||
private TextView tv_time, tv_context;
|
||||
private ImageView iv_seek;
|
||||
private Runnable runnable;
|
||||
private PolyvTickSeekBar.TickData tickData;
|
||||
|
||||
public PolyvTickTips(@NonNull Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public PolyvTickTips(@NonNull Context context, @Nullable AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
|
||||
public PolyvTickTips(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
view = LayoutInflater.from(context).inflate(R.layout.polyv_tick_tips, this);
|
||||
initView();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
removeCallbacks(runnable);
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
tv_time = (TextView) view.findViewById(R.id.tv_time);
|
||||
tv_context = (TextView) view.findViewById(R.id.tv_context);
|
||||
iv_seek = (ImageView) view.findViewById(R.id.iv_seek);
|
||||
iv_seek.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (onSeekClickListener != null)
|
||||
onSeekClickListener.onSeekClick(tickData);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setOnSeekClickListener(OnSeekClickListener onSeekClickListener) {
|
||||
this.onSeekClickListener = onSeekClickListener;
|
||||
}
|
||||
|
||||
private OnSeekClickListener onSeekClickListener;
|
||||
|
||||
public interface OnSeekClickListener {
|
||||
void onSeekClick(PolyvTickSeekBar.TickData tickData);
|
||||
}
|
||||
|
||||
public boolean isShow() {
|
||||
return getVisibility() == View.VISIBLE;
|
||||
}
|
||||
|
||||
public void hide() {
|
||||
removeCallbacks(runnable);
|
||||
setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
||||
private void handleData(final PolyvTickSeekBar.TickData tickData) {
|
||||
if (tickData == null || !(tickData.getTag() instanceof PolyvVideoVO.Videokeyframe))
|
||||
return;
|
||||
MarginLayoutParams mlp = (MarginLayoutParams) getLayoutParams();
|
||||
mlp.leftMargin = 0;
|
||||
setLayoutParams(mlp);//先把margin调整为0,避免textview的文本由于上次的margin显示不全
|
||||
PolyvVideoVO.Videokeyframe videokeyframe = (PolyvVideoVO.Videokeyframe) tickData.getTag();
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
if (videokeyframe.getHouts() > 9) {
|
||||
stringBuilder.append(videokeyframe.getHouts()).append(":");
|
||||
} else if (videokeyframe.getHouts() > 0) {
|
||||
stringBuilder.append(0).append(videokeyframe.getHouts()).append(":");
|
||||
}
|
||||
if (videokeyframe.getMinutes() > 9) {
|
||||
stringBuilder.append(videokeyframe.getMinutes()).append(":");
|
||||
} else if (videokeyframe.getMinutes() >= 0) {
|
||||
stringBuilder.append(0).append(videokeyframe.getMinutes()).append(":");
|
||||
}
|
||||
if (videokeyframe.getSeconds() > 9) {
|
||||
stringBuilder.append(videokeyframe.getSeconds());
|
||||
} else if (videokeyframe.getSeconds() >= 0) {
|
||||
stringBuilder.append(0).append(videokeyframe.getSeconds());
|
||||
}
|
||||
tv_time.setText(stringBuilder.toString());
|
||||
tv_context.setMaxWidth(((ViewGroup) getParent()).getWidth() * 3 / 4);//调整最大的宽度,不然iv_seek可能会显示不了
|
||||
tv_context.setText(videokeyframe.getKeycontext());
|
||||
tv_context.post(runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
//调整位置
|
||||
int parentWidth = ((ViewGroup) getParent()).getWidth();
|
||||
int width = getWidth();
|
||||
float cx = tickData.getCx();
|
||||
MarginLayoutParams mlp = (MarginLayoutParams) getLayoutParams();
|
||||
int halfWidth = width / 2;
|
||||
if (cx > halfWidth) {
|
||||
int leftMargin = (int) (cx - halfWidth);
|
||||
if (leftMargin + width > parentWidth) {
|
||||
if (cx > parentWidth / 2) {
|
||||
leftMargin = parentWidth - width;
|
||||
} else {
|
||||
leftMargin = 0;//中间及左边都为0
|
||||
}
|
||||
}
|
||||
mlp.leftMargin = leftMargin;
|
||||
} else {
|
||||
mlp.leftMargin = 0;
|
||||
}
|
||||
setLayoutParams(mlp);
|
||||
setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void show(final PolyvTickSeekBar.TickData tickData) {
|
||||
if (this.tickData != tickData || !isShow()) {
|
||||
this.tickData = tickData;
|
||||
removeCallbacks(runnable);
|
||||
if (isShow()) {
|
||||
hide();
|
||||
postDelayed(runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
handleData(tickData);
|
||||
}
|
||||
}, 200);
|
||||
} else {
|
||||
handleData(tickData);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user