Skip to content

Commit f04387d

Browse files
committed
first commit
0 parents  commit f04387d

File tree

49 files changed

+1207
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1207
-0
lines changed

.idea/compiler.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/gradle.xml

Lines changed: 23 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
# PagingNavigation
2+
3+
![PagerNavigationView](https://i.ibb.co/wWR6T8n/nav1.jpg)
4+
![PagerNavigationView](https://i.ibb.co/qssTDxw/nav2.jpg)
5+
6+
## Setup
7+
### Gradle
8+
9+
Add this to your project level `build.gradle`:
10+
```groovy
11+
allprojects {
12+
repositories {
13+
maven { url "https://jitpack.io" }
14+
}
15+
}
16+
```
17+
Add this to your app `build.gradle`:
18+
```groovy
19+
dependencies {
20+
implementation 'com.github.edtslib:pagingnavigation:1.0.0'
21+
}
22+
```
23+
# Usage
24+
25+
The PagerNavigationView is very easy to use. Just add it to your layout like any other view.
26+
##### Via XML
27+
28+
Here's a basic implementation.
29+
30+
```xml
31+
<id.co.edtslib.pagingnavigation.PagingNavigation
32+
android:id="@+id/navigation"
33+
android:layout_width="wrap_content"
34+
android:layout_height="wrap_content"
35+
app:count="6"
36+
app:shape="@drawable/bg_test"
37+
app:shapeSize="@dimen/dimen_8dp"
38+
app:shapeSelectedWidth="20dp"
39+
app:layout_constraintBottom_toBottomOf="parent"
40+
app:layout_constraintLeft_toLeftOf="parent"
41+
app:layout_constraintRight_toRightOf="parent"
42+
app:layout_constraintTop_toTopOf="parent" />
43+
```
44+
### Attributes information
45+
46+
##### _app:count_
47+
[integer]: size of pager
48+
49+
##### _app:shape_
50+
[integer]: shape form resource id, default
51+
52+
```xml
53+
<?xml version="1.0" encoding="utf-8"?>
54+
<selector xmlns:android="http://schemas.android.com/apk/res/android">
55+
<!-- shape for selection -->
56+
<item android:state_selected="true">
57+
<shape android:shape="oval">
58+
<solid android:color="#1171D4" />
59+
</shape>
60+
</item>
61+
<!-- shape for defaul -->
62+
<item>
63+
<shape android:shape="oval">
64+
<solid android:color="#DCDEE3" />
65+
</shape>
66+
</item>
67+
</selector>
68+
```
69+
70+
##### _app:shapeSize_
71+
[dimension]: size of shape, default 4dp
72+
73+
##### _app:shapeSelectedWidth_
74+
[dimension]: size of shape if selected, default = shapeSize
75+
76+
##### _app:space_
77+
[reference]: space between shape, default 8dp
78+
79+
### Listening for click actions on the PagingNavigation
80+
81+
You can set a listener to be notified when the user click the PagingNavigation. An example is shown below.
82+
83+
```kotlin
84+
val navigation = findViewById<PagingNavigation>(R.id.navigation)
85+
navigation.delegate = object : PagingNavigationDelegate {
86+
override fun onSelected(position: Int) {
87+
Toast.makeText(this@MainActivity, "Selected Index $position",
88+
Toast.LENGTH_SHORT).show()
89+
}
90+
}
91+
```
92+
93+
### Setting the view attributes via code
94+
For convenience, many of the PagingNavigation attributes can be set via code.
95+
```kotlin
96+
// set size of pager
97+
var count: Int = 0
98+
```
99+
100+
### Method for navigation actions on the PagingNavigation
101+
102+
103+
```kotlin
104+
// selected index of shape
105+
var selectedIndex: Int = -1
106+
```
107+
108+
109+
110+

app/build.gradle

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
plugins {
2+
id 'com.android.application'
3+
id 'kotlin-android'
4+
}
5+
6+
android {
7+
compileSdk 30
8+
9+
defaultConfig {
10+
applicationId "id.co.edtslib.pagingnavigation.example"
11+
minSdk 21
12+
targetSdk 30
13+
versionCode 1
14+
versionName "1.0"
15+
16+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
17+
}
18+
19+
buildTypes {
20+
release {
21+
minifyEnabled false
22+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
23+
}
24+
}
25+
compileOptions {
26+
sourceCompatibility JavaVersion.VERSION_1_8
27+
targetCompatibility JavaVersion.VERSION_1_8
28+
}
29+
kotlinOptions {
30+
jvmTarget = '1.8'
31+
}
32+
}
33+
34+
dependencies {
35+
36+
implementation 'androidx.core:core-ktx:1.6.0'
37+
implementation 'androidx.appcompat:appcompat:1.3.1'
38+
implementation 'com.google.android.material:material:1.4.0'
39+
implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
40+
implementation project(":pagingnavigation")
41+
testImplementation 'junit:junit:4.+'
42+
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
43+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
44+
}

app/proguard-rules.pro

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package id.co.edtslib.pagingnavigation.example
2+
3+
import androidx.test.platform.app.InstrumentationRegistry
4+
import androidx.test.ext.junit.runners.AndroidJUnit4
5+
6+
import org.junit.Test
7+
import org.junit.runner.RunWith
8+
9+
import org.junit.Assert.*
10+
11+
/**
12+
* Instrumented test, which will execute on an Android device.
13+
*
14+
* See [testing documentation](http://d.android.com/tools/testing).
15+
*/
16+
@RunWith(AndroidJUnit4::class)
17+
class ExampleInstrumentedTest {
18+
@Test
19+
fun useAppContext() {
20+
// Context of the app under test.
21+
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22+
assertEquals("id.co.edtslib.pagingnavigation.example", appContext.packageName)
23+
}
24+
}

app/src/main/AndroidManifest.xml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="id.co.edtslib.pagingnavigation.example">
4+
5+
<application
6+
android:allowBackup="true"
7+
android:icon="@mipmap/ic_launcher"
8+
android:label="@string/app_name"
9+
android:roundIcon="@mipmap/ic_launcher_round"
10+
android:supportsRtl="true"
11+
android:theme="@style/Theme.PagingNavigation">
12+
<activity
13+
android:name=".MainActivity"
14+
android:exported="true">
15+
<intent-filter>
16+
<action android:name="android.intent.action.MAIN" />
17+
18+
<category android:name="android.intent.category.LAUNCHER" />
19+
</intent-filter>
20+
</activity>
21+
</application>
22+
23+
</manifest>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package id.co.edtslib.pagingnavigation.example
2+
3+
import androidx.appcompat.app.AppCompatActivity
4+
import android.os.Bundle
5+
import android.os.Handler
6+
import android.os.Looper
7+
import android.widget.Toast
8+
import id.co.edtslib.pagingnavigation.PagingNavigation
9+
import id.co.edtslib.pagingnavigation.PagingNavigationDelegate
10+
11+
class MainActivity : AppCompatActivity() {
12+
override fun onCreate(savedInstanceState: Bundle?) {
13+
super.onCreate(savedInstanceState)
14+
setContentView(R.layout.activity_main)
15+
16+
Handler(Looper.myLooper()!!).post {
17+
val navigation = findViewById<PagingNavigation>(R.id.navigation)
18+
navigation.delegate = object : PagingNavigationDelegate {
19+
override fun onSelected(position: Int) {
20+
Toast.makeText(this@MainActivity, "Selected Index $position",
21+
Toast.LENGTH_SHORT).show()
22+
}
23+
}
24+
navigation.selectedIndex = 2
25+
}
26+
}
27+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
xmlns:aapt="http://schemas.android.com/aapt"
3+
android:width="108dp"
4+
android:height="108dp"
5+
android:viewportWidth="108"
6+
android:viewportHeight="108">
7+
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
8+
<aapt:attr name="android:fillColor">
9+
<gradient
10+
android:endX="85.84757"
11+
android:endY="92.4963"
12+
android:startX="42.9492"
13+
android:startY="49.59793"
14+
android:type="linear">
15+
<item
16+
android:color="#44000000"
17+
android:offset="0.0" />
18+
<item
19+
android:color="#00000000"
20+
android:offset="1.0" />
21+
</gradient>
22+
</aapt:attr>
23+
</path>
24+
<path
25+
android:fillColor="#FFFFFF"
26+
android:fillType="nonZero"
27+
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
28+
android:strokeWidth="1"
29+
android:strokeColor="#00000000" />
30+
</vector>

0 commit comments

Comments
 (0)