|
|
@ -1,5 +1,24 @@ |
|
|
|
package eu.faircode.email; |
|
|
|
|
|
|
|
/* |
|
|
|
This file is part of Safe email. |
|
|
|
|
|
|
|
Safe email is free software: you can redistribute it and/or modify |
|
|
|
it under the terms of the GNU General Public License as published by |
|
|
|
the Free Software Foundation, either version 3 of the License, or |
|
|
|
(at your option) any later version. |
|
|
|
|
|
|
|
NetGuard 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 General Public License for more details. |
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License |
|
|
|
along with NetGuard. If not, see <http://www.gnu.org/licenses/>. |
|
|
|
|
|
|
|
Copyright 2018 by Marcel Bokhorst (M66B) |
|
|
|
*/ |
|
|
|
|
|
|
|
import android.content.Context; |
|
|
|
import android.os.Bundle; |
|
|
|
import android.util.Log; |
|
|
@ -10,6 +29,11 @@ import androidx.loader.app.LoaderManager; |
|
|
|
import androidx.loader.content.AsyncTaskLoader; |
|
|
|
import androidx.loader.content.Loader; |
|
|
|
|
|
|
|
// |
|
|
|
// This simple loader is simple to use, but it is also simple to cause bugs that can easily lead to crashes |
|
|
|
// Make sure to not access any member in any outer scope from onLoad |
|
|
|
// |
|
|
|
|
|
|
|
public abstract class SimpleLoader<T> { |
|
|
|
private Context context; |
|
|
|
private LoaderManager manager; |
|
|
@ -27,6 +51,7 @@ public abstract class SimpleLoader<T> { |
|
|
|
} |
|
|
|
|
|
|
|
public T onLoad(Bundle args) throws Throwable { |
|
|
|
// Be careful not to access members in outer scopes |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
@ -36,6 +61,10 @@ public abstract class SimpleLoader<T> { |
|
|
|
public void onException(Bundle args, Throwable ex) { |
|
|
|
} |
|
|
|
|
|
|
|
protected Context getContext() { |
|
|
|
return context; |
|
|
|
} |
|
|
|
|
|
|
|
private static class CommonLoader extends AsyncTaskLoader<Result> { |
|
|
|
Bundle args; |
|
|
|
SimpleLoader loader; |
|
|
|