Skip to content

Commit 4c728be

Browse files
committed
範例app加入url檢查
1 parent be993df commit 4c728be

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ android {
1010
applicationId "com.jimmyworks.easyhttpexample"
1111
minSdk rootProject.ext.minSdkVersion
1212
targetSdk rootProject.ext.targetSdkVersion
13-
versionCode 1
13+
versionCode 2
1414
versionName "1.0"
1515

1616
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

app/src/main/java/com/jimmyworks/easyhttpexample/activity/DemoRequestActivity.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import android.content.Intent
55
import android.net.Uri
66
import android.os.Bundle
77
import android.provider.OpenableColumns
8+
import android.util.Patterns
89
import android.view.MenuInflater
910
import android.view.View
1011
import android.widget.PopupMenu
@@ -242,6 +243,12 @@ class DemoRequestActivity : AppCompatActivity(), View.OnClickListener {
242243
}
243244

244245
private fun doRequest() {
246+
247+
if (!Patterns.WEB_URL.matcher(viewModel.url).matches()) {
248+
UiUtils.toast(this, getString(R.string.url_error_hint))
249+
return
250+
}
251+
245252
val alertDialog = UiUtils.loadingAlertDialog(this)
246253

247254
val headerMap: MutableMap<String, String> = HashMap()

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,5 @@
3131
<string name="file">File</string>
3232
<string name="text">Text</string>
3333
<string name="about_content">This app is demo for EasyHttp Library.\nYou can get more information in the github page.</string>
34+
<string name="url_error_hint">Url Error</string>
3435
</resources>

0 commit comments

Comments
 (0)