Java Code Examples for com.activeandroid.ActiveAndroid#clearCache()

The following examples show how to use com.activeandroid.ActiveAndroid#clearCache() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JoH.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
public static void clearCache() {
    try {
        ActiveAndroid.clearCache();
    } catch (Exception e) {
        Log.e(TAG, "Error clearing active android cache: " + e);
    }
}
 
Example 2
Source File: JoH.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
public static void clearCache() {
    try {
        ActiveAndroid.clearCache();
    } catch (Exception e) {
        Log.e(TAG, "Error clearing active android cache: " + e);
    }
}
 
Example 3
Source File: JoH.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
public static void clearCache() {
    try {
        ActiveAndroid.clearCache();
    } catch (Exception e) {
        Log.e(TAG, "Error clearing active android cache: " + e);
    }
}
 
Example 4
Source File: JoH.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
public static void clearCache() {
    try {
        ActiveAndroid.clearCache();
    } catch (Exception e) {
        Log.e(TAG, "Error clearing active android cache: " + e);
    }
}
 
Example 5
Source File: Application.java    From mobile-android-survey-app with MIT License 5 votes vote down vote up
@Override
public void deleteDatabase() {
    Log.i(this, "deleteDatabase");
    Prefs.clear();
    deleteDatabase(getManifest("AA_DB_NAME"));
    ActiveAndroid.clearCache();
    ActiveAndroid.dispose();
    ActiveAndroid.initialize(this);
    HttpQueue.getInstance().cancel();
    HttpQueue.getInstance().clear();
}
 
Example 6
Source File: CustomComplicationProviderService.java    From xDrip with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onComplicationUpdate(
        int complicationId, int dataType, ComplicationManager complicationManager) {
    Log.d(TAG, "onComplicationUpdate() id: " + complicationId);
    // Create Tap Action so that the user can trigger an update by tapping the complication.
    final ComponentName thisProvider = new ComponentName(this, getClass());
    // We pass the complication id, so we can only update the specific complication tapped.
    final PendingIntent complicationPendingIntent =
            ComplicationTapBroadcastReceiver.getToggleIntent(
                    this, thisProvider, complicationId);

    String numberText = "";
    BgReading bgReading = BgReading.last(true);
    if ((bgReading == null) || (JoH.msSince(bgReading.timestamp) >= FRESH_MS)) {
        try {
            ActiveAndroid.clearCache(); // we may be in another process!
        } catch (Exception e) {
            Log.d(TAG, "Couldn't clear cache: " + e);
        }
        bgReading = BgReading.last(true);
    }

    boolean is_stale = false;

    if (bgReading == null) {
        numberText = "null";
    } else {
        if (JoH.msSince(bgReading.timestamp) < STALE_MS) {
            numberText = bgReading.displayValue(this) + " " + bgReading.displaySlopeArrow();
        } else {
            numberText = "old " + niceTimeSinceBgReading(bgReading);
            is_stale = true;
        }
    }

    Log.d(TAG, "Returning complication text: " + numberText);

    COMPLICATION_STATE state = COMPLICATION_STATE.get_enum((int) PersistentStore.getLong(ComplicationTapBroadcastReceiver.COMPLICATION_STORE));
    if (state == null) state = COMPLICATION_STATE.DELTA;

    ComplicationData complicationData = null;

    switch (dataType) {
        case ComplicationData.TYPE_SHORT_TEXT:

            final ComplicationData.Builder builder = new ComplicationData.Builder(ComplicationData.TYPE_SHORT_TEXT)
                    .setShortText(ComplicationText.plainText(numberText))
                    .setTapAction(complicationPendingIntent);

            UserError.Log.d(TAG, "TYPE_SHORT_TEXT Current complication state:" + state);
            switch (state) {
                case DELTA:
                    builder.setShortTitle(ComplicationText.plainText(getDeltaText(bgReading, is_stale)));
                    break;
                case AGO:
                    builder.setShortTitle(ComplicationText.plainText(niceTimeSinceBgReading(bgReading)));
                    break;
                default:
                    builder.setShortTitle(ComplicationText.plainText("ERR!"));
            }

            complicationData = builder.build();
            break;
        case ComplicationData.TYPE_LONG_TEXT:
            String numberTextLong = numberText + " " + getDeltaText(bgReading, is_stale) + " (" + niceTimeSinceBgReading(bgReading) + ")";
            Log.d(TAG, "Returning complication text Long: " + numberTextLong);

            //Loop status by @gregorybel
            String externalStatusString = PersistentStore.getString("remote-status-string");
            Log.d(TAG, "Returning complication status: " + externalStatusString);

            final ComplicationData.Builder builderLong = new ComplicationData.Builder(ComplicationData.TYPE_LONG_TEXT)
                    .setLongTitle(ComplicationText.plainText(numberTextLong))
                    .setLongText(ComplicationText.plainText(externalStatusString))
                    .setTapAction(complicationPendingIntent);

            UserError.Log.d(TAG, "TYPE_LONG_TEXT Current complication state:" + state);
            complicationData = builderLong.build();

            break;
        default:
            if (Log.isLoggable(TAG, Log.WARN)) {
                Log.w(TAG, "Unexpected complication type " + dataType);
            }
    }

    if (complicationData != null) {
        complicationManager.updateComplicationData(complicationId, complicationData);

    } else {
        // If no data is sent, we still need to inform the ComplicationManager, so the update
        // job can finish and the wake lock isn't held any longer than necessary.
        complicationManager.noUpdateRequired(complicationId);
    }
}
 
Example 7
Source File: CustomComplicationProviderService.java    From xDrip-plus with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onComplicationUpdate(
        int complicationId, int dataType, ComplicationManager complicationManager) {
    Log.d(TAG, "onComplicationUpdate() id: " + complicationId);
    // Create Tap Action so that the user can trigger an update by tapping the complication.
    final ComponentName thisProvider = new ComponentName(this, getClass());
    // We pass the complication id, so we can only update the specific complication tapped.
    final PendingIntent complicationPendingIntent =
            ComplicationTapBroadcastReceiver.getToggleIntent(
                    this, thisProvider, complicationId);

    String numberText = "";
    BgReading bgReading = BgReading.last(true);
    if ((bgReading == null) || (JoH.msSince(bgReading.timestamp) >= FRESH_MS)) {
        try {
            ActiveAndroid.clearCache(); // we may be in another process!
        } catch (Exception e) {
            Log.d(TAG, "Couldn't clear cache: " + e);
        }
        bgReading = BgReading.last(true);
    }

    boolean is_stale = false;

    if (bgReading == null) {
        numberText = "null";
    } else {
        if (JoH.msSince(bgReading.timestamp) < STALE_MS) {
            numberText = bgReading.displayValue(this) + " " + bgReading.displaySlopeArrow();
        } else {
            numberText = "old " + niceTimeSinceBgReading(bgReading);
            is_stale = true;
        }
    }

    Log.d(TAG, "Returning complication text: " + numberText);

    COMPLICATION_STATE state = COMPLICATION_STATE.get_enum((int) PersistentStore.getLong(ComplicationTapBroadcastReceiver.COMPLICATION_STORE));
    if (state == null) state = COMPLICATION_STATE.DELTA;

    ComplicationData complicationData = null;

    switch (dataType) {
        case ComplicationData.TYPE_SHORT_TEXT:

            final ComplicationData.Builder builder = new ComplicationData.Builder(ComplicationData.TYPE_SHORT_TEXT)
                    .setShortText(ComplicationText.plainText(numberText))
                    .setTapAction(complicationPendingIntent);

            UserError.Log.d(TAG, "TYPE_SHORT_TEXT Current complication state:" + state);
            switch (state) {
                case DELTA:
                    builder.setShortTitle(ComplicationText.plainText(getDeltaText(bgReading, is_stale)));
                    break;
                case AGO:
                    builder.setShortTitle(ComplicationText.plainText(niceTimeSinceBgReading(bgReading)));
                    break;
                default:
                    builder.setShortTitle(ComplicationText.plainText("ERR!"));
            }

            complicationData = builder.build();
            break;
        case ComplicationData.TYPE_LONG_TEXT:
            String numberTextLong = numberText + " " + getDeltaText(bgReading, is_stale) + " (" + niceTimeSinceBgReading(bgReading) + ")";
            Log.d(TAG, "Returning complication text Long: " + numberTextLong);

            //Loop status by @gregorybel
            String externalStatusString = PersistentStore.getString("remote-status-string");
            Log.d(TAG, "Returning complication status: " + externalStatusString);

            final ComplicationData.Builder builderLong = new ComplicationData.Builder(ComplicationData.TYPE_LONG_TEXT)
                    .setLongTitle(ComplicationText.plainText(numberTextLong))
                    .setLongText(ComplicationText.plainText(externalStatusString))
                    .setTapAction(complicationPendingIntent);

            UserError.Log.d(TAG, "TYPE_LONG_TEXT Current complication state:" + state);
            complicationData = builderLong.build();

            break;
        default:
            if (Log.isLoggable(TAG, Log.WARN)) {
                Log.w(TAG, "Unexpected complication type " + dataType);
            }
    }

    if (complicationData != null) {
        complicationManager.updateComplicationData(complicationId, complicationData);

    } else {
        // If no data is sent, we still need to inform the ComplicationManager, so the update
        // job can finish and the wake lock isn't held any longer than necessary.
        complicationManager.noUpdateRequired(complicationId);
    }
}