Pages

26 Nov 2013

Create a flexible link to open Google Play or your own App from web browser in Android

Today I learnt a completely new thing as the title says it all, so I want to note it here for later uses.
So how to do?

In manifest.xml:
        <activity 
            android:label="@string/activity_label"
            android:name="com.your.package.ActivityName">
            <intent-filter>
                 <data
                      android:host="your-domain-or-whatever.com"
                      android:scheme="your-own-scheme" />
                 <action android:name="android.intent.action.VIEW" />
                 <category android:name="android.intent.category.BROWSABLE" />
                 <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity> 

And your link should look like:
<a href="intent://your-domain-or-whatever.com/?param1=value1&amp;param2=value2#Intent;scheme=your-own-scheme;package=com.your.app.package;end">OPEN APP OR GOOGLE PLAY</a>

The last thing is catching parameters in your com.your.package.ActivityName. In onCreate of the Activity:
 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.your_activity_layout);
  Uri mUri = getIntent().getData();
  String value1 = mUri.getQueryParameter("param1");
  String value2 = mUri.getQueryParameter("param2");
 }


That's all, bye xD!
P/S: Oh yeah, I just found this one too: https://developers.google.com/chrome/mobile/docs/intents, check it out!

21 Jul 2013

Fancier Vim

Wow, it's been a while I haven't blogged anything, I know!

I have just been busy with learning Japanese, it's a hard language to learn, but it's even harder when I need to learn it under pressure...
Well, that does suck, but at least I'm still alive :)

Lately, I tried to get used to Vim and I think I fell in love with it. And today, I spent my whole precious Saturday to get to know it more, and this is a result:



Basically, above result is just combination of:
It's not really cool yet, but it's late now, I need to sleep and continue learning Japanese tomorrow :(

Not really cool yet, but it's late now, I need to sleep :D
さようなら!

6 Jun 2013

My Vim configuration

Recently, I got used to Vim, and it's really cooooooooool and it looks way so professional :D
I think I will keep it as my favorite text editors ;)

Anyway, I would like to save and share my Vim configuration here and it will be updated as  soon as I found something new ;)


Copy following configuration into your ~/.vimrc or ~/.exrc (well, I'm really not sure which one will be loaded by Vim :D)

"[Basic]
syntax on                               "turn syntax on
set number                              "show line number
set autoindent                          "turn auto indent on
set tabstop=4                           "set tab = 4 spaces
set shiftwidth=4                        "set tab when use > or < = 4 spaces
set colorcolumn=81                      "show margin line
set cursorline                          "hightlight current line

"[OmniCompletion]
autocmd FileType python set omnifunc=pythoncomplete#Complete
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
autocmd FileType c set omnifunc=ccomplete#Complete
autocmd FileType perl set omnifunc=perlcomplete#Complete
"change ^x^o to ^space
inoremap   pumvisible() \|\| &omnifunc == '' ?
\ "\C-n>" :
\ "\C-x>\C-o>=pumvisible() ?" .
\ "\"\\c-n>\\c-p>\\c-n>\" :" .
\ "\" \\bs>\\C-n>\"\"
imap  

17 Apr 2013

Some useful GIT commands

View unpushed commits
git log --branches --not --remotes

Make git command line colorful
git config --global --add color.ui true 

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: https://github.com/mrleolink/SimpleInfiniteCarousel. 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: http://www.ubuntudz.com/2010/10/how-to-host-files-on-google-javascript.html, 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.