-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'central-dev' into central-master
- Loading branch information
Showing
26 changed files
with
300 additions
and
93 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
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
2 changes: 1 addition & 1 deletion
2
...ki/hentoid/fragments/EndlessFragment.java → .../fragments/downloads/EndlessFragment.java
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package me.devsaki.hentoid.fragments; | ||
package me.devsaki.hentoid.fragments.downloads; | ||
|
||
import android.view.View; | ||
|
||
|
2 changes: 1 addition & 1 deletion
2
...d/fragments/ErrorStatsDialogFragment.java → ...s/downloads/ErrorStatsDialogFragment.java
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
2 changes: 1 addition & 1 deletion
2
...saki/hentoid/fragments/PagerFragment.java → ...id/fragments/downloads/PagerFragment.java
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
2 changes: 1 addition & 1 deletion
2
...fragments/SearchBookIdDialogFragment.java → ...downloads/SearchBookIdDialogFragment.java
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
27 changes: 27 additions & 0 deletions
27
app/src/main/java/me/devsaki/hentoid/util/ImageLoaderThreadExecutor.java
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,27 @@ | ||
package me.devsaki.hentoid.util; | ||
|
||
import java.util.concurrent.LinkedBlockingQueue; | ||
import java.util.concurrent.ThreadPoolExecutor; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
/** | ||
Inspired by {@link android.os.AsyncTask}'s THREAD_POOL_EXECUTOR, | ||
but with a {@link ThreadPoolExecutor.DiscardPolicy} (drop tasks that cannot be processed) | ||
instead of the default {@link ThreadPoolExecutor.AbortPolicy} (throw an exception) | ||
*/ | ||
public class ImageLoaderThreadExecutor extends ThreadPoolExecutor { | ||
|
||
private static final int CPU_COUNT = Runtime.getRuntime().availableProcessors(); | ||
// We want at least 2 threads and at most 4 threads in the core pool, | ||
// preferring to have 1 less than the CPU count to avoid saturating | ||
// the CPU with background work | ||
private static final int CORE_POOL_SIZE = Math.max(2, Math.min(CPU_COUNT - 1, 4)); | ||
private static final int MAXIMUM_POOL_SIZE = CPU_COUNT * 2 + 1; | ||
private static final int KEEP_ALIVE_SECONDS = 30; | ||
|
||
public ImageLoaderThreadExecutor() { | ||
super(CORE_POOL_SIZE, MAXIMUM_POOL_SIZE, KEEP_ALIVE_SECONDS, TimeUnit.SECONDS, | ||
new LinkedBlockingQueue<>(128), new ThreadPoolExecutor.DiscardPolicy()); | ||
this.allowCoreThreadTimeOut(true); | ||
} | ||
} |
Oops, something went wrong.