Skip to content

Commit

Permalink
Merge pull request #2114 from AndreMiras/feature/fixes_linting
Browse files Browse the repository at this point in the history
Fixes linting errors in runnable.py
  • Loading branch information
AndreMiras authored Mar 30, 2020
2 parents 0af0ffa + 2e16e67 commit a548330
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions pythonforandroid/recipes/android/src/android/runnable.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'''
Runnable
========
'''

from jnius import PythonJavaClass, java_method, autoclass
Expand All @@ -14,6 +13,7 @@
# is limited, so by caching them we avoid running out.
__functionstable__ = {}


class Runnable(PythonJavaClass):
'''Wrapper around Java Runnable class. This class can be used to schedule a
call of a Python function into the PythonActivity thread.
Expand All @@ -30,7 +30,6 @@ def __call__(self, *args, **kwargs):
self.args = args
self.kwargs = kwargs
Runnable.__runnables__.append(self)

_PythonActivity.mActivity.runOnUiThread(self)

@java_method('()V')
Expand All @@ -42,24 +41,18 @@ def run(self):
traceback.print_exc()

Runnable.__runnables__.remove(self)




def run_on_ui_thread(f):
'''Decorator to create automatically a :class:`Runnable` object with the
function. The function will be delayed and call into the Activity thread.
'''

if f not in __functionstable__:

rfunction = Runnable(f) #store the runnable function

__functionstable__[f] = {"rfunction":rfunction}

rfunction = Runnable(f) # store the runnable function
__functionstable__[f] = {"rfunction": rfunction}
rfunction = __functionstable__[f]["rfunction"]

def f2(*args, **kwargs):
rfunction(*args, **kwargs)

return f2

0 comments on commit a548330

Please sign in to comment.