Giter VIP home page Giter VIP logo

injecty's Introduction

InjectY

简介

一个简单的注入框架。(待完善)

用法

1、页面注入
(1)启动注入
public abstract class BaseActivity extends AppCompatActivity {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        InjectManager.getInstance().inject(this);
    }
}
(2)设置ContentView
@ContentView(R.layout.activity_main)
public class MainActivity extends BaseActivity {
}
(3)View注入
@FindView(R.id.tv_app_name)
private TextView mTvAppName;
@FindView(R.id.btn_test)
private Button mBtnTest;
(4)事件注入
@OnClick(R.id.btn_test)
private void onViewClick(View view) {
    if (view.getId() == R.id.btn_test) {
        Toast.makeText(MainActivity.this,
                "click: " + mBtnTest.getText(), Toast.LENGTH_SHORT).show();
    }
}

@OnLongClick({R.id.tv_app_name, R.id.btn_test})
private boolean onViewLongClick(View view) {
    switch (view.getId()) {
        case R.id.tv_app_name:
            Toast.makeText(MainActivity.this,
                    "longclick: " + mTvAppName.getText(), Toast.LENGTH_SHORT).show();
            break;
        case R.id.btn_test:
            Toast.makeText(MainActivity.this,
                    "longclick: " + mBtnTest.getText(), Toast.LENGTH_SHORT).show();
            break;
    }
    return true;
}

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.