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. 47
      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
android:name=".activities.profile.ProfileActivity"
android:configChanges="orientation|screenSize"
android:theme="@style/AppTheme.NoActionBar" />
<activity
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.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
@ -374,17 +375,17 @@ public class ProfileActivity extends BaseActivity implements LatestPostsFragment
*/
private void setupViewPager(ViewPager viewPager, Document profilePage) {
ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager());
adapter.addFrag(SummaryFragment.newInstance(profilePage), "SUMMARY");
adapter.addFragment(SummaryFragment.newInstance(profilePage), "SUMMARY");
LatestPostsFragment latestPostsFragment = LatestPostsFragment.newInstance(profileUrl);
latestPostsFragment.setOnLoadingListener(this);
adapter.addFrag(latestPostsFragment, "LATEST POSTS");
adapter.addFragment(latestPostsFragment, "LATEST POSTS");
StatsFragment statsFragment = StatsFragment.newInstance(profileUrl);
statsFragment.setOnLoadingListener(this);
adapter.addFrag(statsFragment, "STATS");
adapter.addFragment(statsFragment, "STATS");
viewPager.setAdapter(adapter);
}
private class ViewPagerAdapter extends FragmentPagerAdapter {
private static class ViewPagerAdapter extends FragmentPagerAdapter {
private final List<Fragment> mFragmentList = new ArrayList<>();
private final List<String> 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);
}

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) {
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);

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 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 = ("<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));
}

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
//style.css
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>");
} else if (!rowText.contains("Name") && !rowText.contains("Όνομα")) { //Doesn't add username twice
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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/background_light">
android:background="@color/background_lighter">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/profile_latest_posts_recycler"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="4dp"
android:clipToPadding = "false"
android:scrollbars="none">
</androidx.recyclerview.widget.RecyclerView>
</RelativeLayout>

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

@ -1,21 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/latest_posts_row"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/background_light">
android:layout_marginBottom="2dp">
<androidx.cardview.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_view"
android:layout_width="match_parent"
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">
<RelativeLayout
android:id="@+id/latest_posts_row"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="@+id/latest_posts_row_head"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:paddingBottom="6dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="6dp">
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:paddingTop="8dp">
<TextView
android:id="@+id/title"
@ -34,21 +51,24 @@
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"/>
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/spacer_divider">
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"
@ -58,4 +78,5 @@
android:text="@string/post"/>
</FrameLayout>
</RelativeLayout>
</FrameLayout>
</androidx.cardview.widget.CardView>
</RelativeLayout>

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

@ -2,17 +2,16 @@
<RelativeLayout
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:layout_height="match_parent">
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="4dp"
android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="4dp"
android:background="@color/background_light">
android:paddingTop="4dp"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:paddingBottom="4dp"
android:background="@color/background_lighter">
<LinearLayout
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:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/background_light"
android:background="@color/background_lighter"
android:paddingEnd="16dp"
android:paddingStart="16dp"
android:scrollbars="none">

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

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

Loading…
Cancel
Save