@@ -24,7 +24,6 @@ class AppStore(Activity):
2424 install_label = None
2525 please_wait_label = None
2626 progress_bar = None
27- _icon_widgets = {}
2827
2928 def onCreate (self ):
3029 self .main_screen = lv .obj ()
@@ -64,7 +63,7 @@ def download_app_index(self, json_url):
6463 print (f"Warning: could not add app from { json_url } to apps list: { e } " )
6564 # Remove duplicates based on app.name
6665 seen = set ()
67- self .apps = [app for app in self .apps if not (app .name in seen or seen .add (app .name ))]
66+ self .apps = [app for app in self .apps if not (app .fullname in seen or seen .add (app .fullname ))]
6867 # Sort apps by app.name
6968 self .apps .sort (key = lambda x : x .name .lower ()) # Use .lower() for case-insensitive sorting
7069 time .sleep_ms (200 )
@@ -84,15 +83,12 @@ def create_apps_list(self):
8483 apps_list .set_style_radius (0 , 0 )
8584 apps_list .set_style_pad_all (0 , 0 )
8685 apps_list .set_size (lv .pct (100 ), lv .pct (100 ))
87- # Clear old icons
88- self ._icon_widgets = {}
86+ self ._icon_widgets = {} # Clear old icons
8987 print ("create_apps_list iterating" )
9088 for app in self .apps :
9189 print (app )
9290 item = apps_list .add_button (None , "Test" )
9391 item .set_style_pad_all (0 , 0 )
94- #item.set_style_border_width(0, 0)
95- #item.set_style_radius(0, 0)
9692 item .set_size (lv .pct (100 ), lv .SIZE_CONTENT )
9793 item .add_event_cb (lambda e , a = app : self .show_app_detail (a ), lv .EVENT .CLICKED , None )
9894 cont = lv .obj (item )
@@ -106,8 +102,8 @@ def create_apps_list(self):
106102 icon_spacer = lv .image (cont )
107103 icon_spacer .set_size (64 , 64 )
108104 icon_spacer .set_src (lv .SYMBOL .REFRESH )
109- self ._icon_widgets [app .fullname ] = icon_spacer
110105 icon_spacer .add_event_cb (lambda e , a = app : self .show_app_detail (a ), lv .EVENT .CLICKED , None )
106+ app .image_icon_widget = icon_spacer # save it so it can be later set to the actual image
111107 label_cont = lv .obj (cont )
112108 label_cont .set_style_border_width (0 , 0 )
113109 label_cont .set_style_radius (0 , 0 )
@@ -130,17 +126,16 @@ def download_icons(self):
130126 print (f"App is stopping, aborting icon downloads." )
131127 break
132128 if not app .icon_data :
133- print (f"No icon_data found for { app } , downloading..." )
134129 app .icon_data = self .download_icon_data (app .icon_url )
135130 if app .icon_data :
136131 print ("download_icons has icon_data, showing it..." )
137- icon_widget = self . _icon_widgets . get ( app .fullname )
138- if icon_widget :
132+ image_icon_widget = app .image_icon_widget
133+ if image_icon_widget :
139134 image_dsc = lv .image_dsc_t ({
140135 'data_size' : len (app .icon_data ),
141136 'data' : app .icon_data
142137 })
143- self .update_ui_threadsafe_if_foreground (icon_widget .set_src , image_dsc ) # error: 'App' object has no attribute 'image'
138+ self .update_ui_threadsafe_if_foreground (image_icon_widget .set_src , image_dsc ) # error: 'App' object has no attribute 'image'
144139 print ("Finished downloading icons." )
145140
146141 def show_app_detail (self , app ):
0 commit comments