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

@ -175,4 +175,9 @@ dependencies {
//rxjava2库 //rxjava2库
api 'io.reactivex.rxjava2:rxjava:2.0.1' api 'io.reactivex.rxjava2:rxjava:2.0.1'
api 'io.reactivex.rxjava2:rxandroid:2.0.1' api 'io.reactivex.rxjava2:rxandroid:2.0.1'
//loading样式库
api 'com.wang.avi:library:2.1.3'
//
api "com.jakewharton:butterknife:10.0.0"
annotationProcessor "com.jakewharton:butterknife-compiler:10.0.0"
} }

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); 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) { public static void displayAvatar(Context context, String url, ImageView imageView) {
if (!contextIsExist(context)){ if (!contextIsExist(context)){
return; return;
@ -69,7 +77,13 @@ public class ImgLoader {
displayWithError(context, url, imageView, R.mipmap.icon_avatar_placeholder); 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) { public static void display(Context context, File file, ImageView imageView) {
if (!contextIsExist(context)){ if (!contextIsExist(context)){
return; return;

View File

@ -3,6 +3,7 @@ package com.yunbao.common.http;
import com.yunbao.common.bean.BaseModel; import com.yunbao.common.bean.BaseModel;
import com.yunbao.common.bean.IMLoginModel; import com.yunbao.common.bean.IMLoginModel;
import com.yunbao.common.bean.NobleTrumpetModel; import com.yunbao.common.bean.NobleTrumpetModel;
import com.yunbao.common.bean.SearchModel;
import java.util.List; import java.util.List;
@ -56,4 +57,36 @@ public interface PDLiveApi {
Observable<ResponseModel<List<BaseModel>>> nobleUseTrumpet( Observable<ResponseModel<List<BaseModel>>> nobleUseTrumpet(
@Query("trumpet_msg") String trumpetMsg, @Query("trumpet_msg") String trumpetMsg,
@Query("anchor_id") String anchorid); @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 android.app.Activity;
import com.yunbao.common.bean.IMLoginModel; import com.yunbao.common.bean.IMLoginModel;
import com.yunbao.common.bean.SearchModel;
import com.yunbao.common.http.API; import com.yunbao.common.http.API;
import com.yunbao.common.http.ResponseModel; import com.yunbao.common.http.ResponseModel;
import com.yunbao.common.http.base.HttpCallback; import com.yunbao.common.http.base.HttpCallback;
import java.util.List;
import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.functions.Consumer; import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers; import io.reactivex.schedulers.Schedulers;
@ -61,5 +64,50 @@ public class MainNetManager {
}).isDisposed(); }).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_ing">Scavenging</string>
<string name="setting_clear_cache">Cache cleared</string> <string name="setting_clear_cache">Cache cleared</string>
<string name="search">search</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="search_no_data">No content found</string>
<string name="share_type_qq">QQ</string> <string name="share_type_qq">QQ</string>
<string name="share_type_qzone">QQ Zone</string> <string name="share_type_qzone">QQ Zone</string>

View File

@ -81,4 +81,5 @@
<color name="green_81c160">#81C16D</color> <color name="green_81c160">#81C16D</color>
<color name="gray_f6f7fb">#F6F7FB</color> <color name="gray_f6f7fb">#F6F7FB</color>
<color name="gray_f6f6f6f6">#FFF6F6F6</color>
</resources> </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_ing">清除中</string>
<string name="setting_clear_cache">緩存已清除</string> <string name="setting_clear_cache">緩存已清除</string>
<string name="search">蒐索</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="search_no_data">沒有搜索到相關內容</string>
<string name="share_type_qq">QQ電話</string> <string name="share_type_qq">QQ電話</string>
<string name="share_type_qzone">QQ空間</string> <string name="share_type_qzone">QQ空間</string>
@ -866,4 +866,8 @@
<string name="go_nobility">前往贵族</string> <string name="go_nobility">前往贵族</string>
<string name="use_successfully">使用成功</string> <string name="use_successfully">使用成功</string>
<string name="use_live">前往直播間</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> </resources>

View File

@ -32,6 +32,15 @@
<!--显示区域以外是否使用黑色半透明背景--> <!--显示区域以外是否使用黑色半透明背景-->
<item name="android:backgroundDimEnabled">true</item> <item name="android:backgroundDimEnabled">true</item>
</style> </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"> <style name="dialog3" parent="AppTheme">
<item name="android:windowFrame">@null</item> <item name="android:windowFrame">@null</item>
<item name="android:windowNoTitle">true</item> <item name="android:windowNoTitle">true</item>

View File

@ -9,9 +9,9 @@ ext {
] ]
manifestPlaceholders = [ manifestPlaceholders = [
// //
serverHost : "https://napi.yaoulive.com", // serverHost : "https://napi.yaoulive.com",
// //
// serverHost : "https://ceshi.yaoulive.com", serverHost : "https://ceshi.yaoulive.com",
// //
txMapAppKey : "EOZBZ-ASLCU-4XPV3-BDCHZ-4E3Q7-H4BWB", txMapAppKey : "EOZBZ-ASLCU-4XPV3-BDCHZ-4E3Q7-H4BWB",

View File

@ -64,7 +64,7 @@ repositories {
} }
dependencies { dependencies {
implementation 'androidx.constraintlayout:constraintlayout:1.1.3' implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation fileTree(dir: 'libs', include: ['*.jar']) implementation fileTree(include: ['*.jar'], dir: 'libs')
// //
api project(':live') api project(':live')
// //
@ -77,5 +77,6 @@ dependencies {
implementation 'com.justkiddingbaby:slidemenu:1.3.0' implementation 'com.justkiddingbaby:slidemenu:1.3.0'
implementation 'com.xj.marqueeView:marqueeView:0.1.20' implementation 'com.xj.marqueeView:marqueeView:0.1.20'
implementation 'com.google.android.gms:play-services-auth:15.0.0' implementation 'com.google.android.gms:play-services-auth:15.0.0'
//Google
implementation files('libs/jcc-bate-0.7.3.jar')
} }

Binary file not shown.

View File

@ -58,7 +58,8 @@
android:screenOrientation="portrait" /> android:screenOrientation="portrait" />
<activity <activity
android:name=".activity.SearchActivity" android:name=".activity.SearchActivity"
android:screenOrientation="portrait" /> android:screenOrientation="portrait"
android:theme="@style/CAppTheme"/>
<activity <activity
android:name=".activity.FollowActivity" android:name=".activity.FollowActivity"
android:screenOrientation="portrait" /> android:screenOrientation="portrait" />

View File

@ -2,101 +2,30 @@ package com.yunbao.main.activity;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.os.Bundle;
import android.graphics.Color;
import android.os.Handler;
import android.os.Message;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentPagerAdapter;
import androidx.viewpager.widget.ViewPager;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.text.Editable; import android.text.Editable;
import android.text.TextUtils; import android.text.TextUtils;
import android.text.TextWatcher; import android.text.TextWatcher;
import android.view.KeyEvent;
import android.view.View;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText; import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.alibaba.fastjson.JSON; import androidx.fragment.app.FragmentManager;
import com.google.gson.Gson; import androidx.fragment.app.FragmentTransaction;
import com.google.gson.reflect.TypeToken;
import com.yunbao.common.Constants;
import com.yunbao.common.activity.AbsActivity; import com.yunbao.common.activity.AbsActivity;
import com.yunbao.common.adapter.RefreshAdapter;
import com.yunbao.common.custom.CommonRefreshView;
import com.yunbao.common.event.FollowEvent;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.interfaces.OnItemClickListener;
import com.yunbao.common.utils.RouteUtil;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordUtil;
import com.yunbao.live.bean.SearchUserBean;
import com.yunbao.main.R; import com.yunbao.main.R;
import com.yunbao.main.adapter.CommonAdapter; import com.yunbao.main.fragment.SearchRecommendFragment;
import com.yunbao.main.adapter.MultiItemTypeAdapter; import com.yunbao.main.fragment.SearchResultsFragment;
import com.yunbao.main.adapter.SearchAdapter; import com.yunbao.main.fragment.SearchResultsItemFragment;
import com.yunbao.main.adapter.ViewHolder;
import com.yunbao.main.dialog.BlankDialog;
import com.yunbao.main.http.MainHttpConsts; import com.yunbao.main.http.MainHttpConsts;
import com.yunbao.main.http.MainHttpUtil; import com.yunbao.main.http.MainHttpUtil;
import com.yunbao.main.utils.HXLinePagerIndicator;
import net.lucode.hackware.magicindicator.MagicIndicator;
import net.lucode.hackware.magicindicator.ViewPagerHelper;
import net.lucode.hackware.magicindicator.buildins.UIUtil;
import net.lucode.hackware.magicindicator.buildins.commonnavigator.CommonNavigator;
import net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.CommonNavigatorAdapter;
import net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.IPagerIndicator;
import net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.IPagerTitleView;
import net.lucode.hackware.magicindicator.buildins.commonnavigator.indicators.LinePagerIndicator;
import net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.SimplePagerTitleView;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
//import com.google.gson.jpush.reflect.TypeToken;
/** /**
* Created by cxf on 2018/10/25. * Created by cxf on 2018/10/25.
*/ */
public class SearchActivity extends AbsActivity implements OnItemClickListener<SearchUserBean> { public class SearchActivity extends AbsActivity {
private ViewPager vp_content;
private MagicIndicator magicIndicator;
private LinearLayout search_view, lt_search_list;
private ImageView search_del;
private EditText mEditText; private EditText mEditText;
private CommonRefreshView mRefreshView;
private SearchAdapter mSearchAdapter;
private InputMethodManager imm;
private String mKey;
private MyHandler mHandler;
private RecyclerView list_record;
private CommonAdapter adapter;
private List<String> records;
SharedPreferences sharedPreferences;
SharedPreferences.Editor editor;
private Fragment[] fragments = null;
private final String[] titles = {WordUtil.getString(R.string.all), WordUtil.getString(R.string.live_anchor), WordUtil.getString(R.string.user)};
public static void forward(Context context) { public static void forward(Context context) {
context.startActivity(new Intent(context, SearchActivity.class)); context.startActivity(new Intent(context, SearchActivity.class));
@ -107,72 +36,29 @@ public class SearchActivity extends AbsActivity implements OnItemClickListener<S
return R.layout.activity_search; return R.layout.activity_search;
} }
Gson gson;
//历史记录
@Override @Override
protected void main() { protected void main() {
imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); //進入頁面首先展示推薦頁面
search_view = (LinearLayout) findViewById(R.id.search_view); SearchRecommendFragment searchRecommendFragment = new SearchRecommendFragment();
search_del = (ImageView) findViewById(R.id.search_del); FragmentManager manager = getSupportFragmentManager();
mEditText = (EditText) findViewById(R.id.edit); FragmentTransaction transaction = manager.beginTransaction();
list_record = (RecyclerView) findViewById(R.id.list_record); transaction.replace(R.id.context_layout, searchRecommendFragment);
lt_search_list = (LinearLayout) findViewById(R.id.lt_search_list); transaction.commit();
magicIndicator = (MagicIndicator) findViewById(R.id.magic_indicator); mEditText = findViewById(R.id.edit);
vp_content = (ViewPager) findViewById(R.id.vp_content); mEditText.addTextChangedListener(textWatcher);
searchIndicator();//绑定指示器
sharedPreferences = getSharedPreferences("data", Context.MODE_PRIVATE);
editor = sharedPreferences.edit();
gson = new Gson();
records = new ArrayList<>();
if (sharedPreferences.contains("data")) {
records = gson.fromJson(sharedPreferences.getString("data", ""), new TypeToken<List<String>>() {
}.getType());
Collections.reverse(records);
}
search_view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
records.clear();
editor.clear();
editor.commit();
adapter.notifyDataSetChanged();
}
});
adapter = new CommonAdapter(SearchActivity.this, R.layout.item_search_record, records) {
@Override
protected void convert(ViewHolder holder, Object o, final int position) {
holder.setText(R.id.text_id, records.get(position));
}
};
adapter.setOnItemClickListener(new MultiItemTypeAdapter.OnItemClickListener() {
@Override
public void onItemClick(View view, RecyclerView.ViewHolder holder, int position) {
mEditText.setText(records.get(position));
search();
} }
@Override @Override
public boolean onItemLongClick(View view, RecyclerView.ViewHolder holder, int position) { protected void onDestroy() {
return false; MainHttpUtil.cancel(MainHttpConsts.SEARCH);
super.onDestroy();
} }
});
list_record.setLayoutManager(new GridLayoutManager(this, 4)); //輸入框監聽函數
list_record.setAdapter(adapter); TextWatcher textWatcher = new TextWatcher() {
mEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
search();
return true;
}
return false;
}
});
mEditText.addTextChangedListener(new TextWatcher() {
@Override @Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) { public void beforeTextChanged(CharSequence s, int start, int count, int after) {
@ -180,215 +66,31 @@ public class SearchActivity extends AbsActivity implements OnItemClickListener<S
@Override @Override
public void onTextChanged(CharSequence s, int start, int before, int count) { public void onTextChanged(CharSequence s, int start, int before, int count) {
MainHttpUtil.cancel(MainHttpConsts.SEARCH); if (TextUtils.isEmpty(s.toString())) {
if (mHandler != null) { //檢索推薦頁面
mHandler.removeCallbacksAndMessages(null); SearchRecommendFragment searchRecommendFragment = new SearchRecommendFragment();
} FragmentManager manager = getSupportFragmentManager();
if (!TextUtils.isEmpty(s)) { FragmentTransaction transaction = manager.beginTransaction();
if (mHandler != null) { transaction.replace(R.id.context_layout, searchRecommendFragment);
mHandler.sendEmptyMessageDelayed(0, 500); transaction.commit();
}
} else { } else {
mKey = null; //展示檢索頁面
if (mSearchAdapter != null) { SearchResultsFragment searchResultsFragment = new SearchResultsFragment();
mSearchAdapter.clearData(); FragmentManager manager = getSupportFragmentManager();
} FragmentTransaction transaction = manager.beginTransaction();
Bundle bundle = new Bundle();
bundle.putString("searchKey", s.toString());
searchResultsFragment.setArguments(bundle);
transaction.replace(R.id.context_layout, searchResultsFragment);
transaction.commit();
} }
} }
@Override @Override
public void afterTextChanged(Editable s) { public void afterTextChanged(Editable s) {
}
});
mRefreshView = findViewById(R.id.refreshView);
mRefreshView.setEmptyLayoutId(R.layout.view_no_data_search);
mRefreshView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false));
mRefreshView.setDataHelper(new CommonRefreshView.DataHelper<SearchUserBean>() {
@Override
public RefreshAdapter<SearchUserBean> getAdapter() {
if (mSearchAdapter == null) {
mSearchAdapter = new SearchAdapter(mContext, Constants.FOLLOW_FROM_SEARCH);
mSearchAdapter.setOnItemClickListener(SearchActivity.this);
}
return mSearchAdapter;
}
@Override
public void loadData(int p, HttpCallback callback) {
if (!TextUtils.isEmpty(mKey)) {
search_view.setVisibility(View.GONE);
if (!sharedPreferences.getString("data", "").contains(mKey)) {
if (records.size() > 10) {
records.remove(0);
}
records.add(mKey);
editor.putString("data", gson.toJson(records));
editor.commit();
adapter.notifyDataSetChanged();
}
MainHttpUtil.search(mKey, typeIndex, p, callback);
lt_search_list.setVisibility(View.VISIBLE);
} else {
search_view.setVisibility(View.VISIBLE);
lt_search_list.setVisibility(View.GONE);
}
}
@Override
public List<SearchUserBean> processData(String[] info) {
return JSON.parseArray(Arrays.toString(info), SearchUserBean.class);
}
@Override
public void onRefreshSuccess(List<SearchUserBean> list, int listCount) {
}
@Override
public void onRefreshFailure() {
}
@Override
public void onLoadMoreSuccess(List<SearchUserBean> loadItemList, int loadItemCount) {
}
@Override
public void onLoadMoreFailure() {
} }
}); };
mHandler = new MyHandler(this);
EventBus.getDefault().register(this);
}
//绑定指示器
private int typeIndex = 1;
private void searchIndicator() {
CommonNavigator commonNavigator = new CommonNavigator(this);
commonNavigator.setAdjustMode(true);
commonNavigator.setAdapter(new CommonNavigatorAdapter() {
@Override
public int getCount() {
return titles == null ? 0 : titles.length;
}
@Override
public IPagerTitleView getTitleView(Context context, final int index) {
SimplePagerTitleView simplePagerTitleView = new SimplePagerTitleView(context);
simplePagerTitleView.setText(titles[index]);
simplePagerTitleView.setTextSize(16);//设置导航的文字大小
simplePagerTitleView.setNormalColor(Color.BLACK);//正常状态下的标题颜色
simplePagerTitleView.setSelectedColor(getResources().getColor(R.color.global));//选中的标题字体颜色
simplePagerTitleView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
vp_content.setCurrentItem(index);
typeIndex = 1 + index;
search();
}
});
return simplePagerTitleView;
}
@Override
public IPagerIndicator getIndicator(Context context) {
HXLinePagerIndicator indicator = new HXLinePagerIndicator(context);
indicator.setMode(LinePagerIndicator.MODE_EXACTLY);
indicator.setLineHeight(UIUtil.dip2px(context, 4));
indicator.setLineWidth(UIUtil.dip2px(context, 20));
indicator.setRoundRadius(UIUtil.dip2px(context, 3));
indicator.setStartInterpolator(new AccelerateInterpolator());
indicator.setEndInterpolator(new DecelerateInterpolator(2.0f));
indicator.setColors(getResources().getColor(R.color.global));
return indicator;
}
});
magicIndicator.setNavigator(commonNavigator);
fragments = new Fragment[]{new BlankDialog(),new BlankDialog(),new BlankDialog()};
//每项只进入一次
vp_content.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {
@Override
public Fragment getItem(int position) {
return fragments[position];
}
@Override
public int getCount() {
return fragments.length;
}
@Override
public CharSequence getPageTitle(int position) {
return titles[position];
}
});
ViewPagerHelper.bind(magicIndicator, vp_content);
}
private void search() {
String key = mEditText.getText().toString().trim();
if (TextUtils.isEmpty(key)) {
ToastUtil.show(R.string.content_empty);
return;
}
MainHttpUtil.cancel(MainHttpConsts.SEARCH);
if (mHandler != null) {
mHandler.removeCallbacksAndMessages(null);
}
mKey = key;
mRefreshView.initData();
}
@Override
protected void onDestroy() {
EventBus.getDefault().unregister(this);
MainHttpUtil.cancel(MainHttpConsts.SEARCH);
if (mHandler != null) {
mHandler.removeCallbacksAndMessages(null);
mHandler.release();
}
mHandler = null;
super.onDestroy();
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onFollowEvent(FollowEvent e) {
if (mSearchAdapter != null) {
mSearchAdapter.updateItem(e.getToUid(), e.getIsAttention());
ToastUtil.show(getResources().getString(R.string.following));
}
}
@Override
public void onItemClick(SearchUserBean bean, int position) {
//跳转到个人资料
if (imm != null && mEditText != null) {
imm.hideSoftInputFromWindow(mEditText.getWindowToken(), 0);
RouteUtil.forwardUserHome(mContext, bean.getId(),0);
}
}
private static class MyHandler extends Handler {
private SearchActivity mActivity;
public MyHandler(SearchActivity activity) {
mActivity = new WeakReference<>(activity).get();
}
@Override
public void handleMessage(Message msg) {
if (mActivity != null) {
mActivity.search();
}
}
public void release() {
mActivity = null;
}
}
} }

View File

@ -0,0 +1,45 @@
package com.yunbao.main.adapter;
import android.annotation.SuppressLint;
import android.content.Context;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
import com.yunbao.main.R;
import java.util.ArrayList;
import java.util.List;
public class SearchFragmentPagerAdapter extends FragmentPagerAdapter {
private Context mContext;
private List<Fragment> fragmentList;
private List<String> tabs = new ArrayList<>();
public SearchFragmentPagerAdapter(FragmentManager fm, Context mContext, List<Fragment> fragmentList) {
super(fm);
this.mContext = mContext;
this.fragmentList = fragmentList;
tabs.add(mContext.getResources().getString(R.string.all));
tabs.add(mContext.getResources().getString(R.string.anchor));
tabs.add(mContext.getResources().getString(R.string.user));
}
@Override
public Fragment getItem(int i) {
return fragmentList.get(i);
}
@Override
public int getCount() {
return fragmentList.size();
}
@Override
public CharSequence getPageTitle(int position) {
return tabs.get(position);
}
}

View File

@ -0,0 +1,73 @@
package com.yunbao.main.adapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.yunbao.common.bean.SearchRecommendModel;
import com.yunbao.main.R;
import com.yunbao.main.views.SearchRecommendBodyViewHolder;
import com.yunbao.main.views.SearchRecommendHeardViewHolder;
import java.util.ArrayList;
import java.util.List;
/**
* 搜索推薦頁面適配器
*/
public class SearchRecommendAdapter extends RecyclerView.Adapter {
private static final int HEAD = 0;
private static final int BODY = 1;
private List<SearchRecommendModel> recommendModels = new ArrayList<>();
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
switch (viewType) {
case HEAD:
View herdView = LayoutInflater.from(parent.getContext()).inflate(R.layout.view_search_recommend_heard, parent, false);
return new SearchRecommendHeardViewHolder(herdView);
default:
View bodyView = LayoutInflater.from(parent.getContext()).inflate(R.layout.view_search_recommend_body, parent, false);
return new SearchRecommendBodyViewHolder(bodyView);
}
}
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
if (holder instanceof SearchRecommendHeardViewHolder) {
SearchRecommendHeardViewHolder heardViewHolder = (SearchRecommendHeardViewHolder) holder;
heardViewHolder.setHistory(recommendModels.get(position).getHistoryRecordMap());
} else {
}
}
@Override
public int getItemCount() {
return recommendModels.size();
}
@Override
public int getItemViewType(int position) {
if (position == (recommendModels.size() - 1)) {
return HEAD;
} else {
return BODY;
}
}
/**
* 添加数据
*
* @param list
*/
public void addData(List<SearchRecommendModel> list) {
recommendModels.clear();
recommendModels.addAll(list);
notifyDataSetChanged();
}
}

View File

@ -0,0 +1,51 @@
package com.yunbao.main.adapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.yunbao.common.bean.SearchModel;
import com.yunbao.main.R;
import com.yunbao.main.views.SearchResultsViewHolder;
import java.util.ArrayList;
import java.util.List;
public class SearchResultsAdapter extends RecyclerView.Adapter {
private List<SearchModel> searchModels = new ArrayList<>();
private int type = -1;
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View bodyView = LayoutInflater.from(parent.getContext()).inflate(R.layout.view_search_results_item_holder, parent, false);
return new SearchResultsViewHolder(bodyView);
}
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
if (holder instanceof SearchResultsViewHolder) {
SearchResultsViewHolder resultsViewHolder = (SearchResultsViewHolder) holder;
resultsViewHolder.showData(searchModels.get(position), type);
}
}
@Override
public int getItemCount() {
return searchModels.size();
}
/**
* 添加數據源
*
* @param models
*/
public void putData(List<SearchModel> models, int type) {
this.type = type;
searchModels.clear();
searchModels.addAll(models);
notifyDataSetChanged();
}
}

View File

@ -0,0 +1,85 @@
package com.yunbao.main.adapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.yunbao.common.bean.SearchModel;
import com.yunbao.main.R;
import com.yunbao.main.views.AnchorSearchResultsItemViewHolder;
import com.yunbao.main.views.UserSearchResultsItemViewHolder;
import java.util.ArrayList;
import java.util.List;
/**
* 搜索結果頁面適配器
*/
public class SearchResultsItemAdapter extends RecyclerView.Adapter {
private List<List<SearchModel>> lists = new ArrayList<>();
private final int ANCHOR = 2, USER = 3;
private int type = -1;
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
switch (viewType) {
case ANCHOR:
View herdView = LayoutInflater.from(parent.getContext()).inflate(R.layout.view_anchor_search_results_item_holder, parent, false);
return new AnchorSearchResultsItemViewHolder(herdView);
default:
View bodyView = LayoutInflater.from(parent.getContext()).inflate(R.layout.view_user_search_results_item_holder, parent, false);
return new UserSearchResultsItemViewHolder(bodyView);
}
}
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
if (holder instanceof AnchorSearchResultsItemViewHolder) {
AnchorSearchResultsItemViewHolder itemViewHolder = (AnchorSearchResultsItemViewHolder) holder;
itemViewHolder.showAnchors(lists.get(position), ANCHOR);
if (type != 1) {
itemViewHolder.hideTypeTitle();
}
} else {
UserSearchResultsItemViewHolder viewHolder = (UserSearchResultsItemViewHolder) holder;
viewHolder.showAnchors(lists.get(position), USER);
if (type != 1) {
viewHolder.hideTypeTitle();
}
}
}
@Override
public int getItemCount() {
return lists.size();
}
@Override
public int getItemViewType(int position) {
if (type == 1) {
if (position == (lists.size() - 1)) {
return ANCHOR;
} else {
return USER;
}
}
return type;
}
/**
* 設置數據源
*
* @param mLists 數據源
* @param type
*/
public void showData(List<List<SearchModel>> mLists, int type) {
this.type = type;
lists.clear();
lists.addAll(mLists);
notifyDataSetChanged();
}
}

View File

@ -0,0 +1,16 @@
package com.yunbao.main.event;
import com.yunbao.common.bean.BaseModel;
public class AnchorSearchEvent extends BaseModel {
private int jumpType = 0;
public int getJumpType() {
return jumpType;
}
public AnchorSearchEvent setJumpType(int jumpType) {
this.jumpType = jumpType;
return this;
}
}

View File

@ -0,0 +1,66 @@
package com.yunbao.main.fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.yunbao.common.bean.SearchRecommendModel;
import com.yunbao.common.fragment.BaseFragment;
import com.yunbao.main.R;
import com.yunbao.main.adapter.SearchRecommendAdapter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 搜索推荐页面 搜索結果
*/
public class SearchRecommendFragment extends BaseFragment {
private RecyclerView searchRecommend;
private SearchRecommendAdapter adapter;
@Override
public View createView(LayoutInflater layoutInflater, ViewGroup viewGroup) {
return layoutInflater.inflate(R.layout.view_search_recommend, viewGroup, false);
}
@Override
protected void initVariables(Bundle bundle) {
}
@Override
protected void initViews(Bundle savedInstanceState, View contentView) {
searchRecommend = contentView.findViewById(R.id.search_recommend_list);
adapter = new SearchRecommendAdapter();
searchRecommend.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, true));
searchRecommend.setAdapter(adapter);
}
@Override
protected void loadData() {
List<SearchRecommendModel> searchRecommendModels = new ArrayList<>();
SearchRecommendModel model = new SearchRecommendModel();
Map<String, String> historyRecordMap = new HashMap<>();
historyRecordMap.put("大米", "");
historyRecordMap.put("開門", "");
historyRecordMap.put("芝麻", "");
historyRecordMap.put("瓦達上來看沒看", "");
historyRecordMap.put("", "");
historyRecordMap.put("加兩顆蛋", "");
historyRecordMap.put("打算", "");
searchRecommendModels.add(model.setHistoryRecordMap(historyRecordMap));
adapter.addData(searchRecommendModels);
}
}

View File

@ -0,0 +1,64 @@
package com.yunbao.main.fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;
import com.google.android.material.tabs.TabLayout;
import com.yunbao.common.fragment.BaseFragment;
import com.yunbao.main.R;
import com.yunbao.main.adapter.SearchFragmentPagerAdapter;
import com.yunbao.main.event.AnchorSearchEvent;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import java.util.ArrayList;
/**
* 搜索結果展示頁面
*/
public class SearchResultsFragment extends BaseFragment {
private String searchKey = "1";//
private TabLayout searchType;
private ViewPager fragmentViewpager;
private ArrayList<Fragment> ViewList = new ArrayList<>(); //页卡视图集合
private SearchFragmentPagerAdapter fragmentPagerAdapter;
@Override
public View createView(LayoutInflater layoutInflater, ViewGroup viewGroup) {
return layoutInflater.inflate(R.layout.view_search_results, viewGroup, false);
}
@Override
protected void initVariables(Bundle bundle) {
searchKey = bundle.getString("searchKey");
ViewList.add(SearchResultsItemFragment.newInstance(searchKey, SearchResultsItemFragment.SearchResultsType.ALL.getType()));
ViewList.add(SearchResultsItemFragment.newInstance(searchKey, SearchResultsItemFragment.SearchResultsType.ANCHOR.getType()));
ViewList.add(SearchResultsItemFragment.newInstance(searchKey, SearchResultsItemFragment.SearchResultsType.USER.getType()));
}
@Override
protected void initViews(Bundle savedInstanceState, View contentView) {
searchType = contentView.findViewById(R.id.search_type);
fragmentViewpager = contentView.findViewById(R.id.context_layout);
fragmentPagerAdapter = new SearchFragmentPagerAdapter(getChildFragmentManager(), getActivity(), ViewList);
fragmentViewpager.setAdapter(fragmentPagerAdapter);
searchType.setupWithViewPager(fragmentViewpager);
}
@Override
protected void loadData() {
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onAnchorSearchEvent(AnchorSearchEvent event) {
fragmentViewpager.setCurrentItem(event.getJumpType());
}
}

View File

@ -0,0 +1,148 @@
package com.yunbao.main.fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.yunbao.common.bean.SearchModel;
import com.yunbao.common.fragment.BaseFragment;
import com.yunbao.common.http.base.HttpCallback;
import com.yunbao.common.http.main.MainNetManager;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.main.R;
import com.yunbao.main.adapter.SearchResultsItemAdapter;
import com.yunbao.main.utils.WordsTypeUtil;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* 展示結果的分類頁面
*/
public class SearchResultsItemFragment extends BaseFragment {
private String searchKey = "";
private int page = 1;
private LinearLayout loading;
private RecyclerView searchList;
private SearchResultsItemAdapter itemAdapter;
@Override
public View createView(LayoutInflater layoutInflater, ViewGroup viewGroup) {
return layoutInflater.inflate(R.layout.view_search_results_item, viewGroup, false);
}
@Override
protected void initVariables(Bundle bundle) {
setSearchKey(bundle.getString("searchKey"), bundle.getInt("type"));
}
@Override
protected void initViews(Bundle savedInstanceState, View contentView) {
loading = contentView.findViewById(R.id.loading);
searchList = contentView.findViewById(R.id.search_list);
loading.setVisibility(View.VISIBLE);
itemAdapter = new SearchResultsItemAdapter();
searchList.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, true));
searchList.setAdapter(itemAdapter);
}
@Override
protected void loadData() {
}
/**
* 開始檢索關鍵字
*
* @param searchKey 關鍵字
* @param type 類型
*/
public void setSearchKey(String searchKey, int type) {
this.searchKey = searchKey;
if (type == 1) {
MainNetManager.get(getActivity())
.search(WordsTypeUtil.changeSimplified(searchKey),
WordsTypeUtil.changeTraditional(searchKey),
type, page, new HttpCallback<List<List<SearchModel>>>() {
@Override
public void onSuccess(List<List<SearchModel>> data) {
Collections.reverse(data);
itemAdapter.showData(data, type);
loading.setVisibility(View.GONE);
}
@Override
public void onError(String error) {
loading.setVisibility(View.GONE);
ToastUtil.show(error);
}
});
} else {
MainNetManager.get(getActivity())
.searchNew(WordsTypeUtil.changeSimplified(searchKey),
WordsTypeUtil.changeTraditional(searchKey),
type, page, new HttpCallback<List<SearchModel>>() {
@Override
public void onSuccess(List<SearchModel> data) {
List<List<SearchModel>> listList = new ArrayList<>();
listList.add(data);
itemAdapter.showData(listList, type);
loading.setVisibility(View.GONE);
}
@Override
public void onError(String error) {
loading.setVisibility(View.GONE);
ToastUtil.show(error);
}
});
}
}
public enum SearchResultsType {
ALL(1, "全部"),
ANCHOR(2, "主播"),
USER(3, "用戶");
private int type;
private String name;
SearchResultsType(int type, String name) {
this.type = type;
this.name = name;
}
public int getType() {
return type;
}
public SearchResultsType setType(int type) {
this.type = type;
return this;
}
public String getName() {
return name;
}
public SearchResultsType setName(String name) {
this.name = name;
return this;
}
}
public static SearchResultsItemFragment newInstance(String searchKey,int type){
SearchResultsItemFragment searchRecommendFragment = new SearchResultsItemFragment();
Bundle bundle = new Bundle();
bundle.putString("searchKey", searchKey);
bundle.putInt("type", type);
searchRecommendFragment.setArguments(bundle);
return searchRecommendFragment;
}
}

View File

@ -318,6 +318,17 @@ public class MainHttpUtil {
.params("p", p) .params("p", p)
.execute(callback); .execute(callback);
} }
/**
* 搜索
*/
public static void searchnew(String fan_key, String jian_key,int type, int p, HttpCallback callback) {
HttpClient.getInstance().get("", MainHttpConsts.SEARCH)
.params("jian_key", jian_key)
.params("fan_key", fan_key)
.params("type", type)
.params("p", p)
.execute(callback);
}
/** /**
* 获取我的拉黑列表 * 获取我的拉黑列表

View File

@ -0,0 +1,36 @@
package com.yunbao.main.utils;
import java.io.IOException;
import taobe.tec.jcc.JChineseConvertor;
/**
* 繁體簡體轉換類
*/
public class WordsTypeUtil {
//繁体转成简体
public static String changeSimplified(String changeText) {
try {
JChineseConvertor jChineseConvertor = JChineseConvertor
.getInstance();
changeText = jChineseConvertor.t2s(changeText);
} catch (IOException e) {
e.printStackTrace();
}
return changeText;
}
//简体转繁体
public static String changeTraditional(String changeText) {
try {
JChineseConvertor jChineseConvertor = JChineseConvertor
.getInstance();
changeText = jChineseConvertor.s2t(changeText);
} catch (IOException e) {
e.printStackTrace();
}
return changeText;
}
}

View File

@ -0,0 +1,51 @@
package com.yunbao.main.views;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.yunbao.common.bean.SearchModel;
import com.yunbao.common.utils.Bus;
import com.yunbao.main.R;
import com.yunbao.main.adapter.SearchResultsAdapter;
import com.yunbao.main.event.AnchorSearchEvent;
import java.util.List;
/**
* 主播列表頁面
*/
public class AnchorSearchResultsItemViewHolder extends RecyclerView.ViewHolder {
private RecyclerView anchorList;
private TextView anchorMore;
private SearchResultsAdapter resultsAdapter;
private FrameLayout typeTitle;
public AnchorSearchResultsItemViewHolder(@NonNull View itemView) {
super(itemView);
anchorList = itemView.findViewById(R.id.anchor_list);
anchorMore = itemView.findViewById(R.id.anchor_more);
typeTitle = itemView.findViewById(R.id.type_title);
anchorMore.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Bus.get().post(new AnchorSearchEvent().setJumpType(1));
}
});
}
public void showAnchors(List<SearchModel> searchModels, int type) {
resultsAdapter = new SearchResultsAdapter();
anchorList.setLayoutManager(new LinearLayoutManager(itemView.getContext(), LinearLayoutManager.VERTICAL, true));
anchorList.setAdapter(resultsAdapter);
resultsAdapter.putData(searchModels, type);
}
public void hideTypeTitle(){
typeTitle.setVisibility(View.GONE);
}
}

View File

@ -0,0 +1,52 @@
package com.yunbao.main.views;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Path;
import android.util.AttributeSet;
import android.widget.ImageView;
/**
* 圓形圖片
*/
public class ClipPathCircleImage extends ImageView {
private int width;
private int height;
private Path path;
public ClipPathCircleImage(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
path = new Path();
}
@Override
protected void onDraw(Canvas canvas) {
canvas.save();
path.reset();
path.addCircle(width / 2, height / 2, width / 2, Path.Direction.CCW);//CCW:逆时针,这里是一个简单的园,无影响
canvas.clipPath(path);
super.onDraw(canvas);
canvas.restore();
//使用Path时如果不与Paint进行共同操作无法解决抗锯齿问题
//这时候只能使用Paint的PorterDuff.Mode替代Path实现所需要的效果
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
width = w;
height = h;
}
public ClipPathCircleImage(Context context, AttributeSet attrs, int defStyleAttr) {
this(context, attrs, defStyleAttr, 0);
}
public ClipPathCircleImage(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public ClipPathCircleImage(Context context) {
this(context, null);
}
}

View File

@ -0,0 +1,128 @@
package com.yunbao.main.views;
import android.content.Context;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import java.util.HashMap;
import java.util.Map;
/**
* 流式佈局
*/
public class FlowLayout extends ViewGroup {
public FlowLayout(Context context) {
super(context);
}
public FlowLayout(Context context, AttributeSet attrs) {
super(context, attrs);
}
public FlowLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
// super.onMeasure(widthMeasureSpec, heightMeasureSpec);
//遍历去调用所有子元素的measure方法child.getMeasuredHeight()才能获取到值否则为0
measureChildren(widthMeasureSpec, heightMeasureSpec);
int measuredWidth = 0, measuredHeight = 0;
int widthSize = MeasureSpec.getSize(widthMeasureSpec);
int widtMode = MeasureSpec.getMode(widthMeasureSpec);
int heightMode = MeasureSpec.getMode(heightMeasureSpec);
int heightSize = MeasureSpec.getSize(heightMeasureSpec);
//由于计算子view所占宽度这里传值需要自身减去PaddingRight宽度PaddingLeft会在接下来计算子元素位置时加上
Map<String, Integer> compute = compute(widthSize - getPaddingRight());
//EXACTLY模式对应于给定大小或者match_parent情况
if (widtMode == MeasureSpec.EXACTLY) {
measuredWidth = widthSize;
//AT_MOS模式对应wrap-content需要手动计算大小否则相当于match_parent
} else if (widtMode == MeasureSpec.AT_MOST) {
measuredWidth = compute.get("allChildWidth");
}
if (heightMode == MeasureSpec.EXACTLY) {
measuredHeight = heightSize;
} else if (heightMode == MeasureSpec.AT_MOST) {
measuredHeight = compute.get("allChildHeight");
}
//设置flow的宽高
setMeasuredDimension(measuredWidth, measuredHeight);
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
for (int i = 0; i < getChildCount(); i++) {
View child = getChildAt(i);
Rect rect = (Rect) getChildAt(i).getTag();
child.layout(rect.left, rect.top, rect.right, rect.bottom);
}
}
/**
* 测量过程
*
* @param flowWidth 该view的宽度
* @return 返回子元素总所占宽度和高度用于计算Flowlayout的AT_MOST模式设置宽高
*/
private Map<String, Integer> compute(int flowWidth) {
//是否是单行
boolean aRow = true;
MarginLayoutParams marginParams;//子元素margin
int rowsWidth = getPaddingLeft();//当前行已占宽度(注意需要加上paddingLeft)
int columnHeight = getPaddingTop();//当前行顶部已占高度(注意需要加上paddingTop)
int rowsMaxHeight = 0;//当前行所有子元素的最大高度用于换行累加高度
for (int i = 0; i < getChildCount(); i++) {
View child = getChildAt(i);
//获取元素测量宽度和高度
int measuredWidth = child.getMeasuredWidth();
int measuredHeight = child.getMeasuredHeight();
//获取元素的margin
marginParams = (MarginLayoutParams) child.getLayoutParams();
//子元素所占宽度 = MarginLeft+ child.getMeasuredWidth+MarginRight 注意此时不能child.getWidth,因为界面没有绘制完成此时wdith为0
int childWidth = marginParams.leftMargin + marginParams.rightMargin + measuredWidth;
int childHeight = marginParams.topMargin + marginParams.bottomMargin + measuredHeight;
//判断是否换行 该行已占大小+该元素大小>父容器宽度 则换行
rowsMaxHeight = Math.max(rowsMaxHeight, childHeight);
//换行
if (rowsWidth + childWidth > flowWidth) {
//重置行宽度
rowsWidth = getPaddingLeft() + getPaddingRight();
//累加上该行子元素最大高度
columnHeight += rowsMaxHeight;
//重置该行最大高度
rowsMaxHeight = childHeight;
aRow = false;
}
//累加上该行子元素宽度
rowsWidth += childWidth;
//判断时占的宽段时加上margin计算设置顶点位置时不包括margin位置不然margin会不起作用这是给View设置tag,在onlayout给子元素设置位置再遍历取出
child.setTag(new Rect(rowsWidth - childWidth + marginParams.leftMargin, columnHeight + marginParams.topMargin, rowsWidth - marginParams.rightMargin, columnHeight + childHeight - marginParams.bottomMargin));
}
//返回子元素总所占宽度和高度用于计算Flowlayout的AT_MOST模式设置宽高
Map<String, Integer> flowMap = new HashMap<>();
//单行
if (aRow) {
flowMap.put("allChildWidth", rowsWidth);
} else {
//多行
flowMap.put("allChildWidth", flowWidth);
}
//FlowLayout测量高度 = 当前行顶部已占高度 +当前行内子元素最大高度+FlowLayout的PaddingBottom
flowMap.put("allChildHeight", columnHeight + rowsMaxHeight + getPaddingBottom());
return flowMap;
}
}

View File

@ -0,0 +1,15 @@
package com.yunbao.main.views;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
/**
* 搜索推荐页头部搜索历史信息
*/
public class SearchRecommendBodyViewHolder extends RecyclerView.ViewHolder {
public SearchRecommendBodyViewHolder(@NonNull View itemView) {
super(itemView);
}
}

View File

@ -0,0 +1,54 @@
package com.yunbao.main.views;
import android.graphics.Color;
import android.util.TypedValue;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.yunbao.main.R;
import java.util.Map;
/**
* 搜索推荐页头部搜索历史信息
*/
public class SearchRecommendHeardViewHolder extends RecyclerView.ViewHolder {
private ImageView searchDel;
private FlowLayout searchHistory;
public SearchRecommendHeardViewHolder(@NonNull View itemView) {
super(itemView);
searchDel = itemView.findViewById(R.id.search_del);
searchHistory = itemView.findViewById(R.id.search_history);
}
/**
* 展示搜索歷史
*/
public void setHistory(Map<String, String> historyMap) {
LinearLayout.LayoutParams layoutParams =
new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
layoutParams.setMargins(17, 10, 0, 10);
int i = 0;
for (String key : historyMap.keySet()) {
i = i + 1;
TextView chip = new TextView(itemView.getContext());
chip.setText(key);
chip.setMaxEms(10);
chip.setTextColor(Color.parseColor("#FF999999"));
chip.setTextSize(TypedValue.COMPLEX_UNIT_SP, 15);
chip.setSingleLine();
chip.setBackgroundResource(R.drawable.background_search_chip);
chip.setLayoutParams(layoutParams);
searchHistory.addView(chip, layoutParams);
}
}
}

View File

@ -0,0 +1,56 @@
package com.yunbao.main.views;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.bean.LevelBean;
import com.yunbao.common.bean.SearchModel;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.main.R;
public class SearchResultsViewHolder extends RecyclerView.ViewHolder {
private ImageView avatar, isLive, sex, focusOn, contribute;
private TextView nickName;
public SearchResultsViewHolder(@NonNull View itemView) {
super(itemView);
avatar = itemView.findViewById(R.id.avatar);
isLive = itemView.findViewById(R.id.is_live);
sex = itemView.findViewById(R.id.sex);
focusOn = itemView.findViewById(R.id.focus_on);
nickName = itemView.findViewById(R.id.nick_name);
contribute = itemView.findViewById(R.id.contribute);
}
public void showData(SearchModel model, int type) {
ImgLoader.displayAvatar(itemView.getContext(), model.getAvatar(), avatar);
//用戶直接隱藏
if (type == 3) {
LevelBean levelBean = CommonAppConfig.getInstance().getLevel(Integer.parseInt(model.getLevel()));
if (levelBean != null) {
ImgLoader.display(itemView.getContext(), levelBean.getThumb(), contribute);
}
isLive.setVisibility(View.GONE);
} else {
LevelBean anchorLevelBean = CommonAppConfig.getInstance().getAnchorLevel(Integer.parseInt(model.getLevelAnchor()));
if (anchorLevelBean != null) {
ImgLoader.display(isLive.getContext(), CommonAppConfig.getInstance().HOST + anchorLevelBean.getThumb(), contribute);
}
isLive.setVisibility(model.getIslive() == 0 ? View.VISIBLE : View.GONE);
}
if (model.getSex() == 2) {
ImgLoader.displayAvatar(itemView.getContext(), R.mipmap.icon_sex_female_1, sex);
} else {
ImgLoader.displayAvatar(itemView.getContext(), R.mipmap.icon_sex_male_1, sex);
}
nickName.setText(model.getUserNicename());
focusOn.setVisibility(TextUtils.equals(model.getIsattention(), "1") ? View.GONE : View.VISIBLE);
}
}

View File

@ -0,0 +1,52 @@
package com.yunbao.main.views;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.yunbao.common.bean.SearchModel;
import com.yunbao.common.utils.Bus;
import com.yunbao.main.R;
import com.yunbao.main.adapter.SearchResultsAdapter;
import com.yunbao.main.event.AnchorSearchEvent;
import java.util.List;
/**
* 用戶展示列表頁面
*/
public class UserSearchResultsItemViewHolder extends RecyclerView.ViewHolder {
private RecyclerView anchorList;
private TextView anchorMore;
private SearchResultsAdapter resultsAdapter;
private FrameLayout typeTitle;
public UserSearchResultsItemViewHolder(@NonNull View itemView) {
super(itemView);
anchorList = itemView.findViewById(R.id.anchor_list);
anchorMore = itemView.findViewById(R.id.anchor_more);
typeTitle = itemView.findViewById(R.id.type_title);
anchorMore.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Bus.get().post(new AnchorSearchEvent().setJumpType(2));
}
});
}
public void showAnchors(List<SearchModel> searchModels, int type) {
resultsAdapter = new SearchResultsAdapter();
anchorList.setLayoutManager(new LinearLayoutManager(itemView.getContext(), LinearLayoutManager.VERTICAL, true));
anchorList.setAdapter(resultsAdapter);
resultsAdapter.putData(searchModels, type);
//滾動到頂部
anchorList.smoothScrollToPosition(0);
}
public void hideTypeTitle(){
typeTitle.setVisibility(View.GONE);
}
}

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<corners android:radius="12dp" />
<solid android:color="#FFF6F6F6" />
<padding android:bottom="7dp" android:left="11dp" android:right="11dp" android:top="7dp" />
</shape>
</item>
</selector>

View File

@ -0,0 +1,9 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:gravity="center_horizontal">
<shape>
<corners android:radius="5dp" />
<size android:width="20dp"
android:height="4dp"/>
</shape>
</item>
</layer-list>

View File

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <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_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/white" android:background="@color/white"
android:orientation="vertical"> android:orientation="vertical"
android:paddingTop="17dp">
<FrameLayout <FrameLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -16,14 +16,14 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="horizontal" android:orientation="horizontal"
android:paddingLeft="10dp" android:paddingLeft="15dp"
android:paddingRight="10dp"> android:paddingRight="10dp">
<LinearLayout <LinearLayout
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="30dp" android:layout_height="30dp"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_marginRight="10dp" android:layout_marginRight="15dp"
android:layout_weight="1" android:layout_weight="1"
android:background="@drawable/bg_search_input_2" android:background="@drawable/bg_search_input_2"
android:orientation="horizontal"> android:orientation="horizontal">
@ -33,7 +33,7 @@
android:layout_height="20dp" android:layout_height="20dp"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp" android:layout_marginLeft="10dp"
android:src="@mipmap/icon_main_search" /> android:src="@mipmap/icon_searchbar" />
<EditText <EditText
android:id="@+id/edit" android:id="@+id/edit"
@ -58,75 +58,15 @@
android:gravity="center" android:gravity="center"
android:onClick="backClick" android:onClick="backClick"
android:text="@string/cancel" android:text="@string/cancel"
android:textColor="@color/gray1" android:textColor="#FF000000"
android:textSize="16sp" /> android:textSize="16sp" />
</LinearLayout> </LinearLayout>
</FrameLayout> </FrameLayout>
<FrameLayout
<LinearLayout android:id="@+id/context_layout"
android:id="@+id/search_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="match_parent" />
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginBottom="5dp"
android:text="搜索历史"
android:textColor="@color/black1"
android:textSize="16sp" />
<ImageView
android:id="@+id/search_del"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:background="@mipmap/search_del" />
</RelativeLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/list_record"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginBottom="10dp"
android:background="@color/color_white" />
</LinearLayout>
<LinearLayout
android:id="@+id/lt_search_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:visibility="gone">
<net.lucode.hackware.magicindicator.MagicIndicator
android:id="@+id/magic_indicator"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@color/color_white" />
<androidx.viewpager.widget.ViewPager
android:id="@+id/vp_content"
android:layout_width="match_parent"
android:layout_height="1dp" />
<com.yunbao.common.custom.CommonRefreshView
android:id="@+id/refreshView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="1dp"
android:layout_weight="1"
app:crv_itemCount="50"
app:crv_refreshEnable="false" />
</LinearLayout>
</LinearLayout> </LinearLayout>

View File

@ -0,0 +1,48 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="20dp"
android:layout_marginRight="20dp"
android:orientation="vertical">
<FrameLayout
android:id="@+id/type_title"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:background="@mipmap/icon_zhubo" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="@string/anchor" />
</LinearLayout>
<TextView
android:id="@+id/anchor_more"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|right"
android:drawableRight="@mipmap/icon_more"
android:drawablePadding="5dp"
android:text="@string/anchor_more" />
</FrameLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/anchor_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp" />
</LinearLayout>

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/search_recommend_list"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="11dp">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/live_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="24dp" />
</LinearLayout>

View File

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="11dp">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="@string/search_history"
android:layout_marginLeft="10dp"
android:textColor="#FF000000"
android:textSize="16sp" />
<ImageView
android:id="@+id/search_del"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="end"
android:src="@mipmap/search_del" />
</FrameLayout>
<com.yunbao.main.views.FlowLayout
android:id="@+id/search_history"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:padding="5dp" />
</LinearLayout>

View File

@ -0,0 +1,49 @@
<?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:background="@color/white"
android:orientation="vertical">
<com.google.android.material.tabs.TabLayout
android:id="@+id/search_type"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:background="@color/white"
app:tabGravity="center"
app:tabIndicator="@drawable/tablayout_indicator_bg"
app:tabIndicatorColor="#FFFF8D41"
app:tabIndicatorHeight="4dp"
app:tabMode="fixed"
app:tabPaddingEnd="20dp"
app:tabPaddingStart="20dp"
app:tabSelectedTextColor="#FFFF8D41"
app:tabTextAppearance="@style/TabLayoutTextStyle"
app:tabTextColor="#FF000000">
<com.google.android.material.tabs.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/all" />
<com.google.android.material.tabs.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/anchor" />
<com.google.android.material.tabs.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/user" />
</com.google.android.material.tabs.TabLayout>
<androidx.viewpager.widget.ViewPager
android:id="@+id/context_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>

View File

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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:orientation="vertical">
<LinearLayout
android:id="@+id/loading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="100dp"
android:layout_gravity="center"
android:orientation="vertical"
android:gravity="center"
android:visibility="gone">
<com.wang.avi.AVLoadingIndicatorView
android:id="@+id/avi"
style="@style/AVLoadingIndicatorView"
android:layout_width="60dp"
android:layout_height="60dp"
android:visibility="visible"
app:indicatorColor="@color/blue_337cf5"
app:indicatorName="LineScaleIndicator" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/refresh_header_loading"
android:textColor="@color/black3" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/search_list"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</FrameLayout>

View File

@ -0,0 +1,71 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="65dp"
android:orientation="horizontal"
android:paddingTop="10dp">
<RelativeLayout
android:layout_width="60dp"
android:layout_height="60dp">
<com.yunbao.main.views.ClipPathCircleImage
android:id="@+id/avatar"
android:layout_width="55dp"
android:layout_height="55dp" />
<ImageView
android:id="@+id/is_live"
android:layout_width="55dp"
android:layout_height="25dp"
android:layout_alignParentBottom="true"
android:src="@mipmap/icon_user_home_living" />
</RelativeLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginLeft="19dp"
android:orientation="vertical">
<TextView
android:id="@+id/nick_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/anchor_more"
android:textColor="#FF161616"
android:textSize="14sp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:gravity="bottom">
<ImageView
android:id="@+id/sex"
android:layout_width="19dp"
android:layout_height="19dp"
android:src="@mipmap/icon_sex_female_1" />
<ImageView
android:id="@+id/contribute"
android:layout_width="55dp"
android:layout_height="20dp" />
</LinearLayout>
</LinearLayout>
<View
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_weight="1" />
<ImageView
android:id="@+id/focus_on"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:src="@mipmap/btn_add" />
</LinearLayout>

View File

@ -0,0 +1,48 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:orientation="vertical">
<FrameLayout
android:id="@+id/type_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:background="@mipmap/icon_yongh" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="@string/user" />
</LinearLayout>
<TextView
android:id="@+id/anchor_more"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|right"
android:drawableRight="@mipmap/icon_more"
android:drawablePadding="5dp"
android:text="@string/anchor_more" />
</FrameLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/anchor_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp" />
</LinearLayout>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 724 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View File

@ -18,4 +18,10 @@
    <item name="android:taskToBackEnterAnimation">@null</item>     <item name="android:taskToBackEnterAnimation">@null</item>
    <item name="android:taskToBackExitAnimation">@null</item>     <item name="android:taskToBackExitAnimation">@null</item>
  </style>   </style>
<style name="CAppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:colorBackground">@color/background</item>
</style>
</resources> </resources>