This repository was archived by the owner on Feb 6, 2021. It is now read-only.
File tree 4 files changed +17
-0
lines changed
app/src/main/java/com/sample/viewbindingdelegate
viewBindingHelper/src/main/java/android/helper/viewBinding
4 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,10 @@ import android.opengl.Visibility
7
7
import android.view.View
8
8
import com.sample.viewbindingdelegate.databinding.ActivityMainBinding
9
9
10
+ /* *
11
+ * Created by abhinav on 18/1/21.
12
+ */
13
+
10
14
class MainActivity : AppCompatActivity () {
11
15
12
16
private val binding: ActivityMainBinding by viewBinding()
Original file line number Diff line number Diff line change @@ -6,6 +6,10 @@ import android.view.View
6
6
import androidx.fragment.app.Fragment
7
7
import com.sample.viewbindingdelegate.databinding.FragmentTestBinding
8
8
9
+ /* *
10
+ * Created by abhinav on 18/1/21.
11
+ */
12
+
9
13
class TestFragment : Fragment (R .layout.fragment_test) {
10
14
11
15
private val binding: FragmentTestBinding by viewBinding()
Original file line number Diff line number Diff line change @@ -6,6 +6,10 @@ import androidx.viewbinding.ViewBinding
6
6
import kotlin.properties.ReadOnlyProperty
7
7
import kotlin.reflect.KProperty
8
8
9
+ /* *
10
+ * Created by abhinav on 18/1/21.
11
+ */
12
+
9
13
inline fun <reified T : ViewBinding > Activity.viewBinding () =
10
14
ActivityBindingHelper (T ::class .java)
11
15
Original file line number Diff line number Diff line change @@ -10,6 +10,11 @@ import androidx.viewbinding.ViewBinding
10
10
import kotlin.properties.ReadOnlyProperty
11
11
import kotlin.reflect.KProperty
12
12
13
+ /* *
14
+ * Created by abhinav on 18/1/21.
15
+ * Thanks Gabor Varadi for the article
16
+ */
17
+
13
18
inline fun <reified T : ViewBinding > Fragment.viewBinding () = FragmentBinding (T ::class .java, this )
14
19
15
20
class FragmentBinding <T : ViewBinding >(
You can’t perform that action at this time.
0 commit comments