Fix some crashes

pull/434/head
Thomas 2 years ago
parent c2a08c6df8
commit 92157dc8dc

@ -665,12 +665,12 @@ public class ProfileActivity extends BaseActivity {
public boolean onOptionsItemSelected(MenuItem item) {
int itemId = item.getItemId();
String[] splitAcct = null;
if (account.acct != null) {
if (account != null && account.acct != null) {
splitAcct = account.acct.split("@");
}
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(ProfileActivity.this);
AlertDialog.Builder builderInner = null;
final boolean isOwner = account.id != null && BaseMainActivity.currentUserID != null && account.id.compareToIgnoreCase(BaseMainActivity.currentUserID) == 0;
final boolean isOwner = account != null && account.id != null && BaseMainActivity.currentUserID != null && account.id.compareToIgnoreCase(BaseMainActivity.currentUserID) == 0;
final String[] stringArrayConf;
if (isOwner) {
stringArrayConf = getResources().getStringArray(R.array.more_action_owner_confirm);

@ -82,23 +82,25 @@ public class NotificationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
@Override
public int getItemViewType(int position) {
String type = notificationList.get(position).type;
switch (type) {
case "follow":
return TYPE_FOLLOW;
case "follow_request":
return TYPE_FOLLOW_REQUEST;
case "mention":
return TYPE_MENTION;
case "reblog":
return TYPE_REBLOG;
case "favourite":
return TYPE_FAVOURITE;
case "poll":
return TYPE_POLL;
case "status":
return TYPE_STATUS;
case "pleroma:emoji_reaction":
return TYPE_REACTION;
if (type != null) {
switch (type) {
case "follow":
return TYPE_FOLLOW;
case "follow_request":
return TYPE_FOLLOW_REQUEST;
case "mention":
return TYPE_MENTION;
case "reblog":
return TYPE_REBLOG;
case "favourite":
return TYPE_FAVOURITE;
case "poll":
return TYPE_POLL;
case "status":
return TYPE_STATUS;
case "pleroma:emoji_reaction":
return TYPE_REACTION;
}
}
return super.getItemViewType(position);
}
@ -279,7 +281,7 @@ public class NotificationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
holderStatus.bindingNotification.containerTransparent.setVisibility(View.VISIBLE);
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
boolean displayMedia = sharedpreferences.getBoolean(context.getString(R.string.SET_DISPLAY_MEDIA_NOTIFICATION), true);
if (displayMedia && notification.status.media_attachments != null && notification.status.media_attachments.size() > 0) {
if (displayMedia && notification.status != null && notification.status.media_attachments != null && notification.status.media_attachments.size() > 0) {
holderStatus.bindingNotification.status.mediaContainer.setVisibility(View.VISIBLE);
} else {
holderStatus.bindingNotification.status.mediaContainer.setVisibility(View.GONE);

@ -691,7 +691,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
Toasty.info(context, context.getString(R.string.retrieve_remote_status), Toasty.LENGTH_SHORT).show();
searchVM.search(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.uri, null, "statuses", false, true, false, 0, null, null, 1)
.observe((LifecycleOwner) context, results -> {
if (results.statuses != null && results.statuses.size() > 0) {
if (results != null && results.statuses != null && results.statuses.size() > 0) {
Status fetchedStatus = statusList.get(0);
statusesVM.bookmark(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, fetchedStatus.id)
.observe((LifecycleOwner) context, _status -> manageAction(context, adapter, holder, CrossActionHelper.TypeOfCrossAction.BOOKMARK_ACTION, statusToDeal, _status, true));
@ -716,7 +716,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
Toasty.info(context, context.getString(R.string.retrieve_remote_status), Toasty.LENGTH_SHORT).show();
searchVM.search(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.uri, null, "statuses", false, true, false, 0, null, null, 1)
.observe((LifecycleOwner) context, results -> {
if (results.statuses != null && results.statuses.size() > 0) {
if (results != null && results.statuses != null && results.statuses.size() > 0) {
Status fetchedStatus = results.statuses.get(0);
Intent intent = new Intent(context, ProfileActivity.class);
Bundle b = new Bundle();
@ -746,7 +746,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
Toasty.info(context, context.getString(R.string.retrieve_remote_status), Toasty.LENGTH_SHORT).show();
searchVM.search(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.uri, null, "statuses", false, true, false, 0, null, null, 1)
.observe((LifecycleOwner) context, results -> {
if (results.statuses != null && results.statuses.size() > 0) {
if (results != null && results.statuses != null && results.statuses.size() > 0) {
Status fetchedStatus = results.statuses.get(0);
Intent intent = new Intent(context, ProfileActivity.class);
Bundle b = new Bundle();
@ -792,7 +792,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
Toasty.info(context, context.getString(R.string.retrieve_remote_status), Toasty.LENGTH_SHORT).show();
searchVM.search(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.uri, null, "statuses", false, true, false, 0, null, null, 1)
.observe((LifecycleOwner) context, results -> {
if (results.statuses != null && results.statuses.size() > 0) {
if (results != null && results.statuses != null && results.statuses.size() > 0) {
Status fetchedStatus = results.statuses.get(0);
statusesVM.reblog(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, fetchedStatus.id, null)
.observe((LifecycleOwner) context, _status -> manageAction(context, adapter, holder, CrossActionHelper.TypeOfCrossAction.REBLOG_ACTION, statusToDeal, _status, true));
@ -820,7 +820,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
Toasty.info(context, context.getString(R.string.retrieve_remote_status), Toasty.LENGTH_SHORT).show();
searchVM.search(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.uri, null, "statuses", false, true, false, 0, null, null, 1)
.observe((LifecycleOwner) context, results -> {
if (results.statuses != null && results.statuses.size() > 0) {
if (results != null && results.statuses != null && results.statuses.size() > 0) {
Status fetchedStatus = results.statuses.get(0);
statusesVM.reblog(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, fetchedStatus.id, null)
.observe((LifecycleOwner) context, _status -> manageAction(context, adapter, holder, CrossActionHelper.TypeOfCrossAction.REBLOG_ACTION, statusToDeal, _status, true));
@ -862,7 +862,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
Toasty.info(context, context.getString(R.string.retrieve_remote_status), Toasty.LENGTH_SHORT).show();
searchVM.search(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.uri, null, "statuses", false, true, false, 0, null, null, 1)
.observe((LifecycleOwner) context, results -> {
if (results.statuses != null && results.statuses.size() > 0) {
if (results != null && results.statuses != null && results.statuses.size() > 0) {
Status fetchedStatus = results.statuses.get(0);
statusesVM.favourite(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, fetchedStatus.id)
.observe((LifecycleOwner) context, _status -> manageAction(context, adapter, holder, CrossActionHelper.TypeOfCrossAction.FAVOURITE_ACTION, statusToDeal, _status, true));
@ -890,7 +890,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
Toasty.info(context, context.getString(R.string.retrieve_remote_status), Toasty.LENGTH_SHORT).show();
searchVM.search(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.uri, null, "statuses", false, true, false, 0, null, null, 1)
.observe((LifecycleOwner) context, results -> {
if (results.statuses != null && results.statuses.size() > 0) {
if (results != null && results.statuses != null && results.statuses.size() > 0) {
Status fetchedStatus = results.statuses.get(0);
statusesVM.favourite(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, fetchedStatus.id)
.observe((LifecycleOwner) context, _status -> manageAction(context, adapter, holder, CrossActionHelper.TypeOfCrossAction.FAVOURITE_ACTION, statusToDeal, _status, true));
@ -1395,7 +1395,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
Toasty.info(context, context.getString(R.string.retrieve_remote_status), Toasty.LENGTH_SHORT).show();
searchVM.search(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.uri, null, "statuses", false, true, false, 0, null, null, 1)
.observe((LifecycleOwner) context, results -> {
if (results.statuses != null && results.statuses.size() > 0) {
if (results != null && results.statuses != null && results.statuses.size() > 0) {
Status fetchedStatus = results.statuses.get(0);
if (fetchedStatus.reblogs_count > 0) {
Intent intent = new Intent(context, StatusInfoActivity.class);
@ -1422,7 +1422,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
Toasty.info(context, context.getString(R.string.retrieve_remote_status), Toasty.LENGTH_SHORT).show();
searchVM.search(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.uri, null, "statuses", false, true, false, 0, null, null, 1)
.observe((LifecycleOwner) context, results -> {
if (results.statuses != null && results.statuses.size() > 0) {
if (results != null && results.statuses != null && results.statuses.size() > 0) {
Status fetchedStatus = results.statuses.get(0);
if (fetchedStatus.favourites_count > 0) {
Intent intent = new Intent(context, StatusInfoActivity.class);
@ -1564,7 +1564,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
Toasty.info(context, context.getString(R.string.retrieve_remote_status), Toasty.LENGTH_SHORT).show();
searchVM.search(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.uri, null, "statuses", false, true, false, 0, null, null, 1)
.observe((LifecycleOwner) context, results -> {
if (results.statuses != null && results.statuses.size() > 0) {
if (results != null && results.statuses != null && results.statuses.size() > 0) {
Status fetchedStatus = results.statuses.get(0);
statusesVM.votePoll(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, fetchedStatus.poll.id, choice)
.observe((LifecycleOwner) context, poll -> {
@ -1646,7 +1646,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
Toasty.info(context, context.getString(R.string.retrieve_remote_status), Toasty.LENGTH_SHORT).show();
searchVM.search(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.uri, null, "statuses", false, true, false, 0, null, null, 1)
.observe((LifecycleOwner) context, results -> {
if (results.statuses != null && results.statuses.size() > 0) {
if (results != null && results.statuses != null && results.statuses.size() > 0) {
Status fetchedStatus = results.statuses.get(0);
Intent intent = new Intent(context, ContextActivity.class);
intent.putExtra(Helper.ARG_STATUS, fetchedStatus);
@ -1971,7 +1971,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
Toasty.info(context, context.getString(R.string.retrieve_remote_status), Toasty.LENGTH_SHORT).show();
searchVM.search(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.uri, null, "statuses", false, true, false, 0, null, null, 1)
.observe((LifecycleOwner) context, results -> {
if (results.statuses != null && results.statuses.size() > 0) {
if (results != null && results.statuses != null && results.statuses.size() > 0) {
Status fetchedStatus = statusList.get(0);
Intent intent = new Intent(context, ComposeActivity.class);
intent.putExtra(Helper.ARG_STATUS_REPLY, fetchedStatus);

@ -66,9 +66,15 @@ public class NodeInfoVM extends AndroidViewModel {
* @return LiveData<WellKnownNodeinfo.NodeInfo>
*/
public LiveData<WellKnownNodeinfo.NodeInfo> getNodeInfo(String instance) {
nodeInfoMutableLiveData = new MutableLiveData<>();
if (instance != null) {
NodeInfoService nodeInfoService = init(instance);
nodeInfoMutableLiveData = new MutableLiveData<>();
NodeInfoService nodeInfoService;
try {
nodeInfoService = init(instance);
} catch (Exception e) {
nodeInfoMutableLiveData.setValue(null);
return nodeInfoMutableLiveData;
}
new Thread(() -> {
WellKnownNodeinfo.NodeInfo nodeInfo = null;

Loading…
Cancel
Save