Guest User

Untitled

a guest
Feb 18th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. function handle_attachments() {
  2. // make sure we have new args before firing
  3. // prevents handling of the same file every time the app opens, resumes, etc
  4. args = Ti.App.getArguments();
  5. var file = args.url;
  6. var source = args.source;
  7.  
  8. // make sure we have something to work with
  9. if(!file) {
  10. return false;
  11. }
  12.  
  13. //opening text file
  14. if( file.indexOf('.txt') != -1 ) {
  15. curr_note_args = Ti.App.Properties.getString('curr_note_args');
  16. if(curr_note_args == args.url) {
  17. return false;
  18. }
  19. // DO SOMETHING HERE
  20.  
  21. Ti.App.Properties.setString('curr_note_args', args.url);
  22. }
  23.  
  24. // opening wave file
  25. if( file.indexOf('.wav') != -1 ) {
  26. curr_audio_args = Ti.App.Properties.getString('curr_audio_args');
  27. if(curr_audio_args == args.url) {
  28. return false;
  29. }
  30. // DO SOMETHING HERE
  31.  
  32. Ti.App.Properties.setString('curr_audio_args', args.url);
  33. }
  34. }
  35.  
  36. // Ti doesn't have an 'open' listener for the app so we listen on the main window
  37. b.addEventListener('open', function(e) {
  38. handle_attachments();
  39. });
  40. Ti.App.addEventListener('resume', function(e) {
  41. handle_attachments();
  42. });
  43. Ti.App.addEventListener('resumed', function(e) {
  44. handle_attachments();
  45. });
  46. Ti.App.addEventListener('pause', function(e) {
  47. handle_attachments();
  48. });
Add Comment
Please, Sign In to add comment