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. 26
      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

26
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<RecyclerView.ViewHolder> {
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<PostSummary> parsedTopicSummaries;
LatestPostsAdapter(BaseFragment.FragmentInteractionListener interactionListener,
@ -70,19 +71,16 @@ class LatestPostsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
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) {

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

3
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" />
</FrameLayout>
<TextView

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

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

2
build.gradle

@ -11,7 +11,7 @@ buildscript {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:4.2.0'
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