summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas <tschneider.ac@gmail.com>2024-01-11 10:58:22 +0100
committerThomas <tschneider.ac@gmail.com>2024-01-11 10:58:22 +0100
commit08c1ba943b0b0b780515fa81211e7cb1a5ff9fe9 (patch)
tree35ff49c76f39b6dda35ae5f747ed302438c6c21b
parent85e462e276f27697c2bc4831d5f2d949ee40378a (diff)
Pass ids for pagers
-rw-r--r--app/src/main/java/app/fedilab/android/mastodon/client/entities/app/CachedBundle.java19
-rw-r--r--app/src/main/java/app/fedilab/android/mastodon/ui/drawer/ConversationAdapter.java2
-rw-r--r--app/src/main/java/app/fedilab/android/mastodon/ui/fragment/media/FragmentMediaProfile.java46
-rw-r--r--app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonAccount.java44
-rw-r--r--app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonTimeline.java77
-rw-r--r--app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentProfileTimeline.java32
-rw-r--r--app/src/main/java/app/fedilab/android/mastodon/ui/pageadapter/FedilabProfilePageAdapter.java17
7 files changed, 174 insertions, 63 deletions
diff --git a/app/src/main/java/app/fedilab/android/mastodon/client/entities/app/CachedBundle.java b/app/src/main/java/app/fedilab/android/mastodon/client/entities/app/CachedBundle.java
index 7dbce5ab5..340f7e779 100644
--- a/app/src/main/java/app/fedilab/android/mastodon/client/entities/app/CachedBundle.java
+++ b/app/src/main/java/app/fedilab/android/mastodon/client/entities/app/CachedBundle.java
@@ -23,6 +23,7 @@ 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;
@@ -34,6 +35,7 @@ import java.util.Date;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
+import app.fedilab.android.mastodon.client.entities.api.Account;
import app.fedilab.android.mastodon.client.entities.api.Status;
import app.fedilab.android.mastodon.exception.DBException;
import app.fedilab.android.mastodon.helper.Helper;
@@ -81,19 +83,21 @@ 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));
valuesAccount.put(Sqlite.COL_CREATED_AT, Helper.dateToString(new Date()));
- valuesAccount.put(Sqlite.COL_TARGET_ID, account.user_id);
+ valuesAccount.put(Sqlite.COL_TARGET_ID, account.id);
valuesAccount.put(Sqlite.COL_USER_ID, currentUser.user_id);
valuesAccount.put(Sqlite.COL_INSTANCE, currentUser.instance);
valuesAccount.put(Sqlite.COL_TYPE, CacheType.ACCOUNT.getValue());
- removeIntent(currentUser, account.user_id);
+ removeIntent(currentUser, account.id);
db.insertOrThrow(Sqlite.TABLE_INTENT, null, valuesAccount);
}
}
@@ -126,8 +130,12 @@ 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) {
@@ -171,10 +179,11 @@ public class CachedBundle {
* @param target_id String
* @return Account {@link Account}
*/
- private Account getCachedAccount(BaseAccount account, String target_id) throws DBException {
+ public Account getCachedAccount(BaseAccount account, String target_id) throws DBException {
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;
}
@@ -184,10 +193,14 @@ 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);
}
} catch (Exception e) {
+ e.printStackTrace();
return null;
}
return null;
diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/ConversationAdapter.java b/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/ConversationAdapter.java
index c352a9035..fb35d988a 100644
--- a/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/ConversationAdapter.java
+++ b/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/ConversationAdapter.java
@@ -51,6 +51,7 @@ import app.fedilab.android.R;
import app.fedilab.android.databinding.DrawerConversationBinding;
import app.fedilab.android.databinding.ThumbnailBinding;
import app.fedilab.android.mastodon.activities.ContextActivity;
+import app.fedilab.android.mastodon.activities.DirectMessageActivity;
import app.fedilab.android.mastodon.client.entities.api.Account;
import app.fedilab.android.mastodon.client.entities.api.Attachment;
import app.fedilab.android.mastodon.client.entities.api.Conversation;
@@ -58,7 +59,6 @@ import app.fedilab.android.mastodon.client.entities.api.Status;
import app.fedilab.android.mastodon.client.entities.app.CachedBundle;
import app.fedilab.android.mastodon.helper.Helper;
import app.fedilab.android.mastodon.helper.MastodonHelper;
-import app.fedilab.android.mastodon.activities.DirectMessageActivity;
public class ConversationAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/media/FragmentMediaProfile.java b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/media/FragmentMediaProfile.java
index d6009fc16..3e18bcd79 100644
--- a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/media/FragmentMediaProfile.java
+++ b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/media/FragmentMediaProfile.java
@@ -18,6 +18,8 @@ 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;
@@ -41,6 +43,7 @@ import app.fedilab.android.mastodon.client.entities.api.Attachment;
import app.fedilab.android.mastodon.client.entities.api.Status;
import app.fedilab.android.mastodon.client.entities.api.Statuses;
import app.fedilab.android.mastodon.client.entities.app.CachedBundle;
+import app.fedilab.android.mastodon.exception.DBException;
import app.fedilab.android.mastodon.helper.CrossActionHelper;
import app.fedilab.android.mastodon.helper.Helper;
import app.fedilab.android.mastodon.helper.MastodonHelper;
@@ -74,19 +77,41 @@ public class FragmentMediaProfile extends Fragment {
if (getArguments() != null) {
long bundleId = getArguments().getLong(Helper.ARG_INTENT_ID, -1);
- new CachedBundle(requireActivity()).getBundle(bundleId, currentAccount, bundle -> {
- if (bundle != null) {
- accountTimeline = (Account) bundle.getSerializable(Helper.ARG_ACCOUNT);
- checkRemotely = bundle.getBoolean(Helper.ARG_CHECK_REMOTELY, false);
+ 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);
+ }
+ Handler mainHandler = new Handler(Looper.getMainLooper());
+ Runnable myRunnable = () -> {
+ initializeAfterBundle(getArguments());
+ };
+ mainHandler.post(myRunnable);
+ }).start();
+ } else {
+ initializeAfterBundle(getArguments());
}
- });
+ }
+ } else {
+ initializeAfterBundle(null);
}
return binding.getRoot();
}
- @Override
- public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
- super.onViewCreated(view, savedInstanceState);
+ private void initializeAfterBundle(Bundle bundle) {
+
+ if (bundle != null) {
+ if (bundle.containsKey(Helper.ARG_ACCOUNT)) {
+ accountTimeline = (Account) bundle.getSerializable(Helper.ARG_ACCOUNT);
+ }
+ checkRemotely = bundle.getBoolean(Helper.ARG_CHECK_REMOTELY, false);
+ }
+
flagLoading = false;
accountsVM = new ViewModelProvider(requireActivity()).get(AccountsVM.class);
mediaStatuses = new ArrayList<>();
@@ -122,7 +147,12 @@ public class FragmentMediaProfile extends Fragment {
accountsVM.getAccountStatuses(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, accountTimeline.id, null, null, null, null, null, true, false, MastodonHelper.statusesPerCall(requireActivity()))
.observe(getViewLifecycleOwner(), this::initializeStatusesCommonView);
}
+ }
+
+ @Override
+ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
+ super.onViewCreated(view, savedInstanceState);
}
/**
diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonAccount.java b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonAccount.java
index f3916ca20..ae0bde26c 100644
--- a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonAccount.java
+++ b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonAccount.java
@@ -22,6 +22,8 @@ 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;
@@ -47,6 +49,7 @@ import app.fedilab.android.mastodon.client.entities.api.Pagination;
import app.fedilab.android.mastodon.client.entities.api.RelationShip;
import app.fedilab.android.mastodon.client.entities.app.CachedBundle;
import app.fedilab.android.mastodon.client.entities.app.Timeline;
+import app.fedilab.android.mastodon.exception.DBException;
import app.fedilab.android.mastodon.helper.Helper;
import app.fedilab.android.mastodon.helper.MastodonHelper;
import app.fedilab.android.mastodon.ui.drawer.AccountAdapter;
@@ -83,7 +86,26 @@ public class FragmentMastodonAccount extends Fragment {
token = currentToken;
if (getArguments() != null) {
long bundleId = getArguments().getLong(Helper.ARG_INTENT_ID, -1);
- new CachedBundle(requireActivity()).getBundle(bundleId, currentAccount, this::initializeAfterBundle);
+ 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);
+ }
+ Handler mainHandler = new Handler(Looper.getMainLooper());
+ Runnable myRunnable = () -> {
+ initializeAfterBundle(getArguments());
+ };
+ mainHandler.post(myRunnable);
+ }).start();
+ } else {
+ initializeAfterBundle(getArguments());
+ }
+ }
} else {
initializeAfterBundle(null);
}
@@ -99,7 +121,9 @@ public class FragmentMastodonAccount extends Fragment {
private void initializeAfterBundle(Bundle bundle) {
if (bundle != null) {
search = bundle.getString(Helper.ARG_SEARCH_KEYWORD, null);
- accountTimeline = (Account) bundle.getSerializable(Helper.ARG_ACCOUNT);
+ if (bundle.containsKey(Helper.ARG_ACCOUNT)) {
+ accountTimeline = (Account) bundle.getSerializable(Helper.ARG_ACCOUNT);
+ }
followType = (FedilabProfileTLPageAdapter.follow_type) bundle.getSerializable(Helper.ARG_FOLLOW_TYPE);
viewModelKey = bundle.getString(Helper.ARG_VIEW_MODEL_KEY, "");
timelineType = (Timeline.TimeLineEnum) bundle.get(Helper.ARG_TIMELINE_TYPE);
@@ -119,14 +143,6 @@ public class FragmentMastodonAccount extends Fragment {
token = currentToken;
}
}
-
- }
-
- @Override
- public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
- super.onViewCreated(view, savedInstanceState);
- binding.loader.setVisibility(View.VISIBLE);
- binding.recyclerView.setVisibility(View.GONE);
accountsVM = new ViewModelProvider(FragmentMastodonAccount.this).get(viewModelKey, AccountsVM.class);
max_id = null;
offset = 0;
@@ -137,6 +153,14 @@ public class FragmentMastodonAccount extends Fragment {
router(true);
}
+ @Override
+ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
+ super.onViewCreated(view, savedInstanceState);
+ binding.loader.setVisibility(View.VISIBLE);
+ binding.recyclerView.setVisibility(View.GONE);
+
+ }
+
/**
* Router for timelines
*/
diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonTimeline.java b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonTimeline.java
index 2bad15743..75149d012 100644
--- a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonTimeline.java
+++ b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonTimeline.java
@@ -27,6 +27,7 @@ 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;
@@ -62,6 +63,7 @@ import app.fedilab.android.mastodon.client.entities.app.PinnedTimeline;
import app.fedilab.android.mastodon.client.entities.app.RemoteInstance;
import app.fedilab.android.mastodon.client.entities.app.TagTimeline;
import app.fedilab.android.mastodon.client.entities.app.Timeline;
+import app.fedilab.android.mastodon.exception.DBException;
import app.fedilab.android.mastodon.helper.CrossActionHelper;
import app.fedilab.android.mastodon.helper.GlideApp;
import app.fedilab.android.mastodon.helper.Helper;
@@ -178,6 +180,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
}
}
};
+ private boolean bundleInitialized;
private boolean retry_for_home_done;
private String lemmy_post_id;
private boolean checkRemotely;
@@ -230,6 +233,10 @@ 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) {
@@ -362,39 +369,38 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
public View onCreateView(@NonNull LayoutInflater inflater,
ViewGroup container, Bundle savedInstanceState) {
- 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;
+
+ bundleInitialized = false;
binding = FragmentPaginationBinding.inflate(inflater, container, false);
- SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity());
- max_id = statusReport != null ? statusReport.id : null;
- offset = 0;
- rememberPosition = sharedpreferences.getBoolean(getString(R.string.SET_REMEMBER_POSITION), true);
- //Inner marker are only for pinned timelines and main timelines, they have isViewInitialized set to false
- if (max_id == null && !isViewInitialized && rememberPosition) {
- max_id = sharedpreferences.getString(getString(R.string.SET_INNER_MARKER) + BaseMainActivity.currentUserID + BaseMainActivity.currentInstance + slug, null);
- }
- //Only fragment in main view pager should not have the view initialized
- //AND Only the first fragment will initialize its view
- flagLoading = 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 {
- initializeAfterBundle(getArguments());
+ 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);
+ }
+ Handler mainHandler = new Handler(Looper.getMainLooper());
+ Runnable myRunnable = () -> {
+ initializeAfterBundle(getArguments());
+ };
+ mainHandler.post(myRunnable);
+ }).start();
+ } else {
+ initializeAfterBundle(getArguments());
+ }
}
}
- boolean displayScrollBar = sharedpreferences.getBoolean(getString(R.string.SET_TIMELINE_SCROLLBAR), false);
- binding.recyclerView.setVerticalScrollBarEnabled(displayScrollBar);
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);
@@ -403,6 +409,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
search = bundle.getString(Helper.ARG_SEARCH_KEYWORD, null);
searchCache = bundle.getString(Helper.ARG_SEARCH_KEYWORD_CACHE, null);
pinnedTimeline = (PinnedTimeline) bundle.getSerializable(Helper.ARG_REMOTE_INSTANCE);
+
if (pinnedTimeline != null && pinnedTimeline.remoteInstance != null) {
if (pinnedTimeline.remoteInstance.type != RemoteInstance.InstanceType.NITTER) {
remoteInstance = pinnedTimeline.remoteInstance.host;
@@ -420,7 +427,9 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
isNotPinnedTimeline = isViewInitialized;
tagTimeline = (TagTimeline) bundle.getSerializable(Helper.ARG_TAG_TIMELINE);
bubbleTimeline = (BubbleTimeline) bundle.getSerializable(Helper.ARG_BUBBLE_TIMELINE);
- accountTimeline = (Account) bundle.getSerializable(Helper.ARG_ACCOUNT);
+ if (bundle.containsKey(Helper.ARG_ACCOUNT)) {
+ accountTimeline = (Account) bundle.getSerializable(Helper.ARG_ACCOUNT);
+ }
exclude_replies = !bundle.getBoolean(Helper.ARG_SHOW_REPLIES, true);
checkRemotely = bundle.getBoolean(Helper.ARG_CHECK_REMOTELY, false);
show_pinned = bundle.getBoolean(Helper.ARG_SHOW_PINNED, false);
@@ -430,9 +439,32 @@ 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());
+ boolean displayScrollBar = sharedpreferences.getBoolean(getString(R.string.SET_TIMELINE_SCROLLBAR), false);
+ binding.recyclerView.setVerticalScrollBarEnabled(displayScrollBar);
+ max_id = statusReport != null ? statusReport.id : null;
+ offset = 0;
+ rememberPosition = sharedpreferences.getBoolean(getString(R.string.SET_REMEMBER_POSITION), true);
+ //Inner marker are only for pinned timelines and main timelines, they have isViewInitialized set to false
+ if (max_id == null && !isViewInitialized && rememberPosition) {
+ max_id = sharedpreferences.getString(getString(R.string.SET_INNER_MARKER) + BaseMainActivity.currentUserID + BaseMainActivity.currentInstance + slug, null);
+ }
+ //Only fragment in main view pager should not have the view initialized
+ //AND Only the first fragment will initialize its view
+ flagLoading = false;
+
//When visiting a profile without being authenticated
if (checkRemotely) {
String[] acctArray = accountTimeline.acct.split("@");
@@ -468,6 +500,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
if (timelineType != null) {
slug = timelineType != Timeline.TimeLineEnum.ART ? timelineType.getValue() + (ident != null ? "|" + ident : "") : Timeline.TimeLineEnum.TAG.getValue() + (ident != null ? "|" + ident : "");
}
+
ContextCompat.registerReceiver(requireActivity(), receive_action, new IntentFilter(Helper.RECEIVE_STATUS_ACTION), ContextCompat.RECEIVER_NOT_EXPORTED);
};
mainHandler.post(myRunnable);
diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentProfileTimeline.java b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentProfileTimeline.java
index 9c83daaf3..589eb00cc 100644
--- a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentProfileTimeline.java
+++ b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentProfileTimeline.java
@@ -17,6 +17,8 @@ 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;
@@ -37,6 +39,7 @@ import app.fedilab.android.databinding.FragmentProfileTimelinesBinding;
import app.fedilab.android.mastodon.client.entities.api.Account;
import app.fedilab.android.mastodon.client.entities.app.CachedBundle;
import app.fedilab.android.mastodon.client.entities.app.Timeline;
+import app.fedilab.android.mastodon.exception.DBException;
import app.fedilab.android.mastodon.helper.Helper;
import app.fedilab.android.mastodon.ui.pageadapter.FedilabProfilePageAdapter;
@@ -51,25 +54,25 @@ public class FragmentProfileTimeline extends Fragment {
ViewGroup container, Bundle savedInstanceState) {
binding = FragmentProfileTimelinesBinding.inflate(inflater, container, false);
if (getArguments() != null) {
- long bundleId = getArguments().getLong(Helper.ARG_INTENT_ID, -1);
- if (bundleId != -1) {
- new CachedBundle(requireActivity()).getBundle(bundleId, currentAccount, bundle -> {
- account = (Account) bundle.getSerializable(Helper.ARG_ACCOUNT);
- checkRemotely = bundle.getBoolean(Helper.ARG_CHECK_REMOTELY, false);
- });
- } else {
- account = (Account) getArguments().getSerializable(Helper.ARG_ACCOUNT);
+ new Thread(() -> {
+ String cached_account_id = getArguments().getString(Helper.ARG_CACHED_ACCOUNT_ID);
+ try {
+ account = new CachedBundle(requireActivity()).getCachedAccount(currentAccount, cached_account_id);
+ } catch (DBException e) {
+ e.printStackTrace();
+ }
checkRemotely = getArguments().getBoolean(Helper.ARG_CHECK_REMOTELY, false);
- }
+ Handler mainHandler = new Handler(Looper.getMainLooper());
+ Runnable myRunnable = this::initializeAfterBundle;
+ mainHandler.post(myRunnable);
+ }).start();
}
return binding.getRoot();
}
- @Override
- public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
- super.onViewCreated(view, savedInstanceState);
+ private void initializeAfterBundle() {
binding.tabLayout.addTab(binding.tabLayout.newTab().setText(getString(R.string.toots)));
binding.tabLayout.addTab(binding.tabLayout.newTab().setText(getString(R.string.replies)));
binding.tabLayout.addTab(binding.tabLayout.newTab().setText(getString(R.string.media)));
@@ -167,5 +170,10 @@ public class FragmentProfileTimeline extends Fragment {
}
+ @Override
+ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
+ super.onViewCreated(view, savedInstanceState);
+ }
+
}
diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/pageadapter/FedilabProfilePageAdapter.java b/app/src/main/java/app/fedilab/android/mastodon/ui/pageadapter/FedilabProfilePageAdapter.java
index 45c203c68..fa8d96af3 100644
--- a/app/src/main/java/app/fedilab/android/mastodon/ui/pageadapter/FedilabProfilePageAdapter.java
+++ b/app/src/main/java/app/fedilab/android/mastodon/ui/pageadapter/FedilabProfilePageAdapter.java
@@ -15,6 +15,7 @@ package app.fedilab.android.mastodon.ui.pageadapter;
* see <http://www.gnu.org/licenses>. */
import android.os.Bundle;
+import android.util.Log;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
@@ -56,29 +57,31 @@ public class FedilabProfilePageAdapter extends FragmentStatePagerAdapter {
public Fragment getItem(int position) {
Bundle bundle = new Bundle();
bundle.putString(Helper.ARG_VIEW_MODEL_KEY, "FEDILAB_" + position);
- FragmentMastodonTimeline fragmentProfileTimeline;
+ FragmentMastodonTimeline fragmentMastodonTimeline;
+ Log.v(Helper.TAG, ">>>>>>>>>FedilabProfilePageAdapter: " + account);
+ Log.v(Helper.TAG, ">>>>>>>>>FedilabProfilePageAdapter ID: " + account.id);
switch (position) {
case 0 -> {
- fragmentProfileTimeline = new FragmentMastodonTimeline();
+ fragmentMastodonTimeline = new FragmentMastodonTimeline();
bundle.putSerializable(Helper.ARG_TIMELINE_TYPE, Timeline.TimeLineEnum.ACCOUNT_TIMELINE);
bundle.putSerializable(Helper.ARG_CACHED_ACCOUNT_ID, account.id);
bundle.putBoolean(Helper.ARG_SHOW_PINNED, true);
bundle.putBoolean(Helper.ARG_SHOW_REPLIES, false);
bundle.putBoolean(Helper.ARG_SHOW_REBLOGS, true);
bundle.putBoolean(Helper.ARG_CHECK_REMOTELY, checkRemotely);
- fragmentProfileTimeline.setArguments(bundle);
- return fragmentProfileTimeline;
+ fragmentMastodonTimeline.setArguments(bundle);
+ return fragmentMastodonTimeline;
}
case 1 -> {
- fragmentProfileTimeline = new FragmentMastodonTimeline();
+ fragmentMastodonTimeline = new FragmentMastodonTimeline();
bundle.putSerializable(Helper.ARG_TIMELINE_TYPE, Timeline.TimeLineEnum.ACCOUNT_TIMELINE);
bundle.putSerializable(Helper.ARG_CACHED_ACCOUNT_ID, account.id);
bundle.putBoolean(Helper.ARG_SHOW_PINNED, false);
bundle.putBoolean(Helper.ARG_SHOW_REPLIES, true);
bundle.putBoolean(Helper.ARG_SHOW_REBLOGS, false);
bundle.putBoolean(Helper.ARG_CHECK_REMOTELY, checkRemotely);
- fragmentProfileTimeline.setArguments(bundle);
- return fragmentProfileTimeline;
+ fragmentMastodonTimeline.setArguments(bundle);
+ return fragmentMastodonTimeline;
}
case 2 -> {
FragmentMediaProfile fragmentMediaProfile = new FragmentMediaProfile();