Loading app/src/main/java/app/fedilab/android/activities/ComposeActivity.java +1 −1 Original line number Diff line number Diff line Loading @@ -843,7 +843,7 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana } if (mediaCount > 0) { Data inputData = new Data.Builder() .putString(Helper.ARG_STATUS_DRAFT, ComposeWorker.serialize(statusDraft)) .putString(Helper.ARG_STATUS_DRAFT_ID, String.valueOf(statusDraft.id)) .putString(Helper.ARG_INSTANCE, instance) .putString(Helper.ARG_TOKEN, token) .putString(Helper.ARG_USER_ID, account.user_id) Loading app/src/main/java/app/fedilab/android/client/endpoints/MastodonTimelinesService.java +6 −6 Original line number Diff line number Diff line Loading @@ -66,15 +66,15 @@ public interface MastodonTimelinesService { Call<List<Status>> getHashTag( @Header("Authorization") String token, @Path("hashtag") String hashtag, @Query("local") boolean local, @Query("only_media") boolean only_media, @Query("local") Boolean local, @Query("only_media") Boolean only_media, @Query("all[]") List<String> all, @Query("any[]") List<String> any, @Query("none[]") List<String> none, @Query("max_id") String max_id, @Query("since_id") String since_id, @Query("min_id") String min_id, @Query("limit") int limit @Query("limit") Integer limit ); //Home timeline Loading @@ -84,8 +84,8 @@ public interface MastodonTimelinesService { @Query("max_id") String max_id, @Query("since_id") String since_id, @Query("min_id") String min_id, @Query("limit") int limit, @Query("local") boolean local @Query("limit") Integer limit, @Query("local") Boolean local ); //List timeline Loading @@ -96,7 +96,7 @@ public interface MastodonTimelinesService { @Query("max_id") String max_id, @Query("since_id") String since_id, @Query("min_id") String min_id, @Query("limit") int limit @Query("limit") Integer limit ); //get conversations Loading app/src/main/java/app/fedilab/android/client/entities/app/StatusCache.java +1 −2 Original line number Diff line number Diff line Loading @@ -441,14 +441,13 @@ public class StatusCache { } /** * @param slug String - slug for the timeline (it's a unique string value for a timeline) * @param instance String - instance * @param user_id String - us * @param search String search * @return - List<Status> * @throws DBException exception */ public List<Status> searchStatus(String slug, String instance, String user_id, String search) throws DBException { public List<Status> searchStatus(String instance, String user_id, String search) throws DBException { if (db == null) { throw new DBException("db is null. Wrong initialization."); } Loading app/src/main/java/app/fedilab/android/jobs/ComposeWorker.java +9 −1 Original line number Diff line number Diff line Loading @@ -363,7 +363,15 @@ public class ComposeWorker extends Worker { @Override public Result doWork() { Data inputData = getInputData(); StatusDraft statusDraft = restore(inputData.getString(Helper.ARG_STATUS_DRAFT)); String statusDraftId = inputData.getString(Helper.ARG_STATUS_DRAFT_ID); StatusDraft statusDraft = null; if (statusDraftId != null) { try { statusDraft = new StatusDraft(getApplicationContext()).geStatusDraft(statusDraftId); } catch (DBException e) { e.printStackTrace(); } } String token = inputData.getString(Helper.ARG_TOKEN); String instance = inputData.getString(Helper.ARG_INSTANCE); String userId = inputData.getString(Helper.ARG_USER_ID); Loading app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonTimeline.java +54 −1 Original line number Diff line number Diff line Loading @@ -581,7 +581,8 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter. } /** * Router for timelines * Router for common timelines that can have the same treatments * - HOME / LOCAL / PUBLIC / LIST / TAG * * @param direction - DIRECTION null if first call, then is set to TOP or BOTTOM depending of scroll */ Loading Loading @@ -619,6 +620,58 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter. timelineParams.hashtagTrim = tagTimeline.name; break; } SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity()); boolean useCache = sharedpreferences.getBoolean(getString(R.string.SET_USE_CACHE), true); if (useCache) { getCachedStatus(direction, fetchingMissing, timelineParams); } else { getLiveStatus(direction, fetchingMissing, timelineParams); } } private void getCachedStatus(DIRECTION direction, boolean fetchingMissing, TimelinesVM.TimelineParams timelineParams) { if (direction == null) { timelinesVM.getTimelineCache(timelineParams) .observe(getViewLifecycleOwner(), statusesCached -> { if (statusesCached == null || statusesCached.statuses == null || statusesCached.statuses.size() == 0) { getLiveStatus(null, fetchingMissing, timelineParams); } else { initializeStatusesCommonView(statusesCached); } }); } else if (direction == DIRECTION.BOTTOM) { timelinesVM.getTimelineCache(timelineParams) .observe(getViewLifecycleOwner(), statusesCachedBottom -> { if (statusesCachedBottom == null || statusesCachedBottom.statuses == null || statusesCachedBottom.statuses.size() == 0) { getLiveStatus(DIRECTION.BOTTOM, fetchingMissing, timelineParams); } else { dealWithPagination(statusesCachedBottom, DIRECTION.BOTTOM, fetchingMissing); } }); } else if (direction == DIRECTION.TOP) { timelinesVM.getTimelineCache(timelineParams) .observe(getViewLifecycleOwner(), statusesCachedTop -> { if (statusesCachedTop == null || statusesCachedTop.statuses == null || statusesCachedTop.statuses.size() == 0) { getLiveStatus(DIRECTION.TOP, fetchingMissing, timelineParams); } else { dealWithPagination(statusesCachedTop, DIRECTION.TOP, fetchingMissing); } }); } else if (direction == DIRECTION.REFRESH || direction == DIRECTION.SCROLL_TOP) { timelinesVM.getTimelineCache(timelineParams) .observe(getViewLifecycleOwner(), statusesRefresh -> { if (statusAdapter != null) { dealWithPagination(statusesRefresh, direction, true); } else { initializeStatusesCommonView(statusesRefresh); } }); } } private void getLiveStatus(DIRECTION direction, boolean fetchingMissing, TimelinesVM.TimelineParams timelineParams) { if (direction == null) { timelinesVM.getTimeline(timelineParams) .observe(getViewLifecycleOwner(), this::initializeStatusesCommonView); Loading Loading
app/src/main/java/app/fedilab/android/activities/ComposeActivity.java +1 −1 Original line number Diff line number Diff line Loading @@ -843,7 +843,7 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana } if (mediaCount > 0) { Data inputData = new Data.Builder() .putString(Helper.ARG_STATUS_DRAFT, ComposeWorker.serialize(statusDraft)) .putString(Helper.ARG_STATUS_DRAFT_ID, String.valueOf(statusDraft.id)) .putString(Helper.ARG_INSTANCE, instance) .putString(Helper.ARG_TOKEN, token) .putString(Helper.ARG_USER_ID, account.user_id) Loading
app/src/main/java/app/fedilab/android/client/endpoints/MastodonTimelinesService.java +6 −6 Original line number Diff line number Diff line Loading @@ -66,15 +66,15 @@ public interface MastodonTimelinesService { Call<List<Status>> getHashTag( @Header("Authorization") String token, @Path("hashtag") String hashtag, @Query("local") boolean local, @Query("only_media") boolean only_media, @Query("local") Boolean local, @Query("only_media") Boolean only_media, @Query("all[]") List<String> all, @Query("any[]") List<String> any, @Query("none[]") List<String> none, @Query("max_id") String max_id, @Query("since_id") String since_id, @Query("min_id") String min_id, @Query("limit") int limit @Query("limit") Integer limit ); //Home timeline Loading @@ -84,8 +84,8 @@ public interface MastodonTimelinesService { @Query("max_id") String max_id, @Query("since_id") String since_id, @Query("min_id") String min_id, @Query("limit") int limit, @Query("local") boolean local @Query("limit") Integer limit, @Query("local") Boolean local ); //List timeline Loading @@ -96,7 +96,7 @@ public interface MastodonTimelinesService { @Query("max_id") String max_id, @Query("since_id") String since_id, @Query("min_id") String min_id, @Query("limit") int limit @Query("limit") Integer limit ); //get conversations Loading
app/src/main/java/app/fedilab/android/client/entities/app/StatusCache.java +1 −2 Original line number Diff line number Diff line Loading @@ -441,14 +441,13 @@ public class StatusCache { } /** * @param slug String - slug for the timeline (it's a unique string value for a timeline) * @param instance String - instance * @param user_id String - us * @param search String search * @return - List<Status> * @throws DBException exception */ public List<Status> searchStatus(String slug, String instance, String user_id, String search) throws DBException { public List<Status> searchStatus(String instance, String user_id, String search) throws DBException { if (db == null) { throw new DBException("db is null. Wrong initialization."); } Loading
app/src/main/java/app/fedilab/android/jobs/ComposeWorker.java +9 −1 Original line number Diff line number Diff line Loading @@ -363,7 +363,15 @@ public class ComposeWorker extends Worker { @Override public Result doWork() { Data inputData = getInputData(); StatusDraft statusDraft = restore(inputData.getString(Helper.ARG_STATUS_DRAFT)); String statusDraftId = inputData.getString(Helper.ARG_STATUS_DRAFT_ID); StatusDraft statusDraft = null; if (statusDraftId != null) { try { statusDraft = new StatusDraft(getApplicationContext()).geStatusDraft(statusDraftId); } catch (DBException e) { e.printStackTrace(); } } String token = inputData.getString(Helper.ARG_TOKEN); String instance = inputData.getString(Helper.ARG_INSTANCE); String userId = inputData.getString(Helper.ARG_USER_ID); Loading
app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonTimeline.java +54 −1 Original line number Diff line number Diff line Loading @@ -581,7 +581,8 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter. } /** * Router for timelines * Router for common timelines that can have the same treatments * - HOME / LOCAL / PUBLIC / LIST / TAG * * @param direction - DIRECTION null if first call, then is set to TOP or BOTTOM depending of scroll */ Loading Loading @@ -619,6 +620,58 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter. timelineParams.hashtagTrim = tagTimeline.name; break; } SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity()); boolean useCache = sharedpreferences.getBoolean(getString(R.string.SET_USE_CACHE), true); if (useCache) { getCachedStatus(direction, fetchingMissing, timelineParams); } else { getLiveStatus(direction, fetchingMissing, timelineParams); } } private void getCachedStatus(DIRECTION direction, boolean fetchingMissing, TimelinesVM.TimelineParams timelineParams) { if (direction == null) { timelinesVM.getTimelineCache(timelineParams) .observe(getViewLifecycleOwner(), statusesCached -> { if (statusesCached == null || statusesCached.statuses == null || statusesCached.statuses.size() == 0) { getLiveStatus(null, fetchingMissing, timelineParams); } else { initializeStatusesCommonView(statusesCached); } }); } else if (direction == DIRECTION.BOTTOM) { timelinesVM.getTimelineCache(timelineParams) .observe(getViewLifecycleOwner(), statusesCachedBottom -> { if (statusesCachedBottom == null || statusesCachedBottom.statuses == null || statusesCachedBottom.statuses.size() == 0) { getLiveStatus(DIRECTION.BOTTOM, fetchingMissing, timelineParams); } else { dealWithPagination(statusesCachedBottom, DIRECTION.BOTTOM, fetchingMissing); } }); } else if (direction == DIRECTION.TOP) { timelinesVM.getTimelineCache(timelineParams) .observe(getViewLifecycleOwner(), statusesCachedTop -> { if (statusesCachedTop == null || statusesCachedTop.statuses == null || statusesCachedTop.statuses.size() == 0) { getLiveStatus(DIRECTION.TOP, fetchingMissing, timelineParams); } else { dealWithPagination(statusesCachedTop, DIRECTION.TOP, fetchingMissing); } }); } else if (direction == DIRECTION.REFRESH || direction == DIRECTION.SCROLL_TOP) { timelinesVM.getTimelineCache(timelineParams) .observe(getViewLifecycleOwner(), statusesRefresh -> { if (statusAdapter != null) { dealWithPagination(statusesRefresh, direction, true); } else { initializeStatusesCommonView(statusesRefresh); } }); } } private void getLiveStatus(DIRECTION direction, boolean fetchingMissing, TimelinesVM.TimelineParams timelineParams) { if (direction == null) { timelinesVM.getTimeline(timelineParams) .observe(getViewLifecycleOwner(), this::initializeStatusesCommonView); Loading