package com.rainbof.nyxtools;

import android.content.Context;

public class NyxTools {

	private volatile static NyxTools mInstance;
	private NyxToolsPersistence persistence;

	public static NyxTools getInstance(Context _context) {
		if (mInstance == null) {
			synchronized (NyxTools.class) {
				mInstance = new NyxTools(_context);
			}
		}
		return mInstance;
	}

	protected NyxTools(Context _context) {
		if (_context.getApplicationContext() != null)
			_context = _context.getApplicationContext();
		persistence = new NyxToolsPersistence(_context);
	}

	public boolean setUsername(String username) {
		return persistence.setUsername(username);
	}

	public String getUsername() {
		return persistence.getUsername();
	}

	public boolean setAuthToken(String authToken) {
		return persistence.setAuthToken(authToken);
	}

	public String getAuthToken() {
		return persistence.getAuthToken();
	}
	
	public String getUserAgentPrefix(){
		return persistence.getUserAgentPrefix();
	}
	
	public boolean setUserAgentPrefix(String uaPrefix){
		return persistence.setUserAgentPrefix(uaPrefix);
	}

}

@@ -55,16 +55,78 @@
 Context;
+%0Aimport android.util.Log;%0A%0Aimport com.rainbof.nyxtools.util.S;
 %0A%0Apublic
@@ -459,24 +459,33 @@
 _context) %7B%0A
+%09%09try %7B%0A%09
 %09%09if (_conte
@@ -523,16 +523,17 @@
 ull)%0A%09%09%09
+%09
 _context
@@ -569,16 +569,189 @@
 text();%0A
+%09%09%7D catch (Exception e) %7B%0A%09%09%09Log.e(S.TAG + %22getApplicationContext%22,%0A%09%09%09%09%09%22You must call getInstance() after super.onCreate(...)%22);%0A%09%09%09throw new IllegalStateException();%0A%09%09%7D%0A
 %09%09persis
@@ -1130,25 +1130,24 @@
 Token();%0A%09%7D%0A
-%09
 %0A%09public Str
@@ -1170,16 +1170,17 @@
 Prefix()
+ 
 %7B%0A%09%09retu
@@ -1219,17 +1219,16 @@
 x();%0A%09%7D%0A
-%09
 %0A%09public
@@ -1271,16 +1271,17 @@
 aPrefix)
+ 
 %7B%0A%09%09retu

Fix for calling getInstance before ApplicationContext is available