implemented custom timeline tabs

fixed datastore reload
This commit is contained in:
Mariotaku Lee 2017-10-29 23:05:30 +08:00
parent ed8fbd662e
commit 6bfd4186bb
No known key found for this signature in database
GPG Key ID: 15C10F89D7C33535
24 changed files with 302 additions and 55 deletions

View File

@ -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);

View File

@ -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;

View File

@ -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<ParcelableStatus>(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<ParcelableStatus>?
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
}

View File

@ -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

View File

@ -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<T>(
private val resolver: ContentResolver,
val uri: Uri,

View File

@ -41,15 +41,11 @@ class CursorObjectTiledDataSource<T>(
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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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 {

View File

@ -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)

View File

@ -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 {

View File

@ -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 {

View File

@ -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

View File

@ -0,0 +1,26 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2017 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* 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 <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.model.refresh
class SearchTimelineContentRefreshParam(
val query: String?,
val local: Boolean,
delegated: ContentRefreshParam
) : DelegateContentRefreshParam(delegated)

View File

@ -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<GroupTimelineContentRefreshParam>(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

View File

@ -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<ListTimelineContentRefreshParam>(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

View File

@ -0,0 +1,50 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2017 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* 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 <http://www.gnu.org/licenses/>.
*/
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<SearchTimelineContentRefreshParam>(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<UserKey>) {
}
}

View File

@ -0,0 +1,50 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2017 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* 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 <http://www.gnu.org/licenses/>.
*/
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<SearchTimelineContentRefreshParam>(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<UserKey>) {
}
}

View File

@ -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<UserRelatedContentRefreshParam>(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

View File

@ -0,0 +1,49 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2017 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* 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 <http://www.gnu.org/licenses/>.
*/
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<UserRelatedContentRefreshParam>(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<UserKey>) {
}
}

View File

@ -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<UserRelatedContentRefreshParam>(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

View File

@ -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)

View File

@ -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"