Obtain styleable fields at runtime

Buy Audison Thesis Ususally, when we want to get some โ€œRโ€ attributes at runtime, we use the Resources getIdentifier method, which is useful for getting strings, drawables and ids at runtime. Unfortunately this method cannot be used to get the styleable fields. However, using java reflections, thereโ€™s another way to solve the problem. With this snippet you can get styleable fields at runtime in your code:

1
2
3
4
5
6
7
8
9
10
11
12
public static final <T> T getFieldFromStyleable( Context context, String name ) {
    try {
      // use reflection to access the resource class
      Field field = Class.forName( context.getPackageName() + ".R$styleable" ).getField( name );
      if ( null != field ) {
         return (T) field.get( null );
      }
   } catch ( Throwable t ) {
      t.printStackTrace();
   }
   return null;
}

Which can be used in this way:

1
2
int[] array = getFieldFromStyleable( context, "MyListView" );
array = context.obtainStyledAttributes( attrs, styleableArray, defStyle, 0 );

Compile skia for android on Mac Lion

Uva Application Essay Some time ago I started to look at skia as possible solution for graphics 2D editing for a native android project I was developing.
Well, even if skia is part of the android system and it’s used everywhere by android itself, trying to include skia in my project was quite an hell..
Looking for resources I just found old examples and tips, and every try was just a failure.. but since android uses skia internally to do graphics operations I decided to look into the android project.

Writing Analysis Essay After downloading the skia module from the android git repository I just realized it couldn’t be compiled by itself because it has external dependencies. So next step was to download and compile the whole android source code. Easy task? not at all, at least if you’re on a mac running Lion!

At the end I managed to compile everything and build the skia module as static module, in this way now my project can link the skia library and include correctly the skia headers.

Ok, I don’t have the whole procedure step by step here, first of all because it depends on the android version you’re going to compiled, second and most important because I didn’t write down all the steps ๐Ÿ™‚ So this is more a sort of list of notes about compiling android on Lion and a reminder for myself too. ( I was trying to compile android 2.2 using “generic-user” as lunch configuration )

Build Android:ย http://source.android.com/source/initializing.html

http://historia-sportu.cba.pl/?master-thesis-on-security Master Thesis On Security To get rid of clearsilver errors:ย http://code.google.com/p/android/issues/detail?id=993#c27

Expert Resume Writing 101 For College Students Java 1.5 version complaining:ย http://wiki.oneswarm.org/index.php/OS_X_10.6_Snow_Leopard

Well, the first time you’ll try to “ make” everything probably you’ll get this error:

1
./external/elfutils/config-compat-darwin.h:42: error: static declaration of โ€˜strnlenโ€™ follows non-static declaration

How To Write A Cover Letter University Admission modify ./external/elfutils/config-compat-darwin.h.
replace:

1
2
3
4
5
6
7
static inline size_t strnlen (const char *__string, size_t __maxlen)
{
int len = 0;
while (__maxlen-- && *__string++)
len++;
return len;
}

with:

1
2
3
4
5
6
7
8
9
#if 0
static inline size_t strnlen (const char *__string, size_t __maxlen)
{
int len = 0;
while (__maxlen-- && *__string++)
len++;
return len;
}
#endif

Dissertation Com Well, at the end of the process I just edited the Android.mk makefile into external/skia adding a new entry for BUILD_STATIC_LIBRARY and the next command was simply:

1
mmm external/skia

which produced the required libskia.a file to be linked in my project.

Java 6 Update 10 breaks Flex compiler!

I just want to share this problem I found so maybe someone can save some time..

Today while surfing the net I received a notification of an update of my Java installation to the Update 10 in order to see correctly the contents of that site.. bla bla bla..

http://sacredsourcework.com/?pay-essays-online Pay Essays Online Sometime later I switched to Flex and at the first execution of my ant script for compiling a flex project I suddenly received this beautiful error:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
[exec] Error: java/security/MessageDigest
[exec] java.lang.NoClassDefFoundError: java/security/MessageDigest
[exec]     at java.io.ObjectStreamClass.computeDefaultSUID(Unknown Source)
[exec]     at java.io.ObjectStreamClass.access$100(Unknown Source)
[exec]     at java.io.ObjectStreamClass$1.run(Unknown Source)
[exec]     at java.security.AccessController.doPrivileged(Native Method)
[exec]     at java.io.ObjectStreamClass.getSerialVersionUID(Unknown Source)
[exec]     at java.io.ObjectStreamClass.initNonProxy(Unknown Source)
[exec]     at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
[exec]     at java.io.ObjectInputStream.readClassDesc(Unknown Source)
[exec]     at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
[exec]     at java.io.ObjectInputStream.readClassDesc(Unknown Source)
[exec]     at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
[exec]     at java.io.ObjectInputStream.readObject0(Unknown Source)
[exec]     at java.io.ObjectInputStream.readObject(Unknown Source)
[exec]     at flex.util.SerializedTemplateFactory.load(SerializedTemplateFactory.java:30)
[exec]     at flex2.compiler.util.VelocityManager.getTemplate(VelocityManager.java:162)
[exec]     at flex2.compiler.util.VelocityManager.getTemplate(VelocityManager.java:151)
[exec]     at flex2.compiler.util.VelocityManager.getTemplate(VelocityManager.java:137)
[exec]     at flex2.compiler.as3.genext.GenerativeSecondPassEvaluator.generateSupportCode(GenerativeSecondPassEvaluator.java:256)
[exec]     at flex2.compiler.as3.genext.GenerativeSecondPassEvaluator.modifySyntaxTree(GenerativeSecondPassEvaluator.java:355)
[exec]     at flex2.compiler.as3.binding.BindableSecondPassEvaluator.evaluate(BindableSecondPassEvaluator.java:102)
[exec]     at macromedia.asc.parser.ClassDefinitionNode.evaluate(ClassDefinitionNode.java:106)
[exec]     at flash.swf.tools.as3.EvaluatorAdapter.evaluate(EvaluatorAdapter.java:338)
[exec]     at macromedia.asc.parser.StatementListNode.evaluate(StatementListNode.java:60)
[exec]     at flash.swf.tools.as3.EvaluatorAdapter.evaluate(EvaluatorAdapter.java:923)
[exec]     at macromedia.asc.parser.ProgramNode.evaluate(ProgramNode.java:80)
[exec]     at flex2.compiler.as3.genext.GenerativeExtension.parse2(GenerativeExtension.java:114)
[exec]     at flex2.compiler.as3.Compiler.parse2(Compiler.java:386)
[exec]     at flex2.compiler.API.parse2(API.java:2390)
[exec]     at flex2.compiler.API.parse2(API.java:2348)
[exec]     at flex2.compiler.API.batch2(API.java:375)
[exec]     at flex2.compiler.API.batch(API.java:1117)
[exec]     at flex2.compiler.API.compile(API.java:1290)
[exec]     at flex2.compiler.API.compile(API.java:1210)
[exec]     at flex2.tools.Compc.compc(Compc.java:158)
[exec]     at flex2.tools.Compc.main(Compc.java:41)

so I tried also to compile another project before go crazy, but I got this another java funny error, which was more or less unreadable as the previous one!

Fortunately I remembered the update I did of Java! And in fact after remove that update everything worked again!

Red5, first thoughts

As I promised myself, I started to spend some of the time in testing red5 since I’ve read the about the 0.6RC1 release.
Unfortunately I wasn’t able to run it on my Windows Vista so I try it on an older Windows XP. Once unpacked the installer I first tested some of the example applications boundled, everything worked fine.. cool, nice, great project indeed!

But then I wanted to migrate one of my FCS2 projects to Red5 in order to test “the real world”.
Ok, I need to write in Java? (there’s Python support, but it’s Jython) Cool.. I never seen Java, I thought it was a monster with eight heads ๐Ÿ™‚
Got the first Java editor I found on the net, IntelliJIdea (what a wonderful editor indeed! much expensive, but really cool), and started with headache..
But at least, for a newbie like me, it seems to me like editing ActionScript3 files, so it wasn’t so difficult to make things running.
I’m still “trying” to re-write the application (with minor changes also in the flash files) but I managed to make remote sharedobjects, streams and remote calls running like in the FCS2 original application and I’m so happy ๐Ÿ™‚

I just encounter a couple of time a Windows blue screen error while getting webcam streams (I need to make a snapshot next time) and some human unreadable java exceptions (It’s indeed a my fault) but I think it was a positive beginning after all.
Great great compliments to red5 developers!

Which documentator for AS2?

I was searching for a valid AS documentation tool…
I have tested the AS2Doc trial but it doesn’t parse correctly my classes.
Also ZenDoc seems to be a valid alternative, also because it’s written in PHP, but it skip all the uncommented methods ๐Ÿ™
NaturalDocs probably is the best choice, for me, but it doesn’t support standard javadoc comments
Acid gives me python errors while parsing the packages and the python code is quite unreadable.
BLDoc is really promising, but it’s still in beta
Probably the best program I found is as2api, which creates a standard javadoc html output. The only thing is that it doesn’t seem to have an option to allow documentation for private methods
Did you have experience with some of these tools, or someone else I didn’t tested?
Which one do you currently use?