-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dedicated class for grabbing context in python
- Loading branch information
Showing
4 changed files
with
41 additions
and
2 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
python-for-android/dists/kolibri/src/main/java/org/kivy/android/PythonContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package org.kivy.android; | ||
|
||
import android.content.Context; | ||
|
||
public class PythonContext { | ||
public static PythonContext mInstance; | ||
|
||
private final Context context; | ||
|
||
private PythonContext(Context context) { | ||
this.context = context; | ||
} | ||
|
||
public static PythonContext getInstance(Context context) { | ||
if (mInstance == null) { | ||
synchronized (PythonContext.class) { | ||
if (mInstance == null) { | ||
mInstance = new PythonContext( | ||
context.getApplicationContext() | ||
); | ||
} | ||
} | ||
} | ||
return PythonContext.mInstance; | ||
} | ||
|
||
public static Context get() { | ||
if (PythonContext.mInstance == null) { | ||
return null; | ||
} | ||
return PythonContext.mInstance.context; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters