Some suggestions.
Here are a few things I see in your code.
I suspect your issue is: You have redefined source in Piccollect. Image has an attribute source. You have added a kivy property named source. Just use self.source of Image.
Use a ListProperty to for the rv data.
In the kv code add it…
<RV>:
data: self.rv_data
viewclass: 'Piccollect'
RecycleGridLayout:
orientation: 'lr-tb'
cols: 4
spacing: ['5dp' , '10dp']
padding: ['5dp']
#default_size: None, dp(rv.width/self.cols*.6)
default_size_hint: 1, None
size_hint_y: None
height: self.minimum_height
And in Python:
class RV(RecycleView):
rv_data = ListProperty()
I also suggest you move your permission code, takingper() to the on_start method of app. The __init__ of recycle view is an odd place for this code.
Make sure your code is running on a desktop, then add the android specifics.
--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/d962bf45-6173-4c5e-ad9d-7b9492008659n%40googlegroups.com.
This can be useful as it prevents your application from waiting until the image is loaded. If you want to display large images or retrieve them from URL’s, using AsyncImage will allow these resources to be retrieved on a background thread without blocking your application.

.jpeg?part=0.2&view=1)
Share a minimal executable that demonstrates the issue.
From: purushottam yadav
Sent: Sunday, July 18, 2021 11:35 AM
To: Kivy users support
Subject: Re: [kivy-users] Re: recycleview on android
This is a memory issue . Someone online suggested me that
"if your code works with few images, then your code is not broken. i would assume there's a memory issue here and simply too much data. try running it on a more powerful desktop and see if it works in principle... "
After this I used AsyncImage for piccollect instead of Image .
This can be useful as it prevents your application from waiting until the image is loaded. If you want to display large images or retrieve them from URL’s, using AsyncImage will allow these resources to be retrieved on a background thread without blocking your application.
class Piccollect(AsyncImage): , Now there is no delay on starting the app in all the cases , but it has delay to display images in all the cases .
when I tried to display few images , there was no delay to start but default images were displayed for a while ( 2 secs ) , and actually images where displayed .
when I tried to display all the images , there was no delay to start but default images were displayed for a while ( 2 secs ) , and actually images started to display and again APK CRASHED , and my phone got hanged for a while .
Below are screen shots during that 2 secs of loading the images .
Now the problem is that while displaying few images APK did not CRASH but CRASHED when tried to display all the images in the android device .
I guess , this is because of loading alot of data at once .
why this is happening and how to handle this issue ?
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/303dfd27-0eeb-4ccf-8092-553c9e4fb4d5n%40googlegroups.com.
In the code below I have made a few changes, some are fixes some are just style so I could run the app on my laptop. My guess is the fundamental issue is that you are dealing with a large number of high resolution images on the phone. I would recommend you create thumbnails for all of the images and display the thumbnail. The app can switch to the full resolution image when required. You may consider storing the thumbnails or the path to the thumbnails in an SQLite database. There may already be a SQLite database on the phone for picture thumbnails – I know apple does it this way.
# from tile import SmartTile
from kivy.app import App
from kivy.lang import Builder
from kivy.properties import ListProperty
from kivy.uix.image import Image
from kivy.uix.recycleview import RecycleView
from kivy.utils import platform
from pathlib import Path
# from tile import SmartTile
kv = '''
<PicCollect>:
#on_release: app.calll(root.source)
<RV>:
viewclass: 'PicCollect'
data: self.rv_data
RecycleGridLayout:
orientation: 'lr-tb'
cols: 4
spacing: ['5dp' , '10dp']
padding: ['5dp']
#default_size: None, dp(rv.width/self.cols*.6)
default_size_hint: 1, None
size_hint_y: None
height: self.minimum_height
BoxLayout:
RV:
id: rv
'''
class RV(RecycleView):
rv_data = ListProperty()
def __init__(self, **kwargs):
super(RV, self).__init__(**kwargs)
# self.takingper()
self.dd = None # used for building the rv_data list
# def on_start(self): # These are all methods of App, not RecycleView
# print("created app " * (20))
#
# def on_stop(self):
# print(" stoped app " * (20))
#
# def on_pause(self):
# print(" paused app " * (20))
#
# def on_resume(self):
# print(" resumed app " * (20))
def takingper(self):
# only Request permissions on Android , not loading images path
if platform == 'android':
pass
# from android.permissions import Permission, request_permissions
#
# def call__back(permission, results):
# if all([res for res in results]):
# print("Got all permissions>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
# self.per = True
# return self.loadaddress()
# print("called loadaddress function ======================")
#
# else:
# print("Did not get all permissions>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
#
# request_permissions([Permission.WRITE_EXTERNAL_STORAGE, Permission.READ_EXTERNAL_STORAGE], call__back)
else:
self.load_address()
def load_address(self):
# this piece of code is for formatting the date string as required
from datetime import date
# calling the today
# function of date class
today = date.today()
self.dddate = f'{today.year}{today.month:02d}{today.day:02d}'
# if len(str(today.month)) == 1:
# self.m = "0" + str(today.month)
# else:
# self.m = str(today.month)
#
# if len(str(today.day)) == 1:
# self.d = "0" + str(today.day)
# else:
# self.d = str(today.day)
#
# self.dddate = str(today.year) + str(self.m) + str(self.d)
# self.dddate will be 20210709 as todays date is 9/7/2021
print(str(self.dddate), "date>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
# self.dd = []
if platform == 'android':
print("loading....=============================")
# for file in glob.glob(f"/storage/emulated/0/DCIM/Camera/IMG_{self.dddate}_*.*") :
# shutil.copy( str(file) , ".")
# self.dd.append({ 'source' : str(file) } )
# In this case apk is taking 15 secs to display the images on the screen
# self.dd = [{'source': file} for file in glob.glob(
# f"/storage/emulated/0/DCIM/Camera/IMG_{self.dddate}_*.*")] # when i want to collect today captured images
# In this case apk is crashing on android just after starting , only blackscreen is displayed for 5 secs
# self.dd = [{'source': file} for file in glob.glob(f"/storage/emulated/0/DCIM/Camera/IMG_*.*")] #when i want to collect all the captured images (800 images ) in the device
else:
print("load_address, not android")
# self.dd = [{'source': file} for file in glob.glob(f"home/purushottam2/Pictures/*.*")]
p = Path.home() / 'OneDrive'/ 'Pictures' / 'family pics
self.dd = [{'source': str(file)} for file in p.glob('*.jpg')]
# from plyer import storagepath
# for root, dirs, files in os.walk(str(storagepath.get_pictures_dir())):
# for file in files:
# if (file.endswith(".jpeg")) or (file.endswith(".png")):
# ss = str(os.path.join(root, file))
#
# self.dd.append({'source': ss})
self.rv_data = self.dd
# print(f'{len(dd)}')
# print(f'{self.rv_data}')
# print(f'len(self.rv_data))
# print(self.data)
# print(len(self.data))
class PicCollect(Image):
# source = StringProperty('')
# nocache = True
# print("created=====================================================")
def on_touch_down(self, touch):
if self.collide_point(*touch.pos):
print("selecting......", self.source)
# k.calll(self.source)
class TestApp(App):
def build(self):
return Builder.load_string(kv)
def on_start(self):
self.root.ids.rv.takingper()
if __name__ == '__main__':
TestApp().run()
From: purushottam yadav
Sent: Sunday, July 18, 2021 11:58 AM
To: Kivy users support
Subject: Re: [kivy-users] Re: recycleview on android
I have attached main file .
On Monday, July 19, 2021 at 12:20:22 AM UTC+5:30 ElliotG wrote:
Share a minimal executable that demonstrates the issue.
From: purushottam yadav
Sent: Sunday, July 18, 2021 11:35 AM
To: Kivy users support
Subject: Re: [kivy-users] Re: recycleview on android
This is a memory issue . Someone online suggested me that
"if your code works with few images, then your code is not broken. i would assume there's a memory issue here and simply too much data. try running it on a more powerful desktop and see if it works in principle... "
After this I used AsyncImage for piccollect instead of Image .
This can be useful as it prevents your application from waiting until the image is loaded. If you want to display large images or retrieve them from URL’s, using AsyncImage will allow these resources to be retrieved on a background thread without blocking your application.
class Piccollect(AsyncImage): , Now there is no delay on starting the app in all the cases , but it has delay to display images in all the cases .
when I tried to display few images , there was no delay to start but default images were displayed for a while ( 2 secs ) , and actually images where displayed .
when I tried to display all the images , there was no delay to start but default images were displayed for a while ( 2 secs ) , and actually images started to display and again APK CRASHED , and my phone got hanged for a while .
Below are screen shots during that 2 secs of loading the images .
Now the problem is that while displaying few images APK did not CRASH but CRASHED when tried to display all the images in the android device .
I guess , this is because of loading alot of data at once .
why this is happening and how to handle this issue ?
On Monday, July 12, 2021 at 7:49:26 PM UTC+5:30 ElliotG wrote:
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/006b79bc-5994-41be-8b77-6d4fef918fafn%40googlegroups.com.
I have no idea… search google, look in the exif data of the thumbnail, see if you can find a SQLite database file.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/281650f6-da8c-4cfa-bd0a-e864d50f095en%40googlegroups.com.