Skip to content

Instantly share code, notes, and snippets.

View javimar's full-sized avatar
🎯
Focusing

Javi Martin javimar

🎯
Focusing
View GitHub Profile
@javimar
javimar / gist:4ad616f7efbc7fe30b2b15bf58b94bb2
Created March 23, 2020 12:31
Correct way to update a Set containing widgets Ids in SharedPreferences.
public static void updateSetInPreferences(Context context, int appWidgetId, String key, String action)
{
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
SharedPreferences.Editor editor = prefs.edit();
Set<String> storedSet, in;
switch(action)
{
case ACTION_ADD_APP_WIDGET_ID:
storedSet = prefs.getStringSet(key, new HashSet<>());
in = new HashSet<>(storedSet);
@javimar
javimar / fifteen.c
Created September 15, 2016 15:20
My version for the game of Fifteen
/**
* fifteen.c
*
* Computer Science 50
* Problem Set 3
*
* Implements Game of Fifteen (generalized to d x d).
*
* Usage: fifteen d
*