PyxInjector

Additional

Language
Kotlin
Version
1.2.1 (Jan 12, 2018)
Created
Oct 23, 2017
Updated
Jan 2, 2019 (Retired)
Owner
WindSekirun (wind.seo) (WindSekirun)
Contributor
WindSekirun (wind.seo) (WindSekirun)
1
Activity
Badge
Generate
Download
Source code

PyxInjector

Annotation Field Injector Library

Pyx is abbreviation of Pyxis, small and faint constellation in the southern sky.

PyxInjector help you to inject field, methods by various annotation field

릴리즈 소개 글은 개인 블로그 PyxisPub 에서 보실 수 있습니다.

Usages

rootProject/build.gradle

allprojects {
    repositories {
     maven { url 'https://jitpack.io' }
    }
}

app/build.gradle

dependencies {
    implementation 'com.github.WindSekirun:PyxInjector:1.2.1'
}

Start to use

  1. extending InjectActivity or InjectSupportFragment in your activity / fragment
  2. Done, you can use any annotation fields below.

If you can't extending pre-bulit classes like InjectActivity, you can call PyxInjector.getInstance().inject maunally. please see Custom object in wiki

Annotation Fields

@BindView

Annotation Field with @BindView with Optional View ID for PyxInjector to find and cast the corresponding view.

Wiki

@Extra

Annotation Field with @Extra with Optional extra key to find and cast the corresponding intent extras.

Wiki

@Argument

Annotation Field with @Argument with Optional extra key to find and cast the corrsponding fragment arguments.

Wiki

@OnClicks / @OnClicks

Annotation Field with @OnClick, @OnClicks with View ID to find and invoke methods

Wiki

@OnLongClick / @OnLongClicks

Annotation Field with @OnLongClick, @OnLongClicks with View ID to find and invoke methods

Wiki

@OnSeekbarChange [Since 1.1]

Annotation Field with @OnSeekbarChange with View ID to find and invoke OnSeekBarChangeListener.onProgressChanged(seekbar: SeekBar?, progress: Int, fromUser: Boolean)

Wiki

@OnEditTextChange [Since 1.1]

Annotation Field with @OnEditTextChange with View ID to find and invoke methods of TextWatcher

Wiki

@OnCheckChange [Since 1.1]

Annotation Field with @OnCheckChange with View ID to find and invoke CompoundButton.OnCheckedChangeListener.onCheckedChanged (CompoundButton buttonView, boolean isChecked)

Wiki

Non-Activity / Fragment Binding [Since 1.1]

public class ListHolder extends RecyclerView.ViewHolder {
    private @BindView TextView txtNum;

    public ListHolder(View itemView) {
        super(itemView);
        PyxInjector.getInstance().execute(getActivity(), this, itemView);
    }
}

find(@resId, View) [Since 1.1.5]

txtName2 = PyxInjector.find(R.id.txtName2, PyxUtils.content(this));

Config (Optional)

as 1.0.0 We support Config of PyxInjector.

Application class

Config config = new Config(BindViewPrefix.PREFIX_M);
PyxInjector.initializeApplication(config);

BindViewPrefix

Wiki

Custom Object

as 1.0.0, We support InjectActivity, InjectFragment, InjectSupportFragment to inject all activity / fragement.

if you need to inherit other class, insert this code in proper methods

License

Copyright 2017 WindSekirun (DongGil, Seo)

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.