A few crashes fixed
This commit is contained in:
parent
19cb548e18
commit
0078cb88c3
@ -1,7 +1,6 @@
|
|||||||
package eu.kanade.tachiyomi.data.cache
|
package eu.kanade.tachiyomi.data.cache
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.text.TextUtils
|
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||||
@ -38,9 +37,9 @@ class CoverCache(private val context: Context) {
|
|||||||
* @param imageView imageView where picture should be displayed.
|
* @param imageView imageView where picture should be displayed.
|
||||||
*/
|
*/
|
||||||
@JvmOverloads
|
@JvmOverloads
|
||||||
fun save(thumbnailUrl: String, headers: LazyHeaders, imageView: ImageView? = null) {
|
fun save(thumbnailUrl: String?, headers: LazyHeaders, imageView: ImageView? = null) {
|
||||||
// Check if url is empty.
|
// Check if url is empty.
|
||||||
if (TextUtils.isEmpty(thumbnailUrl))
|
if (thumbnailUrl.isNullOrEmpty())
|
||||||
return
|
return
|
||||||
|
|
||||||
// Download the cover with Glide and save the file.
|
// Download the cover with Glide and save the file.
|
||||||
@ -51,7 +50,7 @@ class CoverCache(private val context: Context) {
|
|||||||
override fun onResourceReady(resource: File, anim: GlideAnimation<in File>) {
|
override fun onResourceReady(resource: File, anim: GlideAnimation<in File>) {
|
||||||
try {
|
try {
|
||||||
// Copy the cover from Glide's cache to local cache.
|
// Copy the cover from Glide's cache to local cache.
|
||||||
copyToLocalCache(thumbnailUrl, resource)
|
copyToLocalCache(thumbnailUrl!!, resource)
|
||||||
|
|
||||||
// Check if imageView isn't null and show picture in imageView.
|
// Check if imageView isn't null and show picture in imageView.
|
||||||
if (imageView != null) {
|
if (imageView != null) {
|
||||||
@ -93,9 +92,9 @@ class CoverCache(private val context: Context) {
|
|||||||
* @param thumbnailUrl the thumbnail url.
|
* @param thumbnailUrl the thumbnail url.
|
||||||
* @return status of deletion.
|
* @return status of deletion.
|
||||||
*/
|
*/
|
||||||
fun deleteCoverFromCache(thumbnailUrl: String): Boolean {
|
fun deleteCoverFromCache(thumbnailUrl: String?): Boolean {
|
||||||
// Check if url is empty.
|
// Check if url is empty.
|
||||||
if (TextUtils.isEmpty(thumbnailUrl))
|
if (thumbnailUrl.isNullOrEmpty())
|
||||||
return false
|
return false
|
||||||
|
|
||||||
// Remove file.
|
// Remove file.
|
||||||
@ -142,9 +141,9 @@ class CoverCache(private val context: Context) {
|
|||||||
* @param thumbnailUrl url of thumbnail.
|
* @param thumbnailUrl url of thumbnail.
|
||||||
* @param headers headers included in Glide request.
|
* @param headers headers included in Glide request.
|
||||||
*/
|
*/
|
||||||
fun loadFromNetwork(imageView: ImageView, thumbnailUrl: String, headers: LazyHeaders) {
|
fun loadFromNetwork(imageView: ImageView, thumbnailUrl: String?, headers: LazyHeaders) {
|
||||||
// Check if url is empty.
|
// Check if url is empty.
|
||||||
if (TextUtils.isEmpty(thumbnailUrl))
|
if (thumbnailUrl.isNullOrEmpty())
|
||||||
return
|
return
|
||||||
|
|
||||||
val url = GlideUrl(thumbnailUrl, headers)
|
val url = GlideUrl(thumbnailUrl, headers)
|
||||||
|
@ -52,7 +52,7 @@ class DownloadService : Service() {
|
|||||||
listenNetworkChanges()
|
listenNetworkChanges()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int {
|
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
||||||
return Service.START_STICKY
|
return Service.START_STICKY
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ public abstract class BaseRxActivity<P extends Presenter> extends BaseActivity i
|
|||||||
@Override
|
@Override
|
||||||
public P createPresenter() {
|
public P createPresenter() {
|
||||||
P presenter = superFactory.createPresenter();
|
P presenter = superFactory.createPresenter();
|
||||||
App app = (App) BaseRxActivity.this.getApplication();
|
App app = (App) getApplication();
|
||||||
app.getComponentReflection().inject(presenter);
|
app.getComponentReflection().inject(presenter);
|
||||||
((BasePresenter) presenter).setContext(app.getApplicationContext());
|
((BasePresenter) presenter).setContext(app.getApplicationContext());
|
||||||
return presenter;
|
return presenter;
|
||||||
|
@ -60,7 +60,7 @@ public abstract class BaseRxFragment<P extends Presenter> extends BaseFragment i
|
|||||||
@Override
|
@Override
|
||||||
public P createPresenter() {
|
public P createPresenter() {
|
||||||
P presenter = superFactory.createPresenter();
|
P presenter = superFactory.createPresenter();
|
||||||
App app = (App) BaseRxFragment.this.getActivity().getApplication();
|
App app = (App) getActivity().getApplication();
|
||||||
app.getComponentReflection().inject(presenter);
|
app.getComponentReflection().inject(presenter);
|
||||||
((BasePresenter) presenter).setContext(app.getApplicationContext());
|
((BasePresenter) presenter).setContext(app.getApplicationContext());
|
||||||
return presenter;
|
return presenter;
|
||||||
|
Loading…
Reference in New Issue
Block a user