diff --git a/twidere.component.common/src/main/java/org/mariotaku/twidere/provider/TwidereDataStore.java b/twidere.component.common/src/main/java/org/mariotaku/twidere/provider/TwidereDataStore.java index bf43dc23f..ffbc06dfb 100644 --- a/twidere.component.common/src/main/java/org/mariotaku/twidere/provider/TwidereDataStore.java +++ b/twidere.component.common/src/main/java/org/mariotaku/twidere/provider/TwidereDataStore.java @@ -736,9 +736,10 @@ public interface TwidereDataStore { String[] TYPES = ParcelableStatusTableInfo.TYPES; - String[] STATUSES_TABLES = {HomeTimeline.TABLE_NAME, Favorites.TABLE_NAME, - UserTimeline.TABLE_NAME, UserMediaTimeline.TABLE_NAME, ListTimeline.TABLE_NAME, - GroupTimeline.TABLE_NAME, Public.TABLE_NAME, NetworkPublic.TABLE_NAME}; + String[] STATUSES_TABLES = {HomeTimeline.TABLE_NAME, Public.TABLE_NAME, NetworkPublic.TABLE_NAME, + Favorites.TABLE_NAME, UserTimeline.TABLE_NAME, UserMediaTimeline.TABLE_NAME, + ListTimeline.TABLE_NAME, GroupTimeline.TABLE_NAME, SearchTimeline.TABLE_NAME, + MediaSearchTimeline.TABLE_NAME, UserMentions.TABLE_NAME}; interface HomeTimeline extends Statuses { @@ -749,6 +750,24 @@ public interface TwidereDataStore { Uri CONTENT_URI = Uri.withAppendedPath(BASE_CONTENT_URI, CONTENT_PATH); } + interface Public extends Statuses { + + String CONTENT_PATH = "statuses/public_timeline"; + String TABLE_NAME = "public_timeline"; + + @NonNull + Uri CONTENT_URI = Uri.withAppendedPath(BASE_CONTENT_URI, CONTENT_PATH); + } + + interface NetworkPublic extends Statuses { + + String CONTENT_PATH = "statuses/network_public_timeline"; + String TABLE_NAME = "network_public_timeline"; + + @NonNull + Uri CONTENT_URI = Uri.withAppendedPath(BASE_CONTENT_URI, CONTENT_PATH); + } + interface Favorites extends Statuses { String CONTENT_PATH = "statuses/favorites_timeline"; @@ -796,19 +815,29 @@ public interface TwidereDataStore { Uri CONTENT_URI = Uri.withAppendedPath(BASE_CONTENT_URI, CONTENT_PATH); } - interface Public extends Statuses { + interface SearchTimeline extends Statuses { - String CONTENT_PATH = "statuses/public_timeline"; - String TABLE_NAME = "public_timeline"; + String CONTENT_PATH = "statuses/search_timeline"; + String TABLE_NAME = "search_timeline"; @NonNull Uri CONTENT_URI = Uri.withAppendedPath(BASE_CONTENT_URI, CONTENT_PATH); } - interface NetworkPublic extends Statuses { - String CONTENT_PATH = "statuses/network_public_timeline"; - String TABLE_NAME = "network_public_timeline"; + interface MediaSearchTimeline extends Statuses { + + String CONTENT_PATH = "statuses/media_search_timeline"; + String TABLE_NAME = "media_search_timeline"; + + @NonNull + Uri CONTENT_URI = Uri.withAppendedPath(BASE_CONTENT_URI, CONTENT_PATH); + } + + interface UserMentions extends Statuses { + + String CONTENT_PATH = "statuses/user_mentions"; + String TABLE_NAME = "user_mentions_timeline"; @NonNull Uri CONTENT_URI = Uri.withAppendedPath(BASE_CONTENT_URI, CONTENT_PATH); diff --git a/twidere/src/main/java/org/mariotaku/twidere/Constants.java b/twidere/src/main/java/org/mariotaku/twidere/Constants.java index 0e4657fb9..9ee1e73aa 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/Constants.java +++ b/twidere/src/main/java/org/mariotaku/twidere/Constants.java @@ -30,7 +30,7 @@ import org.mariotaku.twidere.model.UserKey; public interface Constants extends TwidereConstants { String DATABASES_NAME = "twidere.sqlite"; - int DATABASES_VERSION = 191; + int DATABASES_VERSION = 192; int EXTRA_FEATURES_NOTICE_VERSION = 2; diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/adapter/ParcelableStatusesAdapter.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/adapter/ParcelableStatusesAdapter.kt index 30a5a0e4d..b4acd8a02 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/adapter/ParcelableStatusesAdapter.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/adapter/ParcelableStatusesAdapter.kt @@ -55,7 +55,10 @@ import org.mariotaku.twidere.util.StatusAdapterLinkClickHandler import org.mariotaku.twidere.util.TwidereLinkify import org.mariotaku.twidere.util.Utils import org.mariotaku.twidere.util.paging.DiffCallbacks -import org.mariotaku.twidere.view.holder.* +import org.mariotaku.twidere.view.holder.EmptyViewHolder +import org.mariotaku.twidere.view.holder.GapViewHolder +import org.mariotaku.twidere.view.holder.LoadIndicatorViewHolder +import org.mariotaku.twidere.view.holder.TimelineFilterHeaderViewHolder import org.mariotaku.twidere.view.holder.iface.IStatusViewHolder import org.mariotaku.twidere.view.holder.status.LargeMediaStatusViewHolder import org.mariotaku.twidere.view.holder.status.MediaStatusViewHolder @@ -128,11 +131,13 @@ class ParcelableStatusesAdapter( private var pagedStatusesHelper = PagedListAdapterHelper(object : ListUpdateCallback { override fun onInserted(position: Int, count: Int) { + itemCounts[ITEM_INDEX_STATUS] += count updateItemCount() notifyItemRangeInserted(position, count) } override fun onRemoved(position: Int, count: Int) { + itemCounts[ITEM_INDEX_STATUS] -= count updateItemCount() notifyItemRangeRemoved(position, count) } @@ -144,6 +149,7 @@ class ParcelableStatusesAdapter( override fun onChanged(position: Int, count: Int, payload: Any?) { updateItemCount() + gapLoadingIds.clear() notifyItemRangeChanged(position, count, payload) } @@ -151,12 +157,7 @@ class ParcelableStatusesAdapter( var statuses: PagedList? get() = pagedStatusesHelper.currentList - set(value) { - pagedStatusesHelper.setList(value) - gapLoadingIds.clear() - updateItemCount() - notifyDataSetChanged() - } + set(value) = pagedStatusesHelper.setList(value) val statusStartIndex: Int get() = getItemStartPosition(ITEM_INDEX_STATUS) @@ -192,8 +193,7 @@ class ParcelableStatusesAdapter( } override fun getStatusCount(raw: Boolean): Int { - if (raw) return statuses?.size ?: 0 - return pagedStatusesHelper.itemCount + return itemCounts[ITEM_INDEX_STATUS] } override fun getItemId(position: Int): Long { @@ -439,7 +439,6 @@ class ParcelableStatusesAdapter( itemCounts[ITEM_INDEX_LOAD_START_INDICATOR] = if (ILoadMoreSupportAdapter.START in loadMoreIndicatorPosition) 1 else 0 itemCounts[ITEM_INDEX_FILTER_HEADER] = if (timelineFilter != null) 1 else 0 itemCounts[ITEM_INDEX_PINNED_STATUS] = pinnedStatuses?.size ?: 0 - itemCounts[ITEM_INDEX_STATUS] = getStatusCount(false) itemCounts[ITEM_INDEX_LOAD_END_INDICATOR] = if (ILoadMoreSupportAdapter.END in loadMoreIndicatorPosition) 1 else 0 } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/constant/TableIds.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/constant/TableIds.kt index 88cfe7b61..b201a8982 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/constant/TableIds.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/constant/TableIds.kt @@ -22,13 +22,16 @@ package org.mariotaku.twidere.constant object TableIds { const val HOME_TIMELINE = 11 - const val FAVORITES = 12 - const val USER_TIMELINE = 13 - const val USER_MEDIA_TIMELINE = 14 - const val LIST_TIMELINE = 15 - const val GROUP_TIMELINE = 16 - const val PUBLIC_TIMELINE = 17 - const val NETWORK_PUBLIC_TIMELINE = 18 + const val PUBLIC_TIMELINE = 12 + const val NETWORK_PUBLIC_TIMELINE = 13 + + const val FAVORITES = 21 + const val USER_TIMELINE = 22 + const val USER_MEDIA_TIMELINE = 23 + const val LIST_TIMELINE = 24 + const val GROUP_TIMELINE = 25 + const val SEARCH_TIMELINE = 26 + const val MEDIA_SEARCH_TIMELINE = 27 const val ACTIVITIES_ABOUT_ME = 51 const val ACTIVITIES_BY_FRIENDS = 52 diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/data/source/CursorObjectLivePagedListProvider.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/data/source/CursorObjectLivePagedListProvider.kt index 1d8c1f11d..d682108d6 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/data/source/CursorObjectLivePagedListProvider.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/data/source/CursorObjectLivePagedListProvider.kt @@ -23,10 +23,6 @@ import android.arch.paging.LivePagedListProvider import android.content.ContentResolver import android.net.Uri -/** - * Created by mariotaku on 2017/10/13. - */ - class CursorObjectLivePagedListProvider( private val resolver: ContentResolver, val uri: Uri, diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/data/source/CursorObjectTiledDataSource.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/data/source/CursorObjectTiledDataSource.kt index 9370a6c2e..4854a0604 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/data/source/CursorObjectTiledDataSource.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/data/source/CursorObjectTiledDataSource.kt @@ -41,15 +41,11 @@ class CursorObjectTiledDataSource( init { val weakThis = toWeak() - val observer = object : ContentObserver(MainHandler) { + resolver.registerContentObserver(uri, false, object : ContentObserver(MainHandler) { override fun onChange(selfChange: Boolean) { weakThis.get()?.invalidate() } - } - addInvalidatedCallback cb@ { - resolver.unregisterContentObserver(observer) - } - resolver.registerContentObserver(uri, false, observer) + }) } override fun countItems() = resolver.queryCount(uri, selection, selectionArgs) diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/timeline/FavoritesTimelineFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/timeline/FavoritesTimelineFragment.kt index fb54b3293..8d07f0e0d 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/timeline/FavoritesTimelineFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/timeline/FavoritesTimelineFragment.kt @@ -31,6 +31,7 @@ import org.mariotaku.twidere.constant.iWantMyStarsBackKey import org.mariotaku.twidere.data.fetcher.UserFavoritesFetcher import org.mariotaku.twidere.extension.adapter.removeStatuses import org.mariotaku.twidere.extension.linkHandlerTitle +import org.mariotaku.twidere.extension.withAppendedPath import org.mariotaku.twidere.model.event.FavoriteTaskEvent import org.mariotaku.twidere.model.refresh.ContentRefreshParam import org.mariotaku.twidere.model.refresh.UserRelatedContentRefreshParam @@ -41,7 +42,8 @@ class FavoritesTimelineFragment : AbsTimelineFragment() { override val filterScope: Int = FilterScope.HOME - override val contentUri: Uri = Statuses.HomeTimeline.CONTENT_URI + override val contentUri: Uri + get() = Statuses.Favorites.CONTENT_URI.withAppendedPath(tabId) override fun onActivityCreated(savedInstanceState: Bundle?) { super.onActivityCreated(savedInstanceState) diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/timeline/GroupTimelineFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/timeline/GroupTimelineFragment.kt index 74aaf6741..8129383f2 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/timeline/GroupTimelineFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/timeline/GroupTimelineFragment.kt @@ -39,6 +39,7 @@ import org.mariotaku.twidere.constant.IntentConstants.EXTRA_GROUP_NAME import org.mariotaku.twidere.data.fetcher.GroupTimelineFetcher import org.mariotaku.twidere.extension.linkHandlerTitle import org.mariotaku.twidere.extension.model.tab.applyToSelection +import org.mariotaku.twidere.extension.withAppendedPath import org.mariotaku.twidere.model.refresh.ContentRefreshParam import org.mariotaku.twidere.model.refresh.GroupTimelineContentRefreshParam import org.mariotaku.twidere.model.tab.extra.HomeTabExtras @@ -49,7 +50,8 @@ import java.util.* class GroupTimelineFragment : AbsTimelineFragment() { override val filterScope: Int = FilterScope.LIST_GROUP_TIMELINE - override val contentUri: Uri = Statuses.GroupTimeline.CONTENT_URI + override val contentUri: Uri + get() = Statuses.GroupTimeline.CONTENT_URI.withAppendedPath(tabId) override fun onActivityCreated(savedInstanceState: Bundle?) { super.onActivityCreated(savedInstanceState) diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/timeline/ListTimelineFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/timeline/ListTimelineFragment.kt index 9a0434909..690217314 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/timeline/ListTimelineFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/timeline/ListTimelineFragment.kt @@ -29,6 +29,7 @@ import org.mariotaku.twidere.constant.IntentConstants.* import org.mariotaku.twidere.data.fetcher.ListTimelineFetcher import org.mariotaku.twidere.extension.linkHandlerTitle import org.mariotaku.twidere.extension.model.tab.applyToSelection +import org.mariotaku.twidere.extension.withAppendedPath import org.mariotaku.twidere.model.UserKey import org.mariotaku.twidere.model.refresh.ContentRefreshParam import org.mariotaku.twidere.model.refresh.ListTimelineContentRefreshParam @@ -40,7 +41,8 @@ import java.util.* class ListTimelineFragment : AbsTimelineFragment() { override val filterScope: Int = FilterScope.LIST_GROUP_TIMELINE - override val contentUri: Uri = Statuses.ListTimeline.CONTENT_URI + override val contentUri: Uri + get() = Statuses.ListTimeline.CONTENT_URI.withAppendedPath(tabId) override fun onActivityCreated(savedInstanceState: Bundle?) { super.onActivityCreated(savedInstanceState) diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/timeline/MediaSearchTimelineFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/timeline/MediaSearchTimelineFragment.kt index c0a18d2ca..31d4f8f89 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/timeline/MediaSearchTimelineFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/timeline/MediaSearchTimelineFragment.kt @@ -20,20 +20,30 @@ package org.mariotaku.twidere.fragment.timeline import android.net.Uri +import org.mariotaku.abstask.library.TaskStarter import org.mariotaku.twidere.annotation.FilterScope +import org.mariotaku.twidere.constant.IntentConstants.EXTRA_LOCAL import org.mariotaku.twidere.constant.IntentConstants.EXTRA_QUERY import org.mariotaku.twidere.data.fetcher.MediaSearchTimelineFetcher import org.mariotaku.twidere.data.fetcher.StatusesFetcher +import org.mariotaku.twidere.extension.withAppendedPath import org.mariotaku.twidere.model.refresh.ContentRefreshParam +import org.mariotaku.twidere.model.refresh.SearchTimelineContentRefreshParam +import org.mariotaku.twidere.provider.TwidereDataStore.Statuses +import org.mariotaku.twidere.task.statuses.GetMediaSearchTimelineTask class MediaSearchTimelineFragment : AbsTimelineFragment() { override val filterScope: Int get() = FilterScope.SEARCH_RESULTS override val contentUri: Uri - get() = TODO("not implemented") + get() = Statuses.MediaSearchTimeline.CONTENT_URI.withAppendedPath(tabId) override fun getStatuses(param: ContentRefreshParam): Boolean { - TODO("not implemented") + val task = GetMediaSearchTimelineTask(context) + task.params = SearchTimelineContentRefreshParam(arguments.getString(EXTRA_QUERY), + arguments.getBoolean(EXTRA_LOCAL, false), param) + TaskStarter.execute(task) + return true } override fun onCreateStatusesFetcher(): StatusesFetcher { diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/timeline/PublicTimelineFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/timeline/PublicTimelineFragment.kt index 3d590c859..9fc896cfa 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/timeline/PublicTimelineFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/timeline/PublicTimelineFragment.kt @@ -41,6 +41,7 @@ class PublicTimelineFragment : AbsTimelineFragment() { override val filterScope: Int = FilterScope.PUBLIC_TIMELINE override val contentUri: Uri = Statuses.Public.CONTENT_URI + override fun onActivityCreated(savedInstanceState: Bundle?) { super.onActivityCreated(savedInstanceState) linkHandlerTitle = getString(R.string.title_public_timeline) diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/timeline/SearchTimelineFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/timeline/SearchTimelineFragment.kt index f4f7a1167..f1295e762 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/timeline/SearchTimelineFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/timeline/SearchTimelineFragment.kt @@ -21,6 +21,7 @@ package org.mariotaku.twidere.fragment.timeline import android.net.Uri import android.os.Bundle +import org.mariotaku.abstask.library.TaskStarter import org.mariotaku.twidere.R import org.mariotaku.twidere.annotation.FilterScope import org.mariotaku.twidere.constant.IntentConstants.EXTRA_LOCAL @@ -28,13 +29,17 @@ import org.mariotaku.twidere.constant.IntentConstants.EXTRA_QUERY import org.mariotaku.twidere.data.fetcher.SearchTimelineFetcher import org.mariotaku.twidere.data.fetcher.StatusesFetcher import org.mariotaku.twidere.extension.linkHandlerTitle +import org.mariotaku.twidere.extension.withAppendedPath import org.mariotaku.twidere.model.refresh.ContentRefreshParam +import org.mariotaku.twidere.model.refresh.SearchTimelineContentRefreshParam +import org.mariotaku.twidere.provider.TwidereDataStore.Statuses +import org.mariotaku.twidere.task.statuses.GetSearchTimelineTask class SearchTimelineFragment : AbsTimelineFragment() { override val filterScope: Int get() = FilterScope.SEARCH_RESULTS override val contentUri: Uri - get() = TODO("not implemented") + get() = Statuses.SearchTimeline.CONTENT_URI.withAppendedPath(tabId) override fun onActivityCreated(savedInstanceState: Bundle?) { super.onActivityCreated(savedInstanceState) @@ -42,7 +47,11 @@ class SearchTimelineFragment : AbsTimelineFragment() { } override fun getStatuses(param: ContentRefreshParam): Boolean { - TODO("not implemented") + val task = GetSearchTimelineTask(context) + task.params = SearchTimelineContentRefreshParam(arguments.getString(EXTRA_QUERY), + arguments.getBoolean(EXTRA_LOCAL, false), param) + TaskStarter.execute(task) + return true } override fun onCreateStatusesFetcher(): StatusesFetcher { diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/timeline/UserMentionsTimelineFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/timeline/UserMentionsTimelineFragment.kt index 48e2ad023..ff60427c9 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/timeline/UserMentionsTimelineFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/timeline/UserMentionsTimelineFragment.kt @@ -21,6 +21,7 @@ package org.mariotaku.twidere.fragment.timeline import android.net.Uri import android.os.Bundle +import org.mariotaku.abstask.library.TaskStarter import org.mariotaku.twidere.R import org.mariotaku.twidere.annotation.FilterScope import org.mariotaku.twidere.constant.IntentConstants.EXTRA_SCREEN_NAME @@ -28,13 +29,17 @@ import org.mariotaku.twidere.constant.IntentConstants.EXTRA_USER_KEY import org.mariotaku.twidere.data.fetcher.StatusesFetcher import org.mariotaku.twidere.data.fetcher.UserMentionsTimelineFetcher import org.mariotaku.twidere.extension.linkHandlerTitle +import org.mariotaku.twidere.extension.withAppendedPath import org.mariotaku.twidere.model.refresh.ContentRefreshParam +import org.mariotaku.twidere.model.refresh.UserRelatedContentRefreshParam +import org.mariotaku.twidere.provider.TwidereDataStore.Statuses +import org.mariotaku.twidere.task.statuses.GetUserMentionsTimelineTask class UserMentionsTimelineFragment : AbsTimelineFragment() { override val filterScope: Int get() = FilterScope.SEARCH_RESULTS override val contentUri: Uri - get() = TODO("not implemented") + get() = Statuses.UserMentions.CONTENT_URI.withAppendedPath(tabId) override fun onActivityCreated(savedInstanceState: Bundle?) { super.onActivityCreated(savedInstanceState) @@ -42,7 +47,11 @@ class UserMentionsTimelineFragment : AbsTimelineFragment() { } override fun getStatuses(param: ContentRefreshParam): Boolean { - TODO("not implemented") + val task = GetUserMentionsTimelineTask(context) + task.params = UserRelatedContentRefreshParam(arguments.getParcelable(EXTRA_USER_KEY), + arguments.getString(EXTRA_SCREEN_NAME), param) + TaskStarter.execute(task) + return true } override fun onCreateStatusesFetcher(): StatusesFetcher { diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/timeline/UserTimelineFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/timeline/UserTimelineFragment.kt index 38b723400..7aa36d0b4 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/timeline/UserTimelineFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/timeline/UserTimelineFragment.kt @@ -35,6 +35,7 @@ import org.mariotaku.twidere.data.fetcher.UserTimelineFetcher import org.mariotaku.twidere.extension.applyTheme import org.mariotaku.twidere.extension.linkHandlerTitle import org.mariotaku.twidere.extension.onShow +import org.mariotaku.twidere.extension.withAppendedPath import org.mariotaku.twidere.fragment.BaseDialogFragment import org.mariotaku.twidere.model.refresh.ContentRefreshParam import org.mariotaku.twidere.model.refresh.UserRelatedContentRefreshParam @@ -46,7 +47,8 @@ import org.mariotaku.twidere.task.statuses.GetUserTimelineTask class UserTimelineFragment : AbsTimelineFragment() { override val filterScope: Int = FilterScope.USER_TIMELINE - override val contentUri: Uri = Statuses.UserTimeline.CONTENT_URI + override val contentUri: Uri + get() = Statuses.UserTimeline.CONTENT_URI.withAppendedPath(tabId) override val timelineFilter: TimelineFilter? get() = if (arguments.getBoolean(EXTRA_ENABLE_TIMELINE_FILTER)) preferences[userTimelineFilterKey] else null diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/model/refresh/SearchTimelineContentRefreshParam.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/model/refresh/SearchTimelineContentRefreshParam.kt new file mode 100644 index 000000000..816ac3dc1 --- /dev/null +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/model/refresh/SearchTimelineContentRefreshParam.kt @@ -0,0 +1,26 @@ +/* + * Twidere - Twitter client for Android + * + * Copyright (C) 2012-2017 Mariotaku Lee + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.mariotaku.twidere.model.refresh + +class SearchTimelineContentRefreshParam( + val query: String?, + val local: Boolean, + delegated: ContentRefreshParam +) : DelegateContentRefreshParam(delegated) \ No newline at end of file diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/task/statuses/GetGroupTimelineTask.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/task/statuses/GetGroupTimelineTask.kt index 9fbb99d8e..ca9c0d01b 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/task/statuses/GetGroupTimelineTask.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/task/statuses/GetGroupTimelineTask.kt @@ -24,6 +24,7 @@ import android.net.Uri import org.mariotaku.twidere.annotation.FilterScope import org.mariotaku.twidere.data.fetcher.GroupTimelineFetcher import org.mariotaku.twidere.data.fetcher.StatusesFetcher +import org.mariotaku.twidere.extension.withAppendedPath import org.mariotaku.twidere.model.UserKey import org.mariotaku.twidere.model.refresh.GroupTimelineContentRefreshParam import org.mariotaku.twidere.provider.TwidereDataStore.Statuses @@ -32,7 +33,8 @@ import org.mariotaku.twidere.util.sync.TimelineSyncManager class GetGroupTimelineTask(context: Context) : GetStatusesTask(context) { - override val contentUri: Uri = Statuses.GroupTimeline.CONTENT_URI + override val contentUri: Uri + get() = Statuses.GroupTimeline.CONTENT_URI.withAppendedPath(params.tabId) override val filterScopes: Int = FilterScope.LIST_GROUP_TIMELINE diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/task/statuses/GetListTimelineTask.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/task/statuses/GetListTimelineTask.kt index dca0fd0ff..667f5b891 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/task/statuses/GetListTimelineTask.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/task/statuses/GetListTimelineTask.kt @@ -24,6 +24,7 @@ import android.net.Uri import org.mariotaku.twidere.annotation.FilterScope import org.mariotaku.twidere.data.fetcher.ListTimelineFetcher import org.mariotaku.twidere.data.fetcher.StatusesFetcher +import org.mariotaku.twidere.extension.withAppendedPath import org.mariotaku.twidere.model.UserKey import org.mariotaku.twidere.model.refresh.ListTimelineContentRefreshParam import org.mariotaku.twidere.provider.TwidereDataStore.Statuses @@ -32,7 +33,8 @@ import org.mariotaku.twidere.util.sync.TimelineSyncManager class GetListTimelineTask(context: Context) : GetStatusesTask(context) { - override val contentUri: Uri = Statuses.GroupTimeline.CONTENT_URI + override val contentUri: Uri + get() = Statuses.GroupTimeline.CONTENT_URI.withAppendedPath(params.tabId) override val filterScopes: Int = FilterScope.LIST_GROUP_TIMELINE diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/task/statuses/GetMediaSearchTimelineTask.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/task/statuses/GetMediaSearchTimelineTask.kt new file mode 100644 index 000000000..48cbd130b --- /dev/null +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/task/statuses/GetMediaSearchTimelineTask.kt @@ -0,0 +1,50 @@ +/* + * Twidere - Twitter client for Android + * + * Copyright (C) 2012-2017 Mariotaku Lee + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.mariotaku.twidere.task.statuses + +import android.content.Context +import android.net.Uri +import org.mariotaku.twidere.annotation.FilterScope +import org.mariotaku.twidere.data.fetcher.MediaSearchTimelineFetcher +import org.mariotaku.twidere.data.fetcher.StatusesFetcher +import org.mariotaku.twidere.extension.withAppendedPath +import org.mariotaku.twidere.model.UserKey +import org.mariotaku.twidere.model.refresh.SearchTimelineContentRefreshParam +import org.mariotaku.twidere.provider.TwidereDataStore.Statuses +import org.mariotaku.twidere.util.ErrorInfoStore +import org.mariotaku.twidere.util.sync.TimelineSyncManager + +class GetMediaSearchTimelineTask(context: Context) : GetStatusesTask(context) { + + override val contentUri: Uri + get() = Statuses.MediaSearchTimeline.CONTENT_URI.withAppendedPath(params.tabId) + + override val filterScopes: Int = FilterScope.SEARCH_RESULTS + + override val errorInfoKey: String = ErrorInfoStore.KEY_SEARCH_TIMELINE + + override fun getStatusesFetcher(params: SearchTimelineContentRefreshParam?): StatusesFetcher { + return MediaSearchTimelineFetcher(params?.query) + } + + override fun syncFetchReadPosition(manager: TimelineSyncManager, accountKeys: Array) { + } + +} \ No newline at end of file diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/task/statuses/GetSearchTimelineTask.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/task/statuses/GetSearchTimelineTask.kt new file mode 100644 index 000000000..60b4bb1a1 --- /dev/null +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/task/statuses/GetSearchTimelineTask.kt @@ -0,0 +1,50 @@ +/* + * Twidere - Twitter client for Android + * + * Copyright (C) 2012-2017 Mariotaku Lee + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.mariotaku.twidere.task.statuses + +import android.content.Context +import android.net.Uri +import org.mariotaku.twidere.annotation.FilterScope +import org.mariotaku.twidere.data.fetcher.SearchTimelineFetcher +import org.mariotaku.twidere.data.fetcher.StatusesFetcher +import org.mariotaku.twidere.extension.withAppendedPath +import org.mariotaku.twidere.model.UserKey +import org.mariotaku.twidere.model.refresh.SearchTimelineContentRefreshParam +import org.mariotaku.twidere.provider.TwidereDataStore.Statuses +import org.mariotaku.twidere.util.ErrorInfoStore +import org.mariotaku.twidere.util.sync.TimelineSyncManager + +class GetSearchTimelineTask(context: Context) : GetStatusesTask(context) { + + override val contentUri: Uri + get() = Statuses.SearchTimeline.CONTENT_URI.withAppendedPath(params.tabId) + + override val filterScopes: Int = FilterScope.SEARCH_RESULTS + + override val errorInfoKey: String = ErrorInfoStore.KEY_SEARCH_TIMELINE + + override fun getStatusesFetcher(params: SearchTimelineContentRefreshParam?): StatusesFetcher { + return SearchTimelineFetcher(params?.query, params?.local ?: false) + } + + override fun syncFetchReadPosition(manager: TimelineSyncManager, accountKeys: Array) { + } + +} \ No newline at end of file diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/task/statuses/GetUserFavoritesTask.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/task/statuses/GetUserFavoritesTask.kt index 266f1f37d..855f15feb 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/task/statuses/GetUserFavoritesTask.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/task/statuses/GetUserFavoritesTask.kt @@ -23,6 +23,7 @@ import android.content.Context import android.net.Uri import org.mariotaku.twidere.annotation.FilterScope import org.mariotaku.twidere.data.fetcher.UserFavoritesFetcher +import org.mariotaku.twidere.extension.withAppendedPath import org.mariotaku.twidere.model.UserKey import org.mariotaku.twidere.model.refresh.UserRelatedContentRefreshParam import org.mariotaku.twidere.provider.TwidereDataStore.Statuses @@ -31,7 +32,8 @@ import org.mariotaku.twidere.util.sync.TimelineSyncManager class GetUserFavoritesTask(context: Context) : GetStatusesTask(context) { - override val contentUri: Uri = Statuses.Favorites.CONTENT_URI + override val contentUri: Uri + get() = Statuses.Favorites.CONTENT_URI.withAppendedPath(params.tabId) override val filterScopes: Int = FilterScope.FAVORITES diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/task/statuses/GetUserMentionsTimelineTask.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/task/statuses/GetUserMentionsTimelineTask.kt new file mode 100644 index 000000000..0a280dd52 --- /dev/null +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/task/statuses/GetUserMentionsTimelineTask.kt @@ -0,0 +1,49 @@ +/* + * Twidere - Twitter client for Android + * + * Copyright (C) 2012-2017 Mariotaku Lee + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.mariotaku.twidere.task.statuses + +import android.content.Context +import android.net.Uri +import org.mariotaku.twidere.annotation.FilterScope +import org.mariotaku.twidere.data.fetcher.UserTimelineFetcher +import org.mariotaku.twidere.extension.withAppendedPath +import org.mariotaku.twidere.model.UserKey +import org.mariotaku.twidere.model.refresh.UserRelatedContentRefreshParam +import org.mariotaku.twidere.provider.TwidereDataStore.Statuses +import org.mariotaku.twidere.util.ErrorInfoStore +import org.mariotaku.twidere.util.sync.TimelineSyncManager + +class GetUserMentionsTimelineTask(context: Context) : GetStatusesTask(context) { + + override val contentUri: Uri + get() = Statuses.UserMentions.CONTENT_URI.withAppendedPath(params.tabId) + + override val filterScopes: Int = FilterScope.USER_TIMELINE + + override val errorInfoKey: String = ErrorInfoStore.KEY_USER_TIMELINE + + override fun getStatusesFetcher(params: UserRelatedContentRefreshParam?): UserTimelineFetcher { + return UserTimelineFetcher(params?.userKey, params?.userScreenName, null) + } + + override fun syncFetchReadPosition(manager: TimelineSyncManager, accountKeys: Array) { + } + +} \ No newline at end of file diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/task/statuses/GetUserTimelineTask.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/task/statuses/GetUserTimelineTask.kt index 5e357eb03..27eb386ef 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/task/statuses/GetUserTimelineTask.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/task/statuses/GetUserTimelineTask.kt @@ -23,6 +23,7 @@ import android.content.Context import android.net.Uri import org.mariotaku.twidere.annotation.FilterScope import org.mariotaku.twidere.data.fetcher.UserTimelineFetcher +import org.mariotaku.twidere.extension.withAppendedPath import org.mariotaku.twidere.model.UserKey import org.mariotaku.twidere.model.refresh.UserRelatedContentRefreshParam import org.mariotaku.twidere.provider.TwidereDataStore.Statuses @@ -31,7 +32,8 @@ import org.mariotaku.twidere.util.sync.TimelineSyncManager class GetUserTimelineTask(context: Context) : GetStatusesTask(context) { - override val contentUri: Uri = Statuses.UserTimeline.CONTENT_URI + override val contentUri: Uri + get() = Statuses.UserTimeline.CONTENT_URI.withAppendedPath(params.tabId) override val filterScopes: Int = FilterScope.USER_TIMELINE diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/util/DataStoreUtils.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/util/DataStoreUtils.kt index f11456296..787e38b63 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/util/DataStoreUtils.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/util/DataStoreUtils.kt @@ -79,21 +79,24 @@ object DataStoreUtils { init { tableMatcher.addPath(Statuses.HomeTimeline.CONTENT_PATH, TableIds.HOME_TIMELINE) + tableMatcher.addPath(Statuses.Public.CONTENT_PATH, TableIds.PUBLIC_TIMELINE) + tableMatcher.addPath(Statuses.NetworkPublic.CONTENT_PATH, TableIds.NETWORK_PUBLIC_TIMELINE) + tableMatcher.addPath(Statuses.Favorites.CONTENT_PATH, TableIds.FAVORITES) tableMatcher.addPath(Statuses.UserTimeline.CONTENT_PATH, TableIds.USER_TIMELINE) tableMatcher.addPath(Statuses.UserMediaTimeline.CONTENT_PATH, TableIds.USER_MEDIA_TIMELINE) tableMatcher.addPath(Statuses.ListTimeline.CONTENT_PATH, TableIds.LIST_TIMELINE) tableMatcher.addPath(Statuses.GroupTimeline.CONTENT_PATH, TableIds.GROUP_TIMELINE) - tableMatcher.addPath(Statuses.Public.CONTENT_PATH, TableIds.PUBLIC_TIMELINE) - tableMatcher.addPath(Statuses.NetworkPublic.CONTENT_PATH, TableIds.NETWORK_PUBLIC_TIMELINE) + tableMatcher.addPath(Statuses.SearchTimeline.CONTENT_PATH, TableIds.SEARCH_TIMELINE) + tableMatcher.addPath(Statuses.MediaSearchTimeline.CONTENT_PATH, TableIds.MEDIA_SEARCH_TIMELINE) tableMatcher.addPath("${Statuses.Favorites.CONTENT_PATH}/#", TableIds.FAVORITES) tableMatcher.addPath("${Statuses.UserTimeline.CONTENT_PATH}/#", TableIds.USER_TIMELINE) tableMatcher.addPath("${Statuses.UserMediaTimeline.CONTENT_PATH}/#", TableIds.USER_MEDIA_TIMELINE) tableMatcher.addPath("${Statuses.ListTimeline.CONTENT_PATH}/#", TableIds.LIST_TIMELINE) tableMatcher.addPath("${Statuses.GroupTimeline.CONTENT_PATH}/#", TableIds.GROUP_TIMELINE) - tableMatcher.addPath("${Statuses.Public.CONTENT_PATH}/#", TableIds.PUBLIC_TIMELINE) - tableMatcher.addPath("${Statuses.NetworkPublic.CONTENT_PATH}/#", TableIds.NETWORK_PUBLIC_TIMELINE) + tableMatcher.addPath("${Statuses.SearchTimeline.CONTENT_PATH}/#", TableIds.SEARCH_TIMELINE) + tableMatcher.addPath("${Statuses.MediaSearchTimeline.CONTENT_PATH}/#", TableIds.MEDIA_SEARCH_TIMELINE) tableMatcher.addPath(Activities.AboutMe.CONTENT_PATH, TableIds.ACTIVITIES_ABOUT_ME) tableMatcher.addPath(Drafts.CONTENT_PATH, TableIds.DRAFTS) diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/util/ErrorInfoStore.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/util/ErrorInfoStore.kt index 0d4293509..6fb840421 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/util/ErrorInfoStore.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/util/ErrorInfoStore.kt @@ -87,6 +87,7 @@ class ErrorInfoStore(application: Context) { val KEY_PUBLIC_TIMELINE = "public_timeline" val KEY_FAVORITES_TIMELINE = "favorites_timeline" val KEY_USER_TIMELINE = "user_timeline" + val KEY_SEARCH_TIMELINE = "search_timeline" val KEY_LIST_GROUP_TIMELINE = "list_group_timeline" val KEY_NETWORK_PUBLIC_TIMELINE = "network_public_timeline" val KEY_ACTIVITIES_BY_FRIENDS = "activities_by_friends"