diff --git a/app/src/main/assets/style.css b/app/src/main/assets/style.css index bb3051a1..d870a911 100644 --- a/app/src/main/assets/style.css +++ b/app/src/main/assets/style.css @@ -170,13 +170,13 @@ a img /* A code block - maybe even PHP ;). */ .code { - color: #26A69A; - background-color: #dddddd; + color: #FFFFFF; + background-color: #626566; font-family: "Comic Sans MS", "times new roman", monospace; font-size: x-small; line-height: 1.3em; /* Put a nice border around it. */ - border: 1px solid #000000; + border: 1px solid #FFFFFF; margin: 1px auto 1px auto; padding: 1px; width: 99%; @@ -191,7 +191,7 @@ a img .quoteheader, .codeheader { font-family: tahoma, sans-serif; - color: #000000; + color: #26A69A; text-decoration: none; font-style: normal; font-weight: bold; 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 31aea846..73686869 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 @@ -6,7 +6,6 @@ import android.support.v7.widget.DividerItemDecoration; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.Toolbar; -import android.util.Log; import android.widget.ProgressBar; import android.widget.Toast; @@ -110,7 +109,7 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo public void onLoadMore() { if (pagesLoaded < numberOfPages) { parsedTopics.add(null); - boardAdapter.notifyItemInserted(parsedSubBoards.size() + parsedTopics.size() - 1); + boardAdapter.notifyItemInserted(parsedSubBoards.size() + parsedTopics.size()); //Load data boardTask = new BoardTask(); @@ -176,7 +175,7 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo private boolean parseBoard(Document boardPage) { //Removes loading item if (isLoadingMore) { - parsedTopics.remove(parsedTopics.size() - 1); + if (parsedTopics.size() > 0) parsedTopics.remove(parsedTopics.size() - 1); } //Finds number of pages if (numberOfPages == -1) { 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 c1f0e125..c4b6c481 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 @@ -2,6 +2,8 @@ package gr.thmmy.mthmmy.activities.board; import android.content.Context; import android.content.Intent; +import android.graphics.Typeface; +import android.os.Build; import android.os.Bundle; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; @@ -29,9 +31,11 @@ import static gr.thmmy.mthmmy.activities.topic.TopicActivity.BUNDLE_TOPIC_URL; */ class BoardAdapter extends RecyclerView.Adapter { private static final String TAG = "BoardAdapter"; - private final int VIEW_TYPE_SUB_BOARD = 0; - private final int VIEW_TYPE_TOPIC = 1; - private final int VIEW_TYPE_LOADING = 2; + private final int VIEW_TYPE_SUB_BOARD_TITLE = 0; + private final int VIEW_TYPE_SUB_BOARD = 1; + private final int VIEW_TYPE_TOPIC_TITLE = 2; + private final int VIEW_TYPE_TOPIC = 3; + private final int VIEW_TYPE_LOADING = 4; private final Context context; private ArrayList parsedSubBoards = new ArrayList<>(); @@ -49,27 +53,62 @@ class BoardAdapter extends RecyclerView.Adapter { @Override public int getItemViewType(int position) { - if (position < parsedSubBoards.size()) + if (position <= parsedSubBoards.size()) { + if (position == 0) return VIEW_TYPE_SUB_BOARD_TITLE; return VIEW_TYPE_SUB_BOARD; - else if (parsedTopics.get(position - parsedSubBoards.size()) != null) - return VIEW_TYPE_TOPIC; - else return VIEW_TYPE_LOADING; + } else if (position <= parsedSubBoards.size() + parsedTopics.size() + 1) { + if (position == parsedSubBoards.size() + 1) return VIEW_TYPE_TOPIC_TITLE; + if (parsedTopics.get(position - parsedSubBoards.size() - 1 - 1) != null) + return VIEW_TYPE_TOPIC; + } + return VIEW_TYPE_LOADING; } @Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { - if (viewType == VIEW_TYPE_SUB_BOARD) { - View view = LayoutInflater.from(parent.getContext()). + if (viewType == VIEW_TYPE_SUB_BOARD_TITLE) { + TextView subBoardTitle = new TextView(context); + subBoardTitle.setLayoutParams(new LinearLayout.LayoutParams( + LinearLayout.LayoutParams.MATCH_PARENT + , LinearLayout.LayoutParams.WRAP_CONTENT)); + subBoardTitle.setText(context.getString(R.string.child_board_title)); + subBoardTitle.setTypeface(subBoardTitle.getTypeface(), Typeface.BOLD); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + subBoardTitle.setBackgroundColor(context.getColor(R.color.card_background)); + subBoardTitle.setTextColor(context.getColor(R.color.accent)); + } else { + //noinspection deprecation + subBoardTitle.setBackgroundColor(context.getResources().getColor(R.color.card_background)); + //noinspection deprecation + subBoardTitle.setTextColor(context.getResources().getColor(R.color.accent)); + } + subBoardTitle.setTextAlignment(View.TEXT_ALIGNMENT_CENTER); + subBoardTitle.setTextSize(20f); + + return new TitlesViewHolder(subBoardTitle); + } else if (viewType == VIEW_TYPE_SUB_BOARD) { + View subBoard = LayoutInflater.from(parent.getContext()). inflate(R.layout.activity_board_sub_board, parent, false); - return new SubBoardViewHolder(view); + return new SubBoardViewHolder(subBoard); + } else if (viewType == VIEW_TYPE_TOPIC_TITLE) { + TextView topicTitle = new TextView(context); + topicTitle.setLayoutParams(new LinearLayout.LayoutParams( + LinearLayout.LayoutParams.MATCH_PARENT + , LinearLayout.LayoutParams.WRAP_CONTENT)); + topicTitle.setText(context.getString(R.string.topic_title)); + topicTitle.setTypeface(topicTitle.getTypeface(), Typeface.BOLD); + topicTitle.setTextAlignment(View.TEXT_ALIGNMENT_CENTER); + topicTitle.setTextSize(20f); + + return new TitlesViewHolder(topicTitle); } else if (viewType == VIEW_TYPE_TOPIC) { - View view = LayoutInflater.from(parent.getContext()). + View topic = LayoutInflater.from(parent.getContext()). inflate(R.layout.activity_board_topic, parent, false); - return new TopicViewHolder(view); + return new TopicViewHolder(topic); } else if (viewType == VIEW_TYPE_LOADING) { - View view = LayoutInflater.from(parent.getContext()). + View loading = LayoutInflater.from(parent.getContext()). inflate(R.layout.recycler_loading_item, parent, false); - return new LoadingViewHolder(view); + return new LoadingViewHolder(loading); } return null; } @@ -77,7 +116,7 @@ class BoardAdapter extends RecyclerView.Adapter { @Override public void onBindViewHolder(final RecyclerView.ViewHolder holder, final int position) { if (holder instanceof SubBoardViewHolder) { - Board subBoard = parsedSubBoards.get(position); + final Board subBoard = parsedSubBoards.get(position - 1); final SubBoardViewHolder subBoardViewHolder = (SubBoardViewHolder) holder; subBoardViewHolder.boardRow.setOnClickListener(new View.OnClickListener() { @@ -85,10 +124,8 @@ class BoardAdapter extends RecyclerView.Adapter { public void onClick(View view) { Intent intent = new Intent(context, BoardActivity.class); Bundle extras = new Bundle(); - extras.putString(BUNDLE_BOARD_URL, parsedSubBoards.get(holder. - getAdapterPosition()).getUrl()); - extras.putString(BUNDLE_BOARD_TITLE, parsedSubBoards.get(holder. - getAdapterPosition()).getTitle()); + extras.putString(BUNDLE_BOARD_URL, subBoard.getUrl()); + extras.putString(BUNDLE_BOARD_TITLE, subBoard.getTitle()); intent.putExtras(extras); intent.setFlags(FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); @@ -99,7 +136,7 @@ class BoardAdapter extends RecyclerView.Adapter { subBoardViewHolder.boardStats.setText(subBoard.getStats()); subBoardViewHolder.boardLastPost.setText(subBoard.getLastPost()); } else if (holder instanceof TopicViewHolder) { - Topic topic = parsedTopics.get(position - parsedSubBoards.size()); + final Topic topic = parsedTopics.get(position - parsedSubBoards.size() - 1 - 1); final TopicViewHolder topicViewHolder = (TopicViewHolder) holder; topicViewHolder.topicRow.setOnClickListener(new View.OnClickListener() { @@ -107,10 +144,8 @@ class BoardAdapter extends RecyclerView.Adapter { public void onClick(View view) { Intent intent = new Intent(context, TopicActivity.class); Bundle extras = new Bundle(); - extras.putString(BUNDLE_TOPIC_URL, parsedTopics.get(holder. - getAdapterPosition() - parsedSubBoards.size()).getUrl()); - extras.putString(BUNDLE_TOPIC_TITLE, parsedTopics.get(holder. - getAdapterPosition() - parsedSubBoards.size()).getSubject()); + extras.putString(BUNDLE_TOPIC_URL, topic.getUrl()); + extras.putString(BUNDLE_TOPIC_TITLE, topic.getSubject()); intent.putExtras(extras); intent.setFlags(FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); @@ -134,10 +169,10 @@ class BoardAdapter extends RecyclerView.Adapter { @Override public int getItemCount() { - if (parsedSubBoards == null && parsedTopics == null) return 0; - else if (parsedSubBoards == null) return parsedTopics.size(); - else if (parsedTopics == null) return parsedSubBoards.size(); - else return parsedSubBoards.size() + parsedTopics.size(); + int items = 0; + if (parsedSubBoards != null) items += parsedSubBoards.size() + 1; + if (parsedTopics != null) items += parsedTopics.size() + 1; + return items; } private static class SubBoardViewHolder extends RecyclerView.ViewHolder { @@ -169,6 +204,12 @@ class BoardAdapter extends RecyclerView.Adapter { } } + private static class TitlesViewHolder extends RecyclerView.ViewHolder { + TitlesViewHolder(View title) { + super(title); + } + } + private static class LoadingViewHolder extends RecyclerView.ViewHolder { final MaterialProgressBar progressBar; 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 fda3490c..c7b9d229 100644 --- a/app/src/main/res/layout/activity_board_sub_board.xml +++ b/app/src/main/res/layout/activity_board_sub_board.xml @@ -15,8 +15,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/child_board_title" - android:textColor="@color/accent" - android:textStyle="bold"/> + android:textColor="@color/accent"/> + android:textColor="@color/primary_text"/> by %1$s - Child Board + Child Boards Moderators: %1$s Stats Last post + Topics Subject Locked/Sticky - Started By: %1$s + Started by: %1$s Stats Last post on: %1$s