Lambda
This commit is contained in:
parent
a9bccdeadd
commit
670ba768c2
|
@ -1233,30 +1233,27 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
holder.status_action_container.setVisibility(View.GONE);
|
||||
if( holder.status_action_container_twitter != null){
|
||||
holder.status_action_container_twitter.setVisibility(View.VISIBLE);
|
||||
holder.status_action_container_twitter.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent sendIntent = new Intent(Intent.ACTION_SEND);
|
||||
sendIntent.putExtra(Intent.EXTRA_SUBJECT, context.getString(R.string.shared_via));
|
||||
String url = status.getUrl();
|
||||
String extra_text;
|
||||
holder.status_action_container_twitter.setOnClickListener(v -> {
|
||||
Intent sendIntent = new Intent(Intent.ACTION_SEND);
|
||||
sendIntent.putExtra(Intent.EXTRA_SUBJECT, context.getString(R.string.shared_via));
|
||||
String url = status.getUrl();
|
||||
String extra_text;
|
||||
|
||||
extra_text = (status.getReblog() != null) ? status.getReblog().getAccount().getAcct() : status.getAccount().getAcct();
|
||||
if (extra_text.split("@").length == 1)
|
||||
extra_text = "@" + extra_text + "@" + Helper.getLiveInstance(context);
|
||||
else
|
||||
extra_text = "@" + extra_text;
|
||||
extra_text += " " + Helper.shortnameToUnicode(":link:", true) + " " + url + "\r\n-\n";
|
||||
final String contentToot;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||
contentToot = Html.fromHtml((status.getReblog() != null) ? status.getReblog().getContent() : status.getContent(), Html.FROM_HTML_MODE_LEGACY).toString();
|
||||
else
|
||||
contentToot = Html.fromHtml((status.getReblog() != null) ? status.getReblog().getContent() : status.getContent()).toString();
|
||||
extra_text += contentToot;
|
||||
sendIntent.putExtra(Intent.EXTRA_TEXT, extra_text);
|
||||
sendIntent.setType("text/plain");
|
||||
context.startActivity(Intent.createChooser(sendIntent, context.getString(R.string.share_with)));
|
||||
}
|
||||
extra_text = (status.getReblog() != null) ? status.getReblog().getAccount().getAcct() : status.getAccount().getAcct();
|
||||
if (extra_text.split("@").length == 1)
|
||||
extra_text = "@" + extra_text + "@" + Helper.getLiveInstance(context);
|
||||
else
|
||||
extra_text = "@" + extra_text;
|
||||
extra_text += " " + Helper.shortnameToUnicode(":link:", true) + " " + url + "\r\n-\n";
|
||||
final String contentToot;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||
contentToot = Html.fromHtml((status.getReblog() != null) ? status.getReblog().getContent() : status.getContent(), Html.FROM_HTML_MODE_LEGACY).toString();
|
||||
else
|
||||
contentToot = Html.fromHtml((status.getReblog() != null) ? status.getReblog().getContent() : status.getContent()).toString();
|
||||
extra_text += contentToot;
|
||||
sendIntent.putExtra(Intent.EXTRA_TEXT, extra_text);
|
||||
sendIntent.setType("text/plain");
|
||||
context.startActivity(Intent.createChooser(sendIntent, context.getString(R.string.share_with)));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1321,26 +1318,23 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
CrossActions.doCrossConversation(context, status);
|
||||
}
|
||||
});
|
||||
holder.main_container.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (type != RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE && type != RetrieveFeedsAsyncTask.Type.NEWS) {
|
||||
Intent intent = new Intent(context, ShowConversationActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
if (social == UpdateAccountInfoAsyncTask.SOCIAL.GNU || social == UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA)
|
||||
b.putString("conversationId", status.getConversationId());
|
||||
if (status.getReblog() == null)
|
||||
b.putParcelable("status", status);
|
||||
else
|
||||
b.putParcelable("status", status.getReblog());
|
||||
intent.putExtras(b);
|
||||
if (type == RetrieveFeedsAsyncTask.Type.CONTEXT)
|
||||
((Activity) context).finish();
|
||||
context.startActivity(intent);
|
||||
} else {
|
||||
if (social != UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE)
|
||||
CrossActions.doCrossConversation(context, status);
|
||||
}
|
||||
holder.main_container.setOnClickListener(v -> {
|
||||
if (type != RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE && type != RetrieveFeedsAsyncTask.Type.NEWS) {
|
||||
Intent intent = new Intent(context, ShowConversationActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
if (social == UpdateAccountInfoAsyncTask.SOCIAL.GNU || social == UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA)
|
||||
b.putString("conversationId", status.getConversationId());
|
||||
if (status.getReblog() == null)
|
||||
b.putParcelable("status", status);
|
||||
else
|
||||
b.putParcelable("status", status.getReblog());
|
||||
intent.putExtras(b);
|
||||
if (type == RetrieveFeedsAsyncTask.Type.CONTEXT)
|
||||
((Activity) context).finish();
|
||||
context.startActivity(intent);
|
||||
} else {
|
||||
if (social != UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE)
|
||||
CrossActions.doCrossConversation(context, status);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1396,7 +1390,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
},
|
||||
0, (acctSpan.length() - 3),
|
||||
Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
SpannableString startingSpan = new SpannableString(starting);
|
||||
SpannableString startingSpan;
|
||||
if (acctReblogSpan != null) {
|
||||
for (URLSpan span : urls)
|
||||
acctReblogSpan.removeSpan(span);
|
||||
|
@ -1488,12 +1482,9 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
holder.status_show_more_content.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
holder.status_show_more_content.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
status.setExpanded(!status.isExpanded());
|
||||
notifyStatusChanged(status);
|
||||
}
|
||||
holder.status_show_more_content.setOnClickListener(v -> {
|
||||
status.setExpanded(!status.isExpanded());
|
||||
notifyStatusChanged(status);
|
||||
});
|
||||
|
||||
|
||||
|
@ -1559,26 +1550,23 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
if (status.isFetchMore()) {
|
||||
holder.fetch_more.setVisibility(View.VISIBLE);
|
||||
holder.fetch_more.setEnabled(true);
|
||||
holder.fetch_more.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
status.setFetchMore(false);
|
||||
holder.fetch_more.setEnabled(false);
|
||||
holder.fetch_more.setVisibility(View.GONE);
|
||||
if (context instanceof BaseMainActivity) {
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
List<ManageTimelines> timelines = new TimelinesDAO(context, db).getDisplayedTimelines();
|
||||
for (ManageTimelines tl : timelines) {
|
||||
if (tl.getType() == ManageTimelines.Type.HOME && mPageReferenceMap != null) {
|
||||
DisplayStatusFragment homeFragment = (DisplayStatusFragment) mPageReferenceMap.get(tl.getPosition());
|
||||
if (homeFragment != null)
|
||||
homeFragment.fetchMore(status.getId());
|
||||
break;
|
||||
}
|
||||
holder.fetch_more.setOnClickListener(view -> {
|
||||
status.setFetchMore(false);
|
||||
holder.fetch_more.setEnabled(false);
|
||||
holder.fetch_more.setVisibility(View.GONE);
|
||||
if (context instanceof BaseMainActivity) {
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
List<ManageTimelines> timelines = new TimelinesDAO(context, db).getDisplayedTimelines();
|
||||
for (ManageTimelines tl : timelines) {
|
||||
if (tl.getType() == ManageTimelines.Type.HOME && mPageReferenceMap != null) {
|
||||
DisplayStatusFragment homeFragment = (DisplayStatusFragment) mPageReferenceMap.get(tl.getPosition());
|
||||
if (homeFragment != null)
|
||||
homeFragment.fetchMore(status.getId());
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
Toasty.error(context, context.getString(R.string.toast_error), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
} else {
|
||||
Toasty.error(context, context.getString(R.string.toast_error), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
holder.fetch_more.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
|
@ -2177,21 +2165,18 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
if (!card.getType().toLowerCase().equals("video") && (display_card || (type == RetrieveFeedsAsyncTask.Type.CONTEXT && viewHolder.getAdapterPosition() == conversationPosition))) {
|
||||
holder.status_cardview.setVisibility(View.VISIBLE);
|
||||
holder.status_cardview_video.setVisibility(View.GONE);
|
||||
holder.status_cardview.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
String url = card.getUrl();
|
||||
boolean nitter = sharedpreferences.getBoolean(Helper.SET_NITTER, false);
|
||||
if (nitter) {
|
||||
Matcher matcher = Helper.nitterPattern.matcher(url);
|
||||
while (matcher.find()) {
|
||||
final String nitter_directory = matcher.group(2);
|
||||
String nitterHost = sharedpreferences.getString(Helper.SET_NITTER_HOST, Helper.DEFAULT_NITTER_HOST).toLowerCase();
|
||||
url = url.replaceAll("https://" + Pattern.quote(matcher.group()), Matcher.quoteReplacement("https://" + nitterHost + nitter_directory));
|
||||
}
|
||||
holder.status_cardview.setOnClickListener(view -> {
|
||||
String url = card.getUrl();
|
||||
boolean nitter = sharedpreferences.getBoolean(Helper.SET_NITTER, false);
|
||||
if (nitter) {
|
||||
Matcher matcher = Helper.nitterPattern.matcher(url);
|
||||
while (matcher.find()) {
|
||||
final String nitter_directory = matcher.group(2);
|
||||
String nitterHost = sharedpreferences.getString(Helper.SET_NITTER_HOST, Helper.DEFAULT_NITTER_HOST).toLowerCase();
|
||||
url = url.replaceAll("https://" + Pattern.quote(matcher.group()), Matcher.quoteReplacement("https://" + nitterHost + nitter_directory));
|
||||
}
|
||||
Helper.openBrowser(context, url);
|
||||
}
|
||||
Helper.openBrowser(context, url);
|
||||
});
|
||||
} else if (card.getType().toLowerCase().equals("video") && (display_video_preview || (type == RetrieveFeedsAsyncTask.Type.CONTEXT && viewHolder.getAdapterPosition() == conversationPosition))) {
|
||||
Glide.with(holder.status_cardview_image.getContext())
|
||||
|
@ -2413,31 +2398,28 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
InputMethodManager imm = (InputMethodManager) context.getSystemService(Activity.INPUT_METHOD_SERVICE);
|
||||
imm.hideSoftInputFromWindow(holder.quick_reply_text.getWindowToken(), 0);
|
||||
}
|
||||
holder.quick_reply_switch_to_full.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
status.setShortReply(false);
|
||||
holder.quick_reply_container.setVisibility(View.GONE);
|
||||
Intent intent = new Intent(context, TootActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
if (status != null && status.getReblog() != null) {
|
||||
b.putParcelable("tootReply", status.getReblog());
|
||||
} else {
|
||||
b.putParcelable("tootReply", status);
|
||||
holder.quick_reply_switch_to_full.setOnClickListener(v12 -> {
|
||||
status.setShortReply(false);
|
||||
holder.quick_reply_container.setVisibility(View.GONE);
|
||||
Intent intent = new Intent(context, TootActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
if (status != null && status.getReblog() != null) {
|
||||
b.putParcelable("tootReply", status.getReblog());
|
||||
} else {
|
||||
b.putParcelable("tootReply", status);
|
||||
}
|
||||
|
||||
b.putString("quickmessagevisibility", status.getQuickReplyPrivacy());
|
||||
b.putString("quickmessagecontent", status.getQuickReplyContent());
|
||||
intent.putExtras(b); //Put your id to your next Intent
|
||||
context.startActivity(intent);
|
||||
if (type == RetrieveFeedsAsyncTask.Type.CONTEXT) {
|
||||
try {
|
||||
//Avoid to open multi activities when replying in a conversation
|
||||
((ShowConversationActivity) context).finish();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
b.putString("quickmessagevisibility", status.getQuickReplyPrivacy());
|
||||
b.putString("quickmessagecontent", status.getQuickReplyContent());
|
||||
intent.putExtras(b); //Put your id to your next Intent
|
||||
context.startActivity(intent);
|
||||
if (type == RetrieveFeedsAsyncTask.Type.CONTEXT) {
|
||||
try {
|
||||
//Avoid to open multi activities when replying in a conversation
|
||||
((ShowConversationActivity) context).finish();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
@ -2452,17 +2434,14 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
});
|
||||
|
||||
|
||||
holder.status_favorite_count.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (!status.isFavourited() && confirmFav)
|
||||
status.setFavAnimated(true);
|
||||
if (!status.isFavourited() && !confirmFav) {
|
||||
status.setFavAnimated(true);
|
||||
notifyStatusChanged(status);
|
||||
}
|
||||
CrossActions.doCrossAction(context, type, status, null, (status.isFavourited() || (status.getReblog() != null && status.getReblog().isFavourited())) ? API.StatusAction.UNFAVOURITE : API.StatusAction.FAVOURITE, statusListAdapter, StatusListAdapter.this, true);
|
||||
holder.status_favorite_count.setOnClickListener(v -> {
|
||||
if (!status.isFavourited() && confirmFav)
|
||||
status.setFavAnimated(true);
|
||||
if (!status.isFavourited() && !confirmFav) {
|
||||
status.setFavAnimated(true);
|
||||
notifyStatusChanged(status);
|
||||
}
|
||||
CrossActions.doCrossAction(context, type, status, null, (status.isFavourited() || (status.getReblog() != null && status.getReblog().isFavourited())) ? API.StatusAction.UNFAVOURITE : API.StatusAction.FAVOURITE, statusListAdapter, StatusListAdapter.this, true);
|
||||
});
|
||||
holder.spark_button_fav.setOnClickListener(v -> {
|
||||
if (!status.isFavourited() && confirmFav)
|
||||
|
@ -2523,7 +2502,6 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
builderInner.setView(input);
|
||||
}
|
||||
builderInner.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
|
||||
final EditText finalInput = input;
|
||||
builderInner.setPositiveButton(R.string.yes, (dialog, which) -> {
|
||||
String targetedId = status.getId();
|
||||
new PostActionAsyncTask(context, doAction, targetedId, StatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
|
@ -2714,7 +2692,6 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||
builderInner.setMessage(Html.fromHtml(status.getContent(), Html.FROM_HTML_MODE_LEGACY));
|
||||
else
|
||||
//noinspection deprecation
|
||||
builderInner.setMessage(Html.fromHtml(status.getContent()));
|
||||
break;
|
||||
case R.id.action_block_domain:
|
||||
|
@ -2807,7 +2784,6 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||
content = Html.fromHtml(status.getContent(), Html.FROM_HTML_MODE_LEGACY).toString();
|
||||
else
|
||||
//noinspection deprecation
|
||||
content = Html.fromHtml(status.getContent()).toString();
|
||||
ClipData clip = ClipData.newPlainText(Helper.CLIP_BOARD, content);
|
||||
if (clipboard != null) {
|
||||
|
@ -3345,7 +3321,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
|
||||
}
|
||||
|
||||
private int closePanels() {
|
||||
private void closePanels() {
|
||||
int position = -1;
|
||||
if (statuses != null && statuses.size() > 0) {
|
||||
for (Status status : statuses) {
|
||||
|
@ -3357,7 +3333,6 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
}
|
||||
}
|
||||
}
|
||||
return position;
|
||||
}
|
||||
|
||||
private void timedMuteAction(Status status) {
|
||||
|
|
Loading…
Reference in New Issue