Posts

Showing posts from March, 2016

android fragment internal notes

Image
Android fragment is really awesome. somehow i kept on forgetting how to implement it after a few weeks down the road. :)

Full source code for this is available in github.

Simple Fragment 

To create a basic fragment on your activity that looks like this :-


Say this is a Fragment A and when you swipe, it goes to Fragment 2.

To create this simple layout, you need

a) ViewPager on your layout.



b) Create a FragmentPagerAdapter



c) Of course your fragments.



d) Tied the Viewpager to Fragment Pager Adapter - There is only 3 liner to tied our fragments layout together as shown below :-




Hopefully i won't forget about this implementation.


Tab with Fragment 

Let's have some fun with tab fragment.

For this case, we need to do all above with one step to add a control in your AppBarLayout called TabLayout.



So, please refer to step a to d above.

Tying it all together with the follow code :-











javascript prototype and __proto__

Javascript prototype is pretty simple, once we have a hang of it. It is used to implement object inheritance. To get started, lets have a look at code below :-












javascript bind & currying

Javascript bind is really useful to help

a) resolving this keyword and issues

b) currying

lets look at a very simple scenario. We would like to create a method that uses "this" keyword. Next we are going to invoke it via "bind" and shows us how it is done.



Next, we will look at currying.

Currying gives you the ability to defer from providing all arguments when trying to invoke a function.  So you can provide one and then the next argument.

Lets see this in our next example.




Installing Google Play servicse on Xamarin Android Player

When you start development on Xamarin targeting Android, chances are you need to test it on an emulator. So comes Android Player. It is a pretty cool emulator where it gives you a better interface to create target test emulator and configure a bunch of other stuffs like battery and gps.

Besides downloading and installing Xamarin Android player. You also need to setup Google Play services on this emulator.

You can obtain Google Play services for different Android version from here.

Download and drag it in to the emulator. Once restarted, you're good to go and it will install whatever updates required to bring your emulator current.





Looking for xamarin cross platform sqlite provider try SQLite.Net-PCL

Hunting down the correct nuget packages that works for your Xamarin pcl (shared) project is not so easy. A library as common as sqlite can really squeeze some hours out of you.

A cross platform sqlite that i successfully used in my project as a shared xamarin project is :
SQLite.Net-PCL. The only catch to this is you have to install it on portable project, android target and ios target project.

The code below is only for demo purposes.

In your portable code, you probably have something like this.



In your android project, you need to add a reference to your shared project and initialize your platform specific sqlite.



In your IOS project, you need to add a reference to your shared project and you need to use the following code.