Skip to content
This repository has been archived by the owner on Feb 17, 2024. It is now read-only.

Commit

Permalink
fix: 修复回贴时添加小尾巴
Browse files Browse the repository at this point in the history
  • Loading branch information
HuanCheng65 committed Aug 20, 2020
1 parent 3da25a4 commit 3a03874
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -288,71 +288,16 @@ private boolean needUpload() {
return needUpload;
}

/*
private void getReplyContent(ReplyContentCallback callback) {
StringBuilder builder = new StringBuilder();
if (replyInfoBean.isSubFloor() && (replyInfoBean.getReplyUser() != null)) {
builder.append("回复 ");
builder.append(replyInfoBean.getReplyUser());
builder.append(" : ");
builder.append(editText.getText().toString());
callback.onSuccess(builder.toString());
return;
}
builder.append(editText.getText().toString());
if (!needUpload()) {
if (hasPhoto()) {
for (PhotoInfoBean photoInfoBean : insertPhotoAdapter.getFileList()) {
if (photoInfoBean.getUploadResult() != null && photoInfoBean.getUploadResult().getInfo() != null) {
builder.append(photoInfoBean.getUploadResult().getInfo().getPic());
}
}
}
callback.onSuccess(builder.toString());
return;
}
StringBuilder picString = new StringBuilder();
UploadHelper.with(this)
.setFileList(insertPhotoAdapter.getFileList())
.setCallback(new UploadCallback() {
@Override
public void onSuccess(List<PhotoInfoBean> photoInfoBeans) {
for (PhotoInfoBean photoInfoBean : photoInfoBeans) {
if (photoInfoBean.getUploadResult() != null && photoInfoBean.getUploadResult().getInfo() != null) {
picString.append(photoInfoBean.getUploadResult().getInfo().getPic());
}
}
builder.append(picString.toString());
callback.onSuccess(builder.toString());
}
@Override
public void onStart(int total) {
callback.onStart(total);
}
@Override
public void onProgress(int current, int total) {
callback.onProgress(current, total);
}
@Override
public void onFailure(String error) {
callback.onFailure(error);
}
})
.start();
}
*/

private String getReplyContent() {
StringBuilder builder = new StringBuilder();
if (replyInfoBean.isSubFloor() && (replyInfoBean.getReplyUser() != null)) {
builder.append("回复 ");
builder.append(replyInfoBean.getReplyUser());
builder.append(" :");
builder.append("回复 ")
.append(replyInfoBean.getReplyUser())
.append(" :");
}
builder.append(editText.getText().toString());
builder.append(editText.getText().toString())
.append("\n")
.append(getAppPreferences().getLittleTail());
return builder.toString();
}

Expand Down Expand Up @@ -515,14 +460,17 @@ public void onSuccess(String data) {
@Override
public void onSuccess(String bsk) {
if (replyInfoBean.getPid() == null && replyInfoBean.getFloorNum() == null) {
TiebaApi.getInstance().webReply(replyInfoBean.getForumId(), replyInfoBean.getForumName(),
TiebaApi.getInstance().webReply(
replyInfoBean.getForumId(),
replyInfoBean.getForumName(),
replyInfoBean.getThreadId(),
replyInfoBean.getTbs(),
getReplyContent(),
data,
replyInfoBean.getNickName(),
replyInfoBean.getPn(),
bsk).enqueue(mCallback);
bsk
).enqueue(mCallback);
} else {
if (replyInfoBean.isSubFloor() && replyInfoBean.getSpid() != null) {
TiebaApi.getInstance().webReply(replyInfoBean.getForumId(), replyInfoBean.getForumName(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,22 @@ import cn.jzvd.Jzvd
import com.billy.android.preloader.PreLoader
import com.bumptech.glide.Glide
import com.google.android.material.snackbar.Snackbar
import com.huanchengfly.tieba.post.ui.theme.utils.ThemeUtils
import com.huanchengfly.tieba.post.R
import com.huanchengfly.tieba.post.adapters.RecyclerThreadAdapter
import com.huanchengfly.tieba.post.api.TiebaApi
import com.huanchengfly.tieba.post.api.interfaces.CommonAPICallback
import com.huanchengfly.tieba.post.api.models.AgreeBean
import com.huanchengfly.tieba.post.api.models.CommonResponse
import com.huanchengfly.tieba.post.api.models.ThreadContentBean
import com.huanchengfly.tieba.post.api.models.ThreadContentBean.PostListItemBean
import com.huanchengfly.tieba.post.api.retrofit.exception.TiebaException
import com.huanchengfly.tieba.post.R
import com.huanchengfly.tieba.post.adapters.RecyclerThreadAdapter
import com.huanchengfly.tieba.post.components.MyLinearLayoutManager
import com.huanchengfly.tieba.post.components.dialogs.EditTextDialog
import com.huanchengfly.tieba.post.components.dividers.ThreadDivider
import com.huanchengfly.tieba.post.models.ReplyInfoBean
import com.huanchengfly.tieba.post.models.ThreadHistoryInfoBean
import com.huanchengfly.tieba.post.models.database.History
import com.huanchengfly.tieba.post.ui.theme.utils.ThemeUtils
import com.huanchengfly.tieba.post.utils.*
import com.huanchengfly.tieba.post.utils.preload.PreloadUtil
import com.huanchengfly.tieba.post.utils.preload.loaders.ThreadContentLoader
Expand Down Expand Up @@ -599,7 +599,7 @@ class ThreadActivity : BaseActivity(), View.OnClickListener {

private fun collect(commonAPICallback: CommonAPICallback<CommonResponse>?, update: Boolean) {
if (dataBean == null || tid == null) return
val postListItemBean = lastVisibleItem ?: return
val postListItemBean = firstVisibleItem ?: return
TiebaApi.getInstance().addStore(tid!!, postListItemBean.id!!, tbs = dataBean!!.anti?.tbs!!).enqueue(object : Callback<CommonResponse> {
override fun onFailure(call: Call<CommonResponse>, t: Throwable) {
if (t is TiebaException) {
Expand Down Expand Up @@ -695,7 +695,7 @@ class ThreadActivity : BaseActivity(), View.OnClickListener {
private fun exit(): Boolean {
if (collect) {
DialogUtil.build(this)
.setTitle("是否更新收藏楼层")
.setMessage(R.string.message_update_store_floor)
.setPositiveButton(R.string.button_yes) { dialog: DialogInterface, _ ->
collect(object : CommonAPICallback<CommonResponse> {
override fun onSuccess(data: CommonResponse) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ open class AppPreferencesUtils(context: Context) {
//PreferenceManager.getDefaultSharedPreferences(context)

var loadPictureWhenScroll by SharedPreferenceDelegates.boolean(true)
var littleTail by SharedPreferenceDelegates.string(key = "little_tail")

private object SharedPreferenceDelegates {
fun int(defaultValue: Int = 0) = object : ReadWriteProperty<AppPreferencesUtils, Int> {
Expand Down Expand Up @@ -81,21 +82,24 @@ open class AppPreferencesUtils(context: Context) {
}
}

fun string(defaultValue: String? = null) =
fun string(
defaultValue: String? = null,
key: String? = null
) =
object : ReadWriteProperty<AppPreferencesUtils, String?> {
override fun getValue(
thisRef: AppPreferencesUtils,
property: KProperty<*>
): String? {
return thisRef.preferences.getString(property.name, defaultValue)
return thisRef.preferences.getString(key ?: property.name, defaultValue)
}

override fun setValue(
thisRef: AppPreferencesUtils,
property: KProperty<*>,
value: String?
) {
thisRef.preferences.edit().putString(property.name, value).apply()
thisRef.preferences.edit().putString(key ?: property.name, value).apply()
}
}

Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -358,4 +358,5 @@
<string name="hint_reply">回复 %1$s</string>
<string name="title_emotion_classic">经典</string>
<string name="title_emotion_emoji">符号</string>
<string name="message_update_store_floor">是否更新收藏楼层</string>
</resources>

0 comments on commit 3a03874

Please sign in to comment.