Skip to content

Commit

Permalink
rich edit text
Browse files Browse the repository at this point in the history
  • Loading branch information
ekibun committed Aug 29, 2019
1 parent 209e408 commit 0340578
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ class TopicPresenter(private val context: TopicActivity) {
}

private fun processTopic(topic: Topic, scrollPost: String){
context.item_reply.setCompoundDrawablesWithIntrinsicBounds(
context.btn_reply.setCompoundDrawablesWithIntrinsicBounds(
if(!topic.formhash.isNullOrEmpty()) ResourceUtil.getDrawable(context, R.drawable.ic_edit) else null,//left
null,
if(!topic.formhash.isNullOrEmpty()) ResourceUtil.getDrawable(context, R.drawable.ic_send) else null,//right
null)
context.item_reply.setOnClickListener {
context.btn_reply.setOnClickListener {
topic.formhash?.let{ formhash -> showReplyPopupWindow(topic.post, FormBody.Builder().add("lastview", topic.lastview!!).add("formhash", formhash),"", context.getString(R.string.parse_hint_reply_topic, topic.title)) }?:{
if(!topic.errorLink.isNullOrEmpty()) WebActivity.launchUrl(context, topic.errorLink, "")
}()
Expand Down Expand Up @@ -140,7 +140,7 @@ class TopicPresenter(private val context: TopicActivity) {
buildPopupWindow(hint, drafts[draftId]) { inputString, send ->
if(send){
data.add("submit", "submit")
data.add("content", comment + inputString)
data.add("content", comment + CustomHtml.toHtml(inputString))
ApiHelper.buildHttpCall(post, mapOf("User-Agent" to ua), body = data.build()){ response ->
val replies = ArrayList(topicView.adapter.data)
replies.removeAll { it.sub_floor > 0 }
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/java/soko/ekibun/bangumi/ui/topic/TopicView.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package soko.ekibun.bangumi.ui.topic

import android.graphics.Rect
import androidx.constraintlayout.widget.ConstraintLayout
import com.google.android.material.appbar.AppBarLayout
import android.view.LayoutInflater
import android.view.View
import androidx.constraintlayout.widget.ConstraintLayout
import com.bumptech.glide.request.RequestOptions
import com.google.android.material.appbar.AppBarLayout
import jp.wasabeef.glide.transformations.BlurTransformation
import kotlinx.android.synthetic.main.activity_topic.*
import soko.ekibun.bangumi.R
Expand Down Expand Up @@ -111,7 +111,7 @@ class TopicView(private val context: TopicActivity){
layoutManager.scrollToPositionWithOffset(adapter.data.indexOfFirst { it.pst_id == scrollPost }, 0) }
adapter.setOnLoadMoreListener({adapter.loadMoreEnd()}, context.item_list)
adapter.setEnableLoadMore(true)
context.item_reply.text = when {
context.btn_reply.text = when {
!topic.formhash.isNullOrEmpty() -> context.getString(R.string.hint_reply)
!topic.error.isNullOrEmpty() -> topic.error
topic.replies.isEmpty() -> context.getString(R.string.hint_empty_topic)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package soko.ekibun.bangumi.ui.view

import android.annotation.SuppressLint
import android.content.Context
import android.net.http.SslError
import android.os.Message
import android.util.AttributeSet
import android.view.MotionEvent
Expand Down Expand Up @@ -43,6 +42,7 @@ class NestedWebView @JvmOverloads constructor(context: Context, attrs: Attribute
webViewClient = mWebViewClient
}

@SuppressLint("ClickableViewAccessibility")
override fun onTouchEvent(event: MotionEvent): Boolean {
if(event.action == MotionEvent.ACTION_DOWN && scrollY <= 0)
scrollTo(scrollX, 1)
Expand Down Expand Up @@ -110,9 +110,6 @@ class NestedWebView @JvmOverloads constructor(context: Context, attrs: Attribute
}

val mWebViewClient = object : WebViewClient() {
override fun onReceivedSslError(view: WebView?, handler: SslErrorHandler, error: SslError?) {
handler.proceed()
}
override fun shouldOverrideUrlLoading(view: WebView, request: WebResourceRequest): Boolean {
return (view as? NestedWebView)?.shouldOverrideUrlLoading?.invoke(view, request) ?: super.shouldOverrideUrlLoading(view, request)
}
Expand Down
12 changes: 7 additions & 5 deletions app/src/main/res/layout/activity_topic.xml
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,13 @@
android:background="?android:colorBackground"
app:layout_anchor="@id/item_swipe"
app:layout_anchorGravity="bottom">
<TextView android:id="@+id/item_reply"
android:padding="8dp"
android:gravity="center_vertical"
android:layout_width="match_parent"
android:layout_height="45dp"/>

<TextView
android:id="@+id/btn_reply"
android:padding="8dp"
android:gravity="center_vertical"
android:layout_width="match_parent"
android:layout_height="45dp"/>
</FrameLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

0 comments on commit 0340578

Please sign in to comment.