mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2024-12-23 17:20:04 +02:00
Fix crashes from bug reports.
This commit is contained in:
parent
a389681b86
commit
0e0fb6e13c
5 changed files with 46 additions and 17 deletions
|
@ -586,7 +586,7 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
|
|||
}
|
||||
Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||
Runnable myRunnable = () -> {
|
||||
if (currentAccount == null) {
|
||||
if (currentAccount == null || currentAccount.mastodon_account == null) {
|
||||
//It is not, the user is redirected to the login page
|
||||
Intent myIntent = new Intent(BaseMainActivity.this, LoginActivity.class);
|
||||
startActivity(myIntent);
|
||||
|
@ -701,6 +701,7 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
|
|||
new ViewModelProvider(BaseMainActivity.this).get(AccountsVM.class).getConnectedAccount(currentInstance, currentToken)
|
||||
.observe(BaseMainActivity.this, mastodonAccount -> {
|
||||
//Initialize static var
|
||||
if (mastodonAccount != null) {
|
||||
currentAccount.mastodon_account = mastodonAccount;
|
||||
displayReleaseNotesIfNeeded(BaseMainActivity.this, false);
|
||||
new Thread(() -> {
|
||||
|
@ -711,6 +712,7 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
|
|||
e.printStackTrace();
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
|
@ -1035,6 +1037,17 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
|
|||
Matcher matcherLink = null;
|
||||
matcherLink = link.matcher(url);
|
||||
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
|
||||
CrossActionHelper.fetchRemoteStatus(BaseMainActivity.this, currentAccount, url, new CrossActionHelper.Callback() {
|
||||
@Override
|
||||
|
|
|
@ -277,7 +277,11 @@ public class FilterActivity extends BaseActivity implements FilterAdapter.Delete
|
|||
|
||||
binding.addFilter.setOnClickListener(v -> addEditFilter(FilterActivity.this, null, filter -> {
|
||||
if (filter != null) {
|
||||
if (MainActivity.mainFilters == null) {
|
||||
MainActivity.mainFilters = new ArrayList<>();
|
||||
}
|
||||
filterList.add(0, filter);
|
||||
MainActivity.mainFilters.add(filter);
|
||||
if (filterAdapter != null) {
|
||||
filterAdapter.notifyItemInserted(0);
|
||||
} else {
|
||||
|
|
|
@ -1029,7 +1029,7 @@ public class Helper {
|
|||
final Activity activity = (Activity) context;
|
||||
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(" ");
|
||||
holder.binding.filterContext.setText(contextString.toString());
|
||||
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).expires_at = filter1.expires_at;
|
||||
BaseMainActivity.mainFilters.get(position).filter_action = filter1.filter_action;
|
||||
BaseMainActivity.mainFilters.get(position).keywords = filter1.keywords;
|
||||
BaseMainActivity.mainFilters.get(position).title = filter1.title;
|
||||
}
|
||||
filterAdapter.notifyItemChanged(position);
|
||||
}
|
||||
}));
|
||||
holder.binding.deleteFilter.setOnClickListener(v -> {
|
||||
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 -> {
|
||||
int i = 0;
|
||||
for (Poll.PollItem item : statusToDeal.poll.options) {
|
||||
if (item.span_title != null) {
|
||||
poll.options.get(i).span_title = item.span_title;
|
||||
} else {
|
||||
poll.options.get(i).span_title = new SpannableString(item.title);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
statusToDeal.poll = poll;
|
||||
|
@ -1627,7 +1631,11 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
if (poll != null) {
|
||||
int i = 0;
|
||||
for (Poll.PollItem item : statusToDeal.poll.options) {
|
||||
if (item.span_title != null) {
|
||||
poll.options.get(i).span_title = item.span_title;
|
||||
} else {
|
||||
poll.options.get(i).span_title = new SpannableString(item.title);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
statusToDeal.poll = poll;
|
||||
|
@ -1642,7 +1650,11 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
//Store span elements
|
||||
int i = 0;
|
||||
for (Poll.PollItem item : statusToDeal.poll.options) {
|
||||
if (item.span_title != null) {
|
||||
poll.options.get(i).span_title = item.span_title;
|
||||
} else {
|
||||
poll.options.get(i).span_title = new SpannableString(item.title);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
statusToDeal.poll = poll;
|
||||
|
|
Loading…
Reference in a new issue