Tuesday, May 30, 2017

TextView.setText() - be careful with overloaded variations of this method

In Android native development, when using TextView's setText() function, one needs to be careful to use a proper overloaded version.

For example, if you provide a string as the first and only parameter of this function, it will set the label of the component to that string. This is usually what developer wants.

However, if you provde an integer as parameter, then setText() will search for a resource with corresponding Resource ID. It won't simply convert to string and display that value. If the resource is not found, it will throw the following error:

Android Resources$NotFoundException: Resource ID .... not found


Therefore, double check this function:)

ADT - unable to deploy to a Genymotion virtual device

Scenario:

You try to deploy your Android for debugging to a Genymotion virtual phone. Eclipse ADT doesn't react to that action. In the bottom right corner you can see "Android SDK Loader" and nothing like "Launching YOUR APP NAME".

What can be wrong?

Check this:

Make sure your adb is connected to the phone.

If it is, then go to Genymotion window, click inside of it, and press ESC on keyboard, to awake it from sleep. That usually helps. Try to re-run (re-deploy) your app from Eclipse ADT again.

Monday, May 29, 2017

ReactJS - Animating with ReactCSSTransitionGroup

Here are a few very important reminders for ReactJS CSS3 animations using ReactCSSTransitionGroup:

1. Your ReactCSSTransitionGroup should be mounted (rendered) before the content that should be dynamically changed.
This means that ReactCSSTransitionGroup and it's child element(s) must not appear at the same action. For example, if both ReactCSSTransitionGroup and it's child element get mounted at the time when property prop1 gets changed, your animation won't work.

So, child elements need to be mounted later then their parent ReactCSSTransitionGroup.


2. Any change of the child elements visibility must come with it's own unique key. If the child elements have no unique keys, the animations won't appear at all!



Here is a working example:

START OF RENDER FUNCTION


....
....


  var curScreen= this.props.curScreen;

    let outerContainer=null;

    if(curScreen!=null){
       // alert("It is not null. I'm mounting it...");


        outerContainer=(
            <div className={'rc-container-outer ' + curScreen}  key={curScreen+"-screen-step"}>


                <div className='panel panel-default'>
                    <div className='panel-body'>

                        <ProgressBar />




                        <StepContainer curScreen={this.props.curScreen} />







                    </div>
                </div>

            </div>

        );



    }
    else{

        outerContainer=<p  key="22aaaa1">Loading..</p>;
       // alert("It is null....");
    }



....
....
....


                        <ReactCSSTransitionGroup
                            transitionName="rct"



                        >

                                {outerContainer}




                        </ReactCSSTransitionGroup>



....
....

END OF RENDER FUNCTION

Monday, May 22, 2017

WP HTTP Error 403 can be raised by Invalid URL

If your WP Admin replies with http error code 403, and an error message like this:
"Sorry, you are not allowed to access this page"
,
and if you cannot find out the cause for this, check the url you are trying to access. Maybe it is not valid.

In example, this url will generate HTTP status 403:
http://localhost/wptest1/wp-admin/admin.php?page=run-connector?a=3

This will be ok:
http://localhost/wptest1/wp-admin/admin.php?page=run-connector&a=3

PSR-1 and PSR-2 coding standards for PHP

Visual aspects of code play a significant role in raising or drowning developer's productivity. In case that there's too much clutte...