Reputation: 3
I'm developing an app that allows users to copy ASCII art and paste it wherever they need. I prompt users to specify the final destination, such as the comment section on Instagram, as most of the text will be shared there. However, there are issues with character disorientation for certain ASCII art. While I can manually adjust a few instances, there are numerous cases where it's not feasible to verify the proper display on Instagram.
I attempted to resolve this by adding
tags as replacements for newlines (/n), but this approach only works effectively for webpages and not apps.
Adapter Class
public void onBindViewHolder(@NonNull MemeViewHolder holder, int position) {
try {
YourClass yourClass = new YourClass();
yourClass.intertitalAd(context);
final String meme = memeList.get(position);
holder.memeTextView.setText(meme);
if (position == 0) {
holder.copyImageView.setVisibility(View.VISIBLE);
holder.lockImageView.setVisibility(View.GONE);
} else if (mSharedPrefs.getBoolean(REWARD_GRANTED_KEY, false)) {
holder.copyImageView.setVisibility(View.VISIBLE);
holder.lockImageView.setVisibility(View.GONE);
} else {
holder.copyImageView.setVisibility(View.GONE);
holder.lockImageView.setVisibility(View.VISIBLE);
}
holder.copyImageView.setOnClickListener(v -> {
try {
String newAsciiArt = meme.replaceAll("\n", "<br>");
clickCounter++;
ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("meme", newAsciiArt);
if (clickCounter == 2) {
if (mInterstitialAd != null) {
mInterstitialAd.show(binding);
}
clipboard.setPrimaryClip(clip);
Toast.makeText(context, "Copied", Toast.LENGTH_SHORT).show();
} else {
clipboard.setPrimaryClip(clip);
Toast.makeText(context, "Copied", Toast.LENGTH_SHORT).show();
}
} catch (Exception e) {
e.printStackTrace();
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
Upvotes: 0
Views: 296