问:
Could not resolve com.android.support:appcompat-v7:26.1.0 in Android Studio new project
I know about this questions:

Failed to resolve: com.android.support:cardview-v7:26.0.0 android

Could not resolve com.android.support:appcompat-v7:26.1.0 [duplicate]

And I've read this documentations:

Migrate to Android Plugin for Gradle 3.0.0

Migrating to Android 8.0

So I'm posting this question believing its not a duplicate.

I've installed Android Studio 3.0.1. I didn't have any previous version before and I started a new project.

Every setting in Gradle file have been set by Android Studio itself and I've checked them all.

These are the file contents:

build.gradle (Module:app)

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

    android {
        compileSdkVersion 26
        defaultConfig {
            applicationId "com.example.administrator.as301test"
            minSdkVersion 16
            targetSdkVersion 26
            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:appcompat-v7:26.1.0'
        implementation 'com.android.support.constraint:constraint-layout:1.0.2'
        implementation 'com.android.support:design:26.1.0'
        testImplementation 'junit:junit:4.12'
        androidTestImplementation 'com.android.support.test:runner:1.0.1'
        androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    }
</code>```

Top level build.gradle

```<code>buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'

        // 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>```

gradle-wrapper.properties

```<code>distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
</code>```

I use google() in repositories as here clearly says:

```<code>  // If you're using a version of Gradle lower than 4.1, you must instead use:
     // maven {
     //     url 'https://maven.google.com'
     // }
</code>```

My gradle version is 4.1 so I don't need above code.

But I still get this error as the others have been asking about:

Error:Unable to resolve dependency for ':app@debug/compileClasspath':
  Could not resolve com.android.support:appcompat-v7:26.1.0.

Why should I get this error when I'm creating a new project in AS 3.0.1 and it has been set all the necessary settings?

Update

@Rohit's answer somehow solved the issue but I still get same error for some other dependencies.

Could not resolve com.android.support.test:runner:1.0.1

Could not resolve
  com.android.support.test.espresso:espresso-core:3.0.1

Could not resolve junit:junit:4.12

答:
Finally I fixed the problem by modifying build.gradle like this:

```<code>android {
    compileSdkVersion 26
    buildToolsVersion "26.0.2"

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 26
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.android.support:design:26.1.0'
}
</code>```

I've removed these lines as these will produce more errors:

```<code>testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
</code>```

Also I had same problem with migrating an existing project from 2.3 to 3.0.1 and with modifying the project gradle files like this, I came up with a working solution:

build.gradle (module app)

```<code>android {
    compileSdkVersion 27
    buildToolsVersion "27.0.1"

    defaultConfig {
        applicationId "com.mobaleghan.tablighcalendar"
        minSdkVersion 16
        targetSdkVersion 27
    }

dependencies {
    implementation 'com.android.support:appcompat-v7:25.1.0'
    implementation 'com.android.support:design:25.1.0'
    implementation 'com.android.support:preference-v7:25.1.0'
    implementation 'com.android.support:recyclerview-v7:25.1.0'
    implementation 'com.android.support:support-annotations:25.1.0'
    implementation 'com.android.support:support-v4:25.1.0'
    implementation 'com.android.support:cardview-v7:25.1.0'
    implementation 'com.google.android.apps.dashclock:dashclock-api:2.0.0'
}
</code>```

Top level build.gradle

```<code>buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}
</code>```

Body:
I know about this questions:

Failed to resolve: com.android.support:cardview-v7:26.0.0 android

Could not resolve com.android.support:appcompat-v7:26.1.0 [duplicate]

And I've read this documentations:

Migrate to Android Plugin for Gradle 3.0.0

Migrating to Android 8.0

So I'm posting this question believing its not a duplicate.

I've installed Android Studio 3.0.1. I didn't have any previous version before and I started a new project.

Every setting in Gradle file have been set by Android Studio itself and I've checked them all.

These are the file contents:

build.gradle (Module:app)

    apply plugin: 'com.android.application'

    android {
        compileSdkVersion 26
        defaultConfig {
            applicationId "com.example.administrator.as301test"
            minSdkVersion 16
            targetSdkVersion 26
            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:appcompat-v7:26.1.0'
        implementation 'com.android.support.constraint:constraint-layout:1.0.2'
        implementation 'com.android.support:design:26.1.0'
        testImplementation 'junit:junit:4.12'
        androidTestImplementation 'com.android.support.test:runner:1.0.1'
        androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    }

Top level build.gradle

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'

        // 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
}

gradle-wrapper.properties

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip

I use google() in repositories as here clearly says:

  // If you're using a version of Gradle lower than 4.1, you must instead use:
     // maven {
     //     url 'https://maven.google.com'
     // }

My gradle version is 4.1 so I don't need above code.

But I still get this error as the others have been asking about:

Error:Unable to resolve dependency for ':app@debug/compileClasspath':
  Could not resolve com.android.support:appcompat-v7:26.1.0.

Why should I get this error when I'm creating a new project in AS 3.0.1 and it has been set all the necessary settings?

Update

@Rohit's answer somehow solved the issue but I still get same error for some other dependencies.

Could not resolve com.android.support.test:runner:1.0.1

Could not resolve
  com.android.support.test.espresso:espresso-core:3.0.1

Could not resolve junit:junit:4.12

Body:
Finally I fixed the problem by modifying build.gradle like this:

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.2"

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 26
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.android.support:design:26.1.0'
}

I've removed these lines as these will produce more errors:

testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'

Also I had same problem with migrating an existing project from 2.3 to 3.0.1 and with modifying the project gradle files like this, I came up with a working solution:

build.gradle (module app)

android {
    compileSdkVersion 27
    buildToolsVersion "27.0.1"

    defaultConfig {
        applicationId "com.mobaleghan.tablighcalendar"
        minSdkVersion 16
        targetSdkVersion 27
    }

dependencies {
    implementation 'com.android.support:appcompat-v7:25.1.0'
    implementation 'com.android.support:design:25.1.0'
    implementation 'com.android.support:preference-v7:25.1.0'
    implementation 'com.android.support:recyclerview-v7:25.1.0'
    implementation 'com.android.support:support-annotations:25.1.0'
    implementation 'com.android.support:support-v4:25.1.0'
    implementation 'com.android.support:cardview-v7:25.1.0'
    implementation 'com.google.android.apps.dashclock:dashclock-api:2.0.0'
}

Top level build.gradle

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
    }
}

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


来源: stackexchange

问:
Java - String value is getting break when doing a concat

I am preparing a mail content using HTML (I am using spring mime message for sending mails) with embedded images in it. The HTML is as follow.

```<code><html><body><div><div style='margin-top: 0; margin-bottom: 0;'><font face='Times New Roman' size='3'> </font></div><div style='margin-top: 0; margin-bottom: 0;'><table width='100%' style='border-collapse: collapse; width: 100%;'><tbody><tr height='8' style='height: 8px;'><td style='width: 100%; padding: 0; border: 0 none black;'><table width='100%'style='border-collapse: collapse; width: 100%;'><tbody><tr height='8' style='height: 8px;'><td style='width: 100%; padding: 0; border: 0 none black;'><table width='600' align='center' style='border-collapse: collapse; width: 600px;><tbody><tr height='8' style='height: 8px;'><td width='600' style='width: 600px; padding: 0; border: 0 none black;'><table width='600' align='center'style='border-collapse: collapse; width: 600px;'><tbody><tr height='8' style='height: 8px;'><td width='600'style='width: 600px; padding: 0; border: 0 none black;'><table width='600' align='left'style='border-collapse: collapse; width: 600px;'><tbody><tr height='8' style='height: 8px;'><td width='600' style='width: 600px; padding: 0;border: 0 none black;'><table width='600' align='left'style='border-collapse:collapse; width: 600px;'><tbody><tr height='8' style='height: 8px;'><td width='600'style='width:600px; padding:0; border: 0 none black;'><div align='center' style='text-align:center;'><a href='http://www.e-XXXXbank.com/'target='_blank'> <img src='cid:logo' 'align='top' alt='logo' style='display:inline;'></a></div></td></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></td></tr><tr height='8' style='height: 8px;'><td style='padding: 0; border: 0 none black;'><br><table width='600' align='center'<tbody><tr height='8' style='height: 8px;'><td width='600'style='width: 600px; padding: 0; border: 0 none black;'><table width='560' align='center'style='border-collapse: collapse; width: 560px;'><tbody><tr height='8' style='height: 8px;'><td width='560'style='width: 560px; padding: 0; border: 0 none black;'><table width='100%'style='border-collapse: collapse; width: 100%;'><tbody><tr height='8' style='height: 8px;'><td style='width: 100%; padding: 0; border: 0 none black;'><table width='560' align='center'style='border-collapse: collapse; width: 560px;'><tbody><tr height='8' style='height: 8px;'><td width='558'style='width: 558px; background-color: #F0F0F0; padding: 0; border: 1px solid #ECECED;'><span style='background-color: #F0F0F0;'><div align='center' style='text-align: center;'><font face='Arial' size='4' color='#104160'><b>XXXX Portfolio Confirmation</b></font></div></span></td></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></td></tr><tr height='8' style='height: 8px;'><td style='padding: 0; border: 0 none black;'><br><table width='600' align='center'style='border-collapse: collapse; width: 600px;'><tbody><tr height='8' style='height: 8px;'><td width='600' style='width: 600px; padding: 0; border: 0 none black;'><img src='cid:space' align='top'alt='space' style='display: inline;'></td></tr></tbody></table></td></tr><tr height='8' style='height: 8px;'><td style='padding: 0; border: 0 none black;'><br><table width='600' align='center'style='border-collapse: collapse; width: 600px;'><tbody><tr height='8' style='height: 8px;'><td width='600'style='width: 600px; padding: 0; border: 0 none black;'><table width='560' align='center'style='border-collapse: collapse; width: 560px;'><tbody><tr height='8' style='height: 8px;'><td width='560'style='width: 560px; padding: 0; border: 0 none black;'><table width='550' align='right'style='border-collapse: collapse; width: 550px;'><tbody><tr height='8' style='height: 8px;'><td width='550'style='width: 550px; padding: 0; border: 0 none black;'></td></tr><tr height='8' style='height: 8px;'><td width='550'style='width: 550px; padding: 0; border: 0 none black;'><table width='550' align='left'style='border-collapse: collapse; width: 550px;'><tbody><tr height='8' style='height: 8px;'><td colspan='2' width='550'style='width: 550px; padding: 0; border: 0 none black;'><font face='Arial' size='4' color='#C21212'><b>Dear Customer</b></font></td></tr><tr height='8' style='height: 8px;'><td colspan='2' width='550'style='width: 550px; padding: 0; border: 0 none black;'><font face='Arial' size='4' color='#104160'><br>Following your instructions we have created your XXXX. The document attached enable you to view the details of your portfolio. You can save, print and store it for your records.</font><font face='Arial' size='4' color='#104160'><br></font><font face='Arial' size='4' color='#104160'><br>For security reasons, the document is protected with a password that has been sent to your mobile by SMS.</font><font face='Arial' size='4' color='#104160'><br></font><font face='Arial' size='4' color='#104160'><br>Many thanks for trusting us to help you manage your finances.</font></td></tr><tr height='8' style='height: 8px;'><td width='510' style='width: 510px; padding: 0; border: 0 none black;'></td><td width='39' style='width: 39px; padding: 0; border: 0 none black;'></td></tr><tr height='8' style='height: 8px;'><td colspan='2' width='550'style='width: 550px; padding: 0; border: 0 noneblack;'><font face='Arial' size='4' color='#C21212'><b>XXXX YYYYY Customer Service</b></font></td></tr><tr height='8' style='height: 8px;'><td width='510' valign='top'style='width: 510px; padding: 0; border: 0 none black;'><table width='510' align='left'style='border-collapse: collapse; width:510px;'><tbody><tr height='8' style='height: 8px;'><td width='510'style='width: 510px; padding:0; border: 0 none black;'></td></tr><tr height='8' style='height: 8px;'><td width='510'style='width: 510px; padding:0; border: 0 none black;'><font face='Times New Roman' size='2'> </font> <div style='margin-top: 0;margin-bottom: 0;'><font face='Times New Roman' size='2'> </font></div><div style='margin-top: 0;margin-bottom: 0;'><font face='Times New Roman' size='2'> </font></div><div style='margin-top: 0;margin-bottom: 0;'><font face='Times New Roman' size='2'> </font></div><div style='margin-top: 0;margin-bottom: 0;'><font face='Arial' size='2'color='#104160'>Please add </font><a href='mailto:XXXXYYYYY@XXXXbank.com.kw'target='_blank'><font face='Arial'size='2'>XXXXYYYYY@XXXXbank.com.kw</font></a><font face='Arial' size='2'color='#104160'> to your email address book to ensure your statements are not redirected to the junk folder.If there are any questions, please contact directly with your XXXX Bank manager.</font></div></td></tr><tr height='8' style='height: 8px;'><td width='510' style='width: 510px; padding: 0; border: 0 none black;'></td></tr></tbody></table></td><td width='39' style='width: 39px; padding: 0; border: 0 none black;'></td></tr></tbody></table> </td></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table> </td></tr><tr height='8' style='height: 8px;'><td style='padding: 0; border: 0 none black;'><br><table width='600' align='center' style='border-collapse: collapse; width: 600px;'><tbody><tr height='8' style='height: 8px;'><td width='600' style='width: 600px; padding: 0; border-width: 0 0 1px 0; border-style: none none solid none; border-color: black;'></td></tr></tbody></table></td></tr><tr height='8' style='height: 8px;'><td style='padding: 0; border: 0 none black;'><table width='600' align='center' style='border-collapse: collapse; width: 600px;'><tbody><tr height='8' style='height: 8px;'><td width='600' style='width: 600px; padding: 0; border: 0 none black;'></td></tr></tbody></table> <br></td></tr><tr height='8' style='height: 8px;'><td style='background-color: #F0F0F0; padding: 0; border: 0 none black;'><span style='background-color: #F0F0F0;'><table width='600' align='center' style='border-collapse: collapse; width: 600px;'><tbody><tr height='8' style='height: 8px;'><td width='600' style='width: 600px; padding: 0; border-width: 1px 0 0 0; border-style: solid none none none; border-color: #E6E6E6;'><table width='560' align='center'style='border-collapse: collapse; width: 560px;'><tbody><tr height='8' style='height: 8px;'><td width='560' style='width: 560px; padding: 0; border: 0 none black;'></td></tr><tr height='8' style='height: 8px;'><td width='560' style='width: 560px; padding: 0; border: 0 none black;'><table width='500' align='center' style='border-collapse: collapse; width: 500px;'><tbody><tr height='8' style='height: 8px;'><td width='300' style='width: 300px; padding: 0; border: 0 none black;'><div align='center' style='text-align: center;'><font face='Arial' size='2' color='#C21212'>© 2016 XXXX Bank. All rights reserved. </font><font face='Arial' size='2' color='#004080'>                    </font></div></td><td width='30' style='width: 30px; padding: 0; border: 0 none black;'><div align='center' style='text-align: center;'><a href='https://XXX/XXXX?_rdr' target='_blank'><img src='cid:facebook' alt='facebook' style='display:inline;'></a><td width='30' style='width: 30px; padding: 0; border: 0 none black;'><div align='center' style='text-align: center;'><a href='http://XXXX.com/XXXX' target='_blank'><img src='cid:twitter' align='top' alt='twitter' style='display:inline;'></a><td width='30' style='width: 30px; padding: 0; border: 0 none black;'><div align='center' style='text-align: center;'><a href='http://XXXXX.com/XXXX' target='_blank'><img src='cid:Instagram' align='top'alt='Instagram' style='display:inline;'></a><td width='30' style='width: 30px; padding: 0; border: 0 none black;'><div align='center' style='text-align: center;'><a href='https://www.youtube.com/XXX/YYYY' target='_blank'><img src='cid:youtube' align='top' alt='youtube' style='display:inline;'></a><td width='30' style='width: 30px; padding: 0; border: 0 none black;'><div align='center' style='text-align: center;'><a href='https://www.linkedin.com/company/XXXX?trk=hb_tab_compy_id_202412' target='_blank'><img src='cid:linkedIn' align='top' alt='linkedIn' style='display:inline;'></a></div></td></tr></tbody></table></td></tr><tr height='8' style='height: 8px;'><td width='560'style='width: 560px; padding: 0; border: 0 none black;'></td></tr></tbody></table> </td></tr></tbody></table></span></td</tr></tbody></table></div><div style='margin-top: 0; margin-bottom: 0;'><font face='Times New Roman' size='3'> </font></div><div style='margin-top: 0; margin-bottom: 0;'><img src='cid:tree' alt='http://XXXX/tree-small.jpg' style='display:inline;'><font face='Arial' size='1' color='green'>Please consider theenvironment & Print only if necessary</font></div><hr></div></body></html>
</code>```

I have prepared the mail content using string and embedded the images using CID

```<code>String htmltext1=mailContentStart.concat(mailContentLogo).concat(mailContentHeading).
                concat(mailContentSpace).concat(mailContentBody);
        String htmltext12=(mailContentImages).concat(mailEnd);
</code>```

When I contact htmltext 1 and htmltext2 am ending up with the below results

```<code><html><body><div><div style='margin-top: 0; margin-bottom: 0;'><font face='Times New Roman' size='3'> </font></div><div style='margin-top: 0; margin-bottom: 0;'><table width='100%' style='border-collapse: collapse; width: 100%;'><tbody><tr height='8' style='height: 8px;'><td style='width: 100%; padding: 0; border: 0 none black;'><table width='100%'style='border-collapse: collapse; width: 100%;'><tbody><tr height='8' style='height: 8px;'><td style='width: 100%; padding: 0; border: 0 none black;'><table width='600' align='center' style='border-collapse: collapse; width: 600px;><tbody><tr height='8' style='height: 8px;'><td width='600' style='width: 600px; padding: 0; border: 0 none black;'><table width='600' align='center'style='border-collapse: collapse; width: 600px;'><tbody><tr height='8' style='height: 8px;'><td width='600'style='width: 600px; padding: 0; border: 0 none black;'><table width='600' align='left'style='border-collapse: collapse; width: 600px;'><tbody><tr height='8' style='height: 8px;'><td width='600' style='width: 600px; padding: 0;border: 0 none black;'><table width='600' align='left'style='border-collapse:collapse; width: 600px;'><tbody><tr height='8' style='height: 8px;'><td width='600'style='width:600px; padding:0; border: 0 none black;'><div align='center' style='text-align:center;'><a href='http://www.e-XXXXbank.com/'target='_blank'> <img src='cid:logo' 'align='top' alt='logo' style='display:inline;'></a></div></td></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></td></tr><tr height='8' style='height: 8px;'><td style='padding: 0; border: 0 none black;'><br><table width='600' align='center'<tbody><tr height='8' style='height: 8px;'><td width='600'style='width: 600px; padding: 0; border: 0 none black;'><table width='560' align='center'style='border-collapse: collapse; width: 560px;'><tbody><tr height='8' style='height: 8px;'><td width='560'style='width: 560px; padding: 0; border: 0 none black;'><table width='100%'style='border-collapse: collapse; width: 100%;'><tbody><tr height='8' style='height: 8px;'><td style='width: 100%; padding: 0; border: 0 none black;'><table width='560' align='center'style='border-collapse: collapse; width: 560px;'><tbody><tr height='8' style='height: 8px;'><td width='558'style='width: 558px; background-color: #F0F0F0; padding: 0; border: 1px solid #ECECED;'><span style='background-color: #F0F0F0;'><div align='center' style='text-align: center;'><font face='Arial' size='4' color='#104160'><b>XXXX Portfolio Confirmation</b></font></div></span></td></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></td></tr><tr height='8' style='height: 8px;'><td style='padding: 0; border: 0 none black;'><br><table width='600' align='center'style='border-collapse: collapse; width: 600px;'><tbody><tr height='8' style='height: 8px;'><td width='600' style='width: 600px; padding: 0; border: 0 none black;'><img src='cid:space' align='top'alt='space' style='display: inline;'></td></tr></tbody></table></td></tr><tr height='8' style='height: 8px;'><td style='padding: 0; border: 0 none black;'><br><table width='600' align='center'style='border-collapse: collapse; width: 600px;'><tbody><tr height='8' style='height: 8px;'><td width='600'style='width: 600px; padding: 0; border: 0 none black;'><table width='560' align='center'style='border-collapse: collapse; width: 560px;'><tbody><tr height='8' style='height: 8px;'><td width='560'style='width: 560px; padding: 0; border: 0 none black;'><table width='550' align='right'style='border-collapse: collapse; width: 550px;'><tbody><tr height='8' style='height: 8px;'><td width='550'style='width: 550px; padding: 0; border: 0 none black;'></td></tr><tr height='8' style='height: 8px;'><td width='550'style='width: 550px; padding: 0; border: 0 none black;'><table width='550' align='left'style='border-collapse: collapse; width: 550px;'><tbody><tr height='8' style='height: 8px;'><td colspan='2' width='550'style='width: 550px; padding: 0; border: 0 none black;'><font face='Arial' size='4' color='#C21212'><b>Dear Customer</b></font></td></tr><tr height='8' style='height: 8px;'><td colspan='2' width='550'style='width: 550px; padding: 0; border: 0 none black;'><font face='Arial' size='4' color='#104160'><br>Following your instructions we have created your XXXX. The document attached enable you to view the details of your portfolio. You can save, print and store it for your records.</font><font face='Arial' size='4' color='#104160'><br></font><font face='Arial' size='4' color='#104160'><br>For security reasons, the document is protected with a password that has been sent to your mobile by SMS.</font><font face='Arial' size='4' color='#104160'><br></font><font face='Arial' size='4' color='#104160'><br>Many thanks for trusting us to help you manage your finances.</font></td></tr><tr height='8' style='height: 8px;'><td width='510' style='width: 510px; padding: 0; border: 0 none black;'></td><td width='39' style='width: 39px; padding: 0; border: 0 none black;'></td></tr><tr height='8' style='height: 8px;'><td colspan='2' width='550'style='width: 550px; padding: 0; border: 0 noneblack;'><font face='Arial' size='4' color='#C21212'><b>XXXX YYYYY Customer Service</b></font></td></tr><tr height='8' style='height: 8px;'><td width='510' valign='top'style='width: 510px; padding: 0; border: 0 none black;'><table width='510' align='left'style='border-collapse: collapse; width:510px;'><tbody><tr height='8' style='height: 8px;'><td width='510'style='width: 510px; padding:0; border: 0 none black;'></td></tr><tr height='8' style='height: 8px;'><td width='510'style='width: 510px; padding:0; border: 0 none black;'><font face='Times New Roman' size='2'> </font> <div style='margin-top: 0;margin-bottom: 0;'><font face='Times New Roman' size='2'> </font></div><div style='margin-top: 0;margin-bottom: 0;'><font face='Times New Roman' size='2'> </font></div><div style='margin-top: 0;margin-bottom: 0;'><font face='Times New Roman' size='2'> </font></div><div style='margin-top: 0;margin-bottom: 0;'><font face='Arial' size='2'color='#104160'>Please add </font><a href='mailto:XXXXYYYYY@XXXXbank.com.kw'target='_blank'><font face='Arial'size='2'>XXXXYYYYY@XXXXbank.com.kw</font></a><font face='Arial' size='2'color='#104160'> to your email address book to ensure your statements are not redirected to the junk folder.If there are any questions, please contact directly with your XXXX Bank manager.</font></div></td></tr><tr height='8' style='height: 8px;'><td width='510' style='width: 510px; padding: 0; border: 0 none black;'></td></tr></tbody></table></td><td width='39' style='width: 39px; padding: 0; border: 0 none black;'></td></tr></tbody></table> </td></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table> </td></tr><tr height='8' style='height: 8px;'><td style='padding: 0; border: 0 none black;'><br><table width='600' align='center' style='border-collapse: collapse; width: 600px;'><tbody><tr height='8' style='height: 8px;'><td width='600' style='width: 600px; padding: 0; border-width: 0 0 1px 0; border-style: none none solid none; border-color: black;'></td></tr></tbody></table></td></tr><tr height='8' style='height: 8px;'><td style='padding: 0; border: 0 none black;'><table width='600' align='center' style='border-collapse: collapse; width: 600px;'><tbody><tr height='8' style='height: 8px;'><td width='600' style='width: 600px; padding: 0; border: 0 none black;'></td></tr></tbody></table> <br></td></tr><tr height='8' style='height: 8px;'><td style='background-color: #F0F0F0; padding: 0; border: 0 none black;'><span style='background-color: #F0F0F0;'><table width='600' align='center' style='border-collapse: collapse; width: 600px;'><tbody><tr height='8' style='height: 8px;'><td width='600' style='width: 600px; padding: 0; border-width: 1px 0 0 0; border-style: solid none none none; border-color: #E6E6E6;'><table width='560' align='center'style='border-collapse: collapse; width: 560px;'><tbody><tr height='8' style='height: 8px;'><td width='560' style='width: 560px; padding: 0; border: 0 none black;'></td></tr><tr height='8' style='height: 8px;'><td width='560' style='width: 560px; padding: 0; border: 0 none black;'><table width='500' align='center' style='border-collapse: collapse; width: 500px;'><tbody><tr height='8' style='height: 8px;'><td width='300' style='width: 300px; padding: 0; border: 0 none black;'><div align='center' style='text-align: center;'><font face='Arial' size='2' color='#C21212'>© 2016 XXXX Bank. All rights reserved. </font><font face='Arial' size='2' color='#004080'>                    </font></div></td><td width='30' style='width: 30px; padding: 0; border: 0 none black;'><div align='center' style='text-align: center;'><a href='https://XXX/XXXX?_rdr' target='_blank'><img src='cid:facebook' alt='facebook' style='display:inline;'></a><td width='30' style='width: 30px; padding: 0; border: 0 none black;'><div align='center' style='text-align: center;'><a href='http://XXXX.com/XXXX' target='_blank'><img src='cid:twitter' align='top' alt='twitter' style='display:inline;'></a><td width='30' style='width: 30px; padding: 0; border: 0 none black;'><div align='center' style='text-align: center;'><a href='http://XXXXX.com/XXXX' target='_blank'><img src='cid:Instagram' align='top'alt='Instagram' style='display:inline;'></a><td width='30' style='width: 30px; padding: 0; border: 0 none black;'><div align='center' style='text-align: center;'><a href='https://www.youtube.com/XXX/YYYY' target='_blank'><img src='cid:youtube' align='top' alt='youtube' style='display:inline;'></a><td width='30' style='width: 30px; padding: 0; border: 0 none black;'><div align='center' style='text-align: center;'><a href='htt.....
</code>```

Can anyone suggest to resolve the same. Because of this my HTML is not getting rendered properly in MAIL.

答:
There is a missing ' in your html:</p>

```<code><table width='600' align='center' style='border-collapse: collapse; width: 600px;>
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I am preparing a mail content using HTML (I am using spring mime message for sending mails) with embedded images in it. The HTML is as follow.

<table width='600' align='center'

XXXX Portfolio Confirmation

Dear Customer

Following your instructions we have created your XXXX. The document attached enable you to view the details of your portfolio. You can save, print and store it for your records.

For security reasons, the document is protected with a password that has been sent to your mobile by SMS.

Many thanks for trusting us to help you manage your finances.

XXXX YYYYY Customer Service

Please add XXXXYYYYY@XXXXbank.com.kw to your email address book to ensure your statements are not redirected to the junk folder.If there are any questions, please contact directly with your XXXX Bank manager.

© 2016 XXXX Bank. All rights reserved.

</td

Please consider theenvironment & Print only if necessary

I have prepared the mail content using string and embedded the images using CID

String htmltext1=mailContentStart.concat(mailContentLogo).concat(mailContentHeading).
                concat(mailContentSpace).concat(mailContentBody);
        String htmltext12=(mailContentImages).concat(mailEnd);

When I contact htmltext 1 and htmltext2 am ending up with the below results

<table width='600' align='center'

XXXX Portfolio Confirmation

Dear Customer

Following your instructions we have created your XXXX. The document attached enable you to view the details of your portfolio. You can save, print and store it for your records.

For security reasons, the document is protected with a password that has been sent to your mobile by SMS.

Many thanks for trusting us to help you manage your finances.

XXXX YYYYY Customer Service

Please add XXXXYYYYY@XXXXbank.com.kw to your email address book to ensure your statements are not redirected to the junk folder.If there are any questions, please contact directly with your XXXX Bank manager.

© 2016 XXXX Bank. All rights reserved.

<a href='htt.....

Can anyone suggest to resolve the same. Because of this my HTML is not getting rendered properly in MAIL.

Body:
There is a missing ' in your html:

<table width='600' align='center' style='border-collapse: collapse; width: 600px;>


问:
Concurrency problem
We got an old system here in .NET 4.0 using an Oracle DB.
At some point, some calculus are made and the system "locks" that register in the table using the following command: "SELECT [the registry that will be update by the calculus] FOR UPDATE NOWAIT". So if anyone tries to calculate or update the registry with that ID it won't work.
After calculating, the system connects to the DB again and then "releases" the registry by simply executing a Rollback command.

Theoretically, this is correct for the system(altought I don't like it).

Anyway, here is the thing: if something is being calculated(and these calculous take like 5 minutes to finish) and in the middle of the calculous I close the browser, the registry will still be "locked", only being unlocked when IIS restarts(actually I dunno if it's released first, I forced IIS restart 'cause it was taking too long).

Could anybody give me a light about how to deal with that?
Or if you guys have a better approach to deal with this tipe of concurrency, I'll be greatful.

Thanks!
Gabriel.

Adding some code.
Before starting the calculus, this method is called:

```<code>Public Shared Sub LockAndUnlock(ByVal pTable As String, ByVal pWhere As String, ByVal pConnectionString As String, ByVal pLock As Boolean)

    Dim vConnection As OleDbConnection = New OleDbConnection(pConnectionString)
    Dim vCommand As OleDbCommand = New OleDbCommand

    Try
        vCommand.Connection = vConnection
        If (pLock) Then
            vCommand.CommandText = "SELECT * " &
                                   "  FROM   " & pTable &
                                   " WHERE   " & pWhere &
                                   " FOR UPDATE NOWAIT"

            vConnection.Open()
            vCommand.ExecuteNonQuery()
        Else
            vCommand.CommandText = "ROLLBACK"

            If (vConnection.State = ConnectionState.Closed) Then
                vConnection.Open()
            End If

            vCommand.ExecuteNonQuery()
            vConnection.Close()
        End If

    Catch ex As Exception
        Throw ex
    End Try
End Sub
</code>```

If the parameter pLock is True then the method locks. Otherwise, it unlocks.

答:
I'd have to see some code, but I'm curious as to what you mean when you say "the system connects to the db again" and then releases the lock.

The fact that the lock is released when IIS restarts indicates to me that the connection is still active.  Are you using the oracle provider, or the MS Oracle provider?

The only time I've had to deal with a long-running process I used a scheduler to run it in off-hours - a 5 minute transaction is really not suited to a web-based application.

ContentLicense: CC BY-SA 2.5

Title: Concurrency problem

Body:
We got an old system here in .NET 4.0 using an Oracle DB.
At some point, some calculus are made and the system "locks" that register in the table using the following command: "SELECT [the registry that will be update by the calculus] FOR UPDATE NOWAIT". So if anyone tries to calculate or update the registry with that ID it won't work.
After calculating, the system connects to the DB again and then "releases" the registry by simply executing a Rollback command.

Theoretically, this is correct for the system(altought I don't like it).

Anyway, here is the thing: if something is being calculated(and these calculous take like 5 minutes to finish) and in the middle of the calculous I close the browser, the registry will still be "locked", only being unlocked when IIS restarts(actually I dunno if it's released first, I forced IIS restart 'cause it was taking too long).

Could anybody give me a light about how to deal with that?
Or if you guys have a better approach to deal with this tipe of concurrency, I'll be greatful.

Thanks!
Gabriel.

Adding some code.
Before starting the calculus, this method is called:

Public Shared Sub LockAndUnlock(ByVal pTable As String, ByVal pWhere As String, ByVal pConnectionString As String, ByVal pLock As Boolean)

    Dim vConnection As OleDbConnection = New OleDbConnection(pConnectionString)
    Dim vCommand As OleDbCommand = New OleDbCommand

    Try
        vCommand.Connection = vConnection
        If (pLock) Then
            vCommand.CommandText = "SELECT * " &
                                   "  FROM   " & pTable &
                                   " WHERE   " & pWhere &
                                   " FOR UPDATE NOWAIT"

            vConnection.Open()
            vCommand.ExecuteNonQuery()
        Else
            vCommand.CommandText = "ROLLBACK"

            If (vConnection.State = ConnectionState.Closed) Then
                vConnection.Open()
            End If

            vCommand.ExecuteNonQuery()
            vConnection.Close()
        End If

    Catch ex As Exception
        Throw ex
    End Try
End Sub

If the parameter pLock is True then the method locks. Otherwise, it unlocks.


问:
Is it possible to assign django channels group in connection?
I hope you're all right:

my question is whether I can make a connection to web socket from the client to a specific group,
I'm currently connecting customers as follows:

```<code>//connecting client with js
var ws_scheme = window. location. protocol == "https:"? "wss":"ws";
//var ws_path = ws_scheme +': //' + window. location. host + "/sync/";
var ws_path = ws_scheme + ": //localhost: 8001";

console. log ("Connecting to " + ws_path);
var socket = new ReconnectingWebSocket (ws_path);
</code>```

Okay, that's how it works,
The problem is that I want each client to connect to a group
created previously example:

```<code>def ws_connect (message):
  for x in users:
    Group (x). add (message. reply_channel)
</code>```

and so sent the message to the respective group

```<code>Group ("group1"). send ({' text': json. dumps (msg)})
Group ("group2"). send ({' text': json. dumps (msg)})
</code>```

答:
while connecting to the sever pass the group name in url.

wss://localhost:8001/sync/< groupname >/

and routing will be

```<code>route("websocket.connect", ws_connect, path=r"^/sync/(?P<group_name>[a-zA-Z0-9_]+)/$")
</code>```

and in consumers.py

```<code>def ws_connect(message, group_name):
    Group(group_name).add(message.reply_channel)
</code>```

Body:
I hope you're all right:

my question is whether I can make a connection to web socket from the client to a specific group,
I'm currently connecting customers as follows:

//connecting client with js
var ws_scheme = window. location. protocol == "https:"? "wss":"ws";
//var ws_path = ws_scheme +': //' + window. location. host + "/sync/";
var ws_path = ws_scheme + ": //localhost: 8001";

console. log ("Connecting to " + ws_path);
var socket = new ReconnectingWebSocket (ws_path);

Okay, that's how it works,
The problem is that I want each client to connect to a group
created previously example:

def ws_connect (message):
  for x in users:
    Group (x). add (message. reply_channel)

and so sent the message to the respective group

Group ("group1"). send ({' text': json. dumps (msg)})
Group ("group2"). send ({' text': json. dumps (msg)})

Body:
while connecting to the sever pass the group name in url.

wss://localhost:8001/sync/< groupname >/

and routing will be

route("websocket.connect", ws_connect, path=r"^/sync/(?P<group_name>[a-zA-Z0-9_]+)/$")

and in consumers.py

def ws_connect(message, group_name):
    Group(group_name).add(message.reply_channel)


问:
Take screenshots of specific areas
What I am trying to achieve is that I would only want to screenshot specific areas using a view that can be dragged around the screen and whatever that the view is hovering on it will only screenshot whatever elements are within the dragged view.

I have been trying to search what to do or where to start, but my initial idea is to screenshot and then crop the image to get what I need.

But is there any other way other than SCREENSHOT --> GET IMAGE --> CROP IMAGE. Is it possible to just get a view and just capture what you need on the screen?

答:
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.os.Environment;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;

import java.io.File;
import java.io.FileOutputStream;
import java.util.Random;

public class MainActivity extends AppCompatActivity {

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

        Bitmap bitmap = loadBitmapFromView(findViewById(R.id.activity_main),350,450);
        saveImage(bitmap);
    }

    public static void saveImage(Bitmap bitmap){
        String root = Environment.getExternalStorageDirectory().toString();
        File myDir = new File(root + "/req_images");
        myDir.mkdirs();
        Random generator = new Random();
        int n = 10000;
        n = generator.nextInt(n);
        String fname = "Image-" + n + ".jpg";
        File file = new File(myDir, fname);
        //  Log.i(TAG, "" + file);
        if (file.exists())
            file.delete();
        try {
            FileOutputStream out = new FileOutputStream(file);
            bitmap.compress(Bitmap.CompressFormat.JPEG, 100, out);
            out.flush();
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static Bitmap loadBitmapFromView(View v, int width, int height) {
        Bitmap b = Bitmap.createBitmap(width , height, Bitmap.Config.ARGB_8888);
        Canvas c = new Canvas(b);
        v.layout(0, 0, v.getLayoutParams().width, v.getLayoutParams().height);
        v.draw(c);
        return b;
    }
}```

Title: Take screenshots of specific areas


问:
Scenarios where automated testing is unhelpful
What are some situations where unit testing and TDD and the like are more trouble than they're worth?

Some things I've come up with are:

When generating test data is tricky: Sometimes, being able to come up with valid, non trivial test data is a challenge in itself.

When the only practical way of verifying correctness of the code is to run it.

When you're testing visual elements of the design.

What are some other cases?

答:
I believe your first two points are not valid.

Creating test data may be a challenge (in fact, it's usually a major part of writing unit tests), but that's simply something you have to accept, not a reason to give up on unit tests. And it can't be impossible, otherwise how would you ever know your app is working correctly?

Unit tests run the code in order to verify its correctness - I don't see the problem.

There certainly are aspects of an application that cannot be unit-tested - visual layout (screen or print) is one such aspect, as is usability in general - things that cannot really be formally specified.

A situation where unit testing may not be applicable is when you're faced with an existing application that was not developed with testability or even modularity in mind (Big Ball of Mud Anti-pattern). But even then, if you know you'll have to maintain and extend this beast for a significant length of time, it is nearly always possible and useful to find a way to automatically test at least some parts of the application. Nobody says you have to write a test suite that achieves 100% code coverage before doing anything else.

OwnerDisplayName: Shalmanese

OwnerDisplayName: Michael Borgwardt

LastEditorDisplayName: Jonathan Leffler


问:
Can a class with all private members be a POD class?
I've heard before that POD types cannot have private data -- but according to the C++0x draft I have the requirement is looser (emphasis mine):

has the same access control (Clause 11) for all non-static data members

which seems to suggest that private data is okay so long as it's all private. I don't have a copy of C++03 though to check...

Would then, WindowsApi::Uuid be a POD class?

```<code>namespace WindowsApi
{
    class Uuid
    {
        union
        {
            ::UUID asUuid; //Win32's UUID struct
            unsigned __int64 asInt64s[2];
            unsigned __int32 asInt32s[4];
        };
    public:
        Uuid() {}
        Uuid(::UUID sourceStructure) : asUuid(sourceStructure) {}
        operator ::UUID() { return asUuid; }
    };
}
</code>```

答:
C++03 still does not allow non-static private or protected data in POD classes. This requirement is specified in the definition of aggregate

An aggregate is an array or a class (clause 9) with no user-declared constructors (12.1), no private or protected non-static data members (clause 11), no base classes (clause 10), and no virtual functions (10.3).

and POD class must be an aggregate first.

Body:
I've heard before that POD types cannot have private data -- but according to the C++0x draft I have the requirement is looser (emphasis mine):

has the same access control (Clause 11) for all non-static data members

which seems to suggest that private data is okay so long as it's all private. I don't have a copy of C++03 though to check...

Would then, WindowsApi::Uuid be a POD class?

namespace WindowsApi
{
    class Uuid
    {
        union
        {
            ::UUID asUuid; //Win32's UUID struct
            unsigned __int64 asInt64s[2];
            unsigned __int32 asInt32s[4];
        };
    public:
        Uuid() {}
        Uuid(::UUID sourceStructure) : asUuid(sourceStructure) {}
        operator ::UUID() { return asUuid; }
    };
}


问:
How to rotate a QPixmap without changing size
How to rotate a QPixmap without changing size
I use this code but when I rotate the image it change the size of the image.

The header file

```<code>#ifndef CUSTOMDIAL_H
#define CUSTOMDIAL_H
#include <QDial>
class CustomDial : public QDial
{
Q_OBJECT
public:
CustomDial(QWidget * parent = nullptr);
private:
virtual void paintEvent(QPaintEvent*) override;
};
#endif
</code>```

the CPP file

```<code>#include "Customdial.h"
#include <QGraphicsPixmapItem>
#include <QPainter>
#include <QColor>
#include <QPixmap>
 CustomDial::CustomDial(QWidget* parent)
                    : QDial(parent)
 {
// Default range
QDial::setRange(0,100);
}
void CustomDial::paintEvent(QPaintEvent*)
{
int a = QDial::sliderPosition();
QPainter painter(this);
//load pixmap
QPixmap pix(":/img/img/knob.png");
//rotate pixmap
QMatrix rm;
        rm.rotate(a);
        pix = pix.transformed(rm);
//draw pixmap
painter.drawPixmap(QPointF(0,0),
                    pix.scaled(QDial::height(),
                    QDial::height(),
                    Qt::KeepAspectRatio),
                    pix.rect().adjusted(1, 1, -1000, -1000) );
}
</code>```

How to rotate a QPixmap without changing size I use this code but when I rotate the image it change the size of the image the header file

答:
The method that Qdial is using to calculate the background circle is this

```<code>int width = option.rect.width();
int height = option.rect.height();
qreal r2 = qMin(width, height) / 2;
r2 -= r2/50;
const qreal d_ = r2 / 6;
const qreal dx = option.rect.x() + d_ + (width - 2 * r2) / 2 + 1;
const qreal dy = option.rect.y() + d_ + (height - 2 * r2) / 2 + 1;
QRectF br = QRectF(dx + 0.5, dy + 0.5,
               int(r2 * 2 - 2 * d_ - 2),
               int(r2 * 2 - 2 * d_ - 2));
</code>```

So QRect br is the rect for the background circle. Then just add the Pixmap resource file using those cordinates

```<code> int w=option.rect.width()/2;
 int h=option.rect.height()/2;
 painter.translate(w,h);
 painter.rotate(a);

 //draw pixmap
 painter.drawPixmap(-br.width()/2,
                    -br.height()/2,
                         pix.scaled(br.width(),br.height(),Qt::KeepAspectRatio));
</code>```

And you get a perfect resizable and rotatable image inside your dial

Body:
How to rotate a QPixmap without changing size
I use this code but when I rotate the image it change the size of the image.

The header file

#ifndef CUSTOMDIAL_H
#define CUSTOMDIAL_H
#include <QDial>
class CustomDial : public QDial
{
Q_OBJECT
public:
CustomDial(QWidget * parent = nullptr);
private:
virtual void paintEvent(QPaintEvent*) override;
};
#endif

the CPP file

#include "Customdial.h"
#include <QGraphicsPixmapItem>
#include <QPainter>
#include <QColor>
#include <QPixmap>
 CustomDial::CustomDial(QWidget* parent)
                    : QDial(parent)
 {
// Default range
QDial::setRange(0,100);
}
void CustomDial::paintEvent(QPaintEvent*)
{
int a = QDial::sliderPosition();
QPainter painter(this);
//load pixmap
QPixmap pix(":/img/img/knob.png");
//rotate pixmap
QMatrix rm;
        rm.rotate(a);
        pix = pix.transformed(rm);
//draw pixmap
painter.drawPixmap(QPointF(0,0),
                    pix.scaled(QDial::height(),
                    QDial::height(),
                    Qt::KeepAspectRatio),
                    pix.rect().adjusted(1, 1, -1000, -1000) );
}

How to rotate a QPixmap without changing size I use this code but when I rotate the image it change the size of the image the header file

Body:
The method that Qdial is using to calculate the background circle is this

int width = option.rect.width();
int height = option.rect.height();
qreal r2 = qMin(width, height) / 2;
r2 -= r2/50;
const qreal d_ = r2 / 6;
const qreal dx = option.rect.x() + d_ + (width - 2 * r2) / 2 + 1;
const qreal dy = option.rect.y() + d_ + (height - 2 * r2) / 2 + 1;
QRectF br = QRectF(dx + 0.5, dy + 0.5,
               int(r2 * 2 - 2 * d_ - 2),
               int(r2 * 2 - 2 * d_ - 2));

So QRect br is the rect for the background circle. Then just add the Pixmap resource file using those cordinates

 int w=option.rect.width()/2;
 int h=option.rect.height()/2;
 painter.translate(w,h);
 painter.rotate(a);

 //draw pixmap
 painter.drawPixmap(-br.width()/2,
                    -br.height()/2,
                         pix.scaled(br.width(),br.height(),Qt::KeepAspectRatio));

And you get a perfect resizable and rotatable image inside your dial


问:
Clear MySQL table data when Spring Boot loads
I'm using Spring Boot with Hibernate.  I'm trying to delete all the contents of a MySQL table when the server reloads.  I know it sounds dumb, but I can't really find a way to do it, probably because it sounds dumb.  Any ideas?</p>

答:
if you want to delete all contents of your tables ,you can do it with adding following property in your application.properties. create property  will create all tables at the starting time

```<code>spring.jpa.hibernate.ddl-auto=create
</code>```

Body:
if you want to delete all contents of your tables ,you can do it with adding following property in your application.properties. create property  will create all tables at the starting time

spring.jpa.hibernate.ddl-auto=create


问:
Python hyper parameter for rounding float numbers
This question must be an easy one but I couldn't find anything about it here.

Is there a way in python to define or use 1 command line so that every float number across the script will be rounded by X digists.

For example if I define:

```<code>max_float_digits = 4
</code>```

and the program wants to outputs or print the following number 5.1355895682, all I will see is 5.1356

This necessity rises when some module return this value to my script:

```<code>[('user_ctr', 2253.459088429824), ('user_clicks', 2042.3175666666664), ('t_avg_sim', 176.83513843049306), ('item_ctr', 137.6051319164618), ('item_age', 128.52122456437388), ('t_max_sim', 126.23752629310347), ('item_read_time', 46.94452635514022), ('clicks', 26.368489035532996), ('likes', 15.43922933884298), ('c_max_sim', 14.761540559999993), ('no_clicks', 13.020515220883516), ('c_avg_sim', 10.969965476190472), ('user_read_time', 10.21293115646259), ('user_age', 9.776781678832117)]
</code>```

Instead of trying to access each value and round them I'd like a 1 command line that will round them all for me.

答:
No, there isn't such a parameter, but you can probably achieve a similar thing with the decimal module if you wan't to use decimal numbers instead of IEEE754 floating-point types.

See the example (from the URL https://docs.python.org/2/library/decimal.html):

```<code>>>> from decimal import *
>>> getcontext().prec = 6
>>> Decimal(1) / Decimal(7)
Decimal('0.142857')
>>> getcontext().prec = 28
>>> Decimal(1) / Decimal(7)
Decimal('0.1428571428571428571428571429')
</code>```

Of course if you need both speed and high precision you can also use modules like mpmath or gmpy but I think that decimal is worth a try in your own case (it is a module from the standard library).

Body:
This question must be an easy one but I couldn't find anything about it here.

Is there a way in python to define or use 1 command line so that every float number across the script will be rounded by X digists.

For example if I define:

max_float_digits = 4

and the program wants to outputs or print the following number 5.1355895682, all I will see is 5.1356

This necessity rises when some module return this value to my script:

[('user_ctr', 2253.459088429824), ('user_clicks', 2042.3175666666664), ('t_avg_sim', 176.83513843049306), ('item_ctr', 137.6051319164618), ('item_age', 128.52122456437388), ('t_max_sim', 126.23752629310347), ('item_read_time', 46.94452635514022), ('clicks', 26.368489035532996), ('likes', 15.43922933884298), ('c_max_sim', 14.761540559999993), ('no_clicks', 13.020515220883516), ('c_avg_sim', 10.969965476190472), ('user_read_time', 10.21293115646259), ('user_age', 9.776781678832117)]

Instead of trying to access each value and round them I'd like a 1 command line that will round them all for me.

Body:
No, there isn't such a parameter, but you can probably achieve a similar thing with the decimal module if you wan't to use decimal numbers instead of IEEE754 floating-point types.

See the example (from the URL https://docs.python.org/2/library/decimal.html):

>>> from decimal import *
>>> getcontext().prec = 6
>>> Decimal(1) / Decimal(7)
Decimal('0.142857')
>>> getcontext().prec = 28
>>> Decimal(1) / Decimal(7)
Decimal('0.1428571428571428571428571429')

Of course if you need both speed and high precision you can also use modules like mpmath or gmpy but I think that decimal is worth a try in your own case (it is a module from the standard library).


问:
checkboxes in recyclerview get changed automatically by scrolling in android
```<code>ArrayList<HashMap<String, String>> hashMapArrayList;

public void onBindViewHolder(final EChallanRecyclerCardViewAdapter.ViewHolder holder, int position) {

 holder.cbSelectedchallans.setChecked(false);

        holder.cbSelectedchallans.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {

                if (isChecked) {
                    String cvTotChallanPayAmount= holder.tvChallanPayAmount.getText().toString().replace("₹","");
                    int TotChallanPayAmount=Integer.parseInt(cvTotChallanPayAmount);
                    TotaltoPay=TotaltoPay+TotChallanPayAmount;
                    Bundle bundle=new Bundle();
                    bundle.putInt("TotaltoPay",TotaltoPay);
                    Intent intent = new Intent("Add_Send_TotaltoPay");
                    intent.putExtras(bundle);
                    LocalBroadcastManager.getInstance(cntx).sendBroadcast(intent);

                } else {
                    if(TotaltoPay!=0) {
                        String cvTotChallanPayAmount = holder.tvChallanPayAmount.getText().toString().replace("₹", "");
                        int TotChallanPayAmount = Integer.parseInt(cvTotChallanPayAmount);
                        TotaltoPay = TotaltoPay - TotChallanPayAmount;
                        Bundle bundle=new Bundle();
                        bundle.putInt("TotaltoPay",TotaltoPay);
                        Intent intent = new Intent("Remove_Send_TotaltoPay");
                        intent.putExtras(bundle);
                        LocalBroadcastManager.getInstance(cntx).sendBroadcast(intent);

                    }
                }
            }
        });
}
</code>```

答:
First Use like this adpter class:

```<code>public class MyAdapter extends ArrayAdapter<ModelClass> {

    private final ArrayList<ModelClass> list;
    private final Activity context;

    public MyAdapter(Activity context, ArrayList<ModelClass> list) {
        super(context, R.layout.raw_project_add, list);
        this.context = context;
        this.list = list;
    }

    class ViewHolder {
        protected TextView text;
        protected CheckBox checkbox;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        ViewHolder viewHolder = null;
        if (convertView == null) {
            LayoutInflater inflator = context.getLayoutInflater();
            convertView = inflator.inflate(R.layout.raw_project_add, null);
            viewHolder = new ViewHolder();
            viewHolder.checkbox = (CheckBox) convertView.findViewById(R.id.chkboxProject);
            viewHolder.checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

                @Override
                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                    int getPosition = (Integer) buttonView.getTag();
                    list.get(getPosition).setSelected(buttonView.isChecked());
                }
            });
            convertView.setTag(viewHolder);
            convertView.setTag(R.id.chkboxProject, viewHolder.checkbox);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        viewHolder.checkbox.setTag(position); // This line is important.

        viewHolder.checkbox.setText(list.get(position).getTitle());
        viewHolder.checkbox.setTypeface(Utils.getTypeFace(context));
        viewHolder.checkbox.setChecked(list.get(position).isSelected());

        return convertView;
    }
    }
</code>```

implement AdapterView.OnItemClickListener in your class.

```<code> @Override
    public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
    CheckBox checkbox = (CheckBox) v.getTag(R.id.chkboxProject);
//        Toast.makeText(v.getContext(), isCheckedOrNot(checkbox), Toast.LENGTH_LONG).show();
    }

    private String isCheckedOrNot(CheckBox checkbox) {
    if (checkbox.isChecked())
        return "is checked";
    else
        return "is not checked";
    }
</code>```

Body:
First Use like this adpter class:

public class MyAdapter extends ArrayAdapter<ModelClass> {

    private final ArrayList<ModelClass> list;
    private final Activity context;

    public MyAdapter(Activity context, ArrayList<ModelClass> list) {
        super(context, R.layout.raw_project_add, list);
        this.context = context;
        this.list = list;
    }

    class ViewHolder {
        protected TextView text;
        protected CheckBox checkbox;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        ViewHolder viewHolder = null;
        if (convertView == null) {
            LayoutInflater inflator = context.getLayoutInflater();
            convertView = inflator.inflate(R.layout.raw_project_add, null);
            viewHolder = new ViewHolder();
            viewHolder.checkbox = (CheckBox) convertView.findViewById(R.id.chkboxProject);
            viewHolder.checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

                @Override
                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                    int getPosition = (Integer) buttonView.getTag();
                    list.get(getPosition).setSelected(buttonView.isChecked());
                }
            });
            convertView.setTag(viewHolder);
            convertView.setTag(R.id.chkboxProject, viewHolder.checkbox);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        viewHolder.checkbox.setTag(position); // This line is important.

        viewHolder.checkbox.setText(list.get(position).getTitle());
        viewHolder.checkbox.setTypeface(Utils.getTypeFace(context));
        viewHolder.checkbox.setChecked(list.get(position).isSelected());

        return convertView;
    }
    }

implement AdapterView.OnItemClickListener in your class.

 @Override
    public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
    CheckBox checkbox = (CheckBox) v.getTag(R.id.chkboxProject);
//        Toast.makeText(v.getContext(), isCheckedOrNot(checkbox), Toast.LENGTH_LONG).show();
    }

    private String isCheckedOrNot(CheckBox checkbox) {
    if (checkbox.isChecked())
        return "is checked";
    else
        return "is not checked";
    }


问:
Change language from dynamically content using Javascript
My project should support different languages for the GUI (spanish, english, german, etc). I'm using CodeIgniter, so I haven't got any problem with PHP views using Language Class. I can load some previously defined vars on PHP to create views in different languages.

The problem comes here:

Some features (a lot of them actually) use Javascript: personalized context menu for some items, differents DIVs created dynamically, etc. The most of this features are created dynamically, so I can't know the language selected (I can create a lot of duplicated code, one for each language, but this is too redundant).

I need to find a way to translate this content into the new language previously selected by user.

For example:

The user right-click and the context menu have the following options (created dynamically using Javascript):

Hi

Goodbye

When the user change the page language to 'Spanish', the context menu should show:

Hola

Adios

Is there any way to save some variables with all the names in different languages, and then load to create the menus?

Sorry for the big post. I hope everyone can help me or bring me a little tip.

答:
Is there any way to save some
  variables with all the names in
  different languages, and then load to
  create the menus?

I assume you're asking if you can save these user preferences?

If so store it as a cookie on the user's computer

If you don't mean this, and you want to store all of the variations of languages, then you could store it in an array which can be loaded by javascript


问:
show direction button in swift mapView using googleMaps api
I'm developing an app for both android and ios. in android mapview when I tap on marks of the map 2 buttons are shown in the bottom of the view. (directions and googlemaps) see the uploaded image

following the instruction from google I setup the mapView in swift to show maps from google. but when I tap on the mark, I don't see any button in the mapView. why is that?

google instruction for setting up the mapview in swift:
https://developers.google.com/maps/documentation/ios-sdk/start

答:
CustomButton - swift
just simply add the class on your viewcontroller bottom

```<code>class CustomButton: UIButton {
    var gps = ""
    override func awakeFromNib() {
        super.awakeFromNib()

        //TODO: Code for our button
    }
}
</code>```

for request "appleMap" required to import MapKit

Body:
CustomButton - swift
just simply add the class on your viewcontroller bottom

class CustomButton: UIButton {
    var gps = ""
    override func awakeFromNib() {
        super.awakeFromNib()

        //TODO: Code for our button
    }
}

for request "appleMap" required to import MapKit


问:
insert a query to database table to prevent auto increment to skip numbers
If user registration has failed, ID (which is set to AUTO INCREMENT) skips a number. To prevent this, I came up with the code below. But rather inserting the word 'Registration error' to winningSegment under table tb_prizewon it only prints the message in die() function

```<code>if (!$success) {
    $query2   = "INSERT into tb_prizewon (winningSegment) VALUES('Registration error')";
    die("Number already registered! Please try again.");
}
</code>```

winningSegment is supposed to be the prize won by the user after spinning a wheel of fortune after a successful registration of his info. tb_prizewon table also have an AUTO_INCREMENT field for ID

答:
You are not executing the query which you have formatted.

Also, make sure that tb_prizewon table have AUTO_INCREMENT field for ID and it could be better if you enclose the fieldname winningSegment with backstick as `winningSegment`

Body:
If user registration has failed, ID (which is set to AUTO INCREMENT) skips a number. To prevent this, I came up with the code below. But rather inserting the word 'Registration error' to winningSegment under table tb_prizewon it only prints the message in die() function

if (!$success) {
    $query2   = "INSERT into tb_prizewon (winningSegment) VALUES('Registration error')";
    die("Number already registered! Please try again.");
}

winningSegment is supposed to be the prize won by the user after spinning a wheel of fortune after a successful registration of his info. tb_prizewon table also have an AUTO_INCREMENT field for ID


问:
How do I store auth token after user login in vue js?
I am using vue js as a front end and after authenticating user from my appi built with laravel I am receiving a token which is supposed to send with every consequent request for authenticating the api.

But how should I store the token in the browser Securely?

答:
Answer that I found here is very inefficient because localStorage is not assync so after login you would need to refresh entire page which is very bad UX to refresh single page app which I believe is what you develop since you use vue.

What I can suggest istead is localForage which is nothing more than assync localStorage. It is promise based and syntax looks very similiar to localStorage.

Example:

```<code>localforage.getItem('something', myCallback);
</code>```

More info in its docs.

And to send token in every request to backend you should use vue.http.interceptors.

Example:

```<code>Vue.http.interceptors.push((request, next)  => {
  request.headers['Authorization'] = auth.getAuthHeader()
    next((response) => {
      if(response.status == 401 ) {
        auth.logout();
        router.go('/login?unauthorized=1');
      }
   });
});
</code>```

Body:
Answer that I found here is very inefficient because localStorage is not assync so after login you would need to refresh entire page which is very bad UX to refresh single page app which I believe is what you develop since you use vue.

What I can suggest istead is localForage which is nothing more than assync localStorage. It is promise based and syntax looks very similiar to localStorage.

Example:

localforage.getItem('something', myCallback);

More info in its docs.

And to send token in every request to backend you should use vue.http.interceptors.

Example:

Vue.http.interceptors.push((request, next)  => {
  request.headers['Authorization'] = auth.getAuthHeader()
    next((response) => {
      if(response.status == 401 ) {
        auth.logout();
        router.go('/login?unauthorized=1');
      }
   });
});


问:
Display user profile url by name instead of ID
I am Newbie. I'm trying to return a view of member profile

At the moment, the user profile is accessible by its ID, like so

profile/7

I would like to access it through the name that I've created

profile/John

this is my route

```<code>Route::get('profile/{id}', 'ProfilController@tampilkanID');
</code>```

this is my controller

```<code>public function tampilkanID($id)
{
    $auth = Auth::user()->id;
    $users=\App\users::all()->whereNotIn('id',$auth);
    $tampilkan = Users::find($id);
    return view('tampilkan', compact('tampilkan', 'users'));
}
</code>```

and this how i call it in my blade

```<code> @foreach($users as $user)
           <tr>
               <td><a id="teamname" href="{{ url('profile',$user->id) }}" target="_blank">{{$user->name}}</a></td>
              </tr>
 @endforeach
</code>```

thank you

答:
Just Customise you RouteServiceProvider as Like below :

```<code>public function boot()
{
    parent::boot();

    Route::bind('user', function ($value) {
        return App\User::where('name', $value)->first() ?? abort(404);
    });
}
</code>```

or

customise your route key in model.

For eg :

```<code>/**
 * Get the route key for the model.
 *
 * @return string
 */
public function getRouteKeyName()
{
    return 'name';
}
</code>```

Route :

```<code>Route::get('users/{user}', function ($user) {
    return view('user.show', compact('user'));
});
</code>```

Body:
I am Newbie. I'm trying to return a view of member profile

At the moment, the user profile is accessible by its ID, like so

profile/7

I would like to access it through the name that I've created

profile/John

this is my route

Route::get('profile/{id}', 'ProfilController@tampilkanID');

this is my controller

public function tampilkanID($id)
{
    $auth = Auth::user()->id;
    $users=\App\users::all()->whereNotIn('id',$auth);
    $tampilkan = Users::find($id);
    return view('tampilkan', compact('tampilkan', 'users'));
}

and this how i call it in my blade

 @foreach($users as $user)

               id) }}" target="_blank">{{$user->name}}

 @endforeach

thank you

Body:
Just Customise you RouteServiceProvider as Like below :

public function boot()
{
    parent::boot();

    Route::bind('user', function ($value) {
        return App\User::where('name', $value)->first() ?? abort(404);
    });
}

or

customise your route key in model.

For eg :

/**
 * Get the route key for the model.
 *
 * @return string
 */
public function getRouteKeyName()
{
    return 'name';
}

Route :

Route::get('users/{user}', function ($user) {
    return view('user.show', compact('user'));
});


问:
How to add options to mouse-right-click menu in Powershell forms
I have a basic Powershell form with a textbox. When I right-click on the textbox, a standard menu appears with copy, cut, paste etc...

My goal is to add a "clear log" option, that clears current textbox content. How can I add this option to right-click menu instead of doing/drawing an actual separate button?

Option will be enabled for this form only, I am not looking a general mouse-right-click solution from registry

答:
To be able to show a ContextMenuStrip for a TextBox first you should set ShortcutsEnabled property of the TextBox to false, then assign a ContextMenuStrip to its ContextMenuStrip property like this:

```<code>$form1= New-Object System.Windows.Forms.Form
$textBox1 = New-Object System.Windows.Forms.TextBox
$contextMenuStrip1 = New-Object System.Windows.Forms.ContextMenuStrip

$contextMenuStrip1.Items.Add("Item 1")
$contextMenuStrip1.Items.Add("Item 2")

$textBox1.ShortcutsEnabled = $false
$textBox1.ContextMenuStrip = $contextMenuStrip1

$form1.Text="Context Menu for TextBox"
$form1.Controls.Add($textBox1)

$form1.ShowDialog()
</code>```

Body:
To be able to show a ContextMenuStrip for a TextBox first you should set ShortcutsEnabled property of the TextBox to false, then assign a ContextMenuStrip to its ContextMenuStrip property like this:

$form1= New-Object System.Windows.Forms.Form
$textBox1 = New-Object System.Windows.Forms.TextBox
$contextMenuStrip1 = New-Object System.Windows.Forms.ContextMenuStrip

$contextMenuStrip1.Items.Add("Item 1")
$contextMenuStrip1.Items.Add("Item 2")

$textBox1.ShortcutsEnabled = $false
$textBox1.ContextMenuStrip = $contextMenuStrip1

$form1.Text="Context Menu for TextBox"
$form1.Controls.Add($textBox1)

$form1.ShowDialog()


问:
Use href or sref according to the location path in angularjs
I have a modularized AngularJS1.5 application, what I mean by modularized is that it used to be a monolithic frontend and I have split it in different applications each one of them running in Kubernetes.

Since now it has been split, all of the applications share the common and core modules that I've packed into an NPM and it's being added to each of them in the Jenkins pipeline.

All the applications share the same UX style frontend including it's navigation pane. Now to change between modules, the user just goes to the navigation pane and clicks the desired link.

What I want to do is if the user is already let's say in the foo module and wants to navigate to FOO1 which is still inside the parent FOO module perform and sref navigation, but if it's in the FOO module and wants to go to BAR module perform an href.

To better explain this, this is my current scenario:

www.domain.com/foo

Navigation Bar

```<code>|->FOO
  |-->FOO1
  |-->FOO2
  |-->FOO3
|->BAR
  |-->BAR1
  |-->BAR2
  |-->BAR3
</code>```

This is the code that I have in my navigation.provider.js

```<code>(function (angular) {
    'use strict';

    angular.module('xxxx.core.layout')
        .provider('xxxx.core.layout.NavigationProvider', NavigationProvider);

    NavigationProvider.$inject = [
        'xxxx.core.states.StatesConstant',
        'xxxx.core.auth.PermissionConstant',
        '$windowProvider',
        '$location',
        'xxxx.core.auth.PermissionTypeConstant',
        'xxxx.core.features.FeaturesConstant'
    ];

    function NavigationProvider(StatesConstant, PermissionConstant, $windowProvider, $location, PermissionTypeConstant, FeaturesConstant) {
        this.$get = Navigation;

        function Navigation() {
            var $window = $windowProvider.$get();
            return [
text: 'FOO',
                    permission: [
                        PermissionConstant.XXXX,
                        PermissionConstant.XXXX_EDIT
                    ].toString(),
                    permissionType: PermissionTypeConstant.AT_LEAST_ONE,
                    children: [
                        {
                            text: 'User Management',
                            //sref: StatesConstant.USER_MANAGEMENT_LIST,
                            href: $window.location.protocol + '//' + $window.location.hostname + '/foo/um/list',
                            permission: PermissionConstant.XXXX
                        },
                        {
                            text: 'Active Features',
                            //sref: StatesConstant.TOGGLE_ADMINISTRATOR,
                            href: $window.location.protocol + '//' + $window.location.hostname + '/foo/toggle',
                            permission: PermissionConstant.XXXX
                        },
                        {
                            text: 'Customer List',
                            //sref: StatesConstant.XXXX_LIST,
                            href: $window.location.protocol + '//' + $window.location.hostname + '/foo/customer-list',
                            permission: PermissionConstant.XXXX_EDIT
                        }
                    ]
</code>```

What I would like to implement,it is something like this:

```<code>let $location = $location.path();
if($location = "/foo"){
sref: StatesConstant.USER_MANAGEMENT_LIST,
}else{
href: $window.location.protocol + '//' + $window.location.hostname + '/foo/um/list',
}
</code>```

Any help would be greatly appreciated it.

Cheers!

答:
Here i'm using angular-ui-router and nested states.

```<code> angular.module('myApp', ['ui.router'])
   .config(function($stateProvider, $urlRouterProvider) {
        $stateProvider

        .state('foo', {
            url:'foo',
            views: { ... }
        })

        .state('foo.foo1', {
            url:'foo1',
            views: { ... }
        })

       .state('bar', {
            url:'bar',
            views: { ... }
        })

        .state('bar.bar1', {
            url:'bar1',
            views: { ... }
        })

    $urlRouterProvider.otherwise('/');
});
</code>```

Hope this is what u want!

Body:
I have a modularized AngularJS1.5 application, what I mean by modularized is that it used to be a monolithic frontend and I have split it in different applications each one of them running in Kubernetes.

Since now it has been split, all of the applications share the common and core modules that I've packed into an NPM and it's being added to each of them in the Jenkins pipeline.

All the applications share the same UX style frontend including it's navigation pane. Now to change between modules, the user just goes to the navigation pane and clicks the desired link.

What I want to do is if the user is already let's say in the foo module and wants to navigate to FOO1 which is still inside the parent FOO module perform and sref navigation, but if it's in the FOO module and wants to go to BAR module perform an href.

To better explain this, this is my current scenario:

www.domain.com/foo

Navigation Bar

|->FOO
  |-->FOO1
  |-->FOO2
  |-->FOO3
|->BAR
  |-->BAR1
  |-->BAR2
  |-->BAR3

This is the code that I have in my navigation.provider.js

(function (angular) {
    'use strict';

    angular.module('xxxx.core.layout')
        .provider('xxxx.core.layout.NavigationProvider', NavigationProvider);

    NavigationProvider.$inject = [
        'xxxx.core.states.StatesConstant',
        'xxxx.core.auth.PermissionConstant',
        '$windowProvider',
        '$location',
        'xxxx.core.auth.PermissionTypeConstant',
        'xxxx.core.features.FeaturesConstant'
    ];

    function NavigationProvider(StatesConstant, PermissionConstant, $windowProvider, $location, PermissionTypeConstant, FeaturesConstant) {
        this.$get = Navigation;

        function Navigation() {
            var $window = $windowProvider.$get();
            return [
text: 'FOO',
                    permission: [
                        PermissionConstant.XXXX,
                        PermissionConstant.XXXX_EDIT
                    ].toString(),
                    permissionType: PermissionTypeConstant.AT_LEAST_ONE,
                    children: [
                        {
                            text: 'User Management',
                            //sref: StatesConstant.USER_MANAGEMENT_LIST,
                            href: $window.location.protocol + '//' + $window.location.hostname + '/foo/um/list',
                            permission: PermissionConstant.XXXX
                        },
                        {
                            text: 'Active Features',
                            //sref: StatesConstant.TOGGLE_ADMINISTRATOR,
                            href: $window.location.protocol + '//' + $window.location.hostname + '/foo/toggle',
                            permission: PermissionConstant.XXXX
                        },
                        {
                            text: 'Customer List',
                            //sref: StatesConstant.XXXX_LIST,
                            href: $window.location.protocol + '//' + $window.location.hostname + '/foo/customer-list',
                            permission: PermissionConstant.XXXX_EDIT
                        }
                    ]

What I would like to implement,it is something like this:

let $location = $location.path();
if($location = "/foo"){
sref: StatesConstant.USER_MANAGEMENT_LIST,
}else{
href: $window.location.protocol + '//' + $window.location.hostname + '/foo/um/list',
}

Any help would be greatly appreciated it.

Cheers!

Body:
Here i'm using angular-ui-router and nested states.

 angular.module('myApp', ['ui.router'])
   .config(function($stateProvider, $urlRouterProvider) {
        $stateProvider

        .state('foo', {
            url:'foo',
            views: { ... }
        })

        .state('foo.foo1', {
            url:'foo1',
            views: { ... }
        })

       .state('bar', {
            url:'bar',
            views: { ... }
        })

        .state('bar.bar1', {
            url:'bar1',
            views: { ... }
        })

    $urlRouterProvider.otherwise('/');
});

Hope this is what u want!


问:
How to Accurate FusedApi between 10 meter
Incorrect Fused Location API location LAtitiude Longitude.Is there any API to provide accurate location?</p>

答:
Use this and you will get precision upto 14+ decimal places.

locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 5000, 10, new MyLocationListener());

ContentLicense: CC BY-SA 4.0