User Tools

Site Tools


import_a_script_directly_into_ll

====== Differences ====== This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
import_a_script_directly_into_ll [2015/08/13 19:27]
lm13
import_a_script_directly_into_ll [2016/01/23 21:46] (current)
lm13
Line 1: Line 1:
 ==== External API: Manage Scripts ==== ==== External API: Manage Scripts ====
- 
-[[https://​drive.google.com/​folderview?​id=0B40xU-30MxN7flhicHg3Y05XMWplMTl3c1RJU0ZuWUZ3emJxZG56RDdma2xpMXVvRmRlaXc&​usp=sharing|Download]] the current Version of the Library and drop the .aar file in your projects lib folder (/app/libs) if the folder does not exist, create it. 
  
 Add this to build.gradle of your apps module: Add this to build.gradle of your apps module:
-<sxh java;>repositories{ +<sxh java>
-    flatDir { +
-        dirs '​libs'​ +
-    } +
-+
 dependencies { dependencies {
-    compile(name:'name-of-file',​ext:'aar')+    compile 'com.faendir.lightninglauncher:scriptlib:​versioncode'
     //other dependencies...     //other dependencies...
 }</​sxh>​ }</​sxh>​
-and replace //name-of-file// with the actual file name (without ​the extension).+and replace //versioncode// with the latest version available. 
 +(You can check for the latest version [[https://​bintray.com/​f43nd1r/​maven/​scriptlib/​view|here]])
  
-Now you can import the class ''​com.app.lukas.script.ScriptManager''​ in any of your modules files.+Now you can import the class ''​com.faendir.lightning_launcher.scriptlib.ScriptManager''​ in any of your modules files.
 The ''​ScriptManager''​ provides several static methods: The ''​ScriptManager''​ provides several static methods:
  
-Method signatures: (v1.3.1) +Method signatures: (v1.6.7 for Repository Importer ​1.10, possibly compatible with older versions
-<sxh java;>​loadScript(Context context, String code / int codeResourceId,​ String name, int flags, final Listener listener)</​sxh>​+<sxh java;>​loadScript(Context context, String code / int codeResourceId,​ String name, int flags, boolean forceUpdate, final Listener listener)</​sxh>​
   * ''​context''​ can be any context   * ''​context''​ can be any context
   * ''​code''​ the code the script should have / ''​codeResourceId''​ the raw resource id containing the script code   * ''​code''​ the code the script should have / ''​codeResourceId''​ the raw resource id containing the script code
Line 31: Line 25:
   * ''​listener''​ a ''​ScriptManager.listener''​ which will retrieve the ID once the script is loaded   * ''​listener''​ a ''​ScriptManager.listener''​ which will retrieve the ID once the script is loaded
  
-<sxh java;>​runScript(Context context, int id, String data) </​sxh>​+<sxh java;>​runScript(Context context, int id, String data, boolean background) </​sxh>​
   * ''​context''​ can be any context   * ''​context''​ can be any context
   * ''​id''​ the id of the script which should be run, usually as returned by a ''​ScriptManager.listener''​   * ''​id''​ the id of the script which should be run, usually as returned by a ''​ScriptManager.listener''​
   * ''​data''​ an optional string containing additional data. Can be retrieved in the script with ''​LL.getEvent().getData()''​   * ''​data''​ an optional string containing additional data. Can be retrieved in the script with ''​LL.getEvent().getData()''​
 +  * ''​background''​ (optional, default is false) whether this script should run in the background or not
  
 <sxh java;>​enableDebug()</​sxh>​ <sxh java;>​enableDebug()</​sxh>​
Line 41: Line 36:
 <sxh java;>​askForRepositoryImporterInstallationIfMissing(boolean value)</​sxh>​ <sxh java;>​askForRepositoryImporterInstallationIfMissing(boolean value)</​sxh>​
   * By Default the library shows a dialog when the Repository Importer is missing. With this method you can disable/​enable that at will.   * By Default the library shows a dialog when the Repository Importer is missing. With this method you can disable/​enable that at will.
 +
 +<sxh java;>​sendIntentToLauncher(Context context, Intent intent)</​sxh>​
 +  * ''​context''​ can be any context
 +  * ''​intent''​ is the intent which should be sent
 +
 +<sxh java;>​replaceLogger(Logger logger)</​sxh>​
 +  * ''​logger''​ a logger. Use this if you want to log to an alternative place (subclass Logger)
  
 Listener methods: Listener methods:
-<sxh java;>OnLoadFinished(int id);</​sxh>​+<sxh java;>onLoadFinished(int id);</​sxh>​
   * This method is called when the load succeeded with the ID of the imported script   * This method is called when the load succeeded with the ID of the imported script
  
-<sxh java;>OnError()</​sxh>​ +<sxh java;>onError()</​sxh>​ 
-  * Implement this method if you want to receive a callback when an error occurs (recommended)+  * Implement this method if you want to receive a callback when an error occurs (recommended). Do not call super.onError().
  
 <sxh java;>​confirmUpdate(UpdateCallback callback)</​sxh>​ <sxh java;>​confirmUpdate(UpdateCallback callback)</​sxh>​
import_a_script_directly_into_ll.1439494049.txt.gz · Last modified: 2015/08/13 19:27 by lm13