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 e3c3ec8d..6054a05f 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 @@ -1,5 +1,6 @@ package gr.thmmy.mthmmy.activities.profile.latestPosts; +import android.graphics.Color; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -21,10 +22,10 @@ import me.zhanghai.android.materialprogressbar.MaterialProgressBar; * specified {@link LatestPostsFragment.LatestPostsFragmentInteractionListener}. */ class LatestPostsAdapter extends RecyclerView.Adapter { - private final int VIEW_TYPE_EMPTY = -1; - private final int VIEW_TYPE_ITEM = 0; - private final int VIEW_TYPE_LOADING = 1; - final private LatestPostsFragment.LatestPostsFragmentInteractionListener interactionListener; + private static final int VIEW_TYPE_EMPTY = -1; + private static final int VIEW_TYPE_ITEM = 0; + private static final int VIEW_TYPE_LOADING = 1; + private final LatestPostsFragment.LatestPostsFragmentInteractionListener interactionListener; private final ArrayList parsedTopicSummaries; LatestPostsAdapter(BaseFragment.FragmentInteractionListener interactionListener, @@ -70,19 +71,16 @@ class LatestPostsAdapter extends RecyclerView.Adapter { latestPostViewHolder.postTitle.setText(topic.getSubject()); latestPostViewHolder.postDate.setText(topic.getDateTime()); + latestPostViewHolder.post.setBackgroundColor(Color.argb(1, 255, 255, 255)); latestPostViewHolder.post.loadDataWithBaseURL("file:///android_asset/" , topic.getPost(), "text/html", "UTF-8", null); - latestPostViewHolder.latestPostsRow.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - if (interactionListener != null) { - // Notify the active callbacks interface (the activity, if the - // fragment is attached to one) that a post has been selected. - interactionListener.onLatestPostsFragmentInteraction( - parsedTopicSummaries.get(holder.getAdapterPosition())); - } - + latestPostViewHolder.latestPostsRow.setOnClickListener(v -> { + if (interactionListener != null) { + // Notify the active callbacks interface (the activity, if the + // fragment is attached to one) that a post has been selected. + interactionListener.onLatestPostsFragmentInteraction( + parsedTopicSummaries.get(holder.getAdapterPosition())); } }); } else if (holder instanceof LoadingViewHolder) { 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 b2fb112c..04f20b60 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 @@ -135,7 +135,6 @@ public class LatestPostsFragment extends BaseFragment implements LatestPostsAdap profileLatestPostsTask.execute(profileUrl + ";sa=showPosts"); pagesLoaded = 1; } - Timber.d("onActivityCreated"); } @Override @@ -193,14 +192,13 @@ public class LatestPostsFragment extends BaseFragment implements LatestPostsAdap //td:contains( Sorry, no matches were found) Elements latestPostsRows = latestPostsPage. select("td:has(table:Contains(Show Posts)):not([style]) > table"); - if (latestPostsRows.isEmpty()) { + if (latestPostsRows.isEmpty()) latestPostsRows = latestPostsPage. select("td:has(table:Contains(Εμφάνιση μηνυμάτων)):not([style]) > table"); - } + //Removes loading item - if (isLoadingMore) { + if (isLoadingMore) parsedTopicSummaries.remove(parsedTopicSummaries.size() - 1); - } if (!latestPostsRows.select("td:contains(Sorry, no matches were found)").isEmpty() || !latestPostsRows.select("td:contains(Δυστυχώς δεν βρέθηκε τίποτα)").isEmpty()){ @@ -222,10 +220,10 @@ public class LatestPostsFragment extends BaseFragment implements LatestPostsAdap } } else { Elements rowHeader = row.select("td.middletext"); - if (rowHeader.size() != 2) { + if (rowHeader.size() != 2) return false; - } else { - pTopicTitle = rowHeader.first().text().trim(); + else { + pTopicTitle = rowHeader.first().text().replaceAll("\\u00a0","").trim(); pTopicUrl = rowHeader.first().select("a").last().attr("href"); pDateTime = rowHeader.last().text(); } diff --git a/app/src/main/res/layout-v21/activity_topic_post_row.xml b/app/src/main/res/layout-v21/activity_topic_post_row.xml index 1cdb357c..d1464a61 100644 --- a/app/src/main/res/layout-v21/activity_topic_post_row.xml +++ b/app/src/main/res/layout-v21/activity_topic_post_row.xml @@ -58,7 +58,8 @@ android:layout_gravity="center" android:adjustViewBounds="true" android:contentDescription="@string/post_thumbnail" - android:transitionName="user_thumbnail" /> + android:transitionName="user_thumbnail" + app:srcCompat="@drawable/ic_default_user_avatar_darker" /> + android:contentDescription="@string/post_thumbnail" + app:srcCompat="@drawable/ic_default_user_avatar_darker" />