androidx版本首次提交

This commit is contained in:
18401019693
2022-07-18 15:31:45 +08:00
commit 1791a114e3
2932 changed files with 218954 additions and 0 deletions

View File

@@ -0,0 +1,703 @@
package com.yunbao.common;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Environment;
import android.text.TextUtils;
import android.util.Log;
import android.util.SparseArray;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yunbao.common.bean.ConfigBean;
import com.yunbao.common.bean.FansMedalBean;
import com.yunbao.common.bean.LevelBean;
import com.yunbao.common.bean.UserBean;
import com.yunbao.common.bean.UserItemBean;
import com.yunbao.common.http.CommonHttpUtil;
import com.yunbao.common.interfaces.CommonCallback;
import com.yunbao.common.utils.L;
import com.yunbao.common.utils.SpUtil;
import com.yunbao.common.utils.WordUtil;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Created by cxf on 2017/8/4.
*/
public class CommonAppConfig {
//域名
public static final String HOST = getMetaDataString("SERVER_HOST");
//是否使用谷歌支付
public static final boolean IS_GOOGLE_PLAY = getMetaDataBoolean("IS_GOOGLE_PLAY");
//外部sd卡
public static final String DCMI_PATH = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM).getAbsolutePath();
//内部存储 /data/data/<application package>/files目录
public static final String INNER_PATH = CommonAppContext.sInstance.getFilesDir().getAbsolutePath();
//文件夹名字
private static final String DIR_NAME = "yunbao";
//保存视频的时候在sd卡存储短视频的路径DCIM下
public static final String VIDEO_PATH = DCMI_PATH + "/" + DIR_NAME + "/video/";
public static final String VIDEO_RECORD_TEMP_PATH = VIDEO_PATH + "recordParts";
//下载贴纸的时候保存的路径 /storage/emulated/0/DCIM/yunbao/tieZhi/
public static final String VIDEO_TIE_ZHI_PATH = DCMI_PATH + "/" + DIR_NAME + "/tieZhi/";
//解压的美颜模型地址
public static String VIDEO_TIE_MODEl_PATH = "";
//360贴纸名字
public static final String TIEZHI_360_NAME = "sticker360";
//下载音乐的时候保存的路径
public static final String MUSIC_PATH = DCMI_PATH + "/" + DIR_NAME + "/music/";
//拍照时图片保存路径
public static final String CAMERA_IMAGE_PATH = DCMI_PATH + "/" + DIR_NAME + "/camera/";
//log保存路径
public static final String LOG_PATH = DCMI_PATH + "/" + DIR_NAME + "/log/";
public static final String GIF_PATH = INNER_PATH + "/gif/";
//QQ登录是否与PC端互通
public static final boolean QQ_LOGIN_WITH_PC = true;
//是否使用游戏
public static final boolean GAME_ENABLE = true;
//是否上下滑动切换直播间
public static final boolean LIVE_ROOM_SCROLL = false;
//直播sdk类型是否由后台控制的
public static final boolean LIVE_SDK_CHANGED = true;
//使用指定的直播sdk类型
public static final int LIVE_SDK_USED = Constants.LIVE_SDK_KSY;
private static CommonAppConfig sInstance;
public static boolean isGetNewWrap = false;//是否获取到新的包裹礼物
public static int alert_time = 1;
public static int alert_end_time = 1;
private CommonAppConfig() {
}
public static CommonAppConfig getInstance() {
if (sInstance == null) {
synchronized (CommonAppConfig.class) {
if (sInstance == null) {
sInstance = new CommonAppConfig();
}
}
}
return sInstance;
}
private String mUid;
private String mToken;
private ConfigBean mConfig;
private double mLng;
private double mLat;
private String mProvince;//省
private String mCity;//市
private String mDistrict;//区
private UserBean mUserBean;
private String mVersion;
private boolean mLoginIM;//IM是否登录了
private boolean mLaunched;//App是否启动了
private String mJPushAppKey;//极光推送的AppKey
private List<UserItemBean> mUserItemList;//个人中心功能列表
private SparseArray<LevelBean> mLevelMap;
private SparseArray<LevelBean> mAnchorLevelMap;
private SparseArray<FansMedalBean> mAnchorFansMedalMap;
private String mGiftListJson;
private String mWrapListJson;
private String mTxMapAppKey;//腾讯定位地图的AppKey
private String mTxMapAppSecret;//腾讯地图的AppSecret
private boolean mFrontGround;
private int mAppIconRes;
private String mAppName;
private Boolean mTiBeautyEnable;//是否使用萌颜 true使用萌颜 false 使用基础美颜
public String getUid() {
if (TextUtils.isEmpty(mUid)) {
String[] uidAndToken = SpUtil.getInstance()
.getMultiStringValue(new String[]{SpUtil.UID, SpUtil.TOKEN});
if (uidAndToken != null) {
if (!TextUtils.isEmpty(uidAndToken[0]) && !TextUtils.isEmpty(uidAndToken[1])) {
mUid = uidAndToken[0];
mToken = uidAndToken[1];
}
} else {
return "-1";
}
}
return mUid;
}
public String getToken() {
return mToken;
}
public String getCoinName() {
ConfigBean configBean = getConfig();
if (configBean != null) {
return configBean.getCoinName();
}
return Constants.DIAMONDS;
}
public String getGoldCoinName() {
ConfigBean configBean = getConfig();
if (configBean != null) {
return configBean.getGoldCoinName();
}
return Constants.GOLD_NAME;
}
public String getVotesName() {
ConfigBean configBean = getConfig();
if (configBean != null) {
return configBean.getVotesName();
}
return Constants.VOTES;
}
public ConfigBean getConfig() {
if (mConfig == null) {
String configString = SpUtil.getInstance().getStringValue(SpUtil.CONFIG);
if (!TextUtils.isEmpty(configString)) {
mConfig = JSON.parseObject(configString, ConfigBean.class);
}
}
return mConfig;
}
public void getConfig(CommonCallback<ConfigBean> callback) {
if (callback == null) {
return;
}
ConfigBean configBean = getConfig();
if (configBean != null) {
callback.callback(configBean);
} else {
CommonHttpUtil.getConfig(null,callback);
}
}
public void setConfig(ConfigBean config) {
mConfig = config;
}
/**
* 经度
*/
public double getLng() {
if (mLng == 0) {
String lng = SpUtil.getInstance().getStringValue(SpUtil.LOCATION_LNG);
if (!TextUtils.isEmpty(lng)) {
try {
mLng = Double.parseDouble(lng);
} catch (Exception e) {
e.printStackTrace();
}
}
}
return mLng;
}
/**
* 纬度
*/
public double getLat() {
if (mLat == 0) {
String lat = SpUtil.getInstance().getStringValue(SpUtil.LOCATION_LAT);
if (!TextUtils.isEmpty(lat)) {
try {
mLat = Double.parseDouble(lat);
} catch (Exception e) {
e.printStackTrace();
}
}
}
return mLat;
}
/**
* 省
*/
public String getProvince() {
if (TextUtils.isEmpty(mProvince)) {
mProvince = SpUtil.getInstance().getStringValue(SpUtil.LOCATION_PROVINCE);
}
return mProvince == null ? "" : mProvince;
}
/**
* 市
*/
public String getCity() {
if (TextUtils.isEmpty(mCity)) {
mCity = SpUtil.getInstance().getStringValue(SpUtil.LOCATION_CITY);
}
return mCity == null ? "" : mCity;
}
/**
* 区
*/
public String getDistrict() {
if (TextUtils.isEmpty(mDistrict)) {
mDistrict = SpUtil.getInstance().getStringValue(SpUtil.LOCATION_DISTRICT);
}
return mDistrict == null ? "" : mDistrict;
}
public void setUserBean(UserBean bean) {
mUserBean = bean;
}
public UserBean getUserBean() {
if (mUserBean == null) {
String userBeanJson = SpUtil.getInstance().getStringValue(SpUtil.USER_INFO);
if (!TextUtils.isEmpty(userBeanJson)) {
mUserBean = JSON.parseObject(userBeanJson, UserBean.class);
}
}
return mUserBean;
}
/**
* 设置萌颜是否可用
*/
public void setTiBeautyEnable(boolean tiBeautyEnable) {
mTiBeautyEnable = tiBeautyEnable;
SpUtil.getInstance().setBooleanValue(SpUtil.TI_BEAUTY_ENABLE, tiBeautyEnable);
}
public boolean isTiBeautyEnable() {
if (mTiBeautyEnable == null) {
mTiBeautyEnable = SpUtil.getInstance().getBooleanValue(SpUtil.TI_BEAUTY_ENABLE);
}
return mTiBeautyEnable;
}
/**
* 设置登录信息
*/
public void setLoginInfo(String uid, String token, boolean save) {
L.e("登录成功", "uid------>" + uid);
L.e("登录成功", "token------>" + token);
mUid = uid;
mToken = token;
if (save) {
Map<String, String> map = new HashMap<>();
map.put(SpUtil.UID, uid);
map.put(SpUtil.TOKEN, token);
SpUtil.getInstance().setMultiStringValue(map);
}
}
/**
* 清除登录信息
*/
public void clearLoginInfo() {
mUid = null;
mToken = null;
mLoginIM = false;
SpUtil.getInstance().removeValue(
SpUtil.UID, SpUtil.TOKEN, SpUtil.USER_INFO, SpUtil.IM_LOGIN
);
}
/**
* 设置位置信息
*
* @param lng 经度
* @param lat 纬度
* @param province 省
* @param city 市
*/
public void setLocationInfo(double lng, double lat, String province, String city, String district) {
mLng = lng;
mLat = lat;
mProvince = province;
mCity = city;
mDistrict = district;
Map<String, String> map = new HashMap<>();
map.put(SpUtil.LOCATION_LNG, String.valueOf(lng));
map.put(SpUtil.LOCATION_LAT, String.valueOf(lat));
map.put(SpUtil.LOCATION_PROVINCE, province);
map.put(SpUtil.LOCATION_CITY, city);
map.put(SpUtil.LOCATION_DISTRICT, district);
SpUtil.getInstance().setMultiStringValue(map);
}
/**
* 清除定位信息
*/
public void clearLocationInfo() {
mLng = 0;
mLat = 0;
mProvince = null;
mCity = null;
mDistrict = null;
SpUtil.getInstance().removeValue(
SpUtil.LOCATION_LNG,
SpUtil.LOCATION_LAT,
SpUtil.LOCATION_PROVINCE,
SpUtil.LOCATION_CITY,
SpUtil.LOCATION_DISTRICT);
}
public boolean isLoginIM() {
return mLoginIM;
}
public void setLoginIM(boolean loginIM) {
mLoginIM = loginIM;
}
/**
* 获取版本号
*/
public String getVersion() {
if (TextUtils.isEmpty(mVersion)) {
try {
PackageManager manager = CommonAppContext.sInstance.getPackageManager();
PackageInfo info = manager.getPackageInfo(CommonAppContext.sInstance.getPackageName(), 0);
mVersion = info.versionName;
} catch (Exception e) {
e.printStackTrace();
}
}
return mVersion;
}
/**
* 获取App名称
*/
public String getAppName() {
if (TextUtils.isEmpty(mAppName)) {
int res = CommonAppContext.sInstance.getResources().getIdentifier("app_name", "string", "myname.pdlive.shayu");
mAppName = WordUtil.getString(res);
}
return mAppName;
}
/**
* 获取App图标的资源id
*/
public int getAppIconRes() {
if (mAppIconRes == 0) {
mAppIconRes = CommonAppContext.sInstance.getResources().getIdentifier("ic_launcher", "mipmap", CommonAppContext.sInstance.getPackageName());
}
return mAppIconRes;
}
/**
* 获取MetaData中的极光AppKey
*/
public String getJPushAppKey() {
if (mJPushAppKey == null) {
mJPushAppKey = getMetaDataString("JPUSH_APPKEY");
}
return mJPushAppKey;
}
/**
* 获取MetaData中的腾讯定位地图的AppKey
*
* @return
*/
public String getTxMapAppKey() {
if (mTxMapAppKey == null) {
mTxMapAppKey = getMetaDataString("TencentMapSDK");
}
return mTxMapAppKey;
}
/**
* 获取MetaData中的腾讯定位地图的AppSecret
*
* @return
*/
public String getTxMapAppSecret() {
if (mTxMapAppSecret == null) {
mTxMapAppSecret = getMetaDataString("TencentMapAppSecret");
}
return mTxMapAppSecret;
}
private static String getMetaDataString(String key) {
String res = null;
try {
ApplicationInfo appInfo = CommonAppContext.sInstance.getPackageManager().getApplicationInfo(CommonAppContext.sInstance.getPackageName(), PackageManager.GET_META_DATA);
res = appInfo.metaData.getString(key);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
Log.i("tag","url:"+res);
return res;
}
private static boolean getMetaDataBoolean(String key) {
boolean res = false;
try {
ApplicationInfo appInfo = CommonAppContext.sInstance.getPackageManager().getApplicationInfo(CommonAppContext.sInstance.getPackageName(), PackageManager.GET_META_DATA);
res = appInfo.metaData.getBoolean(key);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
return res;
}
/**
* 个人中心功能列表
*/
public List<UserItemBean> getUserItemList() {
if (mUserItemList == null || mUserItemList.size() == 0) {
String userBeanJson = SpUtil.getInstance().getStringValue(SpUtil.USER_INFO);
if (!TextUtils.isEmpty(userBeanJson)) {
JSONObject obj = JSON.parseObject(userBeanJson);
if (obj != null) {
setUserItemList(obj.getString("list"));
}
}
}
return mUserItemList;
}
public void setUserItemList(String listString) {
UserItemBean[][] arr = JSON.parseObject(listString, UserItemBean[][].class);
if (arr != null && arr.length > 0) {
List<UserItemBean> newList = new ArrayList<>();
for (int i = 0, length1 = arr.length; i < length1; i++) {
for (int j = 0, length2 = arr[i].length; j < length2; j++) {
UserItemBean bean = arr[i][j];
if (j == length2 - 1) {
if (i < length1 - 1) {
bean.setGroupLast(true);
} else {
bean.setAllLast(true);
}
}
newList.add(bean);
}
}
mUserItemList = newList;
}
}
/**
* 保存用户等级信息
*/
public void setLevel(String levelJson) {
if (TextUtils.isEmpty(levelJson)) {
return;
}
List<LevelBean> list = JSON.parseArray(levelJson, LevelBean.class);
if (list == null || list.size() == 0) {
return;
}
if (mLevelMap == null) {
mLevelMap = new SparseArray<>();
}
mLevelMap.clear();
for (LevelBean bean : list) {
mLevelMap.put(bean.getLevel(), bean);
}
}
/**
* 保存主播等级信息
*/
public void setAnchorLevel(String anchorLevelJson) {
if (TextUtils.isEmpty(anchorLevelJson)) {
return;
}
List<LevelBean> list = JSON.parseArray(anchorLevelJson, LevelBean.class);
if (list == null || list.size() == 0) {
return;
}
if (mAnchorLevelMap == null) {
mAnchorLevelMap = new SparseArray<>();
}
mAnchorLevelMap.clear();
for (LevelBean bean : list) {
mAnchorLevelMap.put(bean.getLevel(), bean);
}
}
/**
* 保存主播粉丝徽章信息
*/
public void setAnchorFansMedal(String anchorMedalJson) {
if (TextUtils.isEmpty(anchorMedalJson)) {
return;
}
List<FansMedalBean> list = JSON.parseArray(anchorMedalJson, FansMedalBean.class);
if (list == null || list.size() == 0) {
return;
}
if (mAnchorFansMedalMap == null) {
mAnchorFansMedalMap = new SparseArray<>();
}
mAnchorFansMedalMap.clear();
for (FansMedalBean bean : list) {
mAnchorFansMedalMap.put(bean.getLevel(), bean);
}
}
/**
* 获取主播粉丝徽章信息
*/
public FansMedalBean getAnchorFansMedal(int level) {
if (mAnchorFansMedalMap == null) {
String configString = SpUtil.getInstance().getStringValue(SpUtil.CONFIG);
if (!TextUtils.isEmpty(configString)) {
JSONObject obj = JSON.parseObject(configString);
setAnchorFansMedal(obj.getString("levelfans"));
}
}
if (mAnchorFansMedalMap == null || mAnchorFansMedalMap.size() == 0) {
return null;
}
return mAnchorFansMedalMap.get(level);
}
/**
* 获取用户等级
*/
public LevelBean getLevel(int level) {
if (mLevelMap == null) {
String configString = SpUtil.getInstance().getStringValue(SpUtil.CONFIG);
if (!TextUtils.isEmpty(configString)) {
JSONObject obj = JSON.parseObject(configString);
setLevel(obj.getString("level"));
}
}
if (mLevelMap == null || mLevelMap.size() == 0) {
return null;
}
return mLevelMap.get(level);
}
/**
* 获取主播等级
*/
public LevelBean getAnchorLevel(int level) {
if (mAnchorLevelMap == null) {
String configString = SpUtil.getInstance().getStringValue(SpUtil.CONFIG);
if (!TextUtils.isEmpty(configString)) {
JSONObject obj = JSON.parseObject(configString);
setAnchorLevel(obj.getString("levelanchor"));
}
}
if (mAnchorLevelMap == null || mAnchorLevelMap.size() == 0) {
return null;
}
return mAnchorLevelMap.get(level);
}
public String getGiftListJson() {
return mGiftListJson;
}
public void setGiftListJson(String getGiftListJson) {
mGiftListJson = getGiftListJson;
}
public String getWrapListJson() {
return mWrapListJson;
}
public void setWrapListJson(String wrapListJson) {
mWrapListJson = wrapListJson;
}
/**
* 判断某APP是否安装
*/
public static boolean isAppExist(String packageName) {
if (!TextUtils.isEmpty(packageName)) {
PackageManager manager = CommonAppContext.sInstance.getPackageManager();
List<PackageInfo> list = manager.getInstalledPackages(0);
for (PackageInfo info : list) {
if (packageName.equalsIgnoreCase(info.packageName)) {
return true;
}
}
}
return false;
}
public boolean isLaunched() {
return mLaunched;
}
public void setLaunched(boolean launched) {
mLaunched = launched;
}
//app是否在前台
public boolean isFrontGround() {
return mFrontGround;
}
//app是否在前台
public void setFrontGround(boolean frontGround) {
mFrontGround = frontGround;
}
//设置美颜类型
public void setBeautySdkType(String sproutType) {
SpUtil.getInstance().setStringValue(SpUtil.BEAUTY_SDK_TYPE, sproutType);
}
public String getBeautySdkType() {
return SpUtil.getInstance().getStringValue(SpUtil.BEAUTY_SDK_TYPE);
}
//设置是否显示转盘功能
public void setTurnTableEnable(String enable) {
SpUtil.getInstance().setStringValue(SpUtil.TURNTABLE_ENABLE, enable);
}
public String getTurnTableEnable() {
return SpUtil.getInstance().getStringValue(SpUtil.TURNTABLE_ENABLE);
}
//设置360美颜贴纸下载地址
public void setBeauty360TieZhiUrl(String tieZhiUrl) {
SpUtil.getInstance().setStringValue(SpUtil.BEAUTY_360_TIEZHI_URL, tieZhiUrl);
}
public String getBeauty360TieZhiUrl() {
return SpUtil.getInstance().getStringValue(SpUtil.BEAUTY_360_TIEZHI_URL);
}
//360贴纸已经下载过
public void setBeauty360TieZhiExist(boolean isExist) {
SpUtil.getInstance().setBooleanValue(SpUtil.BEAUTY_360_TIEZHI_EXIST, isExist);
}
public boolean getBeauty360TieZhiExist() {
return SpUtil.getInstance().getBooleanValue(SpUtil.BEAUTY_360_TIEZHI_EXIST);
}
//设置主播pk时间
public void setAnchorPkTime(String pkTime){
SpUtil.getInstance().setStringValue(SpUtil.ANCHOR_PK_TIME, pkTime);
}
public String getAnchorPkTime(){
return SpUtil.getInstance().getStringValue(SpUtil.ANCHOR_PK_TIME);
}
}

View File

@@ -0,0 +1,132 @@
package com.yunbao.common;
import android.app.Activity;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import androidx.multidex.MultiDex;
import androidx.multidex.MultiDexApplication;
import android.util.Log;
import com.facebook.FacebookSdk;
import com.facebook.appevents.AppEventsLogger;
import com.google.firebase.analytics.FirebaseAnalytics;
import com.yunbao.common.http.CommonHttpUtil;
import com.yunbao.common.utils.L;
import java.util.Locale;
import me.leolin.shortcutbadger.ShortcutBadger;
import static com.facebook.FacebookSdk.setAdvertiserIDCollectionEnabled;
import static com.facebook.FacebookSdk.setAutoLogAppEventsEnabled;
/**
* Created by cxf on 2017/8/3.
*/
public class CommonAppContext extends MultiDexApplication {
public static CommonAppContext sInstance;
private int mCount;
private boolean mFront;//是否前台
public static int jpushMsgNum;
public static int Ingroup = 0;
public static String lang = "chinese";
public static FirebaseAnalytics mFirebaseAnalytics;
public static AppEventsLogger logger;
@Override
public void onCreate() {
super.onCreate();
sInstance = this;
//初始化Http
CommonHttpUtil.init();
//初始化友盟统计
// UMConfigure.init(this, UMConfigure.DEVICE_TYPE_PHONE, null);
FacebookSdk.sdkInitialize(getApplicationContext());
mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
mFirebaseAnalytics.setAnalyticsCollectionEnabled(true);
mFirebaseAnalytics.setUserProperty("ALLOW_AD_PERSONALIZATION_SIGNALS", "true" );
logger = AppEventsLogger.newLogger(this);
setAutoLogAppEventsEnabled(true);
FacebookSdk.fullyInitialize();
setAdvertiserIDCollectionEnabled(true);
registerActivityLifecycleCallbacks();
Locale locale;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
locale = getResources().getConfiguration().getLocales().get(0);
} else {
locale = getResources().getConfiguration().locale;
}
if(locale.getLanguage().equals("en")){
lang = "english";
}else{
lang = "chinese";
}
Log.i("lang",lang);
}
@Override
protected void attachBaseContext(Context base) {
MultiDex.install(this);
super.attachBaseContext(base);
}
private void registerActivityLifecycleCallbacks() {
registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacks() {
@Override
public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
}
@Override
public void onActivityStarted(Activity activity) {
mCount++;
if (!mFront) {
mFront = true;
L.e("AppContext------->处于前台");
ShortcutBadger.applyCount(activity,0);
jpushMsgNum=0;
CommonAppConfig.getInstance().setFrontGround(true);
}
}
@Override
public void onActivityResumed(Activity activity) {
}
@Override
public void onActivityPaused(Activity activity) {
}
@Override
public void onActivityStopped(Activity activity) {
mCount--;
if (mCount == 0) {
mFront = false;
L.e("AppContext------->处于后台");
CommonAppConfig.getInstance().setFrontGround(false);
}
}
@Override
public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
}
@Override
public void onActivityDestroyed(Activity activity) {
}
});
}
}

View File

@@ -0,0 +1,276 @@
package com.yunbao.common;
import com.yunbao.common.bean.ChatRemarksBean;
import java.util.ArrayList;
import java.util.List;
/**
* Created by cxf on 2018/6/7.
*/
public class Constants {
public static final String URL = "url";
public static final String PAYLOAD = "payload";
public static final String SEX = "sex";
public static final String NICK_NAME = "nickname";
public static final String REMARKS = "remarks";
public static final String AVATAR = "avatar";
public static final String SIGN = "sign";
public static final String TO_UID = "toUid";
public static final String INTOINDEX = "intoIndex";
public static final String FROM_LIVE_ROOM = "fromLiveRoom";
public static final String TO_NAME = "toName";
public static final String STREAM = "stream";
public static final String LIMIT = "limit";
public static final String UID = "uid";
public static final String TIP = "tip";
public static final String SHOW_INVITE = "showInvite";
public static final String USER_BEAN = "userBean";
public static final String CLASS_ID = "classID";
public static final String CLASS_NAME = "className";
public static final String CHECKED_ID = "checkedId";
public static final String CHECKED_COIN = "checkedCoin";
public static final String LIVE_DANMU_PRICE = "danmuPrice";
public static final String COIN_NAME = "coinName";
public static final String LIVE_BEAN = "liveBean";
public static final String LIVE_TYPE = "liveType";
public static final String LIVE_KEY = "liveKey";
public static final String LIVE_POSITION = "livePosition";
public static final String LIVE_TYPE_VAL = "liveTypeVal";
public static final String LIVE_UID = "liveUid";
public static final String LIVE_STREAM = "liveStream";
public static final String LIVE_WISH_GIFTID = "wishGiftId";
public static final String LIVE_HOME = "liveHome";
public static final String LIVE_FOLLOW = "liveFollow";
public static final String LIVE_NEAR = "liveNear";
public static final String LIVE_CLASS_PREFIX = "liveClass_";
public static final String LIVE_ADMIN_ROOM = "liveAdminRoom";
public static final String HAS_GAME = "hasGame";
public static final String OPEN_FLASH = "openFlash";
public static final String SHARE_QR_CODE_FILE = "shareQrCodeFile.png";
public static final String ANCHOR = "anchor";
public static final String FOLLOW = "follow";
public static final String DIAMONDS = "钻石";
public static final String GOLD_NAME = "金币";
public static final String VOTES = "映票";
public static final String PAY_ALI_NOT_ENABLE = "支付宝未接入";
public static final String PAY_WX_NOT_ENABLE = "微信支付未接入";
public static final String PAY_ALL_NOT_ENABLE = "未开启支付";
public static final String PAY_TYPE_ALI = "ali";
public static final String PAY_TYPE_WX = "wx";
public static final String PAY_TYPE_HW = "hw";
public static final String PAY_TYPE_HFB = "hfb";
public static final String PAY_TYPE_YUNQU = "yunqu";//海外直播支付yunqu
public static final String PAY_TYPE_PAYSSION = "payssion";//payssion支付
public static final String PAY_TYPE_PAYPAL = "paypal";//paypal支付
public static final String PAY_TYPE_GOOGLE = "google";//google支付
public static final String PAY_BUY_COIN_ALI = "Charge.getAliOrder";
public static final String PAY_BUY_COIN_WX = "Charge.getWxOrder";
public static final String PACKAGE_NAME_ALI = "com.eg.android.AlipayGphone";//支付宝的包名
public static final String PACKAGE_NAME_WX = "com.tencent.mm";//微信的包名
public static final String PACKAGE_NAME_QQ = "com.tencent.mobileqq";//QQ的包名
public static final String LAT = "lat";
public static final String LNG = "lng";
public static final String ADDRESS = "address";
public static final String SCALE = "scale";
public static final String SELECT_IMAGE_PATH = "selectedImagePath";
public static final String COPY_PREFIX = "copy://";
public static final int GUARD_TYPE_NONE = 0;
public static final int GUARD_TYPE_DAY = 1;
public static final int GUARD_TYPE_MONTH = 2;
public static final int GUARD_TYPE_YEAR = 3;
public static final String GIF_GIFT_PREFIX = "gif_gift_";
public static final String GIF_CAR_PREFIX = "gif_car_";
public static final String DOWNLOAD_MUSIC = "downloadMusic";
public static final String LINK = "link";
public static final String REPORT = "report";
public static final String SAVE = "save";
public static final String DELETE = "delete";
public static final String SHARE_FROM = "shareFrom";
public static final int SHARE_FROM_LIVE = 101;
public static final int SHARE_FROM_HOME = 102;
public static final int SETTING_MODIFY_PWD = 15;
public static final int SETTING_UPDATE_ID = 16;
public static final int SETTING_CLEAR_CACHE = 18;
public static final int SETTING_ISBLACK = 20;
public static final int SEX_MALE = 1;
public static final int SEX_FEMALE = 2;
public static final int FOLLOW_FROM_FOLLOW = 1002;
public static final int FOLLOW_FROM_FANS = 1003;
public static final int FOLLOW_FROM_SEARCH = 1004;
public static final String IM_FROM_HOME = "imFromHome";
//直播房间类型
public static final int LIVE_TYPE_NORMAL = 0;//普通房间
public static final int LIVE_TYPE_PWD = 1;//密码房间
public static final int LIVE_TYPE_PAY = 2;//收费房间
public static final int LIVE_TYPE_TIME = 3;//计时房间
public static final int LIVE_TYPE_RESTING = 4;//休息中
//主播直播间功能
public static final int LIVE_FUNC_BEAUTY = 2001;//美颜
public static final int LIVE_FUNC_CAMERA = 2002;//切换摄像头
public static final int LIVE_FUNC_FLASH = 2003;//闪光灯
public static final int LIVE_FUNC_MUSIC = 2004;//伴奏
public static final int LIVE_FUNC_SHARE = 2005;//分享
public static final int LIVE_FUNC_GAME = 2006;//游戏
public static final int LIVE_FUNC_RED_PACK = 2007;//红包
public static final int LIVE_FUNC_LINK_MIC = 2008;//连麦
public static final int LIVE_FUNC_WISHLIST = 2009;//心愿单
public static final int LIVE_FUNC_MIRROR = 2010;//鏡像
public static final int LIVE_FUNC_ZG = 2011;//鏡像
public static final int LIVE_FUNC_DR = 2012;//多人
public static final int LIVE_FUNC_MIC = 2013;//語音
public static final int LIVE_FUNC_WKS = 2014;//語音
public static final int LIVE_FUNC_ZSLK = 2015;//語音
//socket
public static final String SOCKET_CONN = "conn";
public static final String SOCKET_BROADCAST = "broadcastingListen";
public static final String SOCKET_SEND = "broadcast";
public static final String SOCKET_STOP_PLAY = "stopplay";//超管关闭直播间
public static final String SOCKET_STOP_LIVE = "stopLive";//超管关闭直播间
public static final String SOCKET_SEND_MSG = "SendMsg";//发送文字消息,点亮,用户进房间 PS:这种混乱的设计是因为服务器端逻辑就是这样设计的,客户端无法自行修改
public static final String SOCKET_LIGHT = "light";//飘心
public static final String SOCKET_SEND_GIFT = "SendGift";//送礼物
public static final String SOCKET_ALL_SERVER_NOTIFY = "AllServerNotify";//全服通知
public static final String SOCKET_SEND_BARRAGE = "SendBarrage";//发弹幕
public static final String SOCKET_LIVE_DRPK = "LiveDRPK";//多人PK
public static final String SOCKET_LEAVE_ROOM = "disconnect";//用户离开房间
public static final String SOCKET_LIVE_END = "StartEndLive";//主播关闭直播
public static final String SOCKET_SYSTEM = "SystemNot";//系统消息
public static final String UP_USER_LIST = "upuserlist";//更新用戶列表
public static final String LIAN_MAI = "LivePKDRLM";//用户连麦
public static final String CARD = "card";//活动
public static final String SOCKET_KICK = "KickUser";//踢人
public static final String SOCKET_SHUT_UP = "ShutUpUser";//禁言
public static final String SOCKET_SET_ADMIN = "setAdmin";//设置或取消管理员
public static final String SOCKET_CHANGE_LIVE = "changeLive";//切换计时收费类型
public static final String SOCKET_UPDATE_VOTES = "updateVotes";//门票或计时收费时候更新主播的映票数
public static final String SOCKET_FAKE_FANS = "requestFans";//僵尸粉
public static final String SOCKET_LINK_MIC = "ConnectVideo";//连麦
public static final String SOCKET_LINK_MIC_ANCHOR = "LiveConnect";//主播连麦
public static final String SOCKET_LINK_MIC_PK = "LivePK";//主播PK
public static final String SOCKET_BUY_GUARD = "BuyGuard";//购买守护
public static final String SOCKET_RED_PACK = "SendRed";//红包
public static final String SOCKET_LUCK_WIN = "luckWin";//幸运礼物中奖
public static final String SOCKET_PRIZE_POOL_WIN = "jackpotWin";//奖池中奖
public static final String SOCKET_PRIZE_POOL_UP = "jackpotUp";//奖池升级
//游戏socket
public static final String SOCKET_GAME_ZJH = "startGame";//炸金花
public static final String SOCKET_GAME_HD = "startLodumaniGame";//海盗船长
public static final String SOCKET_GAME_NZ = "startCattleGame";//开心牛仔
public static final String SOCKET_GAME_ZP = "startRotationGame";//幸运转盘
public static final String SOCKET_GAME_EBB = "startShellGame";//二八贝
public static final String SOCKET_SEND_ACTIVE_MSG = "SendActiveMsg";//活动,聊天显示
public static final String SOCKET_PRANKTURNTABLE = "prankTurntable";//整蛊消息
public static final String SOCKET_USEHOTCARD = "UseHotCard";//热度卡消息
public static final String LOVE_CHECK = "LoveCheck";//热度卡消息
public static final int SOCKET_WHAT_CONN = 0;
public static final int SOCKET_WHAT_DISCONN = 2;
public static final int SOCKET_WHAT_BROADCAST = 1;
//socket 用户类型
public static final int SOCKET_USER_TYPE_NORMAL = 30;//普通用户
public static final int SOCKET_USER_TYPE_ADMIN = 40;//房间管理员
public static final int SOCKET_USER_TYPE_ANCHOR = 50;//主播
public static final int SOCKET_USER_TYPE_SUPER = 60;//超管
//提现账号类型1表示支付宝2表示微信3表示银行卡
public static final int CASH_ACCOUNT_ALI = 1;
public static final int CASH_ACCOUNT_WX = 2;
public static final int CASH_ACCOUNT_BANK = 3;
public static final String CASH_ACCOUNT_ID = "cashAccountID";
public static final String CASH_ACCOUNT = "cashAccount";
public static final String CASH_ACCOUNT_TYPE = "cashAccountType";
public static final int RED_PACK_TYPE_AVERAGE = 0;//平均红包
public static final int RED_PACK_TYPE_SHOU_QI = 1;//拼手气红包
public static final int RED_PACK_SEND_TIME_NORMAL = 0;//立即发放
public static final int RED_PACK_SEND_TIME_DELAY = 1;//延时发放
public static final int JPUSH_TYPE_NONE = 0;
public static final int JPUSH_TYPE_LIVE = 1;//直播
public static final int JPUSH_TYPE_MESSAGE = 2;//消息
public static final String VIDEO_HOME = "videoHome";
public static final String VIDEO_USER = "videoUser_";
public static final String VIDEO_KEY = "videoKey";
public static final String VIDEO_POSITION = "videoPosition";
public static final String VIDEO_SINGLE = "videoSingle";
public static final String VIDEO_COMMUNITY = "community";
public static final String VIDEO_PAGE = "videoPage";
public static final String VIDEO_BEAN = "videoBean";
public static final String VIDEO_ID = "videoId";
public static final String VIDEO_COMMENT_BEAN = "videoCommnetBean";
public static final String VIDEO_FACE_OPEN = "videoOpenFace";
public static final String VIDEO_FACE_HEIGHT = "videoFaceHeight";
public static final String VIDEO_DURATION = "videoDuration";
public static final String VIDEO_PATH = "videoPath";
public static final String VIDEO_FROM_RECORD = "videoFromRecord";
public static final String VIDEO_MUSIC_BEAN = "videoMusicBean";
public static final String VIDEO_MUSIC_ID = "videoMusicId";
public static final String VIDEO_HAS_BGM = "videoHasBgm";
public static final String VIDEO_MUSIC_NAME_PREFIX = "videoMusicName_";
public static final String VIDEO_SAVE_TYPE = "videoSaveType";
public static final int VIDEO_SAVE_SAVE_AND_PUB = 1;//保存并发布
public static final int VIDEO_SAVE_SAVE = 2;//仅保存
public static final int VIDEO_SAVE_PUB = 3;//仅发布
public static final String MOB_QQ = "qq";
public static final String MOB_QZONE = "qzone";
public static final String MOB_WX = "wx";
public static final String MOB_WX_PYQ = "wchat";
public static final String MOB_FACEBOOK = "facebook";
public static final String MOB_TWITTER = "twitter";
public static final String MOB_PHONE = "phone";
public static final String LIVE_SDK = "liveSdk";
public static final String LIVE_KSY_CONFIG = "liveKsyConfig";
public static final int LIVE_SDK_KSY = 0;//金山推流
public static final int LIVE_SDK_TX = 1;//腾讯推流
public static final int LINK_MIC_TYPE_NORMAL = 0;//观众与主播连麦
public static final int LINK_MIC_TYPE_ANCHOR = 1;//主播与主播连麦
//视频举报获取位置
public static int xIndex = 0;
public static int yindex = 0;
public static String isBlack;
public static String nowPostsId = "";
public static String myAvatar = "";
public static String myUid = "";
public static String myName = "";
public static int myIntoIndex = 0;
public static String chatActionUrl = "";
public static String myUrl = "";
public static String mStream = "";
public static String nowSendUid = "";//获取当前会话新信息用于会话列表显示
public static boolean isAnchor = false;
public static String myPackageUrl = "";
public static boolean isTitle = false;
public static int isShowPage = -1;
public static boolean LoginKefu = true;//是否是从客服进入
public static String nowAnchorName = "";//当前主播昵称
public static String isSend = "0";//是否能发言enterroom接口返回1 可发言 0 不可发言
public static String nowId = "";//当前点击了某个单聊的id
public static String remarks = "";//当前点击了某个单聊的备注
public static String isAdmin = "0";//当前点击了某个单聊是否是指导员
public static List<ChatRemarksBean> remarksListNow = new ArrayList<>();//存储的备注
public static int getWeekIntIndex = 0;//是否刷新了周星列表
public static boolean isInstructor = false;//是否是管理员
public static String isSetRemark = "";//是否有修改备注
public static String isSetRemarkText = "";//修改的备注信息
public static boolean isShowLiveDialog = false;//是否在直播间打开单聊
public static int firstInto = 0;//
}

View File

@@ -0,0 +1,61 @@
package com.yunbao.common;
/**
* Created by cxf on 2018/10/15.
*/
public class HtmlConfig {
//登录即代表同意服务和隐私条款
public static final String LOGIN_PRIVCAY = CommonAppConfig.HOST + "/index.php?g=portal&m=page&a=index&id=3";
public static final String LOGIN_PRIVCAY1 = CommonAppConfig.HOST + "/portal/page/index/id/59";
//注册用户协议
public static final String REG_PRIVCAY1 = CommonAppConfig.HOST + "/index.php?g=portal&m=page&a=index&id=2";
public static final String REG_PRIVCAY2 = CommonAppConfig.HOST + "/index.php?g=portal&m=page&a=index&id=3";
//直播间贡献榜
public static final String LIVE_LIST = CommonAppConfig.HOST + "/index.php?g=Appapi&m=contribute&a=index&uid=";
//直播间粉丝排行榜
public static final String LIVE_FANS_MEDAL_RANKING = CommonAppConfig.HOST + "/index.php?g=Appapi&m=Fans&a=fansranking&uid=";
//个人主页分享链接
public static final String SHARE_HOME_PAGE = CommonAppConfig.HOST + "/index.php?g=Appapi&m=home&a=index&touid=";
//提现记录
public static final String CASH_RECORD = CommonAppConfig.HOST + "/index.php?g=Appapi&m=cash&a=index";
//支付宝充值回调地址
public static final String ALI_PAY_COIN_URL = CommonAppConfig.HOST + "/Appapi/Pay/notify_ali";
//谷歌支付回调地址
public static final String GOOGLE_PAY_COIN_URL = CommonAppConfig.HOST + "/Appapi/Pay/";
//视频分享地址
public static final String SHARE_VIDEO = CommonAppConfig.HOST + "/index.php?g=appapi&m=video&a=index&videoid=";
//直播间幸运礼物说明
public static final String LUCK_GIFT_TIP = CommonAppConfig.HOST + "/index.php?g=portal&m=page&a=index&id=26";
//直播间玩家看到的心愿单
public static final String WISHLIST_URL = CommonAppConfig.HOST + "/index.php?g=Appapi&m=Wish&a=index";
//直播间玩家看到的转盘
public static final String TURNTABLE_URL = CommonAppConfig.HOST + "/Appapi/Turntable/index";
//在线商城
public static final String SHOP = CommonAppConfig.HOST + "/h5/shoppingMall.html";
//社区
public static final String ENCOURAGE = CommonAppConfig.HOST + "/h5/shequ/index.html#/h5/shequ";
//个人信息
public static final String PERSONAL = CommonAppConfig.HOST + "/h5/shequ/index.html#/h5/shequ/Personal";
//我的徽章 右上角问号
public static final String MEDAL_QUESTION = CommonAppConfig.HOST + "/index.php?g=Appapi&m=Fans&a=rule&isfans=1";
//我的明细
public static final String DETAIL = CommonAppConfig.HOST + "/index.php?g=Appapi&m=Detail&a=index";
//充值协议
public static final String CHARGE_PRIVCAY = CommonAppConfig.HOST + "/index.php?g=portal&m=page&a=index&id=6";
//充值说明
public static final String CHARGE_EXPLAIN = CommonAppConfig.HOST + "/index.php?g=portal&m=page&a=index&id=41";
}

View File

@@ -0,0 +1,348 @@
package com.yunbao.common.activity;
import android.app.Activity;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Rect;
import android.os.Build;
import android.os.Bundle;
import android.provider.Settings;
import android.text.TextUtils;
import android.view.KeyCharacterMap;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewTreeObserver;
import android.view.Window;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.TextView;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import com.yunbao.common.R;
import com.yunbao.common.interfaces.LifeCycleListener;
import com.yunbao.common.utils.ClickUtil;
import java.util.ArrayList;
import java.util.List;
/**
* Created by cxf on 2017/8/3.
*/
public abstract class AbsActivity extends AppCompatActivity {
protected String mTag;
protected Activity mContext;
protected List<LifeCycleListener> mLifeCycleListeners;
@Override
public Resources getResources() {
Resources res = super.getResources();
Configuration config = new Configuration();
config.setToDefaults();
res.updateConfiguration(config, res.getDisplayMetrics());
return res;
}
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mTag = this.getClass().getSimpleName();
setStatusBar();
setContentView(getLayoutId());
mContext = this;
mLifeCycleListeners = new ArrayList<>();
main(savedInstanceState);
if (mLifeCycleListeners != null) {
for (LifeCycleListener listener : mLifeCycleListeners) {
listener.onCreate();
}
}
}
protected abstract int getLayoutId();
protected void main(Bundle savedInstanceState) {
main();
}
protected void main() {
}
protected boolean isStatusBarWhite() {
return false;
}
protected void setTitle(String title) {
TextView titleView = (TextView) findViewById(R.id.titleView);
if (titleView != null) {
titleView.setText(title);
}
}
public void backClick(View v) {
if (v.getId() == R.id.btn_back) {
onBackPressed();
}
}
protected boolean canClick() {
return ClickUtil.canClick();
}
/**
* 设置透明状态栏
*/
private void setStatusBar() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Window window = getWindow();
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
if (isStatusBarWhite()) {
window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
} else {
window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
}
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(0);
}
}
@Override
protected void onDestroy() {
if (mLifeCycleListeners != null) {
for (LifeCycleListener listener : mLifeCycleListeners) {
listener.onDestroy();
}
mLifeCycleListeners.clear();
mLifeCycleListeners = null;
}
super.onDestroy();
}
@Override
protected void onStart() {
super.onStart();
if (mLifeCycleListeners != null) {
for (LifeCycleListener listener : mLifeCycleListeners) {
listener.onStart();
}
}
}
@Override
protected void onRestart() {
super.onRestart();
if (mLifeCycleListeners != null) {
for (LifeCycleListener listener : mLifeCycleListeners) {
listener.onReStart();
}
}
}
@Override
protected void onResume() {
super.onResume();
if (mLifeCycleListeners != null) {
for (LifeCycleListener listener : mLifeCycleListeners) {
listener.onResume();
}
}
//友盟统计
// MobclickAgent.onResume(this);
}
@Override
protected void onPause() {
super.onPause();
if (mLifeCycleListeners != null) {
for (LifeCycleListener listener : mLifeCycleListeners) {
listener.onPause();
}
}
//友盟统计
// MobclickAgent.onPause(this);
}
@Override
protected void onStop() {
super.onStop();
if (mLifeCycleListeners != null) {
for (LifeCycleListener listener : mLifeCycleListeners) {
listener.onStop();
}
}
}
public void addLifeCycleListener(LifeCycleListener listener) {
if (mLifeCycleListeners != null && listener != null) {
mLifeCycleListeners.add(listener);
}
}
public void addAllLifeCycleListener(List<LifeCycleListener> listeners) {
if (mLifeCycleListeners != null && listeners != null) {
mLifeCycleListeners.addAll(listeners);
}
}
public void removeLifeCycleListener(LifeCycleListener listener) {
if (mLifeCycleListeners != null) {
mLifeCycleListeners.remove(listener);
}
}
//键盘遮挡问题
private View mChildOfContent;
private int usableHeightPrevious;
private FrameLayout.LayoutParams frameLayoutParams;
public void init() {
FrameLayout content = (FrameLayout) findViewById(android.R.id.content);
mChildOfContent = content.getChildAt(0);
mChildOfContent.getViewTreeObserver().addOnGlobalLayoutListener(
new ViewTreeObserver.OnGlobalLayoutListener() {
public void onGlobalLayout() {
possiblyResizeChildOfContent();
}
});
frameLayoutParams = (FrameLayout.LayoutParams) mChildOfContent
.getLayoutParams();
}
private void possiblyResizeChildOfContent() {
int usableHeightNow = computeUsableHeight();
if (usableHeightNow != usableHeightPrevious) {
int usableHeightSansKeyboard = mChildOfContent.getRootView()
.getHeight();
int heightDifference = usableHeightSansKeyboard - usableHeightNow;
if (heightDifference > (usableHeightSansKeyboard / 4)) {
frameLayoutParams.height = usableHeightSansKeyboard - heightDifference;
} else {
frameLayoutParams.height = usableHeightSansKeyboard - getNavigationBarHeightIfRoom(mContext);
;
}
mChildOfContent.requestLayout();
usableHeightPrevious = usableHeightNow;
}
}
private int computeUsableHeight() {
Rect r = new Rect();
mChildOfContent.getWindowVisibleDisplayFrame(r);
return (r.bottom - r.top);
}
public boolean checkDeviceHasNavigationBar2(Context context) {
//通过判断设备是否有返回键、菜单键(不是虚拟键,是手机屏幕外的按键)来确定是否有navigation bar
boolean hasMenuKey = ViewConfiguration.get(context)
.hasPermanentMenuKey();
boolean hasBackKey = KeyCharacterMap
.deviceHasKey(KeyEvent.KEYCODE_BACK);
if (!hasMenuKey && !hasBackKey) {
// 做任何你需要做的,这个设备有一个导航栏
return true;
}
return false;
}
public static int getNavigationBarHeightIfRoom(Context context) {
if (navigationGestureEnabled(context)) {
return 0;
}
return getCurrentNavigationBarHeight(((Activity) context));
}
/**
* 全面屏(是否开启全面屏开关 0 关闭 1 开启)
*
* @param context
* @return
*/
public static boolean navigationGestureEnabled(Context context) {
int val = Settings.Global.getInt(context.getContentResolver(), getDeviceInfo(), 0);
return val != 0;
}
/**
* 获取设备信息目前支持几大主流的全面屏手机亲测华为、小米、oppo、魅族、vivo都可以
*
* @return
*/
public static String getDeviceInfo() {
String brand = Build.BRAND;
if (TextUtils.isEmpty(brand))
return "navigationbar_is_min";
if (brand.equalsIgnoreCase("HUAWEI")) {
return "navigationbar_is_min";
} else if (brand.equalsIgnoreCase("XIAOMI")) {
return "force_fsg_nav_bar";
} else if (brand.equalsIgnoreCase("VIVO")) {
return "navigation_gesture_on";
} else if (brand.equalsIgnoreCase("OPPO")) {
return "navigation_gesture_on";
} else {
return "navigationbar_is_min";
}
}
/**
* 非全面屏下 虚拟键实际高度(隐藏后高度为0)
*
* @param activity
* @return
*/
public static int getCurrentNavigationBarHeight(Activity activity) {
if (isNavigationBarShown(activity)) {
return getNavigationBarHeight(activity);
} else {
return 0;
}
}
/**
* 非全面屏下 虚拟按键是否打开
*
* @param activity
* @return
*/
public static boolean isNavigationBarShown(Activity activity) {
//虚拟键的view,为空或者不可见时是隐藏状态
View view = activity.findViewById(android.R.id.navigationBarBackground);
if (view == null) {
return false;
}
int visible = view.getVisibility();
if (visible == View.GONE || visible == View.INVISIBLE) {
return false;
} else {
return true;
}
}
/**
* 非全面屏下 虚拟键高度(无论是否隐藏)
*
* @param context
* @return
*/
public static int getNavigationBarHeight(Context context) {
int result = 0;
int resourceId = context.getResources().getIdentifier("navigation_bar_height", "dimen", "android");
if (resourceId > 0) {
result = context.getResources().getDimensionPixelSize(resourceId);
}
return result;
}
}

View File

@@ -0,0 +1,65 @@
package com.yunbao.common.activity;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;
import com.yunbao.common.CommonAppContext;
import com.yunbao.common.R;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordUtil;
/**
* Created by cxf on 2018/8/29.
* 服务器Home.getConfig接口有时候返回的数据无法解析导致崩溃
* 这个类是用来收集服务器返回的错误的信息的
*/
public class ErrorActivity extends AbsActivity {
public static void forward(String title, String errorInfo) {
Intent intent = new Intent(CommonAppContext.sInstance, ErrorActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra("title", title);
intent.putExtra("error", errorInfo);
CommonAppContext.sInstance.startActivity(intent);
}
private TextView mTextView;
private String mErrorInfo;
@Override
protected int getLayoutId() {
return R.layout.activity_error;
}
@Override
protected void main() {
Intent intent = getIntent();
String title = intent.getStringExtra("title");
mErrorInfo = intent.getStringExtra("error");
setTitle(title);
mTextView = (TextView) findViewById(R.id.text);
mTextView.setText(mErrorInfo);
findViewById(R.id.btn_copy).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
copyError();
}
});
}
private void copyError() {
if (TextUtils.isEmpty(mErrorInfo)) {
return;
}
ClipboardManager clipboardManager = (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
ClipData clipData = ClipData.newPlainText("text", mErrorInfo);
clipboardManager.setPrimaryClip(clipData);
ToastUtil.show(WordUtil.getString(R.string.copy_success));
}
}

View File

@@ -0,0 +1,102 @@
package com.yunbao.common.activity;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.viewpager.widget.PagerAdapter;
import androidx.viewpager.widget.ViewPager;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.yunbao.common.R;
import com.yunbao.common.bean.ImageEntity;
import com.yunbao.common.utils.PreViewImageView;
import java.util.List;
/**
* Created by Haoxuan Chen on 2019/07/14.
* Description:查看图片
*/
public class PreviewImageActivity extends AbsActivity implements ViewPager.OnPageChangeListener {
// @BindView(R.id.viewPager)
ViewPager mViewPager;
// @BindView(R.id.tv_count)
TextView mCount;
View v_back;
private List<ImageEntity> mSelectedImages;
@Override
public void main(Bundle savedInstanceState) {
mViewPager = findViewById(R.id.viewPager);
mCount = findViewById(R.id.tv_count);
v_back = findViewById(R.id.v_back);
mSelectedImages = getIntent().getParcelableArrayListExtra("preview_images");
mViewPager.setAdapter(mViewPagerAdapter);
mViewPager.addOnPageChangeListener(this);
mCount.setText(String.format("%s/%s", 1, mSelectedImages.size()));
v_back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
}
@Override
public int getLayoutId() {
return R.layout.activity_preview_image;
}
private PagerAdapter mViewPagerAdapter = new PagerAdapter() {
@Override
public int getCount() {
return mSelectedImages.size();
}
@Override
public boolean isViewFromObject(@NonNull View view, @NonNull Object object) {
return view == object;
}
@NonNull
@Override
public Object instantiateItem(@NonNull ViewGroup container, int position) {
PreViewImageView imageView = new PreViewImageView(container.getContext());
// ImgLoader.display(imageView.getContext(), mSelectedImages.get(position).getPath(), imageView);
Glide.with(imageView.getContext())
.load(mSelectedImages.get(position).getPath())
.centerCrop()
.into(imageView);
container.addView(imageView);
return imageView;
}
@Override
public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
container.removeView((View) object);
}
};
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
mCount.setText(String.format("%s/%s", (position + 1), mSelectedImages.size()));
}
@Override
public void onPageScrollStateChanged(int state) {
}
}

View File

@@ -0,0 +1,304 @@
package com.yunbao.common.activity;
import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AccelerateInterpolator;
import android.widget.RelativeLayout;
import com.tencent.rtmp.ITXVodPlayListener;
import com.tencent.rtmp.TXLiveConstants;
import com.tencent.rtmp.TXVodPlayConfig;
import com.tencent.rtmp.TXVodPlayer;
import com.tencent.rtmp.ui.TXCloudVideoView;
import com.yunbao.common.R;
import com.yunbao.common.bean.ImageEntity;
import java.util.List;
/**
* Created by Haoxuan Chen on 2022/05/4.
* Description:查看视频
*/
public class PreviewVideoActivity extends AbsActivity implements ITXVodPlayListener, View.OnClickListener {
View v_back;
private List<ImageEntity> mSelectedImages;
private TXCloudVideoView mTXCloudVideoView;
private TXVodPlayer mPlayer;
private TXVodPlayConfig mTXVodPlayConfig;
private boolean mStartPlay;
private String mCachePath;
private boolean mPaused;//生命周期暂停
private boolean mClickPaused;//点击暂停
private ObjectAnimator mPlayBtnAnimator;//暂停按钮的动画
private View mPlayBtn;
private View mVideoCover;
private ActionListener mActionListener;
@Override
public void main(Bundle savedInstanceState) {
mSelectedImages = getIntent().getParcelableArrayListExtra("preview_images");
v_back = findViewById(R.id.v_back);
mTXCloudVideoView = (TXCloudVideoView) findViewById(R.id.video_view);
v_back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
playAdVideo();
}
@Override
public int getLayoutId() {
return R.layout.activity_preview_video;
}
/**
* 播放视频
*/
private void playAdVideo() {
mCachePath = mContext.getCacheDir().getAbsolutePath();
mTXCloudVideoView = (TXCloudVideoView) findViewById(R.id.video_view);
mTXCloudVideoView.setRenderMode(TXLiveConstants.RENDER_MODE_FULL_FILL_SCREEN);
mPlayer = new TXVodPlayer(mContext);
mTXVodPlayConfig = new TXVodPlayConfig();
mTXVodPlayConfig.setMaxCacheItems(15);
mTXVodPlayConfig.setProgressInterval(200);
mPlayer.setConfig(mTXVodPlayConfig);
mPlayer.setAutoPlay(true);
mPlayer.setVodListener(this);
mPlayer.setPlayerView(mTXCloudVideoView);
findViewById(R.id.root).setOnClickListener(this);
mVideoCover = findViewById(R.id.video_cover);
mPlayBtn = findViewById(R.id.btn_play);
//暂停按钮动画
mPlayBtnAnimator = ObjectAnimator.ofPropertyValuesHolder(mPlayBtn,
PropertyValuesHolder.ofFloat("scaleX", 4f, 0.8f, 1f),
PropertyValuesHolder.ofFloat("scaleY", 4f, 0.8f, 1f),
PropertyValuesHolder.ofFloat("alpha", 0f, 1f));
mPlayBtnAnimator.setDuration(150);
mPlayBtnAnimator.setInterpolator(new AccelerateInterpolator());
startPlay();
}
/**
* 开始播放
*/
public void startPlay() {
mStartPlay = false;
mClickPaused = false;
if (mVideoCover != null && mVideoCover.getVisibility() != View.VISIBLE) {
mVideoCover.setVisibility(View.VISIBLE);
}
hidePlayBtn();
String url = mSelectedImages.get(0).getPath();
if (TextUtils.isEmpty(url)) {
return;
}
if (mTXVodPlayConfig == null) {
mTXVodPlayConfig = new TXVodPlayConfig();
mTXVodPlayConfig.setMaxCacheItems(15);
mTXVodPlayConfig.setProgressInterval(200);
}
if (url.endsWith(".m3u8")) {
mTXVodPlayConfig.setCacheFolderPath(null);
} else {
mTXVodPlayConfig.setCacheFolderPath(mCachePath);
}
mPlayer.setConfig(mTXVodPlayConfig);
if (mPlayer != null) {
mPlayer.startPlay(url);
}
}
/**
* 获取到视频宽高回调
*/
public void onVideoSizeChanged(float videoWidth, float videoHeight) {
if (mTXCloudVideoView != null && videoWidth > 0 && videoHeight > 0) {
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mTXCloudVideoView.getLayoutParams();
int targetH = 0;
if (videoWidth / videoHeight > 0.5625f) {//横屏 9:16=0.5625
targetH = (int) (mTXCloudVideoView.getWidth() / videoWidth * videoHeight);
} else {
targetH = ViewGroup.LayoutParams.MATCH_PARENT;
}
if (targetH != params.height) {
params.height = targetH;
mTXCloudVideoView.requestLayout();
}
if (mVideoCover != null && mVideoCover.getVisibility() == View.VISIBLE) {
mVideoCover.setVisibility(View.INVISIBLE);
}
}
}
/**
* 停止播放
*/
public void stopPlay() {
if (mPlayer != null) {
mPlayer.stopPlay(false);
}
}
/**
* 循环播放
*/
private void replay() {
if (mPlayer != null) {
mPlayer.seek(0);
mPlayer.resume();
}
}
/**
* 显示开始播放按钮
*/
private void showPlayBtn() {
if (mPlayBtn != null && mPlayBtn.getVisibility() != View.VISIBLE) {
mPlayBtn.setVisibility(View.VISIBLE);
}
}
/**
* 隐藏开始播放按钮
*/
private void hidePlayBtn() {
if (mPlayBtn != null && mPlayBtn.getVisibility() == View.VISIBLE) {
mPlayBtn.setVisibility(View.INVISIBLE);
}
}
@Override
public void onClick(View v) {
int i = v.getId();
if (i == R.id.root) {
clickTogglePlay();
}
}
/**
* 点击切换播放和暂停
*/
private void clickTogglePlay() {
if (!mStartPlay) {
return;
}
if (mPlayer != null) {
if (mClickPaused) {
mPlayer.resume();
} else {
mPlayer.pause();
}
}
mClickPaused = !mClickPaused;
if (mClickPaused) {
showPlayBtn();
if (mPlayBtnAnimator != null) {
mPlayBtnAnimator.start();
}
} else {
hidePlayBtn();
}
}
/**
* 播放器事件回调
*/
@Override
public void onPlayEvent(TXVodPlayer txVodPlayer, int e, Bundle bundle) {
switch (e) {
case TXLiveConstants.PLAY_EVT_PLAY_BEGIN://加载完成,开始播放的回调
mStartPlay = true;
if (mActionListener != null) {
mActionListener.onPlayBegin();
}
break;
case TXLiveConstants.PLAY_EVT_PLAY_LOADING: //开始加载的回调
if (mActionListener != null) {
mActionListener.onPlayLoading();
}
break;
case TXLiveConstants.PLAY_EVT_PLAY_END://获取到视频播放完毕的回调
replay();
break;
case TXLiveConstants.PLAY_EVT_RCV_FIRST_I_FRAME://获取到视频首帧回调
if (mActionListener != null) {
mActionListener.onFirstFrame();
}
if (mPaused && mPlayer != null) {
mPlayer.pause();
}
break;
case TXLiveConstants.PLAY_EVT_CHANGE_RESOLUTION://获取到视频宽高回调
onVideoSizeChanged(bundle.getInt("EVT_PARAM1", 0), bundle.getInt("EVT_PARAM2", 0));
break;
}
}
@Override
public void onNetStatus(TXVodPlayer txVodPlayer, Bundle bundle) {
}
public void release() {
if (mPlayer != null) {
mPlayer.stopPlay(false);
mPlayer.setPlayListener(null);
}
mPlayer = null;
mActionListener = null;
}
public interface ActionListener {
void onPlayBegin();
void onPlayLoading();
void onFirstFrame();
}
public void setActionListener(ActionListener actionListener) {
mActionListener = actionListener;
}
/**
* 生命周期暂停
*/
public void pausePlay() {
mPaused = true;
if (!mClickPaused && mPlayer != null) {
mPlayer.pause();
}
}
/**
* 生命周期恢复
*/
public void resumePlay() {
if (mPaused) {
if (!mClickPaused && mPlayer != null) {
mPlayer.resume();
}
}
mPaused = false;
}
@Override
protected void onDestroy() {
super.onDestroy();
release();
}
}

View File

@@ -0,0 +1,510 @@
package com.yunbao.common.activity;
import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.Parcelable;
import android.provider.MediaStore;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.app.ActivityCompat;
import androidx.loader.app.LoaderManager;
import androidx.core.content.ContextCompat;
import androidx.loader.content.CursorLoader;
import androidx.core.content.FileProvider;
import androidx.loader.content.Loader;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
import com.yunbao.common.R;
import com.yunbao.common.adapter.ImageAdapter;
import com.yunbao.common.adapter.ImageFolderAdapter;
import com.yunbao.common.adapter.MultiTypeSupport;
import com.yunbao.common.adapter.SpaceGridItemDecoration;
import com.yunbao.common.bean.ImageEntity;
import com.yunbao.common.bean.ImageFolderEntity;
import com.yunbao.common.dialog.ImageFolderView;
import com.yunbao.common.utils.StatusBarUtil;
import com.yunbao.common.utils.TDevice;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;
/**
* Created by Chen Haoxuan on 2022/4/30.
* Description:图片选择
*/
public class SelectImageActivity extends AbsActivity implements ImageFolderView.ImageFolderViewListener, ImageAdapter.onCameraClickListener, View.OnClickListener {
// 返回选择图片列表的EXTRA_KEY
public static final String EXTRA_RESULT = "EXTRA_RESULT";
public static int MAX_SIZE = 5;
private static final int PERMISSION_REQUEST_CODE = 88;
private static final int TAKE_PHOTO = 99;
// @BindView(R.id.tv_back)
TextView mTvBack;
// @BindView(R.id.tv_ok)
TextView mTvSelectCount;
// @BindView(R.id.rv)
RecyclerView mRvImage;
// @BindView(R.id.tv_photo)
TextView mTvPhoto;
// @BindView(R.id.tv_preview)
TextView mTvPreview;
// @BindView(R.id.image_folder_view)
ImageFolderView mImageFolderView;
View v_back;
private boolean mHasCamera = true;
//被选中图片的集合
private List<ImageEntity> mSelectedImages = new ArrayList<>();
private List<ImageEntity> mImages = new ArrayList<>();
private List<ImageFolderEntity> mImageFolders = new ArrayList<>();
private ImageAdapter mImageAdapter;
private ImageFolderAdapter mImageFolderAdapter;
private Uri mImageUri;
private File takePhotoImageFile;
private int intoIndex = 0;
@Override
public int getLayoutId() {
return R.layout.activity_select_image;
}
@Override
public void main(Bundle savedInstanceState) {
mTvBack = findViewById(R.id.tv_back);
mTvSelectCount = findViewById(R.id.tv_ok);
mRvImage = findViewById(R.id.rv);
mTvPhoto = findViewById(R.id.tv_photo);
mTvPreview = findViewById(R.id.tv_preview);
mImageFolderView = findViewById(R.id.image_folder_view);
v_back = findViewById(R.id.v_back);
//设置状态栏的颜色
StatusBarUtil.statusBarTintColor(this, ContextCompat.getColor(this, R.color.black2));
setupSelectedImages();
mRvImage.setLayoutManager(new GridLayoutManager(this, 4, LinearLayoutManager.VERTICAL, false));
mRvImage.addItemDecoration(new SpaceGridItemDecoration((int) TDevice.dipToPx(getResources(), 1)));
//异步加载图片
getSupportLoaderManager().initLoader(0, null, mLoaderCallbacks);
mImageFolderView.setListener(this);
if (intoIndex == 1) {
onCameraClick();
}
v_back.setOnClickListener(this);
mTvSelectCount.setOnClickListener(this);
mTvPhoto.setOnClickListener(this);
mTvPreview.setOnClickListener(this);
}
private void setupSelectedImages() {
Intent intent = getIntent();
ArrayList<ImageEntity> selectImages = intent.getParcelableArrayListExtra("selected_images");
intoIndex = intent.getIntExtra("intoIndex", 0);
if (selectImages == null) {
selectImages = new ArrayList<>();
}
mSelectedImages.addAll(selectImages);
String showLook = getResources().getString(R.string.preview) + "%d/";
if (intoIndex == 3) {
showLook = showLook + "1";
MAX_SIZE = 1;
mTvBack.setText(getResources().getString(R.string.video));
mTvPhoto.setText(getResources().getString(R.string.video));
} else {
showLook = showLook + "9";
MAX_SIZE = 9;
mTvBack.setText(getResources().getString(R.string.im_input_img));
mTvPhoto.setText(getResources().getString(R.string.im_input_img));
}
if (mSelectedImages.size() > 0 && mSelectedImages.size() <= MAX_SIZE) {
mTvPreview.setClickable(true);
mTvPreview.setText(String.format(showLook, mSelectedImages.size()));
mTvPreview.setTextColor(ContextCompat.getColor(SelectImageActivity.this, R.color.pk_red));
}
}
@Override
public void onClick(View v) {
int id = v.getId();
if (id == R.id.v_back) {
finish();
} else if (id == R.id.tv_ok) {
Intent intent = new Intent();
intent.putParcelableArrayListExtra(EXTRA_RESULT, (ArrayList<? extends Parcelable>) mSelectedImages);
setResult(RESULT_OK, intent);
finish();
} else if (id == R.id.tv_photo) {
if (mImageFolderView.isShowing()) {
mImageFolderView.hide();
} else {
mImageFolderView.show();
}
} else if (id == R.id.tv_preview) {
if (mSelectedImages.size() > 0) {
if (intoIndex != 3) {
Intent previewIntent = new Intent(this, PreviewImageActivity.class);
previewIntent.putParcelableArrayListExtra("preview_images", (ArrayList<? extends Parcelable>) mSelectedImages);
startActivity(previewIntent);
} else {
Intent previewIntent = new Intent(this, PreviewVideoActivity.class);
previewIntent.putParcelableArrayListExtra("preview_images", (ArrayList<? extends Parcelable>) mSelectedImages);
startActivity(previewIntent);
}
}
}
}
// @OnClick({R.id.tv_back, R.id.tv_ok, R.id.tv_photo, R.id.tv_preview})
// public void onViewClicked(View view) {
// switch (view.getId()) {
// case R.id.tv_back:
// finish();
// break;
// case R.id.tv_ok:
// Intent intent = new Intent();
// intent.putParcelableArrayListExtra(EXTRA_RESULT, (ArrayList<? extends Parcelable>) mSelectedImages);
// setResult(RESULT_OK, intent);
// finish();
// break;
// case R.id.tv_photo:
// if (mImageFolderView.isShowing()) {
// mImageFolderView.hide();
// } else {
// mImageFolderView.show();
// }
// break;
// case R.id.tv_preview:
// Intent previewIntent = new Intent(this, PreviewImageActivity.class);
// previewIntent.putParcelableArrayListExtra("preview_images", (ArrayList<? extends Parcelable>) mSelectedImages);
// startActivity(previewIntent);
// break;
// }
// }
private void addImageFoldersToAdapter() {
if (mImageFolderAdapter == null) {
mImageFolderAdapter = new ImageFolderAdapter(this, mImageFolders, R.layout.item_list_folder);
mImageFolderView.setAdapter(mImageFolderAdapter);
} else {
mImageFolderAdapter.notifyDataSetChanged();
}
}
private void addImagesToAdapter(ArrayList<ImageEntity> images) {
mImages.clear();
mImages.addAll(images);
if (mImageAdapter == null) {
mImageAdapter = new ImageAdapter(this, mImages, mSelectedImages, mMultiTypeSupport);
mRvImage.setAdapter(mImageAdapter);
} else {
mImageAdapter.notifyDataSetChanged();
}
mImageAdapter.setSelectImageCountListener(mOnSelectImageCountListener);
mImageAdapter.setOnCameraClickListener(this);
}
private MultiTypeSupport<ImageEntity> mMultiTypeSupport = new MultiTypeSupport<ImageEntity>() {
@Override
public int getLayoutId(ImageEntity image) {
if (TextUtils.isEmpty(image.getPath())) {
return R.layout.item_list_camera;
}
return R.layout.item_list_image;
}
};
/*************************************已选择的图片回调的方法************************************************/
private ImageAdapter.onSelectImageCountListener mOnSelectImageCountListener = new ImageAdapter.onSelectImageCountListener() {
@Override
public void onSelectImageCount(int count) {
String showLook = getResources().getString(R.string.preview);
if (intoIndex == 3) {
showLook = showLook + "%d/1";
MAX_SIZE = 1;
} else {
showLook = showLook + "%d/9";
MAX_SIZE = 9;
}
if (count == 0) {
showLook = getResources().getString(R.string.preview);
mTvPreview.setClickable(false);
mTvPreview.setText(showLook);
mTvPreview.setTextColor(ContextCompat.getColor(SelectImageActivity.this, R.color.color_b14066));
} else if (count > 0 && count <= MAX_SIZE) {
mTvPreview.setClickable(true);
mTvPreview.setText(String.format(showLook, count));
mTvPreview.setTextColor(ContextCompat.getColor(SelectImageActivity.this, R.color.pk_red));
}
}
@Override
public void onSelectImageList(List<ImageEntity> images) {
mSelectedImages = images;
}
};
/*************************************异步加载相册图片************************************************/
private LoaderManager.LoaderCallbacks<Cursor> mLoaderCallbacks = new LoaderManager.LoaderCallbacks<Cursor>() {
private final String[] IMAGE_PROJECTION = {
MediaStore.Images.Media.DATA,
MediaStore.Images.Media.DISPLAY_NAME,
MediaStore.Images.Media.DATE_ADDED,
MediaStore.Images.Media._ID,
MediaStore.Images.Media.MINI_THUMB_MAGIC,
MediaStore.Images.Media.BUCKET_DISPLAY_NAME};
//创建一个CursorLoader去异步加载相册的图片
@NonNull
@Override
public Loader<Cursor> onCreateLoader(int id, @Nullable Bundle args) {
if (intoIndex == 3) {
return new CursorLoader(SelectImageActivity.this,
MediaStore.Video.Media.EXTERNAL_CONTENT_URI, IMAGE_PROJECTION,
null, null, IMAGE_PROJECTION[2] + " DESC");
} else {
return new CursorLoader(SelectImageActivity.this,
MediaStore.Images.Media.EXTERNAL_CONTENT_URI, IMAGE_PROJECTION,
null, null, IMAGE_PROJECTION[2] + " DESC");
}
}
@Override
public void onLoadFinished(@NonNull Loader<Cursor> loader, Cursor data) {
if (data != null) {
ArrayList<ImageEntity> images = new ArrayList<>();
//是否显示照相图片
if (mHasCamera) {
//添加到第一个的位置(默认)
if (intoIndex != 3) {
images.add(new ImageEntity());
}
}
ImageFolderEntity defaultFolder = new ImageFolderEntity();
defaultFolder.setName("全部照片");
defaultFolder.setPath("");
mImageFolders.add(defaultFolder);
int count = data.getCount();
if (count > 0) {
data.moveToFirst();
do {
String path = data.getString(data.getColumnIndexOrThrow(IMAGE_PROJECTION[0]));
String name = data.getString(data.getColumnIndexOrThrow(IMAGE_PROJECTION[1]));
long dateTime = data.getLong(data.getColumnIndexOrThrow(IMAGE_PROJECTION[2]));
int id = data.getInt(data.getColumnIndexOrThrow(IMAGE_PROJECTION[3]));
String thumbPath = data.getString(data.getColumnIndexOrThrow(IMAGE_PROJECTION[4]));
String bucket = data.getString(data.getColumnIndexOrThrow(IMAGE_PROJECTION[5]));
ImageEntity image = new ImageEntity();
image.setPath(path);
image.setName(name);
image.setDate(dateTime);
image.setId(id);
image.setThumbPath(thumbPath);
image.setFolderName(bucket);
image.setFolderName(bucket);
images.add(image);
//如果是被选中的图片
if (mSelectedImages.size() > 0) {
for (ImageEntity i : mSelectedImages) {
if (i.getPath().equals(image.getPath())) {
image.setSelect(true);
}
}
}
//设置图片分类的文件夹
File imageFile = new File(path);
File folderFile = imageFile.getParentFile();
ImageFolderEntity folder = new ImageFolderEntity();
folder.setName(folderFile.getName());
folder.setPath(folderFile.getAbsolutePath());
//ImageFolder复写了equal方法equal方法比较的是文件夹的路径
if (!mImageFolders.contains(folder)) {
folder.getImages().add(image);
//默认相册封面
folder.setAlbumPath(image.getPath());
mImageFolders.add(folder);
} else {
ImageFolderEntity imageFolder = mImageFolders.get(mImageFolders.indexOf(folder));
imageFolder.getImages().add(image);
}
} while (data.moveToNext());
}
addImagesToAdapter(images);
//全部照片
defaultFolder.getImages().addAll(images);
if (mHasCamera) {
defaultFolder.setAlbumPath(images.size() > 1 ? images.get(1).getPath() : null);
} else {
defaultFolder.setAlbumPath(images.size() > 0 ? images.get(0).getPath() : null);
}
//删除掉不存在的,在于用户选择了相片,又去相册删除
if (mSelectedImages.size() > 0) {
List<ImageEntity> rs = new ArrayList<>();
for (ImageEntity i : mSelectedImages) {
File f = new File(i.getPath());
if (!f.exists()) {
rs.add(i);
}
}
mSelectedImages.removeAll(rs);
}
}
mImageFolderView.setImageFolders(mImageFolders);
addImageFoldersToAdapter();
}
@Override
public void onLoaderReset(@NonNull Loader<Cursor> loader) {
}
};
@Override
public void onSelectFolder(ImageFolderView imageFolderView, ImageFolderEntity imageFolder) {
addImagesToAdapter(imageFolder.getImages());
mRvImage.scrollToPosition(0);
mTvPhoto.setText(imageFolder.getName());
}
@Override
public void onDismiss() {
}
@Override
public void onShow() {
}
/*************************************相机拍照************************************************/
@Override
public void onCameraClick() {
//首先申请下相机权限
int isPermission = ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA);
if (isPermission == PackageManager.PERMISSION_GRANTED) {
takePhoto();
} else {
//申请权限
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.CAMERA}, PERMISSION_REQUEST_CODE);
}
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (requestCode == PERMISSION_REQUEST_CODE) {
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
takePhoto();
} else {
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.CAMERA}, PERMISSION_REQUEST_CODE);
Toast.makeText(this, "需要您的相机权限!", Toast.LENGTH_SHORT).show();
}
}
}
private void takePhoto() {
//用来打开相机的Intent
Intent takePhotoIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
//这句作用是如果没有相机则该应用不会闪退,要是不加这句则当系统没有相机应用的时候该应用会闪退
if (takePhotoIntent.resolveActivity(getPackageManager()) != null) {
takePhotoImageFile = createImageFile();
if (takePhotoImageFile != null) {
Log.i("take photo", "ImageFilePath=" + takePhotoImageFile.getAbsolutePath());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
///7.0以上要通过FileProvider将File转化为Uri
mImageUri = FileProvider.getUriForFile(this, this.getPackageName() + ".fileprovider", takePhotoImageFile);
} else {
//7.0以下则直接使用Uri的fromFile方法将File转化为Uri
mImageUri = Uri.fromFile(takePhotoImageFile);
}
//将用于输出的文件Uri传递给相机
takePhotoIntent.putExtra(MediaStore.EXTRA_OUTPUT, mImageUri);
//启动相机
startActivityForResult(takePhotoIntent, TAKE_PHOTO);
}
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK && requestCode == TAKE_PHOTO) {
//缩略图信息是储存在返回的intent中的Bundle中的对应Bundle中的键为data因此从Intent中取出 Bundle再根据data取出来Bitmap即可
// Bundle extras = data.getExtras();
// Bitmap bitmap = (Bitmap) extras.get("data");
// BitmapFactory.decodeFile(this.getContentResolver().)
// galleryAddPictures(mImageUri);
// getSupportLoaderManager().restartLoader(0, null, mLoaderCallbacks);
galleryAddPictures();
try {
Bitmap bitmap = BitmapFactory.decodeStream(this.getContentResolver().openInputStream(mImageUri));
Log.i("take photo", bitmap + "");
} catch (Exception e) {
e.printStackTrace();
}
}
}
private File createImageFile() {
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.CHINA).format(new Date());
String imageFileName = "BEMS_APP_IMG_" + timeStamp + "_";
File storageDir = getExternalFilesDir(Environment.DIRECTORY_PICTURES);
File imageFile = null;
try {
imageFile = File.createTempFile(imageFileName, ".jpg", storageDir);
} catch (IOException e) {
e.printStackTrace();
}
return imageFile;
}
/**
* 将拍的照片添加到相册
*/
private void galleryAddPictures() {
//把文件插入到系统图库
try {
MediaStore.Images.Media.insertImage(this.getContentResolver(),
takePhotoImageFile.getAbsolutePath(), takePhotoImageFile.getName(), null);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
//通知图库更新
Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.fromFile(takePhotoImageFile));
sendBroadcast(mediaScanIntent);
}
}

View File

@@ -0,0 +1,358 @@
package com.yunbao.common.activity;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.provider.MediaStore;
import androidx.annotation.RequiresApi;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.JavascriptInterface;
import android.webkit.ValueCallback;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.Constants;
import com.yunbao.common.R;
import com.yunbao.common.utils.AndroidBug5497Workaround;
import com.yunbao.common.utils.DpUtil;
import com.yunbao.common.utils.L;
import com.yunbao.common.utils.RouteUtil;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordUtil;
/**
* Created by cxf on 2018/9/25.
*/
public class WebViewActivity extends AbsActivity {
private FrameLayout ft_title;
private ImageView btnEdit;
private ProgressBar mProgressBar;
private WebView mWebView;
private final int CHOOSE = 100;//Android 5.0以下的
private final int CHOOSE_ANDROID_5 = 200;//Android 5.0以上的
private ValueCallback<Uri> mValueCallback;
private ValueCallback<Uri[]> mValueCallback2;
private int indexInto = 0;
private View v_spacing;
@Override
protected int getLayoutId() {
return R.layout.activity_webview;
}
@Override
protected void main() {
String url = getIntent().getStringExtra(Constants.URL);
L.e("H5--->" + url);
LinearLayout rootView = (LinearLayout) findViewById(R.id.rootView);
mProgressBar = (ProgressBar) findViewById(R.id.progressbar);
btnEdit = (ImageView) findViewById(R.id.btn_edit);
ft_title = (FrameLayout) findViewById(R.id.ft_title);
v_spacing = (View) findViewById(R.id.v_spacing);
AndroidBug5497Workaround.assistActivity(this);
mWebView = new WebView(mContext);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
params.topMargin = DpUtil.dp2px(1);
mWebView.setLayoutParams(params);
mWebView.setOverScrollMode(View.OVER_SCROLL_NEVER);
rootView.addView(mWebView);
mWebView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
L.e("H5-------->" + url);
if (url.startsWith(Constants.COPY_PREFIX)) {
String content = url.substring(Constants.COPY_PREFIX.length());
if (!TextUtils.isEmpty(content)) {
copy(content);
}
} else {
view.loadUrl(url);
}
return true;
}
@Override
public void onPageFinished(WebView view, String url) {
setTitle(view.getTitle());
if (url.contains("for")) {
mWebView.loadUrl("javascript:goAnchorTab()");
}
}
});
mWebView.setWebChromeClient(new WebChromeClient() {
@Override
public void onProgressChanged(WebView view, int newProgress) {
if (newProgress == 100) {
mProgressBar.setVisibility(View.GONE);
} else {
mProgressBar.setProgress(newProgress);
}
}
//以下是在各个Android版本中 WebView调用文件选择器的方法
// For Android < 3.0
public void openFileChooser(ValueCallback<Uri> valueCallback) {
openImageChooserActivity(valueCallback);
}
// For Android >= 3.0
public void openFileChooser(ValueCallback valueCallback, String acceptType) {
openImageChooserActivity(valueCallback);
}
//For Android >= 4.1
public void openFileChooser(ValueCallback<Uri> valueCallback,
String acceptType, String capture) {
openImageChooserActivity(valueCallback);
}
// For Android >= 5.0
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override
public boolean onShowFileChooser(WebView webView,
ValueCallback<Uri[]> filePathCallback,
FileChooserParams fileChooserParams) {
mValueCallback2 = filePathCallback;
Intent intent = fileChooserParams.createIntent();
startActivityForResult(intent, CHOOSE_ANDROID_5);
return true;
}
});
mWebView.addJavascriptInterface(new JsInteration(), "androidObject");
mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setDomStorageEnabled(true);
String appCachePath = mContext.getCacheDir().getAbsolutePath();
mWebView.getSettings().setAppCachePath(appCachePath);
mWebView.getSettings().setAllowFileAccess(true);
mWebView.getSettings().setUseWideViewPort(true); // 关键点
mWebView.getSettings().setAllowFileAccess(true); // 允许访问文件
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
mWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
}
mWebView.loadUrl(url);
if (Constants.myIntoIndex == 2) {
ft_title.setVisibility(View.GONE);
btnEdit.setVisibility(View.GONE);
v_spacing.setVisibility(View.VISIBLE);
} else if (Constants.myIntoIndex == 1) {
v_spacing.setVisibility(View.GONE);
} else {
btnEdit.setVisibility(View.GONE);
ft_title.setVisibility(View.VISIBLE);
v_spacing.setVisibility(View.GONE);
}
}
//js调用原生
public class JsInteration {
@JavascriptInterface
public void onBack() {
finish();
}
@JavascriptInterface
public void modifyMydata() {
indexInto = 1;
RouteUtil.forwardEditProfileActivity();
}
@JavascriptInterface
public void reportUser(String touid) {
RouteUtil.forwardLiveReportActivity(touid);
}
@JavascriptInterface
public void gotoHomePage(String indexStr) {
Log.e("tgasss","indexStr4"+indexStr);
if (!"".equals(indexStr) && indexStr != null) {
int index = -1;
if ("0".equals(indexStr)) {
index = 0;
} else if ("1".equals(indexStr)) {
index = 1;
} else if ("2".equals(indexStr)) {
index = 2;
} else if ("3".equals(indexStr)) {
index = 3;
}
if (index != -1) {
finish();
Constants.isShowPage = index;
}
}
}
@JavascriptInterface
public void openWebView(String url) {
Constants.isTitle = false;
RouteUtil.forwardZhuangBanActivity(url);
}
@JavascriptInterface
public void openWebViewTitle(String url) {
Constants.isTitle = true;
RouteUtil.forwardZhuangBanActivity(url);
}
}
private void openImageChooserActivity(ValueCallback<Uri> valueCallback) {
mValueCallback = valueCallback;
Intent intent = new Intent();
if (Build.VERSION.SDK_INT < 19) {
intent.setAction(Intent.ACTION_GET_CONTENT);
} else {
intent.setAction(Intent.ACTION_PICK);
intent.setData(MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
}
intent.setType("image/*");
startActivityForResult(Intent.createChooser(intent, WordUtil.getString(R.string.choose_flie)), CHOOSE);
}
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);
switch (requestCode) {
case CHOOSE://5.0以下选择图片后的回调
processResult(resultCode, intent);
break;
case CHOOSE_ANDROID_5://5.0以上选择图片后的回调
processResultAndroid5(resultCode, intent);
break;
}
}
private void processResult(int resultCode, Intent intent) {
if (mValueCallback == null) {
return;
}
if (resultCode == RESULT_OK && intent != null) {
Uri result = intent.getData();
mValueCallback.onReceiveValue(result);
} else {
mValueCallback.onReceiveValue(null);
}
mValueCallback = null;
}
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private void processResultAndroid5(int resultCode, Intent intent) {
if (mValueCallback2 == null) {
return;
}
if (resultCode == RESULT_OK && intent != null) {
mValueCallback2.onReceiveValue(WebChromeClient.FileChooserParams.parseResult(resultCode, intent));
} else {
mValueCallback2.onReceiveValue(null);
}
mValueCallback2 = null;
}
public static void forward(Context context, String url, boolean addArgs) {
if (Constants.LoginKefu) {
if (addArgs) {
url += "&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken();
}
}
Intent intent = new Intent(context, WebViewActivity.class);
intent.putExtra(Constants.URL, url);
context.startActivity(intent);
}
public static void forward(Context context, String url) {
forward(context, url, true);
}
@Override
protected void onDestroy() {
if (mWebView != null) {
ViewGroup parent = (ViewGroup) mWebView.getParent();
if (parent != null) {
parent.removeView(mWebView);
}
mWebView.destroy();
}
Constants.myIntoIndex = 0;
indexInto = 0;
Constants.LoginKefu = true;
super.onDestroy();
}
/**
* 复制到剪贴板
*/
private void copy(String content) {
ClipboardManager cm = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
ClipData clipData = ClipData.newPlainText("text", content);
cm.setPrimaryClip(clipData);
ToastUtil.show(getString(R.string.copy_success));
}
@Override
protected void onResume() {
super.onResume();
if (Constants.myIntoIndex == 2 && mWebView != null && indexInto == 1) {
if (Build.VERSION.SDK_INT >= 21) {
mWebView.post(new Runnable() {
@Override
public void run() {
String method = "reload()";//拼接参数就可以把数据传递给js
mWebView.evaluateJavascript(method, new ValueCallback<String>() {
@Override
public void onReceiveValue(String value) {
// Log.i("qcl0228", "js返回的数据" + value);
}
});
}
});
} else {
mWebView.post(new Runnable() {
@Override
public void run() {
mWebView.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
mWebView.loadUrl("javascript:reload()");
}
});
}
});
}
indexInto = 0;
}
if (Constants.isShowPage != -1) {
finish();
}
// new Handler().postDelayed(new Runnable() {
// @Override
// public void run() {
// mWebView.reload();
// }
// }, 100);
}
}

View File

@@ -0,0 +1,136 @@
package com.yunbao.common.adapter;
import android.content.Context;
import android.graphics.drawable.Drawable;
import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.Constants;
import com.yunbao.common.bean.CoinBean;
import com.yunbao.common.interfaces.OnItemClickListener;
import com.yunbao.common.utils.WordUtil;
import com.yunbao.common.R;
import java.util.List;
/**
* Created by cxf on 2019/4/22.
*/
public class ChatChargeCoinAdapter extends RecyclerView.Adapter<ChatChargeCoinAdapter.Vh> {
private List<CoinBean> mList;
private LayoutInflater mInflater;
private String mCoinName;
private String mGoldCoinName;
private String mGiveString;
private Drawable mCheckedDrawable;
private Drawable mUnCheckedDrawable;
private int mCheckedPosition;
private View.OnClickListener mOnClickListener;
private OnItemClickListener<CoinBean> mOnItemClickListener;
public ChatChargeCoinAdapter(Context context, List<CoinBean> list) {
mInflater = LayoutInflater.from(context);
mList = list;
mCoinName = CommonAppConfig.getInstance().getCoinName();
mGoldCoinName = CommonAppConfig.getInstance().getGoldCoinName();
mGiveString = WordUtil.getString(R.string.coin_give);
mOnClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
Object tag = v.getTag();
if (tag == null) {
return;
}
int positon = (int) tag;
CoinBean bean = mList.get(positon);
if (mCheckedPosition != positon) {
if (mCheckedPosition >= 0 && mCheckedPosition < mList.size()) {
mList.get(mCheckedPosition).setChecked(false);
notifyItemChanged(mCheckedPosition, Constants.PAYLOAD);
}
bean.setChecked(true);
notifyItemChanged(positon, Constants.PAYLOAD);
mCheckedPosition = positon;
}
if (mOnItemClickListener != null) {
mOnItemClickListener.onItemClick(bean, positon);
}
}
};
mCheckedDrawable = ContextCompat.getDrawable(context, R.drawable.bg_coin_item_1);
mUnCheckedDrawable = ContextCompat.getDrawable(context, R.drawable.bg_coin_item_0);
}
@NonNull
@Override
public Vh onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return new Vh(mInflater.inflate(R.layout.item_coin, parent, false));
}
@Override
public void onBindViewHolder(@NonNull Vh holder, int position) {
}
@Override
public void onBindViewHolder(@NonNull Vh vh, int position, @NonNull List<Object> payloads) {
Object payload = payloads.size() > 0 ? payloads.get(0) : null;
vh.setData(mList.get(position), position, payload);
}
@Override
public int getItemCount() {
return mList.size();
}
class Vh extends RecyclerView.ViewHolder {
TextView mCoin;
TextView mMoney;
TextView mGive;
View mGiveGroup;
View mBg;
public Vh(View itemView) {
super(itemView);
mCoin = itemView.findViewById(R.id.coin);
mMoney = itemView.findViewById(R.id.money);
mGive = itemView.findViewById(R.id.give);
mGiveGroup = itemView.findViewById(R.id.give_group);
mBg = itemView.findViewById(R.id.bg);
itemView.setOnClickListener(mOnClickListener);
}
void setData(CoinBean bean, int position, Object payload) {
if (payload == null) {
itemView.setTag(position);
mCoin.setText(bean.getCoin());
mMoney.setText("" + bean.getMoney());
if (!"0".equals(bean.getGive())) {
if (mGiveGroup.getVisibility() != View.VISIBLE) {
mGiveGroup.setVisibility(View.VISIBLE);
}
mGive.setText(mGiveString + bean.getGive() + mGoldCoinName);
} else {
if (mGiveGroup.getVisibility() == View.VISIBLE) {
mGiveGroup.setVisibility(View.INVISIBLE);
}
}
}
mBg.setBackground(bean.isChecked() ? mCheckedDrawable : mUnCheckedDrawable);
}
}
public void setOnItemClickListener(OnItemClickListener<CoinBean> onItemClickListener) {
mOnItemClickListener = onItemClickListener;
}
}

View File

@@ -0,0 +1,156 @@
package com.yunbao.common.adapter;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.yunbao.common.Constants;
import com.yunbao.common.bean.CoinPayBean;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.R;
import java.util.List;
/**
* Created by cxf on 2019/4/22.
*/
public class ChatChargePayAdapter extends RecyclerView.Adapter<ChatChargePayAdapter.Vh> {
private Context mContext;
private List<CoinPayBean> mList;
private LayoutInflater mInflater;
private Drawable mCheckedDrawable;
private int mCheckedPosition;
private View.OnClickListener mOnClickListener;
public ChatChargePayAdapter(Context context, List<CoinPayBean> list) {
mContext = context;
mInflater = LayoutInflater.from(context);
mList = list;
mCheckedPosition = 0;
mOnClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
Object tag = v.getTag();
if (tag == null) {
return;
}
int positon = (int) tag;
CoinPayBean bean = mList.get(positon);
if (mCheckedPosition != positon) {
if (mCheckedPosition >= 0 && mCheckedPosition < mList.size()) {
mList.get(mCheckedPosition).setChecked(false);
notifyItemChanged(mCheckedPosition, Constants.PAYLOAD);
}
bean.setChecked(true);
notifyItemChanged(positon, Constants.PAYLOAD);
mCheckedPosition = positon;
}
}
};
// mCheckedDrawable = ContextCompat.getDrawable(context, R.drawable.icon_chat_charge_pay_1);
mCheckedDrawable = ContextCompat.getDrawable(context, R.mipmap.icon_coin_wrap);
}
public CoinPayBean getCheckedPayBean() {
if (mList != null && mCheckedPosition >= 0 && mCheckedPosition < mList.size()) {
return mList.get(mCheckedPosition);
}
return null;
}
@NonNull
@Override
public Vh onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return new Vh(mInflater.inflate(R.layout.item_chat_charge_pay2, parent, false));
}
@Override
public void onBindViewHolder(@NonNull Vh holder, int position) {
}
@Override
public void onBindViewHolder(@NonNull Vh vh, int position, @NonNull List<Object> payloads) {
Object payload = payloads.size() > 0 ? payloads.get(0) : null;
vh.setData(mList.get(position), position, payload);
}
@Override
public int getItemCount() {
return mList.size();
}
class Vh extends RecyclerView.ViewHolder {
ImageView mThumb;
TextView mName;
ImageView mImg;
TextView mGive;
View mGiveGroup;
ImageView mWrap;
View viewLine;
public Vh(View itemView) {
super(itemView);
mThumb = itemView.findViewById(R.id.thumb);
mName = itemView.findViewById(R.id.name);
mImg = itemView.findViewById(R.id.img);
mGive = itemView.findViewById(R.id.give);
mGiveGroup = itemView.findViewById(R.id.give_group);
mWrap = itemView.findViewById(R.id.wrap);
viewLine = itemView.findViewById(R.id.viewLine);
itemView.setOnClickListener(mOnClickListener);
}
void setData(CoinPayBean bean, int position, Object payload) {
if (payload == null) {
itemView.setTag(position);
ImgLoader.display(mContext, bean.getThumb(), mThumb);
//大额
if (bean.getPayDesc()!=null && !bean.getPayDesc().isEmpty()){
mGiveGroup.setVisibility(View.VISIBLE);
mGive.setText(bean.getPayDesc());
}else {
mGiveGroup.setVisibility(View.GONE);
mGive.setText("");
}
if (bean.getId().equals(Constants.PAY_TYPE_PAYSSION)){
mName.setText(bean.getName());
mName.setTextColor(Color.parseColor("#323232"));
// mName.setText(bean.getName()+" (推荐)");
// mName.setTextColor(Color.parseColor("#ff6131"));
}
else {
mName.setText(bean.getName());
mName.setTextColor(Color.parseColor("#323232"));
}
}
if (bean.isChecked()) {
if (mWrap.getVisibility() != View.VISIBLE) {
mWrap.setVisibility(View.VISIBLE);
}
viewLine.setVisibility(View.GONE);
} else {
if (mWrap.getVisibility() == View.VISIBLE) {
mWrap.setVisibility(View.INVISIBLE);
}
viewLine.setVisibility(View.VISIBLE);
}
// mImg.setImageDrawable(bean.isChecked() ? mCheckedDrawable : null);
}
}
}

View File

@@ -0,0 +1,85 @@
package com.yunbao.common.adapter;
import android.content.Context;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import java.util.List;
/**
* Created by Chen Haoxuan on 2022/4/30.
*/
public abstract class CommonRecycleAdapter<T> extends RecyclerView.Adapter<CommonViewHolder> {
private int mLayoutId;
private List<T> mData;
private LayoutInflater mInflater;
private OnItemClickListener mItemClickListener;
private MultiTypeSupport mTypeSupport;
public CommonRecycleAdapter(Context context, List<T> mData, int layoutId) {
this.mData = mData;
this.mLayoutId = layoutId;
mInflater = LayoutInflater.from(context);
}
public CommonRecycleAdapter(Context context, List<T> mData, MultiTypeSupport typeSupport) {
this(context, mData, -1);
this.mTypeSupport = typeSupport;
}
@NonNull
@Override
public CommonViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
if (mTypeSupport != null) {
//多布局
mLayoutId = viewType;
}
View itemView = mInflater.inflate(mLayoutId, parent, false);
return new CommonViewHolder(itemView);
}
@Override
public void onBindViewHolder(@NonNull CommonViewHolder holder, final int position) {
convert(holder, mData.get(position), position);
if (mItemClickListener != null) {
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mItemClickListener.onItemClick(position);
}
});
}
}
@Override
public int getItemCount() {
return mData.size();
}
@Override
public int getItemViewType(int position) {
//多布局
if (mTypeSupport != null) {
return mTypeSupport.getLayoutId(mData.get(position));
}
return super.getItemViewType(position);
}
@Override
public long getItemId(int position) {
return position;
}
//点击事件
public void setItemClickListener(OnItemClickListener itemClickListener) {
this.mItemClickListener = itemClickListener;
}
protected abstract void convert(CommonViewHolder holder, T t, int position);
}

View File

@@ -0,0 +1,101 @@
package com.yunbao.common.adapter;
import androidx.recyclerview.widget.RecyclerView;
import android.util.SparseArray;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
/**
* Created by zhiwenyan on 5/25/17.
* <p>
* 通用的ViewHolder
*/
public class CommonViewHolder extends RecyclerView.ViewHolder {
//用于缓存View
private SparseArray<View> mView;
public CommonViewHolder(View itemView) {
super(itemView);
mView = new SparseArray<>();
}
public <T extends View> T getView(int viewId) {
View view = mView.get(viewId);
if (view == null) {
view = itemView.findViewById(viewId);
mView.put(viewId, view);
}
return (T) view;
}
//通用的setText进行封装
/**
* @param viewId
* @param text
* @return
*/
public CommonViewHolder setText(int viewId, CharSequence text) {
TextView tv = getView(viewId);
tv.setText(text);
return this;
}
/**
* 本地图片
*
* @param viewId
* @param resourceId
* @return
*/
public CommonViewHolder setImageResoucrce(int viewId, int resourceId) {
ImageView iv = getView(viewId);
iv.setImageResource(resourceId);
return this;
}
/**
* 网络图片处理
*
* @param viewId
* @param imageLoader
* @return
*/
public CommonViewHolder setImagePath(int viewId, HolderImageLoader imageLoader) {
ImageView iv = getView(viewId);
imageLoader.loadImage(iv, imageLoader.getPath());
return this;
}
abstract static class HolderImageLoader {
private String path;
public HolderImageLoader(String path) {
this.path = path;
}
/**
* 加载图片
*
* @param imageView
* @param path
*/
abstract void loadImage(ImageView imageView, String path);
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
}
}

View File

@@ -0,0 +1,88 @@
package com.yunbao.common.adapter;
import androidx.recyclerview.widget.RecyclerView;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import com.yunbao.common.utils.FaceUtil;
import com.yunbao.common.R;
import com.yunbao.common.interfaces.OnFaceClickListener;
import java.util.List;
/**
* Created by cxf on 2018/7/11.
* 聊天表情的RecyclerView Adapter
*/
public class ImChatFaceAdapter extends RecyclerView.Adapter<ImChatFaceAdapter.Vh> {
private List<String> mList;
private LayoutInflater mInflater;
private View.OnClickListener mOnClickListener;
public ImChatFaceAdapter(List<String> list, LayoutInflater inflater, final OnFaceClickListener onFaceClickListener) {
mList = list;
mInflater = inflater;
mOnClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
Object tag = v.getTag();
if (tag != null && onFaceClickListener != null) {
String str = (String) v.getTag();
if (!TextUtils.isEmpty(str)) {
if ("<".equals(str)) {
onFaceClickListener.onFaceDeleteClick();
} else {
onFaceClickListener.onFaceClick(str, v.getId());
}
}
}
}
};
}
@Override
public Vh onCreateViewHolder(ViewGroup parent, int viewType) {
return new Vh(mInflater.inflate(R.layout.item_list_face, parent, false));
}
@Override
public void onBindViewHolder(Vh vh, int position) {
vh.setData(mList.get(position));
}
@Override
public int getItemCount() {
return mList.size();
}
class Vh extends RecyclerView.ViewHolder {
ImageView mImageView;
public Vh(View itemView) {
super(itemView);
mImageView = (ImageView) itemView;
mImageView.setOnClickListener(mOnClickListener);
}
void setData(String str) {
mImageView.setTag(str);
if (!TextUtils.isEmpty(str)) {
if ("<".equals(str)) {
mImageView.setImageResource(R.mipmap.icon_face_delete);
} else {
int imgRes = FaceUtil.getFaceImageRes(str);
mImageView.setId(imgRes);
mImageView.setImageResource(imgRes);
}
}else{
mImageView.setClickable(false);
}
}
}
}

View File

@@ -0,0 +1,80 @@
package com.yunbao.common.adapter;
import android.content.Context;
import androidx.annotation.Nullable;
import androidx.viewpager.widget.PagerAdapter;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.yunbao.common.utils.FaceUtil;
import com.yunbao.common.R;
import com.yunbao.common.interfaces.OnFaceClickListener;
import java.util.ArrayList;
import java.util.List;
/**
* Created by cxf on 2018/7/11.
* 聊天表情的ViewPager Adapter
*/
public class ImChatFacePagerAdapter extends PagerAdapter {
private List<View> mViewList;
private static final int FACE_COUNT = 20;//每页20个表情
public ImChatFacePagerAdapter(Context context, OnFaceClickListener onFaceClickListener) {
LayoutInflater inflater = LayoutInflater.from(context);
mViewList = new ArrayList<>();
List<String> faceList = FaceUtil.getFaceList();
int fromIndex = 0;
int size = faceList.size();
int pageCount = size / FACE_COUNT;
if (size % FACE_COUNT > 0) {
pageCount++;
for (int i = 0, count = pageCount * FACE_COUNT - size; i < count; i++) {
faceList.add("");
}
}
for (int i = 0; i < pageCount; i++) {
RecyclerView recyclerView = (RecyclerView) inflater.inflate(R.layout.view_chat_face_page, null, false);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new GridLayoutManager(context, 7, GridLayoutManager.VERTICAL, false));
int endIndex = fromIndex + FACE_COUNT;
List<String> list = new ArrayList<>();
for (int j = fromIndex; j < endIndex; j++) {
list.add(faceList.get(j));
}
list.add("<");
recyclerView.setAdapter(new ImChatFaceAdapter(list, inflater, onFaceClickListener));
mViewList.add(recyclerView);
fromIndex = endIndex;
}
}
@Override
public int getCount() {
return mViewList.size();
}
@Override
public boolean isViewFromObject(@Nullable View view, @Nullable Object object) {
return view == object;
}
@Override
public Object instantiateItem(@Nullable ViewGroup container, int position) {
View view = mViewList.get(position);
container.addView(view);
return view;
}
@Override
public void destroyItem(@Nullable ViewGroup container, int position, @Nullable Object object) {
container.removeView(mViewList.get(position));
}
}

View File

@@ -0,0 +1,92 @@
package com.yunbao.common.adapter;
import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import com.yunbao.common.R;
import com.yunbao.common.activity.SelectImageActivity;
import com.yunbao.common.bean.ImageEntity;
import com.yunbao.common.glide.ImgLoader;
import java.util.List;
/**
* Created by Chen Haoxuan on 2022/4/30.
* Description:
*/
public class ImageAdapter extends CommonRecycleAdapter<ImageEntity> {
private Context mContext;
private onSelectImageCountListener mSelectImageCountListener;
private List<ImageEntity> mSelectImages;
public ImageAdapter(Context context, List<ImageEntity> images, List<ImageEntity> selectedImages, MultiTypeSupport typeSupport) {
super(context, images, typeSupport);
this.mContext = context;
this.mSelectImages = selectedImages;
}
@Override
protected void convert(CommonViewHolder holder, final ImageEntity image, int position) {
if (!TextUtils.isEmpty(image.getPath())) {
final ImageView chb_selected = holder.getView(R.id.iv_selected);
final View maskView = holder.getView(R.id.mask);
ImageView iv_image = holder.getView(R.id.iv_image);
// GlideApp.with(mContext).load(image.getPath()).into(iv_image);
ImgLoader.display(mContext, image.getPath(), iv_image);
chb_selected.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (image.isSelect()) {
image.setSelect(false);
mSelectImages.remove(image);
chb_selected.setSelected(false);
} else if (mSelectImages.size() < SelectImageActivity.MAX_SIZE) {
image.setSelect(true);
mSelectImages.add(image);
chb_selected.setSelected(true);
// maskView.setVisibility(image.isSelect() ? View.VISIBLE : View.GONE);
}
if (mSelectImageCountListener != null) {
mSelectImageCountListener.onSelectImageCount(mSelectImages.size());
mSelectImageCountListener.onSelectImageList(mSelectImages);
}
}
});
chb_selected.setSelected(image.isSelect());
// maskView.setVisibility(image.isSelect() ? View.VISIBLE : View.GONE);
} else {
holder.getView(R.id.iv_camera).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mOnCameraClickListener != null) {
mOnCameraClickListener.onCameraClick();
}
}
});
}
}
public void setSelectImageCountListener(onSelectImageCountListener selectImageCountListener) {
mSelectImageCountListener = selectImageCountListener;
}
public interface onSelectImageCountListener {
void onSelectImageCount(int count);
void onSelectImageList(List<ImageEntity> images);
}
private onCameraClickListener mOnCameraClickListener;
public void setOnCameraClickListener(onCameraClickListener onCameraClickListener) {
this.mOnCameraClickListener = onCameraClickListener;
}
public interface onCameraClickListener {
void onCameraClick();
}
}

View File

@@ -0,0 +1,34 @@
package com.yunbao.common.adapter;
import android.content.Context;
import android.widget.ImageView;
import com.yunbao.common.R;
import com.yunbao.common.bean.ImageFolderEntity;
import com.yunbao.common.glide.ImgLoader;
import java.util.List;
/**
* Created by Chen Haoxuan on 2022/4/30.
*/
public class ImageFolderAdapter extends CommonRecycleAdapter<ImageFolderEntity> {
private Context mContext;
public ImageFolderAdapter(Context context, List<ImageFolderEntity> imageFolders, int layoutId) {
super(context, imageFolders, layoutId);
this.mContext = context;
}
@Override
protected void convert(CommonViewHolder holder, ImageFolderEntity imageFolder, int potion) {
holder.setText(R.id.tv_folder_name, imageFolder.getName())
.setText(R.id.tv_size, imageFolder.getImages().size() + "");
ImageView iv_folder = holder.getView(R.id.iv_folder);
ImgLoader.display(mContext, imageFolder.getAlbumPath(), iv_folder);
// GlideApp.with(mContext)
// .load(imageFolder.getAlbumPath())
// .into(iv_folder);
}
}

View File

@@ -0,0 +1,10 @@
package com.yunbao.common.adapter;
/**
* Created by Chen Haoxuan on 2022/4/30.
* 多布局的支持
*/
public interface MultiTypeSupport<T> {
int getLayoutId(T item);
}

View File

@@ -0,0 +1,11 @@
package com.yunbao.common.adapter;
/**
* Created by zhiwenyan on 5/25/17.
* <p>
* 条目的点击事件
*/
public interface OnItemClickListener {
void onItemClick(int position);
}

View File

@@ -0,0 +1,105 @@
package com.yunbao.common.adapter;
import android.content.Context;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import com.yunbao.common.interfaces.OnItemClickListener;
import com.yunbao.common.interfaces.OnItemLongClickListener;
import com.yunbao.common.utils.ClickUtil;
import java.util.ArrayList;
import java.util.List;
/**
* Created by cxf on 2018/6/7.
*/
public abstract class RefreshAdapter<T> extends RecyclerView.Adapter {
protected Context mContext;
protected List<T> mList;
protected LayoutInflater mInflater;
protected RecyclerView mRecyclerView;
protected OnItemClickListener<T> mOnItemClickListener;
protected OnItemLongClickListener<T> mOnItemLongClickListener;
public RefreshAdapter(Context context) {
this(context, new ArrayList<T>());
}
public RefreshAdapter(Context context, List<T> list) {
mList = list;
mContext = context;
mInflater = LayoutInflater.from(mContext);
setHasStableIds(true);
}
@Override
public int getItemCount() {
if (mList != null) {
return mList.size();
}
return 0;
}
public void setOnItemClickListener(OnItemClickListener<T> onItemClickListener) {
mOnItemClickListener = onItemClickListener;
}
public void setOnItemLongClickListener(OnItemLongClickListener<T> onItemLongClickListener) {
mOnItemLongClickListener = onItemLongClickListener;
}
@Override
public void onAttachedToRecyclerView(RecyclerView recyclerView) {
mRecyclerView = recyclerView;
}
public RecyclerView getRecyclerView() {
return mRecyclerView;
}
public void setList(List<T> list) {
if (mList != null) {
mList.clear();
mList.addAll(list);
}
}
public void refreshData(List<T> list) {
if (mRecyclerView != null && list != null) {
mList.clear();
mList.addAll(list);
notifyDataSetChanged();
}
}
public void insertList(List<T> list) {
if (mRecyclerView != null && mList != null && list != null && list.size() > 0) {
int p = mList.size();
mList.addAll(list);
notifyItemRangeInserted(p, list.size());
}
}
public void clearData() {
if (mRecyclerView != null && mList != null) {
mList.clear();
notifyDataSetChanged();
}
}
@Override
public long getItemId(int position) {
return position;
}
protected boolean canClick() {
return ClickUtil.canClick();
}
public List<T> getList() {
return mList;
}
}

View File

@@ -0,0 +1,26 @@
package com.yunbao.common.adapter;
import android.graphics.Rect;
import androidx.recyclerview.widget.RecyclerView;
import android.view.View;
/**
* Created by Chen Haoxuan on 2022/4/30
* Description:
*/
public class SpaceGridItemDecoration extends RecyclerView.ItemDecoration {
private int space;
public SpaceGridItemDecoration(int space) {
this.space = space;
}
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
super.getItemOffsets(outRect, view, parent, state);
outRect.left = space;
outRect.top = space;
outRect.right = space;
outRect.bottom = space;
}
}

View File

@@ -0,0 +1,45 @@
package com.yunbao.common.adapter;
import androidx.annotation.NonNull;
import androidx.viewpager.widget.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;
import java.util.List;
/**
* Created by cxf on 2018/9/22.
*/
public class ViewPagerAdapter extends PagerAdapter {
private List<? extends View> mViewList;
public ViewPagerAdapter(List<? extends View> list) {
mViewList = list;
}
@Override
public int getCount() {
return mViewList.size();
}
@Override
public boolean isViewFromObject(@NonNull View view, @NonNull Object object) {
return view == object;
}
@NonNull
@Override
public Object instantiateItem(@NonNull ViewGroup container, int position) {
View view = mViewList.get(position);
container.addView(view);
return view;
}
@Override
public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
container.removeView(mViewList.get(position));
}
}

View File

@@ -0,0 +1,29 @@
package com.yunbao.common.bean;
import com.alibaba.fastjson.annotation.JSONField;
/**
* Created by cxf on 2019/4/28.
*/
public class AdBean {
private String mUrl;
private String mLink;
@JSONField(name = "thumb")
public String getUrl() {
return mUrl;
}
@JSONField(name = "thumb")
public void setUrl(String url) {
mUrl = url;
}
@JSONField(name = "href")
public String getLink() {
return mLink;
}
@JSONField(name = "href")
public void setLink(String link) {
mLink = link;
}
}

View File

@@ -0,0 +1,52 @@
package com.yunbao.common.bean;
import com.alibaba.fastjson.annotation.JSONField;
/**
* Created by cxf on 2019/3/30.
*/
public class BannerBean {
private String mImageUrl;
private String mLink;
private String show_type;
private String mIntoUrl;
public String getShow_type() {
return show_type;
}
public void setShow_type(String show_type) {
this.show_type = show_type;
}
@JSONField(name = "slide_pic")
public String getImageUrl() {
return mImageUrl;
}
@JSONField(name = "slide_pic")
public void setImageUrl(String imageUrl) {
mImageUrl = imageUrl;
}
@JSONField(name = "slide_url")
public String getLink() {
return mLink;
}
@JSONField(name = "slide_url")
public void setLink(String link) {
mLink = link;
}
@JSONField(name = "href")
public String getmIntoUrl() {
return mIntoUrl;
}
@JSONField(name = "href")
public void setmIntoUrl(String intoUrl) {
mIntoUrl = intoUrl;
}
}

View File

@@ -0,0 +1,30 @@
package com.yunbao.common.bean;
public class ChatRemarksBean {
String userId;
String remarks;
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getRemarks() {
return remarks;
}
public void setRemarks(String remarks) {
this.remarks = remarks;
}
public ChatRemarksBean() {
}
public ChatRemarksBean(String userId, String remarks) {
this.userId = userId;
this.remarks = remarks;
}
}

View File

@@ -0,0 +1,108 @@
package com.yunbao.common.bean;
import android.os.Parcel;
import android.os.Parcelable;
/**
* Created by cxf on 2017/9/21.
*/
public class CoinBean implements Parcelable{
private String id;
private String coin;
private String money;
private String give;
private String money_usd;
private boolean checked;
public CoinBean(){
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getCoin() {
return coin;
}
public void setCoin(String coin) {
this.coin = coin;
}
public String getMoney() {
return money;
}
public void setMoney(String money) {
this.money = money;
}
public String getGive() {
return give;
}
public void setGive(String give) {
this.give = give;
}
public boolean isChecked() {
return checked;
}
public void setChecked(boolean checked) {
this.checked = checked;
}
public String getMoney_usd() {
return money_usd;
}
public void setMoney_usd(String money_usd) {
this.money_usd = money_usd;
}
@Override
public int describeContents() {
return 0;
}
public CoinBean(Parcel in) {
id = in.readString();
coin = in.readString();
money = in.readString();
give = in.readString();
money_usd= in.readString();
checked = in.readByte() != 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(id);
dest.writeString(coin);
dest.writeString(money);
dest.writeString(give);
dest.writeString(money_usd);
dest.writeByte((byte) (checked ? 1 : 0));
}
public static final Creator<CoinBean> CREATOR = new Creator<CoinBean>() {
@Override
public CoinBean createFromParcel(Parcel in) {
return new CoinBean(in);
}
@Override
public CoinBean[] newArray(int size) {
return new CoinBean[size];
}
};
}

View File

@@ -0,0 +1,92 @@
package com.yunbao.common.bean;
import com.alibaba.fastjson.annotation.JSONField;
/**
* Created by cxf on 2019/4/11.
*/
public class CoinPayBean {
private String mId;
private String mName;
private String mThumb;
private String mHref;
private boolean mChecked;
private String mPayDesc;//支付描述,如推荐大额
private String mPriceNum;//显示价格的数量
@JSONField(name = "id")
public String getId() {
return mId;
}
@JSONField(name = "id")
public void setId(String id) {
mId = id;
}
@JSONField(name = "name")
public String getName() {
return mName;
}
@JSONField(name = "name")
public void setName(String name) {
mName = name;
}
@JSONField(name = "payDesc")
public String getPayDesc() {
return mPayDesc;
}
@JSONField(name = "payDesc")
public void setPayDesc(String payDesc) {
mPayDesc = payDesc;
}
@JSONField(name = "priceNum")
public String getPriceNum() {
return mPriceNum;
}
@JSONField(name = "priceNum")
public void setPriceNum(String priceNum) {
mPriceNum = priceNum;
}
@JSONField(name = "thumb")
public String getThumb() {
return mThumb;
}
@JSONField(name = "thumb")
public void setThumb(String thumb) {
mThumb = thumb;
}
@JSONField(name = "href")
public String getHref() {
return mHref;
}
@JSONField(name = "href")
public void setHref(String href) {
mHref = href;
}
@JSONField(serialize = false)
public boolean isChecked() {
return mChecked;
}
@JSONField(serialize = false)
public void setChecked(boolean checked) {
mChecked = checked;
}
}

View File

@@ -0,0 +1,566 @@
package com.yunbao.common.bean;
import com.alibaba.fastjson.annotation.JSONField;
import java.util.Arrays;
import java.util.List;
/**
* Created by cxf on 2017/8/5.
*/
public class ConfigBean {
private String version;//Android apk安装包 版本号
private String downloadApkUrl;//Android apk安装包 下载地址
private String updateDes;//版本更新描述
private String liveWxShareUrl;//直播间微信分享地址
private String liveShareTitle;//直播间分享标题
private String liveShareDes;//直播间分享描述
private String videoShareTitle;//短视频分享标题
private String videoShareDes;//短视频分享描述
private int videoAuditSwitch;//短视频审核是否开启
private int videoCloudType;//短视频云储存类型 1七牛云 2腾讯云
private String videoQiNiuHost;//短视频七牛云域名
private String txCosAppId;//腾讯云存储appId
private String txCosRegion;//腾讯云存储区域
private String txCosBucketName;//腾讯云存储桶名字
private String txCosVideoPath;//腾讯云存储视频文件夹
private String txCosImagePath;//腾讯云存储图片文件夹
private String coinName;//钻石名称
private String goldCoinName;//金币名称
private String votesName;//映票名称
private String[] liveTimeCoin;//直播间计时收费规则
private String[] loginType;//三方登录类型
private String[][] liveType;//直播间开播类型
private String[] shareType;//分享类型
private List<LiveClassBean> liveClass;//直播分类
private int maintainSwitch;//维护开关
private String maintainTips;//维护提示
private String beautyKey;//萌颜鉴权码
private int beautyMeiBai;//萌颜美白数值
private int beautyMoPi;//萌颜磨皮数值
private int beautyBaoHe;//萌颜饱和数值
private int beautyFenNen;//萌颜粉嫩数值
private int beautyBigEye;//萌颜大眼数值
private int beautyFace;//萌颜瘦脸数值
private int faceNarrowing;//窄脸
private String mAdInfo;//引导页 广告信息
private int priMsgSwitch;//私信开关
private int forceUpdate;//强制更新
private String sproutType;//美颜类型,1-基础美颜2-萌颜3-360美颜
private String paster360Url;//360贴纸下载地址
private String pkTime;//主播pk时间
private String serverUrl;//客服地址
private String AllServerGiftIcon;//全服通知横幅icon
private String turntableEnable;//转盘使能
private String txVideoUgcLicenceUrl;//腾讯直播视频鉴权
private String txPlayUgcLicenceUrl;//腾讯短视频鉴权
private String txVideoUgcKey;
@JSONField(name = "tx_play_ugc_licence_url")
public String getTxPlayUgcLicenceUrl() {
return txPlayUgcLicenceUrl;
}
@JSONField(name = "tx_play_ugc_licence_url")
public void setTxPlayUgcLicenceUrl(String txPlayUgcLicenceUrl) {
this.txPlayUgcLicenceUrl = txPlayUgcLicenceUrl;
}
@Override
public String toString() {
return "ConfigBean{" +
"version='" + version + '\'' +
", downloadApkUrl='" + downloadApkUrl + '\'' +
", updateDes='" + updateDes + '\'' +
", liveWxShareUrl='" + liveWxShareUrl + '\'' +
", liveShareTitle='" + liveShareTitle + '\'' +
", liveShareDes='" + liveShareDes + '\'' +
", videoShareTitle='" + videoShareTitle + '\'' +
", videoShareDes='" + videoShareDes + '\'' +
", videoAuditSwitch=" + videoAuditSwitch +
", videoCloudType=" + videoCloudType +
", videoQiNiuHost='" + videoQiNiuHost + '\'' +
", txCosAppId='" + txCosAppId + '\'' +
", txCosRegion='" + txCosRegion + '\'' +
", txCosBucketName='" + txCosBucketName + '\'' +
", txCosVideoPath='" + txCosVideoPath + '\'' +
", txCosImagePath='" + txCosImagePath + '\'' +
", coinName='" + coinName + '\'' +
", goldCoinName='" + goldCoinName + '\'' +
", votesName='" + votesName + '\'' +
", liveTimeCoin=" + Arrays.toString(liveTimeCoin) +
", loginType=" + Arrays.toString(loginType) +
", liveType=" + Arrays.toString(liveType) +
", shareType=" + Arrays.toString(shareType) +
", liveClass=" + liveClass +
", maintainSwitch=" + maintainSwitch +
", maintainTips='" + maintainTips + '\'' +
", beautyKey='" + beautyKey + '\'' +
", beautyMeiBai=" + beautyMeiBai +
", beautyMoPi=" + beautyMoPi +
", beautyBaoHe=" + beautyBaoHe +
", beautyFenNen=" + beautyFenNen +
", beautyBigEye=" + beautyBigEye +
", beautyFace=" + beautyFace +
", faceNarrowing=" + faceNarrowing +
", mAdInfo='" + mAdInfo + '\'' +
", priMsgSwitch=" + priMsgSwitch +
", forceUpdate=" + forceUpdate +
", sproutType='" + sproutType + '\'' +
", paster360Url='" + paster360Url + '\'' +
", pkTime='" + pkTime + '\'' +
", serverUrl='" + serverUrl + '\'' +
", AllServerGiftIcon='" + AllServerGiftIcon + '\'' +
", turntableEnable='" + turntableEnable + '\'' +
", txVideoUgcLicenceUrl='" + txVideoUgcLicenceUrl + '\'' +
", txVideoUgcKey='" + txVideoUgcKey + '\'' +
'}';
}
@JSONField(name = "apk_ver")
public String getVersion() {
return version;
}
@JSONField(name = "apk_ver")
public void setVersion(String version) {
this.version = version;
}
@JSONField(name = "apk_url")
public String getDownloadApkUrl() {
return downloadApkUrl;
}
@JSONField(name = "apk_url")
public void setDownloadApkUrl(String downloadApkUrl) {
this.downloadApkUrl = downloadApkUrl;
}
@JSONField(name = "apk_des")
public String getUpdateDes() {
return updateDes;
}
@JSONField(name = "apk_des")
public void setUpdateDes(String updateDes) {
this.updateDes = updateDes;
}
@JSONField(name = "wx_siteurl")
public void setLiveWxShareUrl(String liveWxShareUrl) {
this.liveWxShareUrl = liveWxShareUrl;
}
@JSONField(name = "wx_siteurl")
public String getLiveWxShareUrl() {
return liveWxShareUrl;
}
@JSONField(name = "share_title")
public String getLiveShareTitle() {
return liveShareTitle;
}
@JSONField(name = "share_title")
public void setLiveShareTitle(String liveShareTitle) {
this.liveShareTitle = liveShareTitle;
}
@JSONField(name = "share_des")
public String getLiveShareDes() {
return liveShareDes;
}
@JSONField(name = "share_des")
public void setLiveShareDes(String liveShareDes) {
this.liveShareDes = liveShareDes;
}
@JSONField(name = "name_coin")
public String getCoinName() {
return coinName;
}
@JSONField(name = "name_coin")
public void setCoinName(String coinName) {
this.coinName = coinName;
}
@JSONField(name = "name_votes")
public String getVotesName() {
return votesName;
}
@JSONField(name = "name_votes")
public void setVotesName(String votesName) {
this.votesName = votesName;
}
@JSONField(name = "live_time_coin")
public String[] getLiveTimeCoin() {
return liveTimeCoin;
}
@JSONField(name = "live_time_coin")
public void setLiveTimeCoin(String[] liveTimeCoin) {
this.liveTimeCoin = liveTimeCoin;
}
@JSONField(name = "login_type")
public String[] getLoginType() {
return loginType;
}
@JSONField(name = "login_type")
public void setLoginType(String[] loginType) {
this.loginType = loginType;
}
@JSONField(name = "live_type")
public String[][] getLiveType() {
return liveType;
}
@JSONField(name = "live_type")
public void setLiveType(String[][] liveType) {
this.liveType = liveType;
}
@JSONField(name = "share_type")
public String[] getShareType() {
return shareType;
}
@JSONField(name = "share_type")
public void setShareType(String[] shareType) {
this.shareType = shareType;
}
@JSONField(name = "liveclass")
public List<LiveClassBean> getLiveClass() {
return liveClass;
}
@JSONField(name = "liveclass")
public void setLiveClass(List<LiveClassBean> liveClass) {
this.liveClass = liveClass;
}
@JSONField(name = "maintain_switch")
public int getMaintainSwitch() {
return maintainSwitch;
}
@JSONField(name = "maintain_switch")
public void setMaintainSwitch(int maintainSwitch) {
this.maintainSwitch = maintainSwitch;
}
@JSONField(name = "maintain_tips")
public String getMaintainTips() {
return maintainTips;
}
@JSONField(name = "maintain_tips")
public void setMaintainTips(String maintainTips) {
this.maintainTips = maintainTips;
}
@JSONField(name = "sprout_key")
public String getBeautyKey() {
return beautyKey;
}
@JSONField(name = "sprout_key")
public void setBeautyKey(String beautyKey) {
this.beautyKey = beautyKey;
}
@JSONField(name = "sprout_white")
public int getBeautyMeiBai() {
return beautyMeiBai;
}
@JSONField(name = "sprout_white")
public void setBeautyMeiBai(int beautyMeiBai) {
this.beautyMeiBai = beautyMeiBai;
}
@JSONField(name = "sprout_skin")
public int getBeautyMoPi() {
return beautyMoPi;
}
@JSONField(name = "sprout_skin")
public void setBeautyMoPi(int beautyMoPi) {
this.beautyMoPi = beautyMoPi;
}
@JSONField(name = "sprout_saturated")
public int getBeautyBaoHe() {
return beautyBaoHe;
}
@JSONField(name = "sprout_saturated")
public void setBeautyBaoHe(int beautyBaoHe) {
this.beautyBaoHe = beautyBaoHe;
}
@JSONField(name = "sprout_pink")
public int getBeautyFenNen() {
return beautyFenNen;
}
@JSONField(name = "sprout_pink")
public void setBeautyFenNen(int beautyFenNen) {
this.beautyFenNen = beautyFenNen;
}
@JSONField(name = "sprout_eye")
public int getBeautyBigEye() {
return beautyBigEye;
}
@JSONField(name = "sprout_eye")
public void setBeautyBigEye(int beautyBigEye) {
this.beautyBigEye = beautyBigEye;
}
@JSONField(name = "sprout_face")
public int getBeautyFace() {
return beautyFace;
}
@JSONField(name = "sprout_face")
public void setBeautyFace(int beautyFace) {
this.beautyFace = beautyFace;
}
@JSONField(name = "sprout_face_narrowing")
public int getBeautyFaceNarrowing() {
return faceNarrowing;
}
@JSONField(name = "sprout_face_narrowing")
public void setBeautyFaceNarrowing(int faceNarrowing) {
this.faceNarrowing = faceNarrowing;
}
public String[] getVideoShareTypes() {
return shareType;
}
@JSONField(name = "video_share_title")
public String getVideoShareTitle() {
return videoShareTitle;
}
@JSONField(name = "video_share_title")
public void setVideoShareTitle(String videoShareTitle) {
this.videoShareTitle = videoShareTitle;
}
@JSONField(name = "video_share_des")
public String getVideoShareDes() {
return videoShareDes;
}
@JSONField(name = "video_share_des")
public void setVideoShareDes(String videoShareDes) {
this.videoShareDes = videoShareDes;
}
@JSONField(name = "video_audit_switch")
public int getVideoAuditSwitch() {
return videoAuditSwitch;
}
@JSONField(name = "video_audit_switch")
public void setVideoAuditSwitch(int videoAuditSwitch) {
this.videoAuditSwitch = videoAuditSwitch;
}
@JSONField(name = "cloudtype")
public int getVideoCloudType() {
return videoCloudType;
}
@JSONField(name = "cloudtype")
public void setVideoCloudType(int videoCloudType) {
this.videoCloudType = videoCloudType;
}
@JSONField(name = "qiniu_domain")
public String getVideoQiNiuHost() {
return videoQiNiuHost;
}
@JSONField(name = "qiniu_domain")
public void setVideoQiNiuHost(String videoQiNiuHost) {
this.videoQiNiuHost = videoQiNiuHost;
}
@JSONField(name = "txcloud_appid")
public String getTxCosAppId() {
return txCosAppId;
}
@JSONField(name = "txcloud_appid")
public void setTxCosAppId(String txCosAppId) {
this.txCosAppId = txCosAppId;
}
@JSONField(name = "txcloud_region")
public String getTxCosRegion() {
return txCosRegion;
}
@JSONField(name = "txcloud_region")
public void setTxCosRegion(String txCosRegion) {
this.txCosRegion = txCosRegion;
}
@JSONField(name = "txcloud_bucket")
public String getTxCosBucketName() {
return txCosBucketName;
}
@JSONField(name = "txcloud_bucket")
public void setTxCosBucketName(String txCosBucketName) {
this.txCosBucketName = txCosBucketName;
}
@JSONField(name = "txvideofolder")
public String getTxCosVideoPath() {
return txCosVideoPath;
}
@JSONField(name = "txvideofolder")
public void setTxCosVideoPath(String txCosVideoPath) {
this.txCosVideoPath = txCosVideoPath;
}
@JSONField(name = "tximgfolder")
public String getTxCosImagePath() {
return txCosImagePath;
}
@JSONField(name = "tximgfolder")
public void setTxCosImagePath(String txCosImagePath) {
this.txCosImagePath = txCosImagePath;
}
@JSONField(name = "guide")
public String getAdInfo() {
return mAdInfo;
}
@JSONField(name = "guide")
public void setAdInfo(String adInfo) {
mAdInfo = adInfo;
}
@JSONField(name = "letter_switch")
public int getPriMsgSwitch() {
return priMsgSwitch;
}
@JSONField(name = "letter_switch")
public void setPriMsgSwitch(int priMsgSwitch) {
this.priMsgSwitch = priMsgSwitch;
}
@JSONField(name = "isup")
public int getForceUpdate() {
return forceUpdate;
}
@JSONField(name = "isup")
public void setForceUpdate(int forceUpdate) {
this.forceUpdate = forceUpdate;
}
@JSONField(name = "sprout_type")
public String getSproutType() {
return sproutType;
}
@JSONField(name = "sprout_type")
public void setSproutType(String sprout_type) {
this.sproutType = sprout_type;
}
@JSONField(name = "turntable_enable")
public String getTurntableEnable() {
return turntableEnable;
}
@JSONField(name = "turntable_enable")
public void setTurntableEnable(String turntable) {
this.turntableEnable = turntable;
}
@JSONField(name = "tx_video_ugc_licence_url")
public String getTxVideoUgcLicenceUrl() {
return txVideoUgcLicenceUrl;
}
@JSONField(name = "tx_video_ugc_licence_url")
public void setTxVideoUgcLicenceUrl(String txVideoUgcLicenceUrl) {
this.txVideoUgcLicenceUrl = txVideoUgcLicenceUrl;
}
@JSONField(name = "tx_video_ugc_key")
public String getTxVideoUgcKey() {
return txVideoUgcKey;
}
@JSONField(name = "tx_video_ugc_key")
public void setTxVideoUgcKey(String txVideoUgcKey) {
this.txVideoUgcKey = txVideoUgcKey;
}
@JSONField(name = "360_paster_url")
public String getPaster360Url() {
return paster360Url;
}
@JSONField(name = "360_paster_url")
public void setPaster360Url(String paster360Url) {
this.paster360Url = paster360Url;
}
@JSONField(name = "live_pk_time")
public String getPkTime() {
return pkTime;
}
@JSONField(name = "live_pk_time")
public void setPkTime(String time) {
this.pkTime = time;
}
@JSONField(name = "service_url")
public String getCustomerServerUrl() {
return serverUrl;
}
@JSONField(name = "service_url")
public void setCustomerServerUrl(String serverUrl) {
this.serverUrl = serverUrl;
}
@JSONField(name = "AllServerGiftIcon")
public String getAllServerGiftIcon() {
return AllServerGiftIcon;
}
@JSONField(name = "AllServerGiftIcon")
public void setAllServerGiftIcon(String allServerGiftIcon) {
AllServerGiftIcon = allServerGiftIcon;
}
@JSONField(name = "goldCoinName")
public String getGoldCoinName() {
return goldCoinName;
}
@JSONField(name = "goldCoinName")
public void setGoldCoinName(String goldCoinName) {
this.goldCoinName = goldCoinName;
}
}

View File

@@ -0,0 +1,63 @@
package com.yunbao.common.bean;
import com.alibaba.fastjson.annotation.JSONField;
/**
* Created by cxf on 2018/10/9.
*/
public class FansMedalBean {
private int level;
private String thumb;
private String color;
private String thumbIcon;
private String bgIcon;
@JSONField(name = "levelid")
public int getLevel() {
return level;
}
@JSONField(name = "levelid")
public void setLevel(int level) {
this.level = level;
}
@JSONField(name = "thumb")
public String getThumb() {
return thumb;
}
@JSONField(name = "thumb")
public void setThumb(String thumb) {
this.thumb = thumb;
}
@JSONField(name = "colour")
public String getColor() {
return color;
}
@JSONField(name = "colour")
public void setColor(String color) {
this.color = color;
}
@JSONField(name = "thumb_mark")
public String getThumbIcon() {
return thumbIcon;
}
@JSONField(name = "thumb_mark")
public void setThumbIcon(String thumbIcon) {
this.thumbIcon = thumbIcon;
}
@JSONField(name = "bg")
public String getBgIcon() {
return bgIcon;
}
@JSONField(name = "bg")
public void setBgIcon(String bgIcon) {
this.bgIcon = bgIcon;
}
}

View File

@@ -0,0 +1,42 @@
package com.yunbao.common.bean;
import java.util.List;
public class GoogleBean {
private String id;
private String terminal;
private String charge_type;
private String is_hide;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTerminal() {
return terminal;
}
public void setTerminal(String terminal) {
this.terminal = terminal;
}
public String getCharge_type() {
return charge_type;
}
public void setCharge_type(String charge_type) {
this.charge_type = charge_type;
}
public String getIs_hide() {
return is_hide;
}
public void setIs_hide(String is_hide) {
this.is_hide = is_hide;
}
}

View File

@@ -0,0 +1,125 @@
package com.yunbao.common.bean;
import android.os.Parcel;
import android.os.Parcelable;
/**
* Created by Chen Haoxuan on 2022/4/30.
* Description:
*/
public class ImageEntity implements Parcelable {
private int id;
private String path;
private String thumbPath;
private boolean isSelect;
private String folderName;
private String name;
private long date;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
public String getThumbPath() {
return thumbPath;
}
public void setThumbPath(String thumbPath) {
this.thumbPath = thumbPath;
}
public boolean isSelect() {
return isSelect;
}
public void setSelect(boolean select) {
isSelect = select;
}
public String getFolderName() {
return folderName;
}
public void setFolderName(String folderName) {
this.folderName = folderName;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public long getDate() {
return date;
}
public void setDate(long date) {
this.date = date;
}
@Override
public boolean equals(Object o) {
if (o instanceof ImageEntity) {
return this.path.equals(((ImageEntity) o).getPath());
}
return false;
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(this.id);
dest.writeString(this.path);
dest.writeString(this.thumbPath);
dest.writeByte(this.isSelect ? (byte) 1 : (byte) 0);
dest.writeString(this.folderName);
dest.writeString(this.name);
dest.writeLong(this.date);
}
public ImageEntity() {
}
protected ImageEntity(Parcel in) {
this.id = in.readInt();
this.path = in.readString();
this.thumbPath = in.readString();
this.isSelect = in.readByte() != 0;
this.folderName = in.readString();
this.name = in.readString();
this.date = in.readLong();
}
public static final Creator<ImageEntity> CREATOR = new Creator<ImageEntity>() {
@Override
public ImageEntity createFromParcel(Parcel source) {
return new ImageEntity(source);
}
@Override
public ImageEntity[] newArray(int size) {
return new ImageEntity[size];
}
};
}

View File

@@ -0,0 +1,54 @@
package com.yunbao.common.bean;
import java.util.ArrayList;
/**
* Created by Chen Haoxuan on 2022/4/30.
*
*/
public class ImageFolderEntity {
private String name;
private String path;
private String albumPath;
private ArrayList<ImageEntity> images = new ArrayList<>();
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
public ArrayList<ImageEntity> getImages() {
return images;
}
public String getAlbumPath() {
return albumPath;
}
public void setAlbumPath(String albumPath) {
this.albumPath = albumPath;
}
@Override
public boolean equals(Object o) {
if (o != null && o instanceof ImageFolderEntity) {
if (((ImageFolderEntity) o).getPath() == null && path != null)
return false;
String oPath = ((ImageFolderEntity) o).getPath().toLowerCase();
return oPath.equals(this.path.toLowerCase());
}
return false;
}
}

View File

@@ -0,0 +1,17 @@
package com.yunbao.common.bean;
public class JsTurnTableBean {
String giftId;
public JsTurnTableBean(String giftId) {
this.giftId = giftId;
}
public String getGiftId() {
return giftId;
}
public void setGiftId(String giftId) {
this.giftId = giftId;
}
}

View File

@@ -0,0 +1,17 @@
package com.yunbao.common.bean;
public class JsTurnTableBean2 {
String giftId;
public JsTurnTableBean2(String giftId) {
this.giftId = giftId;
}
public String getGiftId() {
return giftId;
}
public void setGiftId(String giftId) {
this.giftId = giftId;
}
}

View File

@@ -0,0 +1,17 @@
package com.yunbao.common.bean;
public class JsWishBean {
String giftId;
public JsWishBean(String giftId) {
this.giftId = giftId;
}
public String getGiftId() {
return giftId;
}
public void setGiftId(String giftId) {
this.giftId = giftId;
}
}

View File

@@ -0,0 +1,61 @@
package com.yunbao.common.bean;
import com.alibaba.fastjson.annotation.JSONField;
/**
* Created by cxf on 2018/10/9.
*/
public class LevelBean {
private int level;
private String thumb;
private String color;
private String thumbIcon;
private String bgIcon;
@JSONField(name = "levelid")
public int getLevel() {
return level;
}
@JSONField(name = "levelid")
public void setLevel(int level) {
this.level = level;
}
public String getThumb() {
return thumb;
}
public void setThumb(String thumb) {
this.thumb = thumb;
}
@JSONField(name = "colour")
public String getColor() {
return color;
}
@JSONField(name = "colour")
public void setColor(String color) {
this.color = color;
}
@JSONField(name = "thumb_mark")
public String getThumbIcon() {
return thumbIcon;
}
@JSONField(name = "thumb_mark")
public void setThumbIcon(String thumbIcon) {
this.thumbIcon = thumbIcon;
}
@JSONField(name = "bg")
public String getBgIcon() {
return bgIcon;
}
@JSONField(name = "bg")
public void setBgIcon(String bgIcon) {
this.bgIcon = bgIcon;
}
}

View File

@@ -0,0 +1,127 @@
package com.yunbao.common.bean;
import com.alibaba.fastjson.annotation.JSONField;
/**
* Created by cxf on 2017/8/22.
*/
public class LiveChatBean {
public static final int NORMAL = 0;
public static final int SYSTEM = 1;
public static final int GIFT = 2;
public static final int ENTER_ROOM = 3;
public static final int LIGHT = 4;
public static final int RED_PACK = 5;
private String id;
private String userNiceName;
private int level;
private String content;
private int heart;
private int type; //0是普通消息 1是系统消息 2是礼物消息
private String liangName;
private int vipType;
private int guardType;
private boolean anchor;
private boolean manager;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
@JSONField(name = "user_nicename")
public String getUserNiceName() {
return userNiceName;
}
@JSONField(name = "user_nicename")
public void setUserNiceName(String userNiceName) {
this.userNiceName = userNiceName;
}
public int getLevel() {
return level;
}
public void setLevel(int level) {
this.level = level;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public int getHeart() {
return heart;
}
public void setHeart(int heart) {
this.heart = heart;
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
@JSONField(name = "liangname")
public String getLiangName() {
return liangName;
}
@JSONField(name = "liangname")
public void setLiangName(String liangName) {
if(!"0".equals(liangName)){
this.liangName = liangName;
}
}
public boolean isAnchor() {
return anchor;
}
public void setAnchor(boolean anchor) {
this.anchor = anchor;
}
@JSONField(name = "vip_type")
public int getVipType() {
return vipType;
}
@JSONField(name = "vip_type")
public void setVipType(int vipType) {
this.vipType = vipType;
}
public boolean isManager() {
return manager;
}
public void setManager(boolean manager) {
this.manager = manager;
}
@JSONField(name = "guard_type")
public int getGuardType() {
return guardType;
}
@JSONField(name = "guard_type")
public void setGuardType(int guardType) {
this.guardType = guardType;
}
}

View File

@@ -0,0 +1,75 @@
package com.yunbao.common.bean;
import com.alibaba.fastjson.annotation.JSONField;
/**
* Created by cxf on 2018/9/25.
*/
public class LiveClassBean {
protected int id;
protected String name;
protected String thumb;
protected int orderNo;
private boolean isAll;
private String des;
private boolean checked;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getThumb() {
return thumb;
}
public void setThumb(String thumb) {
this.thumb = thumb;
}
@JSONField(name = "orderno")
public int getOrderNo() {
return orderNo;
}
@JSONField(name = "orderno")
public void setOrderNo(int orderNo) {
this.orderNo = orderNo;
}
public boolean isAll() {
return isAll;
}
public void setAll(boolean all) {
isAll = all;
}
public String getDes() {
return des;
}
public void setDes(String des) {
this.des = des;
}
public boolean isChecked() {
return checked;
}
public void setChecked(boolean checked) {
this.checked = checked;
}
}

View File

@@ -0,0 +1,167 @@
package com.yunbao.common.bean;
import android.view.View;
import com.alibaba.fastjson.annotation.JSONField;
/**
* Created by cxf on 2018/10/12.
*/
public class LiveGiftBean {
// public static final int TYPE_NORMAL = 0;
// public static final int TYPE_DELUXE = 1;
// public static final int MARK_NORMAL = 0;
// public static final int MARK_HOT = 1;
// public static final int MARK_GUARD = 2;
// public static final int MARK_LUCK = 3;
private int id;
private int type;//0 普通礼物 1是豪华礼物
private int mark;// 0 普通 1热门 2守护 3幸运
private String name;
private String price;
private String icon;
private boolean checked;
private int page;
private View mView;
private String sendType;//支付是金币还是钻石
private String mGiftNum;
private String num;//心愿单添加礼物和数量
private String swf;
private String isweek;
private String end_time;
public String getEnd_time() {
return end_time;
}
public void setEnd_time(String end_time) {
this.end_time = end_time;
}
public String getIsweek() {
return isweek;
}
public void setIsweek(String isweek) {
this.isweek = isweek;
}
public String getSwf() {
return swf;
}
public void setSwf(String swf) {
this.swf = swf;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
public int getMark() {
return mark;
}
public void setMark(int mark) {
this.mark = mark;
}
@JSONField(name = "giftname")
public String getName() {
return name;
}
@JSONField(name = "giftname")
public void setName(String name) {
this.name = name;
}
@JSONField(name = "needcoin")
public String getPrice() {
return price;
}
@JSONField(name = "needcoin")
public void setPrice(String price) {
this.price = price;
}
@JSONField(name = "gifticon")
public String getIcon() {
return icon;
}
@JSONField(name = "gifticon")
public void setIcon(String icon) {
this.icon = icon;
}
public boolean isChecked() {
return checked;
}
public void setChecked(boolean checked) {
this.checked = checked;
}
public int getPage() {
return page;
}
public void setPage(int page) {
this.page = page;
}
public View getView() {
return mView;
}
public void setView(View view) {
mView = view;
}
public String getNum() {
return num;
}
public void setNum(String num) {
this.num = num;
}
@JSONField(name = "sendtype")
public String getSendType() {
return sendType;
}
@JSONField(name = "sendtype")
public void setSendType(String sendType) {
this.sendType = sendType;
}
@JSONField(name = "giftnum")
public String getGiftNum() {
return mGiftNum;
}
@JSONField(name = "giftnum")
public void setGiftNum(String giftNum) {
this.mGiftNum = giftNum;
}
}

View File

@@ -0,0 +1,142 @@
package com.yunbao.common.bean;
import android.view.View;
import com.alibaba.fastjson.annotation.JSONField;
/**
* Created by cxf on 2018/10/12.
*/
public class LiveGiftBean2 {
public static final int TYPE_NORMAL = 0;
public static final int TYPE_DELUXE = 1;
public static final int MARK_NORMAL = 0;
public static final int MARK_HOT = 1;
public static final int MARK_GUARD = 2;
public static final int MARK_LUCK = 3;
private int id;
private int type;//0 普通礼物 1是豪华礼物
private int mark;// 0 普通 1热门 2守护 3幸运
private String name;
private String price;
private String icon;
private boolean checked;
private int page;
private View mView;
private String sendType;
private String mGiftNum;
private String num;//心愿单添加礼物和数量
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
public int getMark() {
return mark;
}
public void setMark(int mark) {
this.mark = mark;
}
@JSONField(name = "giftname")
public String getName() {
return name;
}
@JSONField(name = "giftname")
public void setName(String name) {
this.name = name;
}
@JSONField(name = "needcoin")
public String getPrice() {
return price;
}
@JSONField(name = "needcoin")
public void setPrice(String price) {
this.price = price;
}
@JSONField(name = "gifticon")
public String getIcon() {
return icon;
}
@JSONField(name = "gifticon")
public void setIcon(String icon) {
this.icon = icon;
}
public boolean isChecked() {
return checked;
}
public void setChecked(boolean checked) {
this.checked = checked;
}
public int getPage() {
return page;
}
public void setPage(int page) {
this.page = page;
}
public View getView() {
return mView;
}
public void setView(View view) {
mView = view;
}
public String getNum() {
return num;
}
public void setNum(String num) {
this.num = num;
}
@JSONField(name = "sendtype")
public String getSendType() {
return sendType;
}
@JSONField(name = "sendtype")
public void setSendType(String sendType) {
this.sendType = sendType;
}
@JSONField(name = "giftnum")
public String getGiftNum() {
return mGiftNum;
}
@JSONField(name = "giftnum")
public void setGiftNum(String giftNum) {
this.mGiftNum = giftNum;
}
}

View File

@@ -0,0 +1,47 @@
package com.yunbao.common.bean;
public class LiveSvgGiftBean {
/**
* id : 227
* giftname : 愛心飛機
* swf : https://qny.shayucm.com/svga/%E6%84%9B%E5%BF%83%E9%A3%9B%E6%A9%9F.svga
*/
private String id;
private String giftname;
private String swf;
private String md5;
public String getMd5() {
return md5;
}
public void setMd5(String md5) {
this.md5 = md5;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getGiftname() {
return giftname;
}
public void setGiftname(String giftname) {
this.giftname = giftname;
}
public String getSwf() {
return swf;
}
public void setSwf(String swf) {
this.swf = swf;
}
}

View File

@@ -0,0 +1,57 @@
package com.yunbao.common.bean;
/**
* Created by cxf on 2018/9/21.
*/
public class LoginData {
private String mType;
private String mOpenID;
private String mNickName;
private String mAvatar;
public LoginData() {
}
public LoginData(String type, String openID, String nickName, String avatar) {
mType = type;
mOpenID = openID;
mNickName = nickName;
mAvatar = avatar;
}
public String getType() {
return mType;
}
public void setType(String type) {
mType = type;
}
public String getOpenID() {
return mOpenID;
}
public void setOpenID(String openID) {
mOpenID = openID;
}
public String getNickName() {
return mNickName;
}
public void setNickName(String nickName) {
mNickName = nickName;
}
public String getAvatar() {
return mAvatar;
}
public void setAvatar(String avatar) {
mAvatar = avatar;
}
}

View File

@@ -0,0 +1,92 @@
package com.yunbao.common.bean;
import java.util.List;
/**
* Created by cxf on 2018/7/18.
* 腾讯定位结果的实体类
*/
public class TxLocationBean {
private double lng;//经度
private double lat;//纬度
private String nation;//国家
private String province;//省
private String city;//市
private String district;//区
private String street;//街道
private String address;//完整地址
private List<TxLocationPoiBean> poiList;//周边
public double getLng() {
return lng;
}
public void setLng(double lng) {
this.lng = lng;
}
public double getLat() {
return lat;
}
public void setLat(double lat) {
this.lat = lat;
}
public String getNation() {
return nation;
}
public void setNation(String nation) {
this.nation = nation;
}
public String getProvince() {
return province;
}
public void setProvince(String province) {
this.province = province;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getDistrict() {
return district;
}
public void setDistrict(String district) {
this.district = district;
}
public String getStreet() {
return street;
}
public void setStreet(String street) {
this.street = street;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public List<TxLocationPoiBean> getPoiList() {
return poiList;
}
public void setPoiList(List<TxLocationPoiBean> poiList) {
this.poiList = poiList;
}
}

View File

@@ -0,0 +1,103 @@
package com.yunbao.common.bean;
/**
* Created by cxf on 2018/7/18.
* 腾讯定位sdk 的poi 实体类
*/
public class TxLocationPoiBean {
private String id;
private String title;
private String address;
private String category;
private Location location;
private double _distance;
private String _dir_desc;
private boolean checked;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
public Location getLocation() {
return location;
}
public void setLocation(Location location) {
this.location = location;
}
public double get_distance() {
return _distance;
}
public void set_distance(double _distance) {
this._distance = _distance;
}
public String get_dir_desc() {
return _dir_desc;
}
public void set_dir_desc(String _dir_desc) {
this._dir_desc = _dir_desc;
}
public boolean isChecked() {
return checked;
}
public void setChecked(boolean checked) {
this.checked = checked;
}
public class Location {
private double lat;
private double lng;
public double getLat() {
return lat;
}
public void setLat(double lat) {
this.lat = lat;
}
public double getLng() {
return lng;
}
public void setLng(double lng) {
this.lng = lng;
}
}
}

View File

@@ -0,0 +1,32 @@
package com.yunbao.common.bean;
/**
* Created by cxf on 2018/9/30.
*
*/
public class UpdataListBean {
private int index;
private String name;
public UpdataListBean(int index, String name) {
this.index = index;
this.name = name;
}
public int getIndex() {
return index;
}
public void setIndex(int index) {
this.index = index;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}

View File

@@ -0,0 +1,796 @@
package com.yunbao.common.bean;
import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;
import com.alibaba.fastjson.annotation.JSONField;
/**
* Created by cxf on 2017/8/14.
*/
public class UserBean implements Parcelable {
protected String id;
protected String userNiceName;
protected String avatar;
protected String avatarThumb;
protected int sex;
protected String signature;
protected String coin;
protected String gold;
protected String votes;
protected String consumption;
protected String votestotal;
protected String province;
protected String city;
protected String location;//所在地
protected String birthday;
protected int level;
protected int levelAnchor;
protected int lives;
protected int follows;
protected int fans;
protected Vip vip;
protected Liang liang;
protected Car car;
protected int medal_level;
protected String medal_name;
protected DressBean Dress;
protected String noble_id;
protected String yuanbao;
private String noble_name;
private String islive;
private String medal_no_display_src;
private String hot_num;
private String goodnum;
private String fans_pic;
private String gifticon;
private String department_name;
private String token_rong="";
private String noble_end_time;
private String slide;
private String users_type;
private String is_bind;
private String mobile;
private String front_task;
private String is_admin;
public String getIs_admin() {
return is_admin;
}
public void setIs_admin(String is_admin) {
this.is_admin = is_admin;
}
public String getFront_task() {
return front_task;
}
public void setFront_task(String front_task) {
this.front_task = front_task;
}
public String getMobile() {
return mobile;
}
public void setMobile(String mobile) {
this.mobile = mobile;
}
public String getIs_bind() {
return is_bind;
}
public void setIs_bind(String is_bind) {
this.is_bind = is_bind;
}
public String getUsers_type() {
return users_type;
}
public void setUsers_type(String users_type) {
this.users_type = users_type;
}
public String getSlide() {
return slide;
}
public void setSlide(String slide) {
this.slide = slide;
}
public String getNoble_end_time() {
return noble_end_time;
}
public void setNoble_end_time(String noble_end_time) {
this.noble_end_time = noble_end_time;
}
public String getToken_rong() {
return token_rong;
}
public void setToken_rong(String token_rong) {
this.token_rong = token_rong;
}
public String getDepartment_name() {
return department_name;
}
public void setDepartment_name(String department_name) {
this.department_name = department_name;
}
public String getMedal_name() {
return medal_name;
}
public void setMedal_name(String medal_name) {
this.medal_name = medal_name;
}
public String getGifticon() {
return gifticon;
}
public void setGifticon(String gifticon) {
this.gifticon = gifticon;
}
public String getFans_pic() {
return fans_pic;
}
public void setFans_pic(String fans_pic) {
this.fans_pic = fans_pic;
}
public String getGoodnum() {
return goodnum;
}
public void setGoodnum(String goodnum) {
this.goodnum = goodnum;
}
public String getHot_num() {
return hot_num;
}
public void setHot_num(String hot_num) {
this.hot_num = hot_num;
}
public String getMedal_no_display_src() {
return medal_no_display_src;
}
public void setMedal_no_display_src(String medal_no_display_src) {
this.medal_no_display_src = medal_no_display_src;
}
public String getIslive() {
return islive;
}
public void setIslive(String islive) {
this.islive = islive;
}
public String getNoble_name() {
return noble_name;
}
public void setNoble_name(String noble_name) {
this.noble_name = noble_name;
}
public String getYuanbao() {
return yuanbao;
}
public void setYuanbao(String yuanbao) {
this.yuanbao = yuanbao;
}
public String getNoble_id() {
return noble_id;
}
public void setNoble_id(String noble_id) {
this.noble_id = noble_id;
}
public DressBean getDress() {
return Dress;
}
public void setDress(DressBean dress) {
Dress = dress;
}
@JSONField(name = "gold")
public String getGold() {
return gold;
}
@JSONField(name = "gold")
public void setGold(String gold) {
this.gold = gold;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
@JSONField(name = "user_nicename")
public String getUserNiceName() {
return userNiceName;
}
@JSONField(name = "user_nicename")
public void setUserNiceName(String userNiceName) {
this.userNiceName = userNiceName;
}
public String getAvatar() {
return avatar;
}
public void setAvatar(String avatar) {
this.avatar = avatar;
}
@JSONField(name = "avatar_thumb")
public String getAvatarThumb() {
return avatarThumb;
}
@JSONField(name = "avatar_thumb")
public void setAvatarThumb(String avatarThumb) {
this.avatarThumb = avatarThumb;
}
public int getSex() {
return sex;
}
public void setSex(int sex) {
this.sex = sex;
}
public String getSignature() {
return signature;
}
public void setSignature(String signature) {
this.signature = signature;
}
public String getCoin() {
return coin;
}
public void setCoin(String coin) {
this.coin = coin;
}
public String getVotes() {
return votes;
}
public void setVotes(String votes) {
this.votes = votes;
}
public String getConsumption() {
return consumption;
}
public void setConsumption(String consumption) {
this.consumption = consumption;
}
public String getVotestotal() {
return votestotal;
}
public void setVotestotal(String votestotal) {
this.votestotal = votestotal;
}
public String getProvince() {
return province;
}
public void setProvince(String province) {
this.province = province;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getLocation() {
return location;
}
public void setLocation(String location) {
this.location = location;
}
public String getBirthday() {
return birthday;
}
public void setBirthday(String birthday) {
this.birthday = birthday;
}
public int getLevel() {
if (level == 0) {
level = 1;
}
return level;
}
public void setLevel(int level) {
this.level = level;
}
@JSONField(name = "medal_level'")
public int getMedalLevel() {
return medal_level;
}
@JSONField(name = "medal_level'")
public void setMedalLevel(int level) {
this.medal_level = level;
}
@JSONField(name = "medal_name'")
public String getMedalName() {
return medal_name;
}
@JSONField(name = "medal_name'")
public void setMedalName(String name) {
this.medal_name = name;
}
@JSONField(name = "level_anchor")
public int getLevelAnchor() {
return levelAnchor;
}
@JSONField(name = "level_anchor")
public void setLevelAnchor(int levelAnchor) {
this.levelAnchor = levelAnchor;
}
public int getLives() {
return lives;
}
public void setLives(int lives) {
this.lives = lives;
}
public int getFollows() {
return follows;
}
public void setFollows(int follows) {
this.follows = follows;
}
public int getFans() {
return fans;
}
public void setFans(int fans) {
this.fans = fans;
}
public Vip getVip() {
return vip;
}
public void setVip(Vip vip) {
this.vip = vip;
}
public Liang getLiang() {
return liang;
}
public void setLiang(Liang liang) {
this.liang = liang;
}
public Car getCar() {
return car;
}
public void setCar(Car car) {
this.car = car;
}
/**
* 显示靓号
*/
public String getLiangNameTip() {
if (this.liang != null) {
String liangName = this.liang.getName();
if (!TextUtils.isEmpty(liangName) && !"0".equals(liangName)) {
// return WordUtil.getString(R.string.live_liang) + ":" + liangName;
return liangName;
}
}
return "ID:" + this.id;
}
/**
* 获取靓号
*/
public String getGoodName() {
if (this.liang != null) {
return this.liang.getName();
}
return "0";
}
public int getVipType() {
if (this.vip != null) {
return this.vip.getType();
}
return 0;
}
public UserBean() {
}
protected UserBean(Parcel in) {
this.id = in.readString();
this.userNiceName = in.readString();
this.avatar = in.readString();
this.avatarThumb = in.readString();
this.sex = in.readInt();
this.signature = in.readString();
this.coin = in.readString();
this.votes = in.readString();
this.consumption = in.readString();
this.votestotal = in.readString();
this.province = in.readString();
this.city = in.readString();
this.location = in.readString();
this.birthday = in.readString();
this.level = in.readInt();
this.levelAnchor = in.readInt();
this.lives = in.readInt();
this.follows = in.readInt();
this.fans = in.readInt();
this.vip = in.readParcelable(Vip.class.getClassLoader());
this.liang = in.readParcelable(Liang.class.getClassLoader());
this.car = in.readParcelable(Car.class.getClassLoader());
this.medal_name = in.readString();
this.medal_level = in.readInt();
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(this.id);
dest.writeString(this.userNiceName);
dest.writeString(this.avatar);
dest.writeString(this.avatarThumb);
dest.writeInt(this.sex);
dest.writeString(this.signature);
dest.writeString(this.coin);
dest.writeString(this.votes);
dest.writeString(this.consumption);
dest.writeString(this.votestotal);
dest.writeString(this.province);
dest.writeString(this.city);
dest.writeString(this.location);
dest.writeString(this.birthday);
dest.writeInt(this.level);
dest.writeInt(this.levelAnchor);
dest.writeInt(this.lives);
dest.writeInt(this.follows);
dest.writeInt(this.fans);
dest.writeParcelable(this.vip, flags);
dest.writeParcelable(this.liang, flags);
dest.writeParcelable(this.car, flags);
dest.writeString(this.medal_name);
dest.writeInt(this.medal_level);
}
public static final Creator<UserBean> CREATOR = new Creator<UserBean>() {
@Override
public UserBean[] newArray(int size) {
return new UserBean[size];
}
@Override
public UserBean createFromParcel(Parcel in) {
return new UserBean(in);
}
};
public static class Vip implements Parcelable {
protected int type;
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
@Override
public int describeContents() {
return 0;
}
public Vip() {
}
public Vip(Parcel in) {
this.type = in.readInt();
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(this.type);
}
public static final Creator<Vip> CREATOR = new Creator<Vip>() {
@Override
public Vip[] newArray(int size) {
return new Vip[size];
}
@Override
public Vip createFromParcel(Parcel in) {
return new Vip(in);
}
};
}
public static class Liang implements Parcelable {
protected String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Liang() {
}
public Liang(Parcel in) {
this.name = in.readString();
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(this.name);
}
public static final Creator<Liang> CREATOR = new Creator<Liang>() {
@Override
public Liang createFromParcel(Parcel in) {
return new Liang(in);
}
@Override
public Liang[] newArray(int size) {
return new Liang[size];
}
};
}
public static class Car implements Parcelable {
protected int id;
protected String swf;
protected float swftime;
protected String words;
protected String car_swf_type;//0=全屏坐骑 1=横幅坐骑
protected String user_nicename;
protected String car_banner_img;
protected String car_colour;
protected Car(Parcel in) {
id = in.readInt();
swf = in.readString();
swftime = in.readFloat();
words = in.readString();
car_swf_type = in.readString();
user_nicename = in.readString();
car_banner_img = in.readString();
car_colour = in.readString();
}
public static final Creator<Car> CREATOR = new Creator<Car>() {
@Override
public Car createFromParcel(Parcel in) {
return new Car(in);
}
@Override
public Car[] newArray(int size) {
return new Car[size];
}
};
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getSwf() {
return swf;
}
public void setSwf(String swf) {
this.swf = swf;
}
public float getSwftime() {
return swftime;
}
public void setSwftime(float swftime) {
this.swftime = swftime;
}
public String getWords() {
return words;
}
public void setWords(String words) {
this.words = words;
}
public String getCar_swf_type() {
return car_swf_type;
}
public void setCar_swf_type(String car_swf_type) {
this.car_swf_type = car_swf_type;
}
public String getUser_nicename() {
return user_nicename;
}
public void setUser_nicename(String user_nicename) {
this.user_nicename = user_nicename;
}
public String getCar_banner_img() {
return car_banner_img;
}
public void setCar_banner_img(String car_banner_img) {
this.car_banner_img = car_banner_img;
}
public String getCar_colour() {
return car_colour;
}
public void setCar_colour(String car_colour) {
this.car_colour = car_colour;
}
public Car() {
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(id);
dest.writeString(swf);
dest.writeFloat(swftime);
dest.writeString(words);
dest.writeString(car_swf_type);
dest.writeString(user_nicename);
dest.writeString(car_banner_img);
dest.writeString(car_colour);
}
}
public static class DressBean {
private String avatar_frame;
private String medal;
private String bubble;
private String medal_new;
public String getMedal_new() {
return medal_new;
}
public void setMedal_new(String medal_new) {
this.medal_new = medal_new;
}
public String getAvatar_frame() {
return avatar_frame;
}
public void setAvatar_frame(String avatar_frame) {
this.avatar_frame = avatar_frame;
}
public String getMedal() {
return medal;
}
public void setMedal(String medal) {
this.medal = medal;
}
public String getBubble() {
return bubble;
}
public void setBubble(String bubble) {
this.bubble = bubble;
}
}
}

View File

@@ -0,0 +1,87 @@
package com.yunbao.common.bean;
/**
* Created by cxf on 2018/9/28.
* 我的 页面的item
*/
public class UserItemBean {
private int id;
private String name;
private String thumb;
private String href;
private boolean mGroupLast;
private boolean mAllLast;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getThumb() {
return thumb;
}
public void setThumb(String thumb) {
this.thumb = thumb;
}
public String getHref() {
return href;
}
public void setHref(String href) {
this.href = href;
}
public boolean isGroupLast() {
return mGroupLast;
}
public void setGroupLast(boolean groupLast) {
mGroupLast = groupLast;
}
public boolean isAllLast() {
return mAllLast;
}
public void setAllLast(boolean allLast) {
mAllLast = allLast;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
UserItemBean bean = (UserItemBean) o;
if (id != bean.id) return false;
if (name != null ? !name.equals(bean.name) : bean.name != null) return false;
if (thumb != null ? !thumb.equals(bean.thumb) : bean.thumb != null) return false;
return href != null ? href.equals(bean.href) : bean.href == null;
}
@Override
public int hashCode() {
int result = id;
result = 31 * result + (name != null ? name.hashCode() : 0);
result = 31 * result + (thumb != null ? thumb.hashCode() : 0);
result = 31 * result + (href != null ? href.hashCode() : 0);
return result;
}
}

View File

@@ -0,0 +1,189 @@
package com.yunbao.common.bean;
/**
* Created by Chen Haoxuan on 2022/4/11.
*/
public class VideoListBean {
private String id;
private String img_or_video;
private String img_json;
private String video;
private String content;//内容
private String talk_id;
private String is_top;
private String love_num;
private String comment_num;
private String share_num;
private String gift_num;
private String hot_num;
private String create_time;
private String ai_content;
private String user_name;//名字
private String user_avatar;//头像
private String is_attention;//-1=自己 1=关注了 2=没关注 0=没关注
private String user_id;
private String talk_name;
private String is_love;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getImg_or_video() {
return img_or_video;
}
public void setImg_or_video(String img_or_video) {
this.img_or_video = img_or_video;
}
public String getImg_json() {
return img_json;
}
public void setImg_json(String img_json) {
this.img_json = img_json;
}
public String getVideo() {
return video;
}
public void setVideo(String video) {
this.video = video;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getTalk_id() {
return talk_id;
}
public void setTalk_id(String talk_id) {
this.talk_id = talk_id;
}
public String getIs_top() {
return is_top;
}
public void setIs_top(String is_top) {
this.is_top = is_top;
}
public String getLove_num() {
return love_num;
}
public void setLove_num(String love_num) {
this.love_num = love_num;
}
public String getComment_num() {
return comment_num;
}
public void setComment_num(String comment_num) {
this.comment_num = comment_num;
}
public String getShare_num() {
return share_num;
}
public void setShare_num(String share_num) {
this.share_num = share_num;
}
public String getGift_num() {
return gift_num;
}
public void setGift_num(String gift_num) {
this.gift_num = gift_num;
}
public String getHot_num() {
return hot_num;
}
public void setHot_num(String hot_num) {
this.hot_num = hot_num;
}
public String getCreate_time() {
return create_time;
}
public void setCreate_time(String create_time) {
this.create_time = create_time;
}
public String getAi_content() {
return ai_content;
}
public void setAi_content(String ai_content) {
this.ai_content = ai_content;
}
public String getUser_name() {
return user_name;
}
public void setUser_name(String user_name) {
this.user_name = user_name;
}
public String getUser_avatar() {
return user_avatar;
}
public void setUser_avatar(String user_avatar) {
this.user_avatar = user_avatar;
}
public String getIs_attention() {
return is_attention;
}
public void setIs_attention(String is_attention) {
this.is_attention = is_attention;
}
public String getUser_id() {
return user_id;
}
public void setUser_id(String user_id) {
this.user_id = user_id;
}
public String getTalk_name() {
return talk_name;
}
public void setTalk_name(String talk_name) {
this.talk_name = talk_name;
}
public String getIs_love() {
return is_love;
}
public void setIs_love(String is_love) {
this.is_love = is_love;
}
}

View File

@@ -0,0 +1,45 @@
package com.yunbao.common.bean;
/**
* Created by Chen Haoxuan on 2022/6/21.
* 签到奖励实体类
*/
public class WeekListBean {
private String anchor_id;
private String anchor_name;
private String anchor_avatar;
private String seconds;
public String getAnchor_id() {
return anchor_id;
}
public void setAnchor_id(String anchor_id) {
this.anchor_id = anchor_id;
}
public String getAnchor_name() {
return anchor_name;
}
public void setAnchor_name(String anchor_name) {
this.anchor_name = anchor_name;
}
public String getAnchor_avatar() {
return anchor_avatar;
}
public void setAnchor_avatar(String anchor_avatar) {
this.anchor_avatar = anchor_avatar;
}
public String getSeconds() {
return seconds;
}
public void setSeconds(String seconds) {
this.seconds = seconds;
}
}

View File

@@ -0,0 +1,104 @@
package com.yunbao.common.custom;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
import androidx.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;
import com.yunbao.common.R;
/**
* Created by cxf on 2019/4/27.
*/
public class CircleProgress extends View {
private float mStrokeWidth;
private float mR;
private int mBgColor;
private int mFgColor;
private float mMaxProgress;
private float mCurProgress;
private Paint mBgPaint;
private Paint mFgPaint;
private float mX;
private RectF mRectF;
public CircleProgress(Context context) {
this(context, null);
}
public CircleProgress(Context context, @Nullable AttributeSet attrs) {
this(context, attrs, 0);
}
public CircleProgress(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.CircleProgress);
mBgColor = ta.getColor(R.styleable.CircleProgress_cp_bg_color, 0);
mFgColor = ta.getColor(R.styleable.CircleProgress_cp_fg_color, 0);
mStrokeWidth = ta.getDimension(R.styleable.CircleProgress_cp_stroke_width, 0);
mMaxProgress = ta.getFloat(R.styleable.CircleProgress_cp_max_progress, 0);
mCurProgress = ta.getFloat(R.styleable.CircleProgress_cp_cur_progress, 0);
ta.recycle();
initPaint();
}
private void initPaint() {
mBgPaint = new Paint();
mBgPaint.setAntiAlias(true);
mBgPaint.setDither(true);
mBgPaint.setColor(mBgColor);
mBgPaint.setStyle(Paint.Style.STROKE);
mBgPaint.setStrokeWidth(mStrokeWidth);
mFgPaint = new Paint();
mFgPaint.setAntiAlias(true);
mFgPaint.setDither(true);
mFgPaint.setColor(mFgColor);
mFgPaint.setStyle(Paint.Style.STROKE);
mFgPaint.setStrokeWidth(mStrokeWidth);
mRectF = new RectF();
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int widthSize = MeasureSpec.getSize(widthMeasureSpec);
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(widthSize, MeasureSpec.EXACTLY));
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
float offset = mStrokeWidth / 2;
mX = w / 2;
mR = mX - offset;
mRectF = new RectF();
mRectF.left = offset;
mRectF.top = offset;
mRectF.right = w - offset;
mRectF.bottom = mRectF.right;
}
@Override
protected void onDraw(Canvas canvas) {
canvas.drawCircle(mX, mX, mR, mBgPaint);
if (mMaxProgress > 0 && mCurProgress > 0) {
canvas.drawArc(mRectF, -90, mCurProgress / mMaxProgress * 360, false, mFgPaint);
}
}
public void setMaxProgress(float maxProgress) {
mMaxProgress = maxProgress;
}
public void setCurProgress(float curProgress) {
mCurProgress = curProgress;
invalidate();
}
}

View File

@@ -0,0 +1,90 @@
package com.yunbao.common.custom;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.widget.FrameLayout;
import com.yunbao.common.R;
/**
* Created by cxf on 2018/7/11.
*/
public class CoinGiveLayout extends FrameLayout {
private static final String TAG = "CoinGiveLayout";
private Paint mPaint;
private int mBgColor;
private float mRadius;
private float mRadiusD;
private float mArrowWidth;
private float mArrowHeight;
private float mArrowOffsetX;
private int mWidth;
private int mHeight;
private RectF mRectF;
public CoinGiveLayout(Context context) {
super(context, null);
}
public CoinGiveLayout(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public CoinGiveLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.CoinGiveLayout);
mBgColor = ta.getColor(R.styleable.CoinGiveLayout_cgl_bg_color, 0);
mRadius = ta.getDimension(R.styleable.CoinGiveLayout_cgl_radius, 0);
mArrowWidth = ta.getDimension(R.styleable.CoinGiveLayout_cgl_arrow_width, 0);
mArrowHeight = ta.getDimension(R.styleable.CoinGiveLayout_cgl_arrow_height, 0);
mArrowOffsetX = ta.getDimension(R.styleable.CoinGiveLayout_cgl_arrow_offset_x, 0);
ta.recycle();
initPaint();
mRadiusD = mRadius * 2;
mRectF = new RectF();
}
private void initPaint() {
mPaint = new Paint();
mPaint.setAntiAlias(true);
mPaint.setDither(true);
mPaint.setColor(mBgColor);
mPaint.setStyle(Paint.Style.FILL);
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
mWidth = w;
mHeight = h;
mRectF.left = 0;
mRectF.top = 0;
mRectF.right = w;
float bottom = h - mArrowHeight;
mRectF.bottom = bottom > 0 ? bottom : 0;
}
@Override
protected void dispatchDraw(Canvas canvas) {
canvas.drawRoundRect(mRectF, mRadius, mRadiusD, mPaint);
if (mArrowHeight > 0 && mArrowWidth > 0) {
Path path = new Path();
path.moveTo(mWidth - mArrowWidth - mArrowOffsetX, mHeight - mArrowHeight);
path.rLineTo(0, mArrowHeight);
path.rLineTo(mArrowWidth, -mArrowHeight);
path.close();
canvas.drawPath(path, mPaint);
}
super.dispatchDraw(canvas);
}
}

View File

@@ -0,0 +1,438 @@
package com.yunbao.common.custom;
import android.content.Context;
import android.content.res.TypedArray;
import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.SimpleItemAnimator;
import android.util.AttributeSet;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.footer.ClassicsFooter;
import com.scwang.smartrefresh.layout.header.ClassicsHeader;
import com.scwang.smartrefresh.layout.listener.OnLoadMoreListener;
import com.scwang.smartrefresh.layout.listener.OnRefreshListener;
import com.yunbao.common.R;
import com.yunbao.common.adapter.RefreshAdapter;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.utils.ToastUtil;
import java.util.List;
/**
* Created by cxf on 2018/6/7.
*/
public class CommonRefreshView extends FrameLayout implements View.OnClickListener {
private Context mContext;
private DataHelper mDataHelper;
private int mLayoutRes;
private View mContentView;
private SmartRefreshLayout mSmartRefreshLayout;
private ClassicsHeader mHeader;
private ClassicsFooter mFooter;
public RecyclerView mRecyclerView;
private FrameLayout mEmptyLayout;//没有数据的View
private View mLoadFailureView;//加载失败View
private boolean mRefreshEnable;//下拉刷新是否可用
private boolean mLoadMoreEnable;//上拉加载是否可用
private int mPageCount;//页数
private int mItemCount;//每页的Item个数
public CommonRefreshView(Context context) {
this(context, null);
}
public CommonRefreshView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public CommonRefreshView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
mContext = context;
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.CommonRefreshView);
mRefreshEnable = ta.getBoolean(R.styleable.CommonRefreshView_crv_refreshEnable, true);
mLoadMoreEnable = ta.getBoolean(R.styleable.CommonRefreshView_crv_loadMoreEnable, true);
mLayoutRes = ta.getResourceId(R.styleable.CommonRefreshView_crv_layout, R.layout.view_refresh_default);
mItemCount = ta.getInteger(R.styleable.CommonRefreshView_crv_itemCount, 20);
ta.recycle();
}
@Override
protected void onFinishInflate() {
super.onFinishInflate();
LayoutInflater inflater = LayoutInflater.from(mContext);
View view = inflater.inflate(mLayoutRes, this, false);
mContentView = view;
addView(view);
mSmartRefreshLayout = (SmartRefreshLayout) view.findViewById(R.id.refreshLayout);
mSmartRefreshLayout.setEnableLoadMoreWhenContentNotFull(false);//是否在列表不满一页时候开启上拉加载功能
mSmartRefreshLayout.setEnableFooterFollowWhenLoadFinished(true);//是否在全部加载结束之后Footer跟随内容
mSmartRefreshLayout.setEnableOverScrollBounce(false);//设置是否开启越界回弹功能默认true
mEmptyLayout = (FrameLayout) view.findViewById(R.id.no_data_container);
mLoadFailureView = view.findViewById(R.id.load_failure);
mRecyclerView = (RecyclerView) view.findViewById(R.id.recyclerView);
mRecyclerView.setHasFixedSize(true);
((SimpleItemAnimator) mRecyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
mSmartRefreshLayout.setOnRefreshListener(new OnRefreshListener() {
@Override
public void onRefresh(@NonNull RefreshLayout refreshLayout) {
refresh();
}
});
mSmartRefreshLayout.setOnLoadMoreListener(new OnLoadMoreListener() {
@Override
public void onLoadMore(@NonNull RefreshLayout refreshlayout) {
Log.i("t2", "来了哦");
loadMore();
}
});
mSmartRefreshLayout.setEnableRefresh(mRefreshEnable);
mSmartRefreshLayout.setEnableLoadMore(mLoadMoreEnable);
View btnReload = view.findViewById(R.id.btn_reload);
if (btnReload != null) {
btnReload.setOnClickListener(this);
}
int textColor = ContextCompat.getColor(mContext, R.color.textColor);
mHeader = findViewById(R.id.header);
mHeader.setAccentColor(textColor);
mFooter = findViewById(R.id.footer);
mFooter.setAccentColor(textColor);
mFooter.setTextSizeTitle(14);
}
private HttpCallback mRefreshCallback = new HttpCallback() {
private int mDataCount;
@Override
public void onSuccess(int code, String msg, String[] info) {
if (mDataHelper == null) {
return;
}
if (mLoadFailureView != null && mLoadFailureView.getVisibility() == View.VISIBLE) {
mLoadFailureView.setVisibility(View.INVISIBLE);
}
RefreshAdapter adapter = null;
RecyclerView.Adapter recyclerViewAdapter = mRecyclerView.getAdapter();
if (recyclerViewAdapter != null && recyclerViewAdapter instanceof RefreshAdapter) {
adapter = (RefreshAdapter) recyclerViewAdapter;
} else {
adapter = mDataHelper.getAdapter();
if (adapter == null) {
return;
}
mRecyclerView.setAdapter(adapter);
}
if (code != 0) {
ToastUtil.show(msg);
return;
}
if (info != null) {
List list = mDataHelper.processData(info);
if (list == null) {
return;
}
mDataCount = list.size();
if (mDataCount > 0) {
if (mEmptyLayout != null && mEmptyLayout.getVisibility() == View.VISIBLE) {
mEmptyLayout.setVisibility(View.INVISIBLE);
}
adapter.refreshData(list);
} else {
adapter.clearData();
if (mEmptyLayout != null && mEmptyLayout.getVisibility() != View.VISIBLE) {
mEmptyLayout.setVisibility(View.VISIBLE);
}
}
} else {
if (adapter != null) {
adapter.clearData();
}
if (mEmptyLayout != null && mEmptyLayout.getVisibility() != View.VISIBLE) {
mEmptyLayout.setVisibility(View.VISIBLE);
}
}
mDataHelper.onRefreshSuccess(adapter.getList(), adapter.getItemCount());
}
@Override
public void onError() {
if (mEmptyLayout != null && mEmptyLayout.getVisibility() == View.VISIBLE) {
mEmptyLayout.setVisibility(View.INVISIBLE);
}
if (mLoadFailureView != null) {
if (mLoadFailureView.getVisibility() != View.VISIBLE) {
if (mRecyclerView != null) {
RecyclerView.Adapter adapter = mRecyclerView.getAdapter();
if (adapter != null && adapter.getItemCount() > 0) {
ToastUtil.show(R.string.load_failure);
} else {
mLoadFailureView.setVisibility(View.VISIBLE);
}
} else {
mLoadFailureView.setVisibility(View.VISIBLE);
}
} else {
ToastUtil.show(R.string.load_failure);
}
}
if (mDataHelper != null) {
mDataHelper.onRefreshFailure();
}
}
@Override
public void onFinish() {
if (mSmartRefreshLayout != null) {
mSmartRefreshLayout.finishRefresh(true);
if (mDataCount < mItemCount) {
mSmartRefreshLayout.finishLoadMore(true);
}
}
}
};
private HttpCallback mLoadMoreCallback = new HttpCallback() {
private int mDataCount;
@Override
public void onSuccess(int code, String msg, String[] info) {
if (mDataHelper == null) {
mPageCount--;
return;
}
if (code != 0) {
ToastUtil.show(msg);
mPageCount--;
return;
}
if (mLoadFailureView != null && mLoadFailureView.getVisibility() == View.VISIBLE) {
mLoadFailureView.setVisibility(View.INVISIBLE);
}
if (info != null) {
List list = mDataHelper.processData(info);
if (list == null) {
mPageCount--;
return;
}
mDataCount = list.size();
RefreshAdapter adapter = mDataHelper.getAdapter();
if (mDataCount > 0) {
if (adapter != null) {
adapter.insertList(list);
}
} else {
mPageCount--;
}
mDataHelper.onLoadMoreSuccess(list, mDataCount);
} else {
mPageCount--;
}
}
@Override
public void onError() {
super.onError();
mPageCount--;
if (mDataHelper != null) {
mDataHelper.onLoadMoreFailure();
}
}
@Override
public void onFinish() {
Log.i("t2", "更多");
if (mSmartRefreshLayout != null) {
if (mDataCount <= 0) {
mSmartRefreshLayout.finishLoadMoreWithNoMoreData();
} else {
mSmartRefreshLayout.finishLoadMore(true);
}
}
}
};
public <T> void setDataHelper(DataHelper<T> dataHelper) {
mDataHelper = dataHelper;
}
public void setLayoutManager(RecyclerView.LayoutManager layoutManager) {
mRecyclerView.setLayoutManager(layoutManager);
}
public void setItemDecoration(ItemDecoration itemDecoration) {
mRecyclerView.addItemDecoration(itemDecoration);
}
public void showLoading() {
mPageCount = 1;
if (mSmartRefreshLayout != null) {
mSmartRefreshLayout.autoRefreshAnimationOnly();
}
if (mEmptyLayout != null && mEmptyLayout.getVisibility() == VISIBLE) {
mEmptyLayout.setVisibility(INVISIBLE);
}
if (mLoadFailureView != null && mLoadFailureView.getVisibility() == VISIBLE) {
mLoadFailureView.setVisibility(INVISIBLE);
}
}
public void showRefreshBar() {
if (mSmartRefreshLayout != null) {
mSmartRefreshLayout.autoRefresh(100);//延迟400毫秒后自动刷新
}
}
public void showEmpty() {
if (mEmptyLayout != null && mEmptyLayout.getVisibility() != VISIBLE) {
mEmptyLayout.setVisibility(VISIBLE);
}
}
public void hideEmpty() {
if (mEmptyLayout != null && mEmptyLayout.getVisibility() == VISIBLE) {
mEmptyLayout.setVisibility(INVISIBLE);
}
}
public void hideLoadFailure() {
if (mLoadFailureView != null && mLoadFailureView.getVisibility() == VISIBLE) {
mLoadFailureView.setVisibility(INVISIBLE);
}
}
public void initData() {
Log.i("t2", "AAAs1212");
refresh();
}
private void refresh() {
if (mDataHelper != null) {
Log.i("t2", "AAAs");
mPageCount = 1;
mDataHelper.loadData(mPageCount, mRefreshCallback);
}
}
private void loadMore() {
Log.i("t2", "来了哦111");
if (mDataHelper != null) {
Log.i("t2", "来了哦12121");
mPageCount++;
mDataHelper.loadData(mPageCount, mLoadMoreCallback);
}
}
public int getPageCount() {
return mPageCount;
}
public void setPageCount(int pageCount) {
mPageCount = pageCount;
}
public int getItemCount() {
return mItemCount;
}
public void setItemCount(int itemCount) {
mItemCount = itemCount;
}
public void setRefreshEnable(boolean enable) {
if (mSmartRefreshLayout != null) {
mSmartRefreshLayout.setEnableRefresh(enable);
}
}
public void setLoadMoreEnable(boolean enable) {
if (mSmartRefreshLayout != null) {
mSmartRefreshLayout.setEnableLoadMore(enable);
}
}
@Override
public void onClick(View v) {
if (v.getId() == R.id.btn_reload) {
refresh();
}
}
public interface DataHelper<T> {
RefreshAdapter<T> getAdapter();
void loadData(int p, HttpCallback callback);
List<T> processData(String[] info);
/**
* 下拉刷新成功
*
* @param list Adapter的全部数据的List
* @param listCount Adapter的全部数据的个数
*/
void onRefreshSuccess(List<T> list, int listCount);
/**
* 下拉刷新失败
*/
void onRefreshFailure();
/**
* 上拉加载成功
*
* @param loadItemList 本次加载到的数据
* @param loadItemCount 加载到的数据个数
*/
void onLoadMoreSuccess(List<T> loadItemList, int loadItemCount);
/**
* 加载失败
*/
void onLoadMoreFailure();
}
/**
* 空数据的布局
*/
public void setEmptyLayoutId(int noDataLayoutId) {
if (mEmptyLayout != null) {
mEmptyLayout.removeAllViews();
View v = LayoutInflater.from(mContext).inflate(noDataLayoutId, mEmptyLayout, false);
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) v.getLayoutParams();
params.gravity = Gravity.CENTER;
v.setLayoutParams(params);
mEmptyLayout.addView(v);
}
}
public View getContentView() {
return mContentView;
}
public void setRecyclerViewAdapter(RefreshAdapter adapter) {
if (mRecyclerView != null) {
mRecyclerView.setAdapter(adapter);
}
}
}

View File

@@ -0,0 +1,99 @@
package com.yunbao.common.custom;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import androidx.appcompat.widget.AppCompatCheckBox;
import android.util.AttributeSet;
import com.yunbao.common.R;
/**
* Created by cxf on 2017/7/19.
* 可以调节drawable大小的CheckBox
*/
public class DrawableCheckBox extends AppCompatCheckBox {
private int mTopWidth;
private int mTopHeight;
private int mLeftWidth;
private int mLeftHeight;
private int mRightWidth;
private int mRightHeight;
private int mBottomWidth;
private int mBottomHeight;
private Drawable mTopDrawable;
private Drawable mLeftDrawable;
private Drawable mRightDrawable;
private Drawable mBottomDrawable;
public DrawableCheckBox(Context context) {
this(context, null);
}
public DrawableCheckBox(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public DrawableCheckBox(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.DrawableTextView);
mTopWidth = (int) ta.getDimension(R.styleable.DrawableTextView_dt_top_width, 0);
mTopHeight = (int) ta.getDimension(R.styleable.DrawableTextView_dt_top_height, 0);
mLeftWidth = (int) ta.getDimension(R.styleable.DrawableTextView_dt_left_width, 0);
mLeftHeight = (int) ta.getDimension(R.styleable.DrawableTextView_dt_left_height, 0);
mRightWidth = (int) ta.getDimension(R.styleable.DrawableTextView_dt_right_width, 0);
mRightHeight = (int) ta.getDimension(R.styleable.DrawableTextView_dt_right_height, 0);
mBottomWidth = (int) ta.getDimension(R.styleable.DrawableTextView_dt_bottom_width, 0);
mBottomHeight = (int) ta.getDimension(R.styleable.DrawableTextView_dt_bottom_height, 0);
mTopDrawable = ta.getDrawable(R.styleable.DrawableTextView_dt_top_drawable);
mLeftDrawable = ta.getDrawable(R.styleable.DrawableTextView_dt_left_drawable);
mRightDrawable = ta.getDrawable(R.styleable.DrawableTextView_dt_right_drawable);
mBottomDrawable = ta.getDrawable(R.styleable.DrawableTextView_dt_bottom_drawable);
ta.recycle();
}
public void setTopDrawable(Drawable topDrawable) {
mTopDrawable = topDrawable;
}
public void setBottomDrawable(Drawable bottomDrawable) {
mBottomDrawable = bottomDrawable;
}
public void setLeftDrawable(Drawable leftDrawable) {
mLeftDrawable = leftDrawable;
}
public void setRightDrawable(Drawable rightDrawable) {
mRightDrawable = rightDrawable;
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
setCompoundDrawablesWithIntrinsicBounds(mLeftDrawable, mTopDrawable, mRightDrawable, mBottomDrawable);
}
@Override
public void setCompoundDrawablesWithIntrinsicBounds(Drawable left, Drawable top, Drawable right, Drawable bottom) {
if (left != null) {
left.setBounds(0, 0, mLeftWidth, mLeftHeight);
}
if (top != null) {
top.setBounds(0, 0, mTopWidth, mTopHeight);
}
if (right != null) {
right.setBounds(0, 0, mRightWidth, mRightHeight);
}
if (bottom != null) {
bottom.setBounds(0, 0, mBottomWidth, mBottomHeight);
}
setCompoundDrawables(left, top, right, bottom);
}
}

View File

@@ -0,0 +1,99 @@
package com.yunbao.common.custom;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import androidx.appcompat.widget.AppCompatRadioButton;
import android.util.AttributeSet;
import com.yunbao.common.R;
/**
* Created by cxf on 2017/7/19.
* 可以调节drawable大小的RadioButton
*/
public class DrawableRadioButton extends AppCompatRadioButton {
private int mTopWidth;
private int mTopHeight;
private int mLeftWidth;
private int mLeftHeight;
private int mRightWidth;
private int mRightHeight;
private int mBottomWidth;
private int mBottomHeight;
private Drawable mTopDrawable;
private Drawable mLeftDrawable;
private Drawable mRightDrawable;
private Drawable mBottomDrawable;
public DrawableRadioButton(Context context) {
this(context, null);
}
public DrawableRadioButton(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public DrawableRadioButton(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.DrawableTextView);
mTopWidth = (int) ta.getDimension(R.styleable.DrawableTextView_dt_top_width, 0);
mTopHeight = (int) ta.getDimension(R.styleable.DrawableTextView_dt_top_height, 0);
mLeftWidth = (int) ta.getDimension(R.styleable.DrawableTextView_dt_left_width, 0);
mLeftHeight = (int) ta.getDimension(R.styleable.DrawableTextView_dt_left_height, 0);
mRightWidth = (int) ta.getDimension(R.styleable.DrawableTextView_dt_right_width, 0);
mRightHeight = (int) ta.getDimension(R.styleable.DrawableTextView_dt_right_height, 0);
mBottomWidth = (int) ta.getDimension(R.styleable.DrawableTextView_dt_bottom_width, 0);
mBottomHeight = (int) ta.getDimension(R.styleable.DrawableTextView_dt_bottom_height, 0);
mTopDrawable = ta.getDrawable(R.styleable.DrawableTextView_dt_top_drawable);
mLeftDrawable = ta.getDrawable(R.styleable.DrawableTextView_dt_left_drawable);
mRightDrawable = ta.getDrawable(R.styleable.DrawableTextView_dt_right_drawable);
mBottomDrawable = ta.getDrawable(R.styleable.DrawableTextView_dt_bottom_drawable);
ta.recycle();
}
public void setTopDrawable(Drawable topDrawable) {
mTopDrawable = topDrawable;
}
public void setBottomDrawable(Drawable bottomDrawable) {
mBottomDrawable = bottomDrawable;
}
public void setLeftDrawable(Drawable leftDrawable) {
mLeftDrawable = leftDrawable;
}
public void setRightDrawable(Drawable rightDrawable) {
mRightDrawable = rightDrawable;
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
setCompoundDrawablesWithIntrinsicBounds(mLeftDrawable, mTopDrawable, mRightDrawable, mBottomDrawable);
}
@Override
public void setCompoundDrawablesWithIntrinsicBounds(Drawable left, Drawable top, Drawable right, Drawable bottom) {
if (left != null) {
left.setBounds(0, 0, mLeftWidth, mLeftHeight);
}
if (top != null) {
top.setBounds(0, 0, mTopWidth, mTopHeight);
}
if (right != null) {
right.setBounds(0, 0, mRightWidth, mRightHeight);
}
if (bottom != null) {
bottom.setBounds(0, 0, mBottomWidth, mBottomHeight);
}
setCompoundDrawables(left, top, right, bottom);
}
}

View File

@@ -0,0 +1,107 @@
package com.yunbao.common.custom;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import androidx.appcompat.widget.AppCompatRadioButton;
import android.util.AttributeSet;
import com.yunbao.common.R;
/**
* Created by cxf on 2017/7/19.
* 可以调节drawable大小的RadioButton
*/
public class DrawableRadioButton2 extends AppCompatRadioButton {
private int mTopWidth;
private int mTopHeight;
private int mLeftWidth;
private int mLeftHeight;
private int mRightWidth;
private int mRightHeight;
private int mBottomWidth;
private int mBottomHeight;
private Drawable mTopDrawable;
private Drawable mLeftDrawable;
private Drawable mRightDrawable;
private Drawable mBottomDrawable;
public DrawableRadioButton2(Context context) {
this(context, null);
}
public DrawableRadioButton2(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public DrawableRadioButton2(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.DrawableTextView);
mTopWidth = (int) ta.getDimension(R.styleable.DrawableTextView_dt_top_width, 0);
mTopHeight = (int) ta.getDimension(R.styleable.DrawableTextView_dt_top_height, 0);
mLeftWidth = (int) ta.getDimension(R.styleable.DrawableTextView_dt_left_width, 0);
mLeftHeight = (int) ta.getDimension(R.styleable.DrawableTextView_dt_left_height, 0);
mRightWidth = (int) ta.getDimension(R.styleable.DrawableTextView_dt_right_width, 0);
mRightHeight = (int) ta.getDimension(R.styleable.DrawableTextView_dt_right_height, 0);
mBottomWidth = (int) ta.getDimension(R.styleable.DrawableTextView_dt_bottom_width, 0);
mBottomHeight = (int) ta.getDimension(R.styleable.DrawableTextView_dt_bottom_height, 0);
mTopDrawable = ta.getDrawable(R.styleable.DrawableTextView_dt_top_drawable);
mLeftDrawable = ta.getDrawable(R.styleable.DrawableTextView_dt_left_drawable);
mRightDrawable = ta.getDrawable(R.styleable.DrawableTextView_dt_right_drawable);
mBottomDrawable = ta.getDrawable(R.styleable.DrawableTextView_dt_bottom_drawable);
ta.recycle();
}
public void setTopDrawable(Drawable topDrawable) {
mTopDrawable = topDrawable;
}
public void setBottomDrawable(Drawable bottomDrawable) {
mBottomDrawable = bottomDrawable;
}
public void setLeftDrawable(Drawable leftDrawable) {
mLeftDrawable = leftDrawable;
}
public void setRightDrawable(Drawable rightDrawable) {
mRightDrawable = rightDrawable;
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
setCompoundDrawablesWithIntrinsicBounds(mLeftDrawable, mTopDrawable, mRightDrawable, mBottomDrawable);
}
@Override
public void setCompoundDrawablesWithIntrinsicBounds(Drawable left, Drawable top, Drawable right, Drawable bottom) {
if (left != null) {
left.setBounds(0, 0, mLeftWidth, mLeftHeight);
}
if (top != null) {
top.setBounds(0, 0, mTopWidth, mTopHeight);
}
if (right != null) {
right.setBounds(0, 0, mRightWidth, mRightHeight);
}
if (bottom != null) {
bottom.setBounds(0, 0, mBottomWidth, mBottomHeight);
}
setCompoundDrawables(left, top, right, bottom);
}
@Override
public void setChecked(boolean checked) {
// super.setChecked(checked);
}
public void doToggle() {
super.setChecked(!isChecked());
}
}

View File

@@ -0,0 +1,118 @@
package com.yunbao.common.custom;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import androidx.appcompat.widget.AppCompatTextView;
import android.util.AttributeSet;
import com.yunbao.common.R;
/**
* Created by cxf on 2017/8/15.
* 可以调节drawable大小的TextView
*/
public class DrawableTextView extends AppCompatTextView {
private int mTopWidth;
private int mTopHeight;
private int mLeftWidth;
private int mLeftHeight;
private int mRightWidth;
private int mRightHeight;
private int mBottomWidth;
private int mBottomHeight;
private Drawable mTopDrawable;
private Drawable mLeftDrawable;
private Drawable mRightDrawable;
private Drawable mBottomDrawable;
public DrawableTextView(Context context) {
this(context, null);
}
public DrawableTextView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public DrawableTextView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.DrawableTextView);
mTopWidth = (int) ta.getDimension(R.styleable.DrawableTextView_dt_top_width, 0);
mTopHeight = (int) ta.getDimension(R.styleable.DrawableTextView_dt_top_height, 0);
mLeftWidth = (int) ta.getDimension(R.styleable.DrawableTextView_dt_left_width, 0);
mLeftHeight = (int) ta.getDimension(R.styleable.DrawableTextView_dt_left_height, 0);
mRightWidth = (int) ta.getDimension(R.styleable.DrawableTextView_dt_right_width, 0);
mRightHeight = (int) ta.getDimension(R.styleable.DrawableTextView_dt_right_height, 0);
mBottomWidth = (int) ta.getDimension(R.styleable.DrawableTextView_dt_bottom_width, 0);
mBottomHeight = (int) ta.getDimension(R.styleable.DrawableTextView_dt_bottom_height, 0);
mTopDrawable = ta.getDrawable(R.styleable.DrawableTextView_dt_top_drawable);
mLeftDrawable = ta.getDrawable(R.styleable.DrawableTextView_dt_left_drawable);
mRightDrawable = ta.getDrawable(R.styleable.DrawableTextView_dt_right_drawable);
mBottomDrawable = ta.getDrawable(R.styleable.DrawableTextView_dt_bottom_drawable);
ta.recycle();
}
public void setTopDrawable(Drawable topDrawable) {
mTopDrawable = topDrawable;
invalidate();
}
public void setBottomDrawable(Drawable bottomDrawable) {
mBottomDrawable = bottomDrawable;
invalidate();
}
public void setLeftDrawable(Drawable leftDrawable) {
mLeftDrawable = leftDrawable;
invalidate();
}
public void setRightDrawable(Drawable rightDrawable) {
mRightDrawable = rightDrawable;
invalidate();
}
public Drawable getTopDrawable() {
return mTopDrawable;
}
public Drawable getLeftDrawable() {
return mLeftDrawable;
}
public Drawable getRightDrawable() {
return mRightDrawable;
}
public Drawable getBottomDrawable() {
return mBottomDrawable;
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
setCompoundDrawablesWithIntrinsicBounds(mLeftDrawable, mTopDrawable, mRightDrawable, mBottomDrawable);
}
@Override
public void setCompoundDrawablesWithIntrinsicBounds(Drawable left, Drawable top, Drawable right, Drawable bottom) {
if (left != null) {
left.setBounds(0, 0, mLeftWidth, mLeftHeight);
}
if (top != null) {
top.setBounds(0, 0, mTopWidth, mTopHeight);
}
if (right != null) {
right.setBounds(0, 0, mRightWidth, mRightHeight);
}
if (bottom != null) {
bottom.setBounds(0, 0, mBottomWidth, mBottomHeight);
}
setCompoundDrawables(left, top, right, bottom);
}
}

View File

@@ -0,0 +1,58 @@
package com.yunbao.common.custom;
import android.content.Context;
import com.google.android.material.appbar.AppBarLayout;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.core.view.ViewCompat;
import android.util.AttributeSet;
import android.view.View;
/**
* Created by cxf on 2018/10/1.
*
* 问题:
* AppBarLayout + RecycleView 滑动后item 在一段时间内无法点击的问题
* 1. 快速滑动 RecycleView 后,立即去点击 item 往往没有反应,第二次点击或者等待片刻后点击可以生效。
* 2. 缓慢滑动后,立即点击 item发现大多数情况下是有反应的。
*
* 现象:
* 重写 AppBarLayout.Behavior 打印 log发现在快速滑动到顶部和底部之后
* AppBarLayout 在一段时间内还处于 Fling 状态,那么我们想办法把这段无效的 Fling 干掉就好了。
*
* 结论:
* 最后翻找 google 的时候发现这是 google 在修复上个版本嵌套滑动的时候引进来的新 bug。。。
*/
public class FixAppBarLayoutBehavior extends AppBarLayout.Behavior {
public FixAppBarLayoutBehavior() {
super();
}
public FixAppBarLayoutBehavior(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public void onNestedScroll(CoordinatorLayout coordinatorLayout, AppBarLayout child, View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, int type) {
super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed, type);
stopNestedScrollIfNeeded(dyUnconsumed, child, target, type);
}
@Override
public void onNestedPreScroll(CoordinatorLayout coordinatorLayout, AppBarLayout child, View target, int dx, int dy, int[] consumed, int type) {
super.onNestedPreScroll(coordinatorLayout, child, target, dx, dy, consumed, type);
stopNestedScrollIfNeeded(dy, child, target, type);
}
private void stopNestedScrollIfNeeded(int dy, AppBarLayout child, View target, int type) {
if (type == ViewCompat.TYPE_NON_TOUCH) {
final int currOffset = getTopAndBottomOffset();
if ((dy < 0 && currOffset == 0) || (dy > 0 && currOffset == -child.getTotalScrollRange())) {
ViewCompat.stopNestedScroll(target, ViewCompat.TYPE_NON_TOUCH);
}
}
}
}

View File

@@ -0,0 +1,595 @@
package com.yunbao.common.custom;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import androidx.annotation.ColorInt;
import androidx.annotation.Dimension;
import androidx.annotation.DrawableRes;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;
import android.util.TypedValue;
import android.view.View;
/**
* RecyclerView分割线
*/
public class ItemDecoration extends RecyclerView.ItemDecoration {
private static final String TAG = "ItemDecoration";
private Drawable mDivider;
private int dividerHeight;
private int dividerWidth;
private int dividerColor;
private static final int[] ATTRS = new int[]{android.R.attr.listDivider};
private static final int HORIZONTAL_LIST = LinearLayoutManager.HORIZONTAL;
private static final int VERTICAL_LIST = LinearLayoutManager.VERTICAL;
/**
* 设置是否显示左右边界线
*/
private boolean drawBorderLeftAndRight = false;
/**
* 设置是否显示上下边界线
*/
private boolean drawBorderTopAndBottom = false;
/**
* 是否只留空白,不画分割线
*/
private boolean onlySetItemOffsetsButNoDraw=false;
/**
* 是否是线性布局
*/
private boolean isLinearLayoutManager=true;
/**
* 布局方向
*/
private int orientation=VERTICAL_LIST;
public ItemDecoration(Context context) {
final TypedArray a = context.obtainStyledAttributes(ATTRS);
mDivider = a.getDrawable(0);
a.recycle();
this.dividerHeight=mDivider.getIntrinsicHeight();
this.dividerWidth=mDivider.getIntrinsicWidth();
}
/**
* 自定义分割线
*
* @param context
* @param drawableId 分割线图片
*/
public ItemDecoration(Context context, @DrawableRes int drawableId) {
mDivider = ContextCompat.getDrawable(context, drawableId);
this.dividerHeight=mDivider.getIntrinsicHeight();
this.dividerWidth=mDivider.getIntrinsicWidth();
}
/**
* 自定义分割线
* 也可以使用{@link Canvas#drawRect(float, float, float, float, Paint)}或者{@link Canvas#drawText(String, float, float, Paint)}等等
* 结合{@link Paint}去绘制各式各样的分割线
* @param context
* @param color 整型颜色值非资源id
* @param dividerWidth 单位为dp
* @param dividerHeight 单位为dp
*/
public ItemDecoration(Context context, @ColorInt int color, @Dimension float dividerWidth, @Dimension float dividerHeight) {
mDivider = new ColorDrawable(color);
this.dividerWidth= (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,dividerWidth,context.getResources().getDisplayMetrics());
this.dividerHeight= (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,dividerHeight,context.getResources().getDisplayMetrics());
}
/**
* 垂直滚动item宽度充满高度自适应
* 水平滚动,item高度充满宽度自适应
* 在itemView绘制完成之前调用也就是说此方法draw出来的效果将会在itemView的下面
* onDrawOver方法draw出来的效果将叠加在itemView的上面
* @param c
* @param parent
* @param state
*/
@Override
public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) {
if(onlySetItemOffsetsButNoDraw){
return;
}
if(isLinearLayoutManager){
drawLinearItemDivider(c,parent);
}else{
drawHorizontalLine(c, parent);
drawVerticalLine(c, parent);
}
}
private void drawLinearItemDivider(Canvas c, RecyclerView parent){
int spanCount = getSpanCount(parent);
int allChildCount = parent.getAdapter().getItemCount();
int top=0,bottom=0,left=0,right=0;
for (int i = 0; i < parent.getChildCount(); i++) {
final View child = parent.getChildAt(i);
final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
if(orientation==VERTICAL_LIST){//画横线
left = child.getLeft() - params.leftMargin;
right = child.getRight() + params.rightMargin;
if(drawBorderTopAndBottom){
//加上第一条
if(isFirstRaw(parent,params.getViewLayoutPosition(),spanCount)){
top=child.getTop()-params.topMargin-dividerHeight;
bottom = top + dividerHeight;
mDivider.setBounds(left, top, right, bottom);
mDivider.draw(c);
}
}else{
if(isLastRaw(parent,params.getViewLayoutPosition(),spanCount,allChildCount)){
continue;
}
}
top = child.getBottom() + params.bottomMargin;
bottom = top + dividerHeight;
mDivider.setBounds(left, top, right, bottom);
mDivider.draw(c);
}else{//画竖线
top=child.getTop()-params.topMargin;
bottom=child.getBottom()+params.bottomMargin;
if(drawBorderLeftAndRight){
//加上第一条
if(isFirstColumn(parent,params.getViewLayoutPosition(),spanCount)){
left=child.getLeft()-params.leftMargin-dividerWidth;
right = left + dividerWidth;
mDivider.setBounds(left, top, right, bottom);
mDivider.draw(c);
}
}else{
if(isLastColum(parent,params.getViewLayoutPosition(),spanCount,allChildCount)){
continue;
}
}
left = child.getRight() + params.rightMargin;
right = left + dividerWidth;
mDivider.setBounds(left, top, right, bottom);
mDivider.draw(c);
}
}
if(orientation==VERTICAL_LIST){
if(drawBorderLeftAndRight){
top = parent.getPaddingTop();
bottom = parent.getHeight() - parent.getPaddingBottom();
left=parent.getPaddingLeft();
right=left+dividerWidth;
//画左边界
mDivider.setBounds(left,top,right,bottom);
mDivider.draw(c);
left=parent.getWidth()-parent.getPaddingRight()-dividerWidth;
right=left+dividerWidth;
// Log.e(TAG, "drawLinearItemDivider: "+parent.getWidth()+"#"+parent.getPaddingLeft()+"#"+mDivider.getIntrinsicWidth() );
//画右边界
mDivider.setBounds(left,top,right,bottom);
mDivider.draw(c);
}
}else if(orientation==HORIZONTAL_LIST){
if(drawBorderTopAndBottom){
left=parent.getPaddingLeft();
right=parent.getWidth()-parent.getPaddingRight();
top=parent.getPaddingTop();
bottom=top+dividerHeight;
//画上边界
mDivider.setBounds(left,top,right,bottom);
mDivider.draw(c);
top=parent.getHeight()-parent.getPaddingBottom()-dividerHeight;
bottom=top+dividerHeight;
//画下边界
mDivider.setBounds(left,top,right,bottom);
mDivider.draw(c);
}
}
}
/**
* 画水平分割线
* @param c
* @param parent
*/
private void drawHorizontalLine(Canvas c, RecyclerView parent) {
int spanCount = getSpanCount(parent);
for (int i = 0; i < parent.getChildCount(); i++) {
final View child = parent.getChildAt(i);
final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
int top=0,bottom=0,left=0,right=0;
left = child.getLeft() - params.leftMargin;
//因为getItemOffsets中为竖线留了空隙所以要加上分割线的宽度在此处处理下面不用处理
right = child.getRight() + params.rightMargin+ dividerWidth;
if(i==parent.getChildCount()-1 && !drawBorderLeftAndRight){
right-=dividerWidth;//防止最后一个越界
}
if(isFirstColumn(parent,params.getViewLayoutPosition(),spanCount) && drawBorderLeftAndRight){
left-=dividerWidth;//下面不用处理
}
if(drawBorderTopAndBottom){
//加上第一条
if(isFirstRaw(parent,params.getViewLayoutPosition(),spanCount)){
top=child.getTop()-params.topMargin-dividerHeight;
bottom = top + dividerHeight;
mDivider.setBounds(left, top, right, bottom);
mDivider.draw(c);
}
}else{
int allChildCount = parent.getAdapter().getItemCount();
if(isLastRaw(parent,params.getViewLayoutPosition(),spanCount,allChildCount)){
continue;
}
}
// Log.e(TAG, "drawVertical: "+params.getViewLayoutPosition()+"@@"+mDivider.getIntrinsicWidth()+"#"+parent.getLayoutManager().getLeftDecorationWidth(child) );
top = child.getBottom() + params.bottomMargin;
bottom = top + dividerHeight;
mDivider.setBounds(left, top, right, bottom);
mDivider.draw(c);
}
}
/**
* 画垂直分割线
* @param c
* @param parent
*/
private void drawVerticalLine(Canvas c, RecyclerView parent) {
int spanCount = getSpanCount(parent);
for (int i = 0; i < parent.getChildCount(); i++) {
final View child = parent.getChildAt(i);
final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child .getLayoutParams();
int left=0,right=0,top=0,bottom=0;
top=child.getTop()-params.topMargin;
//因为getItemOffsets中为横线留了空隙所以要加上分割线的高度(上下加一处即可)
bottom=child.getBottom()+params.bottomMargin/**+mDivider.getIntrinsicHeight()*/;
// if(isFirstRaw(parent,params.getViewLayoutPosition(),spanCount) && drawBorderTopAndBottom){
// top-=mDivider.getIntrinsicHeight();
// }
if(drawBorderLeftAndRight){
//加上第一条
if(isFirstColumn(parent,params.getViewLayoutPosition(),spanCount)){
left=child.getLeft()-params.leftMargin-dividerWidth;
right = left + dividerWidth;
mDivider.setBounds(left, top, right, bottom);
mDivider.draw(c);
}
}else{
int allChildCount = parent.getAdapter().getItemCount();
if(isLastColum(parent,params.getViewLayoutPosition(),spanCount,allChildCount)){
continue;
}
}
left = child.getRight() + params.rightMargin;
right = left + dividerWidth;
mDivider.setBounds(left, top, right, bottom);
mDivider.draw(c);
}
}
/**
* item的偏移如果不设置也能画线但是画在了item后面(被item挡住了可以通过设置item背景透明度证实)
* @param outRect
* @param view
* @param parent
* @param state
*/
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
RecyclerView.LayoutManager layoutManager = parent.getLayoutManager();
if(!(layoutManager instanceof LinearLayoutManager)){
throw new IllegalStateException("The LayoutManager must be LinearLayoutManager or it's subclass!!!");
}
isLinearLayoutManager=(layoutManager instanceof LinearLayoutManager) && !(layoutManager instanceof GridLayoutManager);
if(isLinearLayoutManager){
orientation=((LinearLayoutManager) layoutManager).getOrientation();
}else{
orientation=(layoutManager instanceof GridLayoutManager)?((GridLayoutManager) layoutManager).getOrientation():((StaggeredGridLayoutManager)layoutManager).getOrientation();
}
int spanCount = getSpanCount(parent);
int childCount = parent.getAdapter().getItemCount();
int itemPosition=((RecyclerView.LayoutParams) view.getLayoutParams()).getViewLayoutPosition();
// Log.e(TAG, "getItemOffsets: "+childCount+"$"+spanCount+"$"+itemPosition );
boolean isLastRaw=isLastRaw(parent, itemPosition, spanCount, childCount);
boolean isLastColum=isLastColum(parent, itemPosition, spanCount, childCount);
boolean isFirstRaw=isFirstRaw(parent,itemPosition,spanCount);
boolean isFirstColumn=isFirstColumn(parent,itemPosition,spanCount);
int left=0,top=0,right=0,bottom=0;
if(isLinearLayoutManager){
if(orientation==VERTICAL_LIST){
//垂直滚动线性布局
bottom=dividerHeight;
if(isLastRaw && !drawBorderTopAndBottom){
bottom=0;
}
if(isFirstRaw && drawBorderTopAndBottom){
top=dividerHeight;
}
if(drawBorderLeftAndRight){
left=dividerWidth;
right=dividerWidth;
}
}else if(orientation==HORIZONTAL_LIST){
right=dividerWidth;
if(isLastColum && !drawBorderLeftAndRight){
right=0;
}
if(isFirstColumn && drawBorderLeftAndRight){
left=dividerWidth;
}
if(drawBorderTopAndBottom){
top=dividerHeight;
bottom=dividerHeight;
}
}
}else{
GridLayoutManager.SpanSizeLookup spanSizeLookup = ((GridLayoutManager)layoutManager).getSpanSizeLookup();
int spanIndexLeft = spanSizeLookup.getSpanIndex(itemPosition, spanCount);//左边的跨度索引值[0,spanCount)之间
int spanIndexRight = spanIndexLeft - 1 + spanSizeLookup.getSpanSize(itemPosition);//右边的跨度索引值[0,spanCount)之间
// Log.e(TAG, "getItemOffsets: "+spanIndexLeft +"#"+spanIndexRight+"#"+itemPosition+"$$$"+spanSizeLookup.getSpanGroupIndex(itemPosition, spanCount));
if(orientation==VERTICAL_LIST){
if(drawBorderLeftAndRight){
//注如果此处不能整除会造成divider的宽或高不统一的bug下同因为Rect不支持float所以暂无法解决
left=dividerWidth * (spanCount - spanIndexLeft) / spanCount;
right=dividerWidth * (spanIndexRight + 1) / spanCount;
}else{
left = dividerWidth * spanIndexLeft / spanCount;
right = dividerWidth * (spanCount - spanIndexRight - 1) / spanCount;
}
if(drawBorderTopAndBottom){
if (spanSizeLookup.getSpanGroupIndex(itemPosition, spanCount) == 0) {
top = dividerHeight;
} else {
top = 0;
}
bottom = dividerHeight;
}else{
if (isLastRaw) {
bottom=0;
} else {
bottom = dividerHeight;
}
top=0;
}
}else if(orientation==HORIZONTAL_LIST){
if(drawBorderTopAndBottom){
top=dividerHeight * (spanCount - spanIndexLeft) / spanCount;
bottom=dividerHeight * (spanIndexRight + 1) / spanCount;
}else{
top = dividerHeight * spanIndexLeft / spanCount;
bottom = dividerHeight * (spanCount - spanIndexRight - 1) / spanCount;
}
if(drawBorderLeftAndRight){
if(isFirstColumn){
left=dividerWidth;
}else{
left=0;
}
right=dividerWidth;
}else{
if(isLastColum){
right=0;
}else{
right=dividerWidth;
}
left=0;
}
}
}
//Log.e(TAG, "getItemOffsets: "+left+"@"+top+"#"+right+"$"+bottom+"%"+itemPosition );
outRect.set(left,top,right,bottom);
}
private boolean isFirstRaw(RecyclerView parent, int pos, int spanCount){
if (!isLinearLayoutManager) {
GridLayoutManager.SpanSizeLookup spanSizeLookup = ((GridLayoutManager)parent.getLayoutManager()).getSpanSizeLookup();
int spanIndexLeft = spanSizeLookup.getSpanIndex(pos, spanCount);
if (orientation == GridLayoutManager.VERTICAL) {
// if(pos<spanCount){
// return true;
// }
//=========================另一种方案兼容每个item的spanSize不同的情况==============================
if(spanSizeLookup.getSpanGroupIndex(pos,spanCount)==0){
return true;
}
}else{
// if(pos%spanCount==0){
// return true;
// }
//=========================另一种方案兼容每个item的spanSize不同的情况==============================
if(spanIndexLeft==0){
return true;
}
}
}else{
if (orientation == LinearLayoutManager.VERTICAL) {
if(pos==0){
return true;
}
}else{
//每一个都是第一行,也是最后一行
return true;
}
}
return false;
}
private boolean isFirstColumn(RecyclerView parent, int pos, int spanCount){
if (!isLinearLayoutManager) {
GridLayoutManager.SpanSizeLookup spanSizeLookup = ((GridLayoutManager)parent.getLayoutManager()).getSpanSizeLookup();
int spanIndexLeft = spanSizeLookup.getSpanIndex(pos, spanCount);
if (orientation == GridLayoutManager.VERTICAL) {
// if(pos%spanCount==0){
// return true;
// }
//=========================另一种方案兼容每个item的spanSize不同的情况==============================
if(spanIndexLeft==0){
return true;
}
}else{
// if(pos<spanCount){
// return true;
// }
//=========================另一种方案兼容每个item的spanSize不同的情况==============================
if(spanSizeLookup.getSpanGroupIndex(pos,spanCount)==0){
return true;
}
}
}else{
if (orientation == LinearLayoutManager.VERTICAL) {
//每一个都是第一列,也是最后一列
return true;
}else{
if(pos==0){
return true;
}
}
}
return false;
}
private boolean isLastColum(RecyclerView parent, int pos, int spanCount, int childCount) {
if (!isLinearLayoutManager) {
GridLayoutManager.SpanSizeLookup spanSizeLookup = ((GridLayoutManager)parent.getLayoutManager()).getSpanSizeLookup();
int spanIndexLeft = spanSizeLookup.getSpanIndex(pos, spanCount);
if (orientation == GridLayoutManager.VERTICAL) {
//最后一列或者不能整除的情况下最后一个
// if ((pos + 1) % spanCount == 0 /**|| pos==childCount-1*/){// 如果是最后一列
// return true;
// }
//=========================另一种方案兼容每个item的spanSize不同的情况==============================
if(spanIndexLeft==spanCount-1 || spanCount==spanSizeLookup.getSpanSize(pos) || pos==childCount-1){
return true;
}
}else{
// if(pos>=childCount-spanCount && childCount%spanCount==0){
// //整除的情况判断最后一整列
// return true;
// }else if(childCount%spanCount!=0 && pos>=spanCount*(childCount/spanCount)){
// //不能整除的情况只判断最后几个
// return true;
// }
//=========================另一种方案==============================
// if(pos>=childCount-spanCount){
// return true;
// }
//=========================另一种方案兼容每个item的spanSize不同的情况==============================
int lastItemSpanGroupIndex=spanSizeLookup.getSpanGroupIndex(childCount-1,spanCount);
if(spanSizeLookup.getSpanGroupIndex(pos,spanCount)==lastItemSpanGroupIndex){
return true;//如果与最后一个元素同组则判定为最后一行
}
}
}else{
if (orientation == LinearLayoutManager.VERTICAL) {
//每一个都是第一列,也是最后一列
return true;
}else{
if(pos==childCount-1){
return true;
}
}
}
return false;
}
private boolean isLastRaw(RecyclerView parent, int pos, int spanCount, int childCount) {
if (!isLinearLayoutManager) {
GridLayoutManager.SpanSizeLookup spanSizeLookup = ((GridLayoutManager)parent.getLayoutManager()).getSpanSizeLookup();
int spanIndexLeft = spanSizeLookup.getSpanIndex(pos, spanCount);
if (orientation == GridLayoutManager.VERTICAL) {
// if(pos>=childCount-spanCount && childCount%spanCount==0){
// //整除的情况判断最后一整行
// return true;
// }else if(childCount%spanCount!=0 && pos>=spanCount*(childCount/spanCount)){
// //不能整除的情况只判断最后几个
// return true;
// }
//=======================另一种方案===============================
// if(pos>=childCount-spanCount){
// return true;
// }
//=========================另一种方案兼容每个item的spanSize不同的情况==============================
//判断最后一行是否充满整行
boolean flag=spanSizeLookup.getSpanIndex(childCount-1, spanCount)==spanCount-1 || spanCount==spanSizeLookup.getSpanSize(childCount-1);
int lastItemSpanGroupIndex=spanSizeLookup.getSpanGroupIndex(childCount-1,spanCount);
if(spanSizeLookup.getSpanGroupIndex(pos,spanCount)==lastItemSpanGroupIndex){
return true;//如果与最后一个元素同组则判定为最后一行
}
// if(flag){
// }else{
// //没有充满则前一行跟最后一行都判定为最后一行
// if(spanSizeLookup.getSpanGroupIndex(pos,spanCount)==lastItemSpanGroupIndex || spanSizeLookup.getSpanGroupIndex(pos,spanCount)==lastItemSpanGroupIndex-1){
// return true;
// }
// }
}else{
//最后一行或者不能整除的情况下最后一个
// if ((pos + 1) % spanCount == 0 /**|| pos==childCount-1*/){// 如果是最后一行
// return true;
// }
//=========================另一种方案兼容每个item的spanSize不同的情况==============================
if(spanIndexLeft==spanCount-1 || spanCount==spanSizeLookup.getSpanSize(pos) || pos==childCount-1){
return true;
}
}
}else{
if (orientation == LinearLayoutManager.VERTICAL) {
if(pos==childCount-1){
return true;
}
}else{
//每一个都是第一行,也是最后一行
return true;
}
}
return false;
}
private int getSpanCount(RecyclerView parent) {
// 列数
int spanCount = -1;
RecyclerView.LayoutManager layoutManager = parent.getLayoutManager();
if (layoutManager instanceof GridLayoutManager) {
spanCount = ((GridLayoutManager) layoutManager).getSpanCount();
} else if (layoutManager instanceof StaggeredGridLayoutManager) {
spanCount = ((StaggeredGridLayoutManager) layoutManager).getSpanCount();
}
return spanCount;
}
public boolean isDrawBorderTopAndBottom() {
return drawBorderTopAndBottom;
}
public void setDrawBorderTopAndBottom(boolean drawBorderTopAndBottom) {
this.drawBorderTopAndBottom = drawBorderTopAndBottom;
}
public boolean isDrawBorderLeftAndRight() {
return drawBorderLeftAndRight;
}
public void setDrawBorderLeftAndRight(boolean drawBorderLeftAndRight) {
this.drawBorderLeftAndRight = drawBorderLeftAndRight;
}
public boolean isOnlySetItemOffsetsButNoDraw() {
return onlySetItemOffsetsButNoDraw;
}
public void setOnlySetItemOffsetsButNoDraw(boolean onlySetItemOffsetsButNoDraw) {
this.onlySetItemOffsetsButNoDraw = onlySetItemOffsetsButNoDraw;
}
}

View File

@@ -0,0 +1,366 @@
package com.yunbao.common.custom;
import android.animation.Animator;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.graphics.Rect;
import androidx.core.view.GestureDetectorCompat;
import androidx.core.view.MotionEventCompat;
import androidx.recyclerview.widget.RecyclerView;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
/**
* 消息列表左滑菜单帮助类
*/
public class ItemSlideHelper implements RecyclerView.OnItemTouchListener, GestureDetector.OnGestureListener {
private final int DEFAULT_DURATION = 150;
private View mTargetView;
private int mActivePointerId;
private int mTouchSlop;
private int mMaxVelocity;
private int mMinVelocity;
private int mLastX;
private int mLastY;
private boolean mIsDragging;
private Animator mExpandAndCollapseAnim;
private GestureDetectorCompat mGestureDetector;
private Callback mCallback;
public ItemSlideHelper(Context context, Callback callback) {
this.mCallback = callback;
//手势用于处理fling
mGestureDetector = new GestureDetectorCompat(context, this);
ViewConfiguration configuration = ViewConfiguration.get(context);
mTouchSlop = configuration.getScaledTouchSlop();
mMaxVelocity = configuration.getScaledMaximumFlingVelocity();
mMinVelocity = configuration.getScaledMinimumFlingVelocity();
}
@Override
public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {
int action = MotionEventCompat.getActionMasked(e);
int x = (int) e.getX();
int y = (int) e.getY();
//如果RecyclerView滚动状态不是空闲targetView不是空
if (rv.getScrollState() != RecyclerView.SCROLL_STATE_IDLE) {
if (mTargetView != null) {
//隐藏已经打开
smoothHorizontalExpandOrCollapse(DEFAULT_DURATION / 2);
mTargetView = null;
}
return false;
}
//如果正在运行动画 ,直接拦截什么都不做
if (mExpandAndCollapseAnim != null && mExpandAndCollapseAnim.isRunning()) {
return true;
}
boolean needIntercept = false;
switch (action) {
case MotionEvent.ACTION_DOWN:
mActivePointerId = MotionEventCompat.getPointerId(e, 0);
mLastX = (int) e.getX();
mLastY = (int) e.getY();
/*
* 如果之前有一个已经打开的项目当此次点击事件没有发生在右侧的菜单中则返回TRUE
* 如果点击的是右侧菜单那么返回FALSE这样做的原因是因为菜单需要响应Onclick
* */
if (mTargetView != null) {
return !inView(x, y);
}
//查找需要显示菜单的view;
mTargetView = mCallback.findTargetView(x, y);
break;
case MotionEvent.ACTION_MOVE:
int deltaX = (x - mLastX);
int deltaY = (y - mLastY);
if (Math.abs(deltaY) > Math.abs(deltaX))
return false;
//如果移动距离达到要求,则拦截
needIntercept = mIsDragging = mTargetView != null && Math.abs(deltaX) >= mTouchSlop;
break;
case MotionEvent.ACTION_CANCEL:
case MotionEvent.ACTION_UP:
/*
* 走这是因为没有发生过拦截事件
* */
if (isExpanded()) {
if (inView(x, y)) {
// 如果走这那行这个ACTION_UP的事件会发生在右侧的菜单中
} else {
//拦截事件,防止targetView执行onClick事件
needIntercept = true;
}
//折叠菜单
smoothHorizontalExpandOrCollapse(DEFAULT_DURATION / 2);
}
mTargetView = null;
break;
}
return needIntercept;
}
private boolean isExpanded() {
int range = getHorizontalRange();
if (range == 0) {
return false;
}
return mTargetView != null && mTargetView.getScrollX() == range;
}
private boolean isCollapsed() {
return mTargetView != null && mTargetView.getScrollX() == 0;
}
/*
* 根据targetView的scrollX计算出targetView的偏移这样能够知道这个point
* 是在右侧的菜单中
* */
private boolean inView(int x, int y) {
if (mTargetView == null)
return false;
int scrollX = mTargetView.getScrollX();
int left = mTargetView.getWidth() - scrollX;
int top = mTargetView.getTop();
int right = left + getHorizontalRange();
int bottom = mTargetView.getBottom();
Rect rect = new Rect(left, top, right, bottom);
return rect.contains(x, y);
}
@Override
public void onTouchEvent(RecyclerView rv, MotionEvent e) {
if (mExpandAndCollapseAnim != null && mExpandAndCollapseAnim.isRunning() || mTargetView == null)
return;
//如果要响应fling事件设置将mIsDragging设为false
if (mGestureDetector.onTouchEvent(e)) {
mIsDragging = false;
return;
}
int x = (int) e.getX();
int y = (int) e.getY();
int action = MotionEventCompat.getActionMasked(e);
switch (action) {
case MotionEvent.ACTION_DOWN:
//RecyclerView 不会转发这个Down事件
break;
case MotionEvent.ACTION_MOVE:
int deltaX = (int) (mLastX - e.getX());
if (mIsDragging) {
horizontalDrag(deltaX);
}
mLastX = x;
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
if (mIsDragging) {
if (!smoothHorizontalExpandOrCollapse(0) && isCollapsed())
mTargetView = null;
mIsDragging = false;
}
break;
}
}
@Override
public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
}
/**
* 根据touch事件来滚动View的scrollX
*
* @param delta
*/
private void horizontalDrag(int delta) {
if (mCallback != null && !mCallback.useLeftScroll()) {
if(delta > 0){
RecyclerView.ViewHolder viewHolder = mCallback.getChildViewHolder(mTargetView);
mCallback.onLeftScroll(viewHolder);
}
return;
}
int scrollX = mTargetView.getScrollX();
int scrollY = mTargetView.getScrollY();
if ((scrollX + delta) <= 0) {
mTargetView.scrollTo(0, scrollY);
return;
}
int horRange = getHorizontalRange();
scrollX += delta;
if (Math.abs(scrollX) < horRange) {
mTargetView.scrollTo(scrollX, scrollY);
} else {
mTargetView.scrollTo(horRange, scrollY);
}
}
/**
* 根据当前scrollX的位置判断是展开还是折叠
*
* @param velocityX 如果不等于0那么这是一次fling事件,否则是一次ACTION_UP或者ACTION_CANCEL
*/
private boolean smoothHorizontalExpandOrCollapse(float velocityX) {
int scrollX = mTargetView.getScrollX();
int scrollRange = getHorizontalRange();
if (mExpandAndCollapseAnim != null)
return false;
int to = 0;
int duration = DEFAULT_DURATION;
if (velocityX == 0) {
//如果已经展一半,平滑展开
if (scrollX > scrollRange / 2) {
to = scrollRange;
}
} else {
if (velocityX > 0)
to = 0;
else
to = scrollRange;
duration = (int) ((1.f - Math.abs(velocityX) / mMaxVelocity) * DEFAULT_DURATION);
}
if (to == scrollX) {
return false;
}
mExpandAndCollapseAnim = ObjectAnimator.ofInt(mTargetView, "scrollX", to);
mExpandAndCollapseAnim.setDuration(duration);
mExpandAndCollapseAnim.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
mExpandAndCollapseAnim = null;
if (isCollapsed())
mTargetView = null;
}
@Override
public void onAnimationCancel(Animator animation) {
//onAnimationEnd(animation);
mExpandAndCollapseAnim = null;
}
@Override
public void onAnimationRepeat(Animator animation) {
}
});
mExpandAndCollapseAnim.start();
return true;
}
public int getHorizontalRange() {
RecyclerView.ViewHolder viewHolder = mCallback.getChildViewHolder(mTargetView);
if (viewHolder == null) {
return 0;
}
return mCallback.getHorizontalRange(viewHolder);
}
@Override
public boolean onDown(MotionEvent e) {
return false;
}
@Override
public void onShowPress(MotionEvent e) {
}
@Override
public boolean onSingleTapUp(MotionEvent e) {
return false;
}
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
return false;
}
@Override
public void onLongPress(MotionEvent e) {
}
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
if (Math.abs(velocityX) > mMinVelocity && Math.abs(velocityX) < mMaxVelocity) {
if (!smoothHorizontalExpandOrCollapse(velocityX)) {
if (isCollapsed())
mTargetView = null;
return true;
}
}
return false;
}
/**
* 左滑菜单Callback
*/
public interface Callback {
int getHorizontalRange(RecyclerView.ViewHolder holder);
RecyclerView.ViewHolder getChildViewHolder(View childView);
View findTargetView(float x, float y);
//是否使用左滑删除
boolean useLeftScroll();
void onLeftScroll(RecyclerView.ViewHolder holder);
}
}

View File

@@ -0,0 +1,36 @@
package com.yunbao.common.custom;
import android.content.Context;
import androidx.annotation.AttrRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import android.util.AttributeSet;
import android.widget.FrameLayout;
/**
* Created by cxf on 2018/9/27.
*/
public class MyFrameLayout1 extends FrameLayout {
private int mScreenWidth;
public MyFrameLayout1(@NonNull Context context) {
this(context, null);
}
public MyFrameLayout1(@NonNull Context context, @Nullable AttributeSet attrs) {
this(context, attrs, 0);
}
public MyFrameLayout1(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
super(context, attrs, defStyleAttr);
mScreenWidth = context.getResources().getDisplayMetrics().widthPixels;
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
widthMeasureSpec = MeasureSpec.makeMeasureSpec(mScreenWidth, MeasureSpec.EXACTLY);
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
}

View File

@@ -0,0 +1,45 @@
package com.yunbao.common.custom;
import android.content.Context;
import android.content.res.TypedArray;
import androidx.annotation.AttrRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import android.util.AttributeSet;
import android.widget.FrameLayout;
import com.yunbao.common.R;
/**
* Created by cxf on 2018/9/27.
*/
public class MyFrameLayout2 extends FrameLayout {
private float mRatio;
private float mOffestY;
public MyFrameLayout2(@NonNull Context context) {
this(context, null);
}
public MyFrameLayout2(@NonNull Context context, @Nullable AttributeSet attrs) {
this(context, attrs, 0);
}
public MyFrameLayout2(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
super(context, attrs, defStyleAttr);
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.MyFrameLayout2);
mRatio = ta.getFloat(R.styleable.MyFrameLayout2_mfl_ratio, 1);
mOffestY = ta.getDimension(R.styleable.MyFrameLayout2_mfl_offestY, 0);
ta.recycle();
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int widthSize = MeasureSpec.getSize(widthMeasureSpec);
heightMeasureSpec = MeasureSpec.makeMeasureSpec((int) (widthSize * mRatio + mOffestY), MeasureSpec.EXACTLY);
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
}

View File

@@ -0,0 +1,50 @@
package com.yunbao.common.custom;
import android.content.Context;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.AppCompatImageView;
import android.util.AttributeSet;
import android.view.animation.Animation;
import android.view.animation.RotateAnimation;
/**
* Created by cxf on 2018/11/21.
*/
public class MyImageView2 extends AppCompatImageView {
private boolean mAnimating;
private RotateAnimation mRotateAnimation;
public MyImageView2(Context context) {
this(context, null);
}
public MyImageView2(Context context, @Nullable AttributeSet attrs) {
this(context, attrs, 0);
}
public MyImageView2(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
mRotateAnimation = new RotateAnimation(-30f, 30f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.2f);
mRotateAnimation.setDuration(300);
mRotateAnimation.setRepeatCount(-1);
mRotateAnimation.setRepeatMode(Animation.REVERSE);
}
public void startAnim() {
if (!mAnimating) {
mAnimating = true;
startAnimation(mRotateAnimation);
}
}
public void stopAnim() {
if(mAnimating){
mAnimating = false;
clearAnimation();
}
}
}

View File

@@ -0,0 +1,34 @@
package com.yunbao.common.custom;
import android.content.Context;
import androidx.annotation.Nullable;
import android.util.AttributeSet;
import android.widget.LinearLayout;
/**
* Created by cxf on 2018/9/27.
*/
public class MyLinearLayout1 extends LinearLayout {
private int mScreenWidth;
public MyLinearLayout1(Context context) {
this(context, null);
}
public MyLinearLayout1(Context context, @Nullable AttributeSet attrs) {
this(context, attrs, 0);
}
public MyLinearLayout1(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
mScreenWidth = context.getResources().getDisplayMetrics().widthPixels;
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
widthMeasureSpec = MeasureSpec.makeMeasureSpec(mScreenWidth * 2, MeasureSpec.EXACTLY);
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
}

View File

@@ -0,0 +1,42 @@
package com.yunbao.common.custom;
import android.content.Context;
import android.content.res.TypedArray;
import androidx.annotation.Nullable;
import android.util.AttributeSet;
import android.widget.LinearLayout;
import com.yunbao.common.R;
/**
* Created by cxf on 2018/9/25.
*/
public class MyLinearLayout2 extends LinearLayout {
private float mScreenWidth;
private int mSpanCount;
public MyLinearLayout2(Context context) {
this(context, null);
}
public MyLinearLayout2(Context context, @Nullable AttributeSet attrs) {
this(context, attrs, 0);
}
public MyLinearLayout2(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
mScreenWidth = context.getResources().getDisplayMetrics().widthPixels;
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.MyLinearLayout2);
mSpanCount = ta.getInteger(R.styleable.MyLinearLayout2_mll_span_count, 6);
ta.recycle();
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
widthMeasureSpec = MeasureSpec.makeMeasureSpec((int) (mScreenWidth / mSpanCount), MeasureSpec.EXACTLY);
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
}

View File

@@ -0,0 +1,49 @@
package com.yunbao.common.custom;
import android.content.Context;
import android.content.res.TypedArray;
import androidx.annotation.Nullable;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.widget.LinearLayout;
import com.yunbao.common.R;
/**
* Created by cxf on 2018/12/3.
*/
public class MyLinearLayout3 extends LinearLayout {
private int mScreenHeight;
private float mHeightPercent;
private int mHeight;
public MyLinearLayout3(Context context) {
this(context, null);
}
public MyLinearLayout3(Context context, @Nullable AttributeSet attrs) {
this(context, attrs, 0);
}
public MyLinearLayout3(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
DisplayMetrics dm = context.getResources().getDisplayMetrics();
mScreenHeight = dm.heightPixels;
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.MyLinearLayout3);
mHeightPercent = ta.getFloat(R.styleable.MyLinearLayout3_mll_height_percent, 0);
mHeight = (int) (mHeightPercent * mScreenHeight);
ta.recycle();
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
heightMeasureSpec = MeasureSpec.makeMeasureSpec(mHeight, MeasureSpec.EXACTLY);
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
public int getHeight2() {
return mHeight;
}
}

View File

@@ -0,0 +1,45 @@
package com.yunbao.common.custom;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.widget.LinearLayout;
import com.yunbao.common.R;
/**
* Created by cxf on 2018/7/26.
*/
public class MyLinearLayout4 extends LinearLayout {
private int mScreenWidth;
private float mCount;
public MyLinearLayout4(Context context) {
this(context, null);
}
public MyLinearLayout4(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public MyLinearLayout4(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.MyLinearLayout4);
mCount = ta.getFloat(R.styleable.MyLinearLayout4_mll4_count, 1);
ta.recycle();
init(context);
}
private void init(Context context) {
mScreenWidth = context.getResources().getDisplayMetrics().widthPixels;
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
widthMeasureSpec = MeasureSpec.makeMeasureSpec((int) (mScreenWidth / mCount), MeasureSpec.EXACTLY);
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
}

View File

@@ -0,0 +1,34 @@
package com.yunbao.common.custom;
import android.content.Context;
import androidx.annotation.Nullable;
import android.util.AttributeSet;
import android.widget.LinearLayout;
/**
* Created by cxf on 2018/7/26.
*/
public class MyLinearLayout5 extends LinearLayout {
public MyLinearLayout5(Context context) {
super(context);
}
public MyLinearLayout5(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}
public MyLinearLayout5(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int widthSize = MeasureSpec.getSize(widthMeasureSpec);
super.onMeasure(MeasureSpec.makeMeasureSpec(widthSize, MeasureSpec.UNSPECIFIED), heightMeasureSpec);
}
}

View File

@@ -0,0 +1,34 @@
package com.yunbao.common.custom;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.RadioButton;
/**
* Created by cxf on 2018/9/28.
*/
public class MyRadioButton extends RadioButton {
public MyRadioButton(Context context) {
super(context);
}
public MyRadioButton(Context context, AttributeSet attrs) {
super(context, attrs);
}
public MyRadioButton(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
public void setChecked(boolean checked) {
//super.setChecked(checked);
}
public void doChecked(boolean checked){
super.setChecked(checked);
}
}

View File

@@ -0,0 +1,48 @@
package com.yunbao.common.custom;
import android.content.Context;
import android.content.res.TypedArray;
import androidx.annotation.AttrRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import android.util.AttributeSet;
import android.widget.RelativeLayout;
import com.yunbao.common.R;
/**
* Created by cxf on 2018/9/27.
*/
public class MyRelativeLayout2 extends RelativeLayout {
private int mScreenWidth;
private float mRatio;
private float mScaleWidth;
public MyRelativeLayout2(@NonNull Context context) {
this(context, null);
}
public MyRelativeLayout2(@NonNull Context context, @Nullable AttributeSet attrs) {
this(context, attrs, 0);
}
public MyRelativeLayout2(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
super(context, attrs, defStyleAttr);
mScreenWidth = context.getResources().getDisplayMetrics().widthPixels;
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.MyRelativeLayout2);
mRatio = ta.getFloat(R.styleable.MyRelativeLayout2_mrl_ratio, 1);
mScaleWidth = ta.getFloat(R.styleable.MyRelativeLayout2_mrl_scaleX, 1);
ta.recycle();
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int widthSize = (int) (mScreenWidth * mScaleWidth);
widthMeasureSpec = MeasureSpec.makeMeasureSpec(widthSize, MeasureSpec.EXACTLY);
heightMeasureSpec = MeasureSpec.makeMeasureSpec((int) (widthSize * mRatio), MeasureSpec.EXACTLY);
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
}

View File

@@ -0,0 +1,31 @@
package com.yunbao.common.custom;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.RelativeLayout;
/**
* Created by cxf on 2018/9/26.
*/
public class MyRelativeLayout5 extends RelativeLayout {
public MyRelativeLayout5(Context context) {
super(context);
}
public MyRelativeLayout5(Context context, AttributeSet attrs) {
super(context, attrs);
}
public MyRelativeLayout5(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int widthSize = MeasureSpec.getSize(widthMeasureSpec);
heightMeasureSpec = MeasureSpec.makeMeasureSpec(widthSize, MeasureSpec.EXACTLY);
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
}

View File

@@ -0,0 +1,31 @@
package com.yunbao.common.custom;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.RelativeLayout;
/**
* Created by cxf on 2018/9/26.
*/
public class MyRelativeLayout6 extends RelativeLayout {
public MyRelativeLayout6(Context context) {
super(context);
}
public MyRelativeLayout6(Context context, AttributeSet attrs) {
super(context, attrs);
}
public MyRelativeLayout6(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
float widthSize = MeasureSpec.getSize(widthMeasureSpec);
heightMeasureSpec = MeasureSpec.makeMeasureSpec((int) (widthSize * 13 / 9), MeasureSpec.EXACTLY);
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
}

View File

@@ -0,0 +1,62 @@
package com.yunbao.common.custom;
import android.content.Context;
import android.content.res.TypedArray;
import androidx.viewpager.widget.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;
import com.yunbao.common.R;
/**
* Created by cxf on 2018/6/9.
* 可以禁止滑动的ViewPager
*/
public class MyViewPager extends ViewPager {
private boolean mCanScroll;
public MyViewPager(Context context) {
this(context, null);
}
public MyViewPager(Context context, AttributeSet attrs) {
super(context, attrs);
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.MyViewPager);
mCanScroll = ta.getBoolean(R.styleable.MyViewPager_canScroll, true);
ta.recycle();
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
if (mCanScroll) {
try {
return super.onInterceptTouchEvent(ev);
} catch (Exception e) {
return false;
}
} else {
return false;
}
}
@Override
public boolean onTouchEvent(MotionEvent ev) {
if (mCanScroll) {
try {
return super.onTouchEvent(ev);
} catch (Exception e) {
return false;
}
} else {
return false;
}
}
public void setCanScroll(boolean canScroll) {
mCanScroll = canScroll;
}
}

View File

@@ -0,0 +1,41 @@
package com.yunbao.common.custom;
import android.content.Context;
import android.content.res.TypedArray;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.AppCompatImageView;
import androidx.appcompat.widget.AppCompatTextView;
import android.util.AttributeSet;
import com.yunbao.common.R;
/**
* Created by cxf on 2018/9/27.
*/
public class RatioImageView extends AppCompatImageView {
private float mRatio;
public RatioImageView(Context context) {
this(context, null);
}
public RatioImageView(Context context, @Nullable AttributeSet attrs) {
this(context, attrs, 0);
}
public RatioImageView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.RatioImageView);
mRatio = ta.getFloat(R.styleable.RatioImageView_ri_ratio, 1);
ta.recycle();
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int widthSize = MeasureSpec.getSize(widthMeasureSpec);
heightMeasureSpec = MeasureSpec.makeMeasureSpec((int) (widthSize * mRatio), MeasureSpec.EXACTLY);
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
}

View File

@@ -0,0 +1,40 @@
package com.yunbao.common.custom;
import android.content.Context;
import android.content.res.TypedArray;
import androidx.annotation.Nullable;
import android.util.AttributeSet;
import com.makeramen.roundedimageview.RoundedImageView;
import com.yunbao.common.R;
/**
* Created by cxf on 2018/9/27.
*/
public class RatioRoundImageView extends RoundedImageView {
private float mRatio;
public RatioRoundImageView(Context context) {
this(context, null);
}
public RatioRoundImageView(Context context, @Nullable AttributeSet attrs) {
this(context, attrs, 0);
}
public RatioRoundImageView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.RatioImageView);
mRatio = ta.getFloat(R.styleable.RatioImageView_ri_ratio, 1);
ta.recycle();
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int widthSize = MeasureSpec.getSize(widthMeasureSpec);
heightMeasureSpec = MeasureSpec.makeMeasureSpec((int) (widthSize * mRatio), MeasureSpec.EXACTLY);
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
}

View File

@@ -0,0 +1,31 @@
package com.yunbao.common.custom;
import android.content.Context;
import androidx.appcompat.widget.AppCompatImageView;
import android.util.AttributeSet;
/**
* Created by cxf on 2018/6/7.
*/
public class SquareImageView extends AppCompatImageView {
public SquareImageView(Context context) {
super(context);
}
public SquareImageView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public SquareImageView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int widthSize = MeasureSpec.getSize(widthMeasureSpec);
heightMeasureSpec = MeasureSpec.makeMeasureSpec(widthSize, MeasureSpec.EXACTLY);
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
}

View File

@@ -0,0 +1,32 @@
package com.yunbao.common.custom;
import android.content.Context;
import android.util.AttributeSet;
import com.makeramen.roundedimageview.RoundedImageView;
/**
* Created by cxf on 2018/6/7.
*/
public class SquareRoundedImageView extends RoundedImageView {
public SquareRoundedImageView(Context context) {
super(context);
}
public SquareRoundedImageView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public SquareRoundedImageView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int widthSize = MeasureSpec.getSize(widthMeasureSpec);
heightMeasureSpec = MeasureSpec.makeMeasureSpec(widthSize, MeasureSpec.EXACTLY);
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
}

View File

@@ -0,0 +1,159 @@
package com.yunbao.common.custom;
import android.animation.ValueAnimator;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import androidx.core.content.ContextCompat;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.ViewGroup;
import android.view.animation.LinearInterpolator;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.yunbao.common.R;
/**
* Created by cxf on 2018/9/21.
* 向宽平
*/
public class TabButton extends LinearLayout {
private Context mContext;
private float mScale;
private String mTip;
private int mIconSize;
private int mTextSize;
private int mTextColorChecked;
private int mTextColorUnChecked;
private boolean mChecked;
private ImageView mImg;
private TextView mText;
private Drawable[] mDrawables;
private int mDrawaleArrayLength;
private ValueAnimator mAnimator;//帧动画
private int mDrawableIndex;
public TabButton(Context context) {
this(context, null);
}
public TabButton(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public TabButton(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
mContext = context;
mScale = context.getResources().getDisplayMetrics().density;
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.TabButton);
int iconArrayId = ta.getResourceId(R.styleable.TabButton_tbn_icon_array_id, 0);
mTip = ta.getString(R.styleable.TabButton_tbn_tip);
mIconSize = (int) ta.getDimension(R.styleable.TabButton_tbn_icon_size, 0);
mTextSize = (int) ta.getDimension(R.styleable.TabButton_tbn_text_size, 0);
mTextColorChecked = ta.getColor(R.styleable.TabButton_tbn_text_color_checked, 0);
mTextColorUnChecked = ta.getColor(R.styleable.TabButton_tbn_text_color_unchecked, 0);
mChecked = ta.getBoolean(R.styleable.TabButton_tbn_checked, false);
ta.recycle();
if (iconArrayId != 0) {
TypedArray arr = getResources().obtainTypedArray(iconArrayId);
int len = arr.length();
int[] iconResArray = new int[len];
for (int i = 0; i < len; i++) {
iconResArray[i] = arr.getResourceId(i, 0);
}
arr.recycle();
mDrawaleArrayLength = iconResArray.length;
if (mDrawaleArrayLength > 0) {
mDrawables = new Drawable[mDrawaleArrayLength];
for (int i = 0; i < mDrawaleArrayLength; i++) {
mDrawables[i] = ContextCompat.getDrawable(context, iconResArray[i]);
}
}
}
mAnimator = ValueAnimator.ofFloat(1, mDrawaleArrayLength - 1);
mAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float v = (float) animation.getAnimatedValue();
int index = (int) v;
if (mDrawableIndex != index) {
mDrawableIndex = index;
if (mImg != null) {
mImg.setImageDrawable(mDrawables[index]);
}
}
}
});
mAnimator.setDuration(800);
mAnimator.setInterpolator(new LinearInterpolator());
}
@Override
protected void onFinishInflate() {
super.onFinishInflate();
setOrientation(VERTICAL);
setGravity(Gravity.CENTER_HORIZONTAL);
mImg = new ImageView(mContext);
LayoutParams params1 = new LayoutParams(mIconSize, mIconSize);
params1.setMargins(0, dp2px(4), 0, 0);
mImg.setLayoutParams(params1);
if (mDrawables != null && mDrawaleArrayLength > 0) {
if (mChecked) {
mImg.setImageDrawable(mDrawables[1]);
} else {
mImg.setImageDrawable(mDrawables[0]);
}
}
mText = new TextView(mContext);
LayoutParams params2 = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
mText.setLayoutParams(params2);
mText.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize);
mText.setText(mTip);
mText.setTextColor(mChecked ? mTextColorChecked : mTextColorUnChecked);
addView(mImg);
addView(mText);
}
public void setChecked(boolean checked) {
mChecked = checked;
if (mDrawables != null && mDrawaleArrayLength > 0) {
if (mChecked) {
if (mText != null) {
mText.setTextColor(mTextColorChecked);
}
if (mAnimator != null) {
mAnimator.start();
}
mImg.setImageDrawable(mDrawables[1]);
} else {
if (mAnimator != null) {
mAnimator.cancel();
}
if (mImg != null) {
mImg.setImageDrawable(mDrawables[0]);
}
if (mText != null) {
mText.setTextColor(mTextColorUnChecked);
}
}
}
}
private int dp2px(int dpVal) {
return (int) (mScale * dpVal + 0.5f);
}
public void cancelAnim() {
if (mAnimator != null) {
mAnimator.cancel();
mAnimator.removeAllUpdateListeners();
}
}
}

View File

@@ -0,0 +1,102 @@
package com.yunbao.common.custom;
import android.content.Context;
import androidx.annotation.Nullable;
import androidx.viewpager.widget.ViewPager;
import android.util.AttributeSet;
import android.view.View;
import android.widget.LinearLayout;
import com.yunbao.common.bean.UpdataListBean;
import org.greenrobot.eventbus.EventBus;
/**
* Created by cxf on 2018/9/22.
*/
public class TabButtonGroup extends LinearLayout implements View.OnClickListener {
private TabButton[] mTabButtons;
private ViewPager mViewPager;
private int mCurPosition;
public TabButtonGroup(Context context) {
this(context, null);
}
public TabButtonGroup(Context context, @Nullable AttributeSet attrs) {
this(context, attrs, 0);
}
public TabButtonGroup(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
protected void onFinishInflate() {
super.onFinishInflate();
int childCount = getChildCount();
if (childCount > 0) {
mTabButtons = new TabButton[childCount];
for (int i = 0; i < childCount; i++) {
View v = getChildAt(i);
v.setTag(i);
v.setOnClickListener(this);
mTabButtons[i] = (TabButton) v;
}
}
}
private long mLastClickBackTime;
public void setCurPosition(int position) {
//点击事件切换
if (position == mCurPosition) {
// return;
long curTime = System.currentTimeMillis();
if (curTime - mLastClickBackTime <= 500) {
if (position != 2 && position != 3) {
EventBus.getDefault().post(new UpdataListBean(position, ""));
}
} else {
mLastClickBackTime = curTime;
}
} else {
mLastClickBackTime = 0;
}
mTabButtons[mCurPosition].setChecked(false);
mTabButtons[position].setChecked(true);
mCurPosition = position;
if (mViewPager != null) {
mViewPager.setCurrentItem(position, false);
}
}
@Override
public void onClick(View v) {
Object tag = v.getTag();
if (tag != null) {
setCurPosition((int) tag);
}
}
public void setViewPager(ViewPager viewPager) {
mViewPager = viewPager;
}
public void cancelAnim() {
if (mTabButtons != null) {
for (TabButton tbn : mTabButtons) {
if (tbn != null) {
tbn.cancelAnim();
}
}
}
}
}

View File

@@ -0,0 +1,48 @@
package com.yunbao.common.custom;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.text.style.ImageSpan;
/**
* Created by cxf on 2017/12/1.
*/
public class VerticalImageSpan extends ImageSpan {
private Drawable drawable;
public VerticalImageSpan(Drawable drawable) {
super(drawable);
this.drawable=drawable;
}
@Override
public int getSize(Paint paint, CharSequence text, int start, int end, Paint.FontMetricsInt fontMetricsInt) {
Drawable drawable = getDrawable();
if(drawable==null){
drawable= this.drawable;
}
Rect rect = drawable.getBounds();
if (fontMetricsInt != null) {
Paint.FontMetricsInt fmPaint = paint.getFontMetricsInt();
int fontHeight = fmPaint.bottom - fmPaint.top;
int drHeight = rect.bottom - rect.top;
int top = drHeight / 2 - fontHeight / 4;
int bottom = drHeight / 2 + fontHeight / 4;
fontMetricsInt.ascent = -bottom;
fontMetricsInt.top = -bottom;
fontMetricsInt.bottom = top;
fontMetricsInt.descent = top;
}
return rect.right;
}
@Override
public void draw(Canvas canvas, CharSequence text, int start, int end, float x, int top, int y, int bottom, Paint paint) {
Drawable drawable = getDrawable();
canvas.save();
int transY = ((bottom - top) - drawable.getBounds().bottom) / 2 + top;
canvas.translate(x, transY);
drawable.draw(canvas);
canvas.restore();
}
}

View File

@@ -0,0 +1,63 @@
package com.yunbao.common.dialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.fragment.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import com.yunbao.common.utils.ClickUtil;
import java.lang.ref.WeakReference;
/**
* Created by cxf on 2018/9/29.
*/
public abstract class AbsDialogFragment extends DialogFragment {
protected Context mContext;
protected View mRootView;
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
mContext = new WeakReference<>(getActivity()).get();
mRootView = LayoutInflater.from(mContext).inflate(getLayoutId(), null);
final Dialog dialog = new Dialog(mContext, getDialogStyle());
dialog.setContentView(mRootView);
dialog.setCancelable(canCancel());
dialog.setCanceledOnTouchOutside(canCancel());
setWindowAttributes(dialog.getWindow());
return dialog;
}
@Override
public void onDismiss(DialogInterface dialog) {
super.onDismiss(dialog);
}
protected abstract int getLayoutId();
protected abstract int getDialogStyle();
protected abstract boolean canCancel();
protected abstract void setWindowAttributes(Window window);
protected View findViewById(int id) {
if (mRootView != null) {
return mRootView.findViewById(id);
}
return null;
}
protected boolean canClick() {
return ClickUtil.canClick();
}
}

View File

@@ -0,0 +1,63 @@
package com.yunbao.common.dialog;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.widget.PopupWindow;
import com.yunbao.common.R;
/**
* Created by cxf on 2018/11/7.
* 聊天表情弹窗
*/
public class ChatFaceDialog extends PopupWindow {
private View mParent;
private View mContentView;
private ActionListener mActionListener;
public ChatFaceDialog(View parent, View contentView, boolean needAnim, ActionListener actionListener) {
mParent = parent;
mActionListener = actionListener;
ViewParent viewParent = contentView.getParent();
if (viewParent != null) {
((ViewGroup) viewParent).removeView(contentView);
}
mContentView = contentView;
setContentView(contentView);
setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
setOutsideTouchable(false);
if (needAnim) {
setAnimationStyle(R.style.bottomToTopAnim2);
}
setOnDismissListener(new OnDismissListener() {
@Override
public void onDismiss() {
ViewParent viewParent = mContentView.getParent();
if (viewParent != null) {
((ViewGroup) viewParent).removeView(mContentView);
}
mContentView = null;
if (mActionListener != null) {
mActionListener.onFaceDialogDismiss();
}
mActionListener = null;
}
});
}
public void show() {
showAtLocation(mParent, Gravity.BOTTOM, 0, 0);
}
public interface ActionListener {
void onFaceDialogDismiss();
}
}

View File

@@ -0,0 +1,169 @@
package com.yunbao.common.dialog;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.content.Context;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.widget.FrameLayout;
import com.yunbao.common.R;
import com.yunbao.common.adapter.ImageFolderAdapter;
import com.yunbao.common.adapter.OnItemClickListener;
import com.yunbao.common.bean.ImageFolderEntity;
import java.util.List;
/**
* Created by Chen Haoxuan on 2022/4/30.
*Description:
*/
public class ImageFolderView extends FrameLayout implements OnItemClickListener {
private View mShadowView;
// private String mShadowViewColor = "#CCCCCC";
private RecyclerView mImageFolderRv;
private List<ImageFolderEntity> mImageFolders;
private ImageFolderViewListener mListener;
private int mImageFolderHeight;
private boolean mShow;
public ImageFolderView(Context context) {
this(context, null);
}
public ImageFolderView(Context context, @Nullable AttributeSet attrs) {
this(context, attrs, 0);
}
public ImageFolderView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
mShadowView = new View(context);
mShadowView.setBackgroundColor(getResources().getColor(R.color.gray_cccccc));
mImageFolderRv = (RecyclerView) inflate(context, R.layout.image_folder_layout, null);
//设置LayoutParams
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
FrameLayout.LayoutParams.MATCH_PARENT);
layoutParams.gravity = Gravity.BOTTOM;
mImageFolderRv.setLayoutParams(layoutParams);
//设置布局管理器setLayoutManager
mImageFolderRv.setLayoutManager(new LinearLayoutManager(context));
addView(mShadowView);
addView(mImageFolderRv);
//开始不显示阴影
mShadowView.setAlpha(0f);
mShadowView.setVisibility(GONE);
}
public void setImageFolders(List<ImageFolderEntity> imageFolders) {
mImageFolders = imageFolders;
}
public void setAdapter(ImageFolderAdapter adapter) {
if (adapter == null) {
throw new NullPointerException("adapter not null");
}
mImageFolderRv.setAdapter(adapter);
adapter.setItemClickListener(this);
}
public void setListener(ImageFolderViewListener listener) {
this.mListener = listener;
}
/**
* 显示
*/
public void show() {
if (mShow) {
return;
}
if (mListener != null) {
mListener.onShow();
}
mShow = true;
mShadowView.setVisibility(VISIBLE);
ObjectAnimator translationYAnimator = ObjectAnimator.ofFloat(mImageFolderRv, "translationY", mImageFolderHeight, 0);
translationYAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(mShadowView, "alpha", 0f, 1f);
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether(translationYAnimator, alphaAnimator);
animatorSet.setDuration(388);
animatorSet.start();
}
/**
* 隐藏
*/
public void hide() {
if (!mShow) {
return;
}
if (mListener != null) {
mListener.onDismiss();
}
ObjectAnimator translationYAnimator = ObjectAnimator.ofFloat(mImageFolderRv,
"translationY", 0, mImageFolderHeight);
translationYAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(mShadowView, "alpha", 1f, 0f);
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether(translationYAnimator, alphaAnimator);
animatorSet.setDuration(388);
animatorSet.start();
animatorSet.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
mShow = false;
mShadowView.setVisibility(GONE);
}
});
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
//获取高度
int height = MeasureSpec.getSize(heightMeasureSpec);
mImageFolderHeight = (int) (height * 0.9f);
ViewGroup.LayoutParams params = mImageFolderRv.getLayoutParams();
params.height = mImageFolderHeight;
mImageFolderRv.setLayoutParams(params);
measureChild(mImageFolderRv, widthMeasureSpec, heightMeasureSpec);
//开始的时候,移下去
mImageFolderRv.setTranslationY(mImageFolderHeight);
}
public boolean isShowing() {
return mShow;
}
@Override
public void onItemClick(int position) {
if (mListener != null) {
mListener.onSelectFolder(this, mImageFolders.get(position));
hide();
}
}
public interface ImageFolderViewListener {
void onSelectFolder(ImageFolderView imageFolderView, ImageFolderEntity imageFolder);
void onDismiss();
void onShow();
}
}

View File

@@ -0,0 +1,222 @@
package com.yunbao.common.dialog;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.activity.AbsActivity;
import com.yunbao.common.bean.CoinBean;
import com.yunbao.common.bean.CoinPayBean;
import com.yunbao.common.custom.ItemDecoration;
import com.yunbao.common.http.CommonHttpConsts;
import com.yunbao.common.http.CommonHttpUtil;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.interfaces.OnItemClickListener;
import com.yunbao.common.pay.PayPresenter;
import com.yunbao.common.utils.DpUtil;
import com.yunbao.common.utils.StringUtil;
import com.yunbao.common.utils.WordUtil;
import com.yunbao.common.R;
import com.yunbao.common.adapter.ChatChargeCoinAdapter;
import java.util.ArrayList;
import java.util.List;
/**
* Created by cxf on 2019/4/22.
*/
public class LiveChargeDialogFragment extends AbsDialogFragment implements View.OnClickListener, OnItemClickListener<CoinBean>, LiveChargePayDialogFragment.ActionListener {
private RecyclerView mRecyclerView;
private TextView mBtnCharge;
private List<CoinPayBean> mPayList;
private ChatChargeCoinAdapter mAdapter;
private CoinBean mCheckedCoinBean;
private PayPresenter mPayPresenter;
@Override
protected int getLayoutId() {
return R.layout.dialog_chat_charge;
}
@Override
protected int getDialogStyle() {
return R.style.dialog2;
}
@Override
protected boolean canCancel() {
return true;
}
@Override
protected void setWindowAttributes(Window window) {
window.setWindowAnimations(R.style.bottomToTopAnim);
WindowManager.LayoutParams params = window.getAttributes();
params.width = WindowManager.LayoutParams.MATCH_PARENT;
params.height = DpUtil.dp2px(500);
params.gravity = Gravity.BOTTOM;
window.setAttributes(params);
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mRecyclerView = (RecyclerView) findViewById(R.id.recyclerView);
mRecyclerView.setHasFixedSize(true);
mRecyclerView.setLayoutManager(new GridLayoutManager(mContext, 3, GridLayoutManager.VERTICAL, false));
ItemDecoration decoration = new ItemDecoration(mContext, 0x00000000, 5, 20);
decoration.setOnlySetItemOffsetsButNoDraw(true);
mRecyclerView.addItemDecoration(decoration);
mBtnCharge = (TextView) findViewById(R.id.btn_charge);
mBtnCharge.setOnClickListener(this);
findViewById(R.id.btn_close).setOnClickListener(this);
loadData();
}
private void loadData() {
CommonHttpUtil.getBalance(new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
if (code == 0 && info.length > 0) {
if (mRecyclerView == null) {
return;
}
JSONObject obj = JSON.parseObject(info[0]);
List<CoinPayBean> paylist = JSON.parseArray(obj.getString("paylist"), CoinPayBean.class);
mPayList = paylist;
List<CoinBean> list = JSON.parseArray(obj.getString("rules"), CoinBean.class);
if (list != null && list.size() > 0) {
CoinBean bean = list.get(0);
bean.setChecked(true);
mAdapter = new ChatChargeCoinAdapter(mContext, list);
mAdapter.setOnItemClickListener(LiveChargeDialogFragment.this);
mRecyclerView.setAdapter(mAdapter);
showMoney(bean);
}
if (mPayPresenter != null) {
String coin = obj.getString("coin");
mPayPresenter.setBalanceValue(Long.parseLong(coin));
mPayPresenter.setAliPartner(obj.getString("aliapp_partner"));
mPayPresenter.setAliSellerId(obj.getString("aliapp_seller_id"));
mPayPresenter.setAliPrivateKey(obj.getString("aliapp_key_android"));
mPayPresenter.setWxAppID(obj.getString("wx_appid"));
}
}
}
});
}
@Override
public void onClick(View v) {
int i = v.getId();
if (i == R.id.btn_close) {
dismiss();
} else if (i == R.id.btn_charge) {
charge();
}
}
@Override
public void onItemClick(CoinBean bean, int position) {
showMoney(bean);
}
private void showMoney(CoinBean bean) {
mCheckedCoinBean = bean;
if (mCheckedCoinBean != null && mBtnCharge != null) {
// mBtnCharge.setText(String.format(WordUtil.getString(R.string.chat_charge_tip), mCheckedCoinBean.getMoney()));
mBtnCharge.setText(String.format(WordUtil.getString(R.string.chat_charge_tip)));
}
}
private void charge() {
if (mCheckedCoinBean == null || mPayList == null || mPayList.size() == 0) {
return;
}
// L.e("《==》支付按钮2--->" );
LiveChargePayDialogFragment fragment = new LiveChargePayDialogFragment();
fragment.setCoinString(StringUtil.contact(mCheckedCoinBean.getCoin(), CommonAppConfig.getInstance().getCoinName()));
fragment.setMoneyString(mCheckedCoinBean.getMoney());
String moneyS=mCheckedCoinBean.getMoney();
float money=0;
if (moneyS!=null && !moneyS.isEmpty()){
try {
money=Float.parseFloat(moneyS);
}catch (Exception e){e.printStackTrace();}
}
List<CoinPayBean> payListTmp = new ArrayList<>();
for (int i=0;i<mPayList.size();i++){
payListTmp.add(mPayList.get(i));
}
//价格超过2800时不显示谷歌支付
if (money > 2800){
for (int i=0;i<mPayList.size();i++){
if ("google".equals(mPayList.get(i).getId())){
payListTmp.remove(i);
fragment.setPayList(payListTmp);
}
}
}
else {
fragment.setPayList(mPayList);
}
// fragment.setPayList(mPayList);
fragment.setActionListener(this);
fragment.show(((AbsActivity) mContext).getSupportFragmentManager(), "ChatChargePayDialogFragment");
}
@Override
public void onChargeClick(CoinPayBean coinPayBean) {
if (mPayPresenter != null && mCheckedCoinBean != null) {
String href = coinPayBean.getHref();
if (TextUtils.isEmpty(href)) {
String money = mCheckedCoinBean.getMoney();
// if(coinPayBean.getId().equals(Constants.PAY_TYPE_HW)
// || coinPayBean.getId().equals(Constants.PAY_TYPE_PAYSSION)
// || coinPayBean.getId().equals(Constants.PAY_TYPE_PAYPAL)
// || coinPayBean.getId().equals(Constants.PAY_TYPE_GOOGLE))
{
money = mCheckedCoinBean.getMoney_usd();
}
String goodsName = StringUtil.contact(mCheckedCoinBean.getCoin(), CommonAppConfig.getInstance().getCoinName());
String orderParams = StringUtil.contact(
"&uid=", CommonAppConfig.getInstance().getUid(),
"&money=", money,
"&changeid=", mCheckedCoinBean.getId(),
"&coin=", mCheckedCoinBean.getCoin());
mPayPresenter.pay(coinPayBean.getId(), money, goodsName, orderParams);
} else {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setData(Uri.parse(href));
mContext.startActivity(intent);
}
}
dismiss();
}
@Override
public void onDestroy() {
CommonHttpUtil.cancel(CommonHttpConsts.GET_BALANCE);
mPayPresenter = null;
super.onDestroy();
}
public void setPayPresenter(PayPresenter payPresenter) {
mPayPresenter = payPresenter;
}
}

View File

@@ -0,0 +1,123 @@
package com.yunbao.common.dialog;
import android.os.Bundle;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;
import com.yunbao.common.bean.CoinPayBean;
import com.yunbao.common.utils.DpUtil;
import com.yunbao.common.R;
import com.yunbao.common.adapter.ChatChargePayAdapter;
import java.util.List;
/**
* Created by cxf on 2019/4/22.
*/
public class LiveChargePayDialogFragment extends AbsDialogFragment implements View.OnClickListener {
private RecyclerView mRecyclerView;
private List<CoinPayBean> mPayList;
private ChatChargePayAdapter mAdapter;
private String mCoinString;
private String mMoneyString;
private ActionListener mActionListener;
@Override
protected int getLayoutId() {
return R.layout.dialog_chat_charge_pay;
}
@Override
protected int getDialogStyle() {
return R.style.dialog3;
}
@Override
protected boolean canCancel() {
return true;
}
@Override
protected void setWindowAttributes(Window window) {
window.setWindowAnimations(R.style.bottomToTopAnim);
WindowManager.LayoutParams params = window.getAttributes();
params.width = DpUtil.dp2px(310);
params.height = DpUtil.dp2px(430);
params.gravity = Gravity.CENTER;
window.setAttributes(params);
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
findViewById(R.id.btn_charge).setOnClickListener(this);
findViewById(R.id.btn_close).setOnClickListener(this);
TextView coin = (TextView) findViewById(R.id.coin);
TextView money = (TextView) findViewById(R.id.money);
coin.setText(mCoinString);
money.setText(mMoneyString);
mRecyclerView = (RecyclerView) findViewById(R.id.recyclerView);
mRecyclerView.setHasFixedSize(true);
mRecyclerView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false));
if (mPayList != null) {
mAdapter = new ChatChargePayAdapter(mContext, mPayList);
mRecyclerView.setAdapter(mAdapter);
}
}
@Override
public void onClick(View v) {
int i = v.getId();
if (i == R.id.btn_close) {
dismiss();
} else if (i == R.id.btn_charge) {
charge();
}
}
private void charge() {
if (mAdapter != null && mActionListener != null) {
// L.e("《==》支付按钮1--->" );
mActionListener.onChargeClick(mAdapter.getCheckedPayBean());
dismiss();
}
}
public void setPayList(List<CoinPayBean> payList) {
for (int i = 0, size = payList.size(); i < size; i++) {
payList.get(i).setChecked(i == 0);
}
mPayList = payList;
}
public void setCoinString(String coinString) {
mCoinString = coinString;
}
public void setMoneyString(String moneyString) {
mMoneyString = moneyString;
}
@Override
public void onDestroy() {
mActionListener = null;
super.onDestroy();
}
public interface ActionListener {
void onChargeClick(CoinPayBean coinPayBean);
}
public void setActionListener(ActionListener actionListener) {
mActionListener = actionListener;
}
}

View File

@@ -0,0 +1,97 @@
package com.yunbao.common.dialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import androidx.fragment.app.DialogFragment;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;
import com.yunbao.common.R;
import com.yunbao.common.utils.DpUtil;
/**
* Created by cxf on 2019/5/29.
*/
public class NotCancelableDialog extends AbsDialogFragment implements View.OnClickListener {
private ActionListener mActionListener;
private String mContent;
@Override
protected int getLayoutId() {
return R.layout.dialog_simple_tip;
}
@Override
protected int getDialogStyle() {
return R.style.dialog2;
}
@Override
protected boolean canCancel() {
return false;
}
@Override
protected void setWindowAttributes(Window window) {
WindowManager.LayoutParams params = window.getAttributes();
params.width = DpUtil.dp2px(280);
params.height = WindowManager.LayoutParams.WRAP_CONTENT;
params.gravity = Gravity.CENTER;
window.setAttributes(params);
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
Dialog dialog = getDialog();
if (dialog != null) {
dialog.setOnKeyListener(new DialogInterface.OnKeyListener() {
@Override
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
return true;
}
return false;
}
});
}
TextView textView = mRootView.findViewById(R.id.content);
textView.setText(mContent);
mRootView.findViewById(R.id.btn_confirm).setOnClickListener(this);
}
@Override
public void onClick(View v) {
if (mActionListener != null) {
mActionListener.onConfirmClick(mContext, this);
}
}
public void setActionListener(ActionListener actionListener) {
mActionListener = actionListener;
}
public void setContent(String content) {
mContent = content;
}
public interface ActionListener {
void onConfirmClick(Context context, DialogFragment dialog);
}
@Override
public void onDestroy() {
mActionListener = null;
super.onDestroy();
}
}

View File

@@ -0,0 +1,29 @@
package com.yunbao.common.dialog;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.FrameLayout;
/**
* Created by Chen Haoxuan on 2022/4/30
* Description:正方形的FrameLayout容器
*/
public class SquareFrameLayout extends FrameLayout {
public SquareFrameLayout(Context context) {
this(context,null);
}
public SquareFrameLayout(Context context, AttributeSet attrs) {
this(context, attrs,0);
}
public SquareFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, widthMeasureSpec);
}
}

View File

@@ -0,0 +1,52 @@
package com.yunbao.common.event;
/**
* Created by cxf on 2018/11/1.
* 钻石数量变化的事件
*/
public class CoinChangeEvent {
private String coin;
private String goldCoinNum;
private boolean chargeSuccess;
public CoinChangeEvent(String coin) {
this.coin = coin;
}
public CoinChangeEvent(String coin, boolean chargeSuccess) {
this.coin = coin;
this.chargeSuccess = chargeSuccess;
}
public CoinChangeEvent(String coin,String goldCoinNum, boolean chargeSuccess) {
this.coin = coin;
this.goldCoinNum = goldCoinNum;
this.chargeSuccess = chargeSuccess;
}
public String getCoin() {
return coin;
}
public void setCoin(String coin) {
this.coin = coin;
}
public String getGoldCoinNum() {
return goldCoinNum;
}
public void setGoldCoinNum(String goldCoinNum) {
this.goldCoinNum = goldCoinNum;
}
public boolean isChargeSuccess() {
return chargeSuccess;
}
public void setChargeSuccess(boolean chargeSuccess) {
this.chargeSuccess = chargeSuccess;
}
}

View File

@@ -0,0 +1,32 @@
package com.yunbao.common.event;
/**
* Created by cxf on 2018/9/28.
*/
public class FollowEvent {
private String mToUid;
private int mIsAttention;
public FollowEvent(String toUid, int isAttention) {
mToUid = toUid;
mIsAttention = isAttention;
}
public String getToUid() {
return mToUid;
}
public void setToUid(String toUid) {
mToUid = toUid;
}
public int getIsAttention() {
return mIsAttention;
}
public void setIsAttention(int isAttention) {
mIsAttention = isAttention;
}
}

View File

@@ -0,0 +1,23 @@
package com.yunbao.common.event;
/**
* Created by cxf on 2018/7/18.
*/
public class LocationEvent {
private double lng;
private double lat;
public LocationEvent(double lng, double lat) {
this.lng = lng;
this.lat = lat;
}
public double getLng() {
return lng;
}
public double getLat() {
return lat;
}
}

View File

@@ -0,0 +1,9 @@
package com.yunbao.common.event;
/**
* Created by cxf on 2018/10/31.
* 登录失效事件
*/
public class LoginInvalidEvent {
}

View File

@@ -0,0 +1,8 @@
package com.yunbao.common.event;
/**
* Created by cxf on 2019/6/22.
*/
public class UpdateFieldEvent {
}

View File

@@ -0,0 +1,21 @@
package com.yunbao.common.event;
/**
* Created by cxf on 2019/6/22.
*/
public class UpdateTablePoint {
int point;
public UpdateTablePoint(int point) {
this.point = point;
}
public int getPoint() {
return point;
}
public void setPoint(int point) {
this.point = point;
}
}

View File

@@ -0,0 +1,21 @@
package com.yunbao.common.event;
/**
* Created by Chen Haoxuan on 2022/6/17.
*/
public class UpdateTablePointMe {
int point;
public UpdateTablePointMe(int point) {
this.point = point;
}
public int getPoint() {
return point;
}
public void setPoint(int point) {
this.point = point;
}
}

View File

@@ -0,0 +1,244 @@
package com.yunbao.common.event;
import android.content.Context;
import android.os.Environment;
import android.telephony.TelephonyManager;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.Reader;
import java.io.Writer;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.security.MessageDigest;
import java.util.UUID;
/**
* @author liangjun on 2018/1/21.
*/
public class getDeviceId {
//保存文件的路径
private static final String CACHE_IMAGE_DIR = "aray/cache/devices";
//保存的文件 采用隐藏文件的形式进行保存
private static final String DEVICES_FILE_NAME = ".DEVICES";
/**
* 获取设备唯一标识符
*
* @param context
* @return
*/
public static String getDeviceId(Context context) {
//读取保存的在sd卡中的唯一标识符
String deviceId = readDeviceID(context);
//用于生成最终的唯一标识符
StringBuffer s = new StringBuffer();
//判断是否已经生成过,
if (deviceId != null && !"".equals(deviceId)) {
return deviceId;
}
try {
//获取IMES(也就是常说的DeviceId)
deviceId = getIMIEStatus(context);
s.append(deviceId);
} catch (Exception e) {
e.printStackTrace();
}
try {
//获取设备的MACAddress地址 去掉中间相隔的冒号
deviceId = getLocalMac(context).replace(":", "");
s.append(deviceId);
} catch (Exception e) {
e.printStackTrace();
}
// }
//如果以上搜没有获取相应的则自己生成相应的UUID作为相应设备唯一标识符
if (s == null || s.length() <= 0) {
UUID uuid = UUID.randomUUID();
deviceId = uuid.toString().replace("-", "");
s.append(deviceId);
}
//为了统一格式对设备的唯一标识进行md5加密 最终生成32位字符串
String md5 = getMD5(s.toString(), false);
if (s.length() > 0) {
//持久化操作, 进行保存到SD卡中
saveDeviceID(md5, context);
}
return md5;
}
/**
* 读取固定的文件中的内容,这里就是读取sd卡中保存的设备唯一标识符
*
* @param context
* @return
*/
public static String readDeviceID(Context context) {
File file = getDevicesDir(context);
StringBuffer buffer = new StringBuffer();
try {
FileInputStream fis = new FileInputStream(file);
InputStreamReader isr = new InputStreamReader(fis, "UTF-8");
Reader in = new BufferedReader(isr);
int i;
while ((i = in.read()) > -1) {
buffer.append((char) i);
}
in.close();
return buffer.toString();
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
/**
* 获取设备的DeviceId(IMES) 这里需要相应的权限<br/>
* 需要 READ_PHONE_STATE 权限
*
* @param context
* @return
*/
private static String getIMIEStatus(Context context) {
TelephonyManager tm = (TelephonyManager) context
.getSystemService(Context.TELEPHONY_SERVICE);
return tm.getDeviceId();
}
/**
* 获取设备MAC 地址 由于 6.0 以后 WifiManager 得到的 MacAddress得到都是 相同的没有意义的内容
* 所以采用以下方法获取Mac地址
* @param context
* @return
*/
private static String getLocalMac(Context context) {
// WifiManager wifi = (WifiManager) context
// .getSystemService(Context.WIFI_SERVICE);
// WifiInfo info = wifi.getConnectionInfo();
// return info.getMacAddress();
String macAddress = null;
StringBuffer buf = new StringBuffer();
NetworkInterface networkInterface = null;
try {
networkInterface = NetworkInterface.getByName("eth1");
if (networkInterface == null) {
networkInterface = NetworkInterface.getByName("wlan0");
}
if (networkInterface == null) {
return "";
}
byte[] addr = networkInterface.getHardwareAddress();
for (byte b : addr) {
buf.append(String.format("%02X:", b));
}
if (buf.length() > 0) {
buf.deleteCharAt(buf.length() - 1);
}
macAddress = buf.toString();
} catch (SocketException e) {
e.printStackTrace();
return "";
}
return macAddress;
}
/**
* 保存 内容到 SD卡中, 这里保存的就是 设备唯一标识符
* @param str
* @param context
*/
public static void saveDeviceID(String str, Context context) {
File file = getDevicesDir(context);
try {
FileOutputStream fos = new FileOutputStream(file);
Writer out = new OutputStreamWriter(fos, "UTF-8");
out.write(str);
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* 对挺特定的 内容进行 md5 加密
* @param message 加密明文
* @param upperCase 加密以后的字符串是是大写还是小写 true 大写 false 小写
* @return
*/
public static String getMD5(String message, boolean upperCase) {
String md5str = "";
try {
MessageDigest md = MessageDigest.getInstance("MD5");
byte[] input = message.getBytes();
byte[] buff = md.digest(input);
md5str = bytesToHex(buff, upperCase);
} catch (Exception e) {
e.printStackTrace();
}
return md5str;
}
public static String bytesToHex(byte[] bytes, boolean upperCase) {
StringBuffer md5str = new StringBuffer();
int digital;
for (int i = 0; i < bytes.length; i++) {
digital = bytes[i];
if (digital < 0) {
digital += 256;
}
if (digital < 16) {
md5str.append("0");
}
md5str.append(Integer.toHexString(digital));
}
if (upperCase) {
return md5str.toString().toUpperCase();
}
return md5str.toString().toLowerCase();
}
/**
* 统一处理设备唯一标识 保存的文件的地址
* @param context
* @return
*/
private static File getDevicesDir(Context context) {
File mCropFile = null;
if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
File cropdir = new File(Environment.getExternalStorageDirectory(), CACHE_IMAGE_DIR);
if (!cropdir.exists()) {
cropdir.mkdirs();
}
mCropFile = new File(cropdir, DEVICES_FILE_NAME); // 用当前时间给取得的图片命名
} else {
File cropdir = new File(context.getFilesDir(), CACHE_IMAGE_DIR);
if (!cropdir.exists()) {
cropdir.mkdirs();
}
mCropFile = new File(cropdir, DEVICES_FILE_NAME);
}
return mCropFile;
}
}

View File

@@ -0,0 +1,138 @@
package com.yunbao.common.fragment;
import android.Manifest;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.core.content.ContextCompat;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.R;
import com.yunbao.common.interfaces.ActivityResultCallback;
import com.yunbao.common.utils.ToastUtil;
import cn.rongcloud.rtc.api.RCRTCEngine;
/**
* Created by cxf on 2018/9/29.
* 处理 检查权限和 startActivityForResult 的回调的Fragment
*/
public class ProcessFragment extends Fragment {
private Context mContext;
private Runnable mPermissionCallback;
private ActivityResultCallback mActivityResultCallback;
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mContext = getActivity();
}
/**
* 检查是否具有多个权限
*
* @param permissions
* @return true 有权限 false无权限
*/
private boolean checkPermissions(String[] permissions) {
for (String permission : permissions) {
if (ContextCompat.checkSelfPermission(mContext, permission) != PackageManager.PERMISSION_GRANTED) {
return false;
}
}
return true;
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
if (isAllGranted(permissions, grantResults)) {
if (mPermissionCallback != null) {
mPermissionCallback.run();
}
}
mPermissionCallback = null;
}
/**
* 判断申请的权限有没有被允许
*/
private boolean isAllGranted(String[] permissions, int[] grantResults) {
for (int i = 0; i < grantResults.length; i++) {
if (grantResults[i] != PackageManager.PERMISSION_GRANTED) {
showTip(permissions[i]);
return false;
}
}
return true;
}
/**
* 拒绝某项权限时候的提示
*/
private void showTip(String permission) {
switch (permission) {
case Manifest.permission.READ_EXTERNAL_STORAGE:
case Manifest.permission.WRITE_EXTERNAL_STORAGE:
ToastUtil.show(R.string.permission_storage_refused);
break;
case Manifest.permission.CAMERA:
ToastUtil.show(R.string.permission_camera_refused);
break;
case Manifest.permission.RECORD_AUDIO:
ToastUtil.show(R.string.permission_record_audio_refused);
break;
case Manifest.permission.ACCESS_COARSE_LOCATION:
ToastUtil.show(R.string.permission_location_refused);
CommonAppConfig.getInstance().clearLocationInfo();
break;
case Manifest.permission.READ_PHONE_STATE:
ToastUtil.show(R.string.permission_read_phone_state_refused);
break;
}
}
public void requestPermissions(String[] permissions, Runnable runnable) {
if (runnable != null) {
if (checkPermissions(permissions)) {
runnable.run();
} else {
mPermissionCallback = runnable;
requestPermissions(permissions, 0);
}
}
}
public void startActivityForResult(Intent intent, ActivityResultCallback callback) {
mActivityResultCallback = callback;
super.startActivityForResult(intent, 0);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
try {
RCRTCEngine.getInstance().getDefaultVideoStream().startCamera(null);
}catch (Exception e){
}
if (mActivityResultCallback != null) {
if (resultCode == -1) {//RESULT_OK
mActivityResultCallback.onSuccess(data);
} else {
mActivityResultCallback.onFailure();
}
}
}
public void release(){
mPermissionCallback=null;
mActivityResultCallback=null;
}
}

View File

@@ -0,0 +1,157 @@
package com.yunbao.common.glide;
import android.app.Activity;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import android.widget.ImageView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.bumptech.glide.request.target.SimpleTarget;
import com.bumptech.glide.request.transition.Transition;
import com.yunbao.common.R;
import java.io.File;
import jp.wasabeef.glide.transformations.BlurTransformation;
/**
* Created by cxf on 2017/8/9.
*/
public class ImgLoader {
private static final boolean SKIP_MEMORY_CACHE = false;
private static BlurTransformation sBlurTransformation;
static {
sBlurTransformation= new BlurTransformation(25);
}
public static void display(Context context, String url, ImageView imageView) {
if (!contextIsExist(context)){
return;
}
Glide.with(context).asDrawable().load(url).skipMemoryCache(SKIP_MEMORY_CACHE).into(imageView);
}
public static void display2(Context context, String url, ImageView imageView) {
if (!contextIsExist(context)){
return;
}
Glide.with(context).asDrawable().load(url).placeholder(imageView.getDrawable()).dontAnimate().skipMemoryCache(SKIP_MEMORY_CACHE).into(imageView);
}
public static void displayWithError(Context context, String url, ImageView imageView, int errorRes) {
if (!contextIsExist(context)){
return;
}
if (imageView == null){
return;
}
Glide.with(context).asDrawable().load(url).error(errorRes).skipMemoryCache(SKIP_MEMORY_CACHE).into(imageView);
}
public static void displayAvatar(Context context, String url, ImageView imageView) {
if (!contextIsExist(context)){
return;
}
displayWithError(context, url, imageView, R.mipmap.icon_avatar_placeholder);
}
public static void display(Context context, File file, ImageView imageView) {
if (!contextIsExist(context)){
return;
}
Glide.with(context).asDrawable().load(file).skipMemoryCache(SKIP_MEMORY_CACHE).into(imageView);
}
public static void display(Context context, int res, ImageView imageView) {
if (!contextIsExist(context)){
return;
}
Glide.with(context).asDrawable().load(res).skipMemoryCache(SKIP_MEMORY_CACHE).into(imageView);
}
/**
* 显示视频封面缩略图
*/
public static void displayVideoThumb(Context context, String videoPath, ImageView imageView) {
if (!contextIsExist(context)){
return;
}
Glide.with(context).asDrawable().load(Uri.fromFile(new File(videoPath))).skipMemoryCache(SKIP_MEMORY_CACHE).into(imageView);
}
public static void displayDrawable(Context context, String url, final DrawableCallback callback) {
if (!contextIsExist(context)){
return;
}
Glide.with(context).asDrawable().load(url).skipMemoryCache(SKIP_MEMORY_CACHE).into(new SimpleTarget<Drawable>() {
@Override
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
if (callback != null) {
callback.onLoadSuccess(resource);
}
}
@Override
public void onLoadFailed(@Nullable Drawable errorDrawable) {
if (callback != null) {
callback.onLoadFailed();
}
}
});
}
public static void clear(Context context, ImageView imageView) {
if (!contextIsExist(context)){
return;
}
Glide.with(context).clear(imageView);
}
/**
* 显示模糊的毛玻璃图片
*/
public static void displayBlur(Context context, String url, ImageView imageView) {
if (!contextIsExist(context)){
return;
}
Glide.with(context).asDrawable().load(url)
.skipMemoryCache(SKIP_MEMORY_CACHE)
.apply(RequestOptions.bitmapTransform(sBlurTransformation))
.into(imageView);
}
private static boolean contextIsExist(Context context) {
if (context == null ) {
return false;
}
if (context instanceof Activity) {
Activity activity = (Activity) context;
if (activity.isDestroyed() || activity.isFinishing()) {
return false;
}
}
return true;
}
public interface DrawableCallback {
void onLoadSuccess(Drawable drawable);
void onLoadFailed();
}
}

View File

@@ -0,0 +1,28 @@
package com.yunbao.common.http;
/**
* Created by cxf on 2018/9/17.
*/
public class CommonHttpConsts {
public static final String LANGUAGE = "language";
public static final String GET_MAP_INFO = "getMapInfoByTxSdk";
public static final String GET_MAP_SEARCH = "searchInfoByTxSdk";
public static final String GET_LOCAITON = "getLocationByTxSdk";
public static final String GET_CONFIG = "getConfig";
public static final String GET_QQ_LOGIN_UNION_ID = "getQQLoginUnionID";
public static final String SET_ATTENTION = "setAttention";
public static final String GET_ALI_ORDER = "getAliOrder";
public static final String GET_WX_ORDER = "getWxOrder";
public static final String GET_CASHIER_ORDER = "getCashierOrder";
public static final String GET_WX_H5ORDER = "getWxH5Order";
public static final String DOWNLOAD_GIF = "downloadGif";
public static final String GET_BALANCE = "getBalance";
public static final String CHECK_TOKEN_INVALID = "checkTokenInvalid";
public static final String NOTIFY_GOOGLE = "Charge.google_pay";
public static final String COMMUNITY_SETREPORT = "Community.setReport";
public static final String GET_USER_HOME = "getUserHome";
public static final String GET_USER_BASEINFO = "getUserBaseinfo";
}

View File

@@ -0,0 +1,437 @@
package com.yunbao.common.http;
import android.content.Context;
import android.os.Build;
import android.util.Log;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.callback.StringCallback;
import com.lzy.okgo.model.Response;
import com.lzy.okgo.request.PostRequest;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.R;
import com.yunbao.common.activity.ErrorActivity;
import com.yunbao.common.bean.ConfigBean;
import com.yunbao.common.event.FollowEvent;
import com.yunbao.common.interfaces.CommonCallback;
import com.yunbao.common.utils.L;
import com.yunbao.common.utils.MD5Util;
import com.yunbao.common.utils.SpUtil;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordUtil;
import org.greenrobot.eventbus.EventBus;
import java.io.File;
import java.util.Locale;
/**
* Created by cxf on 2018/9/17.
*/
public class CommonHttpUtil {
/**
* 初始化
*/
public static void init() {
HttpClient.getInstance().init();
}
/**
* 取消网络请求
*/
public static void cancel(String tag) {
HttpClient.getInstance().cancel(tag);
}
/**
* 使用腾讯定位sdk获取 位置信息
*
* @param lng 经度
* @param lat 纬度
* @param poi 是否要查询POI
*/
public static void getAddressInfoByTxLocaitonSdk(final double lng, final double lat, final int poi, int pageIndex, String tag, final HttpCallback commonCallback) {
String txMapAppKey = CommonAppConfig.getInstance().getTxMapAppKey();
String s = "/ws/geocoder/v1/?get_poi=" + poi + "&key=" + txMapAppKey + "&location=" + lat + "," + lng
+ "&poi_options=address_format=short;radius=1000;page_size=20;page_index=" + pageIndex + ";policy=5" + CommonAppConfig.getInstance().getTxMapAppSecret();
String sign = MD5Util.getMD5(s);
OkGo.<String>get("https://apis.map.qq.com/ws/geocoder/v1/")
.params("location", lat + "," + lng)
.params("get_poi", poi)
.params("poi_options", "address_format=short;radius=1000;page_size=20;page_index=" + pageIndex + ";policy=5")
.params("key", txMapAppKey)
.params("sig", sign)
.tag(tag)
.execute(new StringCallback() {
@Override
public void onSuccess(Response<String> response) {
JSONObject obj = JSON.parseObject(response.body());
if (obj != null && commonCallback != null) {
commonCallback.onSuccess(obj.getIntValue("status"), "", new String[]{obj.getString("result")});
}
}
@Override
public void onError(Response<String> response) {
super.onError(response);
if (commonCallback != null) {
commonCallback.onError();
}
}
@Override
public void onFinish() {
super.onFinish();
if (commonCallback != null) {
commonCallback.onFinish();
}
}
});
}
/**
* 使用腾讯地图API进行搜索
*
* @param lng 经度
* @param lat 纬度
*/
public static void searchAddressInfoByTxLocaitonSdk(final double lng, final double lat, String keyword, int pageIndex, final HttpCallback commonCallback) {
String txMapAppKey = CommonAppConfig.getInstance().getTxMapAppKey();
String s = "/ws/place/v1/search?boundary=nearby(" + lat + "," + lng + ",1000)&key=" + txMapAppKey + "&keyword=" + keyword + "&orderby=_distance&page_index=" + pageIndex +
"&page_size=20" + CommonAppConfig.getInstance().getTxMapAppSecret();
String sign = MD5Util.getMD5(s);
OkGo.<String>get("https://apis.map.qq.com/ws/place/v1/search")
.params("keyword", keyword)
.params("boundary", "nearby(" + lat + "," + lng + ",1000)&orderby=_distance&page_size=20&page_index=" + pageIndex)
.params("key", txMapAppKey)
.params("sig", sign)
.tag(CommonHttpConsts.GET_MAP_SEARCH)
.execute(new StringCallback() {
@Override
public void onSuccess(Response<String> response) {
JSONObject obj = JSON.parseObject(response.body());
if (obj != null && commonCallback != null) {
commonCallback.onSuccess(obj.getIntValue("status"), "", new String[]{obj.getString("data")});
}
}
@Override
public void onError(Response<String> response) {
super.onError(response);
if (commonCallback != null) {
commonCallback.onError();
}
}
@Override
public void onFinish() {
super.onFinish();
if (commonCallback != null) {
commonCallback.onFinish();
}
}
});
}
/**
* 获取config
*/
public static void getConfig(Context context, final CommonCallback<ConfigBean> commonCallback) {
String lang = "";
if (context != null) {
Locale locale;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
locale = context.getResources().getConfiguration().getLocales().get(0);
} else {
locale = context.getResources().getConfiguration().locale;
}
if (locale.getLanguage().equals("en")) {
lang = "english";
} else {
lang = "chinese";
}
}
Log.i("来了", lang);
//或者仅仅使用 locale = Locale.getDefault(); 不需要考虑接口 deprecated(弃用)问题
HttpClient.getInstance().get("Home.getConfig", CommonHttpConsts.GET_CONFIG)
.params("uid", CommonAppConfig.getInstance().getUid())
.params("token", CommonAppConfig.getInstance().getToken())
.params("langue", lang)
.execute(new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
if (code == 0 && info.length > 0) {
try {
JSONObject obj = JSON.parseObject(info[0]);
ConfigBean bean = JSON.toJavaObject(obj, ConfigBean.class);
CommonAppConfig.getInstance().setConfig(bean);
CommonAppConfig.getInstance().setLevel(obj.getString("level"));
CommonAppConfig.getInstance().setAnchorLevel(obj.getString("levelanchor"));
CommonAppConfig.getInstance().alert_time = obj.getInteger("alert_time");
CommonAppConfig.getInstance().alert_end_time = obj.getInteger("alert_end_time");
//解析粉丝徽章
CommonAppConfig.getInstance().setAnchorFansMedal(obj.getString("levelfans"));
SpUtil.getInstance().setStringValue(SpUtil.CONFIG, info[0]);
if (commonCallback != null) {
commonCallback.callback(bean);
}
} catch (Exception e) {
String error = "info[0]:" + info[0] + "\n\n\n" + "Exception:" + e.getClass() + "---message--->" + e.getMessage();
ErrorActivity.forward("GetConfig接口返回数据异常", error);
}
}
}
@Override
public void onError() {
if (commonCallback != null) {
commonCallback.callback(null);
}
}
});
}
/**
* QQ登录的时候 获取unionID 与PC端互通的时候用
*/
public static void getQQLoginUnionID(String accessToken, final CommonCallback<String> commonCallback) {
OkGo.<String>get("https://graph.qq.com/oauth2.0/me?access_token=" + accessToken + "&unionid=1")
.tag(CommonHttpConsts.GET_QQ_LOGIN_UNION_ID)
.execute(new StringCallback() {
@Override
public void onSuccess(Response<String> response) {
if (commonCallback != null) {
String data = response.body();
data = data.substring(data.indexOf("{"), data.lastIndexOf("}") + 1);
L.e("getQQLoginUnionID------>" + data);
JSONObject obj = JSON.parseObject(data);
commonCallback.callback(obj.getString("unionid"));
}
}
});
}
/**
* 关注别人 或 取消对别人的关注的接口
*/
public static void setAttention(String touid, CommonCallback<Integer> callback) {
setAttention(CommonHttpConsts.SET_ATTENTION, touid, callback);
}
// /**
// * 关注别人 或 取消对别人的关注的接口
// */
// public static void setAttention(String tag, final String touid, final CommonCallback<Integer> callback) {
// if (touid.equals(CommonAppConfig.getInstance().getUid())) {
// ToastUtil.show(WordUtil.getString(R.string.cannot_follow_self));
// return;
// }
// HttpClient.getInstance().get("User.setAttent", tag)
// .params("uid", CommonAppConfig.getInstance().getUid())
// .params("token", CommonAppConfig.getInstance().getToken())
// .params("touid", touid)
// .execute(new HttpCallback() {
// @Override
// public void onSuccess(int code, String msg, String[] info) {
// if (code == 0 && info.length > 0) {
// int isAttention = JSON.parseObject(info[0]).getIntValue("isattent");//1是 关注 0是未关注
// EventBus.getDefault().post(new FollowEvent(touid, isAttention));
// if (callback != null) {
// callback.callback(isAttention);
// }
// }
// }
// });
// }
/**
* 关注别人 或 取消对别人的关注的接口
*/
public static void setAttention(String tag, final String touid, final CommonCallback<Integer> callback) {
if (touid.equals(CommonAppConfig.getInstance().getUid())) {
ToastUtil.show(WordUtil.getString(R.string.cannot_follow_self));
return;
}
HttpClient.getInstance().get("User.setAttents", tag)
.params("uid", CommonAppConfig.getInstance().getUid())
.params("token", CommonAppConfig.getInstance().getToken())
.params("touid", touid)
.execute(new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
if (code == 0 && info.length > 0) {
int isAttention = JSON.parseObject(info[0]).getIntValue("isattent");//1是 关注 0是未关注
EventBus.getDefault().post(new FollowEvent(touid, isAttention));
if (callback != null) {
callback.callback(isAttention);
}
}
}
});
}
/**
* 充值页面,我的钻石
*/
public static void getBalance(HttpCallback callback) {
String isGoogle;
if (CommonAppConfig.IS_GOOGLE_PLAY) {
isGoogle = "1";
} else {
isGoogle = "-1";
}
HttpClient.getInstance().get("User.getBalance", CommonHttpConsts.GET_BALANCE)
.params("uid", CommonAppConfig.getInstance().getUid())
.params("token", CommonAppConfig.getInstance().getToken())
.params("type", 0)
.params("isGooglePay", isGoogle)
.execute(callback);
}
/**
* 用支付宝充值 的时候在服务端生成订单号
*
* @param callback
*/
public static void getAliOrder(String parmas, HttpCallback callback) {
HttpClient.getInstance().get(parmas, CommonHttpConsts.GET_ALI_ORDER)
.execute(callback);
}
/**
* 用微信支付充值 的时候在服务端生成订单号
*
* @param callback
*/
public static void getWxOrder(String parmas, HttpCallback callback) {
HttpClient.getInstance().get(parmas, CommonHttpConsts.GET_WX_ORDER)
.execute(callback);
}
/**
* 海外支付
*
* @param callback
*/
public static void getCashierOrder(String parmas, HttpCallback callback) {
HttpClient.getInstance().get(parmas, CommonHttpConsts.GET_CASHIER_ORDER)
.execute(callback);
}
/**
* H5支付
*
* @param callback
*/
public static void getWxH5Order(String parmas, HttpCallback callback) {
HttpClient.getInstance().get(parmas, CommonHttpConsts.GET_WX_H5ORDER)
.execute(callback);
}
/**
* 检查token是否失效
*/
public static void checkTokenInvalid() {
HttpClient.getInstance().get("User.ifToken", CommonHttpConsts.CHECK_TOKEN_INVALID)
.params("uid", CommonAppConfig.getInstance().getUid())
.params("token", CommonAppConfig.getInstance().getToken())
.execute(NO_CALLBACK);
}
/**
* 谷歌支付成功后,通知自己服务器
*/
public static void notifyMeGoogle(String purchaseToken, String productId, String orderno, HttpCallback callback) {
HttpClient.getInstance().get(CommonHttpConsts.NOTIFY_GOOGLE, CommonHttpConsts.NOTIFY_GOOGLE)
.params("purchaseToken", purchaseToken)
.params("productId", productId)
.params("orderno", orderno)
.execute(callback);
}
public static void notifyGoogle(String purchaseToken, String orderNo, String tradeNo, String allData, HttpCallback callback) {
HttpClient.getInstance().get(CommonHttpConsts.NOTIFY_GOOGLE, CommonHttpConsts.NOTIFY_GOOGLE)
.params("purchaseToken", purchaseToken)
.params("orderno", orderNo)
.params("trade_no", tradeNo)
.params("allData", allData)
.execute(callback);
}
//不做任何操作的HttpCallback
public static final HttpCallback NO_CALLBACK = new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
}
};
/**
* 社区举报用户 + 图片
*/
public static void setCommunityReport(String community_type, String comment_id, String dynamic_id, String content, File file1, File file2, File file3, String report_type, HttpCallback callback) {
PostRequest<JsonBean> request;
if ("2".equals(community_type)) {
request = HttpClient.getInstance().post(CommonHttpConsts.COMMUNITY_SETREPORT, CommonHttpConsts.COMMUNITY_SETREPORT)
.isMultipart(true)
.params("uid", CommonAppConfig.getInstance().getUid())
.params("token", CommonAppConfig.getInstance().getToken())
.params("dynamic_id", dynamic_id)
.params("report_type", report_type)
.params("content", content)
.params("community_type", community_type)
.params("comment_id", comment_id);
} else {
request = HttpClient.getInstance().post(CommonHttpConsts.COMMUNITY_SETREPORT, CommonHttpConsts.COMMUNITY_SETREPORT)
.isMultipart(true)
.params("uid", CommonAppConfig.getInstance().getUid())
.params("token", CommonAppConfig.getInstance().getToken())
.params("dynamic_id", dynamic_id)
.params("report_type", report_type)
.params("content", content)
.params("community_type", community_type);
}
if (file1 != null) {
request.params("file1", file1);
}
if (file2 != null) {
request.params("file2", file2);
}
if (file3 != null) {
request.params("file3", file3);
}
request.execute(callback);
}
/**
* 用户个人主页信息
*/
public static void getUserBaseinfo(String touid, HttpCallback callback) {
HttpClient.getInstance().get("User.getUserBaseinfo", CommonHttpConsts.GET_USER_BASEINFO)
.params("uid", CommonAppConfig.getInstance().getUid())
.params("touid", touid)
.execute(callback);
}
}

View File

@@ -0,0 +1,35 @@
package com.yunbao.common.http;
/**
* Created by cxf on 2017/8/5.
*/
public class Data {
private int code;
private String msg;
private String[] info;
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public String[] getInfo() {
return info;
}
public void setInfo(String[] info) {
this.info = info;
}
}

Some files were not shown because too many files have changed in this diff Show More