|
@ -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; |
|
|