问:
Writing try catch finally in shell
Is there a linux bash command like the java try catch finally?
Or does the linux shell always go on?</p>

```<code>try {
   `executeCommandWhichCanFail`
   mv output
} catch {
    mv log
} finally {
    rm tmp
}
</code>```

答:
Warning: exit traps are not always excuted. Since writing this answer I have run into situations, where my exit trap would not be executed, causing loss of files, the reason of which I haven't found yet.

The issue occurred when I stopped a python script with Ctrl+C, which in turn had executed a bash script using exit traps -- which actually should cause the exit traps to be executed, since exit traps are executed on SIGINT in bash.

So, while trap .. exit is useful for cleanup, there are stil scenarios where it won't be executed, the most obvious ones being power outages and receiving SIGKILL.

I often end up with bash scripts becoming quite large, as I add additional options, or otherwise change them. When a bash-script contains a lot of functions, using 'trap EXIT' may become non-trivial.

For instance, consider a script invoked as

```<code>dotask TASK [ARG ...]
</code>```

where each TASK may consists of substeps, where it is desirable to perform cleanup in between.

In this case, it is helpful to work with subshells to produce scoped exit traps, e.g.

```<code>function subTask (
    local tempFile=$(mktemp)
    trap "rm '${tempFile}'" exit
    ...
)
</code>```

However, working with subshells can be tricky, as they can't set global variables of the parent shell.

Additionally, it is often inconvenient to write a single exit trap. For instance, the cleanup steps may depend on how far a function came before encountering an error. It would be nice to be able to make RAII style cleanup declarations:

```<code>function subTask (
    ...
    onExit 'rm tmp.1'
    ...
    onExit 'rm tmp.2'
    ...
)
</code>```

It would seem obvious to use something like

```<code>handlers=""
function onExit { handlers+="$1;"; trap "$handlers" exit; }
</code>```

to update the trap. But this fails for nested subshells, as it would cause premature execution of the parent shell's handlers. The client code would have to explicitly reset the handlers variable at the beginning of the subshell.

Solutions discussed in [multiple bash traps for the same signal], which patch the trap by using the output from trap -p EXIT will equally fail: Even though subshells don't inherit the EXIT trap, trap -p exit will display the parent shell's handler so, again, manual resetting is needed.

Title: Writing try catch finally in shell

Body:
Is there a linux bash command like the java try catch finally?
Or does the linux shell always go on?

try {
   `executeCommandWhichCanFail`
   mv output
} catch {
    mv log
} finally {
    rm tmp
}

Body:
Warning: exit traps are not always excuted. Since writing this answer I have run into situations, where my exit trap would not be executed, causing loss of files, the reason of which I haven't found yet.

The issue occurred when I stopped a python script with Ctrl+C, which in turn had executed a bash script using exit traps -- which actually should cause the exit traps to be executed, since exit traps are executed on SIGINT in bash.

So, while trap .. exit is useful for cleanup, there are stil scenarios where it won't be executed, the most obvious ones being power outages and receiving SIGKILL.

I often end up with bash scripts becoming quite large, as I add additional options, or otherwise change them. When a bash-script contains a lot of functions, using 'trap EXIT' may become non-trivial.

For instance, consider a script invoked as

dotask TASK [ARG ...]

where each TASK may consists of substeps, where it is desirable to perform cleanup in between.

In this case, it is helpful to work with subshells to produce scoped exit traps, e.g.

function subTask (
    local tempFile=$(mktemp)
    trap "rm '${tempFile}'" exit
    ...
)

However, working with subshells can be tricky, as they can't set global variables of the parent shell.

Additionally, it is often inconvenient to write a single exit trap. For instance, the cleanup steps may depend on how far a function came before encountering an error. It would be nice to be able to make RAII style cleanup declarations:

function subTask (
    ...
    onExit 'rm tmp.1'
    ...
    onExit 'rm tmp.2'
    ...
)

It would seem obvious to use something like

handlers=""
function onExit { handlers+="$1;"; trap "$handlers" exit; }

to update the trap. But this fails for nested subshells, as it would cause premature execution of the parent shell's handlers. The client code would have to explicitly reset the handlers variable at the beginning of the subshell.

Solutions discussed in [multiple bash traps for the same signal], which patch the trap by using the output from trap -p EXIT will equally fail: Even though subshells don't inherit the EXIT trap, trap -p exit will display the parent shell's handler so, again, manual resetting is needed.


来源: stackexchange

问:
Two entities are generating strange
CartItem entity

```<code> @Entity
    @Table(name="cart_item")
    public class CartItem {
        @Id
        @GeneratedValue(strategy = GenerationType.AUTO)
        private Integer cartItemId;

        private int quantity;

        private double price;

        @ManyToOne(cascade = CascadeType.ALL)
        @JoinColumn(name = "product_id")
        private Product product;

        @ManyToOne
        @JoinColumn(name = "cart_id")
        private Cart cart;
</code>```

Cart entity

```<code>@Entity
@Table(name="cart")
public class Cart {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Integer cart_id;

    @OneToOne
    @JoinColumn(name = "user_id")
    @JsonIgnore
    private User user;

    @OneToMany(mappedBy = "cart", cascade = CascadeType.ALL,fetch=FetchType.EAGER)
    private List<CartItem> cartItem;

    private double totalPrice;
</code>```

CartItemService

```<code>public void save(User user,CartItem cartItem,String name){
    Cart cart = cartRepository.findCartByUser(user);
    Product product = productRepository.findByName(name);
    cartItem.setProduct(product);
    cartItem.setCart(cart);
    cartItem.setQuantity(1);
    cartItem.setPrice(product.getPrice());
    cartItemRepository.save(cartItem);
}
</code>```

I don't know what is wrong, but I assigned to every user 1 cart, and every time user puts something in cart, or when cart is created, it is adding +1 to both entities id(if there is 2 carts and user adds item to cart ItemCartId will be 3)

答:
It's because the strategy you're using is using the same sequence to generate ids throughout multiple tables. Replacing it with this should solve your problem:</p>

```<code>@GeneratedValue(strategy = GenerationType.IDENTITY)
</code>```

ContentLicense: CC BY-SA 4.0

Title: Two entities are generating strange

Body:
CartItem entity

 @Entity
    @Table(name="cart_item")
    public class CartItem {
        @Id
        @GeneratedValue(strategy = GenerationType.AUTO)
        private Integer cartItemId;

        private int quantity;

        private double price;

        @ManyToOne(cascade = CascadeType.ALL)
        @JoinColumn(name = "product_id")
        private Product product;

        @ManyToOne
        @JoinColumn(name = "cart_id")
        private Cart cart;

Cart entity

@Entity
@Table(name="cart")
public class Cart {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Integer cart_id;

    @OneToOne
    @JoinColumn(name = "user_id")
    @JsonIgnore
    private User user;

    @OneToMany(mappedBy = "cart", cascade = CascadeType.ALL,fetch=FetchType.EAGER)
    private List<CartItem> cartItem;

    private double totalPrice;

CartItemService

public void save(User user,CartItem cartItem,String name){
    Cart cart = cartRepository.findCartByUser(user);
    Product product = productRepository.findByName(name);
    cartItem.setProduct(product);
    cartItem.setCart(cart);
    cartItem.setQuantity(1);
    cartItem.setPrice(product.getPrice());
    cartItemRepository.save(cartItem);
}

I don't know what is wrong, but I assigned to every user 1 cart, and every time user puts something in cart, or when cart is created, it is adding +1 to both entities id(if there is 2 carts and user adds item to cart ItemCartId will be 3)

Body:
It's because the strategy you're using is using the same sequence to generate ids throughout multiple tables. Replacing it with this should solve your problem:

@GeneratedValue(strategy = GenerationType.IDENTITY)


问:
Gatsby Server Rendering APIs - How can I remove the 3 meta tags in default-html.js without copying file to src folder?
Quick Q.

I know I can tweak the build using gatsby-ssr.js (see below for example)

```<code>exports.onPreRenderHTML = ({ pathname, getHeadComponents, replaceHeadComponents }, pluginOptions) => {
    if (pathname.includes(_esi)) {
        let headComponents = getHeadComponents()
        headComponents = headComponents.filter(item => item.type === style)
        replaceHeadComponents(headComponents)
    }
}
</code>```

But how can I remove the 3 core meta tags added in .cache/default-html.js WITHOUT copying it and editing it in src?

答: I had to copy default html to src folder, remove the hard coded metas, and add back via react helmet in layout.js which wraps all other pages.</p>

Body:
Quick Q.

I know I can tweak the build using gatsby-ssr.js (see below for example)

exports.onPreRenderHTML = ({ pathname, getHeadComponents, replaceHeadComponents }, pluginOptions) => {
    if (pathname.includes(_esi)) {
        let headComponents = getHeadComponents()
        headComponents = headComponents.filter(item => item.type === style)
        replaceHeadComponents(headComponents)
    }
}

But how can I remove the 3 core meta tags added in .cache/default-html.js WITHOUT copying it and editing it in src?


问:
Why does this.<variable> or this.<method()> in Parent Class have no effect? Java
I am wondering why this.(...) has no effect in this scenario. The following is a Task of my Exam:

```<code>class PARENT {
    public int x;
    public PARENT(int a)    {this.x = a;}

    public int getX()   {return this.x;}
    public int getY()   {return this.getX();}
}

class CHILD1 extends PARENT {
    public int x;
    public CHILD1(int b) {super(b); this.x = 2 * b;}
}

class CHILD2 extends PARENT {
    public CHILD2(int c)    {super(c);}

    public int getX()   {return 5;}
}

public class ThisTestMain {
    public static void main(String[] args)  {
        PARENT PP = new PARENT(10);
        PARENT PC1 = new CHILD1(100);
        PARENT PC2 = new CHILD2(1000);
        System.out.println(PP.getY());
        System.out.println(PC1.getY());
        System.out.println(PC2.getY());

        CHILD1 CC = new CHILD1(10);
        System.out.println(CC.getY());
    }
}
</code>```

The output is:

```<code>10
100
5
10
</code>```

My question now is why at System.out.println(PC1); the output is NOT 200. Because when I debug the code in IntelliJ I can see that this has the reference
CHILD1@799 and the Object can see the values x and PARENT.x.

At this point why is getX() choosing PARENT.x and not CHILD1.x?

By overriding methods this has also no effect. In this case for example System.out.println(PC2); uses always the getX() in CHILD2, no matter if you write in the getY() Method return this.getX(); or return getX();.

Can someone summerize the system behind that? Maybe also considering super? Thanks!

答:
CHILD1 defines a new field named x that shadows the field x in PARENT. Remove the field. Like

```<code>class CHILD1 extends PARENT {
    // public int x;
    public CHILD1(int b) {super(b); this.x = 2 * b;}
}
</code>```

Body:
I am wondering why this.(...) has no effect in this scenario. The following is a Task of my Exam:

class PARENT {
    public int x;
    public PARENT(int a)    {this.x = a;}

    public int getX()   {return this.x;}
    public int getY()   {return this.getX();}
}

class CHILD1 extends PARENT {
    public int x;
    public CHILD1(int b) {super(b); this.x = 2 * b;}
}

class CHILD2 extends PARENT {
    public CHILD2(int c)    {super(c);}

    public int getX()   {return 5;}
}

public class ThisTestMain {
    public static void main(String[] args)  {
        PARENT PP = new PARENT(10);
        PARENT PC1 = new CHILD1(100);
        PARENT PC2 = new CHILD2(1000);
        System.out.println(PP.getY());
        System.out.println(PC1.getY());
        System.out.println(PC2.getY());

        CHILD1 CC = new CHILD1(10);
        System.out.println(CC.getY());
    }
}

The output is:

10
100
5
10

My question now is why at System.out.println(PC1); the output is NOT 200. Because when I debug the code in IntelliJ I can see that this has the reference
CHILD1@799 and the Object can see the values x and PARENT.x.

At this point why is getX() choosing PARENT.x and not CHILD1.x?

By overriding methods this has also no effect. In this case for example System.out.println(PC2); uses always the getX() in CHILD2, no matter if you write in the getY() Method return this.getX(); or return getX();.

Can someone summerize the system behind that? Maybe also considering super? Thanks!

Body:
CHILD1 defines a new field named x that shadows the field x in PARENT. Remove the field. Like

class CHILD1 extends PARENT {
    // public int x;
    public CHILD1(int b) {super(b); this.x = 2 * b;}
}


问:
JavaScript: location.replace doesn't work in the function
I'm making a web app and I'm struggling with replacing the page.
In the function myPage(), when I put the location.replace("file.html"); in the start, it works if I don't insert inputs on the web app, but when I put the location.replace("file.html"); in the if statement then doesn't work at all, and is there where I need to put the location.replace.

Please help me.

js code:

```<code>    var submit = document.getElementById("submit");
    submit.addEventListener("click",myPage);

    function myPage(){
        //location.replace("file.html"); // here this is working
        var name=document.formId.nameRadio.value;//name="abc"
        if (name=="abc"){
            location.replace("file.html");//but here not
        }
    }

</code>```

html code:

```<code><form  id="formId" name="formId" >
        <label>sth </label><br><br>
        <label for="name"> name  </label>
        <input type="text" id="name" name="name" required>
        <fieldset>
        <legend>sth</legend>
        <ul class="class-radio" >
            <li> <input  type="radio" name="nameRadio" id="abc" value="abc" required><label for="abc">abc</label></li>
            <li> <input  type="radio" name="nameRadio" id="cdf" value="cdf"><label for="cdf">cdf</label></li>

        </ul>
        </fieldset>
        <input id="submit" type="submit" value="next" >
        </form>
</code>```

答:
change your button type to button. your browser submits first.

    var submit = document.getElementById("submit");
    submit.addEventListener("click",myPage);

    function myPage(){
        //location.replace("file.html"); // here this is working
        var name=document.formId.nameRadio.value;//name="abc"
        alert(name);
        if (name=="abc"){
            location.replace("file.html");//but here not
        }
    }```
<pre class="snippet-code-html lang-html prettyprint-override"><code><form  id="formId" name="formId" >
        <label>sth </label><br><br>
        <label for="name"> name  </label>
        <input type="text" id="name" name="name" required>
        <fieldset>
        <legend>sth</legend>
        <ul class="class-radio" >
            <li> <input  type="radio" name="nameRadio" id="abc" value="abc" required><label for="abc">abc</label></li>
            <li> <input  type="radio" name="nameRadio" id="cdf" value="cdf"><label for="cdf">cdf</label></li>

        </ul>
        </fieldset>
        <input id="submit" type="button" value="next" >
        </form></code>```

Body:
I'm making a web app and I'm struggling with replacing the page.
In the function myPage(), when I put the location.replace("file.html"); in the start, it works if I don't insert inputs on the web app, but when I put the location.replace("file.html"); in the if statement then doesn't work at all, and is there where I need to put the location.replace.

Please help me.

js code:

    var submit = document.getElementById("submit");
    submit.addEventListener("click",myPage);

    function myPage(){
        //location.replace("file.html"); // here this is working
        var name=document.formId.nameRadio.value;//name="abc"
        if (name=="abc"){
            location.replace("file.html");//but here not
        }
    }

html code:

<form  id="formId" name="formId" >
        sth

         name
        <input type="text" id="name" name="name" required>
        <fieldset>
        <legend>sth</legend>

 <input  type="radio" name="nameRadio" id="abc" value="abc" required>abc

 <input  type="radio" name="nameRadio" id="cdf" value="cdf">cdf

        </fieldset>
        <input id="submit" type="submit" value="next" >
        </form>

Body:
change your button type to button. your browser submits first.

    var submit = document.getElementById("submit");
    submit.addEventListener("click",myPage);

    function myPage(){
        //location.replace("file.html"); // here this is working
        var name=document.formId.nameRadio.value;//name="abc"
        alert(name);
        if (name=="abc"){
            location.replace("file.html");//but here not
        }
    }

<form  id="formId" name="formId" >
        <label>sth </label><br><br>
        <label for="name"> name  </label>
        <input type="text" id="name" name="name" required>
        <fieldset>
        <legend>sth</legend>
        <ul class="class-radio" >
            <li> <input  type="radio" name="nameRadio" id="abc" value="abc" required><label for="abc">abc</label></li>
            <li> <input  type="radio" name="nameRadio" id="cdf" value="cdf"><label for="cdf">cdf</label></li>

        </ul>
        </fieldset>
        <input id="submit" type="button" value="next" >
        </form>


问:
Where is the Database stored in Orbeon forms CE?
I am using "Orbeon Forms CE" edition.. I biuld number of forms.. I think each form  should have it's own database..So we can access it. So I wanna to find where the database of the created form exists as well as username and password....</p>

答: The forms are stored in an embedded eXist XML database. You shouldn't use this for production. Instead, set up a relational database such as MySQL or PostgreSQL.</p>


问:
Check if Two Values Share a Row Anywhere on an Entire Sheet in Excel
I need to return a Boolean (or count) if two values share 1 row (or more) on an entire page.

The two values could be in any order on that row.
They are not neatly organized in static, predictable columns.

So if we have cells containing:

```<code>abc 111 ghi
ghi 222 abc
jlk 333 xyz
</code>```

I want it to return "true" (or 2, since there are 2 shared rows) when I check for "abc AND ghi".
Similarly, a check for "jlk AND xyz" would return 1/true.

But if I was to check for "111 and 222" it would return 0/False, because they do not share a row.

I've found good support for sumproduct() and countifs() methods to do this, but the techniques were difficult to adapt to an entire page that does not have information organized in predictable columns.

答:
Don't know how many columns you want to work with but this answer might put you on the right path.

Excel: Check if Cell value exists in Column, and return a value in the same row but different column

Body:
I need to return a Boolean (or count) if two values share 1 row (or more) on an entire page.

The two values could be in any order on that row.
They are not neatly organized in static, predictable columns.

So if we have cells containing:

abc 111 ghi
ghi 222 abc
jlk 333 xyz

I want it to return "true" (or 2, since there are 2 shared rows) when I check for "abc AND ghi".
Similarly, a check for "jlk AND xyz" would return 1/true.

But if I was to check for "111 and 222" it would return 0/False, because they do not share a row.

I've found good support for sumproduct() and countifs() methods to do this, but the techniques were difficult to adapt to an entire page that does not have information organized in predictable columns.


问:
Pattern matching a non-exceptional value using try-catch expression
I have a question regarding the try catch block .Here is an example :

```<code>val num = try {
  110 / 12
} catch {
  case ex: NumberFormatException => 0
}

val num1 = try {
  110 / 13
} catch {
  case a: num1 > 10 => 10
  case b: num1 < 10 => 12
}
</code>```

I know num works so why is num1 not valid? All the examples and articles I've seen only do the NumberFormatException or ArithmenticException. And also are greater than and less than not valid operators in the case statement? Is it possible to treat the try catch block like an if else block using pattern matching?

答:
I guess you are attempting to write something like

```<code>try {
  110 / 13
} catch {
  case a if a > 10 => 10
  case b if b < 10 => 12
}
</code>```

however this is not valid syntax because a try expression is of the form

```<code>try { b } catch h
</code>```

where handler h must be a partial function of type

```<code>PartialFunction[Throwable, T]
</code>```

so a in case a if a > 10 must be Throwable however Throwable does not have > method defined on it.

Consider monadic error handling using Try instead of try-catch expression. This would allow you to simply map over in the happy case. For example, consider

```<code>Try(110 / 13)
  .map(num => if (num > 10) 10 else 12)
  .getOrElse(someDefaultValue)
</code>```

Handling Error Without Exceptions has some interactive exercises to get you started with the concept.

Body:
I have a question regarding the try catch block .Here is an example :

val num = try {
  110 / 12
} catch {
  case ex: NumberFormatException => 0
}

val num1 = try {
  110 / 13
} catch {
  case a: num1 > 10 => 10
  case b: num1 < 10 => 12
}

I know num works so why is num1 not valid? All the examples and articles I've seen only do the NumberFormatException or ArithmenticException. And also are greater than and less than not valid operators in the case statement? Is it possible to treat the try catch block like an if else block using pattern matching?

Body:
I guess you are attempting to write something like

try {
  110 / 13
} catch {
  case a if a > 10 => 10
  case b if b < 10 => 12
}

however this is not valid syntax because a try expression is of the form

try { b } catch h

where handler h must be a partial function of type

PartialFunction[Throwable, T]

so a in case a if a > 10 must be Throwable however Throwable does not have > method defined on it.

Consider monadic error handling using Try instead of try-catch expression. This would allow you to simply map over in the happy case. For example, consider

Try(110 / 13)
  .map(num => if (num > 10) 10 else 12)
  .getOrElse(someDefaultValue)

Handling Error Without Exceptions has some interactive exercises to get you started with the concept.


问:
How to place two div side-by-side in a HTML page
I have created a simple HTML page, where I have a parent div with over-flow enabled in both axes. Now within that div, there are 2 divs which I want to place side by side.

#Result {
  margin: 0 auto;
  padding: 0;
  background-color: rgba(0, 0, 0, .02);
  padding-top: 25px;
  font-size: 16px;
  overflow: scroll;
  width: 99%;
  height: calc(100% - 90px - 70px);
  position: absolute;
}

#Left,
#Right {
  height: calc(99vh - 90px - 70px);
  width: 28vw;
  margin: 0 auto;
  padding: 0;
  display: inline-block;
  float: left;
  text-align: center;
  background-color: rgba(0, 0, 0, .04);
  border-right: 1px solid #a6a6a6;
  border-bottom: 1px solid #a6a6a6;
}

#Right {
  background-color: rgba(0, 0, 0, .5);
  border-right: 0px solid #737373;
  padding-left: 15px;
  margin-right: 15px;
  width: 2000px;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div id='Result'>
  <div id='Left'>

  </div>
  <div id='Right'>

  </div>
</div></code>```

Codepen - https://codepen.io/Volabos/pen/qBdNyPa?editors=1100

However unfortunately, the 3rd div is moved down if its width is taken a large number. How can I place the 2nd and 3rd div side by side?

答:
Try this, if you don't mind bodging it a little bit:

#left {
  width: 150px;
  float: left;
  padding-left: 50px;
}

#right {
  /* Change this to whatever the width of your left column is*/
  margin-left: 215px;
  text-align: left;
  font-size: 18px;
}

.clear {
  clear: both;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div id="left">
  <p>foo</p>
</div>
<div id="right">
  <p>bar</p>
</div>
<div id="clear"></div></code>```

Body:
I have created a simple HTML page, where I have a parent div with over-flow enabled in both axes. Now within that div, there are 2 divs which I want to place side by side.

#Result {
  margin: 0 auto;
  padding: 0;
  background-color: rgba(0, 0, 0, .02);
  padding-top: 25px;
  font-size: 16px;
  overflow: scroll;
  width: 99%;
  height: calc(100% - 90px - 70px);
  position: absolute;
}

#Left,
#Right {
  height: calc(99vh - 90px - 70px);
  width: 28vw;
  margin: 0 auto;
  padding: 0;
  display: inline-block;
  float: left;
  text-align: center;
  background-color: rgba(0, 0, 0, .04);
  border-right: 1px solid #a6a6a6;
  border-bottom: 1px solid #a6a6a6;
}

#Right {
  background-color: rgba(0, 0, 0, .5);
  border-right: 0px solid #737373;
  padding-left: 15px;
  margin-right: 15px;
  width: 2000px;
}

Codepen - https://codepen.io/Volabos/pen/qBdNyPa?editors=1100

However unfortunately, the 3rd div is moved down if its width is taken a large number. How can I place the 2nd and 3rd div side by side?

Body:
Try this, if you don't mind bodging it a little bit:

#left {
  width: 150px;
  float: left;
  padding-left: 50px;
}

#right {
  /* Change this to whatever the width of your left column is*/
  margin-left: 215px;
  text-align: left;
  font-size: 18px;
}

.clear {
  clear: both;
}

<div id="left">
  <p>foo</p>
</div>
<div id="right">
  <p>bar</p>
</div>
<div id="clear"></div>


问:
How do I correctly insert ImagePicker to image in header? SwiftUI
I am super new at programming and SwiftUI so I will really appreciate your help.

I place a camera icon on my header to open up an action sheet that will let users select camera or photo gallery.

After that I used a VStack to combine all the elements together. The problem now is that when ImagePicker loads, it only shows half of the screen. I suspect it's because of the Vstack. Any idea how I can solve this issue and make the image picker load the whole screen? Thanks guys.

```<code>struct FeedView: View {
var body: some View {
    VStack(spacing: 20) {

        Header()

        ScrollView(showsIndicators: false) {
            PostView()
            PostView()

        }
    }

  }
}

struct Header: View {

// For Camera Actionsheet
@State var showActionView: Bool = false
@State var isShown: Bool = false

            HStack {

            // Camera
            CameraButtonView(showActionSheet: $showActionView)

            Spacer()

            Image("logo")
                .resizable()
                .frame(width: 150, height: 30)

            }.actionSheet(isPresented: $showActionView, content: { () -> ActionSheet in
                ActionSheet(
                    title: Text("Select image"), message: Text("Please select an image from the photo gallery or use your camera"), buttons: [

                        ActionSheet.Button.default(Text("Camera"), action: {

                        }),

                        ActionSheet.Button.default(Text("Photo Gallery"), action: {
                            self.isShown.toggle()
                        }),

                        ActionSheet.Button.cancel()

                ])
            })
            if isShown {

            ImagePicker()

        }
}
</code>```

答:
You should probably present your ImagePicker inside a sheet like so:

HStack {
 // your code
}
.sheet(isPresented: $isShown) {
    ImagePicker()
}
```

Body:
I am super new at programming and SwiftUI so I will really appreciate your help.

I place a camera icon on my header to open up an action sheet that will let users select camera or photo gallery.

After that I used a VStack to combine all the elements together. The problem now is that when ImagePicker loads, it only shows half of the screen. I suspect it's because of the Vstack. Any idea how I can solve this issue and make the image picker load the whole screen? Thanks guys.

struct FeedView: View {
var body: some View {
    VStack(spacing: 20) {

        Header()

        ScrollView(showsIndicators: false) {
            PostView()
            PostView()

        }
    }

  }
}

struct Header: View {

// For Camera Actionsheet
@State var showActionView: Bool = false
@State var isShown: Bool = false

            HStack {

            // Camera
            CameraButtonView(showActionSheet: $showActionView)

            Spacer()

            Image("logo")
                .resizable()
                .frame(width: 150, height: 30)

            }.actionSheet(isPresented: $showActionView, content: { () -> ActionSheet in
                ActionSheet(
                    title: Text("Select image"), message: Text("Please select an image from the photo gallery or use your camera"), buttons: [

                        ActionSheet.Button.default(Text("Camera"), action: {

                        }),

                        ActionSheet.Button.default(Text("Photo Gallery"), action: {
                            self.isShown.toggle()
                        }),

                        ActionSheet.Button.cancel()

                ])
            })
            if isShown {

            ImagePicker()

        }
}


问:
How to fix Kernal error in jupyter notebook?
So I am trying to install anaconda to use jupyter notebook on my windows computer. When I open jupyter and type code no output comes out. I am asuming this is in realation to the kernal error which is:</p>

```<code>  Traceback (most recent call last):
  File "C:\ProgramData\Anaconda3\lib\site-packages\tornado\web.py", line 1699, in _execute
    result = await result
  File "C:\ProgramData\Anaconda3\lib\site-packages\tornado\gen.py", line 742, in run
    yielded = self.gen.throw(*exc_info)  # type: ignore
  File "C:\ProgramData\Anaconda3\lib\site-packages\notebook\services\sessions\handlers.py", line 72, in post
    type=mtype))
  File "C:\ProgramData\Anaconda3\lib\site-packages\tornado\gen.py", line 735, in run
    value = future.result()
  File "C:\ProgramData\Anaconda3\lib\site-packages\tornado\gen.py", line 742, in run
    yielded = self.gen.throw(*exc_info)  # type: ignore
  File "C:\ProgramData\Anaconda3\lib\site-packages\notebook\services\sessions\sessionmanager.py", line 88, in create_session
    kernel_id = yield self.start_kernel_for_session(session_id, path, name, type, kernel_name)
  File "C:\ProgramData\Anaconda3\lib\site-packages\tornado\gen.py", line 735, in run
    value = future.result()
  File "C:\ProgramData\Anaconda3\lib\site-packages\tornado\gen.py", line 742, in run
    yielded = self.gen.throw(*exc_info)  # type: ignore
  File "C:\ProgramData\Anaconda3\lib\site-packages\notebook\services\sessions\sessionmanager.py", line 101, in start_kernel_for_session
    self.kernel_manager.start_kernel(path=kernel_path, kernel_name=kernel_name)
  File "C:\ProgramData\Anaconda3\lib\site-packages\tornado\gen.py", line 735, in run
    value = future.result()
  File "C:\ProgramData\Anaconda3\lib\site-packages\tornado\gen.py", line 209, in wrapper
    yielded = next(result)
  File "C:\ProgramData\Anaconda3\lib\site-packages\notebook\services\kernels\kernelmanager.py", line 168, in start_kernel
    super(MappingKernelManager, self).start_kernel(**kwargs)
  File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\multikernelmanager.py", line 110, in start_kernel
    km.start_kernel(**kwargs)
  File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\manager.py", line 240, in start_kernel
    self.write_connection_file()
  File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\connect.py", line 547, in write_connection_file
    kernel_name=self.kernel_name
  File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\connect.py", line 212, in write_connection_file
    with secure_write(fname) as f:
  File "C:\ProgramData\Anaconda3\lib\contextlib.py", line 112, in __enter__
    return next(self.gen)
  File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\connect.py", line 102, in secure_write
    with os.fdopen(os.open(fname, open_flag, 0o600), mode) as f:
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\Benito\\AppData\\Roaming\\jupyter\\runtime\\kernel-aceb8175-1088-4a5a-b56e-52595097b287.json'
</code>```

答: Have you tried running jupyter notebook as the administrator? If not try to do this as you are getting a permission error. </p>

Body:
So I am trying to install anaconda to use jupyter notebook on my windows computer. When I open jupyter and type code no output comes out. I am asuming this is in realation to the kernal error which is:

  Traceback (most recent call last):
  File "C:\ProgramData\Anaconda3\lib\site-packages\tornado\web.py", line 1699, in _execute
    result = await result
  File "C:\ProgramData\Anaconda3\lib\site-packages\tornado\gen.py", line 742, in run
    yielded = self.gen.throw(*exc_info)  # type: ignore
  File "C:\ProgramData\Anaconda3\lib\site-packages\notebook\services\sessions\handlers.py", line 72, in post
    type=mtype))
  File "C:\ProgramData\Anaconda3\lib\site-packages\tornado\gen.py", line 735, in run
    value = future.result()
  File "C:\ProgramData\Anaconda3\lib\site-packages\tornado\gen.py", line 742, in run
    yielded = self.gen.throw(*exc_info)  # type: ignore
  File "C:\ProgramData\Anaconda3\lib\site-packages\notebook\services\sessions\sessionmanager.py", line 88, in create_session
    kernel_id = yield self.start_kernel_for_session(session_id, path, name, type, kernel_name)
  File "C:\ProgramData\Anaconda3\lib\site-packages\tornado\gen.py", line 735, in run
    value = future.result()
  File "C:\ProgramData\Anaconda3\lib\site-packages\tornado\gen.py", line 742, in run
    yielded = self.gen.throw(*exc_info)  # type: ignore
  File "C:\ProgramData\Anaconda3\lib\site-packages\notebook\services\sessions\sessionmanager.py", line 101, in start_kernel_for_session
    self.kernel_manager.start_kernel(path=kernel_path, kernel_name=kernel_name)
  File "C:\ProgramData\Anaconda3\lib\site-packages\tornado\gen.py", line 735, in run
    value = future.result()
  File "C:\ProgramData\Anaconda3\lib\site-packages\tornado\gen.py", line 209, in wrapper
    yielded = next(result)
  File "C:\ProgramData\Anaconda3\lib\site-packages\notebook\services\kernels\kernelmanager.py", line 168, in start_kernel
    super(MappingKernelManager, self).start_kernel(**kwargs)
  File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\multikernelmanager.py", line 110, in start_kernel
    km.start_kernel(**kwargs)
  File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\manager.py", line 240, in start_kernel
    self.write_connection_file()
  File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\connect.py", line 547, in write_connection_file
    kernel_name=self.kernel_name
  File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\connect.py", line 212, in write_connection_file
    with secure_write(fname) as f:
  File "C:\ProgramData\Anaconda3\lib\contextlib.py", line 112, in __enter__
    return next(self.gen)
  File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\connect.py", line 102, in secure_write
    with os.fdopen(os.open(fname, open_flag, 0o600), mode) as f:
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\Benito\\AppData\\Roaming\\jupyter\\runtime\\kernel-aceb8175-1088-4a5a-b56e-52595097b287.json'


问:
Reading strings from csv does not print \n
Im reading strings from a csv file. These strings contain "\n" chars to represent new lines.
How can I print these strings with the correct new lines? Using str() didn't work.

CSV File has only one line:

Dest, Test\n Test2\n Test3
```

<p>The code below prints <code>Test\n Test2\n Test3</code></p>

```for ifile in files:
    with open(orderPath + '\\' + ifile) as csv_file:
        csv_reader = csv.reader(csv_file, delimiter=',')

        for row in csv_reader:

            dest = row[0]
            message = row[1]

            message = str(message)
            print(message)
```

答:
It's unclear precisely how you want the data in the csv file to be interpreted, but here's a guess. It uses the ast.literal_eval() function to convert the escape characters in the input data into newline characters.

This involves enclosing the second column in triple double-quotes (""") characters to allow it to interpreted as Python string literal. Triple quotes are used in case the enclosed text itself contains quotes. For example: Dest, Test\n "Test2"\n Test3

```<code>import ast
import csv

filename = 'one_line.csv'

with open(filename, newline='') as csv_file:
    for row in csv.reader(csv_file, delimiter=','):
        dest = row[0]
        message = ast.literal_eval('"""{}"""'.format(row[1]))
        print(dest)
        print(message)
</code>```

Output:

Dest
 Test
 Test2
 Test3
```

Body:
Im reading strings from a csv file. These strings contain "\n" chars to represent new lines.
How can I print these strings with the correct new lines? Using str() didn't work.

CSV File has only one line:

Dest, Test\n Test2\n Test3

The code below prints Test\n Test2\n Test3

for ifile in files:
    with open(orderPath + '\\' + ifile) as csv_file:
        csv_reader = csv.reader(csv_file, delimiter=',')

        for row in csv_reader:

            dest = row[0]
            message = row[1]

            message = str(message)
            print(message)

Body:
It's unclear precisely how you want the data in the csv file to be interpreted, but here's a guess. It uses the ast.literal_eval() function to convert the escape characters in the input data into newline characters.

This involves enclosing the second column in triple double-quotes (""") characters to allow it to interpreted as Python string literal. Triple quotes are used in case the enclosed text itself contains quotes. For example: Dest, Test\n "Test2"\n Test3

import ast
import csv

filename = 'one_line.csv'

with open(filename, newline='') as csv_file:
    for row in csv.reader(csv_file, delimiter=','):
        dest = row[0]
        message = ast.literal_eval('"""{}"""'.format(row[1]))
        print(dest)
        print(message)

Output:

Dest
 Test
 Test2
 Test3


问:
UIBarButtonItem will not show when I segue programmatically
I am building an app where I am segueing programmatically from ViewControllerA because it is a list of menu items that each lead to a different VC, so instead of having multiple segues, I instantiate the view controller in code. My issue is that even though I have a Bar button item on my storyboard it will not show in the app.

View Controller A Menu Model Code:

```<code>class PlayerMenu: Hashable {
       let title: String
       let numberOfItems: String
       let menuItemViewController: UIViewController.Type?

       init(title: String, numberOfItems: String, viewController: UIViewController.Type? = nil) {
           self.title = title
           self.numberOfItems = numberOfItems
           self.menuItemViewController = viewController
       }

       func hash(into hasher: inout Hasher) {
           hasher.combine(identifier)
       }

       static func == (lhs: PlayerMenu, rhs: PlayerMenu) -> Bool {
           return lhs.identifier == rhs.identifier
       }
       private let identifier = UUID()

   }
</code>```

ViewController A Code

```<code> private lazy var menuItems: [PlayerMenu] = {
        return [
            PlayerMenu(title: "Status", numberOfItems: "Available.", viewController: nil),
            PlayerMenu(title: "Pertinent Medical History", numberOfItems: "", viewController: nil),
            PlayerMenu(title: "Injury / Illness", numberOfItems: "There are no injuries.", viewController: nil),
            PlayerMenu(title: "Allergy", numberOfItems: "There are no allergies.", viewController: AllergyTableViewController.self),
            PlayerMenu(title: "Neurocognitive", numberOfItems: "Unavailable.", viewController: nil),
            PlayerMenu(title: "Medication", numberOfItems: "There are no medications.", viewController: nil),
            PlayerMenu(title: "Immunization", numberOfItems: "There are no immunizations", viewController: nil),
            PlayerMenu(title: "Dictations", numberOfItems: "There are no dictations.", viewController: nil),
            PlayerMenu(title: "Imaging",  numberOfItems: "There is no imaging.", viewController: nil),
            PlayerMenu(title: "Participation", numberOfItems: "Unavailable.", viewController: nil),
            PlayerMenu(title: "Away Game Injury", numberOfItems: "Unavailable.", viewController: nil),

        ]
    }()
</code>```

ViewControllerA Segue

```<code>extension PlayerDashboardViewController: UITableViewDelegate {
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        guard let menuItem = self.dataSource.itemIdentifier(for: indexPath) else { return }
        if let viewController = menuItem.menuItemViewController {
            let navController = UINavigationController(rootViewController: viewController.init())
            present(navController, animated: true)
        }
    }
}
</code>```

Storyboard Screenshot

答:
The reason you're not seeing your view controller as you've designed it in your storyboard is because calling viewController.init() does not instantiate your view controller from your storyboard. You need to call:

UIStoryboard.instantiateViewController(withIdentifier:)

Or alternatively (only for iOS 13+):

UIStoryboard.instantiateViewController(identifier:creator:)

I recommend instead of storing the view controller type in your PlayerMenu class that you store the view controller's storyboard identifier, like so:

class PlayerMenu: Hashable {
    let title: String
    let numberOfItems: String
    let menuItemViewControllerStoryboardIdentifier: String?

    init(title: String, numberOfItems: String, viewControllerStoryboardIdentifier: String? = nil) {
        self.title = title
        self.numberOfItems = numberOfItems
        self.menuItemViewControllerStoryboardIdentifier = viewControllerStoryboardIdentifier
    }

    [...]
}
```

<p>Then when you want to instantiate your view controller, get a reference to your storyboard (if it's the same as the current view controller's storyboard, then you can just say <code>self.storyboard</code>, otherwise create the storyboard directly with <code>UIStoryboard.init(name:bundle:)</code>):</p>

<pre class="lang-swift prettyprint-override"><code>extension PlayerDashboardViewController: UITableViewDelegate {
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        guard let menuItem = self.dataSource.itemIdentifier(for: indexPath),
            let viewControllerStoryboardIdentifier = menuItem.menuItemViewControllerStoryboardIdentifier,
            let viewController = self.storyboard?.instantiateViewController(withIdentifier: viewControllerStoryboardIdentifier) else {
                return
        }

        let navController = UINavigationController(rootViewController: viewController)
        present(navController, animated: true)
    }
}
</code>```

Then make sure to give your view controllers identifiers in your storyboard, and create your PlayerMenu items like this:

PlayerMenu(title: "Allergy", numberOfItems: "There are no allergies.", viewControllerStoryboardIdentifier: "AllergyTableViewController (or whatever identifier you give this in your storyboard)")
```

Body:
I am building an app where I am segueing programmatically from ViewControllerA because it is a list of menu items that each lead to a different VC, so instead of having multiple segues, I instantiate the view controller in code. My issue is that even though I have a Bar button item on my storyboard it will not show in the app.

View Controller A Menu Model Code:

class PlayerMenu: Hashable {
       let title: String
       let numberOfItems: String
       let menuItemViewController: UIViewController.Type?

       init(title: String, numberOfItems: String, viewController: UIViewController.Type? = nil) {
           self.title = title
           self.numberOfItems = numberOfItems
           self.menuItemViewController = viewController
       }

       func hash(into hasher: inout Hasher) {
           hasher.combine(identifier)
       }

       static func == (lhs: PlayerMenu, rhs: PlayerMenu) -> Bool {
           return lhs.identifier == rhs.identifier
       }
       private let identifier = UUID()

   }

ViewController A Code

 private lazy var menuItems: [PlayerMenu] = {
        return [
            PlayerMenu(title: "Status", numberOfItems: "Available.", viewController: nil),
            PlayerMenu(title: "Pertinent Medical History", numberOfItems: "", viewController: nil),
            PlayerMenu(title: "Injury / Illness", numberOfItems: "There are no injuries.", viewController: nil),
            PlayerMenu(title: "Allergy", numberOfItems: "There are no allergies.", viewController: AllergyTableViewController.self),
            PlayerMenu(title: "Neurocognitive", numberOfItems: "Unavailable.", viewController: nil),
            PlayerMenu(title: "Medication", numberOfItems: "There are no medications.", viewController: nil),
            PlayerMenu(title: "Immunization", numberOfItems: "There are no immunizations", viewController: nil),
            PlayerMenu(title: "Dictations", numberOfItems: "There are no dictations.", viewController: nil),
            PlayerMenu(title: "Imaging",  numberOfItems: "There is no imaging.", viewController: nil),
            PlayerMenu(title: "Participation", numberOfItems: "Unavailable.", viewController: nil),
            PlayerMenu(title: "Away Game Injury", numberOfItems: "Unavailable.", viewController: nil),

        ]
    }()

ViewControllerA Segue

extension PlayerDashboardViewController: UITableViewDelegate {
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        guard let menuItem = self.dataSource.itemIdentifier(for: indexPath) else { return }
        if let viewController = menuItem.menuItemViewController {
            let navController = UINavigationController(rootViewController: viewController.init())
            present(navController, animated: true)
        }
    }
}

Storyboard Screenshot

Body:
The reason you're not seeing your view controller as you've designed it in your storyboard is because calling viewController.init() does not instantiate your view controller from your storyboard. You need to call:

UIStoryboard.instantiateViewController(withIdentifier:)

Or alternatively (only for iOS 13+):

UIStoryboard.instantiateViewController(identifier:creator:)

I recommend instead of storing the view controller type in your PlayerMenu class that you store the view controller's storyboard identifier, like so:

class PlayerMenu: Hashable {
    let title: String
    let numberOfItems: String
    let menuItemViewControllerStoryboardIdentifier: String?

    init(title: String, numberOfItems: String, viewControllerStoryboardIdentifier: String? = nil) {
        self.title = title
        self.numberOfItems = numberOfItems
        self.menuItemViewControllerStoryboardIdentifier = viewControllerStoryboardIdentifier
    }

    [...]
}

Then when you want to instantiate your view controller, get a reference to your storyboard (if it's the same as the current view controller's storyboard, then you can just say self.storyboard, otherwise create the storyboard directly with UIStoryboard.init(name:bundle:)):

extension PlayerDashboardViewController: UITableViewDelegate {
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        guard let menuItem = self.dataSource.itemIdentifier(for: indexPath),
            let viewControllerStoryboardIdentifier = menuItem.menuItemViewControllerStoryboardIdentifier,
            let viewController = self.storyboard?.instantiateViewController(withIdentifier: viewControllerStoryboardIdentifier) else {
                return
        }

        let navController = UINavigationController(rootViewController: viewController)
        present(navController, animated: true)
    }
}

Then make sure to give your view controllers identifiers in your storyboard, and create your PlayerMenu items like this:

PlayerMenu(title: "Allergy", numberOfItems: "There are no allergies.", viewControllerStoryboardIdentifier: "AllergyTableViewController (or whatever identifier you give this in your storyboard)")


问:
cloning input text with button delete
I have this script:

```<code>$(document).ready(function() {

var i = 1;

    $('#addJabatan').click(function() {
        $('.hapusJabatan:disabled').removeAttr('disabled');
        var c = $('#comboJabatan:first').clone(true);
        c.children(':text').attr('class','jabatan'+ (++i) );
        $('#comboJabatan:last').after(c);
    });

 $('#hapusJabatan').click(function() {
        if (confirm('continue delete')) {
            --i;
            $(this).closest('#comboJabatan').remove();
            $('.hapusJabatan').attr('disabled',($('#comboJabatan').length  < 2));
        }
    });
</code>```

});

and this is my HTML code:

```<code><form id="myForm">
<span id="comboJabatan" class="clonedInput">
                            <input type="button" class="hapusJabatan" value="delete" id="hapusJabatan" disabled>
    <input name="jabatan[]" type="text" data-bvalidator="required"  id="jabatan" class="jabatan1" /><br/>
                            </span>

<span>
                                <a href="#" id="addJabatan">Tambah Jabatan</a>
                            </span>
</code>```

I Confused with the .length() method
anyone can help me..?
thanks before

for more details enter link description here

答:
Try replacing this line

```<code>$('.hapusJabatan').attr('disabled',($('.comboJabatan').length  < 2));
</code>```

with

```<code>if ($('.comboJabatan').length == 1)
     $('.hapusJabatan').attr('disabled', 'disabled');
else
     $('.hapusJabatan').removeAttr('disabled');
</code>```

You are also trying to select multiple elements using an ID which you cant do. I have added a class of 'comboJabatan' to the span and used that for the select.

Working example

ContentLicense: CC BY-SA 3.0

Title: cloning input text with button delete

Body:
I have this script:

$(document).ready(function() {

var i = 1;

    $('#addJabatan').click(function() {
        $('.hapusJabatan:disabled').removeAttr('disabled');
        var c = $('#comboJabatan:first').clone(true);
        c.children(':text').attr('class','jabatan'+ (++i) );
        $('#comboJabatan:last').after(c);
    });

 $('#hapusJabatan').click(function() {
        if (confirm('continue delete')) {
            --i;
            $(this).closest('#comboJabatan').remove();
            $('.hapusJabatan').attr('disabled',($('#comboJabatan').length  < 2));
        }
    });

});

and this is my HTML code:

<form id="myForm">

                            <input type="button" class="hapusJabatan" value="delete" id="hapusJabatan" disabled>
    <input name="jabatan[]" type="text" data-bvalidator="required"  id="jabatan" class="jabatan1" />

                                Tambah Jabatan

I Confused with the .length() method
anyone can help me..?
thanks before

for more details enter link description here

Body:
Try replacing this line

$('.hapusJabatan').attr('disabled',($('.comboJabatan').length  < 2));

with

if ($('.comboJabatan').length == 1)
     $('.hapusJabatan').attr('disabled', 'disabled');
else
     $('.hapusJabatan').removeAttr('disabled');

You are also trying to select multiple elements using an ID which you cant do. I have added a class of 'comboJabatan' to the span and used that for the select.

Working example


问:
using webrtc for audio broadcast
I'm trying to stream a microphone/audio to multiple clients.

the broadcaster is a screenless raspberry, so I can't open a Webbrowser and click on "share mircophone"

The clients will be using their smartphone to listen.

the latency must be super low.

I did not find any WebRTC Demo that worked. All of them are either p2p or the scalable Broadcasting from muaz khan is only working for the initiator; not clients.

I came across Janus (which I didn't really understand what exactly this is doing) but I don't get how to install this and how to configure it.

Is there any way to easily share the microphone's output via WebRTC? Something like Apache hosting a simple website where the microphone audio is hosted on?

Thanks for all the ideas on how to solve it!

答:
Is there any way to easily share the microphone's output via WebRTC?

No.  There's nothing easy or simple about WebRTC.

the broadcaster is a screenless raspberry, so I can't open a Webbrowser and click on "share mircophone"

This is the simplest option... running a browser.  Are you sure you need to actually allow it to access the audio device?

In the past, I've used a flag on Chromium to get around this problem.  I don't remember exactly what that flag was, but looking at the list, it might have been...

```<code>--use-fake-ui-for-media-stream
</code>```

You might also be able to use --enable-kiosk-mode.

At a minimum, if you were to open the browser interactively and enable access, that page would get automatic access in the future.

I did not find any WebRTC Demo that worked. All of them are either p2p

WebRTC is peer-to-peer, but remember that the "server" can be one of those "peers".

Finally, you can look into using GStreamer, but don't expect anything quick and easy.  https://github.com/centricular/gstwebrtc-demos

Title: using webrtc for audio broadcast

Body:
Is there any way to easily share the microphone's output via WebRTC?

No.  There's nothing easy or simple about WebRTC.

the broadcaster is a screenless raspberry, so I can't open a Webbrowser and click on "share mircophone"

This is the simplest option... running a browser.  Are you sure you need to actually allow it to access the audio device?

In the past, I've used a flag on Chromium to get around this problem.  I don't remember exactly what that flag was, but looking at the list, it might have been...

--use-fake-ui-for-media-stream

You might also be able to use --enable-kiosk-mode.

At a minimum, if you were to open the browser interactively and enable access, that page would get automatic access in the future.

I did not find any WebRTC Demo that worked. All of them are either p2p

WebRTC is peer-to-peer, but remember that the "server" can be one of those "peers".

Finally, you can look into using GStreamer, but don't expect anything quick and easy.  https://github.com/centricular/gstwebrtc-demos


问:
DocuSign SOAP API CreateEnvelope draft question
We are attempting to do a SOAP API call to a DocuSign account using the SOAPUI program and we are wanting the envelope to be created as a draft. Currently we only have access to the "CreateAndSendEnvelope" method so we don't have access to use the "state" xml tag so that we can create the envelope as a "draft" by using the "CreateEnvelope" method. The SOAP API guide from DocuSign is not 100 percent clear when it comes to these two methods because it says they are very similar and it doesn't show the schema for the "CreateEnvelope" method.

Can anyone verify that I am not able to create an envelope as a draft using the "CreateAndSendEnvelope" method and that the only way I would be able to do so would be to use the "CreateEnvelope" method?

Thank you in advance for your help!

答:
CreateAndSendEnvelope cannot be used for Draft Envelopes. CreateEnvelope is used to create a Draft status envelope. But since you are doing a new Integration, it is recommended to use REST API. Sample response for CreateEnvelope call would look like below (check status will always be Created):

```<code><CreateEnvelopeResponse xmlns="http://www.docusign.net/API/3.0">
         <CreateEnvelopeResult>
            <RecipientStatuses/>
            <TimeGenerated>2020-02-18T22:30:33.4707464</TimeGenerated>
            <EnvelopeID>033b9ca5-ac56-467a-99c5-63e2a37b9eef</EnvelopeID>
            <Subject/>
            <UserName>Amit Sender</UserName>
            <Email>email@gmail.com</Email>
            <Status>Created</Status>
</code>```

Body:
CreateAndSendEnvelope cannot be used for Draft Envelopes. CreateEnvelope is used to create a Draft status envelope. But since you are doing a new Integration, it is recommended to use REST API. Sample response for CreateEnvelope call would look like below (check status will always be Created):

<CreateEnvelopeResponse xmlns="http://www.docusign.net/API/3.0">
         <CreateEnvelopeResult>
            <RecipientStatuses/>
            <TimeGenerated>2020-02-18T22:30:33.4707464</TimeGenerated>
            <EnvelopeID>033b9ca5-ac56-467a-99c5-63e2a37b9eef</EnvelopeID>
            <Subject/>
            <UserName>Amit Sender</UserName>
            <Email>email@gmail.com</Email>
            <Status>Created</Status>


问:
Unable to display an image from within Jar file
I know this has been asked before but I can't get it to work after trying all variations.I have a small program that I'm wanting the launch frame to have an image displayed on it. I can achieve this by having the jar in the same folder as the image and referencing it, however when I try to reference within the jar file itself I keep getting error:

```<code>Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException
</code>```

The code I am using is this:

```<code>private void imagePanel() {
    setLayout(new BorderLayout());
    BufferedImage image;
    try {
        image = ImageIO.read(this.getClass().getResource("/src/ticketMaster/img/logo.png"));
    } catch (IOException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
    add(new JLabel(new ImageIcon(image)), BorderLayout.CENTER);
}
</code>```

I'm not sure if the path is incorrect, I have made a img folder inside the package named img which contains the logo. I have tried all variations of it

```<code>/img/logo.png
/ticketMaster/img/logo.png
/src/ticketMaster/img/logo.png
</code>```

I am not able to get the image to load like I would just referencing the image outside of the jar. I've used resourceasstream as well and not had any luck with that.

Any ideas here?

答: I dont know your folder or your package structure, but you can try to remove the first '/' for the path you given in the getRessource() method, it may be looking for a absulute path.</p>

Body:
I know this has been asked before but I can't get it to work after trying all variations.I have a small program that I'm wanting the launch frame to have an image displayed on it. I can achieve this by having the jar in the same folder as the image and referencing it, however when I try to reference within the jar file itself I keep getting error:

Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException

The code I am using is this:

private void imagePanel() {
    setLayout(new BorderLayout());
    BufferedImage image;
    try {
        image = ImageIO.read(this.getClass().getResource("/src/ticketMaster/img/logo.png"));
    } catch (IOException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
    add(new JLabel(new ImageIcon(image)), BorderLayout.CENTER);
}

I'm not sure if the path is incorrect, I have made a img folder inside the package named img which contains the logo. I have tried all variations of it

/img/logo.png
/ticketMaster/img/logo.png
/src/ticketMaster/img/logo.png

I am not able to get the image to load like I would just referencing the image outside of the jar. I've used resourceasstream as well and not had any luck with that.

Any ideas here?


问:
Android app crashes on launch due to constrain layout
I try to run my app but I keep getting this error:

```<code>java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.nachum.pap/com.example.nachum.pap.MainMap}: android.view.InflateException: Binary XML file line #2: Error inflating class android.support.constraint.ConstraintLayout
</code>```

I implemented Constraint Layout as instructed but it didn't help

my xml:

```<code><?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/white"
    tools:context=".MainMap">

    <android.support.constraint.ConstraintLayout
        android:layout_width="@dimen/map_width"
        android:layout_height="@dimen/map_height"
        android:layout_marginEnd="8dp"
        android:layout_marginRight="8dp"
        android:background="@drawable/menu_map"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <!--
            The function "go to map" that activates in the onClick goes to the google maps activity and exists in MainMap java file
            The tag helps discern where on the map should the maps activity open.
        -->
        <Button
            android:id="@+id/MaalotButton"
            style="@android:style/Widget.Holo.Light.Button.Borderless.Small"
            android:layout_width="32dp"
            android:layout_height="10dp"
            android:layout_marginLeft="96dp"
            android:layout_marginTop="28dp"
            android:onClick="goToMap" android:tag="0"
            android:text="@string/PaPMaalot"
            android:textSize="8sp"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <Button
            android:id="@+id/ShderotButton"
            style="@android:style/Widget.Holo.Light.Button.Borderless.Small"
            android:layout_width="32dp"
            android:layout_height="10dp"
            android:layout_marginTop="24dp"
            android:layout_marginRight="10dp"
            android:onClick="goToMap" android:tag="1"
            android:text="@string/PaPShderot"
            android:textSize="8sp"
            app:layout_constraintRight_toRightOf="@+id/AshdodButton"
            app:layout_constraintTop_toBottomOf="@+id/AshdodButton" />

        <Button
            android:id="@+id/KfarVardimButton"
            style="@android:style/Widget.Holo.Light.Button.Borderless.Small"
            android:layout_width="46dp"
            android:layout_height="10dp"
            android:layout_marginRight="6dp"
            android:onClick="goToMap" android:tag="2"
            android:text="@string/PaPKfarVradim"
            android:textSize="8sp"
            app:layout_constraintRight_toRightOf="@+id/MaalotButton"
            app:layout_constraintTop_toBottomOf="@+id/MaalotButton" />

        <Button
            android:id="@+id/TalElButton"
            style="@android:style/Widget.Holo.Light.Button.Borderless.Small"
            android:layout_width="32dp"
            android:layout_height="10dp"
            android:layout_marginRight="8dp"
            android:onClick="goToMap" android:tag="3"
            android:text="@string/PaPTalEl"
            android:textSize="8sp"
            app:layout_constraintRight_toRightOf="@+id/KfarVardimButton"
            app:layout_constraintTop_toBottomOf="@+id/KfarVardimButton" />

        <Button
            android:id="@+id/CholonButton"
            style="@android:style/Widget.Holo.Light.Button.Borderless.Small"
            android:layout_width="32dp"
            android:layout_height="10dp"
            android:layout_marginTop="110dp"
            android:layout_marginRight="12dp"
            android:onClick="goToMap" android:tag="4"
            android:text="@string/PaPCholon"
            android:textSize="8sp"
            app:layout_constraintRight_toLeftOf="@+id/TalElButton"
            app:layout_constraintTop_toBottomOf="@+id/TalElButton" />

        <Button
            android:id="@+id/AshdodButton"
            style="@android:style/Widget.Holo.Light.Button.Borderless.Small"
            android:layout_width="32dp"
            android:layout_height="10dp"
            android:layout_marginTop="18dp"
            android:layout_marginRight="14dp"
            android:onClick="goToMap" android:tag="5"
            android:text="@string/PaPAshdod"
            android:textSize="8sp"
            app:layout_constraintRight_toRightOf="@+id/CholonButton"
            app:layout_constraintTop_toBottomOf="@+id/CholonButton" />

        <Button
            android:id="@+id/TfachotButton"
            style="@android:style/Widget.Holo.Light.Button.Borderless.Small"
            android:layout_width="32dp"
            android:layout_height="10dp"
            android:layout_marginTop="7dp"
            android:layout_marginRight="8dp"
            android:onClick="goToMap" android:tag="6"
            android:text="@string/PaPTfachot"
            android:textSize="8sp"
            app:layout_constraintRight_toRightOf="@+id/BarYochayButton7"
            app:layout_constraintTop_toBottomOf="@+id/BarYochayButton7" />

        <Button
            android:id="@+id/DaltonButton"
            style="@android:style/Widget.Holo.Light.Button.Borderless.Small"
            android:layout_width="32dp"
            android:layout_height="10dp"
            android:layout_marginLeft="8dp"
            android:onClick="goToMap" android:tag="7"
            android:text="@string/PaPDalton"
            android:textSize="8sp"
            app:layout_constraintLeft_toRightOf="@+id/MaalotButton"
            app:layout_constraintTop_toTopOf="@+id/MaalotButton" />

        <Button
            android:id="@+id/BarYochayButton7"
            style="@android:style/Widget.Holo.Light.Button.Borderless.Small"
            android:layout_width="38dp"
            android:layout_height="10dp"
            android:layout_marginTop="7dp"
            android:layout_marginRight="8dp"
            android:onClick="goToMap" android:tag="8"
            android:text="@string/PaPBarYochay"
            android:textSize="8sp"
            app:layout_constraintRight_toRightOf="@+id/DaltonButton"
            app:layout_constraintTop_toBottomOf="@+id/DaltonButton" />
    </android.support.constraint.ConstraintLayout>

</android.support.constraint.ConstraintLayout>
</code>```

java:

```<code>package com.example.nachum.pap;

import android.content.Intent;
import android.view.View;
import android.os.Bundle;
import android.widget.EditText;

import androidx.appcompat.app.AppCompatActivity;

public class MainMap extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main_map);
    }

    /** Called when the user taps the Send button */
    public void goToMap(View view) {
        Intent intent = new Intent(this, NAVDRAW.class);
        intent.putExtra("num", view.getTag().toString());
        startActivity(intent);
    }

}

</code>```

logcat:

```<code>07-15 06:13:44.064 20107-20107/? I/art: Late-enabling -Xcheck:jni
07-15 06:13:44.604 20107-20107/com.example.nachum.pap W/FirebaseApp: Default FirebaseApp failed to initialize because no default options were found. This usually means that com.google.gms:google-services was not applied to your gradle project.
07-15 06:13:44.604 20107-20107/com.example.nachum.pap I/FirebaseInitProvider: FirebaseApp initialization unsuccessful
07-15 06:13:44.634 20107-20107/com.example.nachum.pap I/InstantRun: starting instant run server: is main process
07-15 06:13:44.804 20107-20107/com.example.nachum.pap D/ContextHelper: convertTheme. context->name=com.example.nachum.pap themeResourceId=2131689478
07-15 06:13:44.874 20107-20107/com.example.nachum.pap W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter androidx.vectordrawable.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
07-15 06:13:44.944 20107-20107/com.example.nachum.pap D/PhoneWindow: [updateColorViews] sysUiVisibility=0x0
07-15 06:13:44.944 20107-20107/com.example.nachum.pap D/PhoneWindow: [updateColorViews] sysUiVisibility=0x0
07-15 06:13:44.944 20107-20107/com.example.nachum.pap D/PhoneWindow: [updateColorViews] sysUiVisibility=0x0
07-15 06:13:44.944 20107-20107/com.example.nachum.pap D/PhoneWindow: [updateColorViews] sysUiVisibility=0x0
07-15 06:13:44.944 20107-20107/com.example.nachum.pap I/PhoneWindow: [generateLayout] setColorNavigationBar => color=0x ff000001
07-15 06:13:44.944 20107-20107/com.example.nachum.pap D/PhoneWindow: [updateColorViews] sysUiVisibility=0x0
07-15 06:13:45.004 20107-20107/com.example.nachum.pap D/PhoneWindow: [updateColorViews] sysUiVisibility=0x0
07-15 06:13:45.004 20107-20107/com.example.nachum.pap D/PhoneWindowEx: [PWEx][generateLayout] setNavigationBarColor2 : colors=0xff000000
07-15 06:13:45.004 20107-20107/com.example.nachum.pap I/PhoneWindow: [setNavigationBarColor2] color=0x ff000000
07-15 06:13:45.004 20107-20107/com.example.nachum.pap D/PhoneWindow: [updateColorViews] sysUiVisibility=0x0
07-15 06:13:45.004 20107-20107/com.example.nachum.pap D/PhoneWindow: [updateColorViews] sysUiVisibility=0x0
07-15 06:13:45.054 20107-20107/com.example.nachum.pap I/art: Rejecting re-init on previously-failed class java.lang.Class<androidx.core.view.ViewCompat$OnUnhandledKeyEventListenerWrapper>
07-15 06:13:45.054 20107-20107/com.example.nachum.pap I/art: Rejecting re-init on previously-failed class java.lang.Class<androidx.core.view.ViewCompat$OnUnhandledKeyEventListenerWrapper>
07-15 06:13:45.214 20107-20107/com.example.nachum.pap D/AndroidRuntime: Shutting down VM
07-15 06:13:45.214 20107-20107/com.example.nachum.pap E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.nachum.pap, PID: 20107
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.nachum.pap/com.example.nachum.pap.MainMap}: android.view.InflateException: Binary XML file line #2: Error inflating class android.support.constraint.ConstraintLayout
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2306)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2366)
        at android.app.ActivityThread.access$800(ActivityThread.java:149)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1284)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:135)
        at android.app.ActivityThread.main(ActivityThread.java:5297)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:372)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:908)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:703)
     Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class android.support.constraint.ConstraintLayout
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:757)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:482)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
        at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
        at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
        at com.example.nachum.pap.MainMap.onCreate(MainMap.java:17)
        at android.app.Activity.performCreate(Activity.java:6020)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2259)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2366)
        at android.app.ActivityThread.access$800(ActivityThread.java:149)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1284)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:135)
        at android.app.ActivityThread.main(ActivityThread.java:5297)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:372)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:908)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:703)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.constraint.ConstraintLayout" on path: DexPathList[[zip file "/data/app/com.example.nachum.pap-1/base.apk", zip file "/data/app/com.example.nachum.pap-1/split_lib_dependencies_apk.apk", zip file "/data/app/com.example.nachum.pap-1/split_lib_slice_0_apk.apk", zip file "/data/app/com.example.nachum.pap-1/split_lib_slice_1_apk.apk", zip file "/data/app/com.example.nachum.pap-1/split_lib_slice_2_apk.apk", zip file "/data/app/com.example.nachum.pap-1/split_lib_slice_3_apk.apk", zip file "/data/app/com.example.nachum.pap-1/split_lib_slice_4_apk.apk", zip file "/data/app/com.example.nachum.pap-1/split_lib_slice_5_apk.apk", zip file "/data/app/com.example.nachum.pap-1/split_lib_slice_6_apk.apk", zip file "/data/app/com.example.nachum.pap-1/split_lib_slice_7_apk.apk", zip file "/data/app/com.example.nachum.pap-1/split_lib_slice_8_apk.apk", zip file "/data/app/com.example.nachum.pap-1/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
        at android.view.LayoutInflater.createView(LayoutInflater.java:571)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:482)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
        at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
        at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
        at com.example.nachum.pap.MainMap.onCreate(MainMap.java:17)
        at android.app.Activity.performCreate(Activity.java:6020)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2259)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2366)
        at android.app.ActivityThread.access$800(ActivityThread.java:149)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1284)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:135)
        at android.app.ActivityThread.main(ActivityThread.java:5297)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:372)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:908)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:703)
        Suppressed: java.lang.ClassNotFoundException: android.support.constraint.ConstraintLayout
        at java.lang.Class.classForName(Native Method)
        at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
        at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
                ... 22 more
     Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available

</code>```

EDIT:
app gradle:

```<code>apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.nachum.pap"
        minSdkVersion 15
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:support-compat:28.0.0'
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.google.android.gms:play-services-maps:17.0.0'
    implementation 'com.android.support:design:28.1.0'
    implementation 'com.google.firebase:firebase-database:18.0.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
</code>```

project level gradle:

```<code>// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

    repositories {
        google()
        jcenter()
        maven { url "https://maven.google.com/"}
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.2'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
</code>```

答: My problem was a missing drawable. IN fact a main drawable was missing from the default but I had it in bigger screen. I didn't see it because with the device I used for debugging, it was working.</p>

Body:
I try to run my app but I keep getting this error:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.nachum.pap/com.example.nachum.pap.MainMap}: android.view.InflateException: Binary XML file line #2: Error inflating class android.support.constraint.ConstraintLayout

I implemented Constraint Layout as instructed but it didn't help

my xml:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/white"
    tools:context=".MainMap">

    <android.support.constraint.ConstraintLayout
        android:layout_width="@dimen/map_width"
        android:layout_height="@dimen/map_height"
        android:layout_marginEnd="8dp"
        android:layout_marginRight="8dp"
        android:background="@drawable/menu_map"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <Button
            android:id="@+id/MaalotButton"
            style="@android:style/Widget.Holo.Light.Button.Borderless.Small"
            android:layout_width="32dp"
            android:layout_height="10dp"
            android:layout_marginLeft="96dp"
            android:layout_marginTop="28dp"
            android:onClick="goToMap" android:tag="0"
            android:text="@string/PaPMaalot"
            android:textSize="8sp"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <Button
            android:id="@+id/ShderotButton"
            style="@android:style/Widget.Holo.Light.Button.Borderless.Small"
            android:layout_width="32dp"
            android:layout_height="10dp"
            android:layout_marginTop="24dp"
            android:layout_marginRight="10dp"
            android:onClick="goToMap" android:tag="1"
            android:text="@string/PaPShderot"
            android:textSize="8sp"
            app:layout_constraintRight_toRightOf="@+id/AshdodButton"
            app:layout_constraintTop_toBottomOf="@+id/AshdodButton" />

        <Button
            android:id="@+id/KfarVardimButton"
            style="@android:style/Widget.Holo.Light.Button.Borderless.Small"
            android:layout_width="46dp"
            android:layout_height="10dp"
            android:layout_marginRight="6dp"
            android:onClick="goToMap" android:tag="2"
            android:text="@string/PaPKfarVradim"
            android:textSize="8sp"
            app:layout_constraintRight_toRightOf="@+id/MaalotButton"
            app:layout_constraintTop_toBottomOf="@+id/MaalotButton" />

        <Button
            android:id="@+id/TalElButton"
            style="@android:style/Widget.Holo.Light.Button.Borderless.Small"
            android:layout_width="32dp"
            android:layout_height="10dp"
            android:layout_marginRight="8dp"
            android:onClick="goToMap" android:tag="3"
            android:text="@string/PaPTalEl"
            android:textSize="8sp"
            app:layout_constraintRight_toRightOf="@+id/KfarVardimButton"
            app:layout_constraintTop_toBottomOf="@+id/KfarVardimButton" />

        <Button
            android:id="@+id/CholonButton"
            style="@android:style/Widget.Holo.Light.Button.Borderless.Small"
            android:layout_width="32dp"
            android:layout_height="10dp"
            android:layout_marginTop="110dp"
            android:layout_marginRight="12dp"
            android:onClick="goToMap" android:tag="4"
            android:text="@string/PaPCholon"
            android:textSize="8sp"
            app:layout_constraintRight_toLeftOf="@+id/TalElButton"
            app:layout_constraintTop_toBottomOf="@+id/TalElButton" />

        <Button
            android:id="@+id/AshdodButton"
            style="@android:style/Widget.Holo.Light.Button.Borderless.Small"
            android:layout_width="32dp"
            android:layout_height="10dp"
            android:layout_marginTop="18dp"
            android:layout_marginRight="14dp"
            android:onClick="goToMap" android:tag="5"
            android:text="@string/PaPAshdod"
            android:textSize="8sp"
            app:layout_constraintRight_toRightOf="@+id/CholonButton"
            app:layout_constraintTop_toBottomOf="@+id/CholonButton" />

        <Button
            android:id="@+id/TfachotButton"
            style="@android:style/Widget.Holo.Light.Button.Borderless.Small"
            android:layout_width="32dp"
            android:layout_height="10dp"
            android:layout_marginTop="7dp"
            android:layout_marginRight="8dp"
            android:onClick="goToMap" android:tag="6"
            android:text="@string/PaPTfachot"
            android:textSize="8sp"
            app:layout_constraintRight_toRightOf="@+id/BarYochayButton7"
            app:layout_constraintTop_toBottomOf="@+id/BarYochayButton7" />

        <Button
            android:id="@+id/DaltonButton"
            style="@android:style/Widget.Holo.Light.Button.Borderless.Small"
            android:layout_width="32dp"
            android:layout_height="10dp"
            android:layout_marginLeft="8dp"
            android:onClick="goToMap" android:tag="7"
            android:text="@string/PaPDalton"
            android:textSize="8sp"
            app:layout_constraintLeft_toRightOf="@+id/MaalotButton"
            app:layout_constraintTop_toTopOf="@+id/MaalotButton" />

        <Button
            android:id="@+id/BarYochayButton7"
            style="@android:style/Widget.Holo.Light.Button.Borderless.Small"
            android:layout_width="38dp"
            android:layout_height="10dp"
            android:layout_marginTop="7dp"
            android:layout_marginRight="8dp"
            android:onClick="goToMap" android:tag="8"
            android:text="@string/PaPBarYochay"
            android:textSize="8sp"
            app:layout_constraintRight_toRightOf="@+id/DaltonButton"
            app:layout_constraintTop_toBottomOf="@+id/DaltonButton" />
    </android.support.constraint.ConstraintLayout>

</android.support.constraint.ConstraintLayout>

java:

package com.example.nachum.pap;

import android.content.Intent;
import android.view.View;
import android.os.Bundle;
import android.widget.EditText;

import androidx.appcompat.app.AppCompatActivity;

public class MainMap extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main_map);
    }

    /** Called when the user taps the Send button */
    public void goToMap(View view) {
        Intent intent = new Intent(this, NAVDRAW.class);
        intent.putExtra("num", view.getTag().toString());
        startActivity(intent);
    }

}

logcat:

07-15 06:13:44.064 20107-20107/? I/art: Late-enabling -Xcheck:jni
07-15 06:13:44.604 20107-20107/com.example.nachum.pap W/FirebaseApp: Default FirebaseApp failed to initialize because no default options were found. This usually means that com.google.gms:google-services was not applied to your gradle project.
07-15 06:13:44.604 20107-20107/com.example.nachum.pap I/FirebaseInitProvider: FirebaseApp initialization unsuccessful
07-15 06:13:44.634 20107-20107/com.example.nachum.pap I/InstantRun: starting instant run server: is main process
07-15 06:13:44.804 20107-20107/com.example.nachum.pap D/ContextHelper: convertTheme. context->name=com.example.nachum.pap themeResourceId=2131689478
07-15 06:13:44.874 20107-20107/com.example.nachum.pap W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter androidx.vectordrawable.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
07-15 06:13:44.944 20107-20107/com.example.nachum.pap D/PhoneWindow: [updateColorViews] sysUiVisibility=0x0
07-15 06:13:44.944 20107-20107/com.example.nachum.pap D/PhoneWindow: [updateColorViews] sysUiVisibility=0x0
07-15 06:13:44.944 20107-20107/com.example.nachum.pap D/PhoneWindow: [updateColorViews] sysUiVisibility=0x0
07-15 06:13:44.944 20107-20107/com.example.nachum.pap D/PhoneWindow: [updateColorViews] sysUiVisibility=0x0
07-15 06:13:44.944 20107-20107/com.example.nachum.pap I/PhoneWindow: [generateLayout] setColorNavigationBar => color=0x ff000001
07-15 06:13:44.944 20107-20107/com.example.nachum.pap D/PhoneWindow: [updateColorViews] sysUiVisibility=0x0
07-15 06:13:45.004 20107-20107/com.example.nachum.pap D/PhoneWindow: [updateColorViews] sysUiVisibility=0x0
07-15 06:13:45.004 20107-20107/com.example.nachum.pap D/PhoneWindowEx: [PWEx][generateLayout] setNavigationBarColor2 : colors=0xff000000
07-15 06:13:45.004 20107-20107/com.example.nachum.pap I/PhoneWindow: [setNavigationBarColor2] color=0x ff000000
07-15 06:13:45.004 20107-20107/com.example.nachum.pap D/PhoneWindow: [updateColorViews] sysUiVisibility=0x0
07-15 06:13:45.004 20107-20107/com.example.nachum.pap D/PhoneWindow: [updateColorViews] sysUiVisibility=0x0
07-15 06:13:45.054 20107-20107/com.example.nachum.pap I/art: Rejecting re-init on previously-failed class java.lang.Class<androidx.core.view.ViewCompat$OnUnhandledKeyEventListenerWrapper>
07-15 06:13:45.054 20107-20107/com.example.nachum.pap I/art: Rejecting re-init on previously-failed class java.lang.Class<androidx.core.view.ViewCompat$OnUnhandledKeyEventListenerWrapper>
07-15 06:13:45.214 20107-20107/com.example.nachum.pap D/AndroidRuntime: Shutting down VM
07-15 06:13:45.214 20107-20107/com.example.nachum.pap E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.nachum.pap, PID: 20107
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.nachum.pap/com.example.nachum.pap.MainMap}: android.view.InflateException: Binary XML file line #2: Error inflating class android.support.constraint.ConstraintLayout
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2306)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2366)
        at android.app.ActivityThread.access$800(ActivityThread.java:149)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1284)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:135)
        at android.app.ActivityThread.main(ActivityThread.java:5297)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:372)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:908)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:703)
     Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class android.support.constraint.ConstraintLayout
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:757)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:482)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
        at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
        at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
        at com.example.nachum.pap.MainMap.onCreate(MainMap.java:17)
        at android.app.Activity.performCreate(Activity.java:6020)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2259)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2366)
        at android.app.ActivityThread.access$800(ActivityThread.java:149)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1284)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:135)
        at android.app.ActivityThread.main(ActivityThread.java:5297)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:372)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:908)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:703)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.constraint.ConstraintLayout" on path: DexPathList[[zip file "/data/app/com.example.nachum.pap-1/base.apk", zip file "/data/app/com.example.nachum.pap-1/split_lib_dependencies_apk.apk", zip file "/data/app/com.example.nachum.pap-1/split_lib_slice_0_apk.apk", zip file "/data/app/com.example.nachum.pap-1/split_lib_slice_1_apk.apk", zip file "/data/app/com.example.nachum.pap-1/split_lib_slice_2_apk.apk", zip file "/data/app/com.example.nachum.pap-1/split_lib_slice_3_apk.apk", zip file "/data/app/com.example.nachum.pap-1/split_lib_slice_4_apk.apk", zip file "/data/app/com.example.nachum.pap-1/split_lib_slice_5_apk.apk", zip file "/data/app/com.example.nachum.pap-1/split_lib_slice_6_apk.apk", zip file "/data/app/com.example.nachum.pap-1/split_lib_slice_7_apk.apk", zip file "/data/app/com.example.nachum.pap-1/split_lib_slice_8_apk.apk", zip file "/data/app/com.example.nachum.pap-1/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
        at android.view.LayoutInflater.createView(LayoutInflater.java:571)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:482)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
        at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
        at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
        at com.example.nachum.pap.MainMap.onCreate(MainMap.java:17)
        at android.app.Activity.performCreate(Activity.java:6020)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2259)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2366)
        at android.app.ActivityThread.access$800(ActivityThread.java:149)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1284)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:135)
        at android.app.ActivityThread.main(ActivityThread.java:5297)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:372)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:908)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:703)
        Suppressed: java.lang.ClassNotFoundException: android.support.constraint.ConstraintLayout
        at java.lang.Class.classForName(Native Method)
        at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
        at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
                ... 22 more
     Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available

EDIT:
app gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.nachum.pap"
        minSdkVersion 15
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:support-compat:28.0.0'
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.google.android.gms:play-services-maps:17.0.0'
    implementation 'com.android.support:design:28.1.0'
    implementation 'com.google.firebase:firebase-database:18.0.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

project level gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

    repositories {
        google()
        jcenter()
        maven { url "https://maven.google.com/"}
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.2'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}


问:
Difference between "enqueue" and "dequeue"
Can somebody please explain the main differences? I don't have a clear knowledge about these functions in programming for any language.</p>

答:
Enqueue means to add an element, dequeue to remove an element.

```<code>var stackInput= []; // First stack
var stackOutput= []; // Second stack

// For enqueue, just push the item into the first stack
function enqueue(stackInput, item) {
  return stackInput.push(item);
}

function dequeue(stackInput, stackOutput) {
  // Reverse the stack such that the first element of the output stack is the
  // last element of the input stack. After that, pop the top of the output to
  // get the first element that was ever pushed into the input stack
  if (stackOutput.length <= 0) {
    while(stackInput.length > 0) {
      var elementToOutput = stackInput.pop();
      stackOutput.push(elementToOutput);
    }
  }

  return stackOutput.pop();
}
</code>```

Body:
Enqueue means to add an element, dequeue to remove an element.

var stackInput= []; // First stack
var stackOutput= []; // Second stack

// For enqueue, just push the item into the first stack
function enqueue(stackInput, item) {
  return stackInput.push(item);
}

function dequeue(stackInput, stackOutput) {
  // Reverse the stack such that the first element of the output stack is the
  // last element of the input stack. After that, pop the top of the output to
  // get the first element that was ever pushed into the input stack
  if (stackOutput.length <= 0) {
    while(stackInput.length > 0) {
      var elementToOutput = stackInput.pop();
      stackOutput.push(elementToOutput);
    }
  }

  return stackOutput.pop();
}