package com.github.hisaichi5518.kise;

import com.google.firebase.remoteconfig.FirebaseRemoteConfig;

class Fetcher {

    private long cacheExpiration = 43200L; // 12 hours
    private boolean urgentUpdateFlag;

    void enableUrgentUpdateFlag() {
        this.urgentUpdateFlag = true;
    }

    void disableUrgentUpdateFlag() {
        this.urgentUpdateFlag = false;
    }

    void setCacheExpiration(long cacheExpiration) {
        this.cacheExpiration = cacheExpiration;
    }

    void fetch() {
        FirebaseRemoteConfig config = FirebaseRemoteConfig.getInstance();
        config.activateFetched();

        config.fetch(urgentUpdateFlag ? 0 : cacheExpiration);
        disableUrgentUpdateFlag();
    }
}

@@ -32,16 +32,293 @@
 .kise;%0A%0A
+import android.support.annotation.NonNull;%0Aimport android.util.Log;%0A%0Aimport com.google.android.gms.tasks.OnCompleteListener;%0Aimport com.google.android.gms.tasks.OnFailureListener;%0Aimport com.google.android.gms.tasks.OnSuccessListener;%0Aimport com.google.android.gms.tasks.Task;%0A
 import c
@@ -942,16 +942,753 @@
 iration)
+%0A            .addOnFailureListener(new OnFailureListener() %7B%0A                @Override%0A                public void onFailure(@NonNull Exception e) %7B%0A                    Log.d(%22KiseFetcher%22, %22onFailure: %22 + e.getMessage());%0A                %7D%0A            %7D)%0A            .addOnSuccessListener(new OnSuccessListener%3CVoid%3E() %7B%0A                @Override%0A                public void onSuccess(Void aVoid) %7B%0A                    Log.d(%22KiseFetcher%22, %22onSuccess%22);%0A                %7D%0A            %7D)%0A            .addOnCompleteListener(new OnCompleteListener%3CVoid%3E() %7B%0A                @Override%0A                public void onComplete(@NonNull Task%3CVoid%3E task) %7B%0A                    Log.d(%22KiseFetcher%22, %22onComplete%22);%0A                %7D%0A            %7D)
 ;%0A      

Print debug log.