diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
index ce889bd..a88ded0 100644
--- a/.idea/codeStyles/Project.xml
+++ b/.idea/codeStyles/Project.xml
@@ -1,5 +1,8 @@
+
+
+
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
index 07396e1..5b28096 100644
--- a/.idea/gradle.xml
+++ b/.idea/gradle.xml
@@ -11,6 +11,7 @@
+
@@ -19,6 +20,7 @@
+
diff --git a/app/build.gradle b/app/build.gradle
index 0316195..fb4ee2f 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -46,7 +46,7 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "androidx.appcompat:appcompat:${appcompact_version}"
- implementation 'androidx.appcompat:appcompat:1.0.2'
+ implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation "junit:junit:${junit_version}"
implementation "androidx.constraintlayout:constraintlayout:${constraintlayout_version}"
@@ -56,12 +56,6 @@ dependencies {
implementation 'com.android.support:multidex:1.0.3'
-// implementation "com.github.SunnyQjm.quickandroid:quick_android_base:${quick_android_version}"
-// implementation "com.github.SunnyQjm.quickandroid:quick_android_mvp:${quick_android_version}"
-// implementation "com.github.SunnyQjm.quickandroid:quick_android_qrcode:${quick_android_version}"
-// implementation "com.github.SunnyQjm.quickandroid:quick_android_image_picker:${quick_android_version}"
-// implementation "com.github.SunnyQjm.quickandroid:quick_android_rx_permission:${quick_android_version}"
-
implementation project(path: ':quick_android_base')
implementation project(path: ':quick_android_mvp')
implementation project(path: ':quick_android_qrcode')
@@ -69,4 +63,5 @@ dependencies {
implementation project(path: ':quick_android_rx_permission')
implementation project(path: ':quick_android_webview')
implementation project(path: ':quick_android_custom_view')
+ implementation project(path: ':quick_android_easy_bar')
}
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 31bb357..5c53fef 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -1,9 +1,12 @@
+ xmlns:tools="http://schemas.android.com/tools"
+ package="cn.qjm253.quick_android">
+
+
+
+
-
-
-
-
-
-
-
+ android:theme="@style/Theme.AppCompat.Light.NoActionBar"
+ tools:replace="android:label"
+ android:requestLegacyExternalStorage="true"
+ >
+
+
+
-
+
-
+
diff --git a/app/src/main/java/cn/qjm253/quick_android/MainActivity.kt b/app/src/main/java/cn/qjm253/quick_android/MainActivity.kt
index 1b007dd..2acebaa 100644
--- a/app/src/main/java/cn/qjm253/quick_android/MainActivity.kt
+++ b/app/src/main/java/cn/qjm253/quick_android/MainActivity.kt
@@ -9,13 +9,14 @@ import cn.qjm253.quick_android_base.base.activity.BaseQuickAndroidActivity
import cn.qjm253.quick_android_base.extensions.*
import cn.qjm253.quick_android_base.util.ContentUriUtil
import cn.qjm253.quick_android_base.util.RxSchedulersHelper
+import cn.qjm253.quick_android_easy_bar.EasyBar
+import cn.qjm253.quick_android_easy_bar.init
import cn.qjm253.quick_android_image_picker.openWechatStyleGallery
import cn.qjm253.quick_android_image_picker.startClipImage
import cn.qjm253.quick_android_qrcode.scanCode
import cn.qjm253.quick_android_rx_permission.QuickAndroidRxPermission
import com.qingmei2.rximagepicker_extension.MimeType
import com.qingmei2.rximagepicker_extension_wechat.WechatConfigrationBuilder
-import com.qingmei2.rximagepicker_extension_zhihu.ZhihuConfigurationBuilder
import kotlinx.android.synthetic.main.activity_main.*
class MainActivity : BaseQuickAndroidActivity() {
@@ -25,6 +26,12 @@ class MainActivity : BaseQuickAndroidActivity() {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
+ easyBar.init(
+ mode = EasyBar.Mode.NONE,
+ title = "QuickAndroid"
+ )
+
+
mvpDemoBtn.setOnClickListener {
jumpTo(MVPDemoActivity::class.java)
}
@@ -46,7 +53,6 @@ class MainActivity : BaseQuickAndroidActivity() {
}, {
"complete".i()
})
-// easyRequestPermissions(arrayOf(Manifest.permission.CAMERA), R.string.camera_permission_require, 2)
}
btnWechatStyleImagePicker.setOnClickListener {
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index 461c2b6..46bff7d 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -1,48 +1,81 @@
-
+
+
+
+ android:layout_marginStart="8dp"
+ android:layout_marginTop="8dp"
+ android:layout_marginEnd="8dp"
+ android:text="MVPDemo"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="parent"
+ />
+
+ android:layout_marginStart="8dp"
+ android:layout_marginTop="8dp"
+ android:layout_marginEnd="8dp"
+ android:text="scan_qr_code"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/mvpDemoBtn" />
+
+ android:layout_marginStart="8dp"
+ android:layout_marginTop="8dp"
+ android:layout_marginEnd="8dp"
+ android:text="Wechat Style Image Picker"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/btnScanQrCode" />
+
+ android:layout_marginStart="8dp"
+ android:layout_marginTop="8dp"
+ android:layout_marginEnd="8dp"
+ android:text="Webview Demo"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/btnWechatStyleImagePicker" />
+
-
\ No newline at end of file
+ android:layout_marginStart="8dp"
+ android:layout_marginTop="8dp"
+ android:layout_marginEnd="8dp"
+ android:text="Custom view demo"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/btnWebviewDemo" />
+
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
index 07398fa..5e77700 100644
--- a/build.gradle
+++ b/build.gradle
@@ -26,7 +26,7 @@ buildscript {
ext.junit_version = '4.12'
ext.test_runner_version = '1.2.0'
ext.espresso_core_version = '3.2.0'
- ext.core_ktx_version = '1.0.2'
+ ext.core_ktx_version = '1.1.0'
ext.compile_sdk_version = 29
ext.target_sdk_version = 29
@@ -34,8 +34,8 @@ buildscript {
repositories {
google()
- jcenter(){url 'http://jcenter.bintray.com/'}
-
+ jcenter() { url 'http://jcenter.bintray.com/' }
+
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.2'
@@ -48,9 +48,9 @@ buildscript {
allprojects {
repositories {
google()
- jcenter(){url 'http://jcenter.bintray.com/'}
+ jcenter() { url 'http://jcenter.bintray.com/' }
maven { url "https://jitpack.io" }
-
+
}
}
diff --git a/quick_android_easy_bar/.gitignore b/quick_android_easy_bar/.gitignore
new file mode 100644
index 0000000..796b96d
--- /dev/null
+++ b/quick_android_easy_bar/.gitignore
@@ -0,0 +1 @@
+/build
diff --git a/quick_android_easy_bar/build.gradle b/quick_android_easy_bar/build.gradle
new file mode 100644
index 0000000..f8453c4
--- /dev/null
+++ b/quick_android_easy_bar/build.gradle
@@ -0,0 +1,36 @@
+apply plugin: 'com.android.library'
+apply plugin: 'kotlin-android'
+apply plugin: 'kotlin-android-extensions'
+android {
+ compileSdkVersion compile_sdk_version
+
+ defaultConfig {
+ minSdkVersion min_sdk_version
+ targetSdkVersion target_sdk_version
+ 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'
+ }
+ }
+
+}
+
+dependencies {
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
+ implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
+ implementation 'androidx.appcompat:appcompat:1.1.0'
+ implementation 'androidx.core:core-ktx:1.1.0'
+ testImplementation 'junit:junit:4.12'
+
+ implementation project(path: ':quick_android_base')
+ androidTestImplementation 'androidx.test.ext:junit:1.1.1'
+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
+}
diff --git a/quick_android_easy_bar/consumer-rules.pro b/quick_android_easy_bar/consumer-rules.pro
new file mode 100644
index 0000000..e69de29
diff --git a/quick_android_easy_bar/proguard-rules.pro b/quick_android_easy_bar/proguard-rules.pro
new file mode 100644
index 0000000..f1b4245
--- /dev/null
+++ b/quick_android_easy_bar/proguard-rules.pro
@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile
diff --git a/quick_android_easy_bar/src/androidTest/java/cn/qjm253/quick_android_easy_bar/ExampleInstrumentedTest.kt b/quick_android_easy_bar/src/androidTest/java/cn/qjm253/quick_android_easy_bar/ExampleInstrumentedTest.kt
new file mode 100644
index 0000000..e54a232
--- /dev/null
+++ b/quick_android_easy_bar/src/androidTest/java/cn/qjm253/quick_android_easy_bar/ExampleInstrumentedTest.kt
@@ -0,0 +1,24 @@
+package cn.qjm253.quick_android_easy_bar
+
+import androidx.test.platform.app.InstrumentationRegistry
+import androidx.test.ext.junit.runners.AndroidJUnit4
+
+import org.junit.Test
+import org.junit.runner.RunWith
+
+import org.junit.Assert.*
+
+/**
+ * Instrumented test, which will execute on an Android device.
+ *
+ * See [testing documentation](http://d.android.com/tools/testing).
+ */
+@RunWith(AndroidJUnit4::class)
+class ExampleInstrumentedTest {
+ @Test
+ fun useAppContext() {
+ // Context of the app under test.
+ val appContext = InstrumentationRegistry.getInstrumentation().targetContext
+ assertEquals("cn.qjm253.quick_android_easy_bar.test", appContext.packageName)
+ }
+}
diff --git a/quick_android_easy_bar/src/main/AndroidManifest.xml b/quick_android_easy_bar/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..6a731b4
--- /dev/null
+++ b/quick_android_easy_bar/src/main/AndroidManifest.xml
@@ -0,0 +1,2 @@
+
diff --git a/quick_android_easy_bar/src/main/java/cn/qjm253/quick_android_easy_bar/EasyBar.kt b/quick_android_easy_bar/src/main/java/cn/qjm253/quick_android_easy_bar/EasyBar.kt
new file mode 100644
index 0000000..8e0b38f
--- /dev/null
+++ b/quick_android_easy_bar/src/main/java/cn/qjm253/quick_android_easy_bar/EasyBar.kt
@@ -0,0 +1,350 @@
+package cn.qjm253.quick_android_easy_bar
+
+import android.annotation.SuppressLint
+import android.content.Context
+import android.graphics.Bitmap
+import android.graphics.drawable.Drawable
+import android.os.Build
+import android.text.TextUtils
+import android.util.AttributeSet
+import android.util.TypedValue
+import android.view.View
+import android.view.ViewGroup
+import android.widget.ImageView
+import android.widget.RelativeLayout
+import android.widget.TextView
+import androidx.annotation.ColorInt
+import androidx.annotation.Dimension
+import androidx.annotation.DrawableRes
+import androidx.annotation.StringRes
+import cn.qjm253.quick_android_base.util.DisplayUtils
+
+
+/**
+ * Created by Sunny on 2017/8/17 0017.
+ */
+
+class EasyBar @JvmOverloads constructor(
+ context: Context,
+ attrs: AttributeSet? = null,
+ defStyleAttr: Int = 0
+) : RelativeLayout(context, attrs, defStyleAttr) {
+ private var title: String? = null
+ @Dimension
+ private var titleSize: Int = 0
+ @ColorInt
+ private var titleColor: Int = 0
+ @DrawableRes
+ private var leftIcon: Int = 0
+ @DrawableRes
+ private var rightIcon: Int = 0
+ @Dimension
+ private var iconSize: Int = 0
+ @Dimension
+ private var iconMargin: Int = 0
+
+ private var leftText: String = ""
+ private var rightText: String = ""
+ private var displayMode: Mode = Mode.TEXT
+
+
+ private lateinit var imgLeft: ImageView
+ private lateinit var imgRight: ImageView
+ private lateinit var tvTitle: TextView
+ private lateinit var tvLeftText: TextView
+ private lateinit var tvRightText: TextView
+ private var mListener: OnEasyBarClickListener? = null
+
+ init {
+ initAttr(context, attrs)
+ initView(context)
+ }
+
+ @SuppressLint("ObsoleteSdkInt")
+ private fun initView(context: Context) {
+
+ //left icon
+ imgLeft = ImageView(context)
+ imgLeft.setImageResource(leftIcon)
+ imgLeft.scaleType = ImageView.ScaleType.FIT_CENTER
+ val imgLeftParam = RelativeLayout.LayoutParams(
+ ViewGroup.LayoutParams.WRAP_CONTENT,
+ ViewGroup.LayoutParams.WRAP_CONTENT
+ )
+ imgLeftParam.addRule(RelativeLayout.CENTER_VERTICAL)
+ imgLeftParam.addRule(RelativeLayout.ALIGN_PARENT_LEFT)
+ imgLeftParam.width = iconSize
+ imgLeftParam.height = iconSize
+ imgLeft.layoutParams = imgLeftParam
+ imgLeft.setPadding(iconMargin, iconMargin, iconMargin, iconMargin)
+ addView(imgLeft, imgLeftParam)
+
+ imgLeft.setOnClickListener { v ->
+ mListener?.onLeftIconClick(v)
+ }
+
+ //center title
+ tvTitle = TextView(context)
+ tvTitle.ellipsize = TextUtils.TruncateAt.END
+ tvTitle.setSingleLine()
+ tvTitle.text = title
+ tvTitle.textSize = titleSize.toFloat()
+ tvTitle.setTextColor(titleColor)
+ val tvTitleParam = RelativeLayout.LayoutParams(
+ ViewGroup.LayoutParams.WRAP_CONTENT,
+ ViewGroup.LayoutParams.WRAP_CONTENT
+ )
+ val titleMargin = iconSize
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
+ tvTitleParam.marginStart = titleMargin
+ tvTitleParam.marginEnd = titleMargin
+ } else {
+ tvTitleParam.leftMargin = titleMargin
+ tvTitleParam.rightMargin = titleMargin
+ }
+ tvTitleParam.addRule(RelativeLayout.CENTER_IN_PARENT)
+ tvTitle.layoutParams = tvTitleParam
+ addView(tvTitle, tvTitleParam)
+
+ //left text
+ tvLeftText = TextView(context)
+ tvLeftText.textSize = titleSize.toFloat()
+ tvLeftText.setTextColor(titleColor)
+ val tv_left_text_param = RelativeLayout.LayoutParams(
+ ViewGroup.LayoutParams.WRAP_CONTENT,
+ ViewGroup.LayoutParams.WRAP_CONTENT
+ )
+ tv_left_text_param.addRule(RelativeLayout.ALIGN_PARENT_LEFT)
+ tv_left_text_param.addRule(RelativeLayout.CENTER_VERTICAL)
+ tv_left_text_param.leftMargin = iconMargin
+ tvLeftText.layoutParams = tv_left_text_param
+ addView(tvLeftText)
+ tvLeftText.text = leftText
+ tvLeftText.visibility = View.INVISIBLE
+ tvLeftText.setOnClickListener { v ->
+ mListener?.onLeftIconClick(v)
+ }
+
+
+ //right text
+ tvRightText = TextView(context)
+ tvRightText.textSize = titleSize.toFloat()
+ tvRightText.setTextColor(titleColor)
+ val tvRightTextParam = RelativeLayout.LayoutParams(
+ ViewGroup.LayoutParams.WRAP_CONTENT,
+ ViewGroup.LayoutParams.WRAP_CONTENT
+ )
+ tvRightTextParam.addRule(RelativeLayout.ALIGN_PARENT_RIGHT)
+ tvRightTextParam.addRule(RelativeLayout.CENTER_VERTICAL)
+ tvRightTextParam.rightMargin = iconMargin
+ tvRightText.layoutParams = tvRightTextParam
+ addView(tvRightText)
+ tvRightText.text = rightText
+ tvRightText.visibility = View.INVISIBLE
+ tvRightText.setOnClickListener { v ->
+ mListener?.onRightIconClick(v)
+ }
+
+ //right icon
+ imgRight = ImageView(context)
+ imgRight.setImageResource(rightIcon)
+ imgRight.scaleType = ImageView.ScaleType.FIT_CENTER
+ val imgRightParam = RelativeLayout.LayoutParams(
+ ViewGroup.LayoutParams.WRAP_CONTENT,
+ ViewGroup.LayoutParams.WRAP_CONTENT
+ )
+ imgRightParam.addRule(RelativeLayout.CENTER_VERTICAL)
+ imgRightParam.addRule(RelativeLayout.ALIGN_PARENT_RIGHT)
+ imgRightParam.width = iconSize
+ imgRightParam.height = iconSize
+ imgRight.layoutParams = imgRightParam
+ imgRight.setPadding(iconMargin, iconMargin, iconMargin, iconMargin)
+ addView(imgRight, imgRightParam)
+
+ imgRight.visibility = View.INVISIBLE
+ imgRight.setOnClickListener { v ->
+ mListener?.onRightIconClick(v)
+ }
+
+ setDisplayMode(displayMode)
+ }
+
+ private fun initAttr(context: Context, attrs: AttributeSet?) {
+ val ta = context.obtainStyledAttributes(attrs, R.styleable.EasyBar)
+ title = ta.getString(R.styleable.EasyBar_title)
+ titleSize = DisplayUtils.px2sp(
+ context,
+ ta.getDimensionPixelSize(
+ R.styleable.EasyBar_title_size,
+ TypedValue.applyDimension(
+ TypedValue.COMPLEX_UNIT_SP,
+ 14f,
+ resources.displayMetrics
+ ).toInt()
+ ).toFloat()
+ )
+ titleColor =
+ ta.getColor(R.styleable.EasyBar_title_color, resources.getColor(R.color.text_gray))
+ leftIcon = ta.getResourceId(R.styleable.EasyBar_left_icon, R.drawable.back)
+// rightIcon = ta.getResourceId(R.styleable.EasyBar_right_icon, R.drawable.back)
+ iconSize = ta.getDimensionPixelSize(
+ R.styleable.EasyBar_icon_size,
+ DisplayUtils.dip2px(context, 24f)
+ )
+ iconMargin = ta.getDimensionPixelOffset(
+ R.styleable.EasyBar_icon_margin,
+ DisplayUtils.dip2px(context, 12f)
+ )
+ leftText = ta.getString(R.styleable.EasyBar_left_text).toString()
+ rightText = ta.getString(R.styleable.EasyBar_right_text).toString()
+ val mode = ta.getInt(R.styleable.EasyBar_displayMode, 0)
+ displayMode = when (mode) {
+ 0 -> Mode.ICON
+ 1 -> Mode.TEXT
+ else -> Mode.ICON
+ }
+ ta.recycle()
+ }
+
+ fun setTitle(title: String) {
+ this.title = title
+ tvTitle.text = title
+ }
+
+ fun setTitle(@StringRes titleRes: Int) {
+ this.title = context.getString(titleRes)
+ tvTitle.setText(titleRes)
+ }
+
+ fun setLeftText(text: String) {
+ this.leftText = text
+ tvLeftText.text = text
+ }
+
+ fun setRightText(text: String) {
+ this.rightText = text
+ tvRightText.text = text
+ }
+
+ fun setOnEasyBarClickListener(listener: OnEasyBarClickListener) {
+ this.mListener = listener
+ }
+
+
+ fun setRightIcon(drawable: Drawable) {
+ imgRight.setImageDrawable(drawable)
+ }
+
+ fun setRightIcon(bitmap: Bitmap) {
+ imgRight.setImageBitmap(bitmap)
+ }
+
+ fun setRightIcon(@DrawableRes res: Int) {
+ imgRight.setImageResource(res)
+ }
+
+ fun getRightIcon(): View? {
+ return imgRight
+ }
+
+ fun getRightText(): String? {
+ return tvRightText.text.toString()
+ }
+
+ fun setLeftIcon(drawable: Drawable) {
+ imgLeft.setImageDrawable(drawable)
+ }
+
+ fun setLeftIcon(bitmap: Bitmap) {
+ imgLeft.setImageBitmap(bitmap)
+ }
+
+ fun setLeftIcon(@DrawableRes res: Int) {
+ imgLeft.setImageResource(res)
+ }
+
+ fun getLeftIcon(): View? {
+ return imgLeft
+ }
+
+ interface OnEasyBarClickListener {
+ /**
+ * 如果是图标模式,则响应左图标点击,否则响应左文字点击
+ *
+ * @param view
+ */
+ fun onLeftIconClick(view: View)
+
+ /**
+ * 如果是图标模式,则响应右图标点击,否则响应右文字点击
+ *
+ * @param view
+ */
+ fun onRightIconClick(view: View)
+ }
+
+
+ enum class Mode {
+ ICON, TEXT, ICON_TEXT, TEXT_ICON, ICON_, TEXT_, _ICON, _TEXT, NONE
+ }
+
+ fun setDisplayMode(mode: Mode?) {
+ when (mode) {
+ Mode.ICON -> {
+ tvLeftText.visibility = View.INVISIBLE
+ tvRightText.visibility = View.INVISIBLE
+ imgLeft.visibility = View.VISIBLE
+ imgRight.visibility = View.VISIBLE
+
+ }
+ Mode.TEXT -> {
+ tvLeftText.visibility = View.VISIBLE
+ tvRightText.visibility = View.VISIBLE
+ imgLeft.visibility = View.INVISIBLE
+ imgRight.visibility = View.INVISIBLE
+ }
+ Mode.ICON_TEXT -> {
+ tvLeftText.visibility = View.INVISIBLE
+ tvRightText.visibility = View.VISIBLE
+ imgLeft.visibility = View.VISIBLE
+ imgRight.visibility = View.INVISIBLE
+ }
+ Mode.TEXT_ICON -> {
+ tvLeftText.visibility = View.VISIBLE
+ tvRightText.visibility = View.INVISIBLE
+ imgLeft.visibility = View.INVISIBLE
+ imgRight.visibility = View.VISIBLE
+ }
+ Mode.TEXT_ -> {
+ tvLeftText.visibility = View.VISIBLE
+ tvRightText.visibility = View.INVISIBLE
+ imgLeft.visibility = View.INVISIBLE
+ imgRight.visibility = View.INVISIBLE
+ }
+ Mode.ICON_ -> {
+ tvLeftText.visibility = View.INVISIBLE
+ tvRightText.visibility = View.INVISIBLE
+ imgLeft.visibility = View.VISIBLE
+ imgRight.visibility = View.INVISIBLE
+ }
+ Mode._ICON -> {
+ tvLeftText.visibility = View.INVISIBLE
+ tvRightText.visibility = View.INVISIBLE
+ imgLeft.visibility = View.INVISIBLE
+ imgRight.visibility = View.VISIBLE
+ }
+ Mode._TEXT -> {
+ tvLeftText.visibility = View.INVISIBLE
+ tvRightText.visibility = View.VISIBLE
+ imgLeft.visibility = View.INVISIBLE
+ imgRight.visibility = View.INVISIBLE
+ }
+ Mode.NONE -> {
+ tvLeftText.visibility = View.INVISIBLE
+ tvRightText.visibility = View.INVISIBLE
+ imgLeft.visibility = View.INVISIBLE
+ imgRight.visibility = View.INVISIBLE
+ }
+ }
+ }
+}
diff --git a/quick_android_easy_bar/src/main/java/cn/qjm253/quick_android_easy_bar/EasyBarExtensions.kt b/quick_android_easy_bar/src/main/java/cn/qjm253/quick_android_easy_bar/EasyBarExtensions.kt
new file mode 100644
index 0000000..6c5a384
--- /dev/null
+++ b/quick_android_easy_bar/src/main/java/cn/qjm253/quick_android_easy_bar/EasyBarExtensions.kt
@@ -0,0 +1,78 @@
+package cn.qjm253.quick_android_easy_bar
+
+
+import android.annotation.SuppressLint
+import android.view.View
+import androidx.annotation.DrawableRes
+import androidx.annotation.StringRes
+
+/**
+ * Created by sunny on 18-1-25.
+ */
+
+class EasyBarParams(
+ val mode: EasyBar.Mode = EasyBar.Mode.ICON_,
+ val title: String = "",
+ val leftCallback: (v: View) -> Unit = {},
+ val rightCallback: (v: View) -> Unit = {
+ println("empty right")
+ }, @DrawableRes val leftRes: Int = R.drawable.back,
+ @DrawableRes val rightRes: Int = 0,
+ val leftText: String = "",
+ val rightText: String = "", @StringRes val titleRes: Int = -1,
+ val isCoverCallback: Boolean = true
+) {
+}
+
+fun EasyBar.init(easyBarParams: EasyBarParams) {
+ init(
+ easyBarParams.mode,
+ easyBarParams.title,
+ easyBarParams.leftCallback,
+ easyBarParams.rightCallback,
+ easyBarParams.leftRes,
+ easyBarParams.rightRes,
+ easyBarParams.leftText,
+ easyBarParams.rightText,
+ easyBarParams.titleRes,
+ easyBarParams.isCoverCallback
+ )
+}
+
+/**
+ * 标题栏初始化
+ */
+@SuppressLint("ResourceType")
+fun EasyBar.init(
+ mode: EasyBar.Mode = EasyBar.Mode.ICON_,
+ title: String = "",
+ leftCallback: (v: View) -> Unit = {},
+ rightCallback: (v: View) -> Unit = {
+ println("empty right")
+ }, @DrawableRes leftRes: Int = R.drawable.back,
+ @DrawableRes rightRes: Int = 0,
+ leftText: String = "",
+ rightText: String = "", @StringRes titleRes: Int = -1,
+ isCoverCallback: Boolean = true
+) {
+ this.setDisplayMode(mode)
+ if (titleRes > 0)
+ this.setTitle(titleRes)
+ else
+ this.setTitle(title)
+ this.setRightIcon(rightRes)
+ this.setLeftText(leftText)
+ this.setRightText(rightText)
+ this.setLeftIcon(leftRes)
+ if (isCoverCallback)
+ this.setOnEasyBarClickListener(object : EasyBar.OnEasyBarClickListener {
+ override fun onLeftIconClick(view: View) {
+ leftCallback(view)
+ }
+
+ override fun onRightIconClick(view: View) {
+ rightCallback.invoke(view)
+ }
+
+ })
+}
\ No newline at end of file
diff --git a/quick_android_easy_bar/src/main/res/drawable/back.png b/quick_android_easy_bar/src/main/res/drawable/back.png
new file mode 100644
index 0000000..cab12e2
Binary files /dev/null and b/quick_android_easy_bar/src/main/res/drawable/back.png differ
diff --git a/quick_android_easy_bar/src/main/res/values/colors.xml b/quick_android_easy_bar/src/main/res/values/colors.xml
new file mode 100644
index 0000000..b779011
--- /dev/null
+++ b/quick_android_easy_bar/src/main/res/values/colors.xml
@@ -0,0 +1,4 @@
+
+
+ #333333
+
\ No newline at end of file
diff --git a/quick_android_easy_bar/src/main/res/values/quick_android_easy_bar_attrs.xml b/quick_android_easy_bar/src/main/res/values/quick_android_easy_bar_attrs.xml
new file mode 100644
index 0000000..8268eda
--- /dev/null
+++ b/quick_android_easy_bar/src/main/res/values/quick_android_easy_bar_attrs.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/quick_android_easy_bar/src/main/res/values/strings.xml b/quick_android_easy_bar/src/main/res/values/strings.xml
new file mode 100644
index 0000000..527871a
--- /dev/null
+++ b/quick_android_easy_bar/src/main/res/values/strings.xml
@@ -0,0 +1,3 @@
+
+ quick_android_easy_bar
+
diff --git a/quick_android_easy_bar/src/test/java/cn/qjm253/quick_android_easy_bar/ExampleUnitTest.kt b/quick_android_easy_bar/src/test/java/cn/qjm253/quick_android_easy_bar/ExampleUnitTest.kt
new file mode 100644
index 0000000..3d28083
--- /dev/null
+++ b/quick_android_easy_bar/src/test/java/cn/qjm253/quick_android_easy_bar/ExampleUnitTest.kt
@@ -0,0 +1,17 @@
+package cn.qjm253.quick_android_easy_bar
+
+import org.junit.Test
+
+import org.junit.Assert.*
+
+/**
+ * Example local unit test, which will execute on the development machine (host).
+ *
+ * See [testing documentation](http://d.android.com/tools/testing).
+ */
+class ExampleUnitTest {
+ @Test
+ fun addition_isCorrect() {
+ assertEquals(4, 2 + 2)
+ }
+}
diff --git a/settings.gradle b/settings.gradle
index e856275..d4a1759 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1 +1 @@
-include ':app', ':quick_android_base', ':quick_android_mvp', ':quick_android_qrcode', ':quick_android_image_picker', ':quick_android_webview', ':quick_android_rx_permission', ':quick_android_custom_view'
+include ':app', ':quick_android_base', ':quick_android_mvp', ':quick_android_qrcode', ':quick_android_image_picker', ':quick_android_webview', ':quick_android_rx_permission', ':quick_android_custom_view', ':quick_android_easy_bar'