编辑框增加插入游戏和插入回答页面
This commit is contained in:
@ -369,6 +369,14 @@
|
||||
android:name = "com.gh.gamecenter.qa.questions.edit.manager.HistoryActivity"
|
||||
android:screenOrientation = "portrait" />
|
||||
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.qa.editor.InsertAnswerWrapperActivity"
|
||||
android:screenOrientation = "portrait" />
|
||||
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.qa.editor.GameActivity"
|
||||
android:screenOrientation = "portrait" />
|
||||
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.qa.comment.CommentActivity"
|
||||
android:screenOrientation = "portrait"
|
||||
|
||||
@ -10,6 +10,8 @@ import android.webkit.JavascriptInterface
|
||||
import butterknife.OnClick
|
||||
import com.gh.common.view.RichEditor
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.qa.editor.GameActivity
|
||||
import com.gh.gamecenter.qa.editor.InsertAnswerWrapperActivity
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.utils.Utils
|
||||
import com.lightgame.view.CheckableImageView
|
||||
@ -48,7 +50,8 @@ abstract class BaseRichEditorActivity : BaseActivity() {
|
||||
R.id.editor_font_bold, R.id.editor_font_italic, R.id.editor_font_strikethrough,
|
||||
R.id.editor_paragraph_h1, R.id.editor_paragraph_h2, R.id.editor_paragraph_h3,
|
||||
R.id.editor_paragraph_h4, R.id.editor_font_container, R.id.editor_paragraph_container,
|
||||
R.id.editor_paragraph_quote)
|
||||
R.id.editor_paragraph_quote, R.id.editor_link_answer, R.id.editor_link_article,
|
||||
R.id.editor_link_game)
|
||||
fun onRichClick(view: View) {
|
||||
when (view.id) {
|
||||
R.id.editor_font -> {
|
||||
@ -130,6 +133,15 @@ abstract class BaseRichEditorActivity : BaseActivity() {
|
||||
}
|
||||
mEditorParagraphQuote.isChecked = !mEditorParagraphQuote.isChecked
|
||||
}
|
||||
R.id.editor_link_answer -> {
|
||||
startActivity(InsertAnswerWrapperActivity.getIntent(this))
|
||||
}
|
||||
R.id.editor_link_article -> {
|
||||
|
||||
}
|
||||
R.id.editor_link_game -> {
|
||||
startActivity(GameActivity.getIntent(this))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -121,7 +121,6 @@ public class DownloadProgressBar extends ProgressBar {
|
||||
|
||||
public void setText(@StringRes int res) {
|
||||
setText(getResources().getString(res));
|
||||
invalidate(); // 文字绘制没有同步 就重绘多几遍吧 虽然不知到有没有用
|
||||
}
|
||||
|
||||
public void setDownloadType(DownloadType downloadType) {
|
||||
|
||||
@ -0,0 +1,49 @@
|
||||
package com.gh.gamecenter.qa.editor
|
||||
|
||||
import android.content.Context
|
||||
import android.support.v7.widget.RecyclerView
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import com.gh.common.constant.ItemViewType
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.adapter.viewholder.FooterViewHolder
|
||||
import com.gh.gamecenter.baselist.ListAdapter
|
||||
import com.gh.gamecenter.qa.entity.AnswerEntity
|
||||
import com.gh.gamecenter.qa.questions.detail.AnswerViewHolder
|
||||
|
||||
class AnswerAdapter(context: Context, private val mEntrance: String?) : ListAdapter<AnswerEntity>(context) {
|
||||
|
||||
override fun getItemViewType(position: Int): Int {
|
||||
return if (position == itemCount - 1) ItemViewType.ITEM_FOOTER else ItemViewType.ITEM_BODY
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
|
||||
val view: View
|
||||
return when (viewType) {
|
||||
ItemViewType.ITEM_FOOTER -> {
|
||||
view = mLayoutInflater.inflate(R.layout.refresh_footerview, parent, false)
|
||||
FooterViewHolder(view)
|
||||
}
|
||||
ItemViewType.ITEM_BODY -> {
|
||||
view = mLayoutInflater.inflate(R.layout.ask_answer_item, parent, false)
|
||||
AnswerViewHolder(view)
|
||||
}
|
||||
else -> throw NullPointerException()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
|
||||
when (getItemViewType(position)) {
|
||||
ItemViewType.ITEM_BODY -> (holder as AnswerViewHolder).initCollectionAnswerViewHolder(mEntityList[position], mEntrance)
|
||||
ItemViewType.ITEM_FOOTER -> {
|
||||
val footerViewHolder = holder as FooterViewHolder
|
||||
footerViewHolder.initItemPadding()
|
||||
footerViewHolder.initFooterViewHolder(mIsLoading, mIsNetworkError, mIsOver, R.string.ask_loadover_hint)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
return if (mEntityList == null || mEntityList.isEmpty()) 0 else mEntityList.size + ListAdapter.FOOTER_ITEM_COUNT
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
package com.gh.gamecenter.qa.editor
|
||||
|
||||
import android.arch.lifecycle.ViewModelProviders
|
||||
import com.gh.gamecenter.baselist.ListFragment
|
||||
import com.gh.gamecenter.baselist.NormalListViewModel
|
||||
import com.gh.gamecenter.manager.UserManager
|
||||
import com.gh.gamecenter.qa.entity.AnswerEntity
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.halo.assistant.HaloApp
|
||||
import io.reactivex.Observable
|
||||
|
||||
class AnswerFragment : ListFragment<AnswerEntity, NormalListViewModel<AnswerEntity>>() {
|
||||
|
||||
private var mAdapter: AnswerAdapter? = null
|
||||
|
||||
override fun provideListAdapter(): AnswerAdapter {
|
||||
if (mAdapter == null) mAdapter = AnswerAdapter(context!!, mEntrance)
|
||||
return mAdapter!!
|
||||
}
|
||||
|
||||
override fun provideDataObservable(page: Int): Observable<List<AnswerEntity>>? {
|
||||
return RetrofitManager.getInstance(context).api.getCollectionAnswer(UserManager.getInstance().userId, page)
|
||||
}
|
||||
|
||||
override fun provideListViewModel(): NormalListViewModel<AnswerEntity> {
|
||||
val factory = NormalListViewModel.Factory(HaloApp.getInstance().application, this)
|
||||
return ViewModelProviders.of(this, factory).get(NormalListViewModel::class.java) as NormalListViewModel<AnswerEntity>
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,45 @@
|
||||
package com.gh.gamecenter.qa.editor
|
||||
|
||||
import android.arch.lifecycle.ViewModelProviders
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import com.gh.common.constant.Config
|
||||
import com.gh.gamecenter.baselist.ListActivity
|
||||
import com.gh.gamecenter.baselist.NormalListViewModel
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.halo.assistant.HaloApp
|
||||
import io.reactivex.Observable
|
||||
|
||||
class GameActivity : ListActivity<GameEntity, NormalListViewModel<GameEntity>>() {
|
||||
|
||||
private var mAdapter: GameAdapter? = null
|
||||
private val mKey: String? = null
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setNavigationTitle("插入游戏")
|
||||
}
|
||||
override fun provideListAdapter(): GameAdapter? {
|
||||
if (mAdapter == null) {
|
||||
mAdapter = GameAdapter(this)
|
||||
}
|
||||
return mAdapter
|
||||
}
|
||||
|
||||
override fun provideDataObservable(page: Int): Observable<MutableList<GameEntity>> {
|
||||
return RetrofitManager.getInstance(this).api.getSearchGame(Config.API_HOST + "games:search?keyword=" + "少" + "&filter=view=digest")
|
||||
}
|
||||
|
||||
override fun provideListViewModel(): NormalListViewModel<GameEntity> {
|
||||
val factory = NormalListViewModel.Factory(HaloApp.getInstance().application, this)
|
||||
return ViewModelProviders.of(this, factory).get(NormalListViewModel::class.java) as NormalListViewModel<GameEntity>
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun getIntent(context: Context): Intent {
|
||||
return Intent(context, GameActivity::class.java)
|
||||
}
|
||||
}
|
||||
}
|
||||
43
app/src/main/java/com/gh/gamecenter/qa/editor/GameAdapter.kt
Normal file
43
app/src/main/java/com/gh/gamecenter/qa/editor/GameAdapter.kt
Normal file
@ -0,0 +1,43 @@
|
||||
package com.gh.gamecenter.qa.editor
|
||||
|
||||
import android.content.Context
|
||||
import android.support.v7.widget.RecyclerView
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import com.gh.common.constant.ItemViewType
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.adapter.viewholder.ReuseViewHolder
|
||||
import com.gh.gamecenter.baselist.ListAdapter
|
||||
import com.gh.gamecenter.databinding.GameItemBinding
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
import com.gh.gamecenter.game.GameItemViewHolder
|
||||
|
||||
class GameAdapter(context: Context): ListAdapter<GameEntity>(context) {
|
||||
|
||||
override fun getItemViewType(position: Int): Int {
|
||||
if (position == 0) {
|
||||
return ItemViewType.ITEM_TOP
|
||||
}
|
||||
return ItemViewType.ITEM_BODY
|
||||
}
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
|
||||
if (viewType == ItemViewType.ITEM_TOP) {
|
||||
return ReuseViewHolder(mLayoutInflater.inflate(R.layout.layout_search_bar, parent, false))
|
||||
}
|
||||
return GameItemViewHolder(GameItemBinding.bind(mLayoutInflater.inflate(R.layout.game_item, parent, false)))
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
return mEntityList.size + 1
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
|
||||
if (holder is GameItemViewHolder) {
|
||||
val entity = mEntityList[position-1]
|
||||
holder.binding.game = entity
|
||||
holder.binding.subjectTag = "type"
|
||||
holder.binding.downloadBtn.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
package com.gh.gamecenter.qa.editor
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.support.v4.app.Fragment
|
||||
import com.gh.base.BaseActivity_TabLayout
|
||||
|
||||
class InsertAnswerWrapperActivity : BaseActivity_TabLayout() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setNavigationTitle("插入回答")
|
||||
}
|
||||
override fun initFragmentList(fragments: MutableList<Fragment>?) {
|
||||
fragments?.add(LinkFragment())
|
||||
fragments?.add(AnswerFragment())
|
||||
}
|
||||
|
||||
override fun initTabTitleList(tabTitleList: MutableList<String>?) {
|
||||
tabTitleList?.add("输入链接")
|
||||
tabTitleList?.add("收藏回答")
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun getIntent(context: Context): Intent {
|
||||
return Intent(context, InsertAnswerWrapperActivity::class.java)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
package com.gh.gamecenter.qa.editor
|
||||
|
||||
import com.gh.base.fragment.BaseFragment
|
||||
import com.gh.gamecenter.R
|
||||
|
||||
class LinkFragment : BaseFragment<Any>() {
|
||||
override fun getLayoutId(): Int {
|
||||
return R.layout.fragment_link
|
||||
}
|
||||
|
||||
}
|
||||
@ -80,6 +80,7 @@
|
||||
android:orientation = "horizontal" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/editor_link_answer"
|
||||
android:layout_width = "0dp"
|
||||
android:layout_height = "50dp"
|
||||
android:layout_weight = "1"
|
||||
@ -89,6 +90,7 @@
|
||||
android:textSize = "13sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/editor_link_article"
|
||||
android:layout_width = "0dp"
|
||||
android:layout_height = "50dp"
|
||||
android:layout_weight = "1"
|
||||
@ -98,6 +100,7 @@
|
||||
android:textSize = "13sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/editor_link_game"
|
||||
android:layout_width = "0dp"
|
||||
android:layout_height = "50dp"
|
||||
android:layout_weight = "1"
|
||||
@ -139,7 +142,7 @@
|
||||
android:layout_width = "wrap_content"
|
||||
android:layout_height = "wrap_content"
|
||||
android:src = "@drawable/editor_link_selector"
|
||||
android:visibility = "gone" />
|
||||
android:visibility = "visible" />
|
||||
|
||||
<View
|
||||
android:layout_width = "0dp"
|
||||
|
||||
21
app/src/main/res/layout/fragment_link.xml
Normal file
21
app/src/main/res/layout/fragment_link.xml
Normal file
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView xmlns:android = "http://schemas.android.com/apk/res/android"
|
||||
android:layout_width = "match_parent"
|
||||
android:layout_height = "match_parent" >
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width = "match_parent"
|
||||
android:layout_height = "wrap_content"
|
||||
android:orientation = "vertical" >
|
||||
|
||||
<include layout = "@layout/layout_search_bar" />
|
||||
|
||||
<TextView
|
||||
android:layout_width = "wrap_content"
|
||||
android:layout_height = "wrap_content"
|
||||
android:paddingLeft = "20dp"
|
||||
android:paddingRight = "20dp"
|
||||
android:text = "获取回答链接的方式:\n1.在回答详情页面,点击右上角【…】按钮 \n2.然后点击【分享】,再点击【复制链接】"
|
||||
android:textColor = "@color/title" />
|
||||
</LinearLayout >
|
||||
</ScrollView >
|
||||
Reference in New Issue
Block a user