Skip to content
This repository was archived by the owner on Feb 6, 2021. It is now read-only.

Commit f3f53c1

Browse files
authored
Create README.md
1 parent 3032007 commit f3f53c1

1 file changed

Lines changed: 74 additions & 0 deletions

File tree

README.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# ViewBinding Library
2+
This library helps to reduce the boilerplate code in initializing activities and fragments using ViewBinding. With this library you can initialize fragments, activities with a single line of code and can use the reference anywhere in the file.
3+
4+
## Installation
5+
6+
- Add the Jitpack.io dependency in project level gradle file
7+
8+
```gradle
9+
allprojects {
10+
repositories {
11+
...
12+
maven { url 'https://jitpack.io' }
13+
}
14+
}
15+
```
16+
17+
- Add `ViewBinding_Library` dependency in app level gradle file (Replace `Tag` with latest release)
18+
19+
```gradle
20+
dependencies {
21+
implementation 'com.github.abhinav78910:ViewBinding_Library:Tag'
22+
}
23+
```
24+
25+
### Using ViewBinding_Library into your Android Project
26+
27+
- Using ViewBinding_Library in Activity
28+
29+
```kotlin
30+
class MainActivity : AppCompatActivity() {
31+
32+
private val binding: ActivityMainBinding by viewBinding()
33+
34+
override fun onCreate(savedInstanceState: Bundle?) {
35+
super.onCreate(savedInstanceState)
36+
setContentView(binding.root)
37+
}
38+
}
39+
```
40+
- Using ViewBinding_Library in Fragments
41+
42+
```kotlin
43+
class TestFragment : Fragment(R.layout.fragment_test) {
44+
45+
private val binding: FragmentTestBinding by viewBinding()
46+
47+
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
48+
super.onViewCreated(view, savedInstanceState)
49+
}
50+
}
51+
```
52+
Incase of fragments Use onViewCreated instead of onCreateView. UI for the fragment is taken care by the library you need not to use onCreateView for initializing the UI for fragment.
53+
54+
## License
55+
56+
Copyright (c) 2021 Abhinav
57+
58+
Permission is hereby granted, free of charge, to any person obtaining a copy
59+
of this software and associated documentation files (the "Software"), to deal
60+
in the Software without restriction, including without limitation the rights
61+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
62+
copies of the Software, and to permit persons to whom the Software is
63+
furnished to do so, subject to the following conditions:
64+
65+
The above copyright notice and this permission notice shall be included in all
66+
copies or substantial portions of the Software.
67+
68+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
69+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
70+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
71+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
72+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
73+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
74+
SOFTWARE.

0 commit comments

Comments
 (0)