mzule / LayoutAnnotation

@Layout annotation support for arbitrary class

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

功能

一个支持 @Layout 指定布局的库,支持在任意 class 上使用。

集成

buildscript {
  dependencies {
    classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
  }
}
apply plugin: 'android-apt'

dependencies {
    compile 'com.github.mzule.layoutannotation:library:1.0.3'
    apt 'com.github.mzule.layoutannotation:compiler:1.0.3'
}

使用

@Layout(R.layout.activity_main)
public class MainActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        LayoutBinder.bind(this);
    }
}
@Layout(R.layout.fragment_main)
public class MainFragment extends Fragment {
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return LayoutBinder.inflate(this);
    }
}

集成在 BaseActivity 和 ButterKnife 一起使用效果更佳。

public class BaseActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        LayoutBinder.bind(this);
        ButterKnife.bind(this);
    }
}

混淆配置

-keep class com.github.mzule.layoutannotation.** { *; }

许可

Apache License 2.0

联系我

任何相关问题都可以通过以下方式联系我。

  1. 提 issue
  2. 新浪微博 http://weibo.com/mzule
  3. 邮件 "mzule".concat("4j").concat("@").concat("gmail.com")

About

@Layout annotation support for arbitrary class

License:Apache License 2.0


Languages

Language:Java 100.0%