Android IOC Annotation Library EasyUI

Introduction to EasyUI

1. Implement butterknife-like IOC frameworks using reflection mechanisms and annotations
2. Fast findViewById and OnClick
3. Extended click without network monitoring
4. Extended Quick Click Monitoring

Usage method

1. Reference

compile 'cn.cyq.android:easyuilibrary:1.1.0'

2. Initialization (optional)

This step mainly configures the text content of the Toast prompt when there is no network and determines the time interval between quick-read clicks
Toast default: no network, please check the network settings, quickly click on the default 1000ms

public class MyApplication extends Application {

    @Override
    public void onCreate() {
        super.onCreate();
        EasyUI.init(500, "Honey, your network isn't working so hard!");
    }
}

3. Use (activity fragment s custom view)

  • Activity Usage
public class MainActivity extends AppCompatActivity {
    @ViewById(R.id.tv_test)
    private TextView mTvTest;
    @ViewById(R.id.btn_test)
    private Button mBtnTest;
    @ViewById(R.id.img_test)
    private ImageView mImgTest;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        EasyUI.bind(this);
    }

    @OnClick({R.id.btn_test, R.id.img_test})
    @CheckNet //Do not perform onclick without network
    @QuickClick //Click no onclick in 1 second
    public void onclick(View view) {
    }
}
  • fragment use
public class BlankFragment extends Fragment {
    View view;
    @ViewById(R.id.tv_fragment)
    private TextView mTv;
    @ViewById(R.id.btn_fragment)
    private Button mBtn;

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

    @OnClick(R.id.btn_fragment)
    public void onClick(View view) {
    }
}
  1. As for the quick code generation of plug-ins, I will not develop android plug-ins. The cost of learning is a bit high. I do not need to develop plug-ins by myself. I am lazy. Interested buddies can play with dei.

  2. There is no need to tangle with reflective performance issues, and the performance consumed by handler and picture loading is largely negligible relative to threads.

Tags: Android network Fragment ButterKnife

Posted on Mon, 20 Jan 2020 11:23:32 -0500 by svan_rv