问:
How to make onTouch do nothing with Action_up
I am making an app to control a toy car using my smart phone and arduino, i managed to connect to the bluetooth and module and test with an LED lights and everything is fine. I only have one concern, supposedly i want the car to move forward from on Touch method, like this code (but this one is for LED light)

```<code>LED_On.setOnTouchListener(new View.OnTouchListener(){
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_DOWN) {
                LEDOn();
                return true;
            } else if (event.getAction() == MotionEvent.ACTION_UP) {
                LEDOff();
                return false;
            }
            return false;
        }
    });
</code>```

Now my problem is that i want a method or a technique to make the app do nothing when i remove my hand from the touch screen, because right now i am making a separate method for each Action_Down and Action_UP, which makes me specify a different letter each time to send to the arduino to make the changes in the toy car, and by doing so i will have tons of letters which is not convenient.

```<code>public void LEDOn(){
    // turn LED On
    if (btSocket!=null)
    {
        try
        {
            btSocket.getOutputStream().write("F".toString().getBytes());
        }
        catch (IOException e)
        {
            msg("Error");
        }
    }
}
</code>```

Also if someone can explain how does multitouch works exactly, it would be much appreciated.

答:
For anyone facing the same problem with making an Rc controller that was my approach to fix it.

I used this code to send z character whenever i am doing an Action up, for example i touched the forward button and then released, when i release i will send z character.

```<code>if(btSocket!=null){
        try
        {
            btSocket.getOutputStream().write("z".toString().getBytes());
        }
        catch (IOException e)
        {
            msg("Error");
        }
    }
</code>```

This is the method for my backward onTouch.

```<code>downView.setOnTouchListener(new View.OnTouchListener(){
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_DOWN){
                downOn();
                return true;
            } else if (event.getAction() == MotionEvent.ACTION_UP) {
                directionsOff();
                return true;
            }
            return false;
        }
    });
</code>```

This is the method to send character D

```<code>public void downOn(){
    // starts moving backwards
    if(btSocket!=null){
        try
        {
            btSocket.getOutputStream().write("D".toString().getBytes());
        }
        catch (IOException e)
        {
            msg("Error");
        }
    }
}
</code>```

This is the arduino code i used, i was testing on LEDs.

```<code>if (state == 'D') {
  digitalWrite(LED, HIGH);
}else if (state == 'F') {
  digitalWrite(LED2, HIGH);
}else{
  digitalWrite(LED, LOW);
  digitalWrite(LED2, LOW);
}
</code>```

I hope i made it clear enough.

Body:
I am making an app to control a toy car using my smart phone and arduino, i managed to connect to the bluetooth and module and test with an LED lights and everything is fine. I only have one concern, supposedly i want the car to move forward from on Touch method, like this code (but this one is for LED light)

LED_On.setOnTouchListener(new View.OnTouchListener(){
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_DOWN) {
                LEDOn();
                return true;
            } else if (event.getAction() == MotionEvent.ACTION_UP) {
                LEDOff();
                return false;
            }
            return false;
        }
    });

Now my problem is that i want a method or a technique to make the app do nothing when i remove my hand from the touch screen, because right now i am making a separate method for each Action_Down and Action_UP, which makes me specify a different letter each time to send to the arduino to make the changes in the toy car, and by doing so i will have tons of letters which is not convenient.

public void LEDOn(){
    // turn LED On
    if (btSocket!=null)
    {
        try
        {
            btSocket.getOutputStream().write("F".toString().getBytes());
        }
        catch (IOException e)
        {
            msg("Error");
        }
    }
}

Also if someone can explain how does multitouch works exactly, it would be much appreciated.

Body:
For anyone facing the same problem with making an Rc controller that was my approach to fix it.

I used this code to send z character whenever i am doing an Action up, for example i touched the forward button and then released, when i release i will send z character.

if(btSocket!=null){
        try
        {
            btSocket.getOutputStream().write("z".toString().getBytes());
        }
        catch (IOException e)
        {
            msg("Error");
        }
    }

This is the method for my backward onTouch.

downView.setOnTouchListener(new View.OnTouchListener(){
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_DOWN){
                downOn();
                return true;
            } else if (event.getAction() == MotionEvent.ACTION_UP) {
                directionsOff();
                return true;
            }
            return false;
        }
    });

This is the method to send character D

public void downOn(){
    // starts moving backwards
    if(btSocket!=null){
        try
        {
            btSocket.getOutputStream().write("D".toString().getBytes());
        }
        catch (IOException e)
        {
            msg("Error");
        }
    }
}

This is the arduino code i used, i was testing on LEDs.

if (state == 'D') {
  digitalWrite(LED, HIGH);
}else if (state == 'F') {
  digitalWrite(LED2, HIGH);
}else{
  digitalWrite(LED, LOW);
  digitalWrite(LED2, LOW);
}

I hope i made it clear enough.


来源: stackexchange

问:
Regular Expression that matchis something or nothing
I am trying to find a value between two HTML tags i.e:

There can either be a word character \w or nothing (not even a space between the >< closing an opening bracket.

So I am trying this /[\w{1,}|]<\/td>/ but it is not working.

This is for php, and yes, I am well aware of some people warning against parsing HTML with regular expressions ;) ...

Any help would be appreciated.

Thank you

答:
If you need to find a value between two html tags.
Please use bellow regex

```<code>(?<td>)(\w*)(?=<\/td>)
</code>```

It just match only the word or nothing in between

https://regex101.com/r/4Cy2xZ/1

ContentLicense: CC BY-SA 3.0

Body:
If you need to find a value between two html tags.
Please use bellow regex

(?<td>)(\w*)(?=<\/td>)

It just match only the word or nothing in between <td></td>

https://regex101.com/r/4Cy2xZ/1


问:
What should be a container component connected with a redux store and what should not be?
Is there any guideline for what component should be a container component connected with a redux store and what component should not be?

Probably, I should ask what kind of state needs to be an application-level state and what kind of state needs to be an component-level state.

I don't have any guideline for this yet personally, but I think these states are the candidate for an application-level state.

a state which is shared by multiple components.

hmm... that's it, isn't it?

So, back to my original question, any components that have a state shared by multiple components are the good candidate for a container component connected with a redux store?

答:
Your components should ideally just render a UI based on props. So start with a functional component. If you need lifecycle hooks, you will, of course, need a class, but try not to do this with state.

To populate the props of your component, you need a container. This is a blackbox component which takes data and marshals into the props of your component. It can get data from redux, your API, graphql, or even using HOC's from recompose.


问:
replace all word occurrence in list with index of items in another list
I have a list -

```<code>A=["hi how are you","have good day","where are you going ","do you like the place"]
</code>```

and another list -

```<code>B=["how","good","where","going","like","place"]
</code>```

List B includes some of words that exist in list A.
I want to replace all words in List B that occur in List A by their index in list B. If word doesn't exist replace it with 0

So list A after the replacement should be

```<code>["0 1 0 0","0 2 0","3 0 0 4","0 0 5 0 6"]
</code>```

I tried using for loop but it's not effiecent as my list length is > 10000. I also tried using map function but i wasn't successful

Here is my attempt :

```<code>for item in list_A:
    words=sorted(item.split(), key=len,reverse=True)
    for w in word:
        if w.strip() in list_B:
            item=item.replace(w,str(list_B.index(w.strip())))
        else:
            item=item.replace(w,0)
</code>```

答:
This is in Python 3.x

```<code>A=["hi how are you","have good day","where are you going ","do you like the place"]
B=["how","good","where","going","like","place"]
list(map(' '.join, map(lambda x:[str(B.index(i)+1) if i in B else '0' for i in x], [i.split() for i in A])))
</code>```

Output:

```<code>['0 1 0 0', '0 2 0', '3 0 0 4', '0 0 5 0 6']
</code>```

Body:
I have a list -

A=["hi how are you","have good day","where are you going ","do you like the place"]

and another list -

B=["how","good","where","going","like","place"]

List B includes some of words that exist in list A.
I want to replace all words in List B that occur in List A by their index in list B. If word doesn't exist replace it with 0

So list A after the replacement should be

["0 1 0 0","0 2 0","3 0 0 4","0 0 5 0 6"]

I tried using for loop but it's not effiecent as my list length is > 10000. I also tried using map function but i wasn't successful

Here is my attempt :

for item in list_A:
    words=sorted(item.split(), key=len,reverse=True)
    for w in word:
        if w.strip() in list_B:
            item=item.replace(w,str(list_B.index(w.strip())))
        else:
            item=item.replace(w,0)

Body:
This is in Python 3.x

A=["hi how are you","have good day","where are you going ","do you like the place"]
B=["how","good","where","going","like","place"]
list(map(' '.join, map(lambda x:[str(B.index(i)+1) if i in B else '0' for i in x], [i.split() for i in A])))

Output:

['0 1 0 0', '0 2 0', '3 0 0 4', '0 0 5 0 6']


问:
Web server behind IIS on one machine is not able to access files on other machine?
What all permissions or setting Or steps need to be done so that Web application behind IIS on one machine is able to access the files/directory on the other machine.</p>

答: An application pool in IIS has an identity (user) that runs the web site in question. This identity needs access to the files on the other machine. The identity used is often NT Authority\Network Service. So this is basically the account that needs access to the files. The Network Service account of a computer called ComputerA is called ComputerA$ when referenced on another computer. So on your file server you need to make sure that ComputerA$ (or your equivalent) has access to the files.

ContentLicense: CC BY-SA 2.5


问:
Extracting multiple xml trees from a mixed content document
I'm trying to use Python to extract multiple XML elements from a mixed-content document. The use case is an email that contains email text but also contains multiple XML trees.

Here's the example document:

```<code>Email text email text email text email text.

email signature email signature.

<?xml version="1.0"?>
<catalog>
   <book id="bk101">
      <author>Gambardella, Matthew</author>
      <title>XML Developer's Guide</title>
      <genre>Computer</genre>
      <price>44.95</price>
      <publish_date>2000-10-01</publish_date>
      <description>An in-depth look at creating applications
      with XML.</description>
   </book>
</catalog>

Email text email text email text email text.

email signature email signature.

<?xml version="1.0"?>
<catalog>
   <book id="bk101">
      <author>Gambardella, Matthew</author>
      <title>XML Developer's Guide</title>
      <genre>Computer</genre>
      <price>44.95</price>
      <publish_date>2000-10-01</publish_date>
      <description>An in-depth look at creating applications
      with XML.</description>
   </book>
</catalog>

Email text email text email text email text.

email signature email signature.

<?xml version="1.0"?>
<catalog>
   <book id="bk101">
      <author>Gambardella, Matthew</author>
      <title>XML Developer's Guide</title>
      <genre>Computer</genre>
      <price>44.95</price>
      <publish_date>2000-10-01</publish_date>
      <description>An in-depth look at creating applications
      with XML.</description>
   </book>
</catalog>

Email text email text email text email text.

email signature email signature.
</code>```

I want to extract the XML trees so they can be parsed by an XML parser in a for loop. I've perfected parsing the XML, and if I take one of the XML trees and parse it directly, it works llike a charm.

Any advise on how to extract the XML trees? This example is over-simplified as well, the email text and signatures are different in each example that I have, so the only reliable text to key on is the beginning and ending of the XML tree.

答:
The simplest way:

```<code>import re
from lxml import etree

with open('email.txt') as f:
    catalogs = ''.join(re.findall('<catalog.*?</catalog>', f.read(), re.S))
    root = etree.fromstring('<?xml version="1.0"?><root>{}</root>'.format(catalogs))
</code>```

Then you could just use root.iter('book') to iterate over all the book nodes.

Body:
I'm trying to use Python to extract multiple XML elements from a mixed-content document. The use case is an email that contains email text but also contains multiple XML trees.

Here's the example document:

Email text email text email text email text.

email signature email signature.

<?xml version="1.0"?>
<catalog>
   <book id="bk101">
      <author>Gambardella, Matthew</author>
      <title>XML Developer's Guide</title>
      <genre>Computer</genre>
      <price>44.95</price>
      <publish_date>2000-10-01</publish_date>
      <description>An in-depth look at creating applications
      with XML.</description>
   </book>
</catalog>

Email text email text email text email text.

email signature email signature.

<?xml version="1.0"?>
<catalog>
   <book id="bk101">
      <author>Gambardella, Matthew</author>
      <title>XML Developer's Guide</title>
      <genre>Computer</genre>
      <price>44.95</price>
      <publish_date>2000-10-01</publish_date>
      <description>An in-depth look at creating applications
      with XML.</description>
   </book>
</catalog>

Email text email text email text email text.

email signature email signature.

<?xml version="1.0"?>
<catalog>
   <book id="bk101">
      <author>Gambardella, Matthew</author>
      <title>XML Developer's Guide</title>
      <genre>Computer</genre>
      <price>44.95</price>
      <publish_date>2000-10-01</publish_date>
      <description>An in-depth look at creating applications
      with XML.</description>
   </book>
</catalog>

Email text email text email text email text.

email signature email signature.

I want to extract the XML trees so they can be parsed by an XML parser in a for loop. I've perfected parsing the XML, and if I take one of the XML trees and parse it directly, it works llike a charm.

Any advise on how to extract the XML trees? This example is over-simplified as well, the email text and signatures are different in each example that I have, so the only reliable text to key on is the beginning and ending of the XML tree.

Body:
The simplest way:

import re
from lxml import etree

with open('email.txt') as f:
    catalogs = ''.join(re.findall('<catalog.*?</catalog>', f.read(), re.S))
    root = etree.fromstring('<?xml version="1.0"?><root>{}</root>'.format(catalogs))

Then you could just use root.iter('book') to iterate over all the book nodes.


问:
How do I cast to an Interface / Class from Kotlin Class from String?
I get a class with Class.forName("classname").kotlin.

I know that the class implements an Interface, which is extremly simple (if you have a solution that is different from what I think, it would work great too)

```<code>interface Runner {
    fun run(): String
}
</code>```

When I try to cast my class, to use the function, like this

```<code>val result = (Class.forName("classname").kotlin as Runner).run()
</code>```

I get the following error:

```<code>kotlin.reflect.jvm.internal.KClassImpl cannot be cast to Runner
</code>```

Is there even a way to make this work? I also tried it with Class.forName("classname").kotlin.functions and then tried to execute the function from there, but I did not have success with that.

If you know the Java solution to this problem (calling a function from the class name) it may be nice to hear that too.

答:
The problem you have is that Class.forName("...").kotlin returns a KClass, which only represents a class, and isn't an instance of the class that you've referenced. To create an instance of that class, you can use createInstance():

```<code>val kclass = Class.forName("classname").kotlin
val instance = kclass.createInstance() as Runner

println(instance.run())
</code>```

Note that for createInstance to work, the class needs a constructor that can be called with no arguments (so one that has no parameters, or one that has default values for all of its parameters).

Body:
I get a class with Class.forName("classname").kotlin.

I know that the class implements an Interface, which is extremly simple (if you have a solution that is different from what I think, it would work great too)

interface Runner {
    fun run(): String
}

When I try to cast my class, to use the function, like this

val result = (Class.forName("classname").kotlin as Runner).run()

I get the following error:

kotlin.reflect.jvm.internal.KClassImpl cannot be cast to Runner

Is there even a way to make this work? I also tried it with Class.forName("classname").kotlin.functions and then tried to execute the function from there, but I did not have success with that.

If you know the Java solution to this problem (calling a function from the class name) it may be nice to hear that too.

Body:
The problem you have is that Class.forName("...").kotlin returns a KClass, which only represents a class, and isn't an instance of the class that you've referenced. To create an instance of that class, you can use createInstance():

val kclass = Class.forName("classname").kotlin
val instance = kclass.createInstance() as Runner

println(instance.run())

Note that for createInstance to work, the class needs a constructor that can be called with no arguments (so one that has no parameters, or one that has default values for all of its parameters).


问:
Error when building nginx docker
I am trying to build a docker from a fork and I am getting the following error when performing docker build  ./:

```<code>cc1: all warnings being treated as errors
make[1]: *** [objs/src/event/ngx_event_openssl.o] Error 1
objs/Makefile:748: recipe for target 'objs/src/event/ngx_event_openssl.o' failed
make[1]: Leaving directory '/tmp/nginx/nginx-1.8.0'
make: *** [install] Error 2
</code>```

On install we run

```<code>apt-get -y install libpcre3-dev zlib1g-dev libssl-dev openssl build-essential wget
</code>```

I can't find this error on google. The full error for reference as I can't find out the exact error reference I need to research:

```<code>src/event/ngx_event_openssl.c: In function 'ngx_ssl_init':
src/event/ngx_event_openssl.c:112:5: error: 'OPENSSL_config' is deprecated [-Werror=deprecated-declarations]
     OPENSSL_config(NULL);
     ^~~~~~~~~~~~~~
In file included from /usr/include/openssl/ct.h:13:0,
                 from /usr/include/openssl/ssl.h:61,
                 from src/event/ngx_event_openssl.h:15,
                 from src/core/ngx_core.h:80,
                 from src/event/ngx_event_openssl.c:9:
/usr/include/openssl/conf.h:92:1: note: declared here
 DEPRECATEDIN_1_1_0(void OPENSSL_config(const char *config_name))
 ^
src/event/ngx_event_openssl.c: In function 'ngx_ssl_rsa512_key_callback':
src/event/ngx_event_openssl.c:753:9: error: 'RSA_generate_key' is deprecated [-Werror=deprecated-declarations]
         key = RSA_generate_key(512, RSA_F4, NULL, NULL);
         ^~~
In file included from /usr/include/openssl/rsa.h:13:0,
                 from /usr/include/openssl/x509.h:31,
                 from /usr/include/openssl/ssl.h:50,
                 from src/event/ngx_event_openssl.h:15,
                 from src/core/ngx_core.h:80,
                 from src/event/ngx_event_openssl.c:9:
/usr/include/openssl/rsa.h:193:1: note: declared here
 DEPRECATEDIN_0_9_8(RSA *RSA_generate_key(int bits, unsigned long e, void
 ^
src/event/ngx_event_openssl.c: In function 'ngx_ssl_dhparam':
src/event/ngx_event_openssl.c:943:11: error: dereferencing pointer to incomplete type 'DH {aka struct dh_st}'
         dh->p = BN_bin2bn(dh1024_p, sizeof(dh1024_p), NULL);
           ^~
src/event/ngx_event_openssl.c: In function 'ngx_ssl_handshake':
src/event/ngx_event_openssl.c:1164:31: error: dereferencing pointer to incomplete type 'SSL {aka struct ssl_st}'
         if (c->ssl->connection->s3) {
                               ^~
src/event/ngx_event_openssl.c: In function 'ngx_ssl_connection_error':
src/event/ngx_event_openssl.c:1913:21: error: 'SSL_R_NO_CIPHERS_PASSED' undeclared (first use in this function)
             || n == SSL_R_NO_CIPHERS_PASSED                          /*  182 */
                     ^~~~~~~~~~~~~~~~~~~~~~~
src/event/ngx_event_openssl.c:1913:21: note: each undeclared identifier is reported only once for each function it appears in
src/event/ngx_event_openssl.c: In function 'ngx_ssl_session_cache':
src/event/ngx_event_openssl.c:2107:43: error: passing argument 2 of 'SSL_CTX_sess_set_get_cb' from incompatible pointer type [-Werror=incompatible-pointer-types]
         SSL_CTX_sess_set_get_cb(ssl->ctx, ngx_ssl_get_cached_session);
                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from src/event/ngx_event_openssl.h:15:0,
                 from src/core/ngx_core.h:80,
                 from src/event/ngx_event_openssl.c:9:
/usr/include/openssl/ssl.h:637:6: note: expected 'SSL_SESSION * (*)(struct ssl_st *, const unsigned char *, int,  int *) {aka struct ssl_session_st * (*)(struct ssl_st *, const unsigned char *, int,  int *)}' but argument is of type 'SSL_SESSION * (*)(SSL *, u_char *, int,  int *) {aka struct ssl_session_st * (*)(struct ssl_st *, unsigned char *, int,  int *)}'
 void SSL_CTX_sess_set_get_cb(SSL_CTX *ctx,
      ^~~~~~~~~~~~~~~~~~~~~~~
src/event/ngx_event_openssl.c: In function 'ngx_ssl_session_id_context':
src/event/ngx_event_openssl.c:2129:27: error: storage size of 'md' isn't known
     EVP_MD_CTX            md;
                           ^~
src/event/ngx_event_openssl.c:2195:5: error: implicit declaration of function 'EVP_MD_CTX_cleanup' [-Werror=implicit-function-declaration]
     EVP_MD_CTX_cleanup(&md);
     ^~~~~~~~~~~~~~~~~~
src/event/ngx_event_openssl.c: In function 'ngx_ssl_session_ticket_key_callback':
src/event/ngx_event_openssl.c:2864:9: error: 'RAND_pseudo_bytes' is deprecated [-Werror=deprecated-declarations]
         RAND_pseudo_bytes(iv, 16);
         ^~~~~~~~~~~~~~~~~
In file included from /usr/include/openssl/engine.h:19:0,
                 from src/event/ngx_event_openssl.h:22,
                 from src/core/ngx_core.h:80,
                 from src/event/ngx_event_openssl.c:9:
/usr/include/openssl/rand.h:47:1: note: declared here
 DEPRECATEDIN_1_1_0(int RAND_pseudo_bytes(unsigned char *buf, int num))
 ^
cc1: all warnings being treated as errors
make[1]: *** [objs/src/event/ngx_event_openssl.o] Error 1
objs/Makefile:748: recipe for target 'objs/src/event/ngx_event_openssl.o' failed
make[1]: Leaving directory '/tmp/nginx/nginx-1.8.0'
make: *** [install] Error 2
</code>```

This is the docker fork I am running https://github.com/meteorhacks/mup-frontend-server

答:
You are getting various errors and warnings here, but they aren't really about Docker or OpenSSL. If we strip away the extraneous information, here are the problems you are encountering.

```<code>error: 'OPENSSL_config' is deprecated
error: 'RSA_generate_key' is deprecated
error: dereferencing pointer to incomplete type 'DH {aka struct dh_st}'
error: dereferencing pointer to incomplete type 'SSL {aka struct ssl_st}'
error: 'SSL_R_NO_CIPHERS_PASSED' undeclared (first use in this function)
error: passing argument 2 of 'SSL_CTX_sess_set_get_cb' from incompatible pointer type
error: storage size of 'md' isn't known
error: implicit declaration of function 'EVP_MD_CTX_cleanup'
error: 'RAND_pseudo_bytes' is deprecated
</code>```

The core of the problem here is probably that you are using a legacy version of Nginx in this project. From the GitHub repository you pointed to, in install-nginx.sh:

```<code>NGINX_VERSION=1.8.0
</code>```

The current mainline version of Nginx is 1.13.2. I haven't combed through the changelogs for Nginx, but based on the errors you are receiving, it seems likely that between the 1.8 releases and the current ones, OpenSSL has deprecated various functions that Nginx 1.8 relied on. Most likely this can be solved by moving to a recent release of Nginx.

As of this writing, 1.13.2 is the current mainline, and 1.12.0 is the current stable. One of those may work better. Whether you can simply drop this in, I can't say. You may have to change something in the build scripts or the nginx config for a more recent version to work properly.

Title: Error when building nginx docker

Body:
I am trying to build a docker from a fork and I am getting the following error when performing docker build  ./:

cc1: all warnings being treated as errors
make[1]: *** [objs/src/event/ngx_event_openssl.o] Error 1
objs/Makefile:748: recipe for target 'objs/src/event/ngx_event_openssl.o' failed
make[1]: Leaving directory '/tmp/nginx/nginx-1.8.0'
make: *** [install] Error 2

On install we run

apt-get -y install libpcre3-dev zlib1g-dev libssl-dev openssl build-essential wget

I can't find this error on google. The full error for reference as I can't find out the exact error reference I need to research:

src/event/ngx_event_openssl.c: In function 'ngx_ssl_init':
src/event/ngx_event_openssl.c:112:5: error: 'OPENSSL_config' is deprecated [-Werror=deprecated-declarations]
     OPENSSL_config(NULL);
     ^~~~~~~~~~~~~~
In file included from /usr/include/openssl/ct.h:13:0,
                 from /usr/include/openssl/ssl.h:61,
                 from src/event/ngx_event_openssl.h:15,
                 from src/core/ngx_core.h:80,
                 from src/event/ngx_event_openssl.c:9:
/usr/include/openssl/conf.h:92:1: note: declared here
 DEPRECATEDIN_1_1_0(void OPENSSL_config(const char *config_name))
 ^
src/event/ngx_event_openssl.c: In function 'ngx_ssl_rsa512_key_callback':
src/event/ngx_event_openssl.c:753:9: error: 'RSA_generate_key' is deprecated [-Werror=deprecated-declarations]
         key = RSA_generate_key(512, RSA_F4, NULL, NULL);
         ^~~
In file included from /usr/include/openssl/rsa.h:13:0,
                 from /usr/include/openssl/x509.h:31,
                 from /usr/include/openssl/ssl.h:50,
                 from src/event/ngx_event_openssl.h:15,
                 from src/core/ngx_core.h:80,
                 from src/event/ngx_event_openssl.c:9:
/usr/include/openssl/rsa.h:193:1: note: declared here
 DEPRECATEDIN_0_9_8(RSA *RSA_generate_key(int bits, unsigned long e, void
 ^
src/event/ngx_event_openssl.c: In function 'ngx_ssl_dhparam':
src/event/ngx_event_openssl.c:943:11: error: dereferencing pointer to incomplete type 'DH {aka struct dh_st}'
         dh->p = BN_bin2bn(dh1024_p, sizeof(dh1024_p), NULL);
           ^~
src/event/ngx_event_openssl.c: In function 'ngx_ssl_handshake':
src/event/ngx_event_openssl.c:1164:31: error: dereferencing pointer to incomplete type 'SSL {aka struct ssl_st}'
         if (c->ssl->connection->s3) {
                               ^~
src/event/ngx_event_openssl.c: In function 'ngx_ssl_connection_error':
src/event/ngx_event_openssl.c:1913:21: error: 'SSL_R_NO_CIPHERS_PASSED' undeclared (first use in this function)
             || n == SSL_R_NO_CIPHERS_PASSED                          /*  182 */
                     ^~~~~~~~~~~~~~~~~~~~~~~
src/event/ngx_event_openssl.c:1913:21: note: each undeclared identifier is reported only once for each function it appears in
src/event/ngx_event_openssl.c: In function 'ngx_ssl_session_cache':
src/event/ngx_event_openssl.c:2107:43: error: passing argument 2 of 'SSL_CTX_sess_set_get_cb' from incompatible pointer type [-Werror=incompatible-pointer-types]
         SSL_CTX_sess_set_get_cb(ssl->ctx, ngx_ssl_get_cached_session);
                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from src/event/ngx_event_openssl.h:15:0,
                 from src/core/ngx_core.h:80,
                 from src/event/ngx_event_openssl.c:9:
/usr/include/openssl/ssl.h:637:6: note: expected 'SSL_SESSION * (*)(struct ssl_st *, const unsigned char *, int,  int *) {aka struct ssl_session_st * (*)(struct ssl_st *, const unsigned char *, int,  int *)}' but argument is of type 'SSL_SESSION * (*)(SSL *, u_char *, int,  int *) {aka struct ssl_session_st * (*)(struct ssl_st *, unsigned char *, int,  int *)}'
 void SSL_CTX_sess_set_get_cb(SSL_CTX *ctx,
      ^~~~~~~~~~~~~~~~~~~~~~~
src/event/ngx_event_openssl.c: In function 'ngx_ssl_session_id_context':
src/event/ngx_event_openssl.c:2129:27: error: storage size of 'md' isn't known
     EVP_MD_CTX            md;
                           ^~
src/event/ngx_event_openssl.c:2195:5: error: implicit declaration of function 'EVP_MD_CTX_cleanup' [-Werror=implicit-function-declaration]
     EVP_MD_CTX_cleanup(&md);
     ^~~~~~~~~~~~~~~~~~
src/event/ngx_event_openssl.c: In function 'ngx_ssl_session_ticket_key_callback':
src/event/ngx_event_openssl.c:2864:9: error: 'RAND_pseudo_bytes' is deprecated [-Werror=deprecated-declarations]
         RAND_pseudo_bytes(iv, 16);
         ^~~~~~~~~~~~~~~~~
In file included from /usr/include/openssl/engine.h:19:0,
                 from src/event/ngx_event_openssl.h:22,
                 from src/core/ngx_core.h:80,
                 from src/event/ngx_event_openssl.c:9:
/usr/include/openssl/rand.h:47:1: note: declared here
 DEPRECATEDIN_1_1_0(int RAND_pseudo_bytes(unsigned char *buf, int num))
 ^
cc1: all warnings being treated as errors
make[1]: *** [objs/src/event/ngx_event_openssl.o] Error 1
objs/Makefile:748: recipe for target 'objs/src/event/ngx_event_openssl.o' failed
make[1]: Leaving directory '/tmp/nginx/nginx-1.8.0'
make: *** [install] Error 2

This is the docker fork I am running https://github.com/meteorhacks/mup-frontend-server

Body:
You are getting various errors and warnings here, but they aren't really about Docker or OpenSSL. If we strip away the extraneous information, here are the problems you are encountering.

error: 'OPENSSL_config' is deprecated
error: 'RSA_generate_key' is deprecated
error: dereferencing pointer to incomplete type 'DH {aka struct dh_st}'
error: dereferencing pointer to incomplete type 'SSL {aka struct ssl_st}'
error: 'SSL_R_NO_CIPHERS_PASSED' undeclared (first use in this function)
error: passing argument 2 of 'SSL_CTX_sess_set_get_cb' from incompatible pointer type
error: storage size of 'md' isn't known
error: implicit declaration of function 'EVP_MD_CTX_cleanup'
error: 'RAND_pseudo_bytes' is deprecated

The core of the problem here is probably that you are using a legacy version of Nginx in this project. From the GitHub repository you pointed to, in install-nginx.sh:

NGINX_VERSION=1.8.0

The current mainline version of Nginx is 1.13.2. I haven't combed through the changelogs for Nginx, but based on the errors you are receiving, it seems likely that between the 1.8 releases and the current ones, OpenSSL has deprecated various functions that Nginx 1.8 relied on. Most likely this can be solved by moving to a recent release of Nginx.

As of this writing, 1.13.2 is the current mainline, and 1.12.0 is the current stable. One of those may work better. Whether you can simply drop this in, I can't say. You may have to change something in the build scripts or the nginx config for a more recent version to work properly.


问:
Invalid option, /FIC
I am trying to build OpenCV 3.2 using Visual studio 2017 community edition.
I am building without CUDA and all other options are kept as default.

I am getting this error while building:

```<code>Severity    Code    Description Project File    Line    Suppression State
Error   RC1103  invalid option, /FIC:/opencv/modules/videostab/src/precomp.hpp  opencv_videostab    C:\opencv\_build\modules\videostab\RC   1
</code>```

It is also happens in other modules.

BTW during Cmake stage I got this warnings:

```<code>CMake Deprecation Warning at CMakeLists.txt:81 (cmake_policy):
  The OLD behavior for policy CMP0020 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.

CMake Deprecation Warning at CMakeLists.txt:85 (cmake_policy):
  The OLD behavior for policy CMP0022 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.

CMake Deprecation Warning at CMakeLists.txt:94 (cmake_policy):
  The OLD behavior for policy CMP0026 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.
</code>```

答:
I have encountered this problem too and found a solution.
I see you have posted this question on the OpenCV specific question board.
There is also one on the github issue board as well:

https://github.com/opencv/opencv/issues/9100

http://answers.opencv.org/question/163349/invalid-option-fic/

I assume you have already used the solution posted over there but for the sake of completeness and anyone looking on Stackoverflow, here is the solution:

The fast solution is to disable precompiled headers. This will increase compilation time, but otherwise works fine:

Title: Invalid option, /FIC

Body:
I am trying to build OpenCV 3.2 using Visual studio 2017 community edition.
I am building without CUDA and all other options are kept as default.

I am getting this error while building:

Severity    Code    Description Project File    Line    Suppression State
Error   RC1103  invalid option, /FIC:/opencv/modules/videostab/src/precomp.hpp  opencv_videostab    C:\opencv\_build\modules\videostab\RC   1

It is also happens in other modules.

BTW during Cmake stage I got this warnings:

CMake Deprecation Warning at CMakeLists.txt:81 (cmake_policy):
  The OLD behavior for policy CMP0020 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.

CMake Deprecation Warning at CMakeLists.txt:85 (cmake_policy):
  The OLD behavior for policy CMP0022 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.

CMake Deprecation Warning at CMakeLists.txt:94 (cmake_policy):
  The OLD behavior for policy CMP0026 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.


问:
How to use masks while displaying names in tables using sql fuctions

if the record [name surname] it must be masked except the first two letters

if the record [name name surname] the second name must be masked too

if name and surname have only 2 letters nothing changes

答:
You can try this. I'm not very sure about how oracle will handle this query.

```<code>select concat(substr(fn,1,2),replicate("x",len(fn)-2)," ",substr(ln,1,2),replicate("x",len(ln)-2)) as CUSTOMER_NAME_SURNAME
from (select substr(CUSTOMER_NAME_SURNAME, 1, instr(CUSTOMER_NAME_SURNAME," ")) as fn,
        substr(CUSTOMER_NAME_SURNAME, -1, instr(CUSTOMER_NAME_SURNAME," ", -1)) as ln
        from table_name)
</code>```

Or, my best bet would be to split the names in other table and use substrings with replicate. And then concatenate the names. But that will make it confusing and more than one table, I guess.

Additionally, for the middle name, you can use

```<code>substr(CUSTOMER_NAME_SURNAME, instr(CUSTOMER_NAME_SURNAME," ")+1, instr(CUSTOMER_NAME_SURNAME," ",1,2)-1) as mn
</code>```

And then use CASE WHEN with the fn, mn, and ln.

Body:
You can try this. I'm not very sure about how oracle will handle this query.

select concat(substr(fn,1,2),replicate("x",len(fn)-2)," ",substr(ln,1,2),replicate("x",len(ln)-2)) as CUSTOMER_NAME_SURNAME
from (select substr(CUSTOMER_NAME_SURNAME, 1, instr(CUSTOMER_NAME_SURNAME," ")) as fn,
        substr(CUSTOMER_NAME_SURNAME, -1, instr(CUSTOMER_NAME_SURNAME," ", -1)) as ln
        from table_name)

Or, my best bet would be to split the names in other table and use substrings with replicate. And then concatenate the names. But that will make it confusing and more than one table, I guess.

Additionally, for the middle name, you can use

substr(CUSTOMER_NAME_SURNAME, instr(CUSTOMER_NAME_SURNAME," ")+1, instr(CUSTOMER_NAME_SURNAME," ",1,2)-1) as mn

And then use CASE WHEN with the fn, mn, and ln.


问:
mysql lookup table schema
What's a more detailed command for seeing table properties than show tables? In particular, I need to know what storage engines are being used in a database that I've inherited.

答:
You could query the information_schema tables directly.</p>

```<code>SELECT `table_name`, `engine`
FROM `information_schema`.`tables`
WHERE `table_schema` = 'your_db'
ORDER BY `table_name` ASC
</code>```

Title: mysql lookup table schema

Body:
You could query the information_schema tables directly.

SELECT `table_name`, `engine`
FROM `information_schema`.`tables`
WHERE `table_schema` = 'your_db'
ORDER BY `table_name` ASC


问:
New Google developer console crashes stack traces are not accurate anymore
Google has recently updated the Google Play Console, and now crashes are automatically reported.

Since almost all stack traces I got are not accurate anymore:

The stack trace is full of <OR> methods, so I guess full of possible candidates?

All the line numbers are 0

Note that I use Proguard (and not Multidex) and I strongly suspect it is the cause of the problem.

Example:

```<code>java.lang.ClassCastException:
at <<MyPackage>>.adapters.PackageRecyclerViewAdapter.getItemCount(PackageRecyclerViewAdapter.java:0)
at <OR>.getItemViewType(PackageRecyclerViewAdapter.java:0)
at <OR>.onBindViewHolder(PackageRecyclerViewAdapter.java:0)
at <OR>.onCreateViewHolder(PackageRecyclerViewAdapter.java:0)
at android.support.v7.widget.RecyclerView$Adapter.onCreateViewHolder(RecyclerView.java:0)
at <OR>.onBindViewHolder(RecyclerView.java:0)
at <OR>.onBindViewHolder(RecyclerView.java:0)
at <OR>.getItemViewType(RecyclerView.java:0)
at <OR>.getItemCount(RecyclerView.java:0)
at <OR>.onViewRecycled(RecyclerView.java:0)
at <OR>.registerAdapterDataObserver(RecyclerView.java:0)
at <OR>.onAttachedToRecyclerView(RecyclerView.java:0)
at android.support.v7.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:0)
at <OR>.bindViewHolder(RecyclerView.java:0)
at <OR>.getItemId(RecyclerView.java:0)
at <OR>.hasStableIds(RecyclerView.java:0)
at <OR>.onFailedToRecycleView(RecyclerView.java:0)
at <OR>.unregisterAdapterDataObserver(RecyclerView.java:0)
at <OR>.onDetachedFromRecyclerView(RecyclerView.java:0)
at android.support.v7.widget.RecyclerView$Recycler.clear(RecyclerView.java:0)
at <OR>.setViewCacheSize(RecyclerView.java:0)
at <OR>.validateViewHolderForOffsetPosition(RecyclerView.java:0)
at <OR>.tryBindViewHolderByDeadline(RecyclerView.java:0)
at <OR>.getViewForPosition(RecyclerView.java:0)
at <OR>.tryGetViewHolderForPositionByDeadline(RecyclerView.java:0)
at <OR>.invalidateDisplayListInt(RecyclerView.java:0)
at <OR>.recycleView(RecyclerView.java:0)
at <OR>.addViewHolderToRecycledViewPool(RecyclerView.java:0)
at <OR>.getScrapOrCachedViewForId(RecyclerView.java:0)
at <OR>.onAdapterChanged(RecyclerView.java:0)
at <OR>.offsetPositionRecordsForMove(RecyclerView.java:0)
at <OR>.offsetPositionRecordsForRemove(RecyclerView.java:0)
at <OR>.setViewCacheExtension(RecyclerView.java:0)
at <OR>.setRecycledViewPool(RecyclerView.java:0)
at android.support.v7.widget.RecyclerView$Recycler.clear(RecyclerView.java:0)
at <OR>.setViewCacheSize(RecyclerView.java:0)
at <OR>.validateViewHolderForOffsetPosition(RecyclerView.java:0)
at <OR>.tryBindViewHolderByDeadline(RecyclerView.java:0)
at <OR>.getViewForPosition(RecyclerView.java:0)
at <OR>.tryGetViewHolderForPositionByDeadline(RecyclerView.java:0)
at <OR>.invalidateDisplayListInt(RecyclerView.java:0)
at <OR>.recycleView(RecyclerView.java:0)
at <OR>.addViewHolderToRecycledViewPool(RecyclerView.java:0)
at <OR>.getScrapOrCachedViewForId(RecyclerView.java:0)
at <OR>.onAdapterChanged(RecyclerView.java:0)
at <OR>.offsetPositionRecordsForMove(RecyclerView.java:0)
at <OR>.offsetPositionRecordsForRemove(RecyclerView.java:0)
at <OR>.setViewCacheExtension(RecyclerView.java:0)
at <OR>.setRecycledViewPool(RecyclerView.java:0)
at android.support.v7.widget.RecyclerView$Recycler.clear(RecyclerView.java:0)
at <OR>.setViewCacheSize(RecyclerView.java:0)
at <OR>.validateViewHolderForOffsetPosition(RecyclerView.java:0)
at <OR>.tryBindViewHolderByDeadline(RecyclerView.java:0)
at <OR>.getViewForPosition(RecyclerView.java:0)
at <OR>.tryGetViewHolderForPositionByDeadline(RecyclerView.java:0)
at <OR>.invalidateDisplayListInt(RecyclerView.java:0)
at <OR>.recycleView(RecyclerView.java:0)
at <OR>.addViewHolderToRecycledViewPool(RecyclerView.java:0)
at <OR>.getScrapOrCachedViewForId(RecyclerView.java:0)
at <OR>.onAdapterChanged(RecyclerView.java:0)
at <OR>.offsetPositionRecordsForMove(RecyclerView.java:0)
at <OR>.offsetPositionRecordsForRemove(RecyclerView.java:0)
at <OR>.setViewCacheExtension(RecyclerView.java:0)
at <OR>.setRecycledViewPool(RecyclerView.java:0)
at android.support.v7.widget.RecyclerView$Recycler.getScrapList(RecyclerView.java:0)
at <OR>.getViewForPosition(RecyclerView.java:0)
at <OR>.scrapView(RecyclerView.java:0)
at <OR>.unscrapView(RecyclerView.java:0)
at <OR>.viewRangeUpdate(RecyclerView.java:0)
at android.support.v7.widget.LinearLayoutManager$LayoutState.hasMore(LinearLayoutManager.java:0)
at <OR>.next(LinearLayoutManager.java:0)
at <OR>.assignPositionFromScrapList(LinearLayoutManager.java:0)
at <OR>.assignPositionFromScrapList(LinearLayoutManager.java:0)
at android.support.v7.widget.LinearLayoutManager.generateDefaultLayoutParams(LinearLayoutManager.java:0)
at <OR>.onDetachedFromWindow(LinearLayoutManager.java:0)
at <OR>.onInitializeAccessibilityEvent(LinearLayoutManager.java:0)
at <OR>.onRestoreInstanceState(LinearLayoutManager.java:0)
at <OR>.setStackFromEnd(LinearLayoutManager.java:0)
at <OR>.smoothScrollToPosition(LinearLayoutManager.java:0)
at <OR>.onLayoutCompleted(LinearLayoutManager.java:0)
at <OR>.onAnchorReady(LinearLayoutManager.java:0)
at <OR>.updateAnchorInfoForLayout(LinearLayoutManager.java:0)
at <OR>.updateAnchorFromPendingData(LinearLayoutManager.java:0)
at <OR>.fixLayoutEndGap(LinearLayoutManager.java:0)
at <OR>.updateLayoutStateToFillEnd(LinearLayoutManager.java:0)
at <OR>.updateLayoutStateToFillEnd(LinearLayoutManager.java:0)
at <OR>.scrollHorizontallyBy(LinearLayoutManager.java:0)
at <OR>.updateLayoutState(LinearLayoutManager.java:0)
at <OR>.collectPrefetchPositionsForLayoutState(LinearLayoutManager.java:0)
at <OR>.collectInitialPrefetchPositions(LinearLayoutManager.java:0)
at <OR>.collectAdjacentPrefetchPositions(LinearLayoutManager.java:0)
at <OR>.assertNotInLayoutOrScroll(LinearLayoutManager.java:0)
at <OR>.recycleChildren(LinearLayoutManager.java:0)
at <OR>.recycleViewsFromStart(LinearLayoutManager.java:0)
at <OR>.recycleByLayoutState(LinearLayoutManager.java:0)
at <OR>.fill(LinearLayoutManager.java:0)
at <OR>.layoutChunk(LinearLayoutManager.java:0)
at <OR>.findFirstVisibleChildClosestToStart(LinearLayoutManager.java:0)
at <OR>.findReferenceChild(LinearLayoutManager.java:0)
at <OR>.findOneVisibleChild(LinearLayoutManager.java:0)
at <OR>.onFocusSearchFailed(LinearLayoutManager.java:0)
at android.support.v7.widget.LinearLayoutManager.generateDefaultLayoutParams(LinearLayoutManager.java:0)
at <OR>.onDetachedFromWindow(LinearLayoutManager.java:0)
at <OR>.onInitializeAccessibilityEvent(LinearLayoutManager.java:0)
at <OR>.onRestoreInstanceState(LinearLayoutManager.java:0)
at <OR>.setStackFromEnd(LinearLayoutManager.java:0)
at <OR>.smoothScrollToPosition(LinearLayoutManager.java:0)
at <OR>.onLayoutCompleted(LinearLayoutManager.java:0)
at <OR>.onAnchorReady(LinearLayoutManager.java:0)
at <OR>.updateAnchorInfoForLayout(LinearLayoutManager.java:0)
at <OR>.updateAnchorFromPendingData(LinearLayoutManager.java:0)
at <OR>.fixLayoutEndGap(LinearLayoutManager.java:0)
at <OR>.updateLayoutStateToFillEnd(LinearLayoutManager.java:0)
at <OR>.updateLayoutStateToFillEnd(LinearLayoutManager.java:0)
at <OR>.scrollHorizontallyBy(LinearLayoutManager.java:0)
at <OR>.updateLayoutState(LinearLayoutManager.java:0)
at <OR>.collectPrefetchPositionsForLayoutState(LinearLayoutManager.java:0)
at <OR>.collectInitialPrefetchPositions(LinearLayoutManager.java:0)
at <OR>.collectAdjacentPrefetchPositions(LinearLayoutManager.java:0)
at <OR>.assertNotInLayoutOrScroll(LinearLayoutManager.java:0)
at <OR>.recycleChildren(LinearLayoutManager.java:0)
at <OR>.recycleViewsFromStart(LinearLayoutManager.java:0)
at <OR>.recycleByLayoutState(LinearLayoutManager.java:0)
at <OR>.fill(LinearLayoutManager.java:0)
at <OR>.layoutChunk(LinearLayoutManager.java:0)
at <OR>.findFirstVisibleChildClosestToStart(LinearLayoutManager.java:0)
at <OR>.findReferenceChild(LinearLayoutManager.java:0)
at <OR>.findOneVisibleChild(LinearLayoutManager.java:0)
at <OR>.onFocusSearchFailed(LinearLayoutManager.java:0)
at android.support.v7.widget.LinearLayoutManager.onSaveInstanceState(LinearLayoutManager.java:0)
at <OR>.findViewByPosition(LinearLayoutManager.java:0)
at <OR>.onLayoutChildren(LinearLayoutManager.java:0)
at <OR>.computeHorizontalScrollOffset(LinearLayoutManager.java:0)
at <OR>.scrollBy(LinearLayoutManager.java:0)
at <OR>.findOnePartiallyOrCompletelyInvisibleChild(LinearLayoutManager.java:0)
at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:0)
at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:0)
at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:0)
at android.view.View.layout(View.java:17945)
at android.view.ViewGroup.layout(ViewGroup.java:5812)
at android.support.v4.view.ViewPager.onLayout(ViewPager.java:0)
at android.view.View.layout(View.java:17945)
at android.view.ViewGroup.layout(ViewGroup.java:5812)
at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1080)
at android.view.View.layout(View.java:17945)
at android.view.ViewGroup.layout(ViewGroup.java:5812)
at android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:0)
at android.view.View.layout(View.java:17945)
at android.view.ViewGroup.layout(ViewGroup.java:5812)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1742)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1494)
at android.view.View.layout(View.java:17945)
at android.view.ViewGroup.layout(ViewGroup.java:5812)
at android.support.design.widget.CoordinatorLayout.getLastChildRect(CoordinatorLayout.java:0)
at <OR>.layoutChild(CoordinatorLayout.java:0)
at <OR>.resolveGravity(CoordinatorLayout.java:0)
at <OR>.getDependencies(CoordinatorLayout.java:0)
at <OR>.removePreDrawListener(CoordinatorLayout.java:0)
at android.support.design.widget.CoordinatorLayout.releaseTempRect(CoordinatorLayout.java:0)
at <OR>.setWindowInsets(CoordinatorLayout.java:0)
at <OR>.getTopSortedChildren(CoordinatorLayout.java:0)
at <OR>.performIntercept(CoordinatorLayout.java:0)
at <OR>.parseBehavior(CoordinatorLayout.java:0)
at <OR>.getResolvedLayoutParams(CoordinatorLayout.java:0)
at <OR>.getDescendantRect(CoordinatorLayout.java:0)
at <OR>.onMeasureChild(CoordinatorLayout.java:0)
at <OR>.onLayoutChild(CoordinatorLayout.java:0)
at <OR>.getChildRect(CoordinatorLayout.java:0)
at <OR>.getDesiredAnchoredChildRectWithoutConstraints(CoordinatorLayout.java:0)
at <OR>.constrainChildRect(CoordinatorLayout.java:0)
at <OR>.getDesiredAnchoredChildRect(CoordinatorLayout.java:0)
at <OR>.layoutChildWithAnchor(CoordinatorLayout.java:0)
at <OR>.onChildViewsChanged(CoordinatorLayout.java:0)
at <OR>.offsetChildByInset(CoordinatorLayout.java:0)
at <OR>.ensurePreDrawListener(CoordinatorLayout.java:0)
at <OR>.isPointInChildBounds(CoordinatorLayout.java:0)
at <OR>.generateLayoutParams(CoordinatorLayout.java:0)
at <OR>.generateLayoutParams(CoordinatorLayout.java:0)
at android.support.design.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:0)
at android.view.View.layout(View.java:17945)
at android.view.ViewGroup.layout(ViewGroup.java:5812)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:344)
at android.widget.FrameLayout.onLayout(FrameLayout.java:281)
at android.view.View.layout(View.java:17945)
at android.view.ViewGroup.layout(ViewGroup.java:5812)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1742)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1494)
at android.view.View.layout(View.java:17945)
at android.view.ViewGroup.layout(ViewGroup.java:5812)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:344)
at android.widget.FrameLayout.onLayout(FrameLayout.java:281)
at android.view.View.layout(View.java:17945)
at android.view.ViewGroup.layout(ViewGroup.java:5812)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1742)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1494)
at android.view.View.layout(View.java:17945)
at android.view.ViewGroup.layout(ViewGroup.java:5812)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:344)
at android.widget.FrameLayout.onLayout(FrameLayout.java:281)
at com.android.internal.policy.PhoneWindow$DecorView.onLayout(PhoneWindow.java:3178)
at android.view.View.layout(View.java:17945)
at android.view.ViewGroup.layout(ViewGroup.java:5812)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2716)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2417)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1487)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7450)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:920)
at android.view.Choreographer.doCallbacks(Choreographer.java:695)
at android.view.Choreographer.doFrame(Choreographer.java:631)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:906)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7237)
at java.lang.reflect.Method.invoke(Method.java:0)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
</code>```

I fixed this bug and the issue was in the getItemViewType method and not in the first displayed one (getItemCount). So these stack traces are really useless compared to previous ones. You know there is a bug but you don't know exactly where it occurs.

Do you experience the same issues?
Does someone know how to fix it?

答:
I think this is because proguard retrace cannot unambiguously identify the stack frame when line numbers are omitted (see https://www.guardsquare.com/en/proguard/manual/retrace#without).

From these docs, it looks like it's necessary to preserve the LineNumberTable in order to remove ambiguity.

Body:
Google has recently updated the Google Play Console, and now crashes are automatically reported.

Since almost all stack traces I got are not accurate anymore:

The stack trace is full of <OR> methods, so I guess full of possible candidates?

All the line numbers are 0

Note that I use Proguard (and not Multidex) and I strongly suspect it is the cause of the problem.

Example:

java.lang.ClassCastException:
at <<MyPackage>>.adapters.PackageRecyclerViewAdapter.getItemCount(PackageRecyclerViewAdapter.java:0)
at <OR>.getItemViewType(PackageRecyclerViewAdapter.java:0)
at <OR>.onBindViewHolder(PackageRecyclerViewAdapter.java:0)
at <OR>.onCreateViewHolder(PackageRecyclerViewAdapter.java:0)
at android.support.v7.widget.RecyclerView$Adapter.onCreateViewHolder(RecyclerView.java:0)
at <OR>.onBindViewHolder(RecyclerView.java:0)
at <OR>.onBindViewHolder(RecyclerView.java:0)
at <OR>.getItemViewType(RecyclerView.java:0)
at <OR>.getItemCount(RecyclerView.java:0)
at <OR>.onViewRecycled(RecyclerView.java:0)
at <OR>.registerAdapterDataObserver(RecyclerView.java:0)
at <OR>.onAttachedToRecyclerView(RecyclerView.java:0)
at android.support.v7.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:0)
at <OR>.bindViewHolder(RecyclerView.java:0)
at <OR>.getItemId(RecyclerView.java:0)
at <OR>.hasStableIds(RecyclerView.java:0)
at <OR>.onFailedToRecycleView(RecyclerView.java:0)
at <OR>.unregisterAdapterDataObserver(RecyclerView.java:0)
at <OR>.onDetachedFromRecyclerView(RecyclerView.java:0)
at android.support.v7.widget.RecyclerView$Recycler.clear(RecyclerView.java:0)
at <OR>.setViewCacheSize(RecyclerView.java:0)
at <OR>.validateViewHolderForOffsetPosition(RecyclerView.java:0)
at <OR>.tryBindViewHolderByDeadline(RecyclerView.java:0)
at <OR>.getViewForPosition(RecyclerView.java:0)
at <OR>.tryGetViewHolderForPositionByDeadline(RecyclerView.java:0)
at <OR>.invalidateDisplayListInt(RecyclerView.java:0)
at <OR>.recycleView(RecyclerView.java:0)
at <OR>.addViewHolderToRecycledViewPool(RecyclerView.java:0)
at <OR>.getScrapOrCachedViewForId(RecyclerView.java:0)
at <OR>.onAdapterChanged(RecyclerView.java:0)
at <OR>.offsetPositionRecordsForMove(RecyclerView.java:0)
at <OR>.offsetPositionRecordsForRemove(RecyclerView.java:0)
at <OR>.setViewCacheExtension(RecyclerView.java:0)
at <OR>.setRecycledViewPool(RecyclerView.java:0)
at android.support.v7.widget.RecyclerView$Recycler.clear(RecyclerView.java:0)
at <OR>.setViewCacheSize(RecyclerView.java:0)
at <OR>.validateViewHolderForOffsetPosition(RecyclerView.java:0)
at <OR>.tryBindViewHolderByDeadline(RecyclerView.java:0)
at <OR>.getViewForPosition(RecyclerView.java:0)
at <OR>.tryGetViewHolderForPositionByDeadline(RecyclerView.java:0)
at <OR>.invalidateDisplayListInt(RecyclerView.java:0)
at <OR>.recycleView(RecyclerView.java:0)
at <OR>.addViewHolderToRecycledViewPool(RecyclerView.java:0)
at <OR>.getScrapOrCachedViewForId(RecyclerView.java:0)
at <OR>.onAdapterChanged(RecyclerView.java:0)
at <OR>.offsetPositionRecordsForMove(RecyclerView.java:0)
at <OR>.offsetPositionRecordsForRemove(RecyclerView.java:0)
at <OR>.setViewCacheExtension(RecyclerView.java:0)
at <OR>.setRecycledViewPool(RecyclerView.java:0)
at android.support.v7.widget.RecyclerView$Recycler.clear(RecyclerView.java:0)
at <OR>.setViewCacheSize(RecyclerView.java:0)
at <OR>.validateViewHolderForOffsetPosition(RecyclerView.java:0)
at <OR>.tryBindViewHolderByDeadline(RecyclerView.java:0)
at <OR>.getViewForPosition(RecyclerView.java:0)
at <OR>.tryGetViewHolderForPositionByDeadline(RecyclerView.java:0)
at <OR>.invalidateDisplayListInt(RecyclerView.java:0)
at <OR>.recycleView(RecyclerView.java:0)
at <OR>.addViewHolderToRecycledViewPool(RecyclerView.java:0)
at <OR>.getScrapOrCachedViewForId(RecyclerView.java:0)
at <OR>.onAdapterChanged(RecyclerView.java:0)
at <OR>.offsetPositionRecordsForMove(RecyclerView.java:0)
at <OR>.offsetPositionRecordsForRemove(RecyclerView.java:0)
at <OR>.setViewCacheExtension(RecyclerView.java:0)
at <OR>.setRecycledViewPool(RecyclerView.java:0)
at android.support.v7.widget.RecyclerView$Recycler.getScrapList(RecyclerView.java:0)
at <OR>.getViewForPosition(RecyclerView.java:0)
at <OR>.scrapView(RecyclerView.java:0)
at <OR>.unscrapView(RecyclerView.java:0)
at <OR>.viewRangeUpdate(RecyclerView.java:0)
at android.support.v7.widget.LinearLayoutManager$LayoutState.hasMore(LinearLayoutManager.java:0)
at <OR>.next(LinearLayoutManager.java:0)
at <OR>.assignPositionFromScrapList(LinearLayoutManager.java:0)
at <OR>.assignPositionFromScrapList(LinearLayoutManager.java:0)
at android.support.v7.widget.LinearLayoutManager.generateDefaultLayoutParams(LinearLayoutManager.java:0)
at <OR>.onDetachedFromWindow(LinearLayoutManager.java:0)
at <OR>.onInitializeAccessibilityEvent(LinearLayoutManager.java:0)
at <OR>.onRestoreInstanceState(LinearLayoutManager.java:0)
at <OR>.setStackFromEnd(LinearLayoutManager.java:0)
at <OR>.smoothScrollToPosition(LinearLayoutManager.java:0)
at <OR>.onLayoutCompleted(LinearLayoutManager.java:0)
at <OR>.onAnchorReady(LinearLayoutManager.java:0)
at <OR>.updateAnchorInfoForLayout(LinearLayoutManager.java:0)
at <OR>.updateAnchorFromPendingData(LinearLayoutManager.java:0)
at <OR>.fixLayoutEndGap(LinearLayoutManager.java:0)
at <OR>.updateLayoutStateToFillEnd(LinearLayoutManager.java:0)
at <OR>.updateLayoutStateToFillEnd(LinearLayoutManager.java:0)
at <OR>.scrollHorizontallyBy(LinearLayoutManager.java:0)
at <OR>.updateLayoutState(LinearLayoutManager.java:0)
at <OR>.collectPrefetchPositionsForLayoutState(LinearLayoutManager.java:0)
at <OR>.collectInitialPrefetchPositions(LinearLayoutManager.java:0)
at <OR>.collectAdjacentPrefetchPositions(LinearLayoutManager.java:0)
at <OR>.assertNotInLayoutOrScroll(LinearLayoutManager.java:0)
at <OR>.recycleChildren(LinearLayoutManager.java:0)
at <OR>.recycleViewsFromStart(LinearLayoutManager.java:0)
at <OR>.recycleByLayoutState(LinearLayoutManager.java:0)
at <OR>.fill(LinearLayoutManager.java:0)
at <OR>.layoutChunk(LinearLayoutManager.java:0)
at <OR>.findFirstVisibleChildClosestToStart(LinearLayoutManager.java:0)
at <OR>.findReferenceChild(LinearLayoutManager.java:0)
at <OR>.findOneVisibleChild(LinearLayoutManager.java:0)
at <OR>.onFocusSearchFailed(LinearLayoutManager.java:0)
at android.support.v7.widget.LinearLayoutManager.generateDefaultLayoutParams(LinearLayoutManager.java:0)
at <OR>.onDetachedFromWindow(LinearLayoutManager.java:0)
at <OR>.onInitializeAccessibilityEvent(LinearLayoutManager.java:0)
at <OR>.onRestoreInstanceState(LinearLayoutManager.java:0)
at <OR>.setStackFromEnd(LinearLayoutManager.java:0)
at <OR>.smoothScrollToPosition(LinearLayoutManager.java:0)
at <OR>.onLayoutCompleted(LinearLayoutManager.java:0)
at <OR>.onAnchorReady(LinearLayoutManager.java:0)
at <OR>.updateAnchorInfoForLayout(LinearLayoutManager.java:0)
at <OR>.updateAnchorFromPendingData(LinearLayoutManager.java:0)
at <OR>.fixLayoutEndGap(LinearLayoutManager.java:0)
at <OR>.updateLayoutStateToFillEnd(LinearLayoutManager.java:0)
at <OR>.updateLayoutStateToFillEnd(LinearLayoutManager.java:0)
at <OR>.scrollHorizontallyBy(LinearLayoutManager.java:0)
at <OR>.updateLayoutState(LinearLayoutManager.java:0)
at <OR>.collectPrefetchPositionsForLayoutState(LinearLayoutManager.java:0)
at <OR>.collectInitialPrefetchPositions(LinearLayoutManager.java:0)
at <OR>.collectAdjacentPrefetchPositions(LinearLayoutManager.java:0)
at <OR>.assertNotInLayoutOrScroll(LinearLayoutManager.java:0)
at <OR>.recycleChildren(LinearLayoutManager.java:0)
at <OR>.recycleViewsFromStart(LinearLayoutManager.java:0)
at <OR>.recycleByLayoutState(LinearLayoutManager.java:0)
at <OR>.fill(LinearLayoutManager.java:0)
at <OR>.layoutChunk(LinearLayoutManager.java:0)
at <OR>.findFirstVisibleChildClosestToStart(LinearLayoutManager.java:0)
at <OR>.findReferenceChild(LinearLayoutManager.java:0)
at <OR>.findOneVisibleChild(LinearLayoutManager.java:0)
at <OR>.onFocusSearchFailed(LinearLayoutManager.java:0)
at android.support.v7.widget.LinearLayoutManager.onSaveInstanceState(LinearLayoutManager.java:0)
at <OR>.findViewByPosition(LinearLayoutManager.java:0)
at <OR>.onLayoutChildren(LinearLayoutManager.java:0)
at <OR>.computeHorizontalScrollOffset(LinearLayoutManager.java:0)
at <OR>.scrollBy(LinearLayoutManager.java:0)
at <OR>.findOnePartiallyOrCompletelyInvisibleChild(LinearLayoutManager.java:0)
at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:0)
at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:0)
at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:0)
at android.view.View.layout(View.java:17945)
at android.view.ViewGroup.layout(ViewGroup.java:5812)
at android.support.v4.view.ViewPager.onLayout(ViewPager.java:0)
at android.view.View.layout(View.java:17945)
at android.view.ViewGroup.layout(ViewGroup.java:5812)
at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1080)
at android.view.View.layout(View.java:17945)
at android.view.ViewGroup.layout(ViewGroup.java:5812)
at android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:0)
at android.view.View.layout(View.java:17945)
at android.view.ViewGroup.layout(ViewGroup.java:5812)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1742)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1494)
at android.view.View.layout(View.java:17945)
at android.view.ViewGroup.layout(ViewGroup.java:5812)
at android.support.design.widget.CoordinatorLayout.getLastChildRect(CoordinatorLayout.java:0)
at <OR>.layoutChild(CoordinatorLayout.java:0)
at <OR>.resolveGravity(CoordinatorLayout.java:0)
at <OR>.getDependencies(CoordinatorLayout.java:0)
at <OR>.removePreDrawListener(CoordinatorLayout.java:0)
at android.support.design.widget.CoordinatorLayout.releaseTempRect(CoordinatorLayout.java:0)
at <OR>.setWindowInsets(CoordinatorLayout.java:0)
at <OR>.getTopSortedChildren(CoordinatorLayout.java:0)
at <OR>.performIntercept(CoordinatorLayout.java:0)
at <OR>.parseBehavior(CoordinatorLayout.java:0)
at <OR>.getResolvedLayoutParams(CoordinatorLayout.java:0)
at <OR>.getDescendantRect(CoordinatorLayout.java:0)
at <OR>.onMeasureChild(CoordinatorLayout.java:0)
at <OR>.onLayoutChild(CoordinatorLayout.java:0)
at <OR>.getChildRect(CoordinatorLayout.java:0)
at <OR>.getDesiredAnchoredChildRectWithoutConstraints(CoordinatorLayout.java:0)
at <OR>.constrainChildRect(CoordinatorLayout.java:0)
at <OR>.getDesiredAnchoredChildRect(CoordinatorLayout.java:0)
at <OR>.layoutChildWithAnchor(CoordinatorLayout.java:0)
at <OR>.onChildViewsChanged(CoordinatorLayout.java:0)
at <OR>.offsetChildByInset(CoordinatorLayout.java:0)
at <OR>.ensurePreDrawListener(CoordinatorLayout.java:0)
at <OR>.isPointInChildBounds(CoordinatorLayout.java:0)
at <OR>.generateLayoutParams(CoordinatorLayout.java:0)
at <OR>.generateLayoutParams(CoordinatorLayout.java:0)
at android.support.design.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:0)
at android.view.View.layout(View.java:17945)
at android.view.ViewGroup.layout(ViewGroup.java:5812)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:344)
at android.widget.FrameLayout.onLayout(FrameLayout.java:281)
at android.view.View.layout(View.java:17945)
at android.view.ViewGroup.layout(ViewGroup.java:5812)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1742)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1494)
at android.view.View.layout(View.java:17945)
at android.view.ViewGroup.layout(ViewGroup.java:5812)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:344)
at android.widget.FrameLayout.onLayout(FrameLayout.java:281)
at android.view.View.layout(View.java:17945)
at android.view.ViewGroup.layout(ViewGroup.java:5812)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1742)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1494)
at android.view.View.layout(View.java:17945)
at android.view.ViewGroup.layout(ViewGroup.java:5812)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:344)
at android.widget.FrameLayout.onLayout(FrameLayout.java:281)
at com.android.internal.policy.PhoneWindow$DecorView.onLayout(PhoneWindow.java:3178)
at android.view.View.layout(View.java:17945)
at android.view.ViewGroup.layout(ViewGroup.java:5812)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2716)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2417)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1487)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7450)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:920)
at android.view.Choreographer.doCallbacks(Choreographer.java:695)
at android.view.Choreographer.doFrame(Choreographer.java:631)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:906)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7237)
at java.lang.reflect.Method.invoke(Method.java:0)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

I fixed this bug and the issue was in the getItemViewType method and not in the first displayed one (getItemCount). So these stack traces are really useless compared to previous ones. You know there is a bug but you don't know exactly where it occurs.

Do you experience the same issues?
Does someone know how to fix it?


问:
Cakephp option tag attributes
In the view:

```<code>echo $this->Form->input('Ingredient');
</code>```

The above populate multiple select list that HTML output as:

```<code><select name="data[Ingredient][Ingredient][]" option="hh" multiple="multiple" id="IngredientIngredient">
<option value="1" selected="selected">Tomato</option>
<option value="2">Spaghetti </option>
<option value="3" selected="selected">Salt</option>
</select>
</code>```

What I need to know is how to add attributes to the generated <option> tag?

答:
Hi all, In my case, i want to add code="code-value" to my select option and this code is working for me.
If you want to add extra data to your option, try this code:

```<code>    //In controller

    $chapters = $this->Course->Chapter->find('all', array('fields' => array('name', 'code', 'id')));

            // Call the noop function $this->noop() on every element of chapters
            $chapters = Hash::map($chapters, "{n}.Chapter", array($this, 'noop'));

// Callback noop function
    function noop($option) {

            $option['value'] = $option['id'];
            unset($option['id']);
            return $option;
        }
</code>```

You can see document about Hash:map function here. Good luck.

Title: Cakephp option tag attributes

Body:
In the view:

echo $this->Form->input('Ingredient');

The above populate multiple select list that HTML output as:

<select name="data[Ingredient][Ingredient][]" option="hh" multiple="multiple" id="IngredientIngredient">
<option value="1" selected="selected">Tomato</option>
<option value="2">Spaghetti </option>
<option value="3" selected="selected">Salt</option>
</select>

What I need to know is how to add attributes to the generated <option> tag?

Body:
Hi all, In my case, i want to add code="code-value" to my select option and this code is working for me.
If you want to add extra data to your option, try this code:

    //In controller

    $chapters = $this->Course->Chapter->find('all', array('fields' => array('name', 'code', 'id')));

            // Call the noop function $this->noop() on every element of chapters
            $chapters = Hash::map($chapters, "{n}.Chapter", array($this, 'noop'));

// Callback noop function
    function noop($option) {

            $option['value'] = $option['id'];
            unset($option['id']);
            return $option;
        }

You can see document about Hash:map function here. Good luck.


问:
PHPStorm - Find and Replace Text in Selection?
In most other editors, I can select a portion of the text I want to run find and replace on and then hit the ctrl + h combination.  A screen pops up asking me what to find and what to replace.  How do I do this in PHPStorm?</p>

答:
Highlight the code selection you wish to work on
( you can use alt + arrow up if your looking for a cool way to do that)

Press Ctlr + r on PC or Command + r on a Mac

In the upper options window, insert the values you wish to replace

Select the "in selection" check box

Press Replace/Replace all button

ContentLicense: CC BY-SA 4.0


问:
Xamarin : How To Fire Event From PCL In android , how to call addReminder From PCL
Xamarin Project
PCL
Android
IOS

I have a method in Android.MainActivity
and want to call  it from PCL

答:
The default architecture of solution will always be UI->PCL. UI project will have reference to PCL project. So, code in UI project (MainActivity) can call/reference to class/method in PCL. But PCL is not able to call/reference back to class/method in UI project. This is also to avoid cyclic reference.

In order to what you plan to do, you have 2 options:

Option 1

Use Dependency service. You can refer to guide in HERE to learn more about it. Basically it register the UI type to an interface and PCL call through the interface.

Option 2

PCL class have an event

```<code>public event Action SomeEvent;
</code>```

MainActivity will register the event and call to the method that you want to call.

```<code>[PCL class].SomeEvent += SomeEventHandlerMethod;
</code>```

Then whenever you want to call to MainActivity method in PCL, just invoke the event.

```<code>SomeEvent();
</code>```

Body:
The default architecture of solution will always be UI->PCL. UI project will have reference to PCL project. So, code in UI project (MainActivity) can call/reference to class/method in PCL. But PCL is not able to call/reference back to class/method in UI project. This is also to avoid cyclic reference.

In order to what you plan to do, you have 2 options:

Option 1

Use Dependency service. You can refer to guide in HERE to learn more about it. Basically it register the UI type to an interface and PCL call through the interface.

Option 2

PCL class have an event

public event Action SomeEvent;

MainActivity will register the event and call to the method that you want to call.

[PCL class].SomeEvent += SomeEventHandlerMethod;

Then whenever you want to call to MainActivity method in PCL, just invoke the event.

SomeEvent();


问:
determine number of loops based on condition Python
I'm working on the Adobe Analytics reporting/datawarehouse API, and how to process this data into rows and columns (I'm using python and pandas to solve this). This is all going fine as long as only one dimension is used, but when multiple are queried the idea of breakdowns comes into play.

for example, when I'm using 2 dimensions, the data (JSON format) looks something like this:

```<code>{
    "report":{
        "data":[
            {
                "name":"June 13,2017",
                "breakdown":[
                    {
                        "name":"nl",
                        "breakdown":[
                            {
                                "name":"not logged in",
                                "counts":[
                                    "10",
                                    "12"
                                ]
                            },
                            {
                                "name":"logged in",
                                "counts":[
                                    "30",
                                    "2"
                                ]
                            }
                        ]
                    }, ... etc.
</code>```

To elaborate, counts represents an array of metrics and every breakdown represents a dimension (the numbers and names are fictional).

What I want to do here is to build up sets of data that I can ultimately link together in rows and columns, so the first row of the example would be ( "June 13,2017","nl","not logged in",10,12).

in the example situation I could already do that with the following code:

```<code>for period in dataObj['report']['data']:
    for firstbreakdown in period['breakdown']:
        for secondbreakdown in firstbreakdown['breakdown']:
            print(period['name'], firstbreakdown['name'], secondbreakdown['name'], secondbreakdown['counts'])
</code>```

Processing the counts here is not a problem as I've found out I can easily do that with pandas. But here comes the tricky part and my actual question: the number of breakdowns in the JSON example is determined by the number of dimensions that are queried upon.

How can I automatically, based on the number of dimensions queried, make enough loops to keep getting all the dimension values and counts in a row?

I would prefer an elegant & always working solution to do this instead of an if else statement.

答:
Recursive method

If you don't mind recursion (see below), a way to solve this would be using a recursive function to iterate deeper and deeper dimensions. For example:

```<code>def iterBD(dim, breakdown):
  if (dim > 0):
    return [ [breakdown["name"]] + iterBD(dim - 1, sub) for sub in breakdown["breakdown"] ]
  return [ [breakdown["name"]] + data["counts"] for data in breakdown ]
</code>```

Then call on your example data with e.g. iterBD(2, report.data). The result would be an list of lists in the format:

```<code>["June 13,2017", "nl", "not logged in", ["10", "12"]]
["June 13,2017", "nl", "logged in", ["30", "2"]]
...
</code>```

You could potentially detect whether there are additional dimensions to iterate if you are dealing with heterogenous data / rows with different number of dimensions. For example:

```<code>def iterBD2(breakdown):
  if (hasattr(breakdown, "breakdown")):
    return [ [breakdown["name"]] + iterBD2(sub) for sub in breakdown["breakdown"] ]
  return [ [breakdown["name"]] + data["counts"] for data in breakdown ]
</code>```

(might want to check this How to know if an object has an attribute in Python for hasattr / using try  ... catch)

This method would be called like iterBD2(report.data), without having to specify the dimensions.

When recursion could be bad

The above is a recursive method, meaning it relies on the data having relatively few dimensions. If there is a row with e.g. thousands of nested dimensions, Python might have stack problems. As with any recursive function, the above can be rewritten to a non-recursive function. As you pointed out in your comment, the number of dimensions should never be that high in your specific case, and if you have to deal with such an issue, it might be time to reconsider the queries themselves to obtain better data.

Body:
I'm working on the Adobe Analytics reporting/datawarehouse API, and how to process this data into rows and columns (I'm using python and pandas to solve this). This is all going fine as long as only one dimension is used, but when multiple are queried the idea of breakdowns comes into play.

for example, when I'm using 2 dimensions, the data (JSON format) looks something like this:

{
    "report":{
        "data":[
            {
                "name":"June 13,2017",
                "breakdown":[
                    {
                        "name":"nl",
                        "breakdown":[
                            {
                                "name":"not logged in",
                                "counts":[
                                    "10",
                                    "12"
                                ]
                            },
                            {
                                "name":"logged in",
                                "counts":[
                                    "30",
                                    "2"
                                ]
                            }
                        ]
                    }, ... etc.

To elaborate, counts represents an array of metrics and every breakdown represents a dimension (the numbers and names are fictional).

What I want to do here is to build up sets of data that I can ultimately link together in rows and columns, so the first row of the example would be ( "June 13,2017","nl","not logged in",10,12).

in the example situation I could already do that with the following code:

for period in dataObj['report']['data']:
    for firstbreakdown in period['breakdown']:
        for secondbreakdown in firstbreakdown['breakdown']:
            print(period['name'], firstbreakdown['name'], secondbreakdown['name'], secondbreakdown['counts'])

Processing the counts here is not a problem as I've found out I can easily do that with pandas. But here comes the tricky part and my actual question: the number of breakdowns in the JSON example is determined by the number of dimensions that are queried upon.

How can I automatically, based on the number of dimensions queried, make enough loops to keep getting all the dimension values and counts in a row?

I would prefer an elegant & always working solution to do this instead of an if else statement.

Body:
Recursive method

If you don't mind recursion (see below), a way to solve this would be using a recursive function to iterate deeper and deeper dimensions. For example:

def iterBD(dim, breakdown):
  if (dim > 0):
    return [ [breakdown["name"]] + iterBD(dim - 1, sub) for sub in breakdown["breakdown"] ]
  return [ [breakdown["name"]] + data["counts"] for data in breakdown ]

Then call on your example data with e.g. iterBD(2, report.data). The result would be an list of lists in the format:

["June 13,2017", "nl", "not logged in", ["10", "12"]]
["June 13,2017", "nl", "logged in", ["30", "2"]]
...

You could potentially detect whether there are additional dimensions to iterate if you are dealing with heterogenous data / rows with different number of dimensions. For example:

def iterBD2(breakdown):
  if (hasattr(breakdown, "breakdown")):
    return [ [breakdown["name"]] + iterBD2(sub) for sub in breakdown["breakdown"] ]
  return [ [breakdown["name"]] + data["counts"] for data in breakdown ]

(might want to check this How to know if an object has an attribute in Python for hasattr / using try  ... catch)

This method would be called like iterBD2(report.data), without having to specify the dimensions.

When recursion could be bad

The above is a recursive method, meaning it relies on the data having relatively few dimensions. If there is a row with e.g. thousands of nested dimensions, Python might have stack problems. As with any recursive function, the above can be rewritten to a non-recursive function. As you pointed out in your comment, the number of dimensions should never be that high in your specific case, and if you have to deal with such an issue, it might be time to reconsider the queries themselves to obtain better data.


问:
vi substitute in json
I have a JSON file which has a bunch of jpg references that I'm trying to replace with png. I want to match on a pattern where there is a double digit and period before the jpg, capture 1, and use it in the replacement. The issue is I only ever get pattern not found.

```<code>"plith":"img/01.jpg"},{"block_ha....
</code>```

where the substitution code looks like the following

```<code>:%s/\(\d{2}\.\)+jpg/$1png/g
</code>```

答:
I tried this substitution command:

```<code>:%s/\v(\d{2}\.)jpg/\1png/g
</code>```

And it replaced the line:

```<code>"plith":"img/01.jpg"},{"block_ha....
</code>```

With:

```<code>"plith":"img/01.png"},{"block_ha....
</code>```

If the 2 digits and the following dot can be repeated, you can apply the + quantifier to \d{2}\.:

```<code>:%s/\v(\d{2}\.)+jpg/\1png/g
</code>```

In your original command:

```<code>:%s/(\d{2}.)+jpg/$1png/g
</code>```

There seemed to be 3 problems:

you use non-escaped parentheses to capture the digits, but by default you need to escape them. If you don't want to, you can switch to very magic mode by adding the atom \v in your pattern.

you don't escape the ., which means that it will match any character (except a newline), instead of a literal dot

in the replacement part, you use $1 to refer to the first capturing group, but it should be \1

Title: vi substitute in json

Body:
I have a JSON file which has a bunch of jpg references that I'm trying to replace with png. I want to match on a pattern where there is a double digit and period before the jpg, capture 1, and use it in the replacement. The issue is I only ever get pattern not found.

"plith":"img/01.jpg"},{"block_ha....

where the substitution code looks like the following

:%s/\(\d{2}\.\)+jpg/$1png/g

Body:
I tried this substitution command:

:%s/\v(\d{2}\.)jpg/\1png/g

And it replaced the line:

"plith":"img/01.jpg"},{"block_ha....

With:

"plith":"img/01.png"},{"block_ha....

If the 2 digits and the following dot can be repeated, you can apply the + quantifier to \d{2}\.:

:%s/\v(\d{2}\.)+jpg/\1png/g

In your original command:

:%s/(\d{2}.)+jpg/$1png/g

There seemed to be 3 problems:

you use non-escaped parentheses to capture the digits, but by default you need to escape them. If you don't want to, you can switch to very magic mode by adding the atom \v in your pattern.

you don't escape the ., which means that it will match any character (except a newline), instead of a literal dot

in the replacement part, you use $1 to refer to the first capturing group, but it should be \1


问:
Control CheckMark on start from a the listview : simple_list_item_single_choice

I would like to keep the information of the checkmark, the way I was trying to do it is by controlling if a checkmark is true or false at the beginning.

I've tried putting all of them true by using setItemChecked(i,true) but it's not working...

```<code>ArrayAdapter<String> mAdapter = new ArrayAdapter<String>(Main2Activity.this,
                android.R.layout.simple_list_item_single_choice,
                getResources().getStringArray(R.array.Stigmate_P));
listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);

listView.setItemChecked(0,true);
listView.setItemChecked(1,true);
listView.setItemChecked(2,true);
</code>```

When I'm using setOnItemClickListener, I would like to not change the state of my check mark. I've found a way to do so but I'm positive this isn't the best way.

```<code>listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int i, long id) {
    if (Var[i] == 2){
        listView.setItemChecked(i,true);
    }
    else if (Var[i] == 1){
        listView.setItemChecked(i,false);

    }
}
</code>```

Here is most of the java code for my listview

```<code>public class Main2Activity extends AppCompatActivity {
public static int POSITION;
public static int Var[] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};

private Toolbar mActionBarToolbar;
ListView listView;
ImageView ImageView;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (POSITION == 0){
        setContentView(R.layout.activity_main4);
        mActionBarToolbar = (Toolbar) findViewById(R.id.toolbar_actionbar);
        setSupportActionBar(mActionBarToolbar);
        setSupportActionBar(mActionBarToolbar);
        getSupportActionBar().setTitle(" ");}

    if (POSITION == 1){

        setContentView(R.layout.activity_main2);
        mActionBarToolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(mActionBarToolbar);
        getSupportActionBar().setTitle("Stigmate");

        ImageView = (ImageView)findViewById(R.id.imageView2);
        ImageView.setImageResource(R.drawable.r_stigmate);
        listView = (ListView)findViewById(R.id.mainMenu2);

        ArrayAdapter<String> mAdapter = new ArrayAdapter<String>(Main2Activity.this,
                android.R.layout.simple_list_item_single_choice,
                getResources().getStringArray(R.array.Stigmate_P));
        listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);

        listView.setItemChecked(0,true);
        listView.setItemChecked(1,true);
        listView.setItemChecked(2,true);

        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int i, long id) {
                if (Var[i] == 2){
                    listView.setItemChecked(i,true);
                }
                else if (Var[i] == 1){
                    listView.setItemChecked(i,false);
                }

                Intent intent = new Intent(Main2Activity.this, Main3Activity.class);
                intent.putExtra("CountryName",listView.getItemAtPosition(i).toString());
                startActivity(intent);

                int n = 0;
                for (n= 0; n < 20 ; n++) {
                    if(i==n){
                        Main3Activity.POSITION3 = n;
                    }}
            }
        });

        listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
            @Override

            public boolean onItemLongClick(AdapterView<?> arg0, View arg1,
                                           int pos, long id) {
                if (Var[pos] == 1){
                    listView.setItemChecked(pos,true);
                    Var[pos] = 2;
                }
                else if (Var[pos] == 2){
                    listView.setItemChecked(pos,false);
                    Var[pos] = 1;
                }
                return true;
            }
        });
        listView.setAdapter(mAdapter);
    }
...
</code>```

Thanks in advance.

答:
well, first you need set the adapter, then set check able items as checked.

please  check the note layout should be

android.R.layout.simple_list_item_multiple_choice not android.R.layout.simple_list_item_single_choice

try below code

```<code>public class Main2Activity extends AppCompatActivity {
public static int POSITION;
public static int Var[] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};

private Toolbar mActionBarToolbar;
ListView listView;
ImageView ImageView;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

if (POSITION == 0){
    setContentView(R.layout.activity_main4);
    mActionBarToolbar = (Toolbar) findViewById(R.id.toolbar_actionbar);
    setSupportActionBar(mActionBarToolbar);
    setSupportActionBar(mActionBarToolbar);
    getSupportActionBar().setTitle(" ");}

if (POSITION == 1){

    setContentView(R.layout.activity_main2);
    mActionBarToolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(mActionBarToolbar);
    getSupportActionBar().setTitle("Stigmate");

    ImageView = (ImageView)findViewById(R.id.imageView2);
    ImageView.setImageResource(R.drawable.r_stigmate);
    listView = (ListView)findViewById(R.id.mainMenu2);

 // make note : android.R.layout.simple_list_item_multiple_choice not android.R.layout.simple_list_item_single_choice
    ArrayAdapter<String> mAdapter = new ArrayAdapter<String>(Main2Activity.this,
            android.R.layout.simple_list_item_multiple_choice,
            getResources().getStringArray(R.array.Stigmate_P));

    listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
    // add this lines after you set the adapter
    /*listView.setItemChecked(0,true);
    listView.setItemChecked(1,true);
    listView.setItemChecked(2,true);*/

    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int i, long id) {

            if (Var[i] == 2){
                listView.setItemChecked(i,true);
            }
            else if (Var[i] == 1){
                listView.setItemChecked(i,false);

            }

            Intent intent = new Intent(Main2Activity.this, Main3Activity.class);
            intent.putExtra("CountryName",listView.getItemAtPosition(i).toString());
            startActivity(intent);

            int n = 0;
            for (n= 0; n < 20 ; n++) {
                if(i==n){
                    Main3Activity.POSITION3 = n;
                }}

        }

    });

    listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
        @Override

        public boolean onItemLongClick(AdapterView<?> arg0, View arg1,
                                       int pos, long id) {

            if (Var[pos] == 1){
                listView.setItemChecked(pos,true);
                Var[pos] = 2;
            }
            else if (Var[pos] == 2){
                listView.setItemChecked(pos,false);
                Var[pos] = 1;
            }

            return true;
        }
    });
    listView.setAdapter(mAdapter);

 // here you should set checked items
    listView.setItemChecked(0,true);
    listView.setItemChecked(1,true);
    listView.setItemChecked(2,true);

}
</code>```

Body:
I would like to keep the information of the checkmark, the way I was trying to do it is by controlling if a checkmark is true or false at the beginning.

I've tried putting all of them true by using setItemChecked(i,true) but it's not working...

ArrayAdapter<String> mAdapter = new ArrayAdapter<String>(Main2Activity.this,
                android.R.layout.simple_list_item_single_choice,
                getResources().getStringArray(R.array.Stigmate_P));
listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);

listView.setItemChecked(0,true);
listView.setItemChecked(1,true);
listView.setItemChecked(2,true);

When I'm using setOnItemClickListener, I would like to not change the state of my check mark. I've found a way to do so but I'm positive this isn't the best way.

listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int i, long id) {
    if (Var[i] == 2){
        listView.setItemChecked(i,true);
    }
    else if (Var[i] == 1){
        listView.setItemChecked(i,false);

    }
}

Here is most of the java code for my listview

public class Main2Activity extends AppCompatActivity {
public static int POSITION;
public static int Var[] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};

private Toolbar mActionBarToolbar;
ListView listView;
ImageView ImageView;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (POSITION == 0){
        setContentView(R.layout.activity_main4);
        mActionBarToolbar = (Toolbar) findViewById(R.id.toolbar_actionbar);
        setSupportActionBar(mActionBarToolbar);
        setSupportActionBar(mActionBarToolbar);
        getSupportActionBar().setTitle(" ");}

    if (POSITION == 1){

        setContentView(R.layout.activity_main2);
        mActionBarToolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(mActionBarToolbar);
        getSupportActionBar().setTitle("Stigmate");

        ImageView = (ImageView)findViewById(R.id.imageView2);
        ImageView.setImageResource(R.drawable.r_stigmate);
        listView = (ListView)findViewById(R.id.mainMenu2);

        ArrayAdapter<String> mAdapter = new ArrayAdapter<String>(Main2Activity.this,
                android.R.layout.simple_list_item_single_choice,
                getResources().getStringArray(R.array.Stigmate_P));
        listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);

        listView.setItemChecked(0,true);
        listView.setItemChecked(1,true);
        listView.setItemChecked(2,true);

        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int i, long id) {
                if (Var[i] == 2){
                    listView.setItemChecked(i,true);
                }
                else if (Var[i] == 1){
                    listView.setItemChecked(i,false);
                }

                Intent intent = new Intent(Main2Activity.this, Main3Activity.class);
                intent.putExtra("CountryName",listView.getItemAtPosition(i).toString());
                startActivity(intent);

                int n = 0;
                for (n= 0; n < 20 ; n++) {
                    if(i==n){
                        Main3Activity.POSITION3 = n;
                    }}
            }
        });

        listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
            @Override

            public boolean onItemLongClick(AdapterView<?> arg0, View arg1,
                                           int pos, long id) {
                if (Var[pos] == 1){
                    listView.setItemChecked(pos,true);
                    Var[pos] = 2;
                }
                else if (Var[pos] == 2){
                    listView.setItemChecked(pos,false);
                    Var[pos] = 1;
                }
                return true;
            }
        });
        listView.setAdapter(mAdapter);
    }
...

Thanks in advance.

Body:
well, first you need set the adapter, then set check able items as checked.

please  check the note layout should be

android.R.layout.simple_list_item_multiple_choice not android.R.layout.simple_list_item_single_choice

try below code

public class Main2Activity extends AppCompatActivity {
public static int POSITION;
public static int Var[] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};

private Toolbar mActionBarToolbar;
ListView listView;
ImageView ImageView;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

if (POSITION == 0){
    setContentView(R.layout.activity_main4);
    mActionBarToolbar = (Toolbar) findViewById(R.id.toolbar_actionbar);
    setSupportActionBar(mActionBarToolbar);
    setSupportActionBar(mActionBarToolbar);
    getSupportActionBar().setTitle(" ");}

if (POSITION == 1){

    setContentView(R.layout.activity_main2);
    mActionBarToolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(mActionBarToolbar);
    getSupportActionBar().setTitle("Stigmate");

    ImageView = (ImageView)findViewById(R.id.imageView2);
    ImageView.setImageResource(R.drawable.r_stigmate);
    listView = (ListView)findViewById(R.id.mainMenu2);

 // make note : android.R.layout.simple_list_item_multiple_choice not android.R.layout.simple_list_item_single_choice
    ArrayAdapter<String> mAdapter = new ArrayAdapter<String>(Main2Activity.this,
            android.R.layout.simple_list_item_multiple_choice,
            getResources().getStringArray(R.array.Stigmate_P));

    listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
    // add this lines after you set the adapter
    /*listView.setItemChecked(0,true);
    listView.setItemChecked(1,true);
    listView.setItemChecked(2,true);*/

    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int i, long id) {

            if (Var[i] == 2){
                listView.setItemChecked(i,true);
            }
            else if (Var[i] == 1){
                listView.setItemChecked(i,false);

            }

            Intent intent = new Intent(Main2Activity.this, Main3Activity.class);
            intent.putExtra("CountryName",listView.getItemAtPosition(i).toString());
            startActivity(intent);

            int n = 0;
            for (n= 0; n < 20 ; n++) {
                if(i==n){
                    Main3Activity.POSITION3 = n;
                }}

        }

    });

    listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
        @Override

        public boolean onItemLongClick(AdapterView<?> arg0, View arg1,
                                       int pos, long id) {

            if (Var[pos] == 1){
                listView.setItemChecked(pos,true);
                Var[pos] = 2;
            }
            else if (Var[pos] == 2){
                listView.setItemChecked(pos,false);
                Var[pos] = 1;
            }

            return true;
        }
    });
    listView.setAdapter(mAdapter);

 // here you should set checked items
    listView.setItemChecked(0,true);
    listView.setItemChecked(1,true);
    listView.setItemChecked(2,true);

}