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
View bottomSheetView = getDialog().getWindow().getDecorView().findViewById(android.support.design.R.id.design_bottom_sheet); | |
BottomSheetBehavior.from(bottomSheetView).setHideable(false); |
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
private BottomSheetBehavior.BottomSheetCallback mBottomSheetCallback | |
= new BottomSheetBehavior.BottomSheetCallback() { | |
@Override | |
public void onStateChanged(@NonNull View bottomSheet, | |
@BottomSheetBehavior.State int newState) { | |
if (newState == BottomSheetBehavior.STATE_HIDDEN) { | |
dismiss(); | |
} | |
} |
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
<FrameLayout | |
android:id="@+id/design_bottom_sheet" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:layout_gravity="center_horizontal|top" | |
android:clickable="true" | |
app:layout_behavior="@string/bottom_sheet_behavior" | |
style="?attr/bottomSheetStyle"/> |
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
View touchOutsideView = getDialog().getWindow().getDecorView().findViewById(android.support.design.R.id.touch_outside); | |
touchOutsideView.setOnClickListener(null); |
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
private View wrapInBottomSheet(int layoutResId, View view, ViewGroup.LayoutParams params) { | |
... | |
if (shouldWindowCloseOnTouchOutside()) { | |
coordinator.findViewById(R.id.touch_outside).setOnClickListener( | |
new View.OnClickListener() { | |
@Override | |
public void onClick(View view) { | |
if (isShowing()) { | |
cancel(); | |
} |
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
<View | |
android:id="@+id/touch_outside" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:soundEffectsEnabled="false"/> |
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
tasks.withType(JavaCompile) { | |
compileTask -> compileTask.dependsOn ndkBuild | |
} |
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
task ndkBuild(type: Exec, description: ‘Compile JNI source via NDK’) { | |
println(‘executing ndkBuild’) | |
def ndkDir = project.android.ndkDirectory | |
commandLine “$ndkDir/ndk-build”, | |
‘NDK_PROJECT_PATH=build/intermediates/ndk’, | |
‘APP_BUILD_SCRIPT=src/main/jni/Android.mk’, | |
‘NDK_APPLICATION_MK=src/main/jni/Application.mk’, | |
‘V=1’ | |
} |
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
// Find the class of Float | |
jclass FloatClass = env->FindClass(“java/lang/Float”); | |
// And the method ID of constructor of the Float class | |
jmethodID FloatInit = env->GetMethodID(FloatClass, “<init>”, “(F)V”); | |
for (int i = 0; i < 10; i += 1) { | |
jsize index = i; | |
// Create instances of Float | |
jobject value1 = env->NewObject(FloatClass, FloatInit, xxx); | |
jobject value2 = env->NewObject(FloatClass, FloatInit, xxx); | |
// Put the Float values into float arrays |
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
// Find the Java class of ArrayList | |
jclass arrayListClass = (*env).FindClass(“java/util/ArrayList”); | |
// Create an instance by finding the method ID of the constructor | |
jobject arrayList = (*env).NewObject(arrayListClass, (*env).GetMethodID(arrayListClass, “<init>”, “()V”)); | |
// Find the class of float | |
jclass floatClass = env->FindClass(“F”); | |
// Let’s assume a float array contains 10 elements | |
jsize size = 10; | |
// Create arrays |