package com.example.caisiyu.bishe_max;
import android.annotation.TargetApi;
import android.app.AlertDialog;
import android.app.Service;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.os.Handler;
import android.os.Message;
import android.os.Vibrator;
import android.preference.DialogPreference;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.View;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.TimeUnit;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;
public class MainActivity_Two extends ActionBarActivity {
private Button Btn_deng, Btn_huo, Btn_feng, Btn_men;
private DrawerLayout mdrawerLayout;
private TextView Text_wendu;
private TextView Text_shidu;
private TextView Text_fengsu;
private TextView Text_guangzhao;
private TextView Text_state_wendu, Text_state_shidu, Text_state_fengsu, Text_state_guangzhao,Shebei_State;
private Handler handler;
private Timer timer;
private Vibrator vibrator;
private ImageView Dream_zhedie;
// private int Connect_Flag = 0; //在request消息回调是 做标志位
// private int Connect_Back_Message = 0;
private List<Fruit> fruitList = new ArrayList<Fruit>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_activity__two);
vibrator=(Vibrator)getSystemService(Service.VIBRATOR_SERVICE);
timer=new Timer(); //定义一个定时器
// on_timer_Stop(); //调用 cancel后 就不能调用schedule语句,否则提示出错,提示如下:
ui_init();
// okhttp_Request("http://118.178.59.37:1880/Android_Respond?environment=1");
on_timer_start();
initFruits(); // 初始化水果数据
FruitAdapter adapter = new FruitAdapter(MainActivity_Two.this, R.layout.list_item, fruitList);
ListView listView = (ListView) findViewById(R.id.MyListView);
listView.setAdapter(adapter);
//ListView item的点击事件
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
if (i == 0) {
Toast.makeText(MainActivity_Two.this, "这是第一个", Toast.LENGTH_SHORT).show();
mdrawerLayout.closeDrawer(Gravity.START);
vibrator.vibrate(100);//震动一次,时长为100
}
if (i == 1) {
Toast.makeText(MainActivity_Two.this, "这是第二个", Toast.LENGTH_SHORT).show();
mdrawerLayout.closeDrawer(Gravity.START);
vibrator.vibrate(100);//震动一次,时长为100
}
if (i == 2) {
Toast toast = Toast.makeText(MainActivity_Two.this, "姓名:\t\t\t蔡思宇\r\n学校:\t\t\t郑州升达经贸管理学院\r\n班级:\t\t\t电子信息工程1班\r\n联系QQ:\t2455861209", Toast.LENGTH_LONG);
toast.setGravity(Gravity.BOTTOM,10,250);
toast.show();
mdrawerLayout.closeDrawer(Gravity.START);
vibrator.vibrate(100);//震动一次,时长为100
}
if (i == 3) {
Intent intent = new Intent(MainActivity_Two.this, MainActivity_three_quxian.class);
startActivity(intent);
mdrawerLayout.closeDrawer(Gravity.START);
vibrator.vibrate(100);//震动一次,时长为100
// finish(); //在另一个界面 点返回还能返回回来 ,并没有 删除当前界面
}
if (i == 4) {
// Toast.makeText(MainActivity_Two.this, "这是第si个", Toast.LENGTH_SHORT).show();
final EditText editText = new EditText(MainActivity_Two.this);
editText.setFocusable(true);
new AlertDialog.Builder(MainActivity_Two.this)
.setTitle("请输入你的评价:")
.setIcon(R.drawable.pingjia)
.setView(editText)
.setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
if (!TextUtils.isEmpty(editText.getText().toString())) {
String str = String.format("http://118.178.59.37:1880/Android_Callback?Message=%s", editText.getText().toString());
okhttp_Request(str);
Toast.makeText(MainActivity_Two.this, "十分感谢你的评价!!!", Toast.LENGTH_SHORT).show();
// System.out.println("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" + editText.getText().toString());
} else {
Toast.makeText(MainActivity_Two.this, "你没有填写评价内容!!!", Toast.LENGTH_SHORT).show();
}
}
})
.setNegativeButton("取消", null).show();
mdrawerLayout.closeDrawer(Gravity.START);
vibrator.vibrate(100);//震动一次,时长为100
}
if (i == 5) {
new AlertDialog.Builder(MainActivity_Two.this)
.setTitle("警告~")
.setIcon(R.drawable.tishi)
.setMessage("确定要退出程序吗?")
.setNegativeButton("取消", null)
.setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface arg0, int arg1) {
System.exit(0);
}
})
.show();
mdrawerLayout.closeDrawer(Gravity.START);
vibrator.vibrate(100);//震动一次,时长为100
}
}
});
handler = new Handler() {
public void handleMessage(Message msg) {
super.handleMessage(msg);
switch (msg.what) {
case 0:
okhttp_Request("http://118.178.59.37:1880/Android_Respond?environment=1"); //请求数据
break;
case 1:
String msg_json = msg.obj.toString();//
// System.out.println("ConnectionSuccess----------" + msg.obj.toString());
Node_red_Data_Process(msg_json);
handler.removeMessages(1); //�
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
毕业设计_仓库管理系统_bishe_max_okhttp.zip (77个子文件)
bishe_max_okhttp-master
gradle.properties 855B
gradle
wrapper
gradle-wrapper.jar 52KB
gradle-wrapper.properties 230B
caisiyu.apk 1.47MB
app
caisiyu.apk 1.47MB
src
androidTest
java
com
example
caisiyu
bishe_max
ApplicationTest.java 360B
test
java
com
example
caisiyu
bishe_max
ExampleUnitTest.java 322B
main
java
com
example
caisiyu
bishe_max
FruitAdapter.java 1KB
MainActivity_Two.java 18KB
MainActivity.java 1KB
MainActivity_three_quxian.java 13KB
res
mipmap-xxhdpi
ic_launcher.png 8KB
mipmap-hdpi
ic_launcher.png 3KB
mipmap-mdpi
ic_launcher.png 2KB
mipmap-xxxhdpi
ic_launcher.png 10KB
mipmap-xhdpi
ic_launcher.png 5KB
values-w820dp
dimens.xml 358B
values
dimens.xml 211B
strings.xml 72B
styles.xml 194B
layout
list_item.xml 635B
activity_main.xml 7KB
activity_main_activity_three_quxian.xml 1KB
activity_main_activity__two.xml 21KB
drawable
fankui.png 2KB
tishikuang.png 523B
pingjia.png 803B
zhedie.png 593B
background_gradient1.xml 273B
btn.xml 1KB
wendu.png 1KB
callback.png 658B
fenghxe.png 4KB
start.jpg 147KB
zuozhe.png 2KB
jiudian.png 4KB
fengsu.png 1KB
shutiao.png 4KB
fan.png 3KB
fushishen.png 3KB
buttonstyle.xml 588B
daqiao.png 4KB
shidu.png 2KB
exit.png 2KB
qidong.jpg 275KB
mqtt.png 2KB
zhexian1.png 1KB
tishi.png 2KB
guangzhao.png 2KB
zhexian.png 2KB
cangku.png 907B
background_gradient.xml 273B
icon.png 15KB
AndroidManifest.xml 1KB
proguard-rules.pro 645B
libs
okio-1.9.0.jar 74KB
mpandroidchartlibrary-2-1-6.jar 508KB
okhttp-3.2.0.jar 328KB
build.gradle 772B
app-release.apk 1.47MB
.gitignore 7B
gradlew.bat 2KB
build.gradle 498B
.idea
.name 16B
runConfigurations.xml 564B
vcs.xml 164B
misc.xml 3KB
inspectionProfiles
Project_Default.xml 667B
profiles_settings.xml 235B
compiler.xml 686B
modules.xml 369B
gradle.xml 679B
encodings.xml 159B
copyright
profiles_settings.xml 74B
settings.gradle 15B
gradlew 5KB
.gitignore 97B
共 77 条
- 1
资源评论
好家伙VCC
- 粉丝: 2112
- 资源: 9145
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功