com.backendless.BackendlessPrefs Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of backendless Show documentation
Show all versions of backendless Show documentation
Android SDK used by developers to provide Backendless API in apps.
package com.backendless;
import com.backendless.exceptions.ExceptionMessage;
import java.util.Map;
/**
* Created by dzidzoiev on 11/8/15.
*/
class BackendlessPrefs
{
protected AuthKeys authKeys;
protected Map headers;
protected String url;
public BackendlessPrefs()
{
}
public void initPreferences( String applicationId, String apiKey )
{
this.authKeys = new AuthKeys( applicationId, apiKey );
}
public void setHeaders( Map headers )
{
this.headers = headers;
}
public synchronized void cleanHeaders()
{
headers = null;
}
/**
* Should be called before init
*
* @param context - mandatory for android service
*/
public void onCreate( Object context )
{
}
public String getApplicationId()
{
return getAuthKeys().getApplicationId();
}
public String getApiKey()
{
return getAuthKeys().getApiKey();
}
public synchronized Map getHeaders()
{
return headers;
}
private synchronized AuthKeys getAuthKeys()
{
if( authKeys == null)
throw new IllegalStateException( ExceptionMessage.NOT_INITIALIZED );
return authKeys;
}
boolean isAuthKeysExist()
{
return authKeys != null;
}
public void setUrl( String url )
{
this.url = url;
}
public String getUrl()
{
if( this.url == null)
throw new IllegalStateException( ExceptionMessage.NOT_INITIALIZED );
return this.url;
}
}