From db9c800743e0f62e9e021c6d599af992e98565b3 Mon Sep 17 00:00:00 2001 From: Thodoris1999 Date: Thu, 4 Oct 2018 19:36:53 +0300 Subject: [PATCH] fill in the adapter class --- .../main/shoutbox/ShoutAdapter.java | 107 +++++++++++++++++- .../res/layout/activity_topic_post_row.xml | 3 +- app/src/main/res/layout/shout.xml | 54 ++++++++- 3 files changed, 155 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/main/shoutbox/ShoutAdapter.java b/app/src/main/java/gr/thmmy/mthmmy/activities/main/shoutbox/ShoutAdapter.java index 542d90fc..8f1230ea 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/main/shoutbox/ShoutAdapter.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/main/shoutbox/ShoutAdapter.java @@ -1,30 +1,64 @@ package gr.thmmy.mthmmy.activities.main.shoutbox; +import android.annotation.TargetApi; +import android.content.Context; +import android.content.Intent; +import android.net.Uri; +import android.os.Build; +import android.os.Bundle; +import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.webkit.WebResourceRequest; +import android.webkit.WebView; +import android.webkit.WebViewClient; +import android.widget.TextView; import java.util.ArrayList; import androidx.annotation.NonNull; +import gr.thmmy.mthmmy.R; +import gr.thmmy.mthmmy.activities.board.BoardActivity; +import gr.thmmy.mthmmy.activities.profile.ProfileActivity; +import gr.thmmy.mthmmy.activities.topic.TopicActivity; import gr.thmmy.mthmmy.model.Shout; +import gr.thmmy.mthmmy.model.ThmmyPage; import gr.thmmy.mthmmy.utils.CustomRecyclerView; +import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; +import static gr.thmmy.mthmmy.activities.board.BoardActivity.BUNDLE_BOARD_TITLE; +import static gr.thmmy.mthmmy.activities.board.BoardActivity.BUNDLE_BOARD_URL; +import static gr.thmmy.mthmmy.activities.profile.ProfileActivity.BUNDLE_PROFILE_THUMBNAIL_URL; +import static gr.thmmy.mthmmy.activities.profile.ProfileActivity.BUNDLE_PROFILE_URL; +import static gr.thmmy.mthmmy.activities.profile.ProfileActivity.BUNDLE_PROFILE_USERNAME; +import static gr.thmmy.mthmmy.activities.topic.TopicActivity.BUNDLE_TOPIC_URL; + public class ShoutAdapter extends CustomRecyclerView.Adapter { + private Context context; private ArrayList shouts; - public ShoutAdapter(ArrayList shouts) { + public ShoutAdapter(Context context, ArrayList shouts) { + this.context = context; this.shouts = shouts; } @NonNull @Override public ShoutViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { - return null; + View view = LayoutInflater.from(parent.getContext()) + .inflate(R.layout.shout, parent, false); + return new ShoutViewHolder(view); } @Override public void onBindViewHolder(@NonNull ShoutViewHolder holder, int position) { - + Shout currentShout = shouts.get(position); + holder.author.setText(currentShout.getShouter()); + holder.dateTime.setText(currentShout.getDate()); + holder.shoutContent.setClickable(true); + holder.shoutContent.setWebViewClient(new LinkLauncher()); + holder.shoutContent.loadDataWithBaseURL("file:///android_asset/", currentShout.getShout(), + "text/html", "UTF-8", null); } @Override @@ -34,8 +68,73 @@ public class ShoutAdapter extends CustomRecyclerView.Adapter + android:textSize="11sp" + tools:text="date"/> - + - \ No newline at end of file + + + + + + + + + \ No newline at end of file