What is ActionBarSherlock for Android?

1

A former colleague used this framework / lib I do not know in a company project for Android and restricted the version for Android 4.0+, however we need it to run on Android version 2.3 + ... so I do not see option if it does not remove this business. I noticed that all activities have a second class named NameActivity_, terrible that.

I'm using some annotations that seem to me to be theirs with the @click to assign a function to a button, nothing that a method returning a listener does not resolve.

So, what is the framework for? What does he do for the project? on the Site I saw that it would just be a way to add actionBar to the project, but even that we do not use ... is there any use for this business?

    
asked by anonymous 23.01.2015 / 22:47

1 answer

4

These annotations are not ActionBarSherlock and yes Android Annotations .

ActionBarSherlock is responsible for offering a compatibility implementation of ActionBar for devices with Android version less than 3.0. Currently the appcompat library already provides this compatibility implementation, no longer needing to use ActionBarSherlock . In addition, the ActionBar itself is falling into disuse in favor of Toolbar of version 5.0, which appcompat also provides compatibility.

The Android Annotations library adds some annotations, which serve as shortcuts to certain actions, features, and declarations, which in general reduce the amount of redundant, boilerplate written code. The biggest advantage dictated by the creators of the library would be to increase productivity.

Example:

@ViewById -> chama o findViewById da Activity após o setContentView
@EActivity -> chama o setContentView com o id especificado na anotação

The use of this library has its advantages and disadvantages, it depends a lot on each project / team.

The suffix _ in NomeActivity_ is a side effect, because for each annotated class, for example NomeActivity , generates a new class with that suffix, with all the self-generated code corresponding to each of these annotations .

These functions do not at first impact performance because all extra code is generated at compile time, but the code may not be the most optimized (sometimes this does not even matter for readability / productivity).

You can look in the gen of Eclipse folder or search for it using Ctrl-R or Ctrl-T and see the auto-generated code.

In the case of Android Studio , I believe you need to target/generated-sources/annotations and you will see the generated code.

For more details: link

About the release, both libraries support Android 2.3. I suggest you take a look at which libraries the project has and check on the AndroidManifest of which versions they put at least.

If you do not have any, I recommend doing a very careful test / analysis in the code as there may be calls to the API of newer versions that will generate run-time error (some lint may be warning at compile time). E.g: Animation API (ObjectAnimator, ValueAnimator, ViewPropertyAnimator and etc ...).

    
24.01.2015 / 00:00