33
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
package cn.shangyu.gdxzExpert.big.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.gongwen.marqueen.MarqueeFactory;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import cn.shangyu.gdxzExpert.R;
|
||||
import cn.shangyu.gdxzExpert.bean.HomeBean;
|
||||
|
||||
import static cn.shangyu.gdxzExpert.ecdemo.common.utils.CommomUtil.simpleDateFormatbig;
|
||||
import static com.netease.nim.uikit.common.util.sys.TimeUtil.isSameDay;
|
||||
|
||||
public class BigComplexViewMF extends MarqueeFactory<RelativeLayout, HomeBean.MettingBean> {
|
||||
private LayoutInflater inflater;
|
||||
|
||||
public BigComplexViewMF(Context mContext) {
|
||||
super(mContext);
|
||||
inflater = LayoutInflater.from(mContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RelativeLayout generateMarqueeItemView(HomeBean.MettingBean data) {
|
||||
RelativeLayout mView = (RelativeLayout) inflater.inflate(R.layout.complex_view_big, null);
|
||||
|
||||
((TextView) mView.findViewById(R.id.tv_title)).setText(data.getTitle());
|
||||
switch (data.getState()+"")
|
||||
{
|
||||
case "1":
|
||||
if(isSameDay(new Date(Long.valueOf(data.getBegin_date_timestamp())),
|
||||
new Date(System.currentTimeMillis())))
|
||||
{
|
||||
Glide.with(mContext).load(R.drawable.big_b_now_big).into((ImageView) mView.findViewById(R.id.im_s));
|
||||
((TextView) mView.findViewById(R.id.tv_time)).setText("开播时间:"+simpleDateFormatbig.format(new Date(Long.valueOf(data.getBegin_date_timestamp()))));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Glide.with(mContext).load(R.drawable.big_b_not).into((ImageView) mView.findViewById(R.id.im_s));
|
||||
((TextView) mView.findViewById(R.id.tv_time)).setText("开播时间:"+simpleDateFormatbig.format(new Date(Long.valueOf(data.getBegin_date_timestamp()))));
|
||||
}
|
||||
break;
|
||||
case "2":
|
||||
((TextView) mView.findViewById(R.id.tv_time)).setText("开播时间:"+simpleDateFormatbig.format(new Date(Long.valueOf(data.getBegin_date_timestamp()))));
|
||||
Glide.with(mContext).load(R.drawable.big_b_now).into((ImageView) mView.findViewById(R.id.im_s));
|
||||
break;
|
||||
default:
|
||||
Glide.with(mContext).load(R.drawable.big_b_not).into((ImageView) mView.findViewById(R.id.im_s));
|
||||
((TextView) mView.findViewById(R.id.tv_time)).setText("开播时间:"+simpleDateFormatbig.format(new Date(Long.valueOf(data.getBegin_date_timestamp()))));
|
||||
break;
|
||||
|
||||
}
|
||||
return mView;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
package cn.shangyu.gdxzExpert.big.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import cn.forward.androids.views.ShapeImageView;
|
||||
import cn.shangyu.gdxzExpert.R;
|
||||
import cn.shangyu.gdxzExpert.adapter.OnRecyclerViewItemClickListener;
|
||||
import cn.shangyu.gdxzExpert.bean.HomeBean;
|
||||
import cn.shangyu.gdxzExpert.utils.ImageOptions;
|
||||
|
||||
public class BigHuiAdapter extends RecyclerView.Adapter<BigHuiAdapter.ViewHolder> {
|
||||
private Context context;
|
||||
private List<HomeBean.VideoBean> datas;
|
||||
|
||||
|
||||
public BigHuiAdapter(Context context, List<HomeBean.VideoBean> datas) {
|
||||
this.context=context;
|
||||
this.datas=datas;
|
||||
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(context).inflate(R.layout.big_hui_item,
|
||||
parent, false);
|
||||
|
||||
|
||||
|
||||
ViewHolder viewHolder = new ViewHolder(view);
|
||||
|
||||
viewHolder.im_c = view.findViewById(R.id.im_c);
|
||||
viewHolder.tv_n=view.findViewById(R.id.tv_n);
|
||||
// viewHolder.tv_update=view.findViewById(R.id.tv_update);
|
||||
|
||||
// viewHolder.l_c=view.findViewById(R.id.l_c);
|
||||
|
||||
// LinearLayout.LayoutParams params = new LinearLayout.LayoutParams((int) ((context.getResources().getDisplayMetrics().widthPixels - CommonUtil.dip2px(context, 5)) / 4.5f),
|
||||
// ViewGroup.LayoutParams.MATCH_PARENT);平分屏幕宽度,显示4个半
|
||||
// LinearLayout.LayoutParams params = new LinearLayout.LayoutParams((int) ((context.getResources().getDisplayMetrics().widthPixels- CommonUtil.dip2px(context, 10) ) / 1.8f),
|
||||
// ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
// viewHolder.l_c.setLayoutParams(params);
|
||||
// viewHolder.l_c.setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View v) {
|
||||
// if (mOnItemClickListener != null) {
|
||||
// mOnItemClickListener.onItemClick(viewHolder.itemView, viewHolder.getAdapterPosition());
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
viewHolder.im_c.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (mOnItemClickListener != null) {
|
||||
mOnItemClickListener.onItemClick(viewHolder.itemView, viewHolder.getAdapterPosition());
|
||||
}
|
||||
}
|
||||
});
|
||||
return viewHolder;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
||||
// Glide.with(context).asBitmap().load(datas.get(position).getIndex_img())
|
||||
// .into(holder.im_c);
|
||||
|
||||
ImageLoader.getInstance().displayImage(
|
||||
datas.get(position).getImgpath(),
|
||||
holder.im_c,
|
||||
ImageOptions.getImageOptions(R.drawable.home_scroll_default));
|
||||
holder.tv_n.setText(datas.get(position).getName());
|
||||
// if(datas.get(position).getUpload_num().equals(datas.get(position).getVideo_num()))
|
||||
// {
|
||||
// holder.tv_update.setText("已完结");
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// holder.tv_update.setText("已更新"+datas.get(position).getUpload_num()+"课时");
|
||||
// }
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return datas.size();
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder
|
||||
{
|
||||
|
||||
public ViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
}
|
||||
ShapeImageView im_c;
|
||||
TextView tv_n;
|
||||
// ,tv_update;
|
||||
// LinearLayout l_c;
|
||||
}
|
||||
private OnRecyclerViewItemClickListener mOnItemClickListener = null;
|
||||
|
||||
public void setOnItemClickListener(OnRecyclerViewItemClickListener listener) {
|
||||
this.mOnItemClickListener = listener;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,414 @@
|
||||
package cn.shangyu.gdxzExpert.big.adapter;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.github.dfqin.grantor.PermissionListener;
|
||||
import com.github.dfqin.grantor.PermissionsUtil;
|
||||
import com.hjq.window.EasyWindow;
|
||||
import com.lidroid.xutils.HttpUtils;
|
||||
import com.lidroid.xutils.exception.HttpException;
|
||||
import com.lidroid.xutils.http.HttpHandler;
|
||||
import com.lidroid.xutils.http.ResponseInfo;
|
||||
import com.lidroid.xutils.http.callback.RequestCallBack;
|
||||
import com.umeng.analytics.MobclickAgent;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import cn.shangyu.gdxzExpert.R;
|
||||
import cn.shangyu.gdxzExpert.activity.CourseUrlDetailActivity;
|
||||
import cn.shangyu.gdxzExpert.activity.PdfViewActivity;
|
||||
import cn.shangyu.gdxzExpert.adapter.OnRecyclerViewItemClickListener;
|
||||
import cn.shangyu.gdxzExpert.bean.HomeBean;
|
||||
import cn.shangyu.gdxzExpert.big.activity.BigPatientActivity;
|
||||
import cn.shangyu.gdxzExpert.ecdemo.storage.BookDownloadSqlManager;
|
||||
import cn.shangyu.gdxzExpert.ecdemo.storage.CoursewareBookDownloadSqlManager;
|
||||
import cn.shangyu.gdxzExpert.ecdemo.ui.chatting.model.DownloadModel;
|
||||
import cn.shangyu.gdxzExpert.utils.DateUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.StringUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.ToastUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.Url;
|
||||
|
||||
import static cn.shangyu.gdxzExpert.utils.StaUtil.EXPERT_HOME_COURSEWARE_CHECK;
|
||||
import static cn.shangyu.gdxzExpert.utils.StaUtil.EXPERT_HOME_GUIDE_CHECK;
|
||||
import static cn.shangyu.gdxzExpert.utils.StaUtil.EXPERT_HOME_GUIDE_DOWNLOAD;
|
||||
import static cn.shangyu.gdxzExpert.utils.UIUtils.getContext;
|
||||
|
||||
public class BigKejianAdapter extends RecyclerView.Adapter<BigKejianAdapter.ViewHolder>{
|
||||
private Context context;
|
||||
private List<HomeBean.GuideBean> datas;
|
||||
private Boolean guide;
|
||||
|
||||
public BigKejianAdapter(Context context, List<HomeBean.GuideBean> datas) {
|
||||
this.context=context;
|
||||
this.datas=datas;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void setGuide(Boolean guide) {
|
||||
this.guide = guide;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(context).inflate(R.layout.kejian_item_big,
|
||||
parent, false);
|
||||
|
||||
ViewHolder viewHolder = new ViewHolder(view);
|
||||
|
||||
viewHolder.tv_open = view.findViewById(R.id.tv_open);
|
||||
viewHolder.tv_n=view.findViewById(R.id.tv_n);
|
||||
viewHolder.r_kj=view.findViewById(R.id.r_kj);
|
||||
viewHolder.item_iv_down=view.findViewById(R.id.item_iv_down);
|
||||
|
||||
|
||||
// viewHolder.tv_open.setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View v) {
|
||||
// if (mOnItemClickListener != null) {
|
||||
// mOnItemClickListener.onItemClick(viewHolder.itemView, viewHolder.getAdapterPosition());
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
return viewHolder;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
||||
|
||||
holder.tv_n.setText(datas.get(position).getTitle());
|
||||
if(2==getDownloadS(datas.get(position).getArticle_uuid()))
|
||||
{
|
||||
holder.tv_open.setText("查看");
|
||||
holder.tv_open.setVisibility(View.VISIBLE);
|
||||
holder.item_iv_down.setVisibility(View.GONE);
|
||||
}
|
||||
else if(1==getDownloadS(datas.get(position).getArticle_uuid()))
|
||||
{
|
||||
holder.tv_open.setText("下载中");
|
||||
holder.tv_open.setVisibility(View.VISIBLE);
|
||||
holder.item_iv_down.setVisibility(View.GONE);
|
||||
}
|
||||
else
|
||||
{
|
||||
holder.tv_open.setText("下载");
|
||||
holder.tv_open.setVisibility(View.VISIBLE);
|
||||
holder.item_iv_down.setVisibility(View.GONE);
|
||||
// holder.tv_open.setVisibility(View.GONE);
|
||||
// holder.item_iv_down.setVisibility(View.VISIBLE);
|
||||
|
||||
}
|
||||
holder.r_kj.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if(guide)
|
||||
{
|
||||
if(2==getDownloadS(datas.get(position).getArticle_uuid())
|
||||
)
|
||||
{
|
||||
String downloadFilePath = BookDownloadSqlManager
|
||||
.getDownloadFilePath(datas.get(position).getArticle_uuid());
|
||||
|
||||
if (!TextUtils.isEmpty(downloadFilePath)) {
|
||||
MobclickAgent.onEvent(context,EXPERT_HOME_GUIDE_CHECK);
|
||||
// 路径不为空,打开该指南
|
||||
openFile(downloadFilePath);
|
||||
} else {
|
||||
// 路径为空,则删除不存在文件的记录
|
||||
BookDownloadSqlManager.delDownladInfo(datas.get(position).getArticle_uuid());
|
||||
notifyDataSetChanged();
|
||||
ToastUtil.showToast("文件不存在,请重新下载");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (PermissionsUtil.hasPermission(context, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
// 下载
|
||||
downloadPdfen(
|
||||
Url.urlHtml +datas.get(position).getPath(),
|
||||
datas.get(position).getTitle(), position,
|
||||
holder);
|
||||
} else {
|
||||
EasyWindow.with((Activity) context).setGravity(Gravity.TOP).setYOffset(200).setWidth(1000)
|
||||
|
||||
.setContentView(R.layout.float_top_dialog_download).show();
|
||||
PermissionsUtil.requestPermission((Activity)context, new PermissionListener() {
|
||||
@Override
|
||||
public void permissionGranted(@NonNull String[] permissions) {
|
||||
EasyWindow.cancelAll();
|
||||
// 下载
|
||||
downloadPdfen(
|
||||
Url.urlHtml + datas.get(position).getPath(),
|
||||
datas.get(position).getTitle(), position,
|
||||
holder);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void permissionDenied(@NonNull String[] permissions) {
|
||||
EasyWindow.cancelAll();
|
||||
//用户拒绝了访问读写的申请
|
||||
//
|
||||
}
|
||||
|
||||
}, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE});
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
// 下载
|
||||
downloadPdfen(
|
||||
Url.urlHtml + datas.get(position).getPath(),
|
||||
datas.get(position).getTitle(), position,
|
||||
holder);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
MobclickAgent.onEvent(context,EXPERT_HOME_COURSEWARE_CHECK);
|
||||
Intent intent = new Intent(context, CourseUrlDetailActivity.class);
|
||||
intent.putExtra("url", datas.get(position).getPath());
|
||||
intent.putExtra("title", datas.get(position).getTitle());
|
||||
intent.putExtra("uuid", datas.get(position).getArticle_uuid());
|
||||
context.startActivity(intent);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Glide.with(context).asBitmap().load(datas.get(position).getIndex_img())
|
||||
// .into(holder.im_c);
|
||||
// ImageLoader.getInstance().displayImage(
|
||||
// datas.get(position),
|
||||
// holder.im_c,
|
||||
// ImageOptions.getImageOptions(R.drawable.home_scroll_default));
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据库查询下载状态 0未下载,1下载中,2已下载
|
||||
* @param uuid
|
||||
* @return
|
||||
*/
|
||||
private int getDownloadS(String uuid) {
|
||||
// TODO Auto-generated method stub
|
||||
int downloadState;
|
||||
if(guide)
|
||||
{
|
||||
downloadState = BookDownloadSqlManager.getDownloadState(uuid);
|
||||
}
|
||||
else
|
||||
{
|
||||
downloadState = CoursewareBookDownloadSqlManager.getDownloadState(uuid);
|
||||
Log.d("aaaaaa","downloadState"+downloadState+uuid);
|
||||
}
|
||||
|
||||
|
||||
return downloadState;
|
||||
}
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return datas.size();
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder
|
||||
{
|
||||
|
||||
public ViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
}
|
||||
TextView tv_open,tv_n;
|
||||
RelativeLayout r_kj;
|
||||
ImageView item_iv_down;
|
||||
|
||||
}
|
||||
private OnRecyclerViewItemClickListener mOnItemClickListener = null;
|
||||
|
||||
public void setOnItemClickListener(OnRecyclerViewItemClickListener listener) {
|
||||
this.mOnItemClickListener = listener;
|
||||
}
|
||||
public void openFile(final String path) {
|
||||
File file = new File(path);
|
||||
if (file.exists()) {
|
||||
if(path.contains("pdf")){
|
||||
Intent intent1 = new Intent(context, PdfViewActivity.class);
|
||||
intent1.putExtra("path",path);
|
||||
intent1.putExtra("title","文献详情");
|
||||
context.startActivity(intent1);
|
||||
}else {
|
||||
Uri path1 = Uri.fromFile(file);
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.setDataAndType(path1, "application/pdf");
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
try {
|
||||
context.startActivity(intent);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
ToastUtil.showToast("打开失败, 请安装相应应用!");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
// private String filePath = Environment.getExternalStorageDirectory()
|
||||
// .getAbsolutePath() + "/gdxzExpert/download/治疗指南/";
|
||||
private String filePath =getContext().getExternalFilesDir("").getAbsolutePath()+"/gdxzExpert/download/治疗指南/";
|
||||
private HttpHandler<File> hand;
|
||||
/**
|
||||
* @param
|
||||
*
|
||||
*
|
||||
*/
|
||||
protected void downloadPdfen(String url, final String name,
|
||||
final int position, final ViewHolder holder) {
|
||||
MobclickAgent.onEvent(context,EXPERT_HOME_GUIDE_DOWNLOAD);
|
||||
// TODO Auto-generated method stub
|
||||
if(StringUtil.isEmpty(url))
|
||||
{
|
||||
ToastUtil.showToast("下载地址有误"+url);
|
||||
return;
|
||||
}
|
||||
// 下载pdf
|
||||
if (Environment.getExternalStorageState().equals(
|
||||
Environment.MEDIA_MOUNTED)) {
|
||||
// sdcard存在
|
||||
HttpUtils http = new HttpUtils();
|
||||
String[] split = name.split(":");
|
||||
String name1 = split[split.length-1];
|
||||
final String path = filePath + name1 + ".pdf";
|
||||
// 下载的路径,及app安装包的命名
|
||||
// ***************************************************
|
||||
hand = http.download(url, path, false, // 如果目标文件存在,接着未完成的部分继续下载。服务器不支持RANGE时将从新下载。
|
||||
true, // 如果从请求返回信息中获取到文件名,下载完成后自动重命名。
|
||||
new RequestCallBack<File>() {
|
||||
|
||||
private DownloadModel downloadModel;
|
||||
|
||||
/** 下载开始 **/
|
||||
@Override
|
||||
public void onStart() {
|
||||
ToastUtil.showToast("开始下载" + name);
|
||||
|
||||
// 插入下载数据库
|
||||
downloadModel = new DownloadModel(datas
|
||||
.get(position).getArticle_uuid());
|
||||
downloadModel.setTitle(datas.get(position).getTitle());// 设置标题
|
||||
// downloadModel.setTime(datas.get(position).getTitle());// 设置标题
|
||||
if(!StringUtil.isEmpty(datas.get(position).getCreate_date())) {
|
||||
downloadModel.setTime(datas.get(position).getCreate_date());
|
||||
} else {
|
||||
downloadModel.setTime(DateUtil
|
||||
.getCurDateStr("yyyy-MM-dd HH:mm:ss"));
|
||||
}
|
||||
downloadModel.setPath(datas.get(position).getPath());// 设置url路劲
|
||||
downloadModel.setFilePath(path);// 设置文件下载路径
|
||||
downloadModel.setFileFormat(".pdf");// 设置文件格式
|
||||
downloadModel.setState(1);// 0未下载,1下载中,2已下载
|
||||
BookDownloadSqlManager
|
||||
.insertDownload(downloadModel);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
/** 下载中与进度 **/
|
||||
@Override
|
||||
public void onLoading(long total, long current,
|
||||
boolean isUploading) {
|
||||
|
||||
}
|
||||
|
||||
/** 下载完成 **/
|
||||
@Override
|
||||
public void onSuccess(ResponseInfo<File> responseInfo) {
|
||||
|
||||
// 更新下载状态为完成
|
||||
if (downloadModel == null) {
|
||||
downloadModel = new DownloadModel(datas
|
||||
.get(position).getArticle_uuid());
|
||||
}
|
||||
downloadModel.setState(2);// 0未下载,1下载中,2已下载
|
||||
BookDownloadSqlManager
|
||||
.insertDownload(downloadModel);
|
||||
notifyDataSetChanged();
|
||||
// if ((int) holder.bt_down_load.getTag() == position) {
|
||||
// // 异步显示
|
||||
// // holder.bt_down_load.setText("查看全文");
|
||||
// holder.bt_down_load.setBackgroundDrawable(mContext.getResources().getDrawable(R.drawable.lookmess));
|
||||
// holder.tv_down.setVisibility(View.GONE);
|
||||
// }
|
||||
// if (BookshelfListActivity.getInstance() != null) {
|
||||
// BookshelfListActivity.getInstance()
|
||||
// .notifyAdapter();
|
||||
// }
|
||||
// if (MyDownloadActivity.getInstance() != null) {
|
||||
// MyDownloadActivity.getInstance()
|
||||
// .notifyAdapter();
|
||||
// }
|
||||
ToastUtil.showToast(name + "下载完成!");
|
||||
// 打开文件
|
||||
// openFile(path);
|
||||
}
|
||||
|
||||
/** 下载失败 **/
|
||||
@Override
|
||||
public void onFailure(HttpException error, String msg) {
|
||||
|
||||
ToastUtil.showToast(name + "下载失败!");
|
||||
// 更新下载状态为未下载
|
||||
if (downloadModel == null) {
|
||||
downloadModel = new DownloadModel(datas
|
||||
.get(position).getArticle_uuid());
|
||||
}
|
||||
downloadModel.setState(0);// 0未下载,1下载中,2已下载
|
||||
BookDownloadSqlManager
|
||||
.updateDownloadState(downloadModel);
|
||||
notifyDataSetChanged();
|
||||
// if ((int) holder.bt_down_load.getTag() == position) {
|
||||
// 异步显示
|
||||
// holder.bt_down_load.setText("下载全文");
|
||||
// holder.bt_down_load
|
||||
// .setBackgroundDrawable(mContext
|
||||
// .getResources()
|
||||
// .getDrawable(
|
||||
// R.drawable.download));
|
||||
// holder.tv_down.setVisibility(View.GONE);
|
||||
// }
|
||||
// if (BookshelfListActivity.getInstance() != null) {
|
||||
// BookshelfListActivity.getInstance()
|
||||
// .notifyAdapter();
|
||||
// }
|
||||
|
||||
}
|
||||
});
|
||||
} else {
|
||||
ToastUtil.showToast("SD卡不存在,无法下载");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
package cn.shangyu.gdxzExpert.big.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import cn.shangyu.gdxzExpert.R;
|
||||
import cn.shangyu.gdxzExpert.bean.LibraryListBean.LibraryData;
|
||||
|
||||
/**
|
||||
* LibraryBookshelfAdapter.java
|
||||
*
|
||||
* @author liufang
|
||||
* @date 2015-11-4 上午11:15:25 Copyright (C) 2015 河南商宇科技有限公司
|
||||
*
|
||||
* 功能说明:我的图书馆书架适配器
|
||||
*/
|
||||
public class BigLibraryBookshelfAdapter extends BaseAdapter {
|
||||
private Context mContext;
|
||||
private List<LibraryData> mList;
|
||||
private int type;
|
||||
|
||||
public BigLibraryBookshelfAdapter(Context context, List<LibraryData> list,
|
||||
int type) {
|
||||
this.mContext = context;
|
||||
this.mList = list;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return mList.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
return mList.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(mContext,
|
||||
R.layout.bookself_item_big, null);
|
||||
|
||||
holder.name = (TextView) convertView.findViewById(R.id.item_name);// 标题名字
|
||||
// holder.img = (ImageView) convertView.findViewById(R.id.item_img);
|
||||
// holder.tv_num = (TextView) convertView.findViewById(R.id.tv_num);
|
||||
holder.item = convertView.findViewById(R.id.item_view);
|
||||
|
||||
// 计算GridView的列宽
|
||||
// int width = mContext.getResources().getDisplayMetrics().widthPixels;
|
||||
// int w = width - CommonUtil.dip2px(mContext, 40);
|
||||
// double h = (w / 3) * 1.415;
|
||||
// LayoutParams i = holder.img.getLayoutParams();
|
||||
// i.width = LayoutParams.WRAP_CONTENT;
|
||||
// i.height = (int) h;
|
||||
// holder.img.setLayoutParams(i);
|
||||
// LogUtil.i("width=" + width + "w=" + w + "h=" + h);
|
||||
|
||||
// if (type == 1) {
|
||||
// holder.name.setVisibility(View.INVISIBLE);
|
||||
// holder.tv_num.setVisibility(View.INVISIBLE);
|
||||
// } else {
|
||||
// holder.name.setVisibility(View.VISIBLE);
|
||||
// holder.tv_num.setVisibility(View.VISIBLE);
|
||||
// }
|
||||
|
||||
convertView.setTag(holder);
|
||||
} else {
|
||||
holder = (Holder) convertView.getTag();
|
||||
}
|
||||
if (position>=0){
|
||||
final LibraryData data = mList.get(position);
|
||||
// if (type == 1) {
|
||||
// holder.name.setText(" ");
|
||||
// } else {
|
||||
holder.name.setText(data.name);
|
||||
// holder.tv_num.setText("(共"+data.total+"份)");
|
||||
// }
|
||||
|
||||
// if (!TextUtils.isEmpty(data.imgs)) {
|
||||
// ImageLoader.getInstance().displayImage(Url.urlHtml + data.imgs,
|
||||
// holder.img,
|
||||
// ImageOptions.getImageOptions(R.drawable.book_default));
|
||||
//
|
||||
// } else {
|
||||
// holder.img.setImageResource(R.drawable.book_default);
|
||||
// }
|
||||
}
|
||||
|
||||
return convertView;
|
||||
}
|
||||
|
||||
public class Holder {
|
||||
// public ImageView img;
|
||||
public TextView name;
|
||||
// public TextView tv_num;
|
||||
View item;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,265 @@
|
||||
package cn.shangyu.gdxzExpert.big.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.AnimationDrawable;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import cn.forward.androids.views.ShapeImageView;
|
||||
import cn.shangyu.gdxzExpert.R;
|
||||
import cn.shangyu.gdxzExpert.activity.ZhiBoActivity;
|
||||
import cn.shangyu.gdxzExpert.bean.MeetingBean.MeatingList;
|
||||
import cn.shangyu.gdxzExpert.utils.ImageOptions;
|
||||
import cn.shangyu.gdxzExpert.utils.UIUtils;
|
||||
import cn.shangyu.gdxzExpert.utils.Url;
|
||||
|
||||
import static cn.shangyu.gdxzExpert.ecdemo.common.utils.CommomUtil.simpleDateFormatbig;
|
||||
|
||||
public class BigMeetingAdapter extends BaseAdapter {
|
||||
Context context;
|
||||
List<MeatingList> mList;
|
||||
private AnimationDrawable anim;
|
||||
|
||||
|
||||
|
||||
public BigMeetingAdapter(Context mActivity, List<MeatingList> mList) {
|
||||
|
||||
this.context = mActivity;
|
||||
this.mList = mList;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
// TODO Auto-generated method stub
|
||||
return mList.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
// TODO Auto-generated method stub
|
||||
return mList.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
|
||||
ViewHolder vh = null;
|
||||
if (convertView == null) {
|
||||
convertView = UIUtils.inflate(R.layout.item_meeting_big);
|
||||
vh = new ViewHolder();
|
||||
vh.mDate = (TextView) convertView
|
||||
.findViewById(R.id.tv_item_meeting_date);
|
||||
vh.mTitle = (TextView) convertView
|
||||
.findViewById(R.id.tv_item_meeting_title);
|
||||
vh.tv_item_meeting_end=convertView.findViewById(R.id.tv_item_meeting_end);
|
||||
|
||||
// vh.mLocation = (TextView) convertView
|
||||
// .findViewById(R.id.tv_item_meeting_location);
|
||||
// vh.mTDate = (TextView) convertView
|
||||
// .findViewById(R.id.tv_item_meeting_tdate);
|
||||
vh.mImage = convertView
|
||||
.findViewById(R.id.iv_item_meeting_image);
|
||||
vh.imageView1=convertView.findViewById(R.id.imageView1);
|
||||
// vh.mV_color = convertView.findViewById(R.id.item_color);
|
||||
// vh.mRl = (RelativeLayout) convertView
|
||||
// .findViewById(R.id.rl_item_meeting);
|
||||
vh.mFl = (FrameLayout) convertView.findViewById(R.id.fl_meeting);
|
||||
// vh.mZhiBo = (TextView) convertView.findViewById(R.id.tv_meeting);
|
||||
// vh.mIv_bofang = (ImageView) convertView
|
||||
// .findViewById(R.id.iv_meeting_bofang);
|
||||
|
||||
convertView.setTag(vh);
|
||||
} else {
|
||||
vh = (ViewHolder) convertView.getTag();
|
||||
}
|
||||
|
||||
|
||||
// vh.mDate.setText("直播时间:"+" "+getTime(mList.get(position).getBegin_date(),0,16));
|
||||
vh.mTitle.setText(mList.get(position).getTitle());
|
||||
// vh.mLocation.setText(mList.get(position).getLocation());
|
||||
|
||||
if (mList.get(position).getStatus() != null
|
||||
&& mList.get(position).getStatus().equals("1")) {
|
||||
// ViewGroup.LayoutParams pp = vh.mRl.getLayoutParams();
|
||||
// vh.mRl.getLayoutParams();
|
||||
// vh.mIv_bofang.setVisibility(View.VISIBLE);
|
||||
// vh.mZhiBo.setVisibility(View.VISIBLE);
|
||||
// vh.mSpareZhiBo.setVisibility(View.VISIBLE);
|
||||
// pp.height = dip2px(mActivity, 247);
|
||||
vh.mFl.setVisibility(View.VISIBLE);
|
||||
// vh.mRl.setLayoutParams(pp);
|
||||
// vh.mZhiBo.setText("预告");
|
||||
if(getTime(simpleDateFormatbig.format(new Date()),0,10).equals(getTime(mList.get(position).getBegin_date(), 0,10)))
|
||||
{
|
||||
Glide.with(context).load(R.drawable.meetingtime_big1).into(vh.imageView1);
|
||||
vh.mDate.setText("今日"+getTime(mList.get(position).getBegin_date(), 10,16)+" 开始直播");
|
||||
vh.mDate.setTextColor(Color.parseColor("#F0992D"));
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Glide.with(context).load(R.drawable.meetingtime_big).into(vh.imageView1);
|
||||
// vh.imageView1.setImageDrawable(mActivity.getResources().getDrawable(R.drawable.meetingtime_big));
|
||||
vh.mDate.setText("直播时间:"+" "+getTime(mList.get(position).getBegin_date(), 0,16));
|
||||
vh.mDate.setTextColor(Color.parseColor("#999999"));
|
||||
|
||||
}
|
||||
vh.tv_item_meeting_end.setVisibility(View.GONE);
|
||||
} else if (mList.get(position).getStatus() != null
|
||||
&& mList.get(position).getStatus().equals("2")) {
|
||||
// ViewGroup.LayoutParams pp = vh.mRl.getLayoutParams();
|
||||
// vh.mRl.getLayoutParams();
|
||||
// vh.mIv_bofang.setVisibility(View.VISIBLE);
|
||||
// vh.mZhiBo.setVisibility(View.VISIBLE);
|
||||
// vh.mSpareZhiBo.setVisibility(View.VISIBLE);
|
||||
// pp.height = dip2px(mActivity, 247);
|
||||
vh.mFl.setVisibility(View.VISIBLE);
|
||||
// ImageLoader.getInstance().displayImage(
|
||||
// context.getResources().getDrawable(R.drawable.big_bo_g),vh.imageView1);
|
||||
// RequestOptions requestOptions = new RequestOptions().dontAnimate().skipMemoryCache(true);
|
||||
// Glide.with(context).load(R.drawable.zhibo_anim).apply(requestOptions).into(vh.imageView1);
|
||||
vh.imageView1.setImageDrawable(context.getResources().getDrawable(R.drawable.zhibo_anim));
|
||||
// vh.imageView1.setBackground(context.getResources().getDrawable(R.drawable.zhibo_anim));
|
||||
anim = (AnimationDrawable) vh.imageView1.getDrawable();
|
||||
// vh.imageView1.post(new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
//
|
||||
anim.start();
|
||||
// }
|
||||
// });
|
||||
// vh.imageView1.setImageDrawable(mActivity.getResources().getDrawable(R.drawable.meetingtime_big1));
|
||||
vh.mDate.setText("直播进行中");
|
||||
vh.mDate.setTextColor(Color.parseColor("#F0992D"));
|
||||
// vh.mRl.setLayoutParams(pp);
|
||||
// vh.mZhiBo.setText("直播中");
|
||||
vh.tv_item_meeting_end.setVisibility(View.GONE);
|
||||
} else if (mList.get(position).getStatus() != null
|
||||
&& mList.get(position).getStatus().equals("3")) {
|
||||
// ViewGroup.LayoutParams pp = vh.mRl.getLayoutParams();
|
||||
// vh.mRl.getLayoutParams();
|
||||
// vh.mIv_bofang.setVisibility(View.GONE);
|
||||
// vh.mZhiBo.setVisibility(View.VISIBLE);
|
||||
// vh.mSpareZhiBo.setVisibility(View.GONE);
|
||||
// pp.height = dip2px(mActivity, 247);
|
||||
vh.mFl.setVisibility(View.VISIBLE);
|
||||
// vh.mRl.setLayoutParams(pp);
|
||||
Glide.with(context).load(R.drawable.meetingtime_big).into(vh.imageView1);
|
||||
// vh.imageView1.setImageDrawable(mActivity.getResources().getDrawable(R.drawable.meetingtime_big));
|
||||
vh.mDate.setText("直播时间:"+" "+getTime(mList.get(position).getBegin_date(), 0,10));
|
||||
vh.mDate.setTextColor(Color.parseColor("#999999"));
|
||||
// vh.mZhiBo.setText("已结束");
|
||||
vh.tv_item_meeting_end.setVisibility(View.VISIBLE);
|
||||
}else if (mList.get(position).getStatus() != null
|
||||
&& mList.get(position).getStatus().equals("4")) {
|
||||
// ViewGroup.LayoutParams pp = vh.mRl.getLayoutParams();
|
||||
// vh.mRl.getLayoutParams();
|
||||
// vh.mIv_bofang.setVisibility(View.GONE);
|
||||
// vh.mZhiBo.setVisibility(View.VISIBLE);
|
||||
// vh.mSpareZhiBo.setVisibility(View.GONE);
|
||||
// pp.height = dip2px(mActivity, 247);
|
||||
vh.mFl.setVisibility(View.VISIBLE);
|
||||
// vh.mRl.setLayoutParams(pp);
|
||||
Glide.with(context).load(R.drawable.meetingtime_big).into(vh.imageView1);
|
||||
// vh.imageView1.setImageDrawable(mActivity.getResources().getDrawable(R.drawable.meetingtime_big));
|
||||
vh.mDate.setText("直播回放:"+" "+getTime(mList.get(position).getBegin_date(), 0,16));
|
||||
vh.mDate.setTextColor(Color.parseColor("#999999"));
|
||||
// vh.mZhiBo.setText("回放中");
|
||||
vh.tv_item_meeting_end.setVisibility(View.GONE);
|
||||
} else {
|
||||
// vh.mIv_bofang.setVisibility(View.GONE);
|
||||
// vh.mZhiBo.setVisibility(View.GONE);
|
||||
// vh.mSpareZhiBo.setVisibility(View.GONE);
|
||||
// ViewGroup.LayoutParams pp = vh.mRl.getLayoutParams();
|
||||
// vh.mRl.getLayoutParams();
|
||||
// pp.height = dip2px(mActivity, 75);
|
||||
Glide.with(context).load(R.drawable.meetingtime_big).into(vh.imageView1);
|
||||
// vh.imageView1.setImageDrawable(mActivity.getResources().getDrawable(R.drawable.meetingtime_big));
|
||||
vh.mDate.setText("直播时间:"+" "+getTime(mList.get(position).getBegin_date(), 0,16));
|
||||
vh.mDate.setTextColor(Color.parseColor("#999999"));
|
||||
vh.mFl.setVisibility(View.GONE);
|
||||
// vh.mRl.setLayoutParams(pp);
|
||||
vh.tv_item_meeting_end.setVisibility(View.GONE);
|
||||
}
|
||||
vh.mFl.setTag(position);
|
||||
vh.mFl.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// TODO Auto-generated method stub
|
||||
if (mList.get((Integer) v.getTag()).getStatus().equals("3")) {
|
||||
return;
|
||||
}
|
||||
Intent intent = new Intent(context, ZhiBoActivity.class);
|
||||
intent.putExtra("newsTitle", mList.get((Integer) v.getTag())
|
||||
.getTitle());
|
||||
intent.putExtra("url", mList.get((Integer) v.getTag())
|
||||
.getLiveurl());
|
||||
intent.putExtra("summary", mList.get((Integer) v.getTag())
|
||||
.getLiveimg());
|
||||
intent.setType("zhibo");
|
||||
context.startActivity(intent);
|
||||
}
|
||||
});
|
||||
if (!TextUtils.isEmpty(mList.get(position).getLiveimg())
|
||||
&& !"null".equals(mList.get(position).getLiveimg())) {
|
||||
ImageLoader.getInstance().displayImage(
|
||||
Url.urlHtml + mList.get(position).getLiveimg(),
|
||||
vh.mImage,
|
||||
ImageOptions
|
||||
.getImageOptions(R.drawable.home_scroll_default1));
|
||||
} else {
|
||||
vh.mImage.setImageResource(R.drawable.home_scroll_default1);
|
||||
}
|
||||
return convertView;
|
||||
}
|
||||
|
||||
class ViewHolder {
|
||||
TextView mTitle, mDate,tv_item_meeting_end;
|
||||
// View mV_color;
|
||||
ShapeImageView mImage;
|
||||
ImageView imageView1;
|
||||
// RelativeLayout mRl;
|
||||
FrameLayout mFl;
|
||||
}
|
||||
|
||||
public String getTime(String str1, int bnum,int dnum) {
|
||||
// if (str1.subSequence(0, 16).equals(str2.subSequence(0, 16))) {
|
||||
return str1.replaceAll("-", ".").subSequence(bnum, dnum).toString();
|
||||
// }
|
||||
// StringBuilder sb = new StringBuilder();
|
||||
// sb.append(str1.replaceAll("-", ".").subSequence(0, 15));
|
||||
// sb.append("-");
|
||||
// sb.append(str2.replaceAll("-", ".").subSequence(0, 15));
|
||||
// return sb.toString();
|
||||
|
||||
}
|
||||
|
||||
public static int dip2px(Context context, double d) {
|
||||
final float scale = context.getResources().getDisplayMetrics().density;
|
||||
return (int) (d * scale + 0.5f);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package cn.shangyu.gdxzExpert.big.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.LayoutInflater;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import cn.shangyu.gdxzExpert.R;
|
||||
import me.majiajie.pagerbottomtabstrip.item.BaseTabItem;
|
||||
|
||||
public class BigNormalItemView extends BaseTabItem {
|
||||
TextView tv_title;
|
||||
ImageView im_selector;
|
||||
|
||||
public BigNormalItemView(@NonNull Context context) {
|
||||
super(context);
|
||||
LayoutInflater.from(context).inflate(R.layout.item_kejianna, this, true);
|
||||
tv_title=findViewById(R.id.tv_title);
|
||||
im_selector=findViewById(R.id.im_selector);
|
||||
|
||||
}
|
||||
/**
|
||||
* 方便初始化的方法
|
||||
*
|
||||
* @param title 标题
|
||||
*/
|
||||
public void initialize( String title) {
|
||||
|
||||
tv_title.setText(title);
|
||||
}
|
||||
@Override
|
||||
public void setChecked(boolean checked) {
|
||||
if (checked) {
|
||||
|
||||
tv_title.setTextColor(Color.parseColor("#ff000000"));
|
||||
tv_title.setTextSize(23);
|
||||
tv_title.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
|
||||
im_selector.setVisibility(VISIBLE);
|
||||
} else {
|
||||
|
||||
tv_title.setTextColor(Color.parseColor("#ff666666"));
|
||||
tv_title.setTextSize(21);
|
||||
tv_title.setTypeface(Typeface.defaultFromStyle(Typeface.NORMAL));
|
||||
im_selector.setVisibility(GONE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMessageNumber(int number) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHasMessage(boolean hasMessage) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTitle(String title) {
|
||||
tv_title.setText(title);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDefaultDrawable(Drawable drawable) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelectedDrawable(Drawable drawable) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return tv_title.getText().toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package cn.shangyu.gdxzExpert.big.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.zaaach.transformerslayout.holder.Holder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import cn.shangyu.gdxzExpert.R;
|
||||
import cn.shangyu.gdxzExpert.bean.IconBean;
|
||||
|
||||
public class BigRollAdapter extends Holder<IconBean> {
|
||||
private ImageView icon;
|
||||
private TextView text;
|
||||
private ImageView iv_red;
|
||||
public BigRollAdapter(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView(View itemView) {
|
||||
icon = itemView.findViewById(R.id.iv_menu_icon);
|
||||
text = itemView.findViewById(R.id.tv_menu_text);
|
||||
iv_red=itemView.findViewById(R.id.iv_red);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBind(Context context, List<IconBean> list, @Nullable IconBean data, int position) {
|
||||
if (data == null) return;
|
||||
if(data.getRed()==null||!data.getRed())
|
||||
{
|
||||
iv_red.setVisibility(View.GONE);
|
||||
}
|
||||
else
|
||||
{
|
||||
iv_red.setVisibility(View.VISIBLE);
|
||||
}
|
||||
text.setText(data.getName());
|
||||
// icon.setImageResource(data.getIcon());
|
||||
Glide.with(context)
|
||||
.asBitmap()
|
||||
// .placeholder(R.drawable.default_place_holder)
|
||||
.load(data.getImg())
|
||||
.into(icon);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package cn.shangyu.gdxzExpert.big.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.widget.ArrayAdapter;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
public class BigToolAdapter extends ArrayAdapter<String> {
|
||||
|
||||
public BigToolAdapter(@NonNull Context context, int resource, int textViewResourceId, @NonNull String[] objects) {
|
||||
super(context, resource, textViewResourceId, objects);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
package cn.shangyu.gdxzExpert.big.adapter;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import cn.shangyu.gdxzExpert.R;
|
||||
import cn.shangyu.gdxzExpert.bean.VideoMoreBean.VideoMore;
|
||||
import cn.shangyu.gdxzExpert.big.activity.BigVideoActivity;
|
||||
import cn.shangyu.gdxzExpert.polyvplayer.VideoDetailPolyvPlayerActivity;
|
||||
import cn.shangyu.gdxzExpert.utils.UIUtils;
|
||||
|
||||
public class BigVideoSAdapter extends BaseAdapter {
|
||||
private List<VideoMore> lists;
|
||||
private BigVideoActivity mActivity;
|
||||
|
||||
public BigVideoSAdapter(List<VideoMore> lists, BigVideoActivity mActivity) {
|
||||
this.lists = lists;
|
||||
this.mActivity = mActivity;
|
||||
}
|
||||
|
||||
public void getDatas(List<VideoMore> lists) {
|
||||
this.lists = lists;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
// TODO Auto-generated method stub
|
||||
return lists.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
// TODO Auto-generated method stub
|
||||
ViewHolder vh = null;
|
||||
if (convertView == null) {
|
||||
convertView = UIUtils.inflate(R.layout.item_video_list_big);
|
||||
vh = new ViewHolder();
|
||||
vh.item_view = convertView
|
||||
.findViewById(R.id.item_view);
|
||||
vh.mTv_title1 = (TextView) convertView
|
||||
.findViewById(R.id.tv_video_content1);
|
||||
vh.mTv_name1 = (TextView) convertView
|
||||
.findViewById(R.id.tv_video_name1);
|
||||
|
||||
convertView.setTag(vh);
|
||||
} else {
|
||||
vh = (ViewHolder) convertView.getTag();
|
||||
}
|
||||
|
||||
if(lists.get(position).getCreate_date()!=null&&lists.get(position).getCreate_date().length()>9)
|
||||
|
||||
{
|
||||
vh.mTv_title1.setText(lists.get(position).getPublic_name()+" "+lists.get(position).getCreate_date().substring(0,10));
|
||||
}
|
||||
else
|
||||
{
|
||||
vh.mTv_title1.setText(lists.get(position).getPublic_name()+" "+lists.get(position).getCreate_date());
|
||||
}
|
||||
vh.mTv_name1.setText(lists.get(position).getName());
|
||||
|
||||
vh.item_view.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// TODO Auto-generated method stub
|
||||
Intent intent = VideoDetailPolyvPlayerActivity.newIntent(mActivity, VideoDetailPolyvPlayerActivity.PlayMode.portrait,"");
|
||||
// 在线视频和下载的视频播放的时候只显示播放器窗口,用该参数来控制
|
||||
intent.putExtra("startNow", false);
|
||||
intent.putExtra("isVlmsOnline", false);
|
||||
intent.putExtra("url", lists.get(position).getPath());
|
||||
intent.putExtra("uuid", lists.get(position).getUuid());
|
||||
intent.putExtra("note", lists.get(position).getNote());
|
||||
intent.putExtra("title", lists.get(position).getName());
|
||||
intent.putExtra("readnum", lists.get(position).getReadnum());
|
||||
intent.putExtra("imgpath", lists.get(position).getImgpath());
|
||||
intent.putExtra("public_name", lists.get(position)
|
||||
.getPublic_name());
|
||||
mActivity.startActivityForResult(intent,
|
||||
mActivity.GET_READ_NUM_RESULT2);
|
||||
}
|
||||
});
|
||||
|
||||
return convertView;
|
||||
}
|
||||
|
||||
class ViewHolder {
|
||||
|
||||
LinearLayout item_view;
|
||||
TextView mTv_title1, mTv_name1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
package cn.shangyu.gdxzExpert.big.adapter;
|
||||
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import cn.shangyu.gdxzExpert.R;
|
||||
import cn.shangyu.gdxzExpert.adapter.VideoTeachAdapter;
|
||||
import cn.shangyu.gdxzExpert.bean.VideoMoreBean;
|
||||
import cn.shangyu.gdxzExpert.utils.UIUtils;
|
||||
|
||||
/**
|
||||
* Created by WANGChengXin on 2019/10/25.
|
||||
*/
|
||||
|
||||
public class BigVideoTeachAdapter extends VideoTeachAdapter {
|
||||
private List<VideoMoreBean.VideoMore> data;
|
||||
|
||||
|
||||
public BigVideoTeachAdapter(List<VideoMoreBean.VideoMore> data) {
|
||||
super(data);
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
// TODO Auto-generated method stub
|
||||
if (data == null) {
|
||||
return 0;
|
||||
}
|
||||
return data.size();
|
||||
}
|
||||
|
||||
public void getDatas(List<VideoMoreBean.VideoMore> data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
// TODO Auto-generated method stub
|
||||
return 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
|
||||
NewsViewHolder vh = null;
|
||||
if (convertView == null) {
|
||||
convertView = UIUtils.inflate(R.layout.item_video_search_big);
|
||||
vh = new NewsViewHolder();
|
||||
vh.mTv_Title = (TextView) convertView.findViewById(R.id.tv_title);
|
||||
vh.tv_name = (TextView) convertView.findViewById(R.id.tv_name);
|
||||
vh.tv_time = (TextView) convertView.findViewById(R.id.tv_time);
|
||||
vh.tv_video_type_name = (TextView) convertView.findViewById(R.id.tv_video_type_name);
|
||||
vh.tv_num = (TextView) convertView.findViewById(R.id.tv_num);
|
||||
convertView.setTag(vh);
|
||||
} else {
|
||||
vh = (NewsViewHolder) convertView.getTag();
|
||||
}
|
||||
vh.mTv_Title.setText(data.get(position).getName());
|
||||
|
||||
|
||||
|
||||
vh.tv_name.setText(data.get(position).getPublic_name()+" "+data.get(position).getCreate_date().split(" ")[0]);
|
||||
vh.tv_num.setText(data.get(position).getReadnum()+"人阅读");
|
||||
|
||||
|
||||
|
||||
vh.tv_video_type_name.setText(data.get(position).getVideo_type_name());
|
||||
|
||||
// vh.item_view.setOnClickListener(new View.OnClickListener() {
|
||||
//
|
||||
// @Override
|
||||
// public void onClick(View v) {
|
||||
// // TODO Auto-generated method stub
|
||||
// Intent intent = VideoDetailPolyvPlayerActivity.newIntent(mActivity, VideoDetailPolyvPlayerActivity.PlayMode.portrait,"");
|
||||
// // 在线视频和下载的视频播放的时候只显示播放器窗口,用该参数来控制
|
||||
// intent.putExtra("startNow", false);
|
||||
// intent.putExtra("isVlmsOnline", false);
|
||||
// intent.putExtra("url", lists.get(position).getPath());
|
||||
// intent.putExtra("uuid", lists.get(position).getUuid());
|
||||
// intent.putExtra("note", lists.get(position).getNote());
|
||||
// intent.putExtra("title", lists.get(position).getName());
|
||||
// intent.putExtra("readnum", lists.get(position).getReadnum());
|
||||
// intent.putExtra("imgpath", lists.get(position).getImgpath());
|
||||
// intent.putExtra("need_inside_share", "yes");
|
||||
// intent.putExtra("public_name", lists.get(position)
|
||||
// .getPublic_name());
|
||||
// mActivity.startActivityForResult(intent,
|
||||
// mActivity.GET_READ_NUM_RESULT2);
|
||||
//
|
||||
// }
|
||||
// });
|
||||
//
|
||||
//
|
||||
// // 给控件赋值.
|
||||
// VideoMoreBean.VideoMore videoMore = data.get(position);
|
||||
// mHolder.tvTitle.setText(videoMore.getName());
|
||||
// mHolder.im_read_count.setVisibility(View.INVISIBLE);
|
||||
// mHolder.tvreadnum.setVisibility(View.INVISIBLE);
|
||||
// mHolder.tvSummary.setVisibility(View.VISIBLE);
|
||||
// mHolder.im_argee.setVisibility(View.GONE);
|
||||
// mHolder.tvdianzannum.setVisibility(View.GONE);
|
||||
// mHolder.im_argee2.setVisibility(View.VISIBLE);
|
||||
// mHolder.tv_dianzan_count2.setVisibility(View.VISIBLE);
|
||||
// if (!TextUtils.isEmpty(data.get(position).getImgpath())) {
|
||||
// ImageLoader.getInstance().displayImage(
|
||||
// Url.urlHtml + data.get(position).getImgpath(), mHolder.ivImage,
|
||||
// ImageOptions.getImageOptions(R.drawable.default_news_iv));
|
||||
// } else {
|
||||
// mHolder.ivImage.setImageResource(R.drawable.default_news_iv);
|
||||
// }
|
||||
// mHolder.tvSummary.setText(data.get(position).getPublic_name());
|
||||
// mHolder.tvDate.setText(data.get(position).getCreate_date().split(" ")[0]);
|
||||
// mHolder.tv_dianzan_count2.setText(""+data.get(position).getReadnum());
|
||||
|
||||
|
||||
return convertView;
|
||||
}
|
||||
|
||||
private class NewsViewHolder {
|
||||
|
||||
TextView mTv_Title,tv_name,tv_time,tv_video_type_name,tv_num;
|
||||
}
|
||||
|
||||
public boolean inNow(String date) {
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
||||
|
||||
String ds1 = formatter.format(new Date());
|
||||
if (date.equals(ds1)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
package cn.shangyu.gdxzExpert.big.adapter;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.ColorInt;
|
||||
import androidx.annotation.DrawableRes;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import me.majiajie.pagerbottomtabstrip.R;
|
||||
import me.majiajie.pagerbottomtabstrip.internal.RoundMessageView;
|
||||
import me.majiajie.pagerbottomtabstrip.item.BaseTabItem;
|
||||
|
||||
public class NormalItemViewBig extends BaseTabItem {
|
||||
|
||||
private ImageView mIcon;
|
||||
private final TextView mTitle;
|
||||
private final RoundMessageView mMessages;
|
||||
|
||||
private Drawable mDefaultDrawable;
|
||||
private Drawable mCheckedDrawable;
|
||||
|
||||
private int mDefaultTextColor = 0x56000000;
|
||||
private int mCheckedTextColor = 0x56000000;
|
||||
|
||||
private boolean mChecked;
|
||||
|
||||
public NormalItemViewBig(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public NormalItemViewBig(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
|
||||
public NormalItemViewBig(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
|
||||
// LayoutInflater.from(context).inflate(R.layout.item_normal, this, true);
|
||||
LayoutInflater.from(context).inflate(R.layout.item_normal_new_big, this, true);
|
||||
mIcon = findViewById(R.id.icon);
|
||||
mTitle = findViewById(R.id.title);
|
||||
mMessages = findViewById(R.id.messages);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getAccessibilityClassName() {
|
||||
return NormalItemViewBig.class.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* 方便初始化的方法
|
||||
*
|
||||
* @param drawableRes 默认状态的图标
|
||||
* @param checkedDrawableRes 选中状态的图标
|
||||
* @param title 标题
|
||||
*/
|
||||
public void initialize(@DrawableRes int drawableRes, @DrawableRes int checkedDrawableRes, String title) {
|
||||
mDefaultDrawable = ContextCompat.getDrawable(getContext(), drawableRes);
|
||||
mCheckedDrawable = ContextCompat.getDrawable(getContext(), checkedDrawableRes);
|
||||
mTitle.setText(title);
|
||||
}
|
||||
public void initialize(@DrawableRes int drawableRes, @DrawableRes int checkedDrawableRes, String title,int textsize) {
|
||||
mDefaultDrawable = ContextCompat.getDrawable(getContext(), drawableRes);
|
||||
mCheckedDrawable = ContextCompat.getDrawable(getContext(), checkedDrawableRes);
|
||||
mTitle.setText(title);
|
||||
mTitle.setTextSize(textsize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChecked(boolean checked) {
|
||||
if (checked) {
|
||||
mIcon.setImageDrawable(mCheckedDrawable);
|
||||
mTitle.setTextColor(mCheckedTextColor);
|
||||
} else {
|
||||
mIcon.setImageDrawable(mDefaultDrawable);
|
||||
mTitle.setTextColor(mDefaultTextColor);
|
||||
}
|
||||
mChecked = checked;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMessageNumber(int number) {
|
||||
mMessages.setMessageNumber(number);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHasMessage(boolean hasMessage) {
|
||||
mMessages.setHasMessage(hasMessage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTitle(String title) {
|
||||
mTitle.setText(title);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDefaultDrawable(Drawable drawable) {
|
||||
mDefaultDrawable = drawable;
|
||||
if (!mChecked) {
|
||||
mIcon.setImageDrawable(drawable);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelectedDrawable(Drawable drawable) {
|
||||
mCheckedDrawable = drawable;
|
||||
if (mChecked) {
|
||||
mIcon.setImageDrawable(drawable);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return mTitle.getText().toString();
|
||||
}
|
||||
|
||||
public void setTextDefaultColor(@ColorInt int color) {
|
||||
mDefaultTextColor = color;
|
||||
}
|
||||
|
||||
public void setTextCheckedColor(@ColorInt int color) {
|
||||
mCheckedTextColor = color;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package cn.shangyu.gdxzExpert.big.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.GestureDetector;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
public class RecyclerItemClickListener implements RecyclerView.OnItemTouchListener {
|
||||
public interface OnItemClickListener {
|
||||
void onItemClick(View view, int position);
|
||||
|
||||
void onItemLongClick(View view, int position);
|
||||
}
|
||||
|
||||
private OnItemClickListener mListener;
|
||||
|
||||
private GestureDetector mGestureDetector;
|
||||
|
||||
public RecyclerItemClickListener(Context context, final RecyclerView recyclerView, OnItemClickListener listener) {
|
||||
mListener = listener;
|
||||
|
||||
mGestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {
|
||||
@Override
|
||||
public boolean onSingleTapUp(MotionEvent e) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLongPress(MotionEvent e) {
|
||||
View childView = recyclerView.findChildViewUnder(e.getX(), e.getY());
|
||||
|
||||
if (childView != null && mListener != null) {
|
||||
mListener.onItemLongClick(childView, recyclerView.getChildAdapterPosition(childView));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(RecyclerView view, MotionEvent e) {
|
||||
View childView = view.findChildViewUnder(e.getX(), e.getY());
|
||||
|
||||
if (childView != null && mListener != null && mGestureDetector.onTouchEvent(e)) {
|
||||
mListener.onItemClick(childView, view.getChildAdapterPosition(childView));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTouchEvent(RecyclerView view, MotionEvent motionEvent) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user