Commit f94f0ce6 authored by jianglx's avatar jianglx

上传未提交的文件

parent a39381ea
package com.rv.share.adapter;
import android.support.annotation.Nullable;
import com.base.utils.ui.image.round.RoundImageView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ruiwenliu.wrapper.util.glide.GlideManager;
import com.rv.component.utils.DateUtils;
import com.rv.share.R;
import com.rv.share.bean.InviteListBean;
import java.util.List;
public class ActivationListAdapter extends BaseQuickAdapter<InviteListBean.inviteMember, BaseViewHolder> {
public ActivationListAdapter(@Nullable List<InviteListBean.inviteMember> data) {
super(R.layout.item_activation, data);
}
@Override
protected void convert(BaseViewHolder helper, InviteListBean.inviteMember item) {
helper.setText(R.id.tv_name, item.getUsername());
helper.setText(R.id.tv_ac_time, DateUtils.timestampToString1(item.getBindTime()));
GlideManager.getInstance(mContext).loadImage(item.getHeadUrl(), (RoundImageView) helper.itemView.findViewById(R.id.rimg_header));
}
}
package com.rv.share.adapter;
import android.support.annotation.Nullable;
import com.base.utils.ui.image.round.RoundImageView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ruiwenliu.wrapper.util.glide.GlideManager;
import com.rv.component.utils.DateUtils;
import com.rv.share.R;
import com.rv.share.bean.InviteListBean;
import com.rv.share.view.MyTimerView;
import java.util.List;
public class InviteListAdapter extends BaseQuickAdapter<InviteListBean.inviteMember, BaseViewHolder> {
private long effTime = 0L;
public InviteListAdapter(@Nullable List<InviteListBean.inviteMember> data) {
super(R.layout.item_invite, data);
}
public void setEffTime(long effTime) {
this.effTime = effTime;
}
@Override
protected void convert(BaseViewHolder helper, InviteListBean.inviteMember item) {
helper.setText(R.id.tv_income_record, item.getUsername());
helper.setText(R.id.tv_income_time, DateUtils.timestampToString1(item.getJoinTime()));
setTimes(effTime, helper, item);
GlideManager.getInstance(mContext).loadImage(item.getHeadUrl(), (RoundImageView) helper.itemView.findViewById(R.id.rimg_header));
}
private void setTimes(long effTime, BaseViewHolder helper, InviteListBean.inviteMember bean) {
if (bean != null) {
long crtTime = bean.getJoinTime();
long remain = effTime - (System.currentTimeMillis() - crtTime);
if (remain <= 0) {
getData().remove(bean);
notifyDataSetChanged();
} else {
((MyTimerView) helper.itemView.findViewById(com.rv.home.R.id.tv_remain_time)).setTime(effTime, bean.getJoinTime(), timerListener);
}
}
}
public MyTimerView.TimerListener timerListener = new MyTimerView.TimerListener() {
@Override
public void onTimeFinish() {
notifyDataSetChanged();
}
};
}
package com.rv.share.bean;
import com.ruiwenliu.wrapper.base.BaseBean;
import java.util.List;
public class InviteListBean extends BaseBean {
private boolean rel;
private InviteList data;
public boolean isRel() {
return rel;
}
public void setRel(boolean rel) {
this.rel = rel;
}
public InviteList getData() {
return data;
}
public void setData(InviteList data) {
this.data = data;
}
public static class InviteList {
private long failureTime;
private int page;
private int limit;
private int totalCount;
private int totalPage;
private List<inviteMember> inviteMembers;
public long getFailureTime() {
return failureTime;
}
public void setFailureTime(long failureTime) {
this.failureTime = failureTime;
}
public int getPage() {
return page;
}
public void setPage(int page) {
this.page = page;
}
public int getLimit() {
return limit;
}
public void setLimit(int limit) {
this.limit = limit;
}
public int getTotalCount() {
return totalCount;
}
public void setTotalCount(int totalCount) {
this.totalCount = totalCount;
}
public int getTotalPage() {
return totalPage;
}
public void setTotalPage(int totalPage) {
this.totalPage = totalPage;
}
public List<inviteMember> getInviteMembers() {
return inviteMembers;
}
public void setInviteMembers(List<inviteMember> inviteMembers) {
this.inviteMembers = inviteMembers;
}
}
public static class inviteMember {
private String username;
private String headUrl;
private long joinTime;
private long bindTime;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getHeadUrl() {
return headUrl;
}
public void setHeadUrl(String headUrl) {
this.headUrl = headUrl;
}
public long getJoinTime() {
return joinTime;
}
public void setJoinTime(long joinTime) {
this.joinTime = joinTime;
}
public long getBindTime() {
return bindTime;
}
public void setBindTime(long bindTime) {
this.bindTime = bindTime;
}
}
}
package com.rv.share.presenter;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.view.View;
import android.widget.Toast;
import com.rv.home.rv.module.basic.presenter.CommonPresenter;
import com.rv.share.utils.StorageUtils;
import com.umeng.socialize.ShareAction;
import com.umeng.socialize.bean.SHARE_MEDIA;
import com.umeng.socialize.media.UMImage;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
public class ReativeBillPresenter extends CommonPresenter {
private UMImage image = null;
private ShareAction shareAction = null;
/*****
* 保存海报
* @param view
*/
public void saveBill(View view) {
if (view != null) {
Bitmap bitmap = viewConversionBitmap(view);
File file = null;
if (bitmap != null) {
file = saveBitmapFile(bitmap);
}
if (file != null) {
Toast.makeText(getPresenterContext(), "海报保存在" + file.getAbsolutePath(), Toast.LENGTH_SHORT).show();
}
}
}
/*****
* 保存海报
* @param view
*/
public void saveShare(View view) {
if (view != null) {
Bitmap bitmap = viewConversionBitmap(view);
File file = null;
if (bitmap != null) {
file = saveBitmapFile(bitmap);
}
if (file != null) {
image = new UMImage(getPresenterContext(), file);//bitmap文件
image.compressStyle = UMImage.CompressStyle.SCALE;//大小压缩,默认为大小压缩,适合普通很大的图
image.compressStyle = UMImage.CompressStyle.QUALITY;//质量压缩,适合长图的分享
image.compressFormat = Bitmap.CompressFormat.PNG;
share(SHARE_MEDIA.WEIXIN_CIRCLE, image, "");
}
}
}
/******
* 分享文件
* @param var1
* @param var2
*/
private void share(SHARE_MEDIA var1, UMImage var2, String content) {
if (shareAction == null) {
shareAction = new ShareAction((Activity) getPresenterContext()).setCallback(null);
}
shareAction.setPlatform(var1)//传入平台
.withText(content)
.withMedia(var2);//分享内容
shareAction.share();
}
/**
* view转bitmap
*/
private Bitmap viewConversionBitmap(View v) {
int w = v.getWidth();
int h = v.getHeight();
int startX = (int) v.getX();
int startY = (int) v.getY();
Bitmap bmp = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(bmp);
c.drawColor(Color.WHITE);
v.layout(startX, startY, w + startX, h + startY);
v.draw(c);
return bmp;
}
private File saveBitmapFile(Bitmap bitmap) {
File file = new File(StorageUtils.getCachePath(getPresenterContext()) + (int) (System.currentTimeMillis() / 1000000) + ".jpg");//将要保存图片的路径
if (file.exists()) {
return file;
}
try {
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file));
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, bos);
bos.flush();
bos.close();
} catch (IOException e) {
e.printStackTrace();
}
return file;
}
}
package com.rv.share.view;
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.util.AttributeSet;
import android.widget.TextView;
import java.util.Timer;
import java.util.TimerTask;
public class MyTimerView extends TextView {
private long efftiveTime;
private long crTime;
private Timer timer;
private TimerListener mListener;
public MyTimerView(Context context, AttributeSet attrs) {
super(context, attrs);
}
/********
* @param efftiveTime
* 失效时间
* @param crTime
* 创建时间
* @param listener
*/
public void setTime(long efftiveTime, long crTime, TimerListener listener) {
this.efftiveTime = efftiveTime;
this.crTime = crTime;
this.mListener = listener;
showEffTime();
startTimer();
}
private void showEffTime() {
long mTime = efftiveTime - (System.currentTimeMillis() - crTime);
if (mTime > 0) {
int day = 0;
int hour = 0;
int min = 0;
int seconds = (int) (mTime / 1000);
if (seconds > 60) {
min = seconds / 60;
seconds = seconds % 60;
if (min > 60) {
hour = min / 60;
min = min % 60;
if (hour > 24) {
day = hour / 24;
hour = hour % 24;
}
}
}
StringBuilder builder = new StringBuilder();
builder.append("剩余");
if (day > 0) {
builder.append(day + "天 ");
}
dealTime(true, hour, builder);
dealTime(false, min, builder);
setText(builder.toString());
setVisibility(VISIBLE);
} else {
if (mListener != null) {
mListener.onTimeFinish();
}
setVisibility(GONE);
if (timer != null) {
timer.cancel();
timer = null;
}
}
}
private void dealTime(boolean isHour, int hms, StringBuilder builder) {
if (hms < 10) {
builder.append("0");
}
builder.append(hms);
if (isHour) {
builder.append("时");
} else {
builder.append("分");
}
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
if (timer != null) {
timer.cancel();
}
if (handler != null) {
handler.removeCallbacksAndMessages(null);
}
}
/*****
* 开始计时
*/
public void startTimer() {
timer = new Timer();
timer.schedule(new RemindTask(), 0, 1000);
}
class RemindTask extends TimerTask {
@Override
public void run() {
handler.sendEmptyMessage(0);
}
}
private Handler handler = new Handler(Looper.getMainLooper()) {
@Override
public void handleMessage(Message msg) {
showEffTime();
}
};
public interface TimerListener {
void onTimeFinish();
}
}
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#ffffff" />
<corners android:radius="10dip" />
<stroke
android:width="1px"
android:color="@color/colorGray" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="@dimen/size_60"
android:gravity="center">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/size_10"
android:layout_marginTop="@dimen/size_5"
android:layout_marginRight="@dimen/size_10"
android:layout_marginBottom="@dimen/size_5"
android:background="@drawable/bg_income_item">
<com.base.utils.ui.image.round.RoundImageView
android:id="@+id/rimg_header"
android:layout_width="@dimen/size_30"
android:layout_height="@dimen/size_30"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/size_5" />
<TextView
android:id="@+id/tv_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/size_5"
android:layout_toRightOf="@id/rimg_header"
android:textSize="@dimen/sp_14" />
<TextView
android:id="@+id/tv_ac_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="@dimen/text_10"
android:textColor="@color/gray_707070"
android:textSize="@dimen/sp_14" />
</RelativeLayout>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="@dimen/size_60"
android:gravity="center">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/size_10"
android:layout_marginTop="@dimen/size_5"
android:layout_marginRight="@dimen/size_10"
android:layout_marginBottom="@dimen/size_5"
android:background="@drawable/bg_income_item">
<com.base.utils.ui.image.round.RoundImageView
android:id="@+id/rimg_header"
android:layout_width="@dimen/size_30"
android:layout_height="@dimen/size_30"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/size_5" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/size_5"
android:layout_toRightOf="@id/rimg_header"
android:gravity="center_vertical"
android:orientation="vertical">
<TextView
android:id="@+id/tv_income_record"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/sp_14" />
<TextView
android:id="@+id/tv_income_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/colorGray"
android:textSize="@dimen/text_10" />
</LinearLayout>
<com.rv.share.view.MyTimerView
android:id="@+id/tv_remain_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="@dimen/text_10"
android:textColor="@color/gray_707070"
android:textSize="@dimen/sp_14" />
</RelativeLayout>
</LinearLayout>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment