Use application context for MarkdownUtils

This commit is contained in:
Balazs Toldi 2023-08-18 23:35:33 +02:00
parent 0f3197d7e4
commit 116deebf87
No known key found for this signature in database
GPG Key ID: 6C7D440036F99D58
6 changed files with 15 additions and 13 deletions

View File

@ -168,7 +168,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
}
return true;
};
mMarkwon = MarkdownUtils.createFullRedditMarkwon(mActivity,
mMarkwon = MarkdownUtils.createFullRedditMarkwon(mActivity.getApplication(),
miscPlugin, mCommentColor, commentSpoilerBackgroundColor, onLinkLongClickListener);
recycledViewPool = new RecyclerView.RecycledViewPool();
}

View File

@ -214,7 +214,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
}
return true;
};
mCommentMarkwon = MarkdownUtils.createFullRedditMarkwon(mActivity,
mCommentMarkwon = MarkdownUtils.createFullRedditMarkwon(mActivity.getApplication(),
miscPlugin, mCommentTextColor, commentSpoilerBackgroundColor, onLinkLongClickListener);
recycledViewPool = new RecyclerView.RecycledViewPool();
mAccessToken = accessToken;

View File

@ -294,7 +294,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
}
return true;
};
mPostDetailMarkwon = MarkdownUtils.createFullRedditMarkwon(mActivity,
mPostDetailMarkwon = MarkdownUtils.createFullRedditMarkwon(mActivity.getApplication(),
miscPlugin, markdownColor, postSpoilerBackgroundColor, onLinkLongClickListener);
mMarkwonAdapter = MarkdownUtils.createTablesAdapter();

View File

@ -16,13 +16,6 @@ import java.util.ArrayList;
import butterknife.BindView;
import butterknife.ButterKnife;
import io.noties.markwon.AbstractMarkwonPlugin;
import io.noties.markwon.Markwon;
import io.noties.markwon.MarkwonConfiguration;
import io.noties.markwon.MarkwonPlugin;
import io.noties.markwon.core.MarkwonTheme;
import io.noties.markwon.recycler.MarkwonAdapter;
import me.saket.bettermovementmethod.BetterLinkMovementMethod;
import eu.toldi.infinityforlemmy.R;
import eu.toldi.infinityforlemmy.Rule;
import eu.toldi.infinityforlemmy.activities.BaseActivity;
@ -33,6 +26,13 @@ import eu.toldi.infinityforlemmy.customviews.SwipeLockInterface;
import eu.toldi.infinityforlemmy.customviews.SwipeLockLinearLayoutManager;
import eu.toldi.infinityforlemmy.customviews.slidr.widget.SliderPanel;
import eu.toldi.infinityforlemmy.markdown.MarkdownUtils;
import io.noties.markwon.AbstractMarkwonPlugin;
import io.noties.markwon.Markwon;
import io.noties.markwon.MarkwonConfiguration;
import io.noties.markwon.MarkwonPlugin;
import io.noties.markwon.core.MarkwonTheme;
import io.noties.markwon.recycler.MarkwonAdapter;
import me.saket.bettermovementmethod.BetterLinkMovementMethod;
public class RulesRecyclerViewAdapter extends RecyclerView.Adapter<RulesRecyclerViewAdapter.RuleViewHolder> {
private BaseActivity activity;
@ -81,7 +81,7 @@ public class RulesRecyclerViewAdapter extends RecyclerView.Adapter<RulesRecycler
}
return true;
};
markwon = MarkdownUtils.createFullRedditMarkwon(activity,
markwon = MarkdownUtils.createFullRedditMarkwon(activity.getApplication(),
miscPlugin, mPrimaryTextColor, spoilerBackgroundColor, onLinkLongClickListener);
}

View File

@ -147,7 +147,7 @@ public class SidebarFragment extends Fragment {
urlMenuBottomSheetFragment.show(getChildFragmentManager(), null);
return true;
};
Markwon markwon = MarkdownUtils.createFullRedditMarkwon(activity,
Markwon markwon = MarkdownUtils.createFullRedditMarkwon(activity.getApplication(),
miscPlugin, markdownColor, spoilerBackgroundColor, onLinkLongClickListener);
MarkwonAdapter markwonAdapter = MarkdownUtils.createTablesAdapter();

View File

@ -1,5 +1,6 @@
package eu.toldi.infinityforlemmy.markdown;
import android.app.Application;
import android.content.Context;
import android.text.util.Linkify;
@ -29,10 +30,11 @@ import me.saket.bettermovementmethod.BetterLinkMovementMethod;
public class MarkdownUtils {
/**
* Creates a Markwon instance with all the plugins required for processing Reddit's markdown.
*
* @return configured Markwon instance
*/
@NonNull
public static Markwon createFullRedditMarkwon(@NonNull Context context,
public static Markwon createFullRedditMarkwon(@NonNull Application context,
@NonNull MarkwonPlugin miscPlugin,
int markdownColor,
int spoilerBackgroundColor,