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
findPreference<Preference>(getString(R.string.setting_settings_key)) | |
?.setOnPreferenceClickListener { pref -> | |
@SuppressLint("RestrictedApi") | |
if (listView.adapter is PreferenceGroupAdapter) { | |
val adapter = listView.adapter as PreferenceGroupAdapter | |
val position = adapter.getPreferenceAdapterPosition(pref) | |
if (position != RecyclerView.NO_POSITION) { | |
val itemView = listView.findViewHolderForAdapterPosition(position)?.itemView | |
if (itemView != null) { | |
// do something |
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 com.google.protobuf.gradle.* | |
plugins { | |
id("com.google.protobuf") version "0.8.18" | |
} | |
protobuf { | |
protoc { | |
artifact = "com.google.protobuf:protoc:3.19.1" | |
} |
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
#!/bin/sh | |
# Usage: ./watch-fds.sh <application_id> [delay_secs = 5] | |
APP_ID=${1:?missing application id} | |
DELAY=$(( ${2:-5} )) | |
DEVICE_LIMIT=$(( $(adb shell ulimit -n) )) | |
WARN_THRESHOLD=$(( ${DEVICE_LIMIT} / 3 )) | |
echo "Will warn at ${WARN_THRESHOLD}" |
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
GetObjectClass -> DeleteLocalRef | |
FindClass -> DeleteLocalRef | |
NewString -> DeleteLocalRef | |
NewStringUTF -> DeleteLocalRef | |
NewObject -> DeleteLocalRef | |
NewBooleanArray -> DeleteLocalRef | |
NewByteArray -> DeleteLocalRef | |
NewCharArray -> DeleteLocalRef | |
NewShortArray -> DeleteLocalRef | |
NewIntArray -> DeleteLocalRef |
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.app.Activity; | |
import android.content.DialogInterface; | |
import android.content.pm.PackageManager; | |
import android.support.annotation.NonNull; | |
import android.support.annotation.Nullable; | |
import android.support.annotation.StringRes; | |
import android.support.v4.app.ActivityCompat; | |
import java.util.Map; |
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
//call if(BuildConfig.DEBUG) registerActivityLifecycleCallbacks(new ActivityLifecycleLogger()) in your own Application class. | |
public class ActivityLifecycleLogger implements Application.ActivityLifecycleCallbacks { | |
private static final String TAG = "LifeCycleLogger"; | |
private static final Class[] LOG_CYCLE_ACTIVITIES = new Class[] { | |
//add activities you want to log here | |
MainActivity.class | |
}; |
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
Intent[] targetedShareIntents = new Intent[infos.size()]; | |
for (int i = 0; i < infos.size(); i++) { | |
String packageName = infos.get(i).activityInfo.packageName; | |
Intent targetedShareIntent = new Intent(Intent.ACTION_VIEW, uri); | |
targetedShareIntent.setPackage(packageName); | |
targetedShareIntents[i] = targetedShareIntent; | |
} | |
Intent chooserIntent = Intent.createChooser(new Intent(), "打开网页"); | |
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, targetedShareIntents); |
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.support.annotation.NonNull; | |
import android.support.design.widget.AppBarLayout; | |
import android.support.v4.view.MotionEventCompat; | |
import android.support.v4.view.NestedScrollingChild; | |
import android.support.v4.view.NestedScrollingChildHelper; | |
import android.support.v4.view.VelocityTrackerCompat; | |
import android.support.v4.view.ViewCompat; | |
import android.support.v4.widget.ScrollerCompat; | |
import android.util.AttributeSet; |
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.TargetApi; | |
import android.content.Context; | |
import android.graphics.Canvas; | |
import android.graphics.drawable.Drawable; | |
import android.os.Build; | |
import android.support.annotation.NonNull; | |
import android.util.AttributeSet; | |
import android.widget.ImageView; | |
import me.yugy.app.timeline.R; |
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
.gradle | |
.idea | |
*.iml | |
build | |
gradle* | |
local.properties |
NewerOlder