Skip to content

this is the databinding framework of android . help to binding data to the view.

License

Notifications You must be signed in to change notification settings

LightSun/android-databinding

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

this lib will not uphold. if you are interested in 'Data-Binding' please move to Data-Mediator.

这个库将不再维护。如果你对数据绑定感兴趣。推荐你去Data-Mediator. 这个库更加强大.

android-databinding

this framework is now can be used in your app. By test and test,by find bug and fix i think it is now can work with well. it helps you fast bind data and event. Plugin and xml schema file for this framework can be used now. 如果你熟悉汉语, 请点击看中文版

Demo Screen Capture

Demo Screen Capture

Demo Screen Capture

before build the sample project,you need to import the xml schema file of this databind framework, see it below. see [How to use plugin and xml schema ?]

Why I developed this ?

at google-io-2015. android databindingnow can be used, it have some problem, even if this is not the reason. because i think the engineer of google's is one of the best of the world. so it can be better and better i believe. I absolutely can not be compared with them. but i don't like to writing databinding expression in android layout file(in javaweb I hate it too ). so I developed this framework.

support plugin and xml schema

android studio plugin and the xml schema of config file which are used for android-databinding framework is now available .

Features

  • you can apply image property (round,borderColor,borderWidth,circle) by you like now. so to apply image property you must call like this.
DataBindingFactory.setImagePropertyApplier(new VolleyImageApplier()); //here i just use volley to load
  • supported by plugin and xml schema file.

  • support for bind data and event handler by xml. but you must call bind method in java code.

  • support for notify data change.

  • Support for custom attr and listener

  • support for bind adapter for any child of Adapter view or RecyclerView ( contains multi items and multi select mode of adapter )

  • support for bind image (like round/borderColor/borderWith/placeHolder/errorResId),see it bellow.

  • The common support attrs:

      //event name
      String ON_CLICK                =    "onClick";
      String ON_LONG_CLICK           =    "onLongClick";
      String TEXT_CHANGE_BEFORE      =    "textChange_before";
      String TEXT_CHANGE             =    "textChange";
      String TEXT_CHANGE_AFTER       =    "textChange_after";
      String ON_FOCUS_CHANGE         =    "onFocusChange";
    
      String ON_TOUCH                =    "onTouch";
    
      //common name
      String BACKGROUND              =    "background";       //drawable /color / res id
      String BACKGROUND_COLOR        =    "backgroundColor";
      String BACKGROUND_RES          =    "background_res";
    
      String TEXT                    =    "text";
      String TEXT_RES                =    "text_res";
    
      String TEXT_COLOR              =    "textColor";
      String TEXT_COLOR_RES          =    "textColor_res";
      String TEXT_COLOR_STATE        =    "textColor_state";
      String TEXT_COLOR_STATE_RES    =    "textColor_stateRes";
      String TEXT_SIZE               =    "textSize";
      String TEXT_SIZE_RES           =    "textSize_res";
    
      String VISIBILITY              =    "visibility";
      //image
      String IMGAE_URL               =    "img_url";
      String IMGAE_BITMAP            =    "img_bitmap";
      String IMGAE_DRAWABLE          =    "img_drawable";
      
     //ps:  and also support self-attrs 
  • Support multi expressions. eg: java calling expression (only nested ternary expression is not support), android resource reference expression {@drawable/ic_default} or R.drawable.ic_default , dp and sp like "15dp", and color like "#ff0000" and so on.

  • the image full config was supported now (round/circle/borderWith/borderColor/placeHolder).
    here is the demo:

     <bind id="eniv2">
          <property name="onClick" referVariable="eventHandler" > eventHandler.onClickImage()</property>
          <imageProperty type="round" referVariable="imageParam">  <!-- round / circle / oval -->
              <roundSize>{@dimen/corner_size}</roundSize>
              <borderWidth>5dp</borderWidth>
              <borderColor>#ff0000</borderColor>
    
              <url>imageParam.link</url>
              <default>{@drawable/ic_default}</default>     <!-- support drawable ,bitmap,  resource id -->
              <errorResId>R.drawable.ic_error</errorResId>  <!-- only support resource id -->
    
          </imageProperty>
      </bind>

    the more to see in sample/RoundImageBindTest Activity.

  • blog and pdf is at the bottom of this page.

####How to use plugin and xml schema ?

  • 1, click here to donwload the zip. It contains a xml schema file and a jar of android-databinding plugin.

  • 2 , Add the xml schema file (android_databinding.xsd )to android studio. and the URI must be 'http://schemas.android.com/heaven7/android-databinding/1'. And the xsd file can be found in the downloaded zip . add xsd file to as

  • 3, install the plugin 'android_databinding_plugin'. step: in android studio click file-> setting->plugins -> install plugin from disk and select the file android_databinding_plugin.jar which can be found in the downloaded zip file.

  • 4, at the res directory of android studio, right-click and select android-databinding then follow it. and then you can enjoy the android-databinding framework. use demo use demo

version log

Gradle

gradle config:

dependencies {
    compile 'com.heaven7.databinding:android-databinding:1.1.5'
}

Usage

The explanation of usage is moved to child directory. click to see it. Usage Detail

blog and pdf resource

if you are a chinese developer or know chinese. please click here to see more easier. chinese pdf

Compare to google's databinding

see it here. this currently only have chinese doc.

refer lib

android-common-util-light

TODO

  • support gesture image (also nested in viewpager)
  • support generate relative code.
  • add demo for fragment .
  • optimize the plugin to use easier.

issue

  • this framework i will try my best to uphold , and if you have a good suggestion about this, please tell me. Thanks!

About me

hope

i like technology. especially the open-source technology.And previous i didn't contribute to it caused by i am a little lazy, but now i really want to do some for the open-source. So i hope to share and communicate with the all of you.

License

Copyright 2015   
                heaven7([email protected])

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.