mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2024-12-22 16:50:04 +02:00
Working pagers
This commit is contained in:
parent
08c1ba943b
commit
b052547cc4
6 changed files with 121 additions and 182 deletions
|
@ -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;
|
||||
|
||||
|
@ -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));
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@ 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;
|
||||
|
@ -58,8 +57,6 @@ public class FedilabProfilePageAdapter extends FragmentStatePagerAdapter {
|
|||
Bundle bundle = new Bundle();
|
||||
bundle.putString(Helper.ARG_VIEW_MODEL_KEY, "FEDILAB_" + position);
|
||||
FragmentMastodonTimeline fragmentMastodonTimeline;
|
||||
Log.v(Helper.TAG, ">>>>>>>>>FedilabProfilePageAdapter: " + account);
|
||||
Log.v(Helper.TAG, ">>>>>>>>>FedilabProfilePageAdapter ID: " + account.id);
|
||||
switch (position) {
|
||||
case 0 -> {
|
||||
fragmentMastodonTimeline = new FragmentMastodonTimeline();
|
||||
|
|
Loading…
Reference in a new issue