-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Log search functionality and log browser refactoring #4309
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| DO NOT TOUCH; GENERATED BY DRONE | ||
| <span class="mdl-layout-title">Lint Report: 59 warnings</span> | ||
| <span class="mdl-layout-title">Lint Report: 58 warnings</span> |
This file contains hidden or 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 hidden or 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 hidden or 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
65 changes: 0 additions & 65 deletions
65
src/main/java/com/nextcloud/client/core/AsyncRunnerImpl.kt
This file was deleted.
Oops, something went wrong.
76 changes: 76 additions & 0 deletions
76
src/main/java/com/nextcloud/client/core/ManualAsyncRunner.kt
This file contains hidden or 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,76 @@ | ||
| /* | ||
| * Nextcloud Android client application | ||
| * | ||
| * @author Chris Narkiewicz | ||
| * Copyright (C) 2019 Chris Narkiewicz <hello@ezaquarii.com> | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU Affero 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 Affero General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Affero General Public License | ||
| * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
| package com.nextcloud.client.core | ||
|
|
||
| import java.util.ArrayDeque | ||
|
|
||
| /** | ||
| * This async runner is suitable for tests, where manual simulation of | ||
| * asynchronous operations is desirable. | ||
| */ | ||
| class ManualAsyncRunner : AsyncRunner { | ||
|
|
||
| private val queue: ArrayDeque<Task<*>> = ArrayDeque() | ||
|
|
||
| override fun <T> post(task: () -> T, onResult: OnResultCallback<T>?, onError: OnErrorCallback?): Cancellable { | ||
| val taskWrapper = Task( | ||
| postResult = { it.run() }, | ||
| taskBody = task, | ||
| onSuccess = onResult, | ||
| onError = onError | ||
| ) | ||
| queue.push(taskWrapper) | ||
| return taskWrapper | ||
| } | ||
|
|
||
| val size: Int get() = queue.size | ||
| val isEmpty: Boolean get() = queue.size == 0 | ||
|
|
||
| /** | ||
| * Run all enqueued tasks until queue is empty. This will run also tasks | ||
| * enqueued by task callbacks. | ||
| * | ||
| * @param maximum max number of tasks to run to avoid infinite loopss | ||
| * @return number of executed tasks | ||
| */ | ||
| fun runAll(maximum: Int = 100): Int { | ||
| var c = 0 | ||
| while (queue.size > 0) { | ||
| val t = queue.remove() | ||
| t.run() | ||
| c++ | ||
| if (c > maximum) { | ||
| throw IllegalStateException("Maximum number of tasks run. Are you in infinite loop?") | ||
| } | ||
| } | ||
| return c | ||
| } | ||
|
|
||
| /** | ||
| * Run one pending task | ||
| * | ||
| * @return true if task has been run | ||
| */ | ||
| fun runOne(): Boolean { | ||
| val t = queue.pollFirst() | ||
| t?.run() | ||
| return t != null | ||
| } | ||
| } |
This file contains hidden or 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,57 @@ | ||
| /* | ||
| * Nextcloud Android client application | ||
| * | ||
| * @author Chris Narkiewicz | ||
| * Copyright (C) 2019 Chris Narkiewicz <hello@ezaquarii.com> | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU Affero 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 Affero General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Affero General Public License | ||
| * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
| package com.nextcloud.client.core | ||
|
|
||
| import java.util.concurrent.atomic.AtomicBoolean | ||
|
|
||
| /** | ||
| * This is a wrapper for a function run in background. | ||
| * | ||
| * Runs task function and posts result if task is not cancelled. | ||
| */ | ||
| internal class Task<T>( | ||
| private val postResult: (Runnable) -> Unit, | ||
| private val taskBody: () -> T, | ||
| private val onSuccess: OnResultCallback<T>?, | ||
| private val onError: OnErrorCallback? | ||
| ) : Runnable, Cancellable { | ||
|
|
||
| private val cancelled = AtomicBoolean(false) | ||
|
|
||
| override fun run() { | ||
| @Suppress("TooGenericExceptionCaught") // this is exactly what we want here | ||
| try { | ||
| val result = taskBody.invoke() | ||
| if (!cancelled.get()) { | ||
| postResult.invoke(Runnable { | ||
| onSuccess?.invoke(result) | ||
| }) | ||
| } | ||
| } catch (t: Throwable) { | ||
| if (!cancelled.get()) { | ||
| postResult(Runnable { onError?.invoke(t) }) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| override fun cancel() { | ||
| cancelled.set(true) | ||
| } | ||
| } | ||
44 changes: 44 additions & 0 deletions
44
src/main/java/com/nextcloud/client/core/ThreadPoolAsyncRunner.kt
This file contains hidden or 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,44 @@ | ||
| /* | ||
| * Nextcloud Android client application | ||
| * | ||
| * @author Chris Narkiewicz | ||
| * Copyright (C) 2019 Chris Narkiewicz <hello@ezaquarii.com> | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU Affero 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 Affero General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Affero General Public License | ||
| * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
| package com.nextcloud.client.core | ||
|
|
||
| import android.os.Handler | ||
| import java.util.concurrent.ScheduledThreadPoolExecutor | ||
|
|
||
| /** | ||
| * This async runner uses [java.util.concurrent.ScheduledThreadPoolExecutor] to run tasks | ||
| * asynchronously. | ||
| * | ||
| * Tasks are run on multi-threaded pool. If serialized execution is desired, set [corePoolSize] to 1. | ||
| */ | ||
| internal class ThreadPoolAsyncRunner(private val uiThreadHandler: Handler, corePoolSize: Int) : AsyncRunner { | ||
|
|
||
| private val executor = ScheduledThreadPoolExecutor(corePoolSize) | ||
|
|
||
| override fun <T> post(task: () -> T, onResult: OnResultCallback<T>?, onError: OnErrorCallback?): Cancellable { | ||
| val taskWrapper = Task(this::postResult, task, onResult, onError) | ||
| executor.execute(taskWrapper) | ||
| return taskWrapper | ||
| } | ||
|
|
||
| private fun postResult(r: Runnable) { | ||
| uiThreadHandler.post(r) | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.