// Path: app/src/main/java/fr/corenting/edcompanion/utils/MiscUtils.java
// public class MiscUtils {
// 
//     public static void putTextInClipboard(Context ctx, String label, String content,
//                                           boolean displayNotification) {
//         try {
//             ClipboardManager clipboard = (ClipboardManager)
//                     ctx.getSystemService(Context.CLIPBOARD_SERVICE);
//             if (clipboard == null) {
//                 throw new Exception(ctx.getString(R.string.content_copied_to_clipboard_error));
//             }
//             ClipData clip = ClipData.newPlainText(label, content);
//             clipboard.setPrimaryClip(clip);
// 
//             if (displayNotification) {
//                 Toast t = Toast.makeText(ctx, R.string.content_copied_to_clipboard, Toast.LENGTH_SHORT);
//                 t.show();
//             }
//         } catch (Exception e) {
// 
//             if (displayNotification) {
//                 Toast t = Toast.makeText(ctx, R.string.content_copied_to_clipboard_error,
//                         Toast.LENGTH_SHORT);
//                 t.show();
//             }
// 
//         }
//     }
// 
//     public static void startIntentWithFadeAnimation(Context ctx, Intent i) {
//         Bundle bundle = ActivityOptionsCompat.makeCustomAnimation(ctx,
//                 android.R.anim.fade_in, android.R.anim.fade_out).toBundle();
// 
//         ctx.startActivity(i, bundle);
//     }
// 
//     public static void startIntentToSystemDetails(Context ctx, String systemName) {
//         Intent i = new Intent(ctx, SystemDetailsActivity.class);
//         i.putExtra("data", systemName);
//         ctx.startActivity(i);
//     }
// 
//     public static void setTextFromHtml(TextView textView, String text) {
//         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
//             textView.setText(Html.fromHtml(text, Html.FROM_HTML_MODE_COMPACT));
//         } else {
//             textView.setText(Html.fromHtml(text));
//         }
//         textView.setMovementMethod(LinkMovementMethod.getInstance());
//     }
// }


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.DiffUtil;
import androidx.recyclerview.widget.ListAdapter;
import androidx.recyclerview.widget.RecyclerView;
import fr.corenting.edcompanion.R;
import fr.corenting.edcompanion.activities.DetailsActivity;
import fr.corenting.edcompanion.databinding.ListItemCommunityGoalBinding;
import fr.corenting.edcompanion.models.CommunityGoal;
import fr.corenting.edcompanion.utils.MiscUtils;
    }

    @Override
    public long getItemId(int position) {
        final CommunityGoal currentGoal = getItem(position);
        return currentGoal.getId();
    }

    @NonNull
    @Override
    public goalsViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        ListItemCommunityGoalBinding itemBinding = ListItemCommunityGoalBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);

        if (!isDetailsView) {
            itemBinding.getRoot().setOnClickListener(onClickListener);
        }
        return new goalsViewHolder(itemBinding);
    }

    @Override
    public void onBindViewHolder(@NonNull final goalsViewHolder holder, final int position) {
        final CommunityGoal currentGoal = getItem(holder.getAdapterPosition());

        // Content
        holder.viewBinding.titleTextView.setText(currentGoal.getTitle());
        holder.viewBinding.updateTextView.setText(currentGoal.getRefreshDateString(context));
        holder.viewBinding.peopleTextView.setText(context.getString(R.string.cg_contributors,
                String.valueOf(currentGoal.getContributors())));
        holder.viewBinding.remainingTextView.setText(context.getString(R.string.cg_end_date,
                currentGoal.getEndDate(context)));
// Path: app/src/main/java/fr/corenting/edcompanion/utils/MiscUtils.java
// public class MiscUtils {
// 
//     public static void putTextInClipboard(Context ctx, String label, String content,
//                                           boolean displayNotification) {
//         try {
//             ClipboardManager clipboard = (ClipboardManager)
//                     ctx.getSystemService(Context.CLIPBOARD_SERVICE);
//             if (clipboard == null) {
//                 throw new Exception(ctx.getString(R.string.content_copied_to_clipboard_error));
//             }
//             ClipData clip = ClipData.newPlainText(label, content);
//             clipboard.setPrimaryClip(clip);
// 
//             if (displayNotification) {
//                 Toast t = Toast.makeText(ctx, R.string.content_copied_to_clipboard, Toast.LENGTH_SHORT);
//                 t.show();
//             }
//         } catch (Exception e) {
// 
//             if (displayNotification) {
//                 Toast t = Toast.makeText(ctx, R.string.content_copied_to_clipboard_error,
//                         Toast.LENGTH_SHORT);
//                 t.show();
//             }
// 
//         }
//     }
// 
//     public static void startIntentWithFadeAnimation(Context ctx, Intent i) {
//         Bundle bundle = ActivityOptionsCompat.makeCustomAnimation(ctx,
//                 android.R.anim.fade_in, android.R.anim.fade_out).toBundle();
// 
//         ctx.startActivity(i, bundle);
//     }
// 
//     public static void startIntentToSystemDetails(Context ctx, String systemName) {
//         Intent i = new Intent(ctx, SystemDetailsActivity.class);
//         i.putExtra("data", systemName);
//         ctx.startActivity(i);
//     }
// 
//     public static void setTextFromHtml(TextView textView, String text) {
//         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
//             textView.setText(Html.fromHtml(text, Html.FROM_HTML_MODE_COMPACT));
//         } else {
//             textView.setText(Html.fromHtml(text));
//         }
//         textView.setMovementMethod(LinkMovementMethod.getInstance());
//     }
// }


// Path: app/src/main/java/fr/corenting/edcompanion/adapters/CommunityGoalsAdapter.java
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.DiffUtil;
import androidx.recyclerview.widget.ListAdapter;
import androidx.recyclerview.widget.RecyclerView;
import fr.corenting.edcompanion.R;
import fr.corenting.edcompanion.activities.DetailsActivity;
import fr.corenting.edcompanion.databinding.ListItemCommunityGoalBinding;
import fr.corenting.edcompanion.models.CommunityGoal;
import fr.corenting.edcompanion.utils.MiscUtils;

    }

    @Override
    public long getItemId(int position) {
        final CommunityGoal currentGoal = getItem(position);
        return currentGoal.getId();
    }

    @NonNull
    @Override
    public goalsViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        ListItemCommunityGoalBinding itemBinding = ListItemCommunityGoalBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);

        if (!isDetailsView) {
            itemBinding.getRoot().setOnClickListener(onClickListener);
        }
        return new goalsViewHolder(itemBinding);
    }

    @Override
    public void onBindViewHolder(@NonNull final goalsViewHolder holder, final int position) {
        final CommunityGoal currentGoal = getItem(holder.getAdapterPosition());

        // Content
        holder.viewBinding.titleTextView.setText(currentGoal.getTitle());
        holder.viewBinding.updateTextView.setText(currentGoal.getRefreshDateString(context));
        holder.viewBinding.peopleTextView.setText(context.getString(R.string.cg_contributors,
                String.valueOf(currentGoal.getContributors())));
        holder.viewBinding.remainingTextView.setText(context.getString(R.string.cg_end_date,
                currentGoal.getEndDate(context)));
        holder.viewBinding.tierTextView.setText(context.getString(R.string.cg_progress,