Giter Site home page Giter Site logo

butterknifelite's Introduction

ButterKnifeLite

Download Android Arsenal

##Android View initializer and onClick Listener boiler plate code remover

####This library is based on the ideas of ButterKnife but with use cases targeted for view binding of xml. Resulting is a tiny and compact library that don't hamper the existing project with lots of unused codes and consuming unneccessery build apk size

##@BindView annotation to refer any view defined in XML (Note: Use public Keyword)

 @BindView(R.id.txtView)
 public TextView textView1;

 

##@OnClick annotation to set onClick method for any view defined in XML

@OnClick(R.id.btn1)
public void onBtn1Click(){
    textView1.setText("Btn 1 click");
}

##For Any class with inflated view from XML can be used as described below ##For example in a Fragment

public class MyFragment extends Fragment {

    @BindView(R.id.txtView)
    public TextView txtView;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View promptsView = inflater.inflate(R.layout.my_fragment, container, false);
        ButterKnifeLite.bind(this, promptsView);
        return promptsView;
    }

    @OnClick(R.id.btn1)
    public void onBtn1Click(){
        txtView.setText("Btn 1 frag click");
    }

    @OnClick(R.id.btn2)
    public void onBtn2Click(){
        txtView.setText("Btn 2 frag click");
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        ButterKnifeLite.unbind(this);
    }
}

##Call ButterKnifeLite.unbind(this) in the onDestroy() method

@Override
public void onDestroy() {
    super.onDestroy();
    ButterKnifeLite.unbind(this);
}

For other classes

@Override
protected void finalize() throws Throwable {
    super.finalize();
    ButterKnifeLite.unbind(this);
}

#Gradle

  compile 'com.mindorks:butterknifelite:0.0.2'

Proguard Note:

If you are using proguard, then add this rule in proguard-project.txt

  -keepattributes *Annotation*
  -keepclassmembers class ** {
    @com.mindorks.butterknifelite.annotations.** <methods>;
  }

butterknifelite's People

Contributors

janishar avatar amitshekhariitbhu avatar

Watchers

Naseem Akhtar 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.