FudiAnnotation

1. Introduction

Target & How setup

This is a tutorial for introducing a how to save and how to load any object in your Android Project, First at all, need add the dependency repository and library into your gradle files:

Please replace latestVersion annotation with the latest maven version

repositories {
    maven { url 'https://jitpack.io' }
}
dependencies {
    implementation 'com.romellfudi.fudi_annotation:fudi-annotation:1.0.a'
}

Dependencies

Knowledge Basic programming

2. Setting up

To start you need a code with interfaces classes or adapter patterns.

Download the Code

Click the following link to download all the code for this tutorial:

Download source code

What you'll learn

What you'll need

3. Implementation

if you need Inject widget, first setup Fudi Library on your 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 classes:

@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();
    }
}

4. License

by Romell Domínguez

Copyright 2014 Romell D.Z.

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.