@@ -33,7 +33,6 @@ class AppStore(Activity):
3333 _DEFAULT_BACKEND = _BACKEND_API_GITHUB + "," + _GITHUB_PROD_BASE_URL + "/" + _GITHUB_LIST
3434
3535 apps = []
36- prefs = None
3736 can_check_network = True
3837
3938 # Widgets:
@@ -46,18 +45,8 @@ class AppStore(Activity):
4645 progress_bar = None
4746 settings_button = None
4847
49- @staticmethod
50- def _apply_default_styles (widget , border = 0 , radius = 0 , pad = 0 ):
51- """Apply common default styles to reduce repetition"""
52- widget .set_style_border_width (border , 0 )
53- widget .set_style_radius (radius , 0 )
54- widget .set_style_pad_all (pad , 0 )
55-
56- def _add_click_handler (self , widget , callback , app ):
57- """Register click handler to avoid repetition"""
58- widget .add_event_cb (lambda e , a = app : callback (a ), lv .EVENT .CLICKED , None )
59-
6048 def onCreate (self ):
49+ self .prefs = SharedPreferences (self .PACKAGE )
6150 self .main_screen = lv .obj ()
6251 self .please_wait_label = lv .label (self .main_screen )
6352 self .please_wait_label .set_text ("Downloading app index..." )
@@ -75,9 +64,7 @@ def onCreate(self):
7564 self .setContentView (self .main_screen )
7665
7766 def onResume (self , screen ):
78- super ().onResume (screen )
79- if not self .prefs :
80- self .prefs = SharedPreferences (self .PACKAGE )
67+ super ().onResume (screen ) # super handles self._has_foreground
8168 if not len (self .apps ):
8269 self .refresh_list ()
8370
@@ -232,6 +219,20 @@ def show_app_detail(self, app):
232219 intent .putExtra ("appstore" , self )
233220 self .startActivity (intent )
234221
222+ def _get_backend_config (self ):
223+ """Get backend configuration tuple (type, list_url, details_url)"""
224+ pref_string = self .prefs .get_string ("backend" , self ._DEFAULT_BACKEND )
225+ return AppStore .backend_pref_string_to_backend (pref_string )
226+
227+ def get_backend_type_from_settings (self ):
228+ return self ._get_backend_config ()[0 ]
229+
230+ def get_backend_list_url_from_settings (self ):
231+ return self ._get_backend_config ()[1 ]
232+
233+ def get_backend_details_url_from_settings (self ):
234+ return self ._get_backend_config ()[2 ]
235+
235236 @staticmethod
236237 def badgehub_app_to_mpos_app (bhapp ):
237238 name = bhapp .get ("name" )
@@ -252,20 +253,6 @@ def badgehub_app_to_mpos_app(bhapp):
252253 print ("Could not parse category" )
253254 return App (name , None , short_description , None , icon_url , None , fullname , None , category , None )
254255
255- def _get_backend_config (self ):
256- """Get backend configuration tuple (type, list_url, details_url)"""
257- pref_string = self .prefs .get_string ("backend" , self ._DEFAULT_BACKEND )
258- return AppStore .backend_pref_string_to_backend (pref_string )
259-
260- def get_backend_type_from_settings (self ):
261- return self ._get_backend_config ()[0 ]
262-
263- def get_backend_list_url_from_settings (self ):
264- return self ._get_backend_config ()[1 ]
265-
266- def get_backend_details_url_from_settings (self ):
267- return self ._get_backend_config ()[2 ]
268-
269256 @staticmethod
270257 def get_backend_pref_string (index ):
271258 backend_info = AppStore .backends [index ]
@@ -282,3 +269,15 @@ def get_backend_pref_string(index):
282269 @staticmethod
283270 def backend_pref_string_to_backend (string ):
284271 return string .split ("," )
272+
273+ @staticmethod
274+ def _apply_default_styles (widget , border = 0 , radius = 0 , pad = 0 ):
275+ """Apply common default styles to reduce repetition"""
276+ widget .set_style_border_width (border , 0 )
277+ widget .set_style_radius (radius , 0 )
278+ widget .set_style_pad_all (pad , 0 )
279+
280+ @staticmethod
281+ def _add_click_handler (widget , callback , app ):
282+ """Register click handler to avoid repetition"""
283+ widget .add_event_cb (lambda e , a = app : callback (a ), lv .EVENT .CLICKED , None )
0 commit comments