package com.howard.rockear.config;

import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;

/**
 * @author howard data store and fetch
 * 
 */
public class ConfigManager {
	private Context mContext;
	private SharedPreferences spf;

	/**
	 * @param mContext
	 */
	public ConfigManager(Context mContext) {
		super();
		this.mContext = mContext;
		spf = PreferenceManager.getDefaultSharedPreferences(mContext);
	}

	public void setPlayModConfig(int whitch) {
		if (spf == null) {
			spf = PreferenceManager.getDefaultSharedPreferences(mContext);
		}
		spf.edit().putInt("playmod", whitch);
	}

	public int getPlayMod() {
		if (spf == null) {
			spf = PreferenceManager.getDefaultSharedPreferences(mContext);
		}
		return spf.getInt("playmod", 1);

	}

	public void storeCurrent(int whitchQueue, int currentIndex) {
		if (spf == null) {
			spf = PreferenceManager.getDefaultSharedPreferences(mContext);
		}
		spf.edit().putInt("last_queue", whitchQueue);
		spf.edit().putInt("last_index", currentIndex);
	}

	public int getLastCursor() {
		if (spf == null) {
			spf = PreferenceManager.getDefaultSharedPreferences(mContext);
		}
		return spf.getInt("last_index", 0);
	}

	public int getLastQueue() {
		if (spf == null) {
			spf = PreferenceManager.getDefaultSharedPreferences(mContext);
		}
		return spf.getInt("last_queue", 0);
	}

}
