package uk.ac.horizon.artcodes.source;

import android.content.Context;
import android.content.SharedPreferences;
import android.util.Log;
import com.google.common.reflect.TypeToken;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

import java.util.List;

public abstract class PrefList<T> implements UriList<T>
{
	private final SharedPreferences preferences;
	private final String name;
	private final Gson gson;

	public PrefList(Context context, String packageName, String name)
	{
		this.name = name;
		preferences = context.getSharedPreferences(packageName, Context.MODE_PRIVATE);
		this.gson = new GsonBuilder().create();
	}

	@Override
	public void add(String uri)
	{
		List<String> list = getList();
		list.add(uri);
		preferences.edit().putString(name, gson.toJson(list)).apply();
	}

	@Override
	public boolean contains(String uri)
	{
		return getList().contains(uri);
	}

	protected List<String> getList()
	{
		String jsonString = preferences.getString(name, "[]");

		Log.i("", name + " = " + jsonString);

		return gson.fromJson(jsonString, new TypeToken<List<String>>() {}.getType());
	}

	@Override
	public void remove(String uri)
	{
		List<String> list = getList();
		list.remove(uri);
		preferences.edit().putString(name, gson.toJson(list)).apply();

	}
}

@@ -714,24 +714,44 @@
  getList();%0A
+%09%09list.remove(uri);%0A
 %09%09list.add(u
@@ -749,16 +749,19 @@
 ist.add(
+0, 
 uri);%0A%09%09

Fix duplicated in recent