Giter Club home page Giter Club logo

phonegap-plugin-wizassets's Introduction

phonegap-plugin-wizAssets

cordova version : 2.3
last update : 24/04/2013

Description :

PhoneGap plugin for managing application assets with javascript asset maps. Includes( iOS background threaded) downloadFile, getFileURI, getFileURIs, deleteFile.

Changelog:

  • Updated for Cordova 2.3
  • Changed deleteFile error handling.
  • Removed unimplemented plugin methods.
  • Updated error handling to more closely follow the w3c file api error conventions http://www.w3.org/TR/FileAPI/
  • Added Android version.

Install (iOS):

Project tree

project
	/ www
		-index.html
		/ assets [store your app assets here]
		/ phonegap
			/ plugin
				/ wizAssets
					/ wizAssets.js	
	/ Classes
	/ Plugins
		/ WizAssetsPlugin
			/ WizAssetsPlugin.h
			/ WizAssetsPlugin.m
	-project.xcodeproj

1 ) Arrange files to structure seen above.

2 ) Add to cordova.plist in the plugins array;
Key : WizAssetsPlugin
Type : String
Value : WizAssetsPlugin

3 ) Add <script> tag to your index.html

<script type="text/javascript" charset="utf-8" src="phonegap/plugin/wizAssets/wizAssets.js"></script>

^ assuming your index.html is setup like tree above

4 ) Follow example code below...

Install (Android):

Project tree

project
	/ assets
		/ www
			-cordova-2.3.0.js
			-index.html
			/ assets [store your app assets here]
			/ phonegap
				/ plugin
					/ wizAssets
						-wizAssets.js
						-assets.db [list your bundled assets here]
	/ src
		/ jp.wizcorp.phonegap.plugin.WizAssets
			-WizAssetManager.java
			-WizAssetsPlugin.java

1 ) Arrange source files to structure seen above.

2 ) Add to res/xml/config.xml the following line; <plugin name="WizAssetsPlugin" value="jp.wizcorp.phonegap.plugin.WizAssets.WizAssetsPlugin"/>

3 ) Add <script> tag to your index.html <script type="text/javascript" charset="utf-8" src="phonegap/plugin/wizAssets/wizAssets.js"></script> (assuming your index.html is setup like tree above)

4 ) Follow example code below...

API

downloadFile()

wizAssets.downloadFile(String URL, String filePathToBeStoredWithFilename, Function success, Function fail);

  • downloads a file to native App directory @ ./ + gameDir+ / +filePathToBeStoredWithFilename
  • A success returns URI string like; file://documents/settings/img/cards/card001.jpg
  • example;
wizAssets.downloadFile("http://google.com/logo.jpg", "img/ui/logo.jpg", successCallback, failCallback);

deleteFile()

wizAssets.deleteFile(string URI, Function success, Function fail);

  • deletes the file specified by the URI
  • if the URI does not exist fail will be called with error NotFoundError
  • if the URI cannot be deleted (i.e. file resides in read-only memory) fail will be called with error NotModificationAllowedError
wizAssets.deleteFile("file://documents/settings/img/cards/card001.jpg", successCallback, failCallback);

deleteFiles()

wizAssets.deleteFiles(Array manyURIs, Function success, Function fail );

  • delete all URIs in Array like; [ "file://documents/settings/img/cards/card001.jpg", "file://documents/settings/img/cards/card002.jpg " .. ]
  • if you do not specify a filename only dir, then all contents of dir will be deleted; file://documents/settings/img/cards
  • the array CAN contain one URI string

getFileURI()

wizAssets.getFileURI(String filePathWithFilename, Function success, Function fail);

  • A success returns URI string like file://documents/settings/img/cards/card001.jpg
  • example;
wizAssets.getFileURI("img/ui/logo.jpg", successCallback, failCallback);

getFileURIs()

wizAssets.getFileURIs(Function success, Function fail);

  • A success returns URI hashmap such as
{

    "img/ui/loader.gif"  : "/sdcard/<appname>/img/ui/loading.gif", 
    "img/cards/card001.jpg" : "file://documents/settings/img/cards/card001.jpg" 

} 

phonegap-plugin-wizassets's People

Contributors

aogilvie avatar

Watchers

James Cloos avatar Chris Wynn avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.