Posts

Showing posts from September, 2021

Android - RecyclerView - LinearLayoutManager.HORIZONTAL

Image
Some user interfaces could be more interesting when elements are displayed horizontally  than vertically, which is the standard  behavior for most View objects (GUI components). However, using  RecyclerView  is very simple to adjust this behavior for showing elements  horizontally, what could be set with a simple parameter informed in its constructor method. You can see one example at the code below: RecyclerViewAdapterForProducts ca = new RecyclerViewAdapterForProducts( p .getProducts()); RecyclerView cv = this .findViewById( R . id . recycler_view ); cv .setLayoutManager( new LinearLayoutManager( this , LinearLayoutManager . HORIZONTAL , //LinearLayoutManager.VERTICAL true ) //left to right OR right to left ); cv .setAdapter( ca ); Basically the second parameter may inform if the element has to be displayed horizontally (LinearLayoutManager.HORIZONTAL) or vertically (LinearLayoutManager.VERTICAL). You can see a video class presenting the usage...

Drawer - Building menus in your Flutter APP

Image
  Menus are a quite important part of any APP, because it makes possible to users to navigate through the APPs screens. For building Menus with Flutter a simple alternative is based on the usage of Drawer class. In the block of code below, you can see it is just a Widget, composed by a header, with its title, and then can have a set of ListTile widgets, which will represent it menu item. These items may be composed by icons, titles, and of course the action that is triggered with they are clicked.   c lass NavDrawer extends StatelessWidget {   @override   Widget build ( BuildContext context) {     return Drawer (       child: ListView (         padding: EdgeInsets . zero ,         children: < Widget >[           DrawerHeader (             ...

Renaming downloaded files using the download attribute of anchor HTML tag

Image
  Sometimes we need to adjust the file name that is going to be download by users. It may happen because the data source provides the file with strange names that sometimes is not friendly to users. This file renaming could be very simple implemented using the download attribute of <a> tag. It could be utilized as in the example below: < html >   < body >      < h1 > Usage of download </ h1 >      < a   href = "https://www.w3.org/TR/CSS22/css2.pdf" > CSS specification </ a >      < br   />      < a   href = "https://html.spec.whatwg.org/print.pdf"   download = "html_specification.pdf" >         HTML specification - download with name "html_specification.pdf"      </ a > </ body >   ...

MongoDb and Node.js: Listing server databases

Image
  Certain applications needs to identify the existing database instances in a certain database server. For this purpose, the database libraries provides mechanisms to identify metadata over its database instances, as its name, size on disk and amount of stored records/documents.   For identifying the existing databases in a mongodb server connection from node.js programming language you may run a code like this example below: //npm install mongodb   const  { MongoClient } =  require ( 'mongodb' ); const   uri  =  "mongodb://localhost:27017/" ; //$ mongo mongodb://<host>:<port> const   client  =  new   MongoClient ( uri );   client . connect (). then ( function (){      //client.db().      client . db (). admin (). listDatabases (). then ( function ( databases ){          console ....

Flutter: Performing HTTP Requests with DART

Image
  An alternative to consume data from external data source within a Flutter APP is through the performance of HTTP Requests. For this purpose, the first step is to import the http package, include a new dependency in pubspec.yaml file.   The you also has to include the permission to allow your APP to access internet. In case of ANDROID app, add a this permission statement in AndroidManifest.xml. <uses-permission android:name="android.permission.INTERNET" />     Now you are ready to perform HTTP requests. In a .dart file include the following dependencies: import 'package:http/http.dart' as http ; //perform http request import 'dart:convert' ; // convert response string to JSON (map)   Now you are able to perform the HTTP request to a certain endpoint using a code like the one in the method below: performHTTPRequest () async {   String output = "" ;   final response = await http .get( Uri . parse ( 'https://jsonp...

Flutter: Creating dynamic Widgets in screen based on data source

Image
It is very common we have to develop APP widgets which the elements have to be dynamically created based on a certain data set. And when programming with Flutter, it is not different. Basically a Widget is composed of a list of another Widgets, which normally are pre-defined, as we can see in the example below: body: Center (   child: Column (     mainAxisAlignment: MainAxisAlignment . center ,     children: < Widget >[       Text (         ' $ name ' ,         style: Theme . of (context). textTheme . headline4 ,       ),       Text (         ' $ email ' ,         style: Theme . of (context). textTheme . headline6 ,       ),       Text (      ...