28 Feb 2013

Create simple infinite carousel in Android with ViewPager

At first I thought it's easy, someone must have implemented it already, but after searching for it on Google, I got no luck, nobody has done and shared it on the Net, so I decided to make it myself.

I read some posts like:

So I implemented it as you can see in below video:


The main idea is:
  • Use ViewPager as the main view with pages are Fragment, then use ViewPager.setPageMargin(int) to set margin as a negative number, so the next and previous pages of the selected page will be showed up.
  • Override the layout which is the root view of Fragments to create scale animation.
  • Make a little hack in FragmentPagerAdapter so we can fling infinitely to both directions of the ViewPager.

For more information, you guys can get the source code here: I tried to comment as much as possible in source code, so I hope you understand my idea.

By the way, I don't think it's the best solution to implement the carousel pattern, so if you have any idea or there's something you don't understand about what I code, just drop me a line :)

24 Feb 2013

[SmartSVN] How to host files on Google Code (javascript, css, html, ...) and get a permanent, non-redirecting and bandwidth-generous hotlink

Hell yeah, finally I've found a "safe" place to put my stuffs for my site (like html, javascript, css... files), it's Google Code :D

Well, first of all, I just want to let you know I got the know-how from this site:, and I recommend you to read it before start with this post.

Currently, I'm using Windows 8 and already have SmartSVN installed, that means I don't have SVN command. It took me a while to figure out how to change mime-type before commit by SmartSVN, so I would like to note it here just in case I forget how to do it :D
OK, let's go :)

Step1: Add your file to stage

Step 2: Right click on the file -> Properties -> Edit Properties...

Step3: Choose existed property (svn:eol-style) -> click Edit -> Edit like the following screenshot (remember to change "Curren Value" to: text/css for ".css" file, text/html for ".htm" and ".html" files, text/javascript for ".js" files...

Step4: OK -> OK -> Commit file.