Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
polysoft-nafmii
/
polysoft-android
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit d52336cc
authored
May 18, 2021
by
amateur
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
1
1 parent
adb6ccb9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
77 additions
and
7 deletions
app/src/main/java/com/polysoft/nafmii/activity/InputUrlActivity.java
app/src/main/res/layout/activity_input_url.xml
app/src/main/java/com/polysoft/nafmii/activity/InputUrlActivity.java
View file @
d52336c
...
@@ -2,25 +2,68 @@ package com.polysoft.nafmii.activity;
...
@@ -2,25 +2,68 @@ package com.polysoft.nafmii.activity;
import
androidx.appcompat.app.AppCompatActivity
;
import
androidx.appcompat.app.AppCompatActivity
;
import
android.content.Intent
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.text.TextUtils
;
import
android.view.View
;
import
android.view.View
;
import
android.widget.EditText
;
import
android.widget.EditText
;
import
android.widget.RadioButton
;
import
com.polysoft.nafmii.R
;
import
com.polysoft.nafmii.R
;
import
com.polysoft.nafmii.utils.IntentUtils
;
import
com.polysoft.nafmii.utils.SpUtils
;
import
com.polysoft.nafmii.utils.ToastUtils
;
public
class
InputUrlActivity
extends
AppCompatActivity
{
public
class
InputUrlActivity
extends
AppCompatActivity
{
final
String
KEY_URL
=
"Input_Url"
;
final
String
KEY_CHANNEL
=
"Input_Channel"
;
@Override
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_input_url
);
setContentView
(
R
.
layout
.
activity_input_url
);
findViewById
(
R
.
id
.
button
).
setOnClickListener
(
new
View
.
OnClickListener
()
{
findViewById
(
R
.
id
.
button
).
setOnClickListener
(
v
->
{
@Override
jumpHome
();
public
void
onClick
(
View
v
)
{
EditText
inputUrl
=
findViewById
(
R
.
id
.
input_url
);
String
url
=
inputUrl
.
getText
().
toString
();
}
});
});
this
.
init
();
}
private
void
init
()
{
EditText
input
=
findViewById
(
R
.
id
.
input_url
);
input
.
setText
(
SpUtils
.
getString
(
KEY_URL
,
""
));
String
channel
=
SpUtils
.
getString
(
KEY_CHANNEL
,
""
);
RadioButton
button1
=
findViewById
(
R
.
id
.
input_channel_1
);
RadioButton
button2
=
findViewById
(
R
.
id
.
input_channel_2
);
if
(
channel
.
equals
(
button1
.
getTag
()))
{
button1
.
setChecked
(
true
);
}
else
if
(
channel
.
equals
(
button2
.
getTag
()))
{
button2
.
setChecked
(
true
);
}
}
private
void
jumpHome
()
{
EditText
input
=
findViewById
(
R
.
id
.
input_url
);
String
url
=
input
.
getText
().
toString
();
if
(!
TextUtils
.
isEmpty
(
url
))
{
ToastUtils
.
showLong
(
"url 不能为空"
);
}
RadioButton
button1
=
findViewById
(
R
.
id
.
input_channel_1
);
RadioButton
button2
=
findViewById
(
R
.
id
.
input_channel_2
);
String
channel
=
(
String
)
button1
.
getTag
();
if
(
button2
.
isChecked
())
{
channel
=
(
String
)
button2
.
getTag
();
}
SpUtils
.
putString
(
KEY_CHANNEL
,
channel
);
SpUtils
.
putString
(
KEY_URL
,
url
);
Intent
intent
=
new
Intent
(
this
,
HomeActivity
.
class
);
intent
.
putExtra
(
channel
,
url
);
super
.
startActivity
(
intent
);
}
}
}
}
\ No newline at end of file
\ No newline at end of file
app/src/main/res/layout/activity_input_url.xml
View file @
d52336c
...
@@ -20,11 +20,38 @@
...
@@ -20,11 +20,38 @@
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
/>
app:layout_constraintTop_toTopOf=
"parent"
/>
<RadioGroup
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"10dp"
android:orientation=
"horizontal"
app:layout_constraintEnd_toEndOf=
"@+id/input_url"
app:layout_constraintStart_toStartOf=
"@+id/input_url"
app:layout_constraintTop_toBottomOf=
"@+id/input_url"
>
<RadioButton
android:id=
"@+id/input_channel_1"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:checked=
"true"
android:tag=
"home"
android:text=
"首页"
/>
<RadioButton
android:id=
"@+id/input_channel_2"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginLeft=
"30dp"
android:tag=
"learn"
android:text=
"学习"
/>
</RadioGroup>
<Button
<Button
android:id=
"@+id/button"
android:id=
"@+id/button"
android:layout_width=
"0dp"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"
5
0dp"
android:layout_marginTop=
"
8
0dp"
android:text=
"进入"
android:text=
"进入"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment