Loading app/src/main/java/app/fedilab/android/mastodon/client/entities/app/CachedBundle.java +0 −11 Original line number Diff line number Diff line Loading @@ -23,7 +23,6 @@ import android.os.Handler; import android.os.Looper; import android.os.Parcel; import android.util.Base64; import android.util.Log; import com.google.gson.annotations.SerializedName; Loading Loading @@ -83,12 +82,10 @@ public class CachedBundle { values.put(Sqlite.COL_BUNDLE, serializeBundle(bundle)); values.put(Sqlite.COL_CREATED_AT, Helper.dateToString(new Date())); values.put(Sqlite.COL_TYPE, CacheType.ARGS.getValue()); Log.v(Helper.TAG, "insertIntent --> " + currentUser); if (bundle.containsKey(Helper.ARG_ACCOUNT) && currentUser != null) { ContentValues valuesAccount = new ContentValues(); Bundle bundleAccount = new Bundle(); Account account = (Account) bundle.getSerializable(Helper.ARG_ACCOUNT); Log.v(Helper.TAG, "account --> " + account); if (account != null) { bundleAccount.putSerializable(Helper.ARG_ACCOUNT, account); valuesAccount.put(Sqlite.COL_BUNDLE, serializeBundle(bundleAccount)); Loading Loading @@ -130,12 +127,8 @@ public class CachedBundle { Bundle bundle = null; try { CachedBundle cachedBundle = getCachedBundle(String.valueOf(id)); Log.v(Helper.TAG, "cachedBundle --> " + cachedBundle); if (cachedBundle != null) { bundle = cachedBundle.bundle; if (bundle != null) { Log.v(Helper.TAG, "bundle.containsKey(Helper.ARG_CACHED_ACCOUNT_ID) --> " + bundle.containsKey(Helper.ARG_CACHED_ACCOUNT_ID)); } if (bundle != null && bundle.containsKey(Helper.ARG_CACHED_ACCOUNT_ID)) { Account cachedAccount = getCachedAccount(Account, bundle.getString(Helper.ARG_CACHED_ACCOUNT_ID)); if (cachedAccount != null) { Loading Loading @@ -183,7 +176,6 @@ public class CachedBundle { if (db == null) { throw new DBException("db is null. Wrong initialization."); } Log.v(Helper.TAG, "getCachedAccount --> " + account + " -> " + target_id); if (account == null || target_id == null) { return null; } Loading @@ -193,9 +185,6 @@ public class CachedBundle { + Sqlite.COL_TYPE + " = '" + CacheType.ACCOUNT.getValue() + "' AND " + Sqlite.COL_TARGET_ID + " = '" + target_id + "'", null, null, null, null, "1"); CachedBundle cachedBundle = cursorToCachedBundle(c); if (cachedBundle != null) { Log.v(Helper.TAG, "cachedBundle.bundle --> " + cachedBundle.bundle); } if (cachedBundle != null && cachedBundle.bundle.containsKey(Helper.ARG_ACCOUNT)) { return (Account) cachedBundle.bundle.getSerializable(Helper.ARG_ACCOUNT); } Loading app/src/main/java/app/fedilab/android/mastodon/ui/fragment/media/FragmentMediaProfile.java +7 −16 Original line number Diff line number Diff line Loading @@ -18,8 +18,6 @@ import static app.fedilab.android.BaseMainActivity.currentAccount; import android.content.SharedPreferences; import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; Loading Loading @@ -81,21 +79,14 @@ public class FragmentMediaProfile extends Fragment { 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()); } } else { initializeAfterBundle(null); Loading app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonAccount.java +7 −16 Original line number Diff line number Diff line Loading @@ -22,8 +22,6 @@ import static app.fedilab.android.mastodon.helper.MastodonHelper.ACCOUNTS_PER_CA import android.content.SharedPreferences; import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; Loading Loading @@ -90,21 +88,14 @@ public class FragmentMastodonAccount extends Fragment { 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()); } } else { initializeAfterBundle(null); Loading app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonTimeline.java +100 −122 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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) { Loading Loading @@ -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); Loading Loading @@ -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()); Loading Loading @@ -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(); } /** Loading app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentProfileTimeline.java +8 −15 Original line number Diff line number Diff line Loading @@ -17,8 +17,6 @@ package app.fedilab.android.mastodon.ui.fragment.timeline; import static app.fedilab.android.BaseMainActivity.currentAccount; import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; Loading Loading @@ -54,7 +52,6 @@ public class FragmentProfileTimeline extends Fragment { ViewGroup container, Bundle savedInstanceState) { binding = FragmentProfileTimelinesBinding.inflate(inflater, container, false); if (getArguments() != null) { new Thread(() -> { String cached_account_id = getArguments().getString(Helper.ARG_CACHED_ACCOUNT_ID); try { account = new CachedBundle(requireActivity()).getCachedAccount(currentAccount, cached_account_id); Loading @@ -62,12 +59,8 @@ public class FragmentProfileTimeline extends Fragment { e.printStackTrace(); } checkRemotely = getArguments().getBoolean(Helper.ARG_CHECK_REMOTELY, false); Handler mainHandler = new Handler(Looper.getMainLooper()); Runnable myRunnable = this::initializeAfterBundle; mainHandler.post(myRunnable); }).start(); initializeAfterBundle(); } return binding.getRoot(); } Loading Loading
app/src/main/java/app/fedilab/android/mastodon/client/entities/app/CachedBundle.java +0 −11 Original line number Diff line number Diff line Loading @@ -23,7 +23,6 @@ import android.os.Handler; import android.os.Looper; import android.os.Parcel; import android.util.Base64; import android.util.Log; import com.google.gson.annotations.SerializedName; Loading Loading @@ -83,12 +82,10 @@ public class CachedBundle { values.put(Sqlite.COL_BUNDLE, serializeBundle(bundle)); values.put(Sqlite.COL_CREATED_AT, Helper.dateToString(new Date())); values.put(Sqlite.COL_TYPE, CacheType.ARGS.getValue()); Log.v(Helper.TAG, "insertIntent --> " + currentUser); if (bundle.containsKey(Helper.ARG_ACCOUNT) && currentUser != null) { ContentValues valuesAccount = new ContentValues(); Bundle bundleAccount = new Bundle(); Account account = (Account) bundle.getSerializable(Helper.ARG_ACCOUNT); Log.v(Helper.TAG, "account --> " + account); if (account != null) { bundleAccount.putSerializable(Helper.ARG_ACCOUNT, account); valuesAccount.put(Sqlite.COL_BUNDLE, serializeBundle(bundleAccount)); Loading Loading @@ -130,12 +127,8 @@ public class CachedBundle { Bundle bundle = null; try { CachedBundle cachedBundle = getCachedBundle(String.valueOf(id)); Log.v(Helper.TAG, "cachedBundle --> " + cachedBundle); if (cachedBundle != null) { bundle = cachedBundle.bundle; if (bundle != null) { Log.v(Helper.TAG, "bundle.containsKey(Helper.ARG_CACHED_ACCOUNT_ID) --> " + bundle.containsKey(Helper.ARG_CACHED_ACCOUNT_ID)); } if (bundle != null && bundle.containsKey(Helper.ARG_CACHED_ACCOUNT_ID)) { Account cachedAccount = getCachedAccount(Account, bundle.getString(Helper.ARG_CACHED_ACCOUNT_ID)); if (cachedAccount != null) { Loading Loading @@ -183,7 +176,6 @@ public class CachedBundle { if (db == null) { throw new DBException("db is null. Wrong initialization."); } Log.v(Helper.TAG, "getCachedAccount --> " + account + " -> " + target_id); if (account == null || target_id == null) { return null; } Loading @@ -193,9 +185,6 @@ public class CachedBundle { + Sqlite.COL_TYPE + " = '" + CacheType.ACCOUNT.getValue() + "' AND " + Sqlite.COL_TARGET_ID + " = '" + target_id + "'", null, null, null, null, "1"); CachedBundle cachedBundle = cursorToCachedBundle(c); if (cachedBundle != null) { Log.v(Helper.TAG, "cachedBundle.bundle --> " + cachedBundle.bundle); } if (cachedBundle != null && cachedBundle.bundle.containsKey(Helper.ARG_ACCOUNT)) { return (Account) cachedBundle.bundle.getSerializable(Helper.ARG_ACCOUNT); } Loading
app/src/main/java/app/fedilab/android/mastodon/ui/fragment/media/FragmentMediaProfile.java +7 −16 Original line number Diff line number Diff line Loading @@ -18,8 +18,6 @@ import static app.fedilab.android.BaseMainActivity.currentAccount; import android.content.SharedPreferences; import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; Loading Loading @@ -81,21 +79,14 @@ public class FragmentMediaProfile extends Fragment { 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()); } } else { initializeAfterBundle(null); Loading
app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonAccount.java +7 −16 Original line number Diff line number Diff line Loading @@ -22,8 +22,6 @@ import static app.fedilab.android.mastodon.helper.MastodonHelper.ACCOUNTS_PER_CA import android.content.SharedPreferences; import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; Loading Loading @@ -90,21 +88,14 @@ public class FragmentMastodonAccount extends Fragment { 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()); } } else { initializeAfterBundle(null); Loading
app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonTimeline.java +100 −122 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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) { Loading Loading @@ -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); Loading Loading @@ -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()); Loading Loading @@ -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(); } /** Loading
app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentProfileTimeline.java +8 −15 Original line number Diff line number Diff line Loading @@ -17,8 +17,6 @@ package app.fedilab.android.mastodon.ui.fragment.timeline; import static app.fedilab.android.BaseMainActivity.currentAccount; import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; Loading Loading @@ -54,7 +52,6 @@ public class FragmentProfileTimeline extends Fragment { ViewGroup container, Bundle savedInstanceState) { binding = FragmentProfileTimelinesBinding.inflate(inflater, container, false); if (getArguments() != null) { new Thread(() -> { String cached_account_id = getArguments().getString(Helper.ARG_CACHED_ACCOUNT_ID); try { account = new CachedBundle(requireActivity()).getCachedAccount(currentAccount, cached_account_id); Loading @@ -62,12 +59,8 @@ public class FragmentProfileTimeline extends Fragment { e.printStackTrace(); } checkRemotely = getArguments().getBoolean(Helper.ARG_CHECK_REMOTELY, false); Handler mainHandler = new Handler(Looper.getMainLooper()); Runnable myRunnable = this::initializeAfterBundle; mainHandler.post(myRunnable); }).start(); initializeAfterBundle(); } return binding.getRoot(); } Loading