mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2025-01-03 14:40:07 +02:00
Fix some crashes
This commit is contained in:
parent
197dba1658
commit
c998ef1f56
3 changed files with 36 additions and 33 deletions
|
@ -97,25 +97,26 @@ public class ContextActivity extends BaseActivity {
|
||||||
}).start();
|
}).start();
|
||||||
StatusesVM timelinesVM = new ViewModelProvider(ContextActivity.this).get(StatusesVM.class);
|
StatusesVM timelinesVM = new ViewModelProvider(ContextActivity.this).get(StatusesVM.class);
|
||||||
timelinesVM.getStatus(MainActivity.currentInstance, MainActivity.currentToken, focusedStatus.id).observe(ContextActivity.this, status -> {
|
timelinesVM.getStatus(MainActivity.currentInstance, MainActivity.currentToken, focusedStatus.id).observe(ContextActivity.this, status -> {
|
||||||
StatusCache statusCache = new StatusCache();
|
if (status != null) {
|
||||||
statusCache.instance = MainActivity.currentInstance;
|
StatusCache statusCache = new StatusCache();
|
||||||
statusCache.user_id = MainActivity.currentUserID;
|
statusCache.instance = MainActivity.currentInstance;
|
||||||
statusCache.status = status;
|
statusCache.user_id = MainActivity.currentUserID;
|
||||||
statusCache.status_id = status.id;
|
statusCache.status = status;
|
||||||
//Update cache
|
statusCache.status_id = status.id;
|
||||||
new Thread(() -> {
|
//Update cache
|
||||||
try {
|
new Thread(() -> {
|
||||||
new StatusCache(getApplication()).updateIfExists(statusCache);
|
try {
|
||||||
new QuickLoad(getApplication().getApplicationContext()).updateStatus(Helper.getCurrentAccount(ContextActivity.this), status);
|
new StatusCache(getApplication()).updateIfExists(statusCache);
|
||||||
Handler mainHandler = new Handler(Looper.getMainLooper());
|
new QuickLoad(getApplication().getApplicationContext()).updateStatus(Helper.getCurrentAccount(ContextActivity.this), status);
|
||||||
//Update UI
|
Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||||
Runnable myRunnable = () -> sendAction(ContextActivity.this, Helper.ARG_STATUS_ACTION, status, null);
|
//Update UI
|
||||||
mainHandler.post(myRunnable);
|
Runnable myRunnable = () -> sendAction(ContextActivity.this, Helper.ARG_STATUS_ACTION, status, null);
|
||||||
} catch (DBException e) {
|
mainHandler.post(myRunnable);
|
||||||
e.printStackTrace();
|
} catch (DBException e) {
|
||||||
}
|
e.printStackTrace();
|
||||||
}).start();
|
}
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1663,7 +1663,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||||
int position = 0;
|
int position = 0;
|
||||||
if (statusList != null) {
|
if (statusList != null) {
|
||||||
for (Status _status : statusList) {
|
for (Status _status : statusList) {
|
||||||
if (_status.id.compareTo(status.id) == 0 || (_status.reblog != null && _status.reblog.id.compareTo(status.id) == 0)) {
|
if (status.id != null && ((_status.id != null && _status.id.compareTo(status.id) == 0) || (_status.reblog != null && _status.reblog.id != null && _status.reblog.id.compareTo(status.id) == 0))) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
position++;
|
position++;
|
||||||
|
|
|
@ -512,20 +512,22 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
||||||
@Override
|
@Override
|
||||||
public void onDestroyView() {
|
public void onDestroyView() {
|
||||||
//Update last read id for home timeline
|
//Update last read id for home timeline
|
||||||
if (mLayoutManager != null) {
|
if (isAdded()) {
|
||||||
int position = mLayoutManager.findFirstVisibleItemPosition();
|
if (mLayoutManager != null) {
|
||||||
new Thread(() -> {
|
int position = mLayoutManager.findFirstVisibleItemPosition();
|
||||||
try {
|
new Thread(() -> {
|
||||||
new QuickLoad(requireActivity()).storeTimeline(position, user_id, instance, timelineType, statuses, ident);
|
try {
|
||||||
} catch (Exception ignored) {
|
new QuickLoad(requireActivity()).storeTimeline(position, user_id, instance, timelineType, statuses, ident);
|
||||||
}
|
} catch (Exception ignored) {
|
||||||
}).start();
|
}
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
storeMarker();
|
||||||
|
if (binding != null) {
|
||||||
|
binding.recyclerView.setAdapter(null);
|
||||||
|
}
|
||||||
|
LocalBroadcastManager.getInstance(requireActivity()).unregisterReceiver(receive_action);
|
||||||
}
|
}
|
||||||
storeMarker();
|
|
||||||
if (binding != null) {
|
|
||||||
binding.recyclerView.setAdapter(null);
|
|
||||||
}
|
|
||||||
LocalBroadcastManager.getInstance(requireActivity()).unregisterReceiver(receive_action);
|
|
||||||
statusAdapter = null;
|
statusAdapter = null;
|
||||||
binding = null;
|
binding = null;
|
||||||
super.onDestroyView();
|
super.onDestroyView();
|
||||||
|
|
Loading…
Reference in a new issue