This commit is contained in:
18401019693
2022-08-05 18:16:48 +08:00
parent 254f3af3c7
commit b0a1014cf3
57 changed files with 2005 additions and 421 deletions

View File

@@ -0,0 +1,154 @@
package com.yunbao.common.bean;
import com.google.gson.annotations.SerializedName;
/**
* 首頁搜索返回
*/
public class SearchModel extends BaseModel {
/**
* id : 79365
* user_nicename : 鱼鱼子
* avatar : https://ceshi.yaoulive.com/default.jpg
* sex : 2
* signature :
* consumption : 2600
* votestotal : 62850
* islive : 0
* level : 4
* level_anchor : 4
* isattention : 0
*/
//用戶ID
@SerializedName("id")
private long id = 0;
//暱稱
@SerializedName("user_nicename")
private String userNicename = "";
//頭像
@SerializedName("avatar")
private String avatar = "";
//性別
@SerializedName("sex")
private long sex = 0;
//個性簽名
@SerializedName("signature")
private String signature = "";
//消費額度
@SerializedName("consumption")
private long consumption = 0;
//票數
@SerializedName("votestotal")
private long votestotal = 0;
//是否在直播
@SerializedName("islive")
private long islive = 0;
//用戶等級
@SerializedName("level")
private String level = "";
@SerializedName("level_anchor")
private String levelAnchor = "";
//是否關注 1關注 2未關注
@SerializedName("isattention")
private String isattention = "";
public long getId() {
return id;
}
public SearchModel setId(long id) {
this.id = id;
return this;
}
public String getUserNicename() {
return userNicename;
}
public SearchModel setUserNicename(String userNicename) {
this.userNicename = userNicename;
return this;
}
public String getAvatar() {
return avatar;
}
public SearchModel setAvatar(String avatar) {
this.avatar = avatar;
return this;
}
public long getSex() {
return sex;
}
public SearchModel setSex(long sex) {
this.sex = sex;
return this;
}
public String getSignature() {
return signature;
}
public SearchModel setSignature(String signature) {
this.signature = signature;
return this;
}
public long getConsumption() {
return consumption;
}
public SearchModel setConsumption(long consumption) {
this.consumption = consumption;
return this;
}
public long getVotestotal() {
return votestotal;
}
public SearchModel setVotestotal(long votestotal) {
this.votestotal = votestotal;
return this;
}
public long getIslive() {
return islive;
}
public SearchModel setIslive(long islive) {
this.islive = islive;
return this;
}
public String getLevel() {
return level;
}
public SearchModel setLevel(String level) {
this.level = level;
return this;
}
public String getLevelAnchor() {
return levelAnchor;
}
public SearchModel setLevelAnchor(String levelAnchor) {
this.levelAnchor = levelAnchor;
return this;
}
public String getIsattention() {
return isattention;
}
public SearchModel setIsattention(String isattention) {
this.isattention = isattention;
return this;
}
}

View File

@@ -0,0 +1,24 @@
package com.yunbao.common.bean;
import com.google.gson.annotations.SerializedName;
import java.util.HashMap;
import java.util.Map;
/**
* 搜索页面数据类
*/
public class SearchRecommendModel extends BaseModel {
//存在第一条数据
@SerializedName("historyRecordMap")
private Map<String, String> historyRecordMap = new HashMap<>();
public Map<String, String> getHistoryRecordMap() {
return historyRecordMap;
}
public SearchRecommendModel setHistoryRecordMap(Map<String, String> historyRecordMap) {
this.historyRecordMap = historyRecordMap;
return this;
}
}

View File

@@ -0,0 +1,41 @@
package com.yunbao.common.dialog;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.view.Gravity;
import android.view.Window;
import android.view.WindowManager;
import com.yunbao.common.R;
/**
* 耗时操作通用Loading弹窗
*/
public class LoadingDialog extends AbsDialogFragment {
@Override
protected int getLayoutId() {
return R.layout.view_loading;
}
@Override
protected int getDialogStyle() {
return R.style.dialog4;
}
@Override
protected boolean canCancel() {
return false;
}
@Override
protected void setWindowAttributes(Window window) {
window.setWindowAnimations(R.style.bottomToTopAnim);
WindowManager.LayoutParams params = window.getAttributes();
params.width = WindowManager.LayoutParams.WRAP_CONTENT;
params.height = WindowManager.LayoutParams.WRAP_CONTENT;
params.gravity = Gravity.CENTER;
window.setAttributes(params);
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
}
}

View File

@@ -0,0 +1,80 @@
package com.yunbao.common.fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import com.yunbao.common.utils.Bus;
/**
* Fragment基类
*/
public abstract class BaseFragment extends Fragment {
public static String TAG = BaseFragment.class.getSimpleName();
private View contentView;
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
if (null == contentView) {
//赋值TAG
TAG = this.getClass().getSimpleName();
//创建视图
contentView = createView(inflater, container);
//初始化变量(用户传递进来的参数)
initVariables(getArguments());
//初始化视图
initViews(savedInstanceState,contentView);
//加载数据
loadData();
}
//返回视图
return contentView;
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//基类中注册消息总线
Bus.getOnWithBase(this);
}
/**
* 创建视图
*
* @param inflater inflater
* @param container container
* @return 视图
*/
public abstract View createView(LayoutInflater inflater, ViewGroup container);
/**
* 初始化变量
*
* @param bundle bundle
*/
protected abstract void initVariables(Bundle bundle);
/**
* 初始化视图
*
* @param savedInstanceState savedInstanceState
*/
protected abstract void initViews(Bundle savedInstanceState,View contentView);
/**
* 请求数据
*/
protected abstract void loadData();
@Override
public void onDestroy() {
super.onDestroy();
//基类中反注册
Bus.getOffWithBase(this);
}
}

View File

@@ -61,7 +61,15 @@ public class ImgLoader {
}
Glide.with(context).asDrawable().load(url).error(errorRes).skipMemoryCache(SKIP_MEMORY_CACHE).into(imageView);
}
public static void displayWithError(Context context, int 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;
@@ -69,7 +77,13 @@ public class ImgLoader {
displayWithError(context, url, imageView, R.mipmap.icon_avatar_placeholder);
}
public static void displayAvatar(Context context, int 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;

View File

@@ -3,6 +3,7 @@ package com.yunbao.common.http;
import com.yunbao.common.bean.BaseModel;
import com.yunbao.common.bean.IMLoginModel;
import com.yunbao.common.bean.NobleTrumpetModel;
import com.yunbao.common.bean.SearchModel;
import java.util.List;
@@ -56,4 +57,36 @@ public interface PDLiveApi {
Observable<ResponseModel<List<BaseModel>>> nobleUseTrumpet(
@Query("trumpet_msg") String trumpetMsg,
@Query("anchor_id") String anchorid);
/**
* 搜索
*
* @param jianKey 簡體關鍵字
* @param fanKey 繁體關鍵字
* @param type 搜索類型 1全部
* @param p 頁碼
* @return
*/
@GET("/api/public/?service=Home.newSearch")
Observable<ResponseModel<List<List<SearchModel>>>> search(
@Query("jian_key") String jianKey,
@Query("fan_key") String fanKey,
@Query("type") int type,
@Query("p") int p);
/**
* 搜索
*
* @param jianKey 簡體關鍵字
* @param fanKey 繁體關鍵字
* @param type 搜索類型 2主播 3用戶
* @param p 頁碼
* @return
*/
@GET("/api/public/?service=Home.newSearch")
Observable<ResponseModel<List<SearchModel>>> searchNew(
@Query("jian_key") String jianKey,
@Query("fan_key") String fanKey,
@Query("type") int type,
@Query("p") int p);
}

View File

@@ -3,10 +3,13 @@ package com.yunbao.common.http.main;
import android.app.Activity;
import com.yunbao.common.bean.IMLoginModel;
import com.yunbao.common.bean.SearchModel;
import com.yunbao.common.http.API;
import com.yunbao.common.http.ResponseModel;
import com.yunbao.common.http.base.HttpCallback;
import java.util.List;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers;
@@ -61,5 +64,50 @@ public class MainNetManager {
}).isDisposed();
}
/**
* 搜索
*
* @param jianKey 簡體關鍵字
* @param fanKey 繁體關鍵字
* @param type 搜索類型 1全部 2主播 3用戶
* @param p 頁碼
*/
public void search(String jianKey, String fanKey, int type, int p, HttpCallback<List<List<SearchModel>>> callback) {
API.get().pdLiveApi(mContext).search(jianKey,fanKey,type,p)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(listResponseModel -> {
if (callback != null) {
List<List<SearchModel>> model = listResponseModel.getData().getInfo();
callback.onSuccess(model);
}
}, throwable -> {
if (callback != null) {
callback.onError(throwable.getMessage());
}
}).isDisposed();
}
/**
* 搜索
*
* @param jianKey 簡體關鍵字
* @param fanKey 繁體關鍵字
* @param type 搜索類型 1全部 2主播 3用戶
* @param p 頁碼
*/
public void searchNew(String jianKey, String fanKey, int type, int p, HttpCallback<List<SearchModel>> callback) {
API.get().pdLiveApi(mContext).searchNew(jianKey,fanKey,type,p)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(listResponseModel -> {
if (callback != null) {
List<SearchModel> model = listResponseModel.getData().getInfo();
callback.onSuccess(model);
}
}, throwable -> {
if (callback != null) {
callback.onError(throwable.getMessage());
}
}).isDisposed();
}
}

View File

@@ -0,0 +1,75 @@
package com.yunbao.common.manager;
import android.content.Context;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.google.gson.Gson;
import com.yunbao.common.manager.base.BaseCacheManager;
import java.util.HashMap;
import java.util.Map;
/**
* 搜索历史记录管理
*/
public class SearchHistoryRecordManager extends BaseCacheManager {
private final static String KEY_HISTORY_RECORD = "HistoryRecord";
private static SearchHistoryRecordManager manager;
private Map<String, String> historyRecordMap;
public SearchHistoryRecordManager(Context context) {
super(context);
}
/**
* 获取单利
*
* @return
*/
public static SearchHistoryRecordManager get(Context context) {
if (null == manager) {
manager = new SearchHistoryRecordManager(context);
}
return manager;
}
/**
* 获取指导员备注信息
*
* @return
*/
public Map<String, String> getHistoryRecord() {
if (null == historyRecordMap) {
historyRecordMap = JSON.parseObject(getString(KEY_HISTORY_RECORD), new TypeReference<Map<String, String>>() {
});
}
if (historyRecordMap == null) {
historyRecordMap = new HashMap<>();
}
return historyRecordMap;
}
/**
* 新增备注
*
* @param key 用户id
* @param value 备注信息
*/
public void addHistoryRecord(String key, String value) {
this.historyRecordMap.put(key, value);
String json = new Gson().toJson(historyRecordMap).toString();
put(KEY_HISTORY_RECORD, json);
}
/**
* 删除备注
*/
public void removeHistoryRecord(String key) {
historyRecordMap.remove(key);
String json = new Gson().toJson(historyRecordMap).toString();
put(KEY_HISTORY_RECORD, json);
}
}

View File

@@ -0,0 +1,82 @@
package com.yunbao.common.utils;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import java.lang.reflect.Method;
/**
* 老司机-消息总线
*/
public class Bus extends EventBus {
private static Bus INSTANCE;
/**
* 获取车次
*
* @return eventbus对象
*/
public static Bus get() {
synchronized (Bus.class) {
if (null == INSTANCE) {
INSTANCE = new Bus();
}
}
return INSTANCE;
}
/**
* 上车-老司机带带我
*
* @param subscriber 监听者
*/
public static void getOn(Object subscriber) {
get().register(subscriber);
}
/**
* 在基类中注册eventbus
*
* @param subscriber
*/
public static void getOnWithBase(Object subscriber) {
for (Method method : subscriber
.getClass().getDeclaredMethods()) {
if (method.isAnnotationPresent(Subscribe.class)) {
getOn(subscriber);
break;
}
}
}
/**
* 下车
*
* @param subscriber 监听者
*/
public static void getOff(Object subscriber) {
get().unregister(subscriber);
}
/**
* 基类中销毁的方法
*
* @param subscriber
*/
public static void getOffWithBase(Object subscriber) {
if (inBus(subscriber)) {
getOff(subscriber);
}
}
/**
* 是否上车了
*
* @param subscriber 监听者
* @return 是否已监听
*/
public static boolean inBus(Object subscriber) {
return get().isRegistered(subscriber);
}
}

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<com.wang.avi.AVLoadingIndicatorView
android:id="@+id/avi"
style="@style/AVLoadingIndicatorView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:visibility="visible"
app:indicatorColor="@color/blue_337cf5"
app:indicatorName="BallTrianglePathIndicator" />
</LinearLayout>

View File

@@ -527,7 +527,7 @@
<string name="setting_clear_cache_ing">Scavenging</string>
<string name="setting_clear_cache">Cache cleared</string>
<string name="search">search</string>
<string name="search_hint">Please enter the nickname or ID to search</string>
<string name="search_hint">Search by nickname or ID</string>
<string name="search_no_data">No content found</string>
<string name="share_type_qq">QQ</string>
<string name="share_type_qzone">QQ Zone</string>

View File

@@ -81,4 +81,5 @@
<color name="green_81c160">#81C16D</color>
<color name="gray_f6f7fb">#F6F7FB</color>
<color name="gray_f6f6f6f6">#FFF6F6F6</color>
</resources>

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!--文本内容使用-->
<dimen name="content_text_size">5dp</dimen>
</resources>

View File

@@ -464,7 +464,7 @@
<string name="setting_clear_cache_ing">清除中</string>
<string name="setting_clear_cache">緩存已清除</string>
<string name="search">蒐索</string>
<string name="search_hint">請輸入要搜索昵稱或ID</string>
<string name="search_hint">搜索昵稱或ID</string>
<string name="search_no_data">沒有搜索到相關內容</string>
<string name="share_type_qq">QQ電話</string>
<string name="share_type_qzone">QQ空間</string>
@@ -866,4 +866,8 @@
<string name="go_nobility">前往贵族</string>
<string name="use_successfully">使用成功</string>
<string name="use_live">前往直播間</string>
<string name="search_history">搜索歷史</string>
<string name="you_may_also_like">猜你喜歡</string>
<string name="anchor">主播</string>
<string name="anchor_more">更多</string>
</resources>

View File

@@ -32,6 +32,15 @@
<!--显示区域以外是否使用黑色半透明背景-->
<item name="android:backgroundDimEnabled">true</item>
</style>
<style name="dialog4" parent="AppTheme">
<item name="android:windowFrame">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@color/transparent</item>
<!--显示区域以外是否使用黑色半透明背景-->
<item name="android:backgroundDimEnabled">false</item>
</style>
<style name="dialog3" parent="AppTheme">
<item name="android:windowFrame">@null</item>
<item name="android:windowNoTitle">true</item>