Sunday, February 23, 2014

Dynamic Count Changes in Android's ViewPager

Android's ViewPager determines the number of pages when viewPager.setAdapter(pagerAdapter)is called, and then it doesn't update that count even when pagerAdapter.notifyDataSetChanged() is called.

So if the number count of the pages in the adapter is dynamic, you need to run this code every time the number of pages changes:




Friday, February 7, 2014

Using Android's TextureView to Display Video Mirrored

Android's VideoView can only play videos straight and not mirrored.
If you want your app to play a video mirrored (for instance if the video was recorded using a front camera), you will need to use a TextureView, which can be easily mirrored by specifying android:scaleX=-1 in the XML file, or textureView.setScaleX(-1) in the code.

Here is a code sample for playing video using TextureView, with the option of displaying the video mirrored: