Coder Social home page Coder Social logo

ppzhou1984 / android-databinding Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lightsun/android-databinding

0.0 1.0 0.0 10.42 MB

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

License: Apache License 2.0

Java 100.00%

android-databinding's Introduction

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

  • 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";
      String IMGAE_ROUND_BUILDER     =    "img_round_builder";
      
     //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.0'
}

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

refer lib

android-common-utils

TODO

  • support recycler view animator and other.
  • 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.

android-databinding's People

Contributors

lightsun avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.