Repository URL to install this package:
Version:
0.0.4 ▾
|
package com.vipera.splashscreen;
import android.graphics.Color;
import com.vipera.de.utility.logging.impl.DELoggerFactory;
import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaInterface;
import org.apache.cordova.CordovaPlugin;
import org.apache.cordova.CordovaWebView;
import org.json.JSONArray;
import org.json.JSONException;
import org.slf4j.Logger;
/**
* Created by enrico on 23/02/17.
*/
public class DESplashScreenPlugin extends CordovaPlugin {
private static final Logger LOGGER= DELoggerFactory.getLogger(DESplashScreenPlugin.class);
/**
* actions
*/
public static final String HIDE_SPLASH_ACTION="hideSplash";
public static final String SHOW_SPLASH_ACTION="showSplash";
/**
* Preferences TAGs
*/
private static final String AUTO_HIDE_MESSAGE_ID="onPageFinished";
private DESplashScreenManager splashScreenManager;
@Override
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
super.initialize(cordova, webView);
LOGGER.debug("initialize");
splashScreenManager=DESplashScreenManager.getInstance(cordova,preferences);
splashScreenManager.init();
}
@Override
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
if(HIDE_SPLASH_ACTION.equals(action)){
LOGGER.debug("hideSplash action required");
splashScreenManager.hide();
return true;
}else if(SHOW_SPLASH_ACTION.equals(action)){
LOGGER.debug("showSplash action required");
splashScreenManager.show();
return true;
}
return false;
}
@Override
public Object onMessage(String id, Object data) {
LOGGER.info("id {} , data {}",id,data);
if(AUTO_HIDE_MESSAGE_ID.equalsIgnoreCase(id)){
splashScreenManager.autoHide();
}
return super.onMessage(id, data);
}
@Override
public void onDestroy() {
splashScreenManager.destroy();
super.onDestroy();
}
}