|
@ -9,6 +9,7 @@ import android.support.v7.widget.RecyclerView; |
|
|
import android.view.LayoutInflater; |
|
|
import android.view.LayoutInflater; |
|
|
import android.view.View; |
|
|
import android.view.View; |
|
|
import android.view.ViewGroup; |
|
|
import android.view.ViewGroup; |
|
|
|
|
|
import android.widget.ImageButton; |
|
|
import android.widget.LinearLayout; |
|
|
import android.widget.LinearLayout; |
|
|
import android.widget.TextView; |
|
|
import android.widget.TextView; |
|
|
|
|
|
|
|
@ -40,6 +41,8 @@ class BoardAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { |
|
|
private final Context context; |
|
|
private final Context context; |
|
|
private ArrayList<Board> parsedSubBoards = new ArrayList<>(); |
|
|
private ArrayList<Board> parsedSubBoards = new ArrayList<>(); |
|
|
private ArrayList<Topic> parsedTopics = new ArrayList<>(); |
|
|
private ArrayList<Topic> parsedTopics = new ArrayList<>(); |
|
|
|
|
|
private final ArrayList<Boolean> boardExpandableVisibility = new ArrayList<>(); |
|
|
|
|
|
private final ArrayList<Boolean> topicExpandableVisibility = new ArrayList<>(); |
|
|
|
|
|
|
|
|
BoardAdapter(Context context, ArrayList<Board> parsedSubBoards, ArrayList<Topic> parsedTopics) { |
|
|
BoardAdapter(Context context, ArrayList<Board> parsedSubBoards, ArrayList<Topic> parsedTopics) { |
|
|
this.context = context; |
|
|
this.context = context; |
|
@ -119,6 +122,11 @@ class BoardAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { |
|
|
final Board subBoard = parsedSubBoards.get(position - 1); |
|
|
final Board subBoard = parsedSubBoards.get(position - 1); |
|
|
final SubBoardViewHolder subBoardViewHolder = (SubBoardViewHolder) holder; |
|
|
final SubBoardViewHolder subBoardViewHolder = (SubBoardViewHolder) holder; |
|
|
|
|
|
|
|
|
|
|
|
if (boardExpandableVisibility.size() != parsedSubBoards.size()) { |
|
|
|
|
|
for (int i = boardExpandableVisibility.size(); i < parsedSubBoards.size(); ++i) |
|
|
|
|
|
boardExpandableVisibility.add(false); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
subBoardViewHolder.boardRow.setOnClickListener(new View.OnClickListener() { |
|
|
subBoardViewHolder.boardRow.setOnClickListener(new View.OnClickListener() { |
|
|
@Override |
|
|
@Override |
|
|
public void onClick(View view) { |
|
|
public void onClick(View view) { |
|
@ -131,14 +139,40 @@ class BoardAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { |
|
|
context.startActivity(intent); |
|
|
context.startActivity(intent); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
if (boardExpandableVisibility.get(subBoardViewHolder.getAdapterPosition() - 1)) { |
|
|
|
|
|
subBoardViewHolder.boardExpandable.setVisibility(View.VISIBLE); |
|
|
|
|
|
subBoardViewHolder.showHideExpandable.setImageResource(R.drawable.ic_arrow_drop_up); |
|
|
|
|
|
} else { |
|
|
|
|
|
subBoardViewHolder.boardExpandable.setVisibility(View.GONE); |
|
|
|
|
|
subBoardViewHolder.showHideExpandable.setImageResource(R.drawable.ic_arrow_drop_down); |
|
|
|
|
|
} |
|
|
|
|
|
subBoardViewHolder.showHideExpandable.setOnClickListener(new View.OnClickListener() { |
|
|
|
|
|
@Override |
|
|
|
|
|
public void onClick(View view) { |
|
|
|
|
|
final boolean visible = boardExpandableVisibility.get(subBoardViewHolder.getAdapterPosition() - 1); |
|
|
|
|
|
if (visible) { |
|
|
|
|
|
subBoardViewHolder.boardExpandable.setVisibility(View.GONE); |
|
|
|
|
|
subBoardViewHolder.showHideExpandable.setImageResource(R.drawable.ic_arrow_drop_down); |
|
|
|
|
|
} else { |
|
|
|
|
|
subBoardViewHolder.boardExpandable.setVisibility(View.VISIBLE); |
|
|
|
|
|
subBoardViewHolder.showHideExpandable.setImageResource(R.drawable.ic_arrow_drop_up); |
|
|
|
|
|
} |
|
|
|
|
|
boardExpandableVisibility.set(subBoardViewHolder.getAdapterPosition() - 1, !visible); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
subBoardViewHolder.boardTitle.setText(subBoard.getTitle()); |
|
|
subBoardViewHolder.boardTitle.setText(subBoard.getTitle()); |
|
|
subBoardViewHolder.boardMods.setText(context.getString(R.string.child_board_mods, subBoard.getMods())); |
|
|
subBoardViewHolder.boardMods.setText(subBoard.getMods()); |
|
|
subBoardViewHolder.boardStats.setText(subBoard.getStats()); |
|
|
subBoardViewHolder.boardStats.setText(subBoard.getStats()); |
|
|
subBoardViewHolder.boardLastPost.setText(subBoard.getLastPost()); |
|
|
subBoardViewHolder.boardLastPost.setText(subBoard.getLastPost()); |
|
|
} else if (holder instanceof TopicViewHolder) { |
|
|
} else if (holder instanceof TopicViewHolder) { |
|
|
final Topic topic = parsedTopics.get(position - parsedSubBoards.size() - 1 - 1); |
|
|
final Topic topic = parsedTopics.get(position - parsedSubBoards.size() - 1 - 1); |
|
|
final TopicViewHolder topicViewHolder = (TopicViewHolder) holder; |
|
|
final TopicViewHolder topicViewHolder = (TopicViewHolder) holder; |
|
|
|
|
|
|
|
|
|
|
|
if (topicExpandableVisibility.size() != parsedTopics.size()) { |
|
|
|
|
|
for (int i = topicExpandableVisibility.size(); i < parsedTopics.size(); ++i) |
|
|
|
|
|
topicExpandableVisibility.add(false); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
topicViewHolder.topicRow.setOnClickListener(new View.OnClickListener() { |
|
|
topicViewHolder.topicRow.setOnClickListener(new View.OnClickListener() { |
|
|
@Override |
|
|
@Override |
|
|
public void onClick(View view) { |
|
|
public void onClick(View view) { |
|
@ -151,13 +185,40 @@ class BoardAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { |
|
|
context.startActivity(intent); |
|
|
context.startActivity(intent); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
topicViewHolder.topicSubject.setText(topic.getSubject()); |
|
|
if (topicExpandableVisibility.get(topicViewHolder.getAdapterPosition() - parsedSubBoards |
|
|
String lockedSticky = ""; |
|
|
.size() - 2)) { |
|
|
|
|
|
topicViewHolder.topicExpandable.setVisibility(View.VISIBLE); |
|
|
|
|
|
topicViewHolder.showHideExpandable.setImageResource(R.drawable.ic_arrow_drop_up); |
|
|
|
|
|
} else { |
|
|
|
|
|
topicViewHolder.topicExpandable.setVisibility(View.GONE); |
|
|
|
|
|
topicViewHolder.showHideExpandable.setImageResource(R.drawable.ic_arrow_drop_down); |
|
|
|
|
|
} |
|
|
|
|
|
topicViewHolder.showHideExpandable.setOnClickListener(new View.OnClickListener() { |
|
|
|
|
|
@Override |
|
|
|
|
|
public void onClick(View view) { |
|
|
|
|
|
final boolean visible = topicExpandableVisibility.get(topicViewHolder. |
|
|
|
|
|
getAdapterPosition() - parsedSubBoards.size() - 2); |
|
|
|
|
|
if (visible) { |
|
|
|
|
|
topicViewHolder.topicExpandable.setVisibility(View.GONE); |
|
|
|
|
|
topicViewHolder.showHideExpandable.setImageResource(R.drawable.ic_arrow_drop_down); |
|
|
|
|
|
} else { |
|
|
|
|
|
topicViewHolder.topicExpandable.setVisibility(View.VISIBLE); |
|
|
|
|
|
topicViewHolder.showHideExpandable.setImageResource(R.drawable.ic_arrow_drop_up); |
|
|
|
|
|
} |
|
|
|
|
|
topicExpandableVisibility.set(topicViewHolder.getAdapterPosition() - |
|
|
|
|
|
parsedSubBoards.size() - 2, !visible); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
topicViewHolder.topicSubject.setTypeface(Typeface.createFromAsset(context.getAssets() |
|
|
|
|
|
, "fonts/fontawesome-webfont.ttf")); |
|
|
|
|
|
String lockedSticky = topic.getSubject(); |
|
|
if (topic.isLocked()) |
|
|
if (topic.isLocked()) |
|
|
lockedSticky += context.getResources().getString(R.string.fa_lock); |
|
|
lockedSticky += " " + context.getResources().getString(R.string.fa_lock); |
|
|
if (topic.isSticky()) |
|
|
if (topic.isSticky()) { |
|
|
lockedSticky += context.getResources().getString(R.string.fa_sticky); |
|
|
//topicViewHolder.topicSubject.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_pin, 0);
|
|
|
topicViewHolder.topicLockedSticky.setText(lockedSticky); |
|
|
lockedSticky += " " + context.getResources().getString(R.string.fa_sticky); |
|
|
|
|
|
} |
|
|
|
|
|
topicViewHolder.topicSubject.setText(lockedSticky); |
|
|
topicViewHolder.topicStartedBy.setText(context.getString(R.string.topic_started_by, topic.getStarter())); |
|
|
topicViewHolder.topicStartedBy.setText(context.getString(R.string.topic_started_by, topic.getStarter())); |
|
|
topicViewHolder.topicStats.setText(topic.getStats()); |
|
|
topicViewHolder.topicStats.setText(topic.getStats()); |
|
|
topicViewHolder.topicLastPost.setText(context.getString(R.string.topic_last_post, topic.getLastPost())); |
|
|
topicViewHolder.topicLastPost.setText(context.getString(R.string.topic_last_post, topic.getLastPost())); |
|
@ -176,31 +237,36 @@ class BoardAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private static class SubBoardViewHolder extends RecyclerView.ViewHolder { |
|
|
private static class SubBoardViewHolder extends RecyclerView.ViewHolder { |
|
|
final LinearLayout boardRow; |
|
|
final LinearLayout boardRow, boardExpandable; |
|
|
final TextView boardTitle, boardMods, boardStats, boardLastPost; |
|
|
final TextView boardTitle, boardMods, boardStats, boardLastPost; |
|
|
|
|
|
final ImageButton showHideExpandable; |
|
|
|
|
|
|
|
|
SubBoardViewHolder(View itemView) { |
|
|
SubBoardViewHolder(View board) { |
|
|
super(itemView); |
|
|
super(board); |
|
|
boardRow = (LinearLayout) itemView.findViewById(R.id.child_board_row); |
|
|
boardRow = (LinearLayout) board.findViewById(R.id.child_board_row); |
|
|
boardTitle = (TextView) itemView.findViewById(R.id.child_board_title); |
|
|
boardExpandable = (LinearLayout) board.findViewById(R.id.child_board_expandable); |
|
|
boardMods = (TextView) itemView.findViewById(R.id.child_board_mods); |
|
|
showHideExpandable = (ImageButton) board.findViewById(R.id.child_board_expand_collapse_button); |
|
|
boardStats = (TextView) itemView.findViewById(R.id.child_board_stats); |
|
|
boardTitle = (TextView) board.findViewById(R.id.child_board_title); |
|
|
boardLastPost = (TextView) itemView.findViewById(R.id.child_board_last_post); |
|
|
boardMods = (TextView) board.findViewById(R.id.child_board_mods); |
|
|
|
|
|
boardStats = (TextView) board.findViewById(R.id.child_board_stats); |
|
|
|
|
|
boardLastPost = (TextView) board.findViewById(R.id.child_board_last_post); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private static class TopicViewHolder extends RecyclerView.ViewHolder { |
|
|
private static class TopicViewHolder extends RecyclerView.ViewHolder { |
|
|
final LinearLayout topicRow; |
|
|
final LinearLayout topicRow, topicExpandable; |
|
|
final TextView topicSubject, topicLockedSticky, topicStartedBy, topicStats, topicLastPost; |
|
|
final TextView topicSubject, topicStartedBy, topicStats, topicLastPost; |
|
|
|
|
|
final ImageButton showHideExpandable; |
|
|
|
|
|
|
|
|
TopicViewHolder(View itemView) { |
|
|
TopicViewHolder(View topic) { |
|
|
super(itemView); |
|
|
super(topic); |
|
|
topicRow = (LinearLayout) itemView.findViewById(R.id.topic_row_linear); |
|
|
topicRow = (LinearLayout) topic.findViewById(R.id.topic_row_linear); |
|
|
topicSubject = (TextView) itemView.findViewById(R.id.topic_subject); |
|
|
topicExpandable = (LinearLayout) topic.findViewById(R.id.topic_expandable); |
|
|
topicLockedSticky = (TextView) itemView.findViewById(R.id.topic_locked_sticky); |
|
|
showHideExpandable = (ImageButton) topic.findViewById(R.id.topic_expand_collapse_button); |
|
|
topicStartedBy = (TextView) itemView.findViewById(R.id.topic_started_by); |
|
|
topicSubject = (TextView) topic.findViewById(R.id.topic_subject); |
|
|
topicStats = (TextView) itemView.findViewById(R.id.topic_stats); |
|
|
topicStartedBy = (TextView) topic.findViewById(R.id.topic_started_by); |
|
|
topicLastPost = (TextView) itemView.findViewById(R.id.topic_last_post); |
|
|
topicStats = (TextView) topic.findViewById(R.id.topic_stats); |
|
|
|
|
|
topicLastPost = (TextView) topic.findViewById(R.id.topic_last_post); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|