Skip to content

Commit

Permalink
reconstruction of the project to match view binding and kotlin 1.4.20…
Browse files Browse the repository at this point in the history
… alongside faster build gradle execution
  • Loading branch information
CrazyLegenD committed Dec 2, 2020
1 parent 84a6daf commit 3150c54
Show file tree
Hide file tree
Showing 15 changed files with 211 additions and 414 deletions.
75 changes: 10 additions & 65 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,79 +1,24 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion compiledAppVersion
defaultConfig {
applicationId "com.crazylegend.mediapicker"
minSdkVersion 21
targetSdkVersion compiledAppVersion
versionCode 1
versionName "1.0"
vectorDrawables.useSupportLibrary = true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}

compileOptions {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}

kotlinOptions {
jvmTarget = "1.8"
}


viewBinding {
enabled = true
}

androidExtensions {
experimental = true
}


kapt {
correctErrorTypes = true
useBuildCache = true
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(path: ':imagepicker')
implementation project(path: ':videopicker')
implementation project(path: ':audiopicker')
implementation project(path: ':core')

//lang features
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"

testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
testImplementation 'junit:junit:4.13.1'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'

//glide
implementation "com.github.bumptech.glide:glide:$glide"
kapt "com.github.bumptech.glide:compiler:$glide"

//core
implementation 'androidx.activity:activity-ktx:1.2.0-alpha06'
implementation 'androidx.fragment:fragment-ktx:1.3.0-alpha06'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.3.0'
implementation "androidx.activity:activity-ktx:$activity"
implementation "androidx.fragment:fragment-ktx:$fragment"
implementation "androidx.appcompat:appcompat:$appCompat"
implementation "androidx.core:core-ktx:$coreKTX"

//ui
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'com.google.android.material:material:1.3.0-alpha01'
implementation "androidx.constraintlayout:constraintlayout:$constraint_layout"
implementation "androidx.recyclerview:recyclerview:$recycler"
implementation "com.google.android.material:material:$material"

//live data
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle"
Expand Down
32 changes: 20 additions & 12 deletions app/src/main/java/com/crazylegend/mediapicker/FragmentResult.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,24 @@ import com.crazylegend.core.modifiers.base.BaseMultiPickerModifier
import com.crazylegend.imagepicker.images.ImageModel
import com.crazylegend.imagepicker.pickers.MultiImagePicker
import com.crazylegend.imagepicker.pickers.SingleImagePicker
import com.crazylegend.mediapicker.databinding.ActivityMainBinding
import com.crazylegend.videopicker.pickers.MultiVideoPicker
import com.crazylegend.videopicker.pickers.SingleVideoPicker
import com.crazylegend.videopicker.videos.VideoModel
import kotlinx.android.synthetic.main.activity_main.*


/**
* Created by crazy on 5/24/20 to long live and prosper !
*/
class FragmentResult : DialogFragment(R.layout.activity_main), View.OnClickListener {

private var binding: ActivityMainBinding? = null

override fun onDestroyView() {
super.onDestroyView()
binding = null
}

private var clickedID = R.id.singleImageBottomSheetPick

private val askForStoragePermission =
Expand Down Expand Up @@ -137,8 +144,8 @@ class FragmentResult : DialogFragment(R.layout.activity_main), View.OnClickListe
Glide.with(this)
.load(audioModel.loadThumbnail(requireContext().contentResolver))
.error(R.drawable.ic_album)
.into(audio)
audioTitle.text = audioModel.displayName
.into(binding!!.audio)
binding!!.audioTitle.text = audioModel.displayName
Log.d("AUDIO_PICKED ${audioModel.thumbnail?.isRecycled}", audioModel.toString())
}

Expand Down Expand Up @@ -208,7 +215,7 @@ class FragmentResult : DialogFragment(R.layout.activity_main), View.OnClickListe
private fun loadVideo(videoModel: VideoModel) {
Glide.with(this)
.load(videoModel.contentUri)
.into(video)
.into(binding!!.video)
Log.d("VIDEO_PICKED", videoModel.toString())
}

Expand Down Expand Up @@ -279,7 +286,7 @@ class FragmentResult : DialogFragment(R.layout.activity_main), View.OnClickListe
private fun loadImage(imageModel: ImageModel) {
Glide.with(this)
.load(imageModel.contentUri)
.into(image)
.into(binding!!.image)
Log.d("IMAGE_PICKED", imageModel.toString())
}

Expand All @@ -291,20 +298,21 @@ class FragmentResult : DialogFragment(R.layout.activity_main), View.OnClickListe

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding = ActivityMainBinding.bind(view)

launchFragmentResult.hide()
binding!!.launchFragmentResult.hide()

//images
singleImageBottomSheetPick.setOnClickListener(this)
imageBottomSheetMultiPick.setOnClickListener(this)
binding!!.singleImageBottomSheetPick.setOnClickListener(this)
binding!!.imageBottomSheetMultiPick.setOnClickListener(this)

//videos
singleVideoBottomSheetPick.setOnClickListener(this)
videoBottomSheetMultiPick.setOnClickListener(this)
binding!!.singleVideoBottomSheetPick.setOnClickListener(this)
binding!!.videoBottomSheetMultiPick.setOnClickListener(this)

//audios
singleAudioBottomSheetPick.setOnClickListener(this)
audioBottomSheetMultiPick.setOnClickListener(this)
binding!!.singleAudioBottomSheetPick.setOnClickListener(this)
binding!!.audioBottomSheetMultiPick.setOnClickListener(this)


//listeners images
Expand Down
29 changes: 16 additions & 13 deletions app/src/main/java/com/crazylegend/mediapicker/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@ import com.crazylegend.core.modifiers.base.BaseMultiPickerModifier
import com.crazylegend.imagepicker.images.ImageModel
import com.crazylegend.imagepicker.pickers.MultiImagePicker
import com.crazylegend.imagepicker.pickers.SingleImagePicker
import com.crazylegend.mediapicker.databinding.ActivityMainBinding
import com.crazylegend.videopicker.pickers.MultiVideoPicker
import com.crazylegend.videopicker.pickers.SingleVideoPicker
import com.crazylegend.videopicker.videos.VideoModel
import kotlinx.android.synthetic.main.activity_main.*

@SuppressLint("MissingPermission")
class MainActivity : AppCompatActivity(), View.OnClickListener {

private lateinit var binding: ActivityMainBinding

private var clickedID = R.id.singleImageBottomSheetPick

private val askForStoragePermission =
Expand Down Expand Up @@ -138,8 +140,8 @@ class MainActivity : AppCompatActivity(), View.OnClickListener {
Glide.with(this)
.load(audioModel.loadThumbnail(contentResolver))
.error(R.drawable.ic_album)
.into(audio)
audioTitle.text = audioModel.displayName
.into(binding.audio)
binding.audioTitle.text = audioModel.displayName
Log.d("AUDIO_PICKED ${audioModel.thumbnail?.isRecycled}", audioModel.toString())
}

Expand Down Expand Up @@ -207,7 +209,7 @@ class MainActivity : AppCompatActivity(), View.OnClickListener {
private fun loadVideo(videoModel: VideoModel) {
Glide.with(this)
.load(videoModel.contentUri)
.into(video)
.into(binding.video)
Log.d("VIDEO_PICKED", videoModel.toString())
}

Expand Down Expand Up @@ -280,7 +282,7 @@ class MainActivity : AppCompatActivity(), View.OnClickListener {
private fun loadImage(imageModel: ImageModel) {
Glide.with(this)
.load(imageModel.contentUri)
.into(image)
.into(binding.image)
Log.d("IMAGE_PICKED", imageModel.toString())
}

Expand All @@ -292,22 +294,23 @@ class MainActivity : AppCompatActivity(), View.OnClickListener {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)

//images
singleImageBottomSheetPick.setOnClickListener(this)
imageBottomSheetMultiPick.setOnClickListener(this)
binding.singleImageBottomSheetPick.setOnClickListener(this)
binding.imageBottomSheetMultiPick.setOnClickListener(this)

//videos
singleVideoBottomSheetPick.setOnClickListener(this)
videoBottomSheetMultiPick.setOnClickListener(this)
binding.singleVideoBottomSheetPick.setOnClickListener(this)
binding.videoBottomSheetMultiPick.setOnClickListener(this)

//audios
singleAudioBottomSheetPick.setOnClickListener(this)
audioBottomSheetMultiPick.setOnClickListener(this)
binding.singleAudioBottomSheetPick.setOnClickListener(this)
binding.audioBottomSheetMultiPick.setOnClickListener(this)

//fragment result
launchFragmentResult.setOnClickListener(this)
binding.launchFragmentResult.setOnClickListener(this)
}

override fun onRestoreInstanceState(savedInstanceState: Bundle) {
Expand Down
53 changes: 0 additions & 53 deletions audiopicker/build.gradle
Original file line number Diff line number Diff line change
@@ -1,53 +0,0 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion compiledAppVersion
defaultConfig {
minSdkVersion 21
targetSdkVersion compiledAppVersion
versionCode 1
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-rules.pro'
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}

compileOptions {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}

kotlinOptions {
jvmTarget = "1.8"
}


viewBinding {
enabled = true
}

androidExtensions {
experimental = true
}


kapt {
correctErrorTypes = true
useBuildCache = true
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(path: ':core')
implementation project(path: ':extensions')
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,8 @@ import com.crazylegend.audiopicker.audios.AudioModel
/**
* Created by crazy on 5/12/20 to long live and prosper !
*/
internal interface onAudioPicked {
internal fun interface onAudioPicked {
fun forAudio(audio: AudioModel)
}

internal inline fun onAudioDSL(crossinline callback: (audioModel: AudioModel) -> Unit = {}) = object : onAudioPicked {
override fun forAudio(audio: AudioModel) {
callback(audio)
}
}
internal inline fun onAudioDSL(crossinline callback: (audioModel: AudioModel) -> Unit = {}) = onAudioPicked { audio -> callback(audio) }
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,8 @@ import com.crazylegend.audiopicker.audios.AudioModel
/**
* Created by crazy on 5/12/20 to long live and prosper !
*/
internal interface onAudiosPicked {
internal fun interface onAudiosPicked {
fun forAudios(audioList: List<AudioModel>)
}

internal inline fun onAudiosDSL(crossinline callback: (audioList: List<AudioModel>) -> Unit = {}) = object : onAudiosPicked {
override fun forAudios(audioList: List<AudioModel>) {
callback(audioList)
}
}
internal inline fun onAudiosDSL(crossinline callback: (audioList: List<AudioModel>) -> Unit = {}) = onAudiosPicked { audioList -> callback(audioList) }
Loading

0 comments on commit 3150c54

Please sign in to comment.