Fix crashes from bug reports.
This commit is contained in:
parent
a389681b86
commit
0e0fb6e13c
|
@ -586,7 +586,7 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
|
||||||
}
|
}
|
||||||
Handler mainHandler = new Handler(Looper.getMainLooper());
|
Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||||
Runnable myRunnable = () -> {
|
Runnable myRunnable = () -> {
|
||||||
if (currentAccount == null) {
|
if (currentAccount == null || currentAccount.mastodon_account == null) {
|
||||||
//It is not, the user is redirected to the login page
|
//It is not, the user is redirected to the login page
|
||||||
Intent myIntent = new Intent(BaseMainActivity.this, LoginActivity.class);
|
Intent myIntent = new Intent(BaseMainActivity.this, LoginActivity.class);
|
||||||
startActivity(myIntent);
|
startActivity(myIntent);
|
||||||
|
@ -701,6 +701,7 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
|
||||||
new ViewModelProvider(BaseMainActivity.this).get(AccountsVM.class).getConnectedAccount(currentInstance, currentToken)
|
new ViewModelProvider(BaseMainActivity.this).get(AccountsVM.class).getConnectedAccount(currentInstance, currentToken)
|
||||||
.observe(BaseMainActivity.this, mastodonAccount -> {
|
.observe(BaseMainActivity.this, mastodonAccount -> {
|
||||||
//Initialize static var
|
//Initialize static var
|
||||||
|
if (mastodonAccount != null) {
|
||||||
currentAccount.mastodon_account = mastodonAccount;
|
currentAccount.mastodon_account = mastodonAccount;
|
||||||
displayReleaseNotesIfNeeded(BaseMainActivity.this, false);
|
displayReleaseNotesIfNeeded(BaseMainActivity.this, false);
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
|
@ -711,6 +712,7 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}).start();
|
}).start();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -1035,6 +1037,17 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
|
||||||
Matcher matcherLink = null;
|
Matcher matcherLink = null;
|
||||||
matcherLink = link.matcher(url);
|
matcherLink = link.matcher(url);
|
||||||
if (matcherLink.find()) {
|
if (matcherLink.find()) {
|
||||||
|
if (currentAccount == null) {
|
||||||
|
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(BaseMainActivity.this);
|
||||||
|
if (currentToken == null || currentToken.trim().isEmpty()) {
|
||||||
|
currentToken = sharedpreferences.getString(Helper.PREF_USER_TOKEN, null);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
currentAccount = new Account(BaseMainActivity.this).getConnectedAccount();
|
||||||
|
} catch (DBException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
if (matcherLink.group(3) != null && Objects.requireNonNull(matcherLink.group(3)).length() > 0) { //It's a toot
|
if (matcherLink.group(3) != null && Objects.requireNonNull(matcherLink.group(3)).length() > 0) { //It's a toot
|
||||||
CrossActionHelper.fetchRemoteStatus(BaseMainActivity.this, currentAccount, url, new CrossActionHelper.Callback() {
|
CrossActionHelper.fetchRemoteStatus(BaseMainActivity.this, currentAccount, url, new CrossActionHelper.Callback() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -277,7 +277,11 @@ public class FilterActivity extends BaseActivity implements FilterAdapter.Delete
|
||||||
|
|
||||||
binding.addFilter.setOnClickListener(v -> addEditFilter(FilterActivity.this, null, filter -> {
|
binding.addFilter.setOnClickListener(v -> addEditFilter(FilterActivity.this, null, filter -> {
|
||||||
if (filter != null) {
|
if (filter != null) {
|
||||||
|
if (MainActivity.mainFilters == null) {
|
||||||
|
MainActivity.mainFilters = new ArrayList<>();
|
||||||
|
}
|
||||||
filterList.add(0, filter);
|
filterList.add(0, filter);
|
||||||
|
MainActivity.mainFilters.add(filter);
|
||||||
if (filterAdapter != null) {
|
if (filterAdapter != null) {
|
||||||
filterAdapter.notifyItemInserted(0);
|
filterAdapter.notifyItemInserted(0);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1029,7 +1029,7 @@ public class Helper {
|
||||||
final Activity activity = (Activity) context;
|
final Activity activity = (Activity) context;
|
||||||
return !activity.isDestroyed() && !activity.isFinishing();
|
return !activity.isDestroyed() && !activity.isFinishing();
|
||||||
}
|
}
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -78,14 +78,14 @@ public class FilterAdapter extends RecyclerView.Adapter<FilterAdapter.FilterView
|
||||||
contextString.append(ct).append(" ");
|
contextString.append(ct).append(" ");
|
||||||
holder.binding.filterContext.setText(contextString.toString());
|
holder.binding.filterContext.setText(contextString.toString());
|
||||||
holder.binding.editFilter.setOnClickListener(v -> FilterActivity.addEditFilter(context, filter, filter1 -> {
|
holder.binding.editFilter.setOnClickListener(v -> FilterActivity.addEditFilter(context, filter, filter1 -> {
|
||||||
if (filter1 != null) {
|
if (filter1 != null && BaseMainActivity.mainFilters.size() > position) {
|
||||||
BaseMainActivity.mainFilters.get(position).context = filter1.context;
|
BaseMainActivity.mainFilters.get(position).context = filter1.context;
|
||||||
BaseMainActivity.mainFilters.get(position).expires_at = filter1.expires_at;
|
BaseMainActivity.mainFilters.get(position).expires_at = filter1.expires_at;
|
||||||
BaseMainActivity.mainFilters.get(position).filter_action = filter1.filter_action;
|
BaseMainActivity.mainFilters.get(position).filter_action = filter1.filter_action;
|
||||||
BaseMainActivity.mainFilters.get(position).keywords = filter1.keywords;
|
BaseMainActivity.mainFilters.get(position).keywords = filter1.keywords;
|
||||||
BaseMainActivity.mainFilters.get(position).title = filter1.title;
|
BaseMainActivity.mainFilters.get(position).title = filter1.title;
|
||||||
}
|
|
||||||
filterAdapter.notifyItemChanged(position);
|
filterAdapter.notifyItemChanged(position);
|
||||||
|
}
|
||||||
}));
|
}));
|
||||||
holder.binding.deleteFilter.setOnClickListener(v -> {
|
holder.binding.deleteFilter.setOnClickListener(v -> {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(context, Helper.dialogStyle());
|
AlertDialog.Builder builder = new AlertDialog.Builder(context, Helper.dialogStyle());
|
||||||
|
|
|
@ -1611,7 +1611,11 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||||
.observe((LifecycleOwner) context, poll -> {
|
.observe((LifecycleOwner) context, poll -> {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (Poll.PollItem item : statusToDeal.poll.options) {
|
for (Poll.PollItem item : statusToDeal.poll.options) {
|
||||||
|
if (item.span_title != null) {
|
||||||
poll.options.get(i).span_title = item.span_title;
|
poll.options.get(i).span_title = item.span_title;
|
||||||
|
} else {
|
||||||
|
poll.options.get(i).span_title = new SpannableString(item.title);
|
||||||
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
statusToDeal.poll = poll;
|
statusToDeal.poll = poll;
|
||||||
|
@ -1627,7 +1631,11 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||||
if (poll != null) {
|
if (poll != null) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (Poll.PollItem item : statusToDeal.poll.options) {
|
for (Poll.PollItem item : statusToDeal.poll.options) {
|
||||||
|
if (item.span_title != null) {
|
||||||
poll.options.get(i).span_title = item.span_title;
|
poll.options.get(i).span_title = item.span_title;
|
||||||
|
} else {
|
||||||
|
poll.options.get(i).span_title = new SpannableString(item.title);
|
||||||
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
statusToDeal.poll = poll;
|
statusToDeal.poll = poll;
|
||||||
|
@ -1642,7 +1650,11 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||||
//Store span elements
|
//Store span elements
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (Poll.PollItem item : statusToDeal.poll.options) {
|
for (Poll.PollItem item : statusToDeal.poll.options) {
|
||||||
|
if (item.span_title != null) {
|
||||||
poll.options.get(i).span_title = item.span_title;
|
poll.options.get(i).span_title = item.span_title;
|
||||||
|
} else {
|
||||||
|
poll.options.get(i).span_title = new SpannableString(item.title);
|
||||||
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
statusToDeal.poll = poll;
|
statusToDeal.poll = poll;
|
||||||
|
|
Loading…
Reference in New Issue