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