package com.example.jack.timetable;
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.os.Message;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
import android.widget.Toast;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class SecondActive extends AppCompatActivity {
String ID;
String path;
String cookie;
String referer;
String params;
String Data = null;
Handler handler;
String yzmCheck = null;
List classtable;
TextView textView_Mon_one;
TextView textView_Mon_two;
TextView textView_Mon_three ;
TextView textView_Mon_four;
TextView textView_Mon_five;
TextView textView_Mon_six;
TextView textView_Tues_one;
TextView textView_Tues_two ;
TextView textView_Tues_three ;
TextView textView_Tues_four;
TextView textView_Tues_five ;
TextView textView_Tues_six;
TextView textView_Wed_one;
TextView textView_Wed_two;
TextView textView_Wed_three;
TextView textView_Wed_four;
TextView textView_Wed_five;
TextView textView_Wed_six;
TextView textView_Thur_one;
TextView textView_Thur_two;
TextView textView_Thur_three;
TextView textView_Thur_four;
TextView textView_Thur_five;
TextView textView_Thur_six;
TextView textView_Fri_one;
TextView textView_Fri_two;
TextView textView_Fri_three;
TextView textView_Fri_four;
TextView textView_Fri_five;
TextView textView_Fri_six;
TextView textView_Sat_one;
TextView textView_Sat_two;
TextView textView_Sat_three;
TextView textView_Sat_four;
TextView textView_Sat_five;
TextView textView_Sat_six;
TextView textView_Sun_one;
TextView textView_Sun_two;
TextView textView_Sun_three;
TextView textView_Sun_four;
TextView textView_Sun_five;
TextView textView_Sun_six;
String[] classer = new String[42];
String yzm;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_class_table);
Intent intent = getIntent();
ID =intent.getStringExtra("ID");
yzm = intent.getStringExtra("yzm");
path = "http://jwgl.lnc.edu.cn/ZNPK/TeacherKBFB_rpt.aspx";
cookie = intent.getStringExtra("cookie");
//
Log.i("cookie111222",cookie);
referer = "http://jwgl.lnc.edu.cn/ZNPK/TeacherKBFB.aspx";
params = "Sel_XNXQ=20170&Sel_JS="+ID+"&type=1&txt_yzm="+yzm;
/*"Sel_XNXQ=20170&Sel_JS="+ID+"&type=1&txt_yzm=8ufc";*/
Get();
handler = new Handler(){
public void handleMessage(Message msg) {
/*if (yzmCheck!=null){
Toast.makeText(SecondActive.this, "验证码有误,重新输入", Toast.LENGTH_SHORT);
Intent intent = new Intent(SecondActive.this,FirstActive.class);
intent.putExtra("check","false");
startActivity(intent);
}*/
if(classtable.size()>41) {
textView_Mon_one.setText(classtable.get(0));
textView_Mon_two.setText(classtable.get(7));
textView_Mon_three.setText(classtable.get(14));
textView_Mon_four.setText(classtable.get(21));
textView_Mon_five.setText(classtable.get(28));
textView_Mon_six.setText(classtable.get(35));
//星期二
textView_Tues_one.setText(classtable.get(1));
textView_Tues_two.setText(classtable.get(8));
textView_Tues_three.setText(classtable.get(15));
textView_Tues_four.setText(classtable.get(22));
textView_Tues_five.setText(classtable.get(29));
textView_Tues_six.setText(classtable.get(36));
//星期三
textView_Wed_one.setText(classtable.get(2));
textView_Wed_two.setText(classtable.get(9));
textView_Wed_three.setText(classtable.get(16));
textView_Wed_four.setText(classtable.get(23));
textView_Wed_five.setText(classtable.get(30));
textView_Wed_six.setText(classtable.get(37));
//星期四
textView_Thur_one.setText(classtable.get(3));
textView_Thur_two.setText(classtable.get(10));
textView_Thur_three.setText(classtable.get(17));
textView_Thur_four.setText(classtable.get(24));
textView_Thur_five.setText(classtable.get(31));
textView_Thur_six.setText(classtable.get(38));
//星期五
textView_Fri_one.setText(classtable.get(4));
textView_Fri_two.setText(classtable.get(11));
textView_Fri_three.setText(classtable.get(18));
textView_Fri_four.setText(classtable.get(25));
textView_Fri_five.setText(classtable.get(32));
textView_Fri_six.setText(classtable.get(39));
//星期六
textView_Sat_one.setText(classtable.get(5));
textView_Sat_two.setText(classtable.get(12));
textView_Sat_three.setText(classtable.get(19));
textView_Sat_four.setText(classtable.get(26));
textView_Sat_five.setText(classtable.get(33));
textView_Sat_six.setText(classtable.get(40));
//星期天
textView_Sun_one.setText(classtable.get(6));
textView_Sun_two.setText(classtable.get(19));
textView_Sun_three.setText(classtable.get(20));
textView_Sun_four.setText(classtable.get(27));
textView_Sun_five.setText(classtable.get(34));
textView_Sun_six.setText(classtable.get(41));
int i= 1;
for (String s:classtable){
Log.i("classtest",i+" "+s);
i++;
}
classtable.clear();
}
}
};
textView_Mon_one = (TextView) findViewById(R.id.Mon_one);
textView_Mon_two = (TextView) findViewById(R.id.Mon_two);
textView_Mon_three= (TextView) findViewById(R.id.Mon_three);
textView_Mon_four = (TextView) findViewById(R.id.Mon_four);
textView_Mon_five = (TextView) findViewById(R.id.Mon_five);
textView_Mon_six = (TextView) findViewById(R.id.Mon_six);
textView_Tues_one = (TextView) findViewById(R.id.Tues_one);
textView_Tues_two = (TextView) findViewById(R.id.Tues_two);
textView_Tues_three = (TextView) findViewById(R.id.Tues_three);
textView_Tues_four = (TextView) findViewById(R.id.Tues_four);
textView_Tues_five = (TextView) findViewById(R.id.Tues_five);
textView_Tues_six = (TextView) findViewById(R.id.Tues_six);
textView_Wed_one = (TextView) findViewById(R.id.Wed_one);
textView_Wed_two = (TextView) findViewById(R.id.Wed_two);
textView_Wed_three = (TextView) findViewById(R.id.Wed_three);
textView_Wed_four = (TextView) findViewById(R.id.Wed_four);
textView_Wed_five = (TextView) findViewById(R.id.Wed_five);
textView_Wed_six = (TextView) findViewById(R.id.Wed_six);
textView_Thur_one = (TextView) findViewById(R.id.Thur_one);
textView_Thur_two = (TextView) findViewById(R.id.Thur_two);
textView_Thur_three = (TextView) findViewById(R.id.Thur_three);
textView_Thur_four = (TextView) findViewById(R.id.Thur_four);
textView_Thur_five = (TextView) findViewById(R.id.Thur_five);
textView_Thur_six = (TextView) findViewById(R.id.Thur_six);
textView_Fri_one = (TextView) findViewById(R.id.Fri_one);
textView_Fri_two = (TextView) findViewById(R.id.Fri_two);
textView_Fri_three = (TextView) findViewById(R.id.Fri_three);
textView_Fri_four = (TextView) findViewById(R.id.Fri_four);
textView_Fri_five = (TextView) findViewById(R.id.Fri_five);
textView_Fri_six = (TextView) findViewById(R.id.Fri_six);
textView_Sat_one = (TextView) findViewById(R.id.Sat_one);
textView_Sat_two = (TextView) findViewById(R.id.Sat_two);
textView_Sat_three = (TextView) findViewById(R.id.Sat_three);
textView_Sat_four = (TextView) findViewById(R.id.Sat_four);
textView_Sat_five = (TextView) findViewById(R.id.Sat_five);
textView_Sat_six = (TextView) findViewById(R.id.Sat_six);
textView_Sun_one = (TextView) findViewById(R.id.Sun_one);
textView_Sun_two = (TextView) findViewById(R.id.Sun_two);
textView_Sun_three = (TextView) findViewById(R.id.Sun_three);
textView_Sun_four = (TextView) findViewById(R.id.Sun_four);
textView_Sun_five = (TextView) findViewById(R.id.Sun_five);
textView_Sun_six = (TextView) findViewById(R.id.Sun_six);
}
public void Get(){
new Thread(new Runnable() {
public void run() {
try {
/*获取数据*/
getClassData getclasstable = new getClassData();
classtable = getclasstable.getClassData(path,cookie,referer,params);
/*获取完成*/
Message message = Message.obtain();
message.obj="222";
//通过Handler发布传送消息,handler
handler.sendMessage(message);
} catch (Exception e) {
e.printStackTrace();
}
}
}).start();
}
public void setshow(){
textView_Mon_one.setText(classtable.get(0));
textView_Mon_two.setText(classtable.get(1));
textView_Mon_three.setText(classtable.get(2));
textView_Mon_four.setText(classtable.get(3));
textView_Mon_five.setText(classtable.get(4));
textView_Mon_six.setText(classtable.get(5));
//星期二
textView_Tues_one.setText(classtable.get(6));
textView_Tues_two.setText(classtable.get(7));
textView_Tues_three.setText(classtable.get(8));
textView_Tues_four.setText(classtable.get(9));
textView_Tues_five.setText(classtable.get(10));
textView_Tues_six.setText(classtable.get(11));
//星期三
textView_Wed_one.setText(classtable.get(12));
textView_Wed_two.setText(classtable.get(13));
textView_Wed_three.setText(classtable.get(14));
textView_Wed_four.setText(classtable.get(15));
textView_Wed_five.setText(classtable.get(16));
textView_Wed_six.setText(classtable.get(17));
//星期四
textView_Thur_one.setText(classtable.get(18));
textView_Thur_two.setText(classtable.get(19));
textView_Thur_three.setText(classtable.get(20));
textView_Thur_four.setText(classtable.get(21));
textView_Thur_five.setText(classtable.get(22));
textView_Thur_six.setText(classtable.get(23));
//星期五
textView_Fri_one.setText(classtable.get(24));
textView_Fri_two.setText(classtable.get(25));
textView_Fri_three.setText(classtable.get(26));
textView_Fri_four.setText(classtable.get(27));
textView_Fri_five.setText(classtable.get(28));
textView_Fri_six.setText(classtable.get(29));
//星期六
textView_Sat_one.setText(classtable.get(30));
textView_Sat_two.setText(classtable.get(31));
textView_Sat_three.setText(classtable.get(32));
textView_Sat_four.setText(classtable.get(33));
textView_Sat_five.setText(classtable.get(34));
textView_Sat_six.setText(classtable.get(35));
//星期天
textView_Sun_one.setText(classtable.get(36));
textView_Sun_two.setText(classtable.get(37));
textView_Sun_three.setText(classtable.get(38));
textView_Sun_four.setText(classtable.get(39));
textView_Sun_five.setText(classtable.get(40));
textView_Sun_six.setText(classtable.get(41));
}
}
一键复制
编辑
Web IDE
原始数据
按行查看
历史