andbook!.pdf - Learning Android Get an anddev.org - Android-Shirt Back to index
anddev.org Header Logo
FAQ Search Top rated articles Browse Feeds anddev.org - Authors Contact Details Register Log in

new widget - Panel

Goto page 1, 2, 3, 4, 5  Next
 
       anddev.org - Android Development Community | Android Tutorials | Index -> View, Layout & Resource Problems
Author Message
pskink
Senior Developer
Senior Developer


Joined: 24 Nov 2008
Posts: 194

PostPosted: Wed Jan 14, 2009 11:59 pm    Post subject: new widget - Panel Reply with quote

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
View user's profile Send private message
Emmanuel7
Senior Developer
Senior Developer


Joined: 12 Dec 2008
Posts: 161
Location: Paris

PostPosted: Thu Jan 15, 2009 2:05 am    Post subject: Reply with quote

Really nice, congratulations !
I think it will interest a lot of people here !

Just two (small) points ( yes, I really did read your code Smile ) :
* 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 Smile
* ( 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
View user's profile Send private message Visit poster's website
pskink
Senior Developer
Senior Developer


Joined: 24 Nov 2008
Posts: 194

PostPosted: Thu Jan 15, 2009 12:32 pm    Post subject: Reply with quote

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
View user's profile Send private message
MrSnowflake
Moderator
Moderator


Joined: 16 Feb 2008
Posts: 1437
Location: Flanders, Belgium

PostPosted: Thu Jan 15, 2009 2:43 pm    Post subject: Reply with quote

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 Smile.
Back to top
View user's profile Send private message
pskink
Senior Developer
Senior Developer


Joined: 24 Nov 2008
Posts: 194

PostPosted: Thu Jan 15, 2009 3:26 pm    Post subject: Reply with quote

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
View user's profile Send private message
pskink
Senior Developer
Senior Developer


Joined: 24 Nov 2008
Posts: 194

PostPosted: Thu Jan 15, 2009 11:43 pm    Post subject: Reply with quote

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
View user's profile Send private message
MrSnowflake
Moderator
Moderator


Joined: 16 Feb 2008
Posts: 1437
Location: Flanders, Belgium

PostPosted: Fri Jan 16, 2009 10:24 am    Post subject: Reply with quote

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? Smile. Well then, that's very good then and you may ignore, my ignorance Smile.
Back to top
View user's profile Send private message
pskink
Senior Developer
Senior Developer


Joined: 24 Nov 2008
Posts: 194

PostPosted: Fri Jan 16, 2009 12:49 pm    Post subject: Reply with quote

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
View user's profile Send private message
MrSnowflake
Moderator
Moderator


Joined: 16 Feb 2008
Posts: 1437
Location: Flanders, Belgium

PostPosted: Fri Jan 16, 2009 1:09 pm    Post subject: Reply with quote

pskink wrote:
MrSnowflake wrote:
Well then, that's very good then and you may ignore, my ignorance Smile.

i wouldn't call it 'ignorance', rather good detective's inspection/investigation Smile - 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 Very Happy.
Back to top
View user's profile Send private message
Emmanuel7
Senior Developer
Senior Developer


Joined: 12 Dec 2008
Posts: 161
Location: Paris

PostPosted: Sat Jan 17, 2009 2:58 am    Post subject: Reply with quote

Wahooo !!

There are four of them on every sides !

Congratulation on continuing to improve your widget !

_________________
Emmanuel
My Android development blog : http://androidblogger.blogspot.com/
My application site : http://www.alocaly.com
Back to top
View user's profile Send private message Visit poster's website
pskink
Senior Developer
Senior Developer


Joined: 24 Nov 2008
Posts: 194

PostPosted: Sat Jan 17, 2009 11:26 am    Post subject: Reply with quote

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
View user's profile Send private message
pskink
Senior Developer
Senior Developer


Joined: 24 Nov 2008
Posts: 194

PostPosted: Sat Jan 17, 2009 9:38 pm    Post subject: Reply with quote

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
View user's profile Send private message
pskink
Senior Developer
Senior Developer


Joined: 24 Nov 2008
Posts: 194

PostPosted: Mon Jan 19, 2009 12:07 am    Post subject: Reply with quote

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
View user's profile Send private message
darolla
Senior Developer
Senior Developer


Joined: 25 Sep 2008
Posts: 195
Location: Dortmund, Germany

PostPosted: Mon Jan 19, 2009 10:26 am    Post subject: Reply with quote

hi,

very well done, mate !!!

But I've got 1 wish and 1 suggestion Wink

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
View user's profile Send private message
MrSnowflake
Moderator
Moderator


Joined: 16 Feb 2008
Posts: 1437
Location: Flanders, Belgium

PostPosted: Mon Jan 19, 2009 11:24 am    Post subject: Reply with quote

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? Smile
Back to top
View user's profile Send private message
Display posts from previous:   
       anddev.org - Android Development Community | Android Tutorials | Index -> View, Layout & Resource Problems All times are GMT + 1 Hour
Goto page 1, 2, 3, 4, 5  Next
Page 1 of 5

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


© 2007, Android Development Community
All rights reserved.
Powered by phpBB.