|
|
|
@ -1,5 +1,6 @@ |
|
|
|
|
package com.community.pocket.ui.main.ui.forum.data; |
|
|
|
|
|
|
|
|
|
import android.app.Activity; |
|
|
|
|
import android.content.Intent; |
|
|
|
|
import android.os.Bundle; |
|
|
|
|
import android.os.Handler; |
|
|
|
@ -65,17 +66,17 @@ public class ForumDataActivity extends BaseActivity { |
|
|
|
|
private Button openReply; |
|
|
|
|
|
|
|
|
|
//帖子id
|
|
|
|
|
private int forumId; |
|
|
|
|
private String forumId; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
protected void onCreate(Bundle savedInstanceState) { |
|
|
|
|
protected void onCreate(final Bundle savedInstanceState) { |
|
|
|
|
super.onCreate(savedInstanceState); |
|
|
|
|
|
|
|
|
|
viewModel = new ViewModelProvider(this, new ViewModelProvider.NewInstanceFactory()).get(ForumDataViewModel.class); |
|
|
|
|
|
|
|
|
|
Intent intent = getIntent(); |
|
|
|
|
forumId = intent.getIntExtra(Param.forumId.name(), 0); |
|
|
|
|
if (forumId == 0) { |
|
|
|
|
forumId = intent.getStringExtra(Param.forumId.name()); |
|
|
|
|
if (forumId == null) { |
|
|
|
|
Toast.makeText(getApplicationContext(), R.string.forum_data_fail, Toast.LENGTH_LONG).show(); |
|
|
|
|
finish(); |
|
|
|
|
} else { |
|
|
|
@ -109,6 +110,7 @@ public class ForumDataActivity extends BaseActivity { |
|
|
|
|
|
|
|
|
|
if (forumDataResponse.getResult() == Response.Result.OK) { |
|
|
|
|
handler.sendEmptyMessage(0); |
|
|
|
|
viewModel.loadData(forumId); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
@ -127,7 +129,7 @@ public class ForumDataActivity extends BaseActivity { |
|
|
|
|
List<ForumContent> forumContents = listForumDataResponse.getForumContentList(); |
|
|
|
|
initFirst(forumContents.get(0)); |
|
|
|
|
if (forumContents.size() > 1) { |
|
|
|
|
createReply(forumContents.subList(1, forumContents.size() - 1)); |
|
|
|
|
createReply(forumContents.subList(1, forumContents.size())); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -201,6 +203,7 @@ public class ForumDataActivity extends BaseActivity { |
|
|
|
|
*/ |
|
|
|
|
@Event(value = R.id.back) |
|
|
|
|
private void back(View view) { |
|
|
|
|
setResult(Activity.RESULT_OK); |
|
|
|
|
finish(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -208,6 +211,7 @@ public class ForumDataActivity extends BaseActivity { |
|
|
|
|
* 创建楼层数据 |
|
|
|
|
*/ |
|
|
|
|
private void createReply(List<ForumContent> forumContentList) { |
|
|
|
|
replyLayout.removeAllViews(); |
|
|
|
|
for (ForumContent forumContent : forumContentList) { |
|
|
|
|
View view = View.inflate(this, R.layout.forum_data_content, null); |
|
|
|
|
ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); |
|
|
|
@ -226,7 +230,7 @@ public class ForumDataActivity extends BaseActivity { |
|
|
|
|
TextView name = view.findViewById(R.id.name); |
|
|
|
|
name.setText(forumContent.getUsername()); |
|
|
|
|
TextView score = view.findViewById(R.id.score); |
|
|
|
|
score.setText(String.valueOf(forumContent.getScore())); |
|
|
|
|
score.setText(String.valueOf(forumContent.getMyInfo().getCreditScore())); |
|
|
|
|
TextView time = view.findViewById(R.id.time); |
|
|
|
|
time.setText(DateFormat.format(getString(R.string.dateformat), forumContent.getTime())); |
|
|
|
|
TextView tower = view.findViewById(R.id.tower); |
|
|
|
|