Fix some crashes
This commit is contained in:
parent
c2a08c6df8
commit
92157dc8dc
|
@ -665,12 +665,12 @@ public class ProfileActivity extends BaseActivity {
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
int itemId = item.getItemId();
|
int itemId = item.getItemId();
|
||||||
String[] splitAcct = null;
|
String[] splitAcct = null;
|
||||||
if (account.acct != null) {
|
if (account != null && account.acct != null) {
|
||||||
splitAcct = account.acct.split("@");
|
splitAcct = account.acct.split("@");
|
||||||
}
|
}
|
||||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(ProfileActivity.this);
|
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(ProfileActivity.this);
|
||||||
AlertDialog.Builder builderInner = null;
|
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;
|
final String[] stringArrayConf;
|
||||||
if (isOwner) {
|
if (isOwner) {
|
||||||
stringArrayConf = getResources().getStringArray(R.array.more_action_owner_confirm);
|
stringArrayConf = getResources().getStringArray(R.array.more_action_owner_confirm);
|
||||||
|
|
|
@ -82,6 +82,7 @@ public class NotificationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||||
@Override
|
@Override
|
||||||
public int getItemViewType(int position) {
|
public int getItemViewType(int position) {
|
||||||
String type = notificationList.get(position).type;
|
String type = notificationList.get(position).type;
|
||||||
|
if (type != null) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "follow":
|
case "follow":
|
||||||
return TYPE_FOLLOW;
|
return TYPE_FOLLOW;
|
||||||
|
@ -100,6 +101,7 @@ public class NotificationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||||
case "pleroma:emoji_reaction":
|
case "pleroma:emoji_reaction":
|
||||||
return TYPE_REACTION;
|
return TYPE_REACTION;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return super.getItemViewType(position);
|
return super.getItemViewType(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,7 +281,7 @@ public class NotificationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||||
holderStatus.bindingNotification.containerTransparent.setVisibility(View.VISIBLE);
|
holderStatus.bindingNotification.containerTransparent.setVisibility(View.VISIBLE);
|
||||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
boolean displayMedia = sharedpreferences.getBoolean(context.getString(R.string.SET_DISPLAY_MEDIA_NOTIFICATION), true);
|
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);
|
holderStatus.bindingNotification.status.mediaContainer.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
holderStatus.bindingNotification.status.mediaContainer.setVisibility(View.GONE);
|
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();
|
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)
|
searchVM.search(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.uri, null, "statuses", false, true, false, 0, null, null, 1)
|
||||||
.observe((LifecycleOwner) context, results -> {
|
.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);
|
Status fetchedStatus = statusList.get(0);
|
||||||
statusesVM.bookmark(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, fetchedStatus.id)
|
statusesVM.bookmark(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, fetchedStatus.id)
|
||||||
.observe((LifecycleOwner) context, _status -> manageAction(context, adapter, holder, CrossActionHelper.TypeOfCrossAction.BOOKMARK_ACTION, statusToDeal, _status, true));
|
.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();
|
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)
|
searchVM.search(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.uri, null, "statuses", false, true, false, 0, null, null, 1)
|
||||||
.observe((LifecycleOwner) context, results -> {
|
.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);
|
Status fetchedStatus = results.statuses.get(0);
|
||||||
Intent intent = new Intent(context, ProfileActivity.class);
|
Intent intent = new Intent(context, ProfileActivity.class);
|
||||||
Bundle b = new Bundle();
|
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();
|
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)
|
searchVM.search(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.uri, null, "statuses", false, true, false, 0, null, null, 1)
|
||||||
.observe((LifecycleOwner) context, results -> {
|
.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);
|
Status fetchedStatus = results.statuses.get(0);
|
||||||
Intent intent = new Intent(context, ProfileActivity.class);
|
Intent intent = new Intent(context, ProfileActivity.class);
|
||||||
Bundle b = new Bundle();
|
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();
|
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)
|
searchVM.search(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.uri, null, "statuses", false, true, false, 0, null, null, 1)
|
||||||
.observe((LifecycleOwner) context, results -> {
|
.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);
|
Status fetchedStatus = results.statuses.get(0);
|
||||||
statusesVM.reblog(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, fetchedStatus.id, null)
|
statusesVM.reblog(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, fetchedStatus.id, null)
|
||||||
.observe((LifecycleOwner) context, _status -> manageAction(context, adapter, holder, CrossActionHelper.TypeOfCrossAction.REBLOG_ACTION, statusToDeal, _status, true));
|
.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();
|
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)
|
searchVM.search(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.uri, null, "statuses", false, true, false, 0, null, null, 1)
|
||||||
.observe((LifecycleOwner) context, results -> {
|
.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);
|
Status fetchedStatus = results.statuses.get(0);
|
||||||
statusesVM.reblog(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, fetchedStatus.id, null)
|
statusesVM.reblog(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, fetchedStatus.id, null)
|
||||||
.observe((LifecycleOwner) context, _status -> manageAction(context, adapter, holder, CrossActionHelper.TypeOfCrossAction.REBLOG_ACTION, statusToDeal, _status, true));
|
.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();
|
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)
|
searchVM.search(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.uri, null, "statuses", false, true, false, 0, null, null, 1)
|
||||||
.observe((LifecycleOwner) context, results -> {
|
.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);
|
Status fetchedStatus = results.statuses.get(0);
|
||||||
statusesVM.favourite(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, fetchedStatus.id)
|
statusesVM.favourite(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, fetchedStatus.id)
|
||||||
.observe((LifecycleOwner) context, _status -> manageAction(context, adapter, holder, CrossActionHelper.TypeOfCrossAction.FAVOURITE_ACTION, statusToDeal, _status, true));
|
.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();
|
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)
|
searchVM.search(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.uri, null, "statuses", false, true, false, 0, null, null, 1)
|
||||||
.observe((LifecycleOwner) context, results -> {
|
.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);
|
Status fetchedStatus = results.statuses.get(0);
|
||||||
statusesVM.favourite(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, fetchedStatus.id)
|
statusesVM.favourite(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, fetchedStatus.id)
|
||||||
.observe((LifecycleOwner) context, _status -> manageAction(context, adapter, holder, CrossActionHelper.TypeOfCrossAction.FAVOURITE_ACTION, statusToDeal, _status, true));
|
.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();
|
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)
|
searchVM.search(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.uri, null, "statuses", false, true, false, 0, null, null, 1)
|
||||||
.observe((LifecycleOwner) context, results -> {
|
.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);
|
Status fetchedStatus = results.statuses.get(0);
|
||||||
if (fetchedStatus.reblogs_count > 0) {
|
if (fetchedStatus.reblogs_count > 0) {
|
||||||
Intent intent = new Intent(context, StatusInfoActivity.class);
|
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();
|
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)
|
searchVM.search(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.uri, null, "statuses", false, true, false, 0, null, null, 1)
|
||||||
.observe((LifecycleOwner) context, results -> {
|
.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);
|
Status fetchedStatus = results.statuses.get(0);
|
||||||
if (fetchedStatus.favourites_count > 0) {
|
if (fetchedStatus.favourites_count > 0) {
|
||||||
Intent intent = new Intent(context, StatusInfoActivity.class);
|
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();
|
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)
|
searchVM.search(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.uri, null, "statuses", false, true, false, 0, null, null, 1)
|
||||||
.observe((LifecycleOwner) context, results -> {
|
.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);
|
Status fetchedStatus = results.statuses.get(0);
|
||||||
statusesVM.votePoll(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, fetchedStatus.poll.id, choice)
|
statusesVM.votePoll(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, fetchedStatus.poll.id, choice)
|
||||||
.observe((LifecycleOwner) context, poll -> {
|
.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();
|
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)
|
searchVM.search(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.uri, null, "statuses", false, true, false, 0, null, null, 1)
|
||||||
.observe((LifecycleOwner) context, results -> {
|
.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);
|
Status fetchedStatus = results.statuses.get(0);
|
||||||
Intent intent = new Intent(context, ContextActivity.class);
|
Intent intent = new Intent(context, ContextActivity.class);
|
||||||
intent.putExtra(Helper.ARG_STATUS, fetchedStatus);
|
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();
|
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)
|
searchVM.search(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.uri, null, "statuses", false, true, false, 0, null, null, 1)
|
||||||
.observe((LifecycleOwner) context, results -> {
|
.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);
|
Status fetchedStatus = statusList.get(0);
|
||||||
Intent intent = new Intent(context, ComposeActivity.class);
|
Intent intent = new Intent(context, ComposeActivity.class);
|
||||||
intent.putExtra(Helper.ARG_STATUS_REPLY, fetchedStatus);
|
intent.putExtra(Helper.ARG_STATUS_REPLY, fetchedStatus);
|
||||||
|
|
|
@ -66,9 +66,15 @@ public class NodeInfoVM extends AndroidViewModel {
|
||||||
* @return LiveData<WellKnownNodeinfo.NodeInfo>
|
* @return LiveData<WellKnownNodeinfo.NodeInfo>
|
||||||
*/
|
*/
|
||||||
public LiveData<WellKnownNodeinfo.NodeInfo> getNodeInfo(String instance) {
|
public LiveData<WellKnownNodeinfo.NodeInfo> getNodeInfo(String instance) {
|
||||||
if (instance != null) {
|
|
||||||
NodeInfoService nodeInfoService = init(instance);
|
|
||||||
nodeInfoMutableLiveData = new MutableLiveData<>();
|
nodeInfoMutableLiveData = new MutableLiveData<>();
|
||||||
|
if (instance != null) {
|
||||||
|
NodeInfoService nodeInfoService;
|
||||||
|
try {
|
||||||
|
nodeInfoService = init(instance);
|
||||||
|
} catch (Exception e) {
|
||||||
|
nodeInfoMutableLiveData.setValue(null);
|
||||||
|
return nodeInfoMutableLiveData;
|
||||||
|
}
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
WellKnownNodeinfo.NodeInfo nodeInfo = null;
|
WellKnownNodeinfo.NodeInfo nodeInfo = null;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue