diff --git a/app/src/main/java/com/gh/gamecenter/qa/AskFragment.kt b/app/src/main/java/com/gh/gamecenter/qa/AskFragment.kt index 528dc64c9f..62488c2903 100644 --- a/app/src/main/java/com/gh/gamecenter/qa/AskFragment.kt +++ b/app/src/main/java/com/gh/gamecenter/qa/AskFragment.kt @@ -1,5 +1,6 @@ package com.gh.gamecenter.qa +import android.annotation.SuppressLint import android.app.Activity import android.app.Dialog import android.arch.lifecycle.Observer @@ -23,6 +24,7 @@ import com.gh.base.adapter.FragmentAdapter import com.gh.base.fragment.BaseFragment import com.gh.base.onDoubleTapListener import com.gh.common.util.MtaHelper +import com.gh.common.util.addOnPageChangeListener import com.gh.gamecenter.MainActivity import com.gh.gamecenter.R import com.gh.gamecenter.entity.ResultEntity @@ -33,6 +35,7 @@ import com.gh.gamecenter.qa.column.AskColumnFragment import com.gh.gamecenter.qa.column.AskColumnViewModel import com.gh.gamecenter.qa.follow.AskFollowFragment import com.gh.gamecenter.qa.newest.AskQuestionsNewFragment +import com.gh.gamecenter.qa.questions.edit.QuestionEditActivity import com.gh.gamecenter.qa.recommends.AskRecommendWrapperFragment import com.gh.gamecenter.qa.search.AskSearchActivity import com.gh.gamecenter.qa.select.CommunitiesSelectActivity @@ -52,20 +55,17 @@ class AskFragment : BaseFragment() { const val INDEX_QUESTIONS = 3 // communities const val COMMUNITIES_SELECT_REQUEST = 103 - const val SP_KEY_CLICKED_SELECT_GAME = "has_clicked_select_game" - const val EB_SELECT_KEY = "EB_SELECT_KEY" const val EB_RETRY_PAGE = "EB_RETRY_PAGE" - const val EB_HIDE_FOLLOW_HINT = "EB_HIDE_FOLLOW_HINT" - const val SCROLL_RECOMMEND_TO_TOP = "SCROLL_RECOMMEND_TO_TOP" + const val SP_KEY_CLICKED_SELECT_GAME = "has_clicked_select_game" } - @BindView(R.id.ask_selectgame) - lateinit var mAskSelectgame: ImageView - @BindView(R.id.ask_gamename) - lateinit var mAskGamename: TextView + @BindView(R.id.ask_select_community) + lateinit var mAskSelectCommunity: ImageView + @BindView(R.id.ask_community_name) + lateinit var mAskCommunityName: TextView @BindView(R.id.ask_search) lateinit var mAskSearch: ImageView @BindView(R.id.ask_follow) @@ -92,6 +92,8 @@ class AskFragment : BaseFragment() { lateinit var mColumnLine: View @BindView(R.id.follow_hint) lateinit var mFollowHint: View + @BindView(R.id.ask_put_questions) + lateinit var mPutQuestions: View private lateinit var mRecommendsFragment: AskRecommendWrapperFragment @@ -137,10 +139,10 @@ class AskFragment : BaseFragment() { || TextUtils.isEmpty(UserManager.getInstance().community.id)) { showCommunitySelectFragment() } else { - mAskGamename.text = UserManager.getInstance().community.name + mAskCommunityName.text = UserManager.getInstance().community.name showAvailableInfo() initViewPager() - setTabbarPosition(INDEX_HOT) + setTabBarPosition(INDEX_HOT) if (mOpenedFragment != null) hideCommunitySelectFragmentAndShowCommunityWithHint() @@ -159,7 +161,7 @@ class AskFragment : BaseFragment() { if ((it == null || it.isEmpty()) && mAskColumn.visibility == View.VISIBLE) { mAskColumn.visibility = View.GONE mColumnLine.visibility = View.GONE - if (mAskColumn.isChecked) setTabbarPosition(INDEX_HOT) + if (mAskColumn.isChecked) setTabBarPosition(INDEX_HOT) } else if (it != null && !it.isEmpty() && mAskColumn.visibility == View.GONE) { mAskColumn.visibility = View.VISIBLE mColumnLine.visibility = View.VISIBLE @@ -187,25 +189,26 @@ class AskFragment : BaseFragment() { // 社区没有被隐藏,正常显示社区信息 private fun showAvailableInfo() { - mAskGamename.text = UserManager.getInstance().community.name + mAskCommunityName.text = UserManager.getInstance().community.name mAskSearch.visibility = View.VISIBLE mAskTabBar.visibility = View.VISIBLE mAskViewpager.visibility = View.VISIBLE - mAskSelectgame.visibility = View.VISIBLE + mAskSelectCommunity.visibility = View.VISIBLE mCommunitiesSelectLayout.visibility = View.GONE mLoading.visibility = View.GONE } - @OnClick(R.id.ask_selectgame, + @OnClick(R.id.ask_select_community, R.id.ask_search, R.id.ask_hot, R.id.ask_follow, R.id.ask_questions, R.id.ask_column, - R.id.reuse_no_connection) + R.id.reuse_no_connection, + R.id.ask_put_questions) fun onViewClicked(view: View) { when (view.id) { - R.id.ask_selectgame -> { + R.id.ask_select_community -> { if (!mHasClickedSelectGame) { mHasClickedSelectGame = true sp.edit().putBoolean(SP_KEY_CLICKED_SELECT_GAME, mHasClickedSelectGame).apply() @@ -223,7 +226,7 @@ class AskFragment : BaseFragment() { startActivity(AskSearchActivity.getIntent(context, "(首页-问答)")) } R.id.ask_follow -> { - setTabbarPosition(INDEX_FOLLOW) + setTabBarPosition(INDEX_FOLLOW) // 关注 tab 存在未读红点,刷新一下 val isRefreshing = mAskFollowFragment.load() if (mFollowHint.visibility == View.VISIBLE && @@ -233,24 +236,28 @@ class AskFragment : BaseFragment() { MtaHelper.onEvent("问答页面", UserManager.getInstance().community.name, "关注Tab") } R.id.ask_hot -> { - setTabbarPosition(INDEX_HOT) + setTabBarPosition(INDEX_HOT) MtaHelper.onEvent("问答页面", UserManager.getInstance().community.name, "推荐Tab") } R.id.ask_questions -> { - setTabbarPosition(INDEX_QUESTIONS) + setTabBarPosition(INDEX_QUESTIONS) MtaHelper.onEvent("问答页面", UserManager.getInstance().community.name, "问题Tab") } R.id.ask_column -> { - setTabbarPosition(INDEX_COLUMN) + setTabBarPosition(INDEX_COLUMN) MtaHelper.onEvent("问答页面", UserManager.getInstance().community.name, "专栏Tab") } R.id.reuse_no_connection -> { mNoConn.visibility = View.GONE mLoading.visibility = View.VISIBLE } + R.id.ask_put_questions -> { + startActivity(QuestionEditActivity.getIntent(context!!)) + } } } + @SuppressLint("ClickableViewAccessibility") private fun initViewPager() { val fragmentList = ArrayList() mRecommendsFragment = AskRecommendWrapperFragment() @@ -262,7 +269,15 @@ class AskFragment : BaseFragment() { mAskViewpager.setScrollable(false) mAskViewpager.offscreenPageLimit = fragmentList.size - mAskGamename.setOnTouchListener(object : onDoubleTapListener(context) { + mAskViewpager.addOnPageChangeListener(onSelected = { + mPutQuestions.visibility = if (fragmentList[it] is AskColumnFragment) { + View.GONE + } else { + View.VISIBLE + } + }) + + mAskCommunityName.setOnTouchListener(object : onDoubleTapListener(context) { override fun onDoubleTap() { when (mAskViewpager.currentItem) { INDEX_FOLLOW -> { @@ -275,7 +290,7 @@ class AskFragment : BaseFragment() { }) } - private fun setTabbarPosition(index: Int) { + private fun setTabBarPosition(index: Int) { when (index) { INDEX_FOLLOW -> { mAskFollow.isChecked = true @@ -333,9 +348,10 @@ class AskFragment : BaseFragment() { } private fun showCommunitySelectFragment() { - mAskSelectgame.visibility = View.INVISIBLE + mPutQuestions.visibility = View.GONE + mAskSelectCommunity.visibility = View.INVISIBLE mAskSearch.visibility = View.INVISIBLE - mAskGamename.text = "选择游戏" + mAskCommunityName.text = "选择游戏" mAskTabBar.visibility = View.GONE mLoading.visibility = View.GONE mCommunitiesSelectLayout.visibility = View.VISIBLE diff --git a/app/src/main/java/com/gh/gamecenter/qa/entity/CommunityHotSearch.kt b/app/src/main/java/com/gh/gamecenter/qa/entity/CommunityHotSearch.kt new file mode 100644 index 0000000000..258c6238cd --- /dev/null +++ b/app/src/main/java/com/gh/gamecenter/qa/entity/CommunityHotSearch.kt @@ -0,0 +1,5 @@ +package com.gh.gamecenter.qa.entity + +class CommunityHotSearch(val title: String, + val introduction: String, + val keyword: String) \ No newline at end of file diff --git a/app/src/main/java/com/gh/gamecenter/qa/search/AskSearchActivity.java b/app/src/main/java/com/gh/gamecenter/qa/search/AskSearchActivity.java index a6b20cbcd8..3e1937cfd1 100644 --- a/app/src/main/java/com/gh/gamecenter/qa/search/AskSearchActivity.java +++ b/app/src/main/java/com/gh/gamecenter/qa/search/AskSearchActivity.java @@ -5,6 +5,7 @@ import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.os.Message; +import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentTransaction; import android.text.Editable; @@ -27,16 +28,22 @@ import com.gh.gamecenter.eventbus.EBSearch; import com.gh.gamecenter.manager.UserManager; import com.gh.gamecenter.qa.questions.edit.QuestionEditActivity; import com.gh.gamecenter.qa.search.history.HistoryFragment; +import com.gh.gamecenter.retrofit.Response; +import com.gh.gamecenter.retrofit.RetrofitManager; import com.lightgame.utils.Util_System_Keyboard; import com.lightgame.utils.Utils; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; +import org.json.JSONArray; import java.util.List; import butterknife.BindView; import butterknife.OnClick; +import io.reactivex.android.schedulers.AndroidSchedulers; +import io.reactivex.schedulers.Schedulers; +import okhttp3.ResponseBody; /** * Created by khy on 8/12/17. @@ -46,7 +53,7 @@ public class AskSearchActivity extends BaseActivity { private static final int POST_SEARCH_WHAT = 2; private static final int QUESTION_REQUEST_CODE = 2; - private static final String ASK_SEARCH_EB_TYPE = "askHistory"; + public static final String ASK_SEARCH_EB_TYPE = "invoke_search"; @BindView(R.id.bar_search_edit) EditText mSearchEt; @@ -63,9 +70,9 @@ public class AskSearchActivity extends BaseActivity { private String mSearchKey; private String mPostedKey; - private String mColumnId; private String mQuestionTag; + private String mDefaultSearchKey; public static Intent getIntent(Context context, String entrance) { Intent intent = new Intent(context, AskSearchActivity.class); @@ -125,6 +132,7 @@ public class AskSearchActivity extends BaseActivity { } } + getCommunityDefaultSearch(); changeFragment(); mSearchEt.setOnEditorActionListener((v, actionId, event) -> { @@ -176,28 +184,44 @@ public class AskSearchActivity extends BaseActivity { startActivityForResult(QuestionEditActivity.Companion.getIntent(this, mSearchKey), QUESTION_REQUEST_CODE); }); } else if (v.getId() == R.id.bar_question_btn) { - if (!TextUtils.isEmpty(mColumnId) || !TextUtils.isEmpty(mQuestionTag)) { - search(); - mDao.add(mSearchKey, UserManager.getInstance().getCommunity().getId()); - Util_System_Keyboard.hideSoftKeyboard(this, mSearchEt); - } else { - String entrance; - if (!TextUtils.isEmpty(mColumnId)) { - entrance = "专栏详情-搜索-点我提问"; - } else if (!TextUtils.isEmpty(mQuestionTag)) { - entrance = "问题标签详情-搜索-点我提问"; - } else { - entrance = "问答-搜索-点我提问"; + String key = mSearchEt.getText().toString().trim(); + if (TextUtils.isEmpty(key)) { + if (!TextUtils.isEmpty(mDefaultSearchKey)) { + mSearchEt.setText(mDefaultSearchKey); + mDao.add(mDefaultSearchKey, UserManager.getInstance().getCommunity().getId()); + Util_System_Keyboard.hideSoftKeyboard(this, mSearchEt); } - CheckLoginUtils.checkLogin(this, entrance, () -> { - startActivityForResult(QuestionEditActivity.Companion.getIntent(this, mSearchKey), QUESTION_REQUEST_CODE); - }); + } else { + mDao.add(mSearchKey, UserManager.getInstance().getCommunity().getId()); } } else if (v.getId() == R.id.bar_back) { finish(); } } + private void getCommunityDefaultSearch() { + RetrofitManager + .getInstance(this) + .getApi() + .getCommunityDefaultSearch(UserManager.getInstance().getCommunity().getId()) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new Response() { + @Override + public void onResponse(@Nullable ResponseBody response) { + try { + JSONArray array = new JSONArray(response.string()); + if (array.length() > 0) { + mDefaultSearchKey = (String) array.get(0); + mSearchEt.setHint(mDefaultSearchKey); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + } + private void search() { if (mSearchKey == null) return; diff --git a/app/src/main/java/com/gh/gamecenter/qa/search/history/HistoryFragment.kt b/app/src/main/java/com/gh/gamecenter/qa/search/history/HistoryFragment.kt index 310cc6734d..1ee3a2e57b 100644 --- a/app/src/main/java/com/gh/gamecenter/qa/search/history/HistoryFragment.kt +++ b/app/src/main/java/com/gh/gamecenter/qa/search/history/HistoryFragment.kt @@ -1,5 +1,7 @@ package com.gh.gamecenter.qa.search.history +import android.arch.lifecycle.Observer +import android.arch.lifecycle.ViewModelProviders import android.os.Bundle import android.support.v7.widget.GridLayoutManager import android.support.v7.widget.RecyclerView @@ -14,20 +16,39 @@ import kotterknife.bindView class HistoryFragment : BaseFragment() { private val mRecyclerView by bindView(R.id.search_history_list) + private val mHotRecyclerView by bindView(R.id.search_hot_rv) private val mHistoryContainer by bindView(R.id.search_history_container) private val mCleanBtn by bindView(R.id.search_history_clean) + private val mHotContainer by bindView(R.id.search_hot_container) private var dao: AskSearchHistoryDao? = null private var mHistoryAdapter: HistoryFragmentAdapter? = null + private lateinit var mViewModel: HistoryViewModel + override fun getLayoutId(): Int { return R.layout.fragment_ask_search_history } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) + mViewModel = ViewModelProviders.of(this).get(HistoryViewModel::class.java) + mViewModel.hotSearchLiveData.observe(this, Observer { + if (it?.size!! > 0) { + mHotRecyclerView.adapter = HotFragmentAdapter(context!!, it) + mHotContainer.visibility = View.VISIBLE + } else { + mHotContainer.visibility = View.GONE + } + }) + dao = AskSearchHistoryDao(context) - mRecyclerView.layoutManager = object : GridLayoutManager(activity, 3) { + mRecyclerView.layoutManager = object : GridLayoutManager(activity, 2) { + override fun canScrollVertically(): Boolean { + return false + } + } + mHotRecyclerView.layoutManager = object : GridLayoutManager(activity, 2) { override fun canScrollVertically(): Boolean { return false } diff --git a/app/src/main/java/com/gh/gamecenter/qa/search/history/HistoryFragmentAdapter.kt b/app/src/main/java/com/gh/gamecenter/qa/search/history/HistoryFragmentAdapter.kt index 5a1c7d4b10..5e95418822 100644 --- a/app/src/main/java/com/gh/gamecenter/qa/search/history/HistoryFragmentAdapter.kt +++ b/app/src/main/java/com/gh/gamecenter/qa/search/history/HistoryFragmentAdapter.kt @@ -1,25 +1,20 @@ package com.gh.gamecenter.qa.search.history import android.content.Context -import android.support.v4.content.ContextCompat -import android.support.v7.widget.RecyclerView -import android.text.TextUtils -import android.view.Gravity -import android.view.View import android.view.ViewGroup -import android.widget.LinearLayout -import android.widget.TextView -import com.gh.common.util.DisplayUtils +import com.gh.base.BaseRecyclerViewHolder import com.gh.gamecenter.R +import com.gh.gamecenter.databinding.CommunitySearchHistoryItemBinding import com.gh.gamecenter.db.AskSearchHistoryDao import com.gh.gamecenter.eventbus.EBSearch import com.gh.gamecenter.manager.UserManager +import com.gh.gamecenter.qa.search.AskSearchActivity import com.lightgame.adapter.BaseRecyclerAdapter import com.lightgame.utils.Util_System_Keyboard import org.greenrobot.eventbus.EventBus class HistoryFragmentAdapter(context: Context, dao: AskSearchHistoryDao, historyEmptyCallback: () -> Unit) : - BaseRecyclerAdapter(context) { + BaseRecyclerAdapter(context) { private val mDao: AskSearchHistoryDao = dao @@ -31,39 +26,30 @@ class HistoryFragmentAdapter(context: Context, dao: AskSearchHistoryDao, history } } - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): TextViewHolder { - val textView = TextView(mContext) - textView.setSingleLine() - textView.ellipsize = TextUtils.TruncateAt.END - textView.textSize = 13f - textView.setPadding(DisplayUtils.dip2px(mContext, 10f), 0, DisplayUtils.dip2px(mContext, 10f), 0) - textView.layoutParams = LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, DisplayUtils.dip2px(mContext, 32f)) - textView.gravity = Gravity.CENTER_VERTICAL - textView.setBackgroundResource(R.drawable.reuse_listview_item_style) - return TextViewHolder(textView) + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): HistoryViewHolder { + val view = mLayoutInflater.inflate(R.layout.community_search_history_item, parent, false) + return HistoryViewHolder(CommunitySearchHistoryItemBinding.bind(view)) } override fun getItemCount(): Int { return mHistoryList.size } - override fun onBindViewHolder(holder: TextViewHolder, position: Int) { - holder.textView.text = mHistoryList[position] - holder.textView.setTextColor(ContextCompat.getColor(mContext, R.color.title)) + override fun onBindViewHolder(holder: HistoryViewHolder, position: Int) { + val key = mHistoryList[position] + holder.binding.key = key holder.itemView.setOnClickListener { v -> - val key = holder.textView.text.toString() mDao.add(key, UserManager.getInstance().community.id) - EventBus.getDefault().post(EBSearch("askHistory", key)) + EventBus.getDefault().post(EBSearch(AskSearchActivity.ASK_SEARCH_EB_TYPE, key)) Util_System_Keyboard.hideSoftKeyboardByIBinder(mContext, v.windowToken) } } - class TextViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { - val textView: TextView = itemView as TextView - } fun clearSearchResult() { mHistoryList.clear() notifyDataSetChanged() } + + class HistoryViewHolder(val binding: CommunitySearchHistoryItemBinding) : BaseRecyclerViewHolder(binding.root) } \ No newline at end of file diff --git a/app/src/main/java/com/gh/gamecenter/qa/search/history/HistoryViewModel.kt b/app/src/main/java/com/gh/gamecenter/qa/search/history/HistoryViewModel.kt new file mode 100644 index 0000000000..03bc441b07 --- /dev/null +++ b/app/src/main/java/com/gh/gamecenter/qa/search/history/HistoryViewModel.kt @@ -0,0 +1,32 @@ +package com.gh.gamecenter.qa.search.history + +import android.app.Application +import android.arch.lifecycle.AndroidViewModel +import android.arch.lifecycle.MutableLiveData +import com.gh.gamecenter.manager.UserManager +import com.gh.gamecenter.qa.entity.CommunityHotSearch +import com.gh.gamecenter.retrofit.Response +import com.gh.gamecenter.retrofit.RetrofitManager +import io.reactivex.android.schedulers.AndroidSchedulers +import io.reactivex.schedulers.Schedulers + +class HistoryViewModel(application: Application) : AndroidViewModel(application) { + + val hotSearchLiveData = MutableLiveData>() + + init { + getHotSearch() + } + + private fun getHotSearch() { + RetrofitManager.getInstance(getApplication()).api + .getCommunityHotSearch(UserManager.getInstance().community.id) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(object : Response>() { + override fun onResponse(response: List?) { + if (response != null) hotSearchLiveData.postValue(response) + } + }) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/gh/gamecenter/qa/search/history/HotFragmentAdapter.kt b/app/src/main/java/com/gh/gamecenter/qa/search/history/HotFragmentAdapter.kt new file mode 100644 index 0000000000..7e30a21de1 --- /dev/null +++ b/app/src/main/java/com/gh/gamecenter/qa/search/history/HotFragmentAdapter.kt @@ -0,0 +1,38 @@ +package com.gh.gamecenter.qa.search.history + +import android.content.Context +import android.view.ViewGroup +import com.gh.base.BaseRecyclerViewHolder +import com.gh.gamecenter.R +import com.gh.gamecenter.databinding.CommunitySearchHotItemBinding +import com.gh.gamecenter.eventbus.EBSearch +import com.gh.gamecenter.qa.entity.CommunityHotSearch +import com.gh.gamecenter.qa.search.AskSearchActivity +import com.lightgame.adapter.BaseRecyclerAdapter +import com.lightgame.utils.Util_System_Keyboard +import org.greenrobot.eventbus.EventBus + +class HotFragmentAdapter(context: Context, val list: List) + : BaseRecyclerAdapter(context) { + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): HotFragmentAdapter.HotViewHolder { + val view = mLayoutInflater.inflate(R.layout.community_search_hot_item, parent, false) + return HotViewHolder(CommunitySearchHotItemBinding.bind(view)) + } + + override fun getItemCount(): Int { + return list.size + } + + override fun onBindViewHolder(holder: HotFragmentAdapter.HotViewHolder, position: Int) { + val data = list[position] + holder.binding.setPosition(position + 1) + holder.binding.data = data + holder.itemView.setOnClickListener { v -> + EventBus.getDefault().post(EBSearch(AskSearchActivity.ASK_SEARCH_EB_TYPE, data.keyword)) + Util_System_Keyboard.hideSoftKeyboardByIBinder(mContext, v.windowToken) + } + } + + class HotViewHolder(val binding: CommunitySearchHotItemBinding) : BaseRecyclerViewHolder(binding.root) +} \ No newline at end of file diff --git a/app/src/main/java/com/gh/gamecenter/retrofit/service/ApiService.java b/app/src/main/java/com/gh/gamecenter/retrofit/service/ApiService.java index 7dd67614b5..76bb473278 100644 --- a/app/src/main/java/com/gh/gamecenter/retrofit/service/ApiService.java +++ b/app/src/main/java/com/gh/gamecenter/retrofit/service/ApiService.java @@ -49,6 +49,7 @@ import com.gh.gamecenter.qa.entity.AskGameSelectEntity; import com.gh.gamecenter.qa.entity.AskSearchEntity; import com.gh.gamecenter.qa.entity.AskSubjectEntity; import com.gh.gamecenter.qa.entity.AskTagGroupsEntity; +import com.gh.gamecenter.qa.entity.CommunityHotSearch; import com.gh.gamecenter.qa.entity.InviteEntity; import com.gh.gamecenter.qa.entity.QuestionHistoryDetailEntity; import com.gh.gamecenter.qa.entity.QuestionHistoryEntity; @@ -1518,4 +1519,16 @@ public interface ApiService { */ @GET("communities/{community_id}") Observable getCommunityDesc(@Path("community_id") String community_id); + + /** + * 获取社区默认搜索文案 + */ + @GET("communities/{community_id}/default_search") + Observable getCommunityDefaultSearch(@Path("community_id") String communityId); + + /** + * 获取默认社区们搜索文案 + */ + @GET("communities/{community_id}/hot_search") + Observable> getCommunityHotSearch(@Path("community_id") String communityId); } \ No newline at end of file diff --git a/app/src/main/res/drawable-xhdpi/community_search_history.png b/app/src/main/res/drawable-xhdpi/community_search_history.png new file mode 100644 index 0000000000..1085f9122b Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/community_search_history.png differ diff --git a/app/src/main/res/layout/ask_search_actionbar.xml b/app/src/main/res/layout/ask_search_actionbar.xml index c6a8079968..e87655f91a 100644 --- a/app/src/main/res/layout/ask_search_actionbar.xml +++ b/app/src/main/res/layout/ask_search_actionbar.xml @@ -58,7 +58,7 @@ android:layout_width = "@dimen/appbar_height" android:layout_height = "@dimen/appbar_height" android:gravity = "center" - android:text = "@string/ask_search_questions" + android:text = "@string/search_search" android:textColor = "@color/theme" android:textSize = "14sp" /> diff --git a/app/src/main/res/layout/community_search_history_item.xml b/app/src/main/res/layout/community_search_history_item.xml new file mode 100644 index 0000000000..2947d48e2d --- /dev/null +++ b/app/src/main/res/layout/community_search_history_item.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/community_search_hot_item.xml b/app/src/main/res/layout/community_search_hot_item.xml new file mode 100644 index 0000000000..defccf6268 --- /dev/null +++ b/app/src/main/res/layout/community_search_hot_item.xml @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/fragment_ask.xml b/app/src/main/res/layout/fragment_ask.xml index b993dd0c91..fbb44cca0a 100644 --- a/app/src/main/res/layout/fragment_ask.xml +++ b/app/src/main/res/layout/fragment_ask.xml @@ -12,7 +12,7 @@ android:background = "@android:color/white" > + app:layout_constraintTop_toTopOf = "@id/ask_select_community" + tools:text = "光环助手" /> + app:layout_constraintTop_toBottomOf = "@id/ask_select_community" > + android:layout_height = "match_parent" + android:layout_weight = "1" > + android:id = "@+id/follow_hint" + android:layout_width = "5dp" + android:layout_height = "5dp" + android:layout_marginTop = "6dp" + android:background = "@drawable/oval_message_hint_bg" + android:visibility = "gone" + app:layout_constraintHorizontal_bias = "0.69" + app:layout_constraintLeft_toLeftOf = "parent" + app:layout_constraintRight_toRightOf = "parent" + app:layout_constraintTop_toTopOf = "parent" + tools:visibility = "visible" /> - + + android:layout_marginTop = "@dimen/appbar_height" + android:background = "@color/background" /> + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_ask_search_history.xml b/app/src/main/res/layout/fragment_ask_search_history.xml index d692b495c9..c0364e5c73 100644 --- a/app/src/main/res/layout/fragment_ask_search_history.xml +++ b/app/src/main/res/layout/fragment_ask_search_history.xml @@ -5,10 +5,41 @@ android:orientation = "vertical" > + + + + + + + + @@ -16,25 +47,24 @@ android:id = "@+id/search_history_ll" android:layout_width = "match_parent" android:layout_height = "wrap_content" - android:gravity = "center_vertical" > + android:gravity = "center_vertical" + android:paddingLeft = "15dp" + android:paddingTop = "20dp" > + android:textColor = "@color/black" + android:textSize = "14sp" + android:textStyle = "bold" /> + android:gravity = "center" > - + android:paddingTop = "10dp" + android:paddingBottom = "5dp" /> \ No newline at end of file