Posts

Creating Bottom Navigation in Android

Image
What is Bottom Navigation? Bottom navigation bars make it easy to explore and switch between top-level views in a single tap. —  Material Design spec This helps developers opt for Bottom Navigation, instead of a Navigation Drawer. If you have about four top-level navigation items, its ideal to use Bottom Navigation. Otherwise, go for a Navigation Drawer. We don’t want the Bottom Navigation looking too crowded now, do we? This was already common for iOS apps. But now, a lot of Android apps have started adapting this. To name a few, the YouTube app recently made the switch. YouTube app’s simplified navigation with Bottom Bar When to use? A Bottom Navigation is best used when you have three to five top-level navigation items of similar importance. Until now, the default, go-to navigation solution is the  Navigation Drawer . Would you agree? Grab all your screens, throw them in the Navigation Drawer and we’re done. I don’t blame you. Once upon a t...

Checking the version of application which I am currently using in my app.

Checking the version is because we have to make the users to update the application so that there is no error when we change the scripts from the server. Use: try { PackageInfo pInfo = this . getPackageManager (). getPackageInfo ( getPackageName (), 0 ); String version = pInfo . versionName ; } catch ( PackageManager . NameNotFoundException e ) { e . printStackTrace (); } And you can get the version code by using this int verCode = pInfo . versionCode ;

Shifting from normal PHP scripts to PDO Scripts.

PHP Scripts are used a lot but on changing the trend is the new PDO Scripts. Moreover shifting from normal servers to AWS server i.e Amazon Web Services then we have to use PDO scripts. There are a lot of new things to do in PDO Scripts but some main points are to be followed while converting them. Retrival - mysql_query is changed with $DBH->query()  where $DBH is the reference variable of the Object in PDO setFetchMode(FETCH_MODE::ASSOC); This mode is used for the retrieval of associative array Insertion and Updation-  For insertion and updation prepare statements are used. Statements are prepared using the command as shown. There is an array which is used for the creation of prepared statements. $array=array("Values"); $DBH->prepare("Prepare Statement");

What's the difference between commit() and apply() in Shared Preference

apply()  was added in 2.3, it commits  without  returning a boolean indicating success or failure. commit()   returns   true   if the save works,   false   otherwise. apply()  was added as the Android dev team noticed that almost no one took notice of the return value, so apply is faster as it is asynchronous commit()   writes the data   synchronously   (blocking the thread its called from). It then   informs  you about the success of the operation. apply()   schedules the data to be written   asynchronously . It   does not inform   you about the success of the operation. If you save with  apply()   and   immediately read   via any getX-method, the   new   value will be returned! If you called   apply()   at some point and it's still executing, any calls to   commit()   will block until all apply-calls and its own commit are finished. ...

Transactions in SQL

A transaction is a unit of work that is performed against a database. Transactions are units or sequences of work accomplished in a logical order, whether in a manual fashion by a user or automatically by some sort of a database program. A transaction is the propagation of one or more changes to the database. For example, if you are creating a record or updating a record or deleting a record from the table, then you are performing a transaction on that table. It is important to control these transactions to ensure the data integrity and to handle database errors. Practically, you will club many SQL queries into a group and you will execute all of them together as a part of a transaction. Properties of Transactions Transactions have the following four standard properties, usually referred to by the acronym  ACID . Atomicity  − ensures that all operations within the work unit are completed successfully. Otherwise, the transaction is aborted at the point of failure a...

Lottie Animation in Android

Gradle is the only supported build configuration, so just add the dependency to your project  build.gradle  file: dependencies { ... compile 'com.airbnb.android:lottie:2.2.5' ... } Lottie supports ICS (API 14) and above. The simplest way to use it is with LottieAnimationView: <com.airbnb.lottie.LottieAnimationView android:id="@+id/animation_view" android:layout_width="wrap_content" android:layout_height="wrap_content" app:lottie_fileName="hello-world.json" app:lottie_loop="true" app:lottie_autoPlay="true" /> Or you can load it programmatically in multiple ways. From a json asset in app/src/main/assets: LottieAnimationView animationView = ( LottieAnimationView ) findViewById ( R . id . animation_view ) ; animationView . setAnimation ( "hello-world.json" ) ; animationView . loop ( true ) ; animationView . playAnimation ( ) ; ...