diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java index 73686869..76eff468 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java @@ -45,7 +45,6 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo private MaterialProgressBar progressBar; private BoardTask boardTask; - private RecyclerView mainContent; private BoardAdapter boardAdapter; private final ArrayList parsedSubBoards = new ArrayList<>(); private final ArrayList parsedTopics = new ArrayList<>(); @@ -77,7 +76,7 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo createDrawer(); boardAdapter = new BoardAdapter(getApplicationContext(), parsedSubBoards, parsedTopics); - mainContent = (RecyclerView) findViewById(R.id.board_recycler_view); + RecyclerView mainContent = (RecyclerView) findViewById(R.id.board_recycler_view); mainContent.setAdapter(boardAdapter); final LinearLayoutManager layoutManager = new LinearLayoutManager(this); mainContent.setLayoutManager(layoutManager); @@ -167,8 +166,7 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo ++pagesLoaded; //Parse was successful progressBar.setVisibility(ProgressBar.INVISIBLE); - boardAdapter = new BoardAdapter(getApplicationContext(), parsedSubBoards, parsedTopics); - mainContent.swapAdapter(boardAdapter, false); + boardAdapter.notifyDataSetChanged(); isLoadingMore = false; } @@ -225,15 +223,14 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo String pTopicUrl, pSubject, pStartedBy, pLastPost, pStats; boolean pLocked = false, pSticky = false; Elements topicColumns = topicRow.select(">td"); - //if (topicColumns.size() != 7) return false; { Element column = topicColumns.get(2); Element tmp = column.select("span[id^=msg_] a").first(); pTopicUrl = tmp.attr("href"); pSubject = tmp.text(); - if (topicColumns.get(1).select("img[id^=stickyicon]").first() != null) + if (column.select("img[id^=stickyicon]").first() != null) pSticky = true; - if (topicColumns.get(1).select("img[id^=lockicon]").first() != null) + if (column.select("img[id^=lockicon]").first() != null) pLocked = true; } pStartedBy = topicColumns.get(3).text(); diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardAdapter.java b/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardAdapter.java index c4b6c481..6ad340fd 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardAdapter.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardAdapter.java @@ -9,6 +9,7 @@ import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.ImageButton; import android.widget.LinearLayout; import android.widget.TextView; @@ -40,6 +41,8 @@ class BoardAdapter extends RecyclerView.Adapter { private final Context context; private ArrayList parsedSubBoards = new ArrayList<>(); private ArrayList parsedTopics = new ArrayList<>(); + private final ArrayList boardExpandableVisibility = new ArrayList<>(); + private final ArrayList topicExpandableVisibility = new ArrayList<>(); BoardAdapter(Context context, ArrayList parsedSubBoards, ArrayList parsedTopics) { this.context = context; @@ -119,6 +122,11 @@ class BoardAdapter extends RecyclerView.Adapter { final Board subBoard = parsedSubBoards.get(position - 1); 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() { @Override public void onClick(View view) { @@ -131,14 +139,40 @@ class BoardAdapter extends RecyclerView.Adapter { 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.boardMods.setText(context.getString(R.string.child_board_mods, subBoard.getMods())); + subBoardViewHolder.boardMods.setText(subBoard.getMods()); subBoardViewHolder.boardStats.setText(subBoard.getStats()); subBoardViewHolder.boardLastPost.setText(subBoard.getLastPost()); } else if (holder instanceof TopicViewHolder) { final Topic topic = parsedTopics.get(position - parsedSubBoards.size() - 1 - 1); 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() { @Override public void onClick(View view) { @@ -151,13 +185,40 @@ class BoardAdapter extends RecyclerView.Adapter { context.startActivity(intent); } }); - topicViewHolder.topicSubject.setText(topic.getSubject()); - String lockedSticky = ""; + if (topicExpandableVisibility.get(topicViewHolder.getAdapterPosition() - parsedSubBoards + .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()) - lockedSticky += context.getResources().getString(R.string.fa_lock); - if (topic.isSticky()) - lockedSticky += context.getResources().getString(R.string.fa_sticky); - topicViewHolder.topicLockedSticky.setText(lockedSticky); + lockedSticky += " " + context.getResources().getString(R.string.fa_lock); + if (topic.isSticky()) { + //topicViewHolder.topicSubject.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_pin, 0); + 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.topicStats.setText(topic.getStats()); topicViewHolder.topicLastPost.setText(context.getString(R.string.topic_last_post, topic.getLastPost())); @@ -176,31 +237,36 @@ class BoardAdapter extends RecyclerView.Adapter { } private static class SubBoardViewHolder extends RecyclerView.ViewHolder { - final LinearLayout boardRow; + final LinearLayout boardRow, boardExpandable; final TextView boardTitle, boardMods, boardStats, boardLastPost; + final ImageButton showHideExpandable; - SubBoardViewHolder(View itemView) { - super(itemView); - boardRow = (LinearLayout) itemView.findViewById(R.id.child_board_row); - boardTitle = (TextView) itemView.findViewById(R.id.child_board_title); - boardMods = (TextView) itemView.findViewById(R.id.child_board_mods); - boardStats = (TextView) itemView.findViewById(R.id.child_board_stats); - boardLastPost = (TextView) itemView.findViewById(R.id.child_board_last_post); + SubBoardViewHolder(View board) { + super(board); + boardRow = (LinearLayout) board.findViewById(R.id.child_board_row); + boardExpandable = (LinearLayout) board.findViewById(R.id.child_board_expandable); + showHideExpandable = (ImageButton) board.findViewById(R.id.child_board_expand_collapse_button); + boardTitle = (TextView) board.findViewById(R.id.child_board_title); + 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 { - final LinearLayout topicRow; - final TextView topicSubject, topicLockedSticky, topicStartedBy, topicStats, topicLastPost; + final LinearLayout topicRow, topicExpandable; + final TextView topicSubject, topicStartedBy, topicStats, topicLastPost; + final ImageButton showHideExpandable; - TopicViewHolder(View itemView) { - super(itemView); - topicRow = (LinearLayout) itemView.findViewById(R.id.topic_row_linear); - topicSubject = (TextView) itemView.findViewById(R.id.topic_subject); - topicLockedSticky = (TextView) itemView.findViewById(R.id.topic_locked_sticky); - topicStartedBy = (TextView) itemView.findViewById(R.id.topic_started_by); - topicStats = (TextView) itemView.findViewById(R.id.topic_stats); - topicLastPost = (TextView) itemView.findViewById(R.id.topic_last_post); + TopicViewHolder(View topic) { + super(topic); + topicRow = (LinearLayout) topic.findViewById(R.id.topic_row_linear); + topicExpandable = (LinearLayout) topic.findViewById(R.id.topic_expandable); + showHideExpandable = (ImageButton) topic.findViewById(R.id.topic_expand_collapse_button); + topicSubject = (TextView) topic.findViewById(R.id.topic_subject); + topicStartedBy = (TextView) topic.findViewById(R.id.topic_started_by); + topicStats = (TextView) topic.findViewById(R.id.topic_stats); + topicLastPost = (TextView) topic.findViewById(R.id.topic_last_post); } } diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsAdapter.java b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsAdapter.java index 4e861de9..4e60e949 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsAdapter.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsAdapter.java @@ -50,7 +50,7 @@ class LatestPostsAdapter extends RecyclerView.Adapter { public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { if (viewType == VIEW_TYPE_ITEM) { View view = LayoutInflater.from(parent.getContext()). - inflate(R.layout.profile_fragment_latest_posts_row, parent, false); + inflate(R.layout.fragment_latest_posts_row, parent, false); return new LatestPostViewHolder(view); } else if (viewType == VIEW_TYPE_LOADING) { View view = LayoutInflater.from(parent.getContext()). diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsFragment.java index 6daf5f11..dbe83af3 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsFragment.java @@ -87,7 +87,7 @@ public class LatestPostsFragment extends BaseFragment implements LatestPostsAdap @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - final View rootView = inflater.inflate(R.layout.profile_fragment_latest_posts, container, false); + final View rootView = inflater.inflate(R.layout.fragment_latest_posts, container, false); latestPostsAdapter = new LatestPostsAdapter(fragmentInteractionListener, parsedTopicSummaries); mainContent = (RecyclerView) rootView.findViewById(R.id.profile_latest_posts_recycler); mainContent.setAdapter(latestPostsAdapter); diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/stats/StatsFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/stats/StatsFragment.java index e1ba8400..3b780108 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/stats/StatsFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/stats/StatsFragment.java @@ -94,7 +94,7 @@ public class StatsFragment extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - final View rootView = inflater.inflate(R.layout.profile_fragment_stats, container, false); + final View rootView = inflater.inflate(R.layout.fragment_stats, container, false); mainContent = (LinearLayout) rootView.findViewById(R.id.main_content); progressBar = (MaterialProgressBar) rootView.findViewById(R.id.progressBar); if (haveParsed) diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/summary/SummaryFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/summary/SummaryFragment.java index 5e89ca5c..6ff199fb 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/summary/SummaryFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/summary/SummaryFragment.java @@ -78,7 +78,7 @@ public class SummaryFragment extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - final View rootView = inflater.inflate(R.layout.profile_fragment_summary, container, false); + final View rootView = inflater.inflate(R.layout.fragment_summary, container, false); mainContent = (LinearLayout) rootView.findViewById(R.id.profile_activity_content); if (!parsedProfileSummaryData.isEmpty()) populateLayout(); diff --git a/app/src/main/res/drawable-hdpi/ic_arrow_drop_down.png b/app/src/main/res/drawable-hdpi/ic_arrow_drop_down.png new file mode 100644 index 00000000..8c2624cc Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_arrow_drop_down.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_arrow_drop_up.png b/app/src/main/res/drawable-hdpi/ic_arrow_drop_up.png new file mode 100644 index 00000000..f70260ad Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_arrow_drop_up.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_pin.png b/app/src/main/res/drawable-hdpi/ic_pin.png new file mode 100644 index 00000000..9b2e2981 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_pin.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_arrow_drop_down.png b/app/src/main/res/drawable-mdpi/ic_arrow_drop_down.png new file mode 100644 index 00000000..a617f943 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_arrow_drop_down.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_arrow_drop_up.png b/app/src/main/res/drawable-mdpi/ic_arrow_drop_up.png new file mode 100644 index 00000000..73f9bb68 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_arrow_drop_up.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_pin.png b/app/src/main/res/drawable-mdpi/ic_pin.png new file mode 100644 index 00000000..efbfd6bd Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_pin.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_arrow_drop_down.png b/app/src/main/res/drawable-xhdpi/ic_arrow_drop_down.png new file mode 100644 index 00000000..79f45456 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_arrow_drop_down.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_arrow_drop_up.png b/app/src/main/res/drawable-xhdpi/ic_arrow_drop_up.png new file mode 100644 index 00000000..b3823901 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_arrow_drop_up.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_pin.png b/app/src/main/res/drawable-xhdpi/ic_pin.png new file mode 100644 index 00000000..43cc8ca0 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_pin.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_arrow_drop_down.png b/app/src/main/res/drawable-xxhdpi/ic_arrow_drop_down.png new file mode 100644 index 00000000..a62e15ba Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_arrow_drop_down.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_arrow_drop_up.png b/app/src/main/res/drawable-xxhdpi/ic_arrow_drop_up.png new file mode 100644 index 00000000..935d805e Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_arrow_drop_up.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_pin.png b/app/src/main/res/drawable-xxhdpi/ic_pin.png new file mode 100644 index 00000000..f1b6eb44 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_pin.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_arrow_drop_down.png b/app/src/main/res/drawable-xxxhdpi/ic_arrow_drop_down.png new file mode 100644 index 00000000..fb2d3adc Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_arrow_drop_down.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_arrow_drop_up.png b/app/src/main/res/drawable-xxxhdpi/ic_arrow_drop_up.png new file mode 100644 index 00000000..18fd806f Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_arrow_drop_up.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_pin.png b/app/src/main/res/drawable-xxxhdpi/ic_pin.png new file mode 100644 index 00000000..4d6bdf41 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_pin.png differ diff --git a/app/src/main/res/layout/activity_board_sub_board.xml b/app/src/main/res/layout/activity_board_sub_board.xml index c7b9d229..07557353 100644 --- a/app/src/main/res/layout/activity_board_sub_board.xml +++ b/app/src/main/res/layout/activity_board_sub_board.xml @@ -7,41 +7,62 @@ android:background="@color/card_background" android:clickable="true" android:orientation="vertical" - android:paddingLeft="10dp" - android:paddingRight="10dp"> + android:paddingLeft="16dp" + android:paddingRight="16dp"> - + android:layout_marginBottom="5dp" + android:layout_marginTop="5dp" + android:orientation="horizontal"> - - android:layout_marginLeft="7dp" - android:layout_marginRight="7dp" - android:text="@string/child_board_mods" - android:textColor="@color/secondary_text"/> + + - + android:orientation="vertical" + android:visibility="gone"> - + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_board_topic.xml b/app/src/main/res/layout/activity_board_topic.xml index 7670bfb3..debdc311 100644 --- a/app/src/main/res/layout/activity_board_topic.xml +++ b/app/src/main/res/layout/activity_board_topic.xml @@ -6,54 +6,61 @@ android:layout_height="wrap_content" android:clickable="true" android:orientation="vertical" - android:paddingLeft="10dp" - android:paddingRight="10dp"> + android:paddingLeft="16dp" + android:paddingRight="16dp"> + android:textColor="@color/primary_text" + android:textSize="18sp"/> - - + android:background="@color/background" + android:contentDescription="@string/child_board_button" + android:src="@drawable/ic_arrow_drop_down"/> - + android:orientation="vertical" + android:visibility="gone"> - + - + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/profile_fragment_latest_posts.xml b/app/src/main/res/layout/fragment_latest_posts.xml similarity index 100% rename from app/src/main/res/layout/profile_fragment_latest_posts.xml rename to app/src/main/res/layout/fragment_latest_posts.xml diff --git a/app/src/main/res/layout/profile_fragment_latest_posts_row.xml b/app/src/main/res/layout/fragment_latest_posts_row.xml similarity index 100% rename from app/src/main/res/layout/profile_fragment_latest_posts_row.xml rename to app/src/main/res/layout/fragment_latest_posts_row.xml diff --git a/app/src/main/res/layout/profile_fragment_stats.xml b/app/src/main/res/layout/fragment_stats.xml similarity index 100% rename from app/src/main/res/layout/profile_fragment_stats.xml rename to app/src/main/res/layout/fragment_stats.xml diff --git a/app/src/main/res/layout/profile_fragment_summary.xml b/app/src/main/res/layout/fragment_summary.xml similarity index 100% rename from app/src/main/res/layout/profile_fragment_summary.xml rename to app/src/main/res/layout/fragment_summary.xml diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e6b0a1d9..7226450f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -19,7 +19,8 @@ Child Boards - Moderators: %1$s + Exp/Coll + Moderators Stats Last post Topics