Skip to content

Commit

Permalink
Addded Sample
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-manshu committed Feb 27, 2019
2 parents f3ff60c + d084c28 commit 8cfc99c
Show file tree
Hide file tree
Showing 20 changed files with 76 additions and 32 deletions.
Binary file added .gradle/4.10.1/fileContent/fileContent.lock
Binary file not shown.
Binary file modified .gradle/4.10.1/fileHashes/fileHashes.bin
Binary file not shown.
Binary file modified .gradle/4.10.1/fileHashes/fileHashes.lock
Binary file not shown.
Binary file added .gradle/4.10.1/fileHashes/resourceHashesCache.bin
Binary file not shown.
Binary file added .gradle/4.10.1/javaCompile/classAnalysis.bin
Binary file not shown.
Binary file added .gradle/4.10.1/javaCompile/jarAnalysis.bin
Binary file not shown.
Binary file added .gradle/4.10.1/javaCompile/javaCompile.lock
Binary file not shown.
Binary file added .gradle/4.10.1/javaCompile/taskHistory.bin
Binary file not shown.
Binary file modified .gradle/4.10.1/taskHistory/taskHistory.bin
Binary file not shown.
Binary file modified .gradle/4.10.1/taskHistory/taskHistory.lock
Binary file not shown.
Binary file modified .gradle/buildOutputCleanup/buildOutputCleanup.lock
Binary file not shown.
Binary file modified .gradle/buildOutputCleanup/outputFiles.bin
Binary file not shown.
2 changes: 1 addition & 1 deletion app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<compilerSettings />
<compilerArguments>
<option name="destination" value="$MODULE_DIR$/build/tmp/kotlin-classes/debug" />
<option name="classpath" value="$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.3.21/d207ce2c9bcf17dc8e51bab4dbfdac4d013e7138/kotlin-stdlib-jdk7-1.3.21.jar:/Users/himanshusingh/.gradle/caches/transforms-1/files-1.1/appcompat-v7-28.0.0.aar/8a8d7200bad9af68773d12bf7b8b53a6/jars/classes.jar:/Users/himanshusingh/.gradle/caches/transforms-1/files-1.1/constraint-layout-1.1.3.aar/837647ec22ae5d1f37a0a039f67f2cc3/jars/classes.jar:/Users/himanshusingh/Documents/v/viewcolorgenerator/build/intermediates/intermediate-jars/debug/classes.jar:/Users/himanshusingh/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.3.21/4bcc2012b84840e19e1e28074284cac908be0295/kotlin-stdlib-1.3.21.jar:/Users/himanshusingh/.gradle/caches/transforms-1/files-1.1/support-fragment-28.0.0.aar/e6bd61706c256b55294f4e9d90d83988/jars/classes.jar:/Users/himanshusingh/.gradle/caches/transforms-1/files-1.1/animated-vector-drawable-28.0.0.aar/256a545d6b87f61291e19d5e43520baf/jars/classes.jar:/Users/himanshusingh/.gradle/caches/transforms-1/files-1.1/support-core-ui-28.0.0.aar/5c7837baf4a2f7f6d66421cd747efaca/jars/classes.jar:/Users/himanshusingh/.gradle/caches/transforms-1/files-1.1/support-core-utils-28.0.0.aar/eee06291ab027360e48f8009f28b6e89/jars/classes.jar:/Users/himanshusingh/.gradle/caches/transforms-1/files-1.1/support-vector-drawable-28.0.0.aar/d2d0e10361bfd2611f5a2a2a07b8e211/jars/classes.jar:/Users/himanshusingh/.gradle/caches/transforms-1/files-1.1/loader-28.0.0.aar/19e688d07c01c34f8e9955a7652746c0/jars/classes.jar:/Users/himanshusingh/.gradle/caches/transforms-1/files-1.1/viewpager-28.0.0.aar/bd508507fc9f04745ad475b711bd549f/jars/classes.jar:/Users/himanshusingh/.gradle/caches/transforms-1/files-1.1/coordinatorlayout-28.0.0.aar/b48d88ea3da09e20aed15d5261516ded/jars/classes.jar:/Users/himanshusingh/.gradle/caches/transforms-1/files-1.1/drawerlayout-28.0.0.aar/88159c181ee4e566fcef7a254bb31d48/jars/classes.jar:/Users/himanshusingh/.gradle/caches/transforms-1/files-1.1/slidingpanelayout-28.0.0.aar/5fa2bb1e59218179ca836acf333197ac/jars/classes.jar:/Users/himanshusingh/.gradle/caches/transforms-1/files-1.1/customview-28.0.0.aar/bb2517aad2da23e2de58993dde7eea4d/jars/classes.jar:/Users/himanshusingh/.gradle/caches/transforms-1/files-1.1/swiperefreshlayout-28.0.0.aar/82254a15fade5bf5505a047521423832/jars/classes.jar:/Users/himanshusingh/.gradle/caches/transforms-1/files-1.1/asynclayoutinflater-28.0.0.aar/aa2e8d5907602a9724a4f62a03e85450/jars/classes.jar:/Users/himanshusingh/.gradle/caches/transforms-1/files-1.1/support-compat-28.0.0.aar/44482178196d16c8e34f78cf592b1af5/jars/classes.jar:/Users/himanshusingh/.gradle/caches/transforms-1/files-1.1/versionedparcelable-28.0.0.aar/92f767926f4352ac4ba0b335939d9ac4/jars/classes.jar:/Users/himanshusingh/.gradle/caches/modules-2/files-2.1/com.android.support/collections/28.0.0/c1bcdade4d3cc2836130424a3f3e4182c666a745/collections-28.0.0.jar:/Users/himanshusingh/.gradle/caches/transforms-1/files-1.1/cursoradapter-28.0.0.aar/b1196f686b51a9e3a2990d2cf4252b62/jars/classes.jar:/Users/himanshusingh/.gradle/caches/transforms-1/files-1.1/runtime-1.1.1.aar/9ad4b58bfdbaf809f1300f86020b54e3/jars/classes.jar:/Users/himanshusingh/.gradle/caches/transforms-1/files-1.1/documentfile-28.0.0.aar/a90e2145ebe0ae92bdfdf5c90c90efee/jars/classes.jar:/Users/himanshusingh/.gradle/caches/transforms-1/files-1.1/localbroadcastmanager-28.0.0.aar/19c9781b5bb33d80ebf205bcbdc9e26c/jars/classes.jar:/Users/himanshusingh/.gradle/caches/transforms-1/files-1.1/print-28.0.0.aar/6fec40295aaddc852b4c4d4202f0e8e1/jars/classes.jar:/Users/himanshusingh/.gradle/caches/transforms-1/files-1.1/viewmodel-1.1.1.aar/626477116b28479494ce4dce598ba9e5/jars/classes.jar:/Users/himanshusingh/.gradle/caches/transforms-1/files-1.1/livedata-1.1.1.aar/a6e6f8d8acffd752ac6f6d149a7c08d2/jars/classes.jar:/Users/himanshusingh/.gradle/caches/transforms-1/files-1.1/livedata-core-1.1.1.aar/aeead4520d2d43127e8c1fa3db4515e9/jars/classes.jar:/Users/himanshusingh/.gradle/caches/modules-2/files-2.1/android.arch.lifecycle/common/1.1.1/207a6efae6a3555e326de41f76bdadd9a239cbce/common-1.1.1.jar:/Users/himanshusingh/.gradle/caches/transforms-1/files-1.1/runtime-1.1.1.aar/6bf3549272e365ced527c33fd0fe118c/jars/classes.jar:/Users/himanshusingh/.gradle/caches/modules-2/files-2.1/android.arch.core/common/1.1.1/e55b70d1f5620db124b3e85a7f4bdc7bd48d9f95/common-1.1.1.jar:/Users/himanshusingh/.gradle/caches/transforms-1/files-1.1/interpolator-28.0.0.aar/b125179b1eca0a53efbd72d0178e17c5/jars/classes.jar:/Users/himanshusingh/.gradle/caches/modules-2/files-2.1/com.android.support/support-annotations/28.0.0/ed73f5337a002d1fd24339d5fb08c2c9d9ca60d8/support-annotations-28.0.0.jar:/Users/himanshusingh/.gradle/caches/modules-2/files-2.1/com.android.support.constraint/constraint-layout-solver/1.1.3/bde0667d7414c16ed62d3cfe993cff7f9d732373/constraint-layout-solver-1.1.3.jar:/Users/himanshusingh/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.3.21/f30e4a9897913e53d778f564110bafa1fef46643/kotlin-stdlib-common-1.3.21.jar:/Users/himanshusingh/.gradle/caches/modules-2/files-2.1/org.jetbrains/annotations/13.0/919f0dfe192fb4e063e7dacadee7f8bb9a2672a9/annotations-13.0.jar:/Users/himanshusingh/Library/Android/sdk/platforms/android-28/android.jar" />
<option name="classpath" value="$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.3.21/d207ce2c9bcf17dc8e51bab4dbfdac4d013e7138/kotlin-stdlib-jdk7-1.3.21.jar:/Users/himanshusingh/.gradle/caches/transforms-1/files-1.1/appcompat-v7-28.0.0.aar/8a8d7200bad9af68773d12bf7b8b53a6/jars/classes.jar:/Users/himanshusingh/.gradle/caches/transforms-1/files-1.1/constraint-layout-1.1.3.aar/837647ec22ae5d1f37a0a039f67f2cc3/jars/classes.jar:/Users/himanshusingh/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.3.21/4bcc2012b84840e19e1e28074284cac908be0295/kotlin-stdlib-1.3.21.jar:/Users/himanshusingh/.gradle/caches/transforms-1/files-1.1/support-fragment-28.0.0.aar/e6bd61706c256b55294f4e9d90d83988/jars/classes.jar:/Users/himanshusingh/.gradle/caches/transforms-1/files-1.1/animated-vector-drawable-28.0.0.aar/256a545d6b87f61291e19d5e43520baf/jars/classes.jar:/Users/himanshusingh/.gradle/caches/transforms-1/files-1.1/support-core-ui-28.0.0.aar/5c7837baf4a2f7f6d66421cd747efaca/jars/classes.jar:/Users/himanshusingh/.gradle/caches/transforms-1/files-1.1/support-core-utils-28.0.0.aar/eee06291ab027360e48f8009f28b6e89/jars/classes.jar:/Users/himanshusingh/.gradle/caches/transforms-1/files-1.1/support-vector-drawable-28.0.0.aar/d2d0e10361bfd2611f5a2a2a07b8e211/jars/classes.jar:/Users/himanshusingh/.gradle/caches/transforms-1/files-1.1/loader-28.0.0.aar/19e688d07c01c34f8e9955a7652746c0/jars/classes.jar:/Users/himanshusingh/.gradle/caches/transforms-1/files-1.1/viewpager-28.0.0.aar/bd508507fc9f04745ad475b711bd549f/jars/classes.jar:/Users/himanshusingh/.gradle/caches/transforms-1/files-1.1/coordinatorlayout-28.0.0.aar/b48d88ea3da09e20aed15d5261516ded/jars/classes.jar:/Users/himanshusingh/.gradle/caches/transforms-1/files-1.1/drawerlayout-28.0.0.aar/88159c181ee4e566fcef7a254bb31d48/jars/classes.jar:/Users/himanshusingh/.gradle/caches/transforms-1/files-1.1/slidingpanelayout-28.0.0.aar/5fa2bb1e59218179ca836acf333197ac/jars/classes.jar:/Users/himanshusingh/.gradle/caches/transforms-1/files-1.1/customview-28.0.0.aar/bb2517aad2da23e2de58993dde7eea4d/jars/classes.jar:/Users/himanshusingh/.gradle/caches/transforms-1/files-1.1/swiperefreshlayout-28.0.0.aar/82254a15fade5bf5505a047521423832/jars/classes.jar:/Users/himanshusingh/.gradle/caches/transforms-1/files-1.1/asynclayoutinflater-28.0.0.aar/aa2e8d5907602a9724a4f62a03e85450/jars/classes.jar:/Users/himanshusingh/.gradle/caches/transforms-1/files-1.1/support-compat-28.0.0.aar/44482178196d16c8e34f78cf592b1af5/jars/classes.jar:/Users/himanshusingh/.gradle/caches/transforms-1/files-1.1/versionedparcelable-28.0.0.aar/92f767926f4352ac4ba0b335939d9ac4/jars/classes.jar:/Users/himanshusingh/.gradle/caches/modules-2/files-2.1/com.android.support/collections/28.0.0/c1bcdade4d3cc2836130424a3f3e4182c666a745/collections-28.0.0.jar:/Users/himanshusingh/.gradle/caches/transforms-1/files-1.1/cursoradapter-28.0.0.aar/b1196f686b51a9e3a2990d2cf4252b62/jars/classes.jar:/Users/himanshusingh/.gradle/caches/transforms-1/files-1.1/runtime-1.1.1.aar/9ad4b58bfdbaf809f1300f86020b54e3/jars/classes.jar:/Users/himanshusingh/.gradle/caches/transforms-1/files-1.1/documentfile-28.0.0.aar/a90e2145ebe0ae92bdfdf5c90c90efee/jars/classes.jar:/Users/himanshusingh/.gradle/caches/transforms-1/files-1.1/localbroadcastmanager-28.0.0.aar/19c9781b5bb33d80ebf205bcbdc9e26c/jars/classes.jar:/Users/himanshusingh/.gradle/caches/transforms-1/files-1.1/print-28.0.0.aar/6fec40295aaddc852b4c4d4202f0e8e1/jars/classes.jar:/Users/himanshusingh/.gradle/caches/transforms-1/files-1.1/viewmodel-1.1.1.aar/626477116b28479494ce4dce598ba9e5/jars/classes.jar:/Users/himanshusingh/.gradle/caches/transforms-1/files-1.1/livedata-1.1.1.aar/a6e6f8d8acffd752ac6f6d149a7c08d2/jars/classes.jar:/Users/himanshusingh/.gradle/caches/transforms-1/files-1.1/livedata-core-1.1.1.aar/aeead4520d2d43127e8c1fa3db4515e9/jars/classes.jar:/Users/himanshusingh/.gradle/caches/modules-2/files-2.1/android.arch.lifecycle/common/1.1.1/207a6efae6a3555e326de41f76bdadd9a239cbce/common-1.1.1.jar:/Users/himanshusingh/.gradle/caches/transforms-1/files-1.1/runtime-1.1.1.aar/6bf3549272e365ced527c33fd0fe118c/jars/classes.jar:/Users/himanshusingh/.gradle/caches/modules-2/files-2.1/android.arch.core/common/1.1.1/e55b70d1f5620db124b3e85a7f4bdc7bd48d9f95/common-1.1.1.jar:/Users/himanshusingh/.gradle/caches/transforms-1/files-1.1/interpolator-28.0.0.aar/b125179b1eca0a53efbd72d0178e17c5/jars/classes.jar:/Users/himanshusingh/.gradle/caches/modules-2/files-2.1/com.android.support/support-annotations/28.0.0/ed73f5337a002d1fd24339d5fb08c2c9d9ca60d8/support-annotations-28.0.0.jar:/Users/himanshusingh/.gradle/caches/modules-2/files-2.1/com.android.support.constraint/constraint-layout-solver/1.1.3/bde0667d7414c16ed62d3cfe993cff7f9d732373/constraint-layout-solver-1.1.3.jar:/Users/himanshusingh/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.3.21/f30e4a9897913e53d778f564110bafa1fef46643/kotlin-stdlib-common-1.3.21.jar:/Users/himanshusingh/.gradle/caches/modules-2/files-2.1/org.jetbrains/annotations/13.0/919f0dfe192fb4e063e7dacadee7f8bb9a2672a9/annotations-13.0.jar:/Users/himanshusingh/Library/Android/sdk/platforms/android-28/android.jar" />
<option name="noStdlib" value="true" />
<option name="noReflect" value="true" />
<option name="moduleName" value="app_debug" />
Expand Down
23 changes: 15 additions & 8 deletions app/src/main/java/com/mindorks/sample/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
package com.mindorks.sample

import android.graphics.Bitmap
import android.graphics.Color
import android.graphics.drawable.Drawable
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.util.Log
import com.mindorks.ViewColorGenerator
import com.mindorks.`interface`.*
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : AppCompatActivity() {

val url = "https://bit.ly/2Eem9EV"
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val viewcolor = ViewColorGenerator()
viewcolor.load(resources.getDrawable(R.drawable.ic_search), object : OnImageLoaded {


viewcolor.load(url, object : OnImageLoaded {
override fun onImageLoaded(
vibrantColor: String,
vibrantLightColor: String,
Expand All @@ -27,7 +32,9 @@ class MainActivity : AppCompatActivity() {
}

})
viewcolor.load(resources.getDrawable(R.drawable.ic_search), object : OnVibrantDarkColorGenerated {


viewcolor.load(url, object : OnVibrantDarkColorGenerated {
override fun onVibrantDarkColorGenerated(titleTextColor: String, bodyColor: String) {
background.setBackgroundColor(Color.parseColor(bodyColor))
backgroundText.setTextColor(Color.parseColor(titleTextColor))
Expand All @@ -36,31 +43,31 @@ class MainActivity : AppCompatActivity() {
}
})

viewcolor.load((resources.getDrawable(R.drawable.ic_search)), object : OnVibrantColorGenerated {
viewcolor.load((url), object : OnVibrantColorGenerated {
override fun onVibrantColorGenerated(titleTextColor: String, bodyColor: String) {
backgroundTwo.setBackgroundColor(Color.parseColor(bodyColor))
backgroundTextTwo.setTextColor(Color.parseColor(titleTextColor))
}
})
viewcolor.load((resources.getDrawable(R.drawable.ic_search)), object : OnMutedDarkColorGenerated {
viewcolor.load((url), object : OnMutedDarkColorGenerated {
override fun onMutedDarkColorGenerated(titleTextColor: String, bodyColor: String) {
backgroundThree.setBackgroundColor(Color.parseColor(bodyColor))
backgroundTextThree.setTextColor(Color.parseColor(titleTextColor))
}
})
viewcolor.load((resources.getDrawable(R.drawable.ic_search)), object : OnMutedLightColorGenerated {
viewcolor.load((url), object : OnMutedLightColorGenerated {
override fun onMutedLightColorGenerated(titleTextColor: String, bodyColor: String) {
backgroundFour.setBackgroundColor(Color.parseColor(bodyColor))
backgroundTextFour.setTextColor(Color.parseColor(titleTextColor))
}
})
viewcolor.load((resources.getDrawable(R.drawable.ic_search)), object : OnVibrantLightColorGenerated {
viewcolor.load((url), object : OnVibrantLightColorGenerated {
override fun onVibrantLightColorGenerated(titleTextColor: String, bodyColor: String) {
backgroundFive.setBackgroundColor(Color.parseColor(bodyColor))
backgroundTextFive.setTextColor(Color.parseColor(titleTextColor))
}
})
viewcolor.load((resources.getDrawable(R.drawable.ic_search)), object : OnMutedColorGenerated {
viewcolor.load((url), object : OnMutedColorGenerated {
override fun onMutedColorGenerated(titleTextColor: String, bodyColor: String) {
backgroundSix.setBackgroundColor(Color.parseColor(bodyColor))
backgroundTextSix.setTextColor(Color.parseColor(titleTextColor))
Expand Down
Binary file added images/image_mock.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions viewcolorgenerator/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ dependencies {
implementation 'com.android.support:palette-v7:28.0.0'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "com.squareup.picasso:picasso:2.71828"


}
repositories {
mavenCentral()
Expand Down
1 change: 1 addition & 0 deletions viewcolorgenerator/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mindorks"

/>
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ import android.graphics.drawable.Drawable
import android.view.View
import com.mindorks.util.Util
import android.support.v7.graphics.Palette
import android.util.Log
import com.mindorks.`interface`.*
import com.mindorks.util.Util.colorToHex
import com.squareup.picasso.Picasso


/**
* @author Himanshu Singh
Expand All @@ -25,6 +28,10 @@ class ViewColorGenerator {
private var dominantColor = 0
private val defaultValue = 0x000000

init {

}

/**
* @param srcType is the type of ViewPassed
* @param interfaceType is the interface which has to be used for color listeners
Expand All @@ -34,12 +41,14 @@ class ViewColorGenerator {
when (srcType) {
is View -> loadImagePalette(Util.loadViewToBitmap(srcType), interfaceType)
is Drawable -> loadImagePalette(Util.drawableToBitmap(srcType), interfaceType)
else -> throw IllegalArgumentException("The src type should be either be View / Drawable / Url")

is String -> getBitmap(srcType, interfaceType)
else -> throw Exception("The src type should be either be View / Drawable / Url")
}


}


/**
* @param image is the bitmap of the view/drawable
* @param interfaceType is the interface which has to be used for color listeners
Expand Down Expand Up @@ -133,12 +142,24 @@ class ViewColorGenerator {
colorToHex(colorRgb)
)
}
else -> throw IllegalArgumentException("The Interface type not available")
else -> throw Exception("The Interface type not available")
}
}

}

private fun getBitmap(url: String, interfaceType: Any) {
Picasso.get().load(url).into(object : com.squareup.picasso.Target {
override fun onBitmapLoaded(bitmap: Bitmap, from: Picasso.LoadedFrom?) {
loadImagePalette(bitmap, interfaceType)
}

override fun onPrepareLoad(placeHolderDrawable: Drawable?) {}

override fun onBitmapFailed(e: Exception?, errorDrawable: Drawable?) {}
})
}


}

8 changes: 8 additions & 0 deletions viewcolorgenerator/src/main/java/com/mindorks/util/Util.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
package com.mindorks.util

import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.graphics.Canvas
import android.view.View
import android.graphics.drawable.BitmapDrawable
import android.graphics.drawable.Drawable
import android.os.AsyncTask
import java.io.IOException
import java.io.InputStream
import java.net.HttpURLConnection
import java.net.MalformedURLException
import java.net.URL


object Util {
Expand Down Expand Up @@ -68,4 +75,5 @@ object Util {
val hex = "00" + Integer.toHexString(value)
return hex.substring(hex.length - 2, hex.length)
}

}
Loading

0 comments on commit 8cfc99c

Please sign in to comment.