package com.wasu.cs.module;

import android.content.Context;
import android.content.SharedPreferences;
import android.text.TextUtils;

import com.wasu.module.IModule;

/**
 * 角标处理模块
 * Created by danxingxi on 2015/11/18.
 */
public class CornerMarkModule extends IModule{

	public final static String TAG = CornerMarkModule.class.getSimpleName();
	
	private static CornerMarkModule mInstance;
	private static SharedPreferences sp;
	/**
	 * 模块初始化
	 * @param c
	 */
	@SuppressWarnings("static-access")
	public void init(Context c){
		setContext(c);
		sp = c.getSharedPreferences("configData", c.MODE_PRIVATE);
		setInited(true);
	}
	
	/**
	 * 获取单例
	 * @return
	 */
	public static CornerMarkModule getInstance(){
		if(null == mInstance){
			synchronized (CornerMarkModule.class){
				if(null == mInstance){
					mInstance = new CornerMarkModule();
				}
			}
		}
		return mInstance;
	}
	
	/**
	 * 如果资产给出的角标允许显示就返回该角标图片URL
	 * @param Cmark
	 * @return
	 */
	public String getCornerMarkPicUrl(String Cmark){
		if(!TextUtils.isEmpty(sp.getString(Cmark,null))){
			return sp.getString(Cmark,null);
		}else{
			return null;
		}
	}
	
	/**
	 * 清除角标数据
	 */
	public void clearCornerMarkData(){
		sp.edit().clear().commit();
	}
}
