|
|
@ -11,19 +11,20 @@ import android.widget.Toast; |
|
|
|
|
|
|
|
|
|
|
|
import com.community.pocket.R; |
|
|
|
import com.community.pocket.R; |
|
|
|
import com.community.pocket.data.model.Forum; |
|
|
|
import com.community.pocket.data.model.Forum; |
|
|
|
|
|
|
|
import com.community.pocket.data.model.Page; |
|
|
|
import com.community.pocket.ui.BaseFragment; |
|
|
|
import com.community.pocket.ui.BaseFragment; |
|
|
|
import com.community.pocket.ui.main.ui.forum.data.ForumDataActivity; |
|
|
|
import com.community.pocket.ui.main.ui.forum.data.ForumDataActivity; |
|
|
|
import com.community.pocket.util.Param; |
|
|
|
import com.community.pocket.util.Param; |
|
|
|
|
|
|
|
|
|
|
|
import org.xutils.view.annotation.ViewInject; |
|
|
|
import org.xutils.view.annotation.ViewInject; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public abstract class ForumPost extends BaseFragment { |
|
|
|
public abstract class ForumPost extends BaseFragment { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//显示发帖人
|
|
|
|
|
|
|
|
protected abstract int showAuthor(); |
|
|
|
|
|
|
|
|
|
|
|
protected abstract int own(); |
|
|
|
//显示审核状态
|
|
|
|
|
|
|
|
protected abstract int showStatus(); |
|
|
|
|
|
|
|
|
|
|
|
@ViewInject(R.id.post_layout) |
|
|
|
@ViewInject(R.id.post_layout) |
|
|
|
private LinearLayout layout; |
|
|
|
private LinearLayout layout; |
|
|
@ -31,22 +32,35 @@ public abstract class ForumPost extends BaseFragment { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* 加载帖子数据 |
|
|
|
* 加载帖子数据 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected void loadPost(List<Forum> forumList) { |
|
|
|
protected void loadPost(Page<Forum> forumList) { |
|
|
|
|
|
|
|
|
|
|
|
if (forumList.isEmpty()) { |
|
|
|
if (forumList.isEmpty()) { |
|
|
|
Toast.makeText(getContext(), R.string.no_more_forum, Toast.LENGTH_LONG).show(); |
|
|
|
Toast.makeText(getContext(), R.string.no_more_forum, Toast.LENGTH_LONG).show(); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
layout.removeAllViews(); |
|
|
|
for (int i = 0; i < forumList.getList().size(); i++) { |
|
|
|
for (int i = 0; i < forumList.size(); i++) { |
|
|
|
final Forum forum = forumList.getList().get(i); |
|
|
|
final Forum forum = forumList.get(i); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
View childView = View.inflate(getContext(), R.layout.post, null); |
|
|
|
View childView = View.inflate(getContext(), R.layout.post, null); |
|
|
|
|
|
|
|
TextView status = childView.findViewById(R.id.check_status); |
|
|
|
|
|
|
|
status.setVisibility(showStatus()); |
|
|
|
|
|
|
|
switch (forum.getStatus()) { |
|
|
|
|
|
|
|
case ok: |
|
|
|
|
|
|
|
status.setText(R.string.forum_status_ok); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case fail: |
|
|
|
|
|
|
|
status.setText(R.string.forum_status_fail); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case uncheck: |
|
|
|
|
|
|
|
status.setText(R.string.forum_status_uncheck); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
TextView title = childView.findViewById(R.id.post_title); |
|
|
|
TextView title = childView.findViewById(R.id.post_title); |
|
|
|
title.setText(forum.getTitle()); |
|
|
|
title.setText(forum.getTitle()); |
|
|
|
TextView content = childView.findViewById(R.id.post_content); |
|
|
|
TextView content = childView.findViewById(R.id.post_content); |
|
|
|
content.setText(forum.getContent()); |
|
|
|
content.setText(forum.getContent()); |
|
|
|
TextView author = childView.findViewById(R.id.poster); |
|
|
|
TextView author = childView.findViewById(R.id.poster); |
|
|
|
author.setVisibility(own()); |
|
|
|
author.setVisibility(showAuthor()); |
|
|
|
author.setText(getString(R.string.poster, forum.getUsername())); |
|
|
|
author.setText(getString(R.string.poster, forum.getUsername())); |
|
|
|
|
|
|
|
|
|
|
|
TextView postReply = childView.findViewById(R.id.post_reply); |
|
|
|
TextView postReply = childView.findViewById(R.id.post_reply); |
|
|
|