项目作者: romellfudi

项目描述 :
:gear:Android Annotation Library for Widgets Design
高级语言: Java
项目地址: git://github.com/romellfudi/FudiAnnotation.git
创建时间: 2018-09-06T01:07:35Z
项目社区:https://github.com/romellfudi/FudiAnnotation

开源协议:Apache License 2.0

下载


platform
API
License
Workflow
Android Arsenal
Jitpack

by Romell Dominguez

latestVersion is 1.0.a

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

  1. repositories {
  2. jcenter()
  3. }
  4. dependencies {
  5. implementation 'com.romellfudi.fudi_annotation:fudi-annotation:1.0.a'
  6. }

Examples:

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

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

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

  1. @ItemWidget(identifier = R.id.toolbar)
  2. public Toolbar toolbar;
  3. @ItemWidget
  4. RadioGroup radio_group; // private variable
  5. @ItemWidget
  6. private Spinner my_spinner;

You can also override mapping claases:

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

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

  1. @ItemWidget
  2. @TabHostWidget(
  3. tabcontent = R.id.tabcontent,
  4. value = {
  5. @SimpleTabHost(c = RetrievalFragment.class, t = "", d = R.drawable.buscar_cliente_icon),
  6. @SimpleTabHost(c = ConfigurationFragment.class, t = "", d = R.drawable.config_icon)
  7. })
  8. FragmentTabHost tabHost;

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

  1. @ItemWidget(identifier = R.id.tl_main)
  2. @ViewPagerWidget(
  3. idViewPaper = R.id.vp_main,
  4. colorSelected = R.color.colorCasiNegro100,
  5. colorUnselected = R.color.colorCasiNegro70,
  6. values = {
  7. @SimpleViewPaper(c = DatosPersonalesFragment.class, t = "DATOS PERSONALES", d = R.drawable.ic_datos_personales_50dp),
  8. @SimpleViewPaper(c = HijosFragment.class, t = "HIJOS", d = R.drawable.ic_child_friendly_black_24dp)
  9. })
  10. TabLayout tl_main;

This API also have inject methods for android performance:

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

Other inject methods:

  1. @OnLongClick(identifier = R.id.btn_apretar)

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

  1. @SpinnerSelected(identifier = R.id.my_spinner, arrayStringId = R.array.lista_pais,
  2. typeSpinner = android.R.layout.simple_spinner_item)
  3. private void SeleccionPaises(String paisSelected, int position) {
  4. Toast.makeText(this, position + "-" + paisSelected, Toast.LENGTH_SHORT).show();
  5. }
  6. @GroupButtonSeleted(identifier = R.id.radio_group)
  7. private void ChangeYesNo(RadioGroup radioGroup, RadioButton radioButton) {
  8. Toast.makeText(this, "valor=" + radioButton.getText(), Toast.LENGTH_SHORT).show();
  9. }

For EditText widget, like current input:

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

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

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

License

  1. Copyright 2017 Romell D.Z.
  2. Licensed under the Apache License, Version 2.0 (the "License");
  3. you may not use this file except in compliance with the License.
  4. You may obtain a copy of the License at
  5. http://www.apache.org/licenses/LICENSE-2.0
  6. Unless required by applicable law or agreed to in writing, software
  7. distributed under the License is distributed on an "AS IS" BASIS,
  8. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. See the License for the specific language governing permissions and
  10. limitations under the License.

2017, January