Skip to content

Commit

Permalink
Added listener interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
IODevBlue committed Sep 28, 2022
1 parent e1dc878 commit eb10d28
Show file tree
Hide file tree
Showing 14 changed files with 297 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
local.properties
1 change: 1 addition & 0 deletions library/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
40 changes: 40 additions & 0 deletions library/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
plugins {
id 'com.android.library'
id 'org.jetbrains.kotlin.android'
}

android {
compileSdk 32

defaultConfig {
minSdk 21
targetSdk 32

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

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}

dependencies {

implementation 'androidx.core:core-ktx:1.8.0'
implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'com.google.android.material:material:1.6.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
Empty file added library/consumer-rules.pro
Empty file.
21 changes: 21 additions & 0 deletions library/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.blueiobase.api.android.parallaxnavigationdrawer

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(
"com.blueiobase.api.android.parallaxnavigationdrawer.test",
appContext.packageName
)
}
}
2 changes: 2 additions & 0 deletions library/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.blueiobase.api.android.parallaxnavigationdrawer"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.blueiobase.api.android.parallaxnavigationdrawer.annotation

import androidx.annotation.IntDef
import com.blueiobase.api.android.parallaxnavigationdrawer.base.IParallaxDrawer

@IntDef(
IParallaxDrawer.DRAWER_MODE_LEFT,
IParallaxDrawer.DRAWER_MODE_RIGHT,
IParallaxDrawer.DRAWER_MODE_BOTH,
IParallaxDrawer.DRAWER_MODE_NONE
)
@Retention(AnnotationRetention.SOURCE)
annotation class DrawerMode
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
package com.blueiobase.api.android.parallaxnavigationdrawer.base

import android.view.View
import androidx.annotation.ColorRes
import androidx.annotation.FloatRange
import com.blueiobase.api.android.parallaxnavigationdrawer.annotation.DrawerMode
import com.blueiobase.api.android.parallaxnavigationdrawer.listener.OnDrawerCloseListener
import com.blueiobase.api.android.parallaxnavigationdrawer.listener.OnDrawerOpenListener
import com.blueiobase.api.android.parallaxnavigationdrawer.listener.OnDrawerStateListener


interface IParallaxDrawer {

companion object {
const val DRAWER_MODE_NONE = 0

const val DRAWER_MODE_LEFT = 1

const val DRAWER_MODE_RIGHT = 2

const val DRAWER_MODE_BOTH = 3
}

/**
*
*/
fun setDrawerMode(@DrawerMode slideMode: Int)

/**
*
*
* @param slidePadding
*/
fun setDrawerPadding(slidePadding: Int)

/**
*
*
* @param drawerDuration
*/
fun setDrawerAnimationDuration(drawerDuration: Int)

/**
*
*
* @param parallax
*/
fun setParallaxEnabled(parallax: Boolean)

/**
*
*
*/
fun setMainContentAlpha(@FloatRange(from = 0.0, to = 1.0) contentAlpha: Float)

/**
*
*
* @param color
*/
fun setMainContentShadowColor(@ColorRes color: Int)

/**
*
*
*/
fun setMainContentCloseOnTouch(canCloseFromMainContent: Boolean)

/**
*
*
*/
fun setAllowDragging(allowDragging: Boolean)

/**
*
*
* @return [View]
*/
fun getLeftDrawerView(): View?

/**
*
*
* @return [View]
*/
fun getRightDrawerView(): View?

/**
*
*
* @return [View]
*/
fun getMainContentView(): View?

fun toggleLeftDrawer()

fun openLeftDrawer()

fun closeLeftDrawer()

fun isLeftDrawerOpen(): Boolean

fun toggleRightDrawer()

fun openRightDrawer()

fun closeRightDrawer()

fun isRightDrawerOpen(): Boolean

fun setOnDrawerOpenListener(listener: OnDrawerOpenListener?)

fun setOnDrawerCloseListener(listener: OnDrawerCloseListener?)

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.blueiobase.api.android.parallaxnavigationdrawer.listener

import com.blueiobase.api.android.parallaxnavigationdrawer.ParallaxNavigationDrawer

interface OnDrawerCloseListener {

fun onDrawerClose (
parallaxNavigationDrawer: ParallaxNavigationDrawer,
isLeftDrawerClose: Boolean,
isRightDrawerClose: Boolean
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.blueiobase.api.android.parallaxnavigationdrawer.listener

import com.blueiobase.api.android.parallaxnavigationdrawer.ParallaxNavigationDrawer

interface OnDrawerOpenListener {
fun onDrawerOpen(
parallaxNavigationDrawer: ParallaxNavigationDrawer,
isLeftDrawerOpen: Boolean,
isRightDrawerOpen: Boolean
)
}
19 changes: 19 additions & 0 deletions library/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!--侧滑菜单的属性-->
<declare-styleable name="ParallaxNavigationDrawer">
<attr format="enum" name="drawerMode">
<enum name="left" value="1"/>
<enum name="right" value="2"/>
<enum name="both" value="3"/>
<enum name="none" value="0"/>
</attr>
<attr format="dimension" name="drawerPadding"/>
<attr format="integer" name="duration"/>
<attr format="boolean" name="parallax"/>
<attr format="float" name="mainContentAlpha"/>
<attr format="color" name="mainContentShadowColor"/>
<attr format="boolean" name="mainContentCloseOnTouch"/>
<attr format="boolean" name="allowDragging"/>
</declare-styleable>
</resources>
3 changes: 3 additions & 0 deletions library/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<resources>
<string name="app_name">Parallax Navigation Drawer</string>
</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.blueiobase.api.android.parallaxnavigationdrawer

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)
}
}

0 comments on commit eb10d28

Please sign in to comment.