comparison cagou/plugins/plugin_transfer_android_gallery.py @ 444:e578df3304d8

transfer (android gallery): unbind activity_result
author Goffi <goffi@goffi.org>
date Sat, 07 Mar 2020 00:05:50 +0100
parents 1da3c379205b
children 3c9ba4a694ef
comparison
equal deleted inserted replaced
443:61322ff8090b 444:e578df3304d8
44 "description": _("upload a photo from photo gallery"), 44 "description": _("upload a photo from photo gallery"),
45 "icon_medium": "{media}/icons/muchoslava/png/gallery_50.png", 45 "icon_medium": "{media}/icons/muchoslava/png/gallery_50.png",
46 } 46 }
47 47
48 48
49 class AndroidGallery(object): 49 class AndroidGallery:
50 50
51 def __init__(self, callback, cancel_cb): 51 def __init__(self, callback, cancel_cb):
52 self.callback = callback 52 self.callback = callback
53 self.cancel_cb = cancel_cb 53 self.cancel_cb = cancel_cb
54 activity.bind(on_activity_result=self.on_activity_result) 54 activity.bind(on_activity_result=self.on_activity_result)
56 intent.setType('image/*') 56 intent.setType('image/*')
57 intent.setAction(Intent.ACTION_GET_CONTENT) 57 intent.setAction(Intent.ACTION_GET_CONTENT)
58 mActivity.startActivityForResult(intent, PHOTO_GALLERY); 58 mActivity.startActivityForResult(intent, PHOTO_GALLERY);
59 59
60 def on_activity_result(self, requestCode, resultCode, data): 60 def on_activity_result(self, requestCode, resultCode, data):
61 activity.unbind(on_activity_result=self.on_activity_result)
61 # TODO: move file dump to a thread or use async callbacks during file writting 62 # TODO: move file dump to a thread or use async callbacks during file writting
62 if requestCode == PHOTO_GALLERY and resultCode == RESULT_OK: 63 if requestCode == PHOTO_GALLERY and resultCode == RESULT_OK:
63 if data is None: 64 if data is None:
64 log.warning("No data found in activity result") 65 log.warning("No data found in activity result")
65 self.cancel_cb(self, None) 66 self.cancel_cb(self, None)