Skip to content

Commit

Permalink
add commenting in the paging view
Browse files Browse the repository at this point in the history
  • Loading branch information
kidozh committed Mar 13, 2021
1 parent c395ac7 commit 4b48e69
Show file tree
Hide file tree
Showing 15 changed files with 699 additions and 411 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,9 @@ private void configureIntentData(){
private void bindViewModel(){
forumViewModel.totalThreadListMutableLiveData.observe(this, it->{
Map<String,String> threadTypeMap = null;
if(forumViewModel.displayForumResultMutableLiveData.getValue()!=null){
threadTypeMap = forumViewModel.displayForumResultMutableLiveData.getValue().forumVariables.threadTypeInfo.idNameMap;
if(forumViewModel.displayForumResultMutableLiveData.getValue()!=null &&
forumViewModel.displayForumResultMutableLiveData.getValue().forumVariables.getThreadTypeInfo()!=null){
threadTypeMap = forumViewModel.displayForumResultMutableLiveData.getValue().forumVariables.getThreadTypeInfo().idNameMap;
}

adapter.updateListAndType(it, threadTypeMap);
Expand Down Expand Up @@ -377,9 +378,9 @@ public void onClick(View v) {
intent.putExtra(ConstUtils.PASS_BBS_USER_KEY, user);
intent.putExtra(ConstUtils.PASS_POST_TYPE, ConstUtils.TYPE_POST_THREAD);
if(forumViewModel.displayForumResultMutableLiveData
.getValue().forumVariables.threadTypeInfo != null){
.getValue().forumVariables.getThreadTypeInfo() != null){
intent.putExtra(ConstUtils.PASS_THREAD_CATEGORY_KEY, (Serializable) forumViewModel.displayForumResultMutableLiveData
.getValue().forumVariables.threadTypeInfo.idNameMap);
.getValue().forumVariables.getThreadTypeInfo().idNameMap);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1342,7 +1342,8 @@ protected void onPreExecute() {
builder.url(URLUtils.getPostThreadUrl(fid));
}
else {
int fidInt = Integer.parseInt(fid);
// int fidInt = Integer.parseInt(fid);
int fidInt = 0;
builder.url(URLUtils.getReplyThreadUrl(fidInt,tid));

}
Expand Down
238 changes: 123 additions & 115 deletions app/src/main/java/com/kidozh/discuzhub/activities/ThreadActivity.kt

Large diffs are not rendered by default.

312 changes: 198 additions & 114 deletions app/src/main/java/com/kidozh/discuzhub/activities/ThreadPageActivity.kt

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions app/src/main/java/com/kidozh/discuzhub/adapter/PostAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ class PostAdapter(private val bbsInfo: Discuz, private val user: User?, viewThre
val bundle = options.toBundle()
context.startActivity(intent, bundle)
}
holder.mReplyBtn.setOnClickListener { replyListener!!.replyToSomeOne(position) }
holder.mReplyBtn.setOnClickListener { replyListener!!.replyToSomeOne(post) }

// advance option
if (bbsInfo.apiVersion > 4) {
Expand Down Expand Up @@ -826,7 +826,7 @@ class PostAdapter(private val bbsInfo: Discuz, private val user: User?, viewThre
}

interface onAdapterReply {
fun replyToSomeOne(position: Int)
fun replyToSomeOne(post : Post)
}

interface OnLinkClicked {
Expand Down
12 changes: 12 additions & 0 deletions app/src/main/java/com/kidozh/discuzhub/results/BaseResult.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.kidozh.discuzhub.results
import android.text.TextUtils
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
import com.fasterxml.jackson.annotation.JsonProperty
import com.kidozh.discuzhub.activities.BaseStatusActivity
import com.kidozh.discuzhub.entities.ErrorMessage

@JsonIgnoreProperties(ignoreUnknown = true)
Expand All @@ -13,6 +14,17 @@ open class BaseResult {
@JsonProperty("Charset")
lateinit var Charset: String

fun getCharsetType():Int{
if (Charset == "GBK") {
return BaseStatusActivity.CHARSET_GBK
} else if (Charset == "BIG5") {
return BaseStatusActivity.CHARSET_BIG5
}
else{
return BaseStatusActivity.CHARSET_UTF8
}
}

@JvmField
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonProperty("Message")
Expand Down
123 changes: 0 additions & 123 deletions app/src/main/java/com/kidozh/discuzhub/results/ForumResult.java

This file was deleted.

159 changes: 159 additions & 0 deletions app/src/main/java/com/kidozh/discuzhub/results/ForumResult.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
package com.kidozh.discuzhub.results

import com.fasterxml.jackson.annotation.JsonIgnoreProperties
import com.kidozh.discuzhub.results.BaseResult
import com.fasterxml.jackson.annotation.JsonProperty
import com.kidozh.discuzhub.results.VariableResults
import com.kidozh.discuzhub.entities.Forum
import com.kidozh.discuzhub.results.ForumResult.SubForumInfo
import com.fasterxml.jackson.annotation.JsonFormat
import com.kidozh.discuzhub.results.ForumResult.ThreadTypeInfo
import com.fasterxml.jackson.databind.annotation.JsonDeserialize
import com.kidozh.discuzhub.utilities.OneZeroBooleanJsonDeserializer
import com.fasterxml.jackson.annotation.JsonInclude
import com.kidozh.discuzhub.results.ForumResult.ForumThreadTypeDeserializer
import com.fasterxml.jackson.databind.JsonDeserializer
import kotlin.Throws
import com.fasterxml.jackson.core.JsonProcessingException
import com.fasterxml.jackson.core.JsonParser
import com.fasterxml.jackson.core.JsonToken
import com.fasterxml.jackson.core.type.TypeReference
import com.fasterxml.jackson.databind.DeserializationContext
import com.fasterxml.jackson.databind.ObjectMapper
import com.kidozh.discuzhub.entities.Thread
import java.io.IOException
import java.io.Serializable
import java.util.ArrayList
import java.util.HashMap

class ForumResult : BaseResult() {

@JsonProperty("Variables")
lateinit var forumVariables: ForumVariables


class ForumVariables : VariableResults() {

@JsonProperty("forum")
lateinit var forum: Forum

@JsonProperty("group")
var groupInfo: GroupInfo? = null

@JsonProperty("forum_threadlist")
lateinit var forumThreadList: List<Thread>

@JsonProperty("groupiconid")
var groupIconId: Map<String, String>? = null

@JvmField
@JsonProperty("sublist")
var subForumLists: List<SubForumInfo> = ArrayList()

@JsonFormat(shape = JsonFormat.Shape.STRING)
var tpp = 0

@JsonFormat(shape = JsonFormat.Shape.STRING)
var page = 0

@JsonProperty("reward_unit")
var rewardUnit: String? = null


@JsonProperty("threadtypes")
var threadTypeInfo: ThreadTypeInfo? = null
}

class GroupInfo : Serializable {
@JsonProperty("groupid")
@JsonFormat(shape = JsonFormat.Shape.STRING)
var groupId = 0

@JsonProperty("grouptitle")
var groupTitle: String? = null
}

@JsonIgnoreProperties(ignoreUnknown = true)
class ShortReply : Serializable {
@JsonFormat(shape = JsonFormat.Shape.STRING)
var pid = 0

@JvmField
@JsonFormat(shape = JsonFormat.Shape.STRING)
@JsonProperty("authorid")
var authorId = 0

lateinit var author: String

lateinit var message: String
}

@JsonIgnoreProperties(ignoreUnknown = true)
class SubForumInfo : Serializable {
@JvmField
@JsonFormat(shape = JsonFormat.Shape.STRING)
var fid = 0

@JvmField
@JsonFormat(shape = JsonFormat.Shape.STRING)
var threads = 0

@JvmField
@JsonFormat(shape = JsonFormat.Shape.STRING)
var posts = 0
@JvmField
var name: String? = null

@JvmField
@JsonFormat(shape = JsonFormat.Shape.STRING)
@JsonProperty("todayposts")
var todayPosts = 0

@JsonProperty("icon")
var iconURL: String? = null
}

@JsonIgnoreProperties(ignoreUnknown = true)
class ThreadTypeInfo : Serializable {
@JsonFormat(shape = JsonFormat.Shape.STRING)
@JsonDeserialize(using = OneZeroBooleanJsonDeserializer::class)
@JsonInclude(JsonInclude.Include.NON_NULL)
var required = false

@JsonFormat(shape = JsonFormat.Shape.STRING)
@JsonDeserialize(using = OneZeroBooleanJsonDeserializer::class)
@JsonInclude(JsonInclude.Include.NON_NULL)
var listable = false
var prefix: String? = null

@JvmField
@JsonProperty("types")
@JsonDeserialize(using = ForumThreadTypeDeserializer::class)
var idNameMap = HashMap<String, String>()

@JsonProperty("icons")
@JsonDeserialize(using = ForumThreadTypeDeserializer::class)
var idIconMap: Map<String, String> = HashMap()

@JsonProperty("moderators")
@JsonDeserialize(using = ForumThreadTypeDeserializer::class)
var idModeratorMap: Map<String, String> = HashMap()
}

class ForumThreadTypeDeserializer : JsonDeserializer<Map<String, String>>() {
@Throws(IOException::class, JsonProcessingException::class)
override fun deserialize(p: JsonParser, ctxt: DeserializationContext): Map<String, String> {
val currentToken = p.currentToken
return if (currentToken == JsonToken.START_OBJECT) {
val mapper = ObjectMapper()
mapper.readValue<Map<String, String>>(p, object : TypeReference<Map<String, String>>() {})
} else {
HashMap()
}
}
}

override fun isError(): Boolean {
return message != null
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,17 @@ class ThreadResult : BaseResult() {
var ppp = 0

@JsonProperty("setting_rewriterule")
var rewriteRule: Map<String, String> = HashMap()
var rewriteRule: Map<String, String>? = HashMap()

@JsonProperty("setting_rewritestatus")
@JsonDeserialize(using = SettingRewriteStatusJsonDeserializer::class)
var rewriteList: List<String> = ArrayList()
var rewriteList: List<String>? = ArrayList()

@JsonProperty("forum_threadpay")
var threadPay: String? = null

@JsonProperty("cache_custominfo_postno")
var customPostNoList: List<String> = ArrayList()
var customPostNoList: List<String>? = ArrayList()

// for poll
@JsonIgnoreProperties(ignoreUnknown = true)
Expand Down
Loading

0 comments on commit 4b48e69

Please sign in to comment.