Browse Source

LatestPosts flickering and wrong avatars fixes

pull/61/merge
Ezerous 6 years ago
parent
commit
d465350358
No known key found for this signature in database GPG Key ID: 262B2954BBA319E3
  1. 16
      app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsAdapter.java
  2. 14
      app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsFragment.java
  3. 3
      app/src/main/res/layout-v21/activity_topic_post_row.xml
  4. 3
      app/src/main/res/layout/activity_topic_post_row.xml
  5. 2
      build.gradle

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

@ -1,5 +1,6 @@
package gr.thmmy.mthmmy.activities.profile.latestPosts; package gr.thmmy.mthmmy.activities.profile.latestPosts;
import android.graphics.Color;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -21,10 +22,10 @@ import me.zhanghai.android.materialprogressbar.MaterialProgressBar;
* specified {@link LatestPostsFragment.LatestPostsFragmentInteractionListener}. * specified {@link LatestPostsFragment.LatestPostsFragmentInteractionListener}.
*/ */
class LatestPostsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { class LatestPostsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private final int VIEW_TYPE_EMPTY = -1; private static final int VIEW_TYPE_EMPTY = -1;
private final int VIEW_TYPE_ITEM = 0; private static final int VIEW_TYPE_ITEM = 0;
private final int VIEW_TYPE_LOADING = 1; private static final int VIEW_TYPE_LOADING = 1;
final private LatestPostsFragment.LatestPostsFragmentInteractionListener interactionListener; private final LatestPostsFragment.LatestPostsFragmentInteractionListener interactionListener;
private final ArrayList<PostSummary> parsedTopicSummaries; private final ArrayList<PostSummary> parsedTopicSummaries;
LatestPostsAdapter(BaseFragment.FragmentInteractionListener interactionListener, LatestPostsAdapter(BaseFragment.FragmentInteractionListener interactionListener,
@ -70,20 +71,17 @@ class LatestPostsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
latestPostViewHolder.postTitle.setText(topic.getSubject()); latestPostViewHolder.postTitle.setText(topic.getSubject());
latestPostViewHolder.postDate.setText(topic.getDateTime()); latestPostViewHolder.postDate.setText(topic.getDateTime());
latestPostViewHolder.post.setBackgroundColor(Color.argb(1, 255, 255, 255));
latestPostViewHolder.post.loadDataWithBaseURL("file:///android_asset/" latestPostViewHolder.post.loadDataWithBaseURL("file:///android_asset/"
, topic.getPost(), "text/html", "UTF-8", null); , topic.getPost(), "text/html", "UTF-8", null);
latestPostViewHolder.latestPostsRow.setOnClickListener(new View.OnClickListener() { latestPostViewHolder.latestPostsRow.setOnClickListener(v -> {
@Override
public void onClick(View v) {
if (interactionListener != null) { if (interactionListener != null) {
// Notify the active callbacks interface (the activity, if the // Notify the active callbacks interface (the activity, if the
// fragment is attached to one) that a post has been selected. // fragment is attached to one) that a post has been selected.
interactionListener.onLatestPostsFragmentInteraction( interactionListener.onLatestPostsFragmentInteraction(
parsedTopicSummaries.get(holder.getAdapterPosition())); parsedTopicSummaries.get(holder.getAdapterPosition()));
} }
}
}); });
} else if (holder instanceof LoadingViewHolder) { } else if (holder instanceof LoadingViewHolder) {
LoadingViewHolder loadingViewHolder = (LoadingViewHolder) holder; LoadingViewHolder loadingViewHolder = (LoadingViewHolder) holder;

14
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"); profileLatestPostsTask.execute(profileUrl + ";sa=showPosts");
pagesLoaded = 1; pagesLoaded = 1;
} }
Timber.d("onActivityCreated");
} }
@Override @Override
@ -193,14 +192,13 @@ public class LatestPostsFragment extends BaseFragment implements LatestPostsAdap
//td:contains( Sorry, no matches were found) //td:contains( Sorry, no matches were found)
Elements latestPostsRows = latestPostsPage. Elements latestPostsRows = latestPostsPage.
select("td:has(table:Contains(Show Posts)):not([style]) > table"); select("td:has(table:Contains(Show Posts)):not([style]) > table");
if (latestPostsRows.isEmpty()) { if (latestPostsRows.isEmpty())
latestPostsRows = latestPostsPage. latestPostsRows = latestPostsPage.
select("td:has(table:Contains(Εμφάνιση μηνυμάτων)):not([style]) > table"); select("td:has(table:Contains(Εμφάνιση μηνυμάτων)):not([style]) > table");
}
//Removes loading item //Removes loading item
if (isLoadingMore) { if (isLoadingMore)
parsedTopicSummaries.remove(parsedTopicSummaries.size() - 1); parsedTopicSummaries.remove(parsedTopicSummaries.size() - 1);
}
if (!latestPostsRows.select("td:contains(Sorry, no matches were found)").isEmpty() || if (!latestPostsRows.select("td:contains(Sorry, no matches were found)").isEmpty() ||
!latestPostsRows.select("td:contains(Δυστυχώς δεν βρέθηκε τίποτα)").isEmpty()){ !latestPostsRows.select("td:contains(Δυστυχώς δεν βρέθηκε τίποτα)").isEmpty()){
@ -222,10 +220,10 @@ public class LatestPostsFragment extends BaseFragment implements LatestPostsAdap
} }
} else { } else {
Elements rowHeader = row.select("td.middletext"); Elements rowHeader = row.select("td.middletext");
if (rowHeader.size() != 2) { if (rowHeader.size() != 2)
return false; return false;
} else { else {
pTopicTitle = rowHeader.first().text().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();
} }

3
app/src/main/res/layout-v21/activity_topic_post_row.xml

@ -58,7 +58,8 @@
android:layout_gravity="center" android:layout_gravity="center"
android:adjustViewBounds="true" android:adjustViewBounds="true"
android:contentDescription="@string/post_thumbnail" android:contentDescription="@string/post_thumbnail"
android:transitionName="user_thumbnail" /> android:transitionName="user_thumbnail"
app:srcCompat="@drawable/ic_default_user_avatar_darker" />
</FrameLayout> </FrameLayout>
<TextView <TextView

3
app/src/main/res/layout/activity_topic_post_row.xml

@ -57,7 +57,8 @@
android:layout_height="@dimen/thumbnail_size" android:layout_height="@dimen/thumbnail_size"
android:layout_gravity="center" android:layout_gravity="center"
android:adjustViewBounds="true" android:adjustViewBounds="true"
android:contentDescription="@string/post_thumbnail" /> android:contentDescription="@string/post_thumbnail"
app:srcCompat="@drawable/ic_default_user_avatar_darker" />
</FrameLayout> </FrameLayout>
<TextView <TextView

2
build.gradle

@ -11,7 +11,7 @@ buildscript {
classpath 'com.android.tools.build:gradle:3.2.1' classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:4.2.0' classpath 'com.google.gms:google-services:4.2.0'
classpath 'io.fabric.tools:gradle:1.26.1' classpath 'io.fabric.tools:gradle:1.26.1'
classpath 'org.ajoberstar.grgit:grgit-core:3.0.0' classpath 'org.ajoberstar.grgit:grgit-core:3.0.0' // Also change in app/gradle/grgit.gradle
} }
} }

Loading…
Cancel
Save