|
|
|
@ -27,7 +27,6 @@ import android.content.SharedPreferences;
|
|
|
|
|
import android.os.Bundle;
|
|
|
|
|
import android.os.Handler;
|
|
|
|
|
import android.os.Looper;
|
|
|
|
|
import android.util.Log;
|
|
|
|
|
import android.view.LayoutInflater;
|
|
|
|
|
import android.view.View;
|
|
|
|
|
import android.view.ViewGroup;
|
|
|
|
@ -180,7 +179,6 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
private boolean bundleInitialized;
|
|
|
|
|
private boolean retry_for_home_done;
|
|
|
|
|
private String lemmy_post_id;
|
|
|
|
|
private boolean checkRemotely;
|
|
|
|
@ -233,10 +231,6 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
|
|
|
|
@Override
|
|
|
|
|
public void onResume() {
|
|
|
|
|
super.onResume();
|
|
|
|
|
Log.v(Helper.TAG, "onResume bundleInitialized: " + bundleInitialized);
|
|
|
|
|
if (!bundleInitialized) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!isViewInitialized) {
|
|
|
|
|
isViewInitialized = true;
|
|
|
|
|
if (initialStatuses != null) {
|
|
|
|
@ -370,38 +364,28 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
|
|
|
|
public View onCreateView(@NonNull LayoutInflater inflater,
|
|
|
|
|
ViewGroup container, Bundle savedInstanceState) {
|
|
|
|
|
|
|
|
|
|
bundleInitialized = false;
|
|
|
|
|
timelineType = Timeline.TimeLineEnum.HOME;
|
|
|
|
|
binding = FragmentPaginationBinding.inflate(inflater, container, false);
|
|
|
|
|
if (getArguments() != null) {
|
|
|
|
|
long bundleId = getArguments().getLong(Helper.ARG_INTENT_ID, -1);
|
|
|
|
|
Log.v(Helper.TAG, "onCreateView bundleId: " + bundleId);
|
|
|
|
|
if (bundleId != -1) {
|
|
|
|
|
new CachedBundle(requireActivity()).getBundle(bundleId, currentAccount, this::initializeAfterBundle);
|
|
|
|
|
} else {
|
|
|
|
|
if (getArguments().containsKey(Helper.ARG_CACHED_ACCOUNT_ID)) {
|
|
|
|
|
new Thread(() -> {
|
|
|
|
|
try {
|
|
|
|
|
accountTimeline = new CachedBundle(requireActivity()).getCachedAccount(currentAccount, getArguments().getString(Helper.ARG_CACHED_ACCOUNT_ID));
|
|
|
|
|
} catch (DBException e) {
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
Handler mainHandler = new Handler(Looper.getMainLooper());
|
|
|
|
|
Runnable myRunnable = () -> {
|
|
|
|
|
initializeAfterBundle(getArguments());
|
|
|
|
|
};
|
|
|
|
|
mainHandler.post(myRunnable);
|
|
|
|
|
}).start();
|
|
|
|
|
} else {
|
|
|
|
|
initializeAfterBundle(getArguments());
|
|
|
|
|
}
|
|
|
|
|
initializeAfterBundle(getArguments());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return binding.getRoot();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void initializeAfterBundle(Bundle bundle) {
|
|
|
|
|
Log.v(Helper.TAG, "initializeAfterBundle: " + bundle);
|
|
|
|
|
new Thread(() -> {
|
|
|
|
|
if (bundle != null) {
|
|
|
|
|
timelineType = (Timeline.TimeLineEnum) bundle.get(Helper.ARG_TIMELINE_TYPE);
|
|
|
|
|
lemmy_post_id = bundle.getString(Helper.ARG_LEMMY_POST_ID, null);
|
|
|
|
@ -439,16 +423,13 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
|
|
|
|
minified = bundle.getBoolean(Helper.ARG_MINIFIED, false);
|
|
|
|
|
statusReport = (Status) bundle.getSerializable(Helper.ARG_STATUS_REPORT);
|
|
|
|
|
initialStatus = (Status) bundle.getSerializable(Helper.ARG_STATUS);
|
|
|
|
|
Log.v(Helper.TAG, "accountTimeline: " + accountTimeline);
|
|
|
|
|
}
|
|
|
|
|
bundleInitialized = true;
|
|
|
|
|
Handler mainHandler = new Handler(Looper.getMainLooper());
|
|
|
|
|
Runnable myRunnable = () -> {
|
|
|
|
|
|
|
|
|
|
timelinesVM = new ViewModelProvider(FragmentMastodonTimeline.this).get(viewModelKey, TimelinesVM.class);
|
|
|
|
|
accountsVM = new ViewModelProvider(FragmentMastodonTimeline.this).get(viewModelKey, AccountsVM.class);
|
|
|
|
|
initialStatuses = null;
|
|
|
|
|
lockForResumeCall = 0;
|
|
|
|
|
timelineType = Timeline.TimeLineEnum.HOME;
|
|
|
|
|
|
|
|
|
|
canBeFederated = true;
|
|
|
|
|
retry_for_home_done = false;
|
|
|
|
|
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity());
|
|
|
|
@ -502,9 +483,6 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ContextCompat.registerReceiver(requireActivity(), receive_action, new IntentFilter(Helper.RECEIVE_STATUS_ACTION), ContextCompat.RECEIVER_NOT_EXPORTED);
|
|
|
|
|
};
|
|
|
|
|
mainHandler.post(myRunnable);
|
|
|
|
|
}).start();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|