Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
石璀亮
/
system_info
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 6e742ed5
authored
Jul 19, 2017
by
石璀亮
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(model):add the product model choose ui, and logic for choose
1 parent
581aa6a7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
107 additions
and
6 deletions
app/src/main/java/com/nbbsw/cuiliang/systemsetting/ProductModelActivity.java
app/src/main/java/com/nbbsw/cuiliang/systemsetting/SystemSetting.java
app/src/main/res/layout/activity_model.xml
app/src/main/java/com/nbbsw/cuiliang/systemsetting/ProductModelActivity.java
View file @
6e742ed
package
com
.
nbbsw
.
cuiliang
.
systemsetting
;
import
android.app.AlertDialog
;
import
android.app.Dialog
;
import
android.content.DialogInterface
;
import
android.os.Bundle
;
import
android.support.v7.app.AppCompatActivity
;
import
android.view.View
;
import
android.widget.Button
;
import
android.widget.EditText
;
/**
* Created by st on 17-7-19.
* Function: The Product Model Setting.
*/
public
class
ProductModelActivity
extends
AppCompatActivity
{
public
static
int
mSelectedType
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_model
);
// Choose the model for the product
Button
chooseButton
=
(
Button
)
findViewById
(
R
.
id
.
choose_type
);
chooseButton
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
chooseTypeOfProduct
();
}
});
// Clean the model input text.
Button
cleanButton
=
(
Button
)
findViewById
(
R
.
id
.
model_clean
);
cleanButton
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
EditText
modelType
=
(
EditText
)
findViewById
(
R
.
id
.
model_type
);
modelType
.
setText
(
""
);
}
});
// Reset product model to default.
Button
resetButton
=
(
Button
)
findViewById
(
R
.
id
.
model_reset
);
resetButton
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
String
value
=
SystemSetting
.
handleModelStatus
();
EditText
modelType
=
(
EditText
)
findViewById
(
R
.
id
.
model_type
);
modelType
.
setText
(
value
);
}
});
// Confirm product model
Button
confirmButton
=
(
Button
)
findViewById
(
R
.
id
.
model_confirm
);
confirmButton
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
EditText
modelType
=
(
EditText
)
findViewById
(
R
.
id
.
model_type
);
String
value
=
SystemSetting
.
handleModelStatus
(
modelType
.
getText
().
toString
());
modelType
.
setText
(
value
);
}
});
}
/**
* Choose type of product.
* A Recommend for user input.
*/
public
void
chooseTypeOfProduct
(){
final
String
[]
arrayFruit
=
new
String
[]
{
"4G"
,
"3G"
,
"2G"
,
"1G"
};
Dialog
alertDialog
=
new
AlertDialog
.
Builder
(
this
).
setTitle
(
"选择型号"
).
setIcon
(
R
.
drawable
.
ic_launcher
)
.
setSingleChoiceItems
(
arrayFruit
,
0
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
ProductModelActivity
.
mSelectedType
=
which
;
}
}).
setPositiveButton
(
"确认"
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
EditText
modelType
=
(
EditText
)
findViewById
(
R
.
id
.
model_type
);
modelType
.
setText
(
arrayFruit
[
ProductModelActivity
.
mSelectedType
]);
}
}).
setNegativeButton
(
"取消"
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
}
}).
create
();
alertDialog
.
show
();
}
}
app/src/main/java/com/nbbsw/cuiliang/systemsetting/SystemSetting.java
View file @
6e742ed
...
...
@@ -49,4 +49,15 @@ public class SystemSetting {
}
}
public
static
String
handleModelStatus
()
{
String
value
=
"4G"
;
return
handleModelStatus
(
value
);
}
public
static
String
handleModelStatus
(
String
value
)
{
Log
.
d
(
"SystemSetting"
,
"Model:"
+
value
);
// TODO: System setting For change the product model. eg. 3G, 4G...
return
value
;
}
}
\ No newline at end of file
app/src/main/res/layout/activity_model.xml
View file @
6e742ed
...
...
@@ -10,14 +10,14 @@
android:text=
"@string/model_input_tips"
/>
<EditText
android:id=
"@+id/
editText2
"
android:id=
"@+id/
model_type
"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:ems=
"10"
android:inputType=
"textPersonName"
/>
<Button
android:id=
"@+id/
button4
"
android:id=
"@+id/
choose_type
"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"选择其他型号"
/>
...
...
@@ -26,21 +26,21 @@
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
>
<Button
android:id=
"@+id/
button
"
android:id=
"@+id/
model_confirm
"
android:layout_width=
"0dp"
android:layout_weight=
"1"
android:layout_height=
"wrap_content"
android:text=
"确定"
/>
<Button
android:id=
"@+id/
button2
"
android:id=
"@+id/
model_reset
"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:text=
"重置"
/>
<Button
android:id=
"@+id/
button3
"
android:id=
"@+id/
model_clean
"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
...
...
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