Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function handle_attachments() {
- // make sure we have new args before firing
- // prevents handling of the same file every time the app opens, resumes, etc
- args = Ti.App.getArguments();
- var file = args.url;
- var source = args.source;
- // make sure we have something to work with
- if(!file) {
- return false;
- }
- //opening text file
- if( file.indexOf('.txt') != -1 ) {
- curr_note_args = Ti.App.Properties.getString('curr_note_args');
- if(curr_note_args == args.url) {
- return false;
- }
- // DO SOMETHING HERE
- Ti.App.Properties.setString('curr_note_args', args.url);
- }
- // opening wave file
- if( file.indexOf('.wav') != -1 ) {
- curr_audio_args = Ti.App.Properties.getString('curr_audio_args');
- if(curr_audio_args == args.url) {
- return false;
- }
- // DO SOMETHING HERE
- Ti.App.Properties.setString('curr_audio_args', args.url);
- }
- }
- // Ti doesn't have an 'open' listener for the app so we listen on the main window
- b.addEventListener('open', function(e) {
- handle_attachments();
- });
- Ti.App.addEventListener('resume', function(e) {
- handle_attachments();
- });
- Ti.App.addEventListener('resumed', function(e) {
- handle_attachments();
- });
- Ti.App.addEventListener('pause', function(e) {
- handle_attachments();
- });
Add Comment
Please, Sign In to add comment