MCPcopy Create free account
hub / github.com/dtmilano/AndroidViewClient / factory

Method factory

src/com/dtmilano/android/viewclient.py:178–224  ·  view source on GitHub ↗

View factory @type arg1: ClassType or dict @type arg2: View instance or AdbClient

(arg1, arg2, version=-1, forceviewserveruse=False, windowId=None, uiAutomatorHelper=None)

Source from the content-addressed store, hash-verified

176
177 @staticmethod
178 def factory(arg1, arg2, version=-1, forceviewserveruse=False, windowId=None, uiAutomatorHelper=None):
179 """
180 View factory
181
182 @type arg1: ClassType or dict
183 @type arg2: View instance or AdbClient
184 """
185
186 if DEBUG_VIEW_FACTORY:
187 print("View.factory(%s, %s, %s, %s, %s, %s)" % (
188 arg1, arg2, version, forceviewserveruse, windowId, uiAutomatorHelper), file=sys.stderr)
189 if type(arg1) == type:
190 cls = arg1
191 attrs = None
192 else:
193 cls = None
194 attrs = arg1
195 if isinstance(arg2, View):
196 view = arg2
197 device = None
198 else:
199 device = arg2
200 view = None
201
202 if attrs and 'class' in attrs:
203 clazz = attrs['class']
204 if DEBUG_VIEW_FACTORY:
205 print(" View.factory: creating View with specific class: %s" % clazz, file=sys.stderr)
206 if clazz == 'android.widget.TextView':
207 return TextView(attrs, device, version, forceviewserveruse, windowId, uiAutomatorHelper)
208 elif clazz == 'android.widget.EditText':
209 return EditText(attrs, device, version, forceviewserveruse, windowId, uiAutomatorHelper)
210 elif clazz == 'android.widget.ListView':
211 return ListView(attrs, device, version, forceviewserveruse, windowId, uiAutomatorHelper)
212 else:
213 return View(attrs, device, version, forceviewserveruse, windowId, uiAutomatorHelper)
214 elif cls:
215 if view:
216 return cls.__copy(view)
217 else:
218 return cls(attrs, device, version, forceviewserveruse, windowId, uiAutomatorHelper)
219 elif view:
220 return copy.copy(view)
221 else:
222 if DEBUG_VIEW_FACTORY:
223 print(" View.factory: creating generic View", file=sys.stderr)
224 return View(attrs, device, version, forceviewserveruse, windowId, uiAutomatorHelper)
225
226 @classmethod
227 def __copy(cls, view):

Callers 6

StartElementMethod · 0.45
__parseTreeMethod · 0.45
testViewFactory_ViewMethod · 0.45

Calls 5

TextViewClass · 0.85
EditTextClass · 0.85
ListViewClass · 0.85
ViewClass · 0.85
__copyMethod · 0.80

Tested by 2

testViewFactory_ViewMethod · 0.36