Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 084d4928 authored by Santiago Etchebehere's avatar Santiago Etchebehere Committed by android-build-merger
Browse files

Handle no clocks case as error

am: 4f16109a

Change-Id: Ie1978b225183c09e817d4d94a2b172dd35a6b897
parents df98d043 4f16109a
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -37,27 +37,35 @@ public class ContentProviderClockProvider implements ClockProvider {

    @Override
    public boolean isAvailable() {
        return mProviderInfo != null;
        return mProviderInfo != null && (mClocks == null || !mClocks.isEmpty());
    }

    @Override
    public void fetch(OptionsFetchedListener<Clockface> callback, boolean reload) {
        if (!isAvailable()) {
            if (callback != null) {
                callback.onOptionsLoaded(null);
                callback.onError(null);
            }
            return;
        }
        if (mClocks != null && !reload) {
            if (callback != null) {
                if (!mClocks.isEmpty()) {
                    callback.onOptionsLoaded(mClocks);
                } else {
                    callback.onError(null);
                }
            }
            return;
        }
        new ClocksFetchTask(mContext, mProviderInfo, options -> {
            mClocks = options;
            if (callback != null) {
                if (!mClocks.isEmpty()) {
                    callback.onOptionsLoaded(mClocks);
                } else {
                    callback.onError(null);
                }
            }
        }).execute();
    }