Sunday, 29 May 2016

This week 7/2016

This week I finished configure fragments in my simple application. As I mentioned that a filed marked as a number field is associated with a String type of model attribute. If you need to associate your field with other time it is required to create your own binder method.

A long time took me to find out how to make unusual binder method for spinner.  In my case, I needed to bind a view action to a model. I used standard spinner listener to update my model but it wasn't a final solution. The best was to create your own binding method with a special annotations contains used in XML parameters. It is possible to bind more than one parameter at once.

ex.

    @BindingAdapter({"bind:enumElements", "bind:selected"})
    public static <T> void spinnerEnumBinnder(Spinner view, Enum<?>[] enumClass, T selected) {
        if (view.getAdapter() == null) {
            loadEnums(view, enumClass);
        }
        .....
    }


And than it is needed to add in layout XML:

<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:bind="http://schemas.android.com/apk/res-auto">
    <data>
        <variable name="linkName" type="org.example.ModelObject" />
    </data>

    <LinearLayout android:orientation="vertical" tools:context="org.example.ParamFragment">
        <Spinner
            android:id="@+id/objectType"
            bind:selected="@{linkName.type}"
            bind:enumElements="@{linkName.deviceTypes}"
            android:layout_gravity="center_horizontal|top"
            android:spinnerMode="dropdown" />

    </LinearLayout>
</layout>

Sunday, 22 May 2016

This week 6/2016

Android - to be continued

In my project I used Fragments to could reuse fragments and to improve performance during switching between screens. Managing fragments it is important to care what is added to which object. Ex. I had problems with hiding and showing fragment because I added it to it self. 

Other area explored by me was testing Android application. 
- Unit tests - the same as for desktop/j2ee application tests
- UI test - there is a tool called uiautomatentest - I haven't used it yet. It can send to Android application events as touches, finger moves etc.

At the end I collected some best practices to develop in Android:
1) don't execute long process task in UI thread - since Android 3.x some IO tasks will throw an exception then they are used in the same thread as UI.
2) prefer to use a service than an asyncTask. During memory cleaning at first are killed asyncTask and only when there is too little memory services are killed.
3) give your application permission only it needs. Application will be safer.
4) store application and user data on phone, avoid save it on external memory.
Now, all hands to the pumps!

Saturday, 14 May 2016

This week 5/2016

Android - another meeting.

This is my another meeting with the Android development (this time with SDK v19). Last time I was coding for Android 2.3. It was 3-4 years ago.
At the beginning I checked what changed in architecture and developing Android applications. From my point of view there isn't any differences. The same as 3 years ago main activity extends Activity object. This time in my project I used fragments for fluent navigation and reuse some parts of code in a activity.

The Android promotes to use free of charge based on JetBrain product IntelliJ Idea - Android Studio IDE. Tool has good Gradle support.

I found one useful library to bind data between view and activity/model. It is possible to bind string object but also it is possible to create your own data converter and use it in layout xml. During creation of binding I founds some problems as:
1) from model I couldn't execute refreshing only one element of a data model
2) binding didn't worked until I used in xml following construction of calling variable @={pojoObjectAliasFromTagData.attribute} - on Android page is missing equal sign.

Wednesday, 4 May 2016

This week 4/2016

Last two weeks I explored Google looking for some libs to support IP camera in a linux environment. I found two or there libs  but any so good to describe some of them.
The main problem is, they don't support RTSP which is the most important for me. I'd like to allow my application two ways communication as it is possible in the Windows version of attached application. I found one native libs dedicated for Android but it doesn't work with my linux kernel.
Request of snapshot or fetch MJPG stream isn't enough for me.
Anyway I have other question. Is it possible to tunnel RTSP stream in https SSL connection?
Nowadays I know that best way to see a steam from my camera is to connect with it by VPN and use VLC to watch video.

Tuesday, 19 April 2016

This week 3/2016

It is my first meeting with Selenium. I didn't know how to start, finally I watched and read a few tutorials. Than I installed the Selenium plugin for Firefox. I was looking for a plugin for Chrome but one plugin I found isn't so useful as this in Firefox.
Than I recorded my first test and exported to a Java class. Hm.. I found six different options of exporting my record to Java code. I can choose one of a few frameworks and type of testing path - local or remote. The plugin allow to  generate Java code dedicated for old Selenium libraries bellow 3 version (it is deprecated code in version 2.52) and developing type for future 3rd version of  Selenium libraries (WebDriver).

I tried all possible combinations except dedicated for TestNG framework.
Finally I can compare some common functionality. Below I  present main difference.
Old SeleniumWebDriver
Selenium interface is deprecated and will be removed in 3.x version
Supports regular expressions in disabled native mode/td>Till now I didn't find any way to localise elements by regular expressions by xpath
All actions are accessible by one interfaceFunctionality of old interface is available by a few separated classes


Next my question was, how can I execute a test generated by IDE. Is it possible to run it from maven and what I need to run.
The IDE generated me a simple test class, in which I updated example package path. Class can be executed as unit test. However it is required to have run test environment for pass a test. I found no other way to do it.

Monday, 4 April 2016

This week 1/2016

Today I'd like to get to know what is done in subject of creating unit test for pl/SQL scripts. 4 years ago I created some unit test for my code. I didn't use any framework or tools. It was just a other package with tests.

However I am writing what new I was learned... Today I read article about how to write unit test in Oracle SQL Developer. This part of development has it own tools, which support preparing and rollback data. Collects statistics an probably much more. However writing unit test in pl/SQL is something unusual and most developers don't do that. Even PL/SQL developers.

Second subject is testing AngularJs UI. As I checked it is possible to test UI with ProtractoJS. Protractor can execute connection and even do snapshot. I haven't tried yet but it looks promising.