aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/Settings/AcknowledgementRecyclerViewAdapter.java
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2019-08-24 08:27:34 +0000
committerAlex Ning <chineseperson5@gmail.com>2019-08-24 08:27:34 +0000
commit4d4e6165f0e1bcd72c54fa015a9e1112103e9062 (patch)
treeba276cfc847fd2addc888078784998a2df957554 /app/src/main/java/Settings/AcknowledgementRecyclerViewAdapter.java
parent4a3266e68994b55bf1fc40256cd65c3ac831d2e8 (diff)
downloadinfinity-for-reddit-4d4e6165f0e1bcd72c54fa015a9e1112103e9062.tar
infinity-for-reddit-4d4e6165f0e1bcd72c54fa015a9e1112103e9062.tar.gz
infinity-for-reddit-4d4e6165f0e1bcd72c54fa015a9e1112103e9062.tar.bz2
infinity-for-reddit-4d4e6165f0e1bcd72c54fa015a9e1112103e9062.tar.lz
infinity-for-reddit-4d4e6165f0e1bcd72c54fa015a9e1112103e9062.tar.xz
infinity-for-reddit-4d4e6165f0e1bcd72c54fa015a9e1112103e9062.tar.zst
infinity-for-reddit-4d4e6165f0e1bcd72c54fa015a9e1112103e9062.zip
Add an acknowledgement page in settings.
Diffstat (limited to '')
-rw-r--r--app/src/main/java/Settings/AcknowledgementRecyclerViewAdapter.java67
1 files changed, 67 insertions, 0 deletions
diff --git a/app/src/main/java/Settings/AcknowledgementRecyclerViewAdapter.java b/app/src/main/java/Settings/AcknowledgementRecyclerViewAdapter.java
new file mode 100644
index 00000000..81286903
--- /dev/null
+++ b/app/src/main/java/Settings/AcknowledgementRecyclerViewAdapter.java
@@ -0,0 +1,67 @@
+package Settings;
+
+import android.content.Context;
+import android.content.Intent;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
+
+import java.util.ArrayList;
+
+import butterknife.BindView;
+import butterknife.ButterKnife;
+import ml.docilealligator.infinityforreddit.LinkResolverActivity;
+import ml.docilealligator.infinityforreddit.R;
+
+class AcknowledgementRecyclerViewAdapter extends RecyclerView.Adapter<AcknowledgementRecyclerViewAdapter.AcknowledgementViewHolder> {
+ private ArrayList<Acknowledgement> acknowledgements;
+ private Context context;
+
+ AcknowledgementRecyclerViewAdapter(Context context, ArrayList<Acknowledgement> acknowledgements) {
+ this.context = context;
+ this.acknowledgements = acknowledgements;
+ }
+
+ @NonNull
+ @Override
+ public AcknowledgementViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
+ return new AcknowledgementViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_acknowledgement, parent, false));
+ }
+
+ @Override
+ public void onBindViewHolder(@NonNull AcknowledgementViewHolder holder, int position) {
+ Acknowledgement acknowledgement = acknowledgements.get(holder.getAdapterPosition());
+ if(acknowledgement != null) {
+ holder.nameTextView.setText(acknowledgement.getName());
+ holder.introductionTextView.setText(acknowledgement.getIntroduction());
+ holder.itemView.setOnClickListener(view -> {
+ if(context != null) {
+ Intent intent = new Intent(context, LinkResolverActivity.class);
+ intent.setData(acknowledgement.getLink());
+ context.startActivity(intent);
+ }
+ });
+ }
+ }
+
+ @Override
+ public int getItemCount() {
+ return acknowledgements == null ? 0 : acknowledgements.size();
+ }
+
+ class AcknowledgementViewHolder extends RecyclerView.ViewHolder {
+ View itemView;
+ @BindView(R.id.name_text_view_item_acknowledgement) TextView nameTextView;
+ @BindView(R.id.introduction_text_view_item_acknowledgement) TextView introductionTextView;
+
+ AcknowledgementViewHolder(@NonNull View itemView) {
+ super(itemView);
+ ButterKnife.bind(this, itemView);
+ this.itemView = itemView;
+ }
+ }
+}