Fudi Annotation

Additional

Language
Java
Version
Rev03 (Sep 6, 2018)
Created
Sep 6, 2018
Updated
Sep 16, 2018
Owner
Freddy Fudi (romellfudi)
Contributor
Freddy Fudi (romellfudi)
1
Activity
Badge
Generate
Download
Source code
APK file

Show card

FUDI ANNOTATION Library API

by Romell Dominguez

latestVersion is 1.0.a

Add the following in your app's build.gradle file:

repositories {
    jcenter()
}
dependencies {
    compile 'com.romellfudi.fudi_annotation:fudi-annotation:1.0.a'
}

Examples:

if you need Inject widget, first setup Fudi Library on youe activity or fragment:

import com.romellfudi.fudi_annotation.Bind;
setContentView(R.layout.activity_main);
Bind.Plug(this);

Then you could be able inject whatever android widget without initializer:

@ItemWidget(identifier = R.id.toolbar)
public Toolbar toolbar;
@ItemWidget
RadioGroup radio_group; // private variable
@ItemWidget
private Spinner my_spinner;

You can also override mapping claases:

@ItemWidget(className = FloatingActionButton.class)
public View fab;

if you use would like Tabhost on your frame, thats it:

@ItemWidget
@TabHostWidget(
        tabcontent = R.id.tabcontent,
        value = {
                @SimpleTabHost(c = RetrievalFragment.class, t = "", d = R.drawable.buscar_cliente_icon),
                @SimpleTabHost(c = ConfigurationFragment.class, t = "", d = R.drawable.config_icon)
        })
FragmentTabHost tabHost;

if you use would like Tablayout, with many custom ViewPages:

@ItemWidget(identifier = R.id.tl_main)
@ViewPagerWidget(
        idViewPaper = R.id.vp_main,
        colorSelected = R.color.colorCasiNegro100,
        colorUnselected = R.color.colorCasiNegro70,
        values = {
                @SimpleViewPaper(c = DatosPersonalesFragment.class, t = "DATOS PERSONALES", d = R.drawable.ic_datos_personales_50dp),
                @SimpleViewPaper(c = HijosFragment.class, t = "HIJOS", d = R.drawable.ic_child_friendly_black_24dp)
        })
TabLayout tl_main;

This API also have inject methods for android performance:

@OnClick(identifier = R.id.btn_apretar)
private void info() {
        Toast.makeText(this, "Go!", Toast.LENGTH_SHORT).show();
}

Other inject methods:

 @OnLongClick(identifier = R.id.btn_apretar)

for Spinners or ButtomGroups, you can implement the inject metthods:

@SpinnerSelected(identifier = R.id.my_spinner, arrayStringId = R.array.lista_pais,
            typeSpinner = android.R.layout.simple_spinner_item)
private void SeleccionPaises(String paisSelected, int position) {
    Toast.makeText(this, position + "-" + paisSelected, Toast.LENGTH_SHORT).show();
}

@GroupButtonSeleted(identifier = R.id.radio_group)
private void ChangeYesNo(RadioGroup radioGroup, RadioButton radioButton) {
    Toast.makeText(this, "valor=" + radioButton.getText(), Toast.LENGTH_SHORT).show();
}

For EditText widget, like current input:

@OnFocus(identifier = R.id.et_world, viewRequestFocus = R.id.et_ip, needParameters = true)
private void cuandoEsteEnfocado(EditText v, boolean b) {
    if (b)
        Toast.makeText(this, "Ingrese info", Toast.LENGTH_SHORT).show();
    else
        v.setText("Ha ingresado :" + v.getText().toString());
}

if you want setup easy regular expression on EditText widgets use:

@RegularExpression(identifier = R.id.et_ip, maxLeght = 15,
            regularExpression = "^([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." +
                    "([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." +
                    "([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." +
                    "([01]?\\d\\d?|2[0-4]\\d|25[0-5])$",
            isIPAdress = true)
private void FormatoIP(List<Object> objects) {
    if (objects.size() > 0) {
        String finalValue = (String) objects.get(0);
        Toast.makeText(this, "->" + finalValue, Toast.LENGTH_SHORT).show();
    }
}

2017, January

<style> img[src*='#center'] { width:500px; display: block; margin: auto; } img[src*='#gif'] { width:200px; display: block; margin: auto; } </style>