public interface ViewWithActivity {
// Using android-gradle-plugin 3.0, which has the desugar step for default methods on interfaces
default Activity getActivity() {
// https://android.googlesource.com/platform/frameworks/support/+/03e0f3daf3c97ee95cd78b2f07bc9c1be05d43db/v7/mediarouter/src/android/support/v7/app/MediaRouteButton.java#276
Context context = getContext();
while (context instanceof ContextWrapper) {
if (context instanceof Activity) {https://stackoverflow.com/a/11583503/1891118
To help track down the setting, I'd try to use:
git config --local credential.helper
git config --global credential.helper
git config --system credential.helper
This file contains hidden or 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
| import android.content.ComponentName; | |
| import android.content.Context; | |
| import android.content.pm.PackageManager; | |
| public class Android_enableManifestComponent { | |
| public static void enableManifestComponent(Context context, Class<?> component, boolean enable) { | |
| ComponentName receiver = new ComponentName(context, component); | |
| PackageManager pm = context.getPackageManager(); | |
This file contains hidden or 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
| apply plugin: 'maven' | |
| afterEvaluate { project -> | |
| uploadArchives { | |
| repositories { | |
| mavenDeployer { | |
| repository(url: mavenLocal().url) | |
| pom.groupId = project.group | |
| pom.artifactId = project.name | |
| pom.version = project.version |
This file contains hidden or 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
| import android.annotation.SuppressLint; | |
| import android.content.Context; | |
| import android.support.annotation.Nullable; | |
| @SuppressLint("PrivateApi") | |
| public class StaticContext { | |
| @Nullable | |
| public static Context getContext() { | |
| try { | |
| return (Context) Class.forName("android.app.ActivityThread") |
This file contains hidden or 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
| import android.content.Context; | |
| import android.os.Handler; | |
| import android.os.Looper; | |
| import android.os.Message; | |
| import android.widget.Toast; | |
| @SuppressWarnings({"unused", "PrivateApi", "StaticFieldLeak", "SameParameterValue", "WeakerAccess"}) | |
| public final class Toaster implements Handler.Callback { | |
| private static Context context; | |
| private static Handler handler; |
This file contains hidden or 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
| <?xml version="1.0"?> | |
| <manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
| package="com.google.firebase"> | |
| <application> | |
| <provider | |
| android:authorities="${applicationId}.firebaseinitprovider" | |
| android:name="com.google.firebase.provider.FirebaseInitProvider" | |
| android:exported="false" | |
| android:initOrder="100" | |
| /> |
This file contains hidden or 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
| public class Test24 { | |
| private static final Object[] lock = { "Zero", new Integer(1), Double.valueOf(2) }; | |
| static void notifyAndPrint(int who, int what) { | |
| synchronized (lock[who]) { | |
| System.out.print(what); | |
| lock[who].notifyAll(); | |
| } | |
| } |
This file contains hidden or 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
| // NOTE in this example setStackFromEnd(true) was used | |
| // so we operate here with 'bottom', 'last' properties/methods | |
| public void setNewData(List<Object> newData) { | |
| Object currentItem = null; | |
| Rect parentRect = new Rect(); | |
| if (!recyclerView.getGlobalVisibleRect(parentRect)) { | |
| parentRect = null; | |
| } |
This file contains hidden or 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
| public class Kmp { | |
| public static int indexOf(String t, String p) { | |
| return compile(p).matcher(t).find(); | |
| } | |
| public static Pattern compile(String p) { | |
| return new Pattern(p); | |
| } | |
| public static class Pattern { |