Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrated to androidX, kotlin. refactored. #1

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 109 additions & 25 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 45 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 16 additions & 9 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 28
compileSdkVersion 29
defaultConfig {
applicationId "com.droidbyme.bottomsheet"
minSdkVersion 19
targetSdkVersion 28
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}
buildTypes {
release {
Expand All @@ -20,10 +22,15 @@ android {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation "androidx.core:core-ktx:1.2.0"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
repositories {
jcenter()
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.droidbyme.bottomsheet;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">
<activity android:name=".MenuActivity">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down

This file was deleted.

69 changes: 69 additions & 0 deletions app/src/main/java/com/droidbyme/bottomsheet/BottomSheetFragment.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package com.droidbyme.bottomsheet

import android.app.Dialog
import android.content.DialogInterface
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.FrameLayout
import android.widget.ImageView
import android.widget.Toast
import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.google.android.material.bottomsheet.BottomSheetDialogFragment

class BottomSheetFragment : BottomSheetDialogFragment() {

/** ⚽️ This method is sufficient if you only need to set contentView and manipulate views */
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val view = inflater.inflate(R.layout.bottom_sheet_2, container, false)
view.findViewById<ImageView>(R.id.imageView).setOnClickListener{
Toast.makeText(context, "clicked", Toast.LENGTH_SHORT).show()
}
return view
}

/** 🏵 This method is needed if you want to set callback method which is triggered when the bottom sheet dialog is shown. Then you can watch state changes */
/** In addition, you can set the layout in onCreateDialog() method, then you can remove the above onCreateView() method.
* val dialog = super.onCreateDialog(savedInstanceState) as BottomSheetDialog
* val view = View.inflate(context, R.layout.fragment_bottomsheet3, null)
* dialog.setContentView(view)
*/
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {

val dialog = super.onCreateDialog(savedInstanceState) as BottomSheetDialog

dialog.setOnShowListener(DialogInterface.OnShowListener { dialogInterface ->
val b = dialogInterface as BottomSheetDialog
val b2 = b.findViewById<FrameLayout>(R.id.design_bottom_sheet)

b2?.let{
val bottomSheetBehavior = BottomSheetBehavior.from<FrameLayout>(it)
bottomSheetBehavior.addBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback(){
override fun onSlide(bottomSheet: View, slideOffset: Float) {
Log.d("test123", "onSlide: $slideOffset")
}

override fun onStateChanged(bottomSheet: View, newState: Int) {
Log.d("test123", "onStateChanged: $newState")
}

})
}
})
return dialog
}

/** 🪂 It is also possible to set layout using only setupDialog() method */
/*override fun setupDialog(dialog: Dialog, style: Int) {
val view = View.inflate(context, R.layout.bottom_sheet_2, null)

view.findViewById<ImageView>(R.id.imageView).setOnClickListener{
Toast.makeText(context, "clicked", Toast.LENGTH_SHORT).show()
}

dialog.setContentView(view)
}*/
}
Loading