Browse Source

LatestPostsFragment improvements

pull/70/head
Ezerous 4 years ago
parent
commit
3dff698502
  1. 1
      app/src/main/AndroidManifest.xml
  2. 11
      app/src/main/assets/style_dark.css
  3. 11
      app/src/main/assets/style_light.css
  4. 12
      app/src/main/java/gr/thmmy/mthmmy/activities/profile/ProfileActivity.java
  5. 2
      app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsAdapter.java
  6. 11
      app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsFragment.java
  7. 1
      app/src/main/java/gr/thmmy/mthmmy/activities/profile/summary/SummaryFragment.java
  8. 4
      app/src/main/res/layout/fragment_profile_latest_posts.xml
  9. 121
      app/src/main/res/layout/fragment_profile_latest_posts_row.xml
  10. 13
      app/src/main/res/layout/fragment_profile_stats.xml
  11. 2
      app/src/main/res/layout/fragment_profile_summary.xml
  12. 1
      app/src/main/res/values/colors.xml

1
app/src/main/AndroidManifest.xml

@ -96,6 +96,7 @@
</activity> </activity>
<activity <activity
android:name=".activities.profile.ProfileActivity" android:name=".activities.profile.ProfileActivity"
android:configChanges="orientation|screenSize"
android:theme="@style/AppTheme.NoActionBar" /> android:theme="@style/AppTheme.NoActionBar" />
<activity <activity
android:name=".activities.board.BoardActivity" android:name=".activities.board.BoardActivity"

11
app/src/main/assets/style_dark.css

@ -0,0 +1,11 @@
body {
background: #323232 !important;
}
.post, .personalmessage {
background: #323232 !important;
}
.customSignature {
background: #323232 !important;
}

11
app/src/main/assets/style_light.css

@ -0,0 +1,11 @@
body {
background: #434649 !important;
}
.post, .personalmessage {
background: #434649 !important;
}
.customSignature {
background: #434649 !important;
}

12
app/src/main/java/gr/thmmy/mthmmy/activities/profile/ProfileActivity.java

@ -18,6 +18,7 @@ import android.widget.ProgressBar;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatDelegate; import androidx.appcompat.app.AppCompatDelegate;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentManager;
@ -374,17 +375,17 @@ public class ProfileActivity extends BaseActivity implements LatestPostsFragment
*/ */
private void setupViewPager(ViewPager viewPager, Document profilePage) { private void setupViewPager(ViewPager viewPager, Document profilePage) {
ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager()); ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager());
adapter.addFrag(SummaryFragment.newInstance(profilePage), "SUMMARY"); adapter.addFragment(SummaryFragment.newInstance(profilePage), "SUMMARY");
LatestPostsFragment latestPostsFragment = LatestPostsFragment.newInstance(profileUrl); LatestPostsFragment latestPostsFragment = LatestPostsFragment.newInstance(profileUrl);
latestPostsFragment.setOnLoadingListener(this); latestPostsFragment.setOnLoadingListener(this);
adapter.addFrag(latestPostsFragment, "LATEST POSTS"); adapter.addFragment(latestPostsFragment, "LATEST POSTS");
StatsFragment statsFragment = StatsFragment.newInstance(profileUrl); StatsFragment statsFragment = StatsFragment.newInstance(profileUrl);
statsFragment.setOnLoadingListener(this); statsFragment.setOnLoadingListener(this);
adapter.addFrag(statsFragment, "STATS"); adapter.addFragment(statsFragment, "STATS");
viewPager.setAdapter(adapter); viewPager.setAdapter(adapter);
} }
private class ViewPagerAdapter extends FragmentPagerAdapter { private static class ViewPagerAdapter extends FragmentPagerAdapter {
private final List<Fragment> mFragmentList = new ArrayList<>(); private final List<Fragment> mFragmentList = new ArrayList<>();
private final List<String> mFragmentTitleList = new ArrayList<>(); private final List<String> mFragmentTitleList = new ArrayList<>();
@ -392,6 +393,7 @@ public class ProfileActivity extends BaseActivity implements LatestPostsFragment
super(manager); super(manager);
} }
@NonNull
@Override @Override
public Fragment getItem(int position) { public Fragment getItem(int position) {
return mFragmentList.get(position); return mFragmentList.get(position);
@ -402,7 +404,7 @@ public class ProfileActivity extends BaseActivity implements LatestPostsFragment
return mFragmentList.size(); return mFragmentList.size();
} }
void addFrag(Fragment fragment, String title) { void addFragment(Fragment fragment, String title) {
mFragmentList.add(fragment); mFragmentList.add(fragment);
mFragmentTitleList.add(title); mFragmentTitleList.add(title);
} }

2
app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsAdapter.java

@ -92,7 +92,7 @@ class LatestPostsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
LatestPostViewHolder(View itemView) { LatestPostViewHolder(View itemView) {
super(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); postTitle = itemView.findViewById(R.id.title);
postDate = itemView.findViewById(R.id.date); postDate = itemView.findViewById(R.id.date);
post = itemView.findViewById(R.id.post); post = itemView.findViewById(R.id.post);

11
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 android.view.ViewGroup;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
@ -90,9 +89,6 @@ public class LatestPostsFragment extends BaseFragment {
recyclerView.setAdapter(latestPostsAdapter); recyclerView.setAdapter(latestPostsAdapter);
final LinearLayoutManager layoutManager = new LinearLayoutManager(getContext()); final LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
recyclerView.setLayoutManager(layoutManager); recyclerView.setLayoutManager(layoutManager);
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(recyclerView.getContext(),
layoutManager.getOrientation());
recyclerView.addItemDecoration(dividerItemDecoration);
recyclerView.setItemViewCacheSize(15); recyclerView.setItemViewCacheSize(15);
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@ -190,7 +186,6 @@ public class LatestPostsFragment extends BaseFragment {
int prevSize = parsedTopicSummaries.size(); int prevSize = parsedTopicSummaries.size();
parsedTopicSummaries.addAll(fetchedParsedTopicSummaries); parsedTopicSummaries.addAll(fetchedParsedTopicSummaries);
latestPostsAdapter.notifyItemRangeInserted(prevSize, parsedTopicSummaries.size() - prevSize); latestPostsAdapter.notifyItemRangeInserted(prevSize, parsedTopicSummaries.size() - prevSize);
latestPostsAdapter.notifyDataSetChanged();
isLoadingMore = false; isLoadingMore = false;
onLoadingListener.onLoadingLatestPosts(false); onLoadingListener.onLoadingLatestPosts(false);
} }
@ -228,13 +223,15 @@ public class LatestPostsFragment extends BaseFragment {
else { else {
pTopicTitle = rowHeader.first().text().replaceAll("\\u00a0","").trim(); pTopicTitle = rowHeader.first().text().replaceAll("\\u00a0","").trim();
pTopicUrl = rowHeader.first().select("a").last().attr("href"); 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()); pPost = ParseHelpers.youtubeEmbeddedFix(row.select("div.post").first());
//Add stuff to make it work in WebView //Add stuff to make it work in WebView
//style.css //style.css
pPost = ("<link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\" />" + pPost); pPost = ("<link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\" />"
+ "<link rel=\"stylesheet\" type=\"text/css\" href=\"style_dark.css\" />"
+ pPost);
fetchedParsedTopicSummaries.add(new PostSummary(pTopicUrl, pTopicTitle, pDateTime, pPost)); fetchedParsedTopicSummaries.add(new PostSummary(pTopicUrl, pTopicTitle, pDateTime, pPost));
} }

1
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 //Add stuff to make it work in WebView
//style.css //style.css
pHtml = ("<link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\" />\n" + pHtml = ("<link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\" />\n" +
"<link rel=\"stylesheet\" type=\"text/css\" href=\"style_light.css\" />\n" +
"<div class=\"customSignature\">\n" + pHtml + "\n</div>"); "<div class=\"customSignature\">\n" + pHtml + "\n</div>");
} else if (!rowText.contains("Name") && !rowText.contains("Όνομα")) { //Doesn't add username twice } else if (!rowText.contains("Name") && !rowText.contains("Όνομα")) { //Doesn't add username twice
if (Objects.equals(summaryRow.select("td").get(1).text(), "")) if (Objects.equals(summaryRow.select("td").get(1).text(), ""))

4
app/src/main/res/layout/fragment_profile_latest_posts.xml

@ -3,12 +3,14 @@
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/background_light"> android:background="@color/background_lighter">
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/profile_latest_posts_recycler" android:id="@+id/profile_latest_posts_recycler"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:padding="4dp"
android:clipToPadding = "false"
android:scrollbars="none"> android:scrollbars="none">
</androidx.recyclerview.widget.RecyclerView> </androidx.recyclerview.widget.RecyclerView>
</RelativeLayout> </RelativeLayout>

121
app/src/main/res/layout/fragment_profile_latest_posts_row.xml

@ -1,61 +1,82 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<FrameLayout <RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/latest_posts_row"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@color/background_light"> android:layout_marginBottom="2dp">
<RelativeLayout <androidx.cardview.widget.CardView
android:id="@+id/latest_posts_row" xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:background="?android:attr/selectableItemBackground" android:layout_gravity="center"
android:clickable="true" android:foreground="?android:attr/selectableItemBackground"
android:focusable="true" card_view:cardBackgroundColor="@color/background"
android:paddingBottom="6dp" card_view:cardCornerRadius="5dp"
android:paddingLeft="10dp" card_view:cardElevation="2dp"
android:paddingRight="10dp" card_view:cardPreventCornerOverlap="false"
android:paddingTop="6dp"> card_view:cardUseCompatPadding="true">
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:textAppearance="?attr/textAppearanceListItem"
android:textColor="@color/primary_text"/>
<TextView
android:id="@+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="@+id/title"
android:textColor="@color/secondary_text"/>
<View
android:id="@+id/spacer_divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="@+id/date"
android:layout_marginBottom="3dp"
android:layout_marginTop="3dp"
android:background="@color/divider"/>
<FrameLayout <RelativeLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="wrap_content">
android:layout_alignParentStart="true"
android:layout_below="@+id/spacer_divider">
<gr.thmmy.mthmmy.views.ReactiveWebView <RelativeLayout
android:id="@+id/post" android:id="@+id/latest_posts_row_head"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@color/background_light" android:background="?android:attr/selectableItemBackground"
android:text="@string/post"/> android:clickable="true"
</FrameLayout> android:focusable="true"
</RelativeLayout> android:paddingStart="10dp"
</FrameLayout> android:paddingEnd="10dp"
android:paddingTop="8dp">
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:textAppearance="?attr/textAppearanceListItem"
android:textColor="@color/primary_text"/>
<TextView
android:id="@+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="@+id/title"
android:textColor="@color/secondary_text"/>
<View
android:id="@+id/spacer_divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="@+id/date"
android:layout_marginTop="6dp"
android:background="@color/secondary_text"/>
</RelativeLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_below="@+id/latest_posts_row_head"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:paddingTop="6dp"
android:paddingBottom="8dp">
<gr.thmmy.mthmmy.views.ReactiveWebView
android:id="@+id/post"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/background_light"
android:text="@string/post"/>
</FrameLayout>
</RelativeLayout>
</androidx.cardview.widget.CardView>
</RelativeLayout>

13
app/src/main/res/layout/fragment_profile_stats.xml

@ -2,17 +2,16 @@
<RelativeLayout <RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent">
android:background="@color/background_light">
<androidx.core.widget.NestedScrollView <androidx.core.widget.NestedScrollView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginBottom="4dp" android:paddingTop="4dp"
android:layout_marginEnd="16dp" android:paddingStart="16dp"
android:layout_marginStart="16dp" android:paddingEnd="16dp"
android:layout_marginTop="4dp" android:paddingBottom="4dp"
android:background="@color/background_light"> android:background="@color/background_lighter">
<LinearLayout <LinearLayout
android:id="@+id/main_content" android:id="@+id/main_content"

2
app/src/main/res/layout/fragment_profile_summary.xml

@ -4,7 +4,7 @@
android:id="@+id/nested_scroll" android:id="@+id/nested_scroll"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/background_light" android:background="@color/background_lighter"
android:paddingEnd="16dp" android:paddingEnd="16dp"
android:paddingStart="16dp" android:paddingStart="16dp"
android:scrollbars="none"> android:scrollbars="none">

1
app/src/main/res/values/colors.xml

@ -16,6 +16,7 @@
<color name="secondary_text">#757575</color> <color name="secondary_text">#757575</color>
<color name="background">#323232</color> <color name="background">#323232</color>
<color name="background_light">#3C3F41</color> <color name="background_light">#3C3F41</color>
<color name="background_lighter">#434649</color>
<color name="divider">#8B8B8B</color> <color name="divider">#8B8B8B</color>
<color name="link_color">#FF9800</color> <color name="link_color">#FF9800</color>
<color name="mention_color">#FAA61A</color> <color name="mention_color">#FAA61A</color>

Loading…
Cancel
Save