From 3dff698502a9e7173c4e605d3bb23f0e8da9dc3b Mon Sep 17 00:00:00 2001 From: Ezerous Date: Wed, 19 Aug 2020 19:12:35 +0300 Subject: [PATCH] LatestPostsFragment improvements --- app/src/main/AndroidManifest.xml | 1 + app/src/main/assets/style_dark.css | 11 ++ app/src/main/assets/style_light.css | 11 ++ .../activities/profile/ProfileActivity.java | 12 +- .../latestPosts/LatestPostsAdapter.java | 2 +- .../latestPosts/LatestPostsFragment.java | 11 +- .../profile/summary/SummaryFragment.java | 1 + .../layout/fragment_profile_latest_posts.xml | 4 +- .../fragment_profile_latest_posts_row.xml | 121 ++++++++++-------- .../res/layout/fragment_profile_stats.xml | 13 +- .../res/layout/fragment_profile_summary.xml | 2 +- app/src/main/res/values/colors.xml | 1 + 12 files changed, 118 insertions(+), 72 deletions(-) create mode 100644 app/src/main/assets/style_dark.css create mode 100644 app/src/main/assets/style_light.css diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 7c7ab811..8b01d869 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -96,6 +96,7 @@ mFragmentList = new ArrayList<>(); private final List mFragmentTitleList = new ArrayList<>(); @@ -392,6 +393,7 @@ public class ProfileActivity extends BaseActivity implements LatestPostsFragment super(manager); } + @NonNull @Override public Fragment getItem(int position) { return mFragmentList.get(position); @@ -402,7 +404,7 @@ public class ProfileActivity extends BaseActivity implements LatestPostsFragment return mFragmentList.size(); } - void addFrag(Fragment fragment, String title) { + void addFragment(Fragment fragment, String title) { mFragmentList.add(fragment); mFragmentTitleList.add(title); } 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 4bd9ee1f..e42e4095 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 @@ -92,7 +92,7 @@ class LatestPostsAdapter extends RecyclerView.Adapter { LatestPostViewHolder(View itemView) { super(itemView); - latestPostsRow = itemView.findViewById(R.id.latest_posts_row); + latestPostsRow = itemView.findViewById(R.id.latest_posts_row_head); postTitle = itemView.findViewById(R.id.title); postDate = itemView.findViewById(R.id.date); post = itemView.findViewById(R.id.post); 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 cbe2f3f0..939a1fbd 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 @@ -7,7 +7,6 @@ import android.view.View; import android.view.ViewGroup; import androidx.annotation.NonNull; -import androidx.recyclerview.widget.DividerItemDecoration; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; @@ -90,9 +89,6 @@ public class LatestPostsFragment extends BaseFragment { recyclerView.setAdapter(latestPostsAdapter); final LinearLayoutManager layoutManager = new LinearLayoutManager(getContext()); recyclerView.setLayoutManager(layoutManager); - DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(recyclerView.getContext(), - layoutManager.getOrientation()); - recyclerView.addItemDecoration(dividerItemDecoration); recyclerView.setItemViewCacheSize(15); recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { @@ -190,7 +186,6 @@ public class LatestPostsFragment extends BaseFragment { int prevSize = parsedTopicSummaries.size(); parsedTopicSummaries.addAll(fetchedParsedTopicSummaries); latestPostsAdapter.notifyItemRangeInserted(prevSize, parsedTopicSummaries.size() - prevSize); - latestPostsAdapter.notifyDataSetChanged(); isLoadingMore = false; onLoadingListener.onLoadingLatestPosts(false); } @@ -228,13 +223,15 @@ public class LatestPostsFragment extends BaseFragment { else { pTopicTitle = rowHeader.first().text().replaceAll("\\u00a0","").trim(); pTopicUrl = rowHeader.first().select("a").last().attr("href"); - pDateTime = rowHeader.last().text(); + pDateTime = rowHeader.last().text().replaceAll("(on: )|(στις: )",""); } pPost = ParseHelpers.youtubeEmbeddedFix(row.select("div.post").first()); //Add stuff to make it work in WebView //style.css - pPost = ("" + pPost); + pPost = ("" + + "" + + pPost); fetchedParsedTopicSummaries.add(new PostSummary(pTopicUrl, pTopicTitle, pDateTime, pPost)); } 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 21513a4b..d58112ea 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 @@ -143,6 +143,7 @@ public class SummaryFragment extends Fragment { //Add stuff to make it work in WebView //style.css pHtml = ("\n" + + "\n" + "
\n" + pHtml + "\n
"); } else if (!rowText.contains("Name") && !rowText.contains("Όνομα")) { //Doesn't add username twice if (Objects.equals(summaryRow.select("td").get(1).text(), "")) diff --git a/app/src/main/res/layout/fragment_profile_latest_posts.xml b/app/src/main/res/layout/fragment_profile_latest_posts.xml index 5802869a..6827530d 100644 --- a/app/src/main/res/layout/fragment_profile_latest_posts.xml +++ b/app/src/main/res/layout/fragment_profile_latest_posts.xml @@ -3,12 +3,14 @@ xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" - android:background="@color/background_light"> + android:background="@color/background_lighter"> \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_profile_latest_posts_row.xml b/app/src/main/res/layout/fragment_profile_latest_posts_row.xml index 23412289..bf992123 100644 --- a/app/src/main/res/layout/fragment_profile_latest_posts_row.xml +++ b/app/src/main/res/layout/fragment_profile_latest_posts_row.xml @@ -1,61 +1,82 @@ - + android:layout_marginBottom="2dp"> - - - - - - - - + android:layout_height="match_parent" + android:layout_gravity="center" + android:foreground="?android:attr/selectableItemBackground" + card_view:cardBackgroundColor="@color/background" + card_view:cardCornerRadius="5dp" + card_view:cardElevation="2dp" + card_view:cardPreventCornerOverlap="false" + card_view:cardUseCompatPadding="true"> - + android:layout_height="wrap_content"> - - - - \ No newline at end of file + android:background="?android:attr/selectableItemBackground" + android:clickable="true" + android:focusable="true" + android:paddingStart="10dp" + android:paddingEnd="10dp" + android:paddingTop="8dp"> + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_profile_stats.xml b/app/src/main/res/layout/fragment_profile_stats.xml index 54e7bbbd..745ef986 100644 --- a/app/src/main/res/layout/fragment_profile_stats.xml +++ b/app/src/main/res/layout/fragment_profile_stats.xml @@ -2,17 +2,16 @@ + android:layout_height="match_parent"> + android:paddingTop="4dp" + android:paddingStart="16dp" + android:paddingEnd="16dp" + android:paddingBottom="4dp" + android:background="@color/background_lighter"> diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index d668b8d2..71091412 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -16,6 +16,7 @@ #757575 #323232 #3C3F41 + #434649 #8B8B8B #FF9800 #FAA61A