| Author |
Message |
pskink Senior Developer

Joined: 24 Nov 2008 Posts: 194
|
Posted: Wed Jan 14, 2009 11:59 pm Post subject: new widget - Panel |
|
|
IMPORTANT !!!
now this code is hosted in svn at
http://code.google.com/p/android-misc-widgets/
what you see below drastically differs from newest stuff...
hi,
just created new widget - Panel, which can be expanded & collapsed.
change between expanded <-> collapsed states is done using customizable animation.
it's relatively small (~130 lines of code) but functional :)
any comments appreciated _________________ pskink
Last edited by pskink on Wed Jan 28, 2009 8:33 pm; edited 5 times in total |
|
| Back to top |
|
 |
|
|
 |
Emmanuel7 Senior Developer

Joined: 12 Dec 2008 Posts: 161 Location: Paris
|
Posted: Thu Jan 15, 2009 2:05 am Post subject: |
|
|
Really nice, congratulations !
I think it will interest a lot of people here !
Just two (small) points ( yes, I really did read your code ) :
* Why a setOrientation ( VERTICAL ) ? It won't work in horizontal mode ?
* The way you post a empty message to create a timer 'looks' strange. I've always seen a generic handler used, with mHandler.postDelayed(mUpdateTimeTask, mUpdateInterval ); called, with mUpdateTimeTask a runnable with a run() method doing whatever we want. Note that the fact that I always seen this method is far from meaning it is superior
* ( Yes, I know I said two points ) : your code is much more lighter than the Home sliding drawer (here ). Are there some features missing in your version ?
Thanks for this nice contribution ! _________________ Emmanuel
My Android development blog : http://androidblogger.blogspot.com/
My application site : http://www.alocaly.com |
|
| Back to top |
|
 |
pskink Senior Developer

Joined: 24 Nov 2008 Posts: 194
|
Posted: Thu Jan 15, 2009 12:32 pm Post subject: |
|
|
| Emmanuel7 wrote: | Really nice, congratulations !
I think it will interest a lot of people here !
Just two (small) points ( yes, I really did read your code :) ) :
* Why a setOrientation ( VERTICAL ) ? It won't work in horizontal mode ?
* The way you post a empty message to create a timer 'looks' strange. I've always seen a generic handler used, with mHandler.postDelayed(mUpdateTimeTask, mUpdateInterval ); called, with mUpdateTimeTask a runnable with a run() method doing whatever we want. Note that the fact that I always seen this method is far from meaning it is superior :)
* ( Yes, I know I said two points ) : your code is much more lighter than the Home sliding drawer (here ). Are there some features missing in your version ?
Thanks for this nice contribution ! |
thanks for nice comment ;)
to be honest you inspired me to enhance my Panel: now it takes ~190 lines of code:
answering you question:
ad 1) both should work now, even more: you can select position from top, bottom, left & right (see layout file)
ad 2) posting messages is imho low level API of Handler (opposite to use Runnables). and since implementing widget is somehow low level job i decided to use low leve API. also this method is imho better if you use several postDelayed, you must create several anonymous Runnables (this is not case here since i use only two times) and with low level API you only have to make one anonymous Handler and handle message in dispatchMessage()
ad 3) sure it's missing some features: otherwise i would work at google ;) but if you ask if some features are missing it means that you didn't notice them and you don't care ;)
thanks and regards, _________________ pskink
Last edited by pskink on Thu Jan 22, 2009 8:17 pm; edited 1 time in total |
|
| Back to top |
|
 |
MrSnowflake Moderator


Joined: 16 Feb 2008 Posts: 1437 Location: Flanders, Belgium
|
Posted: Thu Jan 15, 2009 2:43 pm Post subject: |
|
|
Awsome, looks great, I'm probably gonna use it in my new project, I'm currently working on.
What's the licence? GPL/Apache/BSD/pure public domain?
I have one remark: in the exceptions you throw you are talking about id attributes with the name R.id.panelContent. But the actual Id is panelContent, without the R.id. ! Just so your exceptions become more correct . |
|
| Back to top |
|
 |
pskink Senior Developer

Joined: 24 Nov 2008 Posts: 194
|
Posted: Thu Jan 15, 2009 3:26 pm Post subject: |
|
|
| MrSnowflake wrote: | Awsome, looks great, I'm probably gonna use it in my new project, I'm currently working on.
What's the licence? GPL/Apache/BSD/pure public domain?
I have one remark: in the exceptions you throw you are talking about id attributes with the name R.id.panelContent. But the actual Id is panelContent, without the R.id. ! Just so your exceptions become more correct :). |
thanks! nice to hear it... licence is: 'do what you want' :)
for exception: the check was 'stolen' from some google sources (TabHost.java IIRC) and i wanted to be consistent since they also used R.id prefix.
i'm facing minor problems with padding - hope to upload new version really soon _________________ pskink |
|
| Back to top |
|
 |
pskink Senior Developer

Joined: 24 Nov 2008 Posts: 194
|
Posted: Thu Jan 15, 2009 11:43 pm Post subject: |
|
|
hi,
this is my third version of Panel, this time i did little polishing: comments, javadocs etc, also changed a bit Panel's XML attributes
i'm experiencing small problem though (see TODOs), it is visible when content is LinearLayout, maybe some of you could help?
thanks _________________ pskink
Last edited by pskink on Thu Jan 22, 2009 8:18 pm; edited 1 time in total |
|
| Back to top |
|
 |
|
|
 |
MrSnowflake Moderator


Joined: 16 Feb 2008 Posts: 1437 Location: Flanders, Belgium
|
Posted: Fri Jan 16, 2009 10:24 am Post subject: |
|
|
| pskink wrote: | | for exception: the check was 'stolen' from some google sources (TabHost.java IIRC) and i wanted to be consistent since they also used R.id prefix. | Oh rly? . Well then, that's very good then and you may ignore, my ignorance . |
|
| Back to top |
|
 |
pskink Senior Developer

Joined: 24 Nov 2008 Posts: 194
|
Posted: Fri Jan 16, 2009 12:49 pm Post subject: |
|
|
| MrSnowflake wrote: | | Well then, that's very good then and you may ignore, my ignorance :). |
i wouldn't call it 'ignorance', rather good detective's inspection/investigation :) - good for you!
seems that my widget gets final shape - i added two XML attributes 'closedHandle' and 'openedHandle' so client's code is now MUCH simplier - see Test.java.
listener got Panel parameter which simplifies life a lot.
also added two simple getters - getHandle() and getContent().
yet, problem with measuring content still exists :( _________________ pskink
Last edited by pskink on Thu Jan 22, 2009 8:21 pm; edited 1 time in total |
|
| Back to top |
|
 |
MrSnowflake Moderator


Joined: 16 Feb 2008 Posts: 1437 Location: Flanders, Belgium
|
Posted: Fri Jan 16, 2009 1:09 pm Post subject: |
|
|
| pskink wrote: | | MrSnowflake wrote: | Well then, that's very good then and you may ignore, my ignorance . |
i wouldn't call it 'ignorance', rather good detective's inspection/investigation - good for you! | I would say not so good, as I didn't know those are the same as Google uses. On the other hand, as I didn't know this, it must mean I never encountered such an Exception, which means my coding skills are through the roof . |
|
| Back to top |
|
 |
Emmanuel7 Senior Developer

Joined: 12 Dec 2008 Posts: 161 Location: Paris
|
|
| Back to top |
|
 |
pskink Senior Developer

Joined: 24 Nov 2008 Posts: 194
|
Posted: Sat Jan 17, 2009 11:26 am Post subject: |
|
|
| Emmanuel7 wrote: | Wahooo !!
There are four of them on every sides !
Congratulation on continuing to improve your widget ! |
finally fixed the problem with measuring content dimensions.
now code not only is shorter but also MUCH MUCH simplier
also added small extra widget with animated drawables (try to "long press" top red button)
as always any comments welcome _________________ pskink
Last edited by pskink on Thu Jan 22, 2009 8:23 pm; edited 1 time in total |
|
| Back to top |
|
 |
pskink Senior Developer

Joined: 24 Nov 2008 Posts: 194
|
Posted: Sat Jan 17, 2009 9:38 pm Post subject: |
|
|
BANG!
now even i am impressed since code is yet more simple but got extra flexibility - Interpolators.
i must say Animations and Interpolators really ROCK!
cheers _________________ pskink
Last edited by pskink on Thu Jan 22, 2009 8:25 pm; edited 1 time in total |
|
| Back to top |
|
 |
pskink Senior Developer

Joined: 24 Nov 2008 Posts: 194
|
Posted: Mon Jan 19, 2009 12:07 am Post subject: |
|
|
| pskink wrote: | BANG!
now even i am impressed since code is yet more simple but got extra flexibility - Interpolators.
i must say Animations and Interpolators really ROCK!
cheers |
and how it looks like now...
anyone wanting to write tutorial?
enjoy :D _________________ pskink
Last edited by pskink on Thu Jan 22, 2009 8:26 pm; edited 1 time in total |
|
| Back to top |
|
 |
darolla Senior Developer


Joined: 25 Sep 2008 Posts: 195 Location: Dortmund, Germany
|
Posted: Mon Jan 19, 2009 10:26 am Post subject: |
|
|
hi,
very well done, mate !!!
But I've got 1 wish and 1 suggestion
wish: how about placing the new new widget above the view, using overlay technique?
suggestion: the red button animation is done using lots of PNGs. take a look at drawMagicFlame inside ColorButton.java of the Calculator sources I'll attach, the buttons are lightly transparent and the color animation is painted into the background of the button...
greetings,
darolla |
|
| Back to top |
|
 |
MrSnowflake Moderator


Joined: 16 Feb 2008 Posts: 1437 Location: Flanders, Belgium
|
Posted: Mon Jan 19, 2009 11:24 am Post subject: |
|
|
Yeah, what Darola says is true, I think you should use overlays, because now, you see that the drawer handle is beneath the listview, and you don't see the listview continue next to the handle.
I would make a tut, but I have exams now...
BTW: How do you do such overlay stuff darola?  |
|
| Back to top |
|
 |
|