-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upgrade to SplashScreen. Update dependencies.
- Loading branch information
1 parent
155ddea
commit 9e4de21
Showing
14 changed files
with
115 additions
and
12 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
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,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<color name="splashColor">#222222</color> | ||
</resources> |
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
74 changes: 74 additions & 0 deletions
74
library/src/main/java/candybar/lib/tasks/WallpaperThumbPreloaderTask.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,74 @@ | ||
package candybar.lib.tasks; | ||
|
||
import android.content.Context; | ||
import android.util.Log; | ||
|
||
import androidx.annotation.NonNull; | ||
|
||
import com.bumptech.glide.Glide; | ||
import com.bumptech.glide.load.engine.DiskCacheStrategy; | ||
import com.danimahardhika.android.helpers.core.utils.LogUtil; | ||
|
||
import java.io.InputStream; | ||
import java.lang.ref.WeakReference; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import candybar.lib.applications.CandyBarApplication; | ||
import candybar.lib.helpers.JsonHelper; | ||
import candybar.lib.helpers.WallpaperHelper; | ||
import candybar.lib.utils.AsyncTaskBase; | ||
import candybar.lib.utils.ImageConfig; | ||
|
||
public class WallpaperThumbPreloaderTask extends AsyncTaskBase { | ||
|
||
private final WeakReference<Context> context; | ||
|
||
public WallpaperThumbPreloaderTask(@NonNull Context context) { | ||
this.context = new WeakReference<>(context); | ||
} | ||
|
||
@Override | ||
protected boolean run() { | ||
if (!isCancelled()) { | ||
try { | ||
Thread.sleep(1); | ||
|
||
if (WallpaperHelper.getWallpaperType(context.get()) != WallpaperHelper.CLOUD_WALLPAPERS) | ||
return true; | ||
|
||
InputStream stream = WallpaperHelper.getJSONStream(context.get()); | ||
|
||
if (stream != null) { | ||
List<?> list = JsonHelper.parseList(stream); | ||
if (list == null) { | ||
LogUtil.e("Json error, no array with name: " | ||
+ CandyBarApplication.getConfiguration().getWallpaperJsonStructure().getArrayName()); | ||
return false; | ||
} | ||
|
||
if (list.size() > 0 && list.get(0) instanceof Map) { | ||
Map<?, ?> map = (Map<?, ?>) list.get(0); | ||
String thumbUrl = JsonHelper.getThumbUrl(map); | ||
|
||
// Preload the first wallpaper's thumbnail | ||
// It should show up immediately without any delay on first run | ||
// so that the intro popup works correctly | ||
if (context.get() != null) { | ||
Glide.with(context.get()) | ||
.load(thumbUrl) | ||
.diskCacheStrategy(DiskCacheStrategy.RESOURCE) | ||
.override(ImageConfig.getThumbnailSize()) | ||
.preload(); | ||
} | ||
} | ||
} | ||
return true; | ||
} catch (Exception e) { | ||
LogUtil.e(Log.getStackTraceString(e)); | ||
return false; | ||
} | ||
} | ||
return false; | ||
} | ||
} |
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