-
Notifications
You must be signed in to change notification settings - Fork 551
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2041862
commit 622903d
Showing
7 changed files
with
139 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
app/src/main/java/org/fossasia/openevent/general/event/EventsDataSourceFactory.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package org.fossasia.openevent.general.event | ||
|
||
import androidx.lifecycle.MutableLiveData | ||
import androidx.paging.DataSource | ||
import io.reactivex.disposables.CompositeDisposable | ||
import org.fossasia.openevent.general.event.faq.EventsDataSource | ||
|
||
class EventsDataSourceFactory(private val compositeDisposable: CompositeDisposable, | ||
private val eventService: EventService, | ||
private val query:String?) | ||
: DataSource.Factory<Int, Event>() { | ||
|
||
val usersDataSourceLiveData = MutableLiveData<EventsDataSource>() | ||
|
||
override fun create(): DataSource<Int, Event> { | ||
val usersDataSource = EventsDataSource(eventService, compositeDisposable,query) | ||
usersDataSourceLiveData.postValue(usersDataSource) | ||
return usersDataSource | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
app/src/main/java/org/fossasia/openevent/general/event/faq/EventsDataSource.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package org.fossasia.openevent.general.event.faq | ||
|
||
import androidx.paging.PageKeyedDataSource | ||
import io.reactivex.disposables.CompositeDisposable | ||
import org.fossasia.openevent.general.event.Event | ||
import org.fossasia.openevent.general.event.EventService | ||
|
||
class EventsDataSource( | ||
private val eventsService: EventService, | ||
private val compositeDisposable: CompositeDisposable, | ||
val query:String?) | ||
: PageKeyedDataSource<Int, Event>() { | ||
private var sourceIndex: Int = 1 | ||
override fun loadInitial(params: LoadInitialParams<Int>, callback: LoadInitialCallback<Int, Event>) { | ||
compositeDisposable.add(eventsService.getEventsByLocationPaged(query,1).subscribe({ users -> | ||
sourceIndex++ | ||
callback.onResult(users,null,sourceIndex) | ||
}, { throwable ->})) | ||
} | ||
override fun loadAfter(params: LoadParams<Int>, callback: LoadCallback<Int, Event>) { | ||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates. | ||
} | ||
override fun loadBefore(params: LoadParams<Int>, callback: LoadCallback<Int, Event>) { | ||
// // ignored, since we only ever append to our initial load | ||
} | ||
// override fun loadInitial(params: LoadInitialParams<Long>, callback: LoadInitialCallback<Event>) { | ||
|
||
// } | ||
// | ||
// override fun loadAfter(params: LoadParams<Long>, callback: LoadCallback<User>) { | ||
// //get the users from the api after id | ||
// compositeDisposable.add(githubService.getUsers(params.key, params.requestedLoadSize).subscribe({ users -> | ||
// callback.onResult(users) | ||
// }, { throwable -> })) | ||
// } | ||
// | ||
// override fun loadBefore(params: LoadParams<Long>, callback: LoadCallback<User>) { | ||
// // ignored, since we only ever append to our initial load | ||
// } | ||
// | ||
// override fun getKey(item: User): Long { | ||
// return item.id | ||
// } | ||
|
||
} |