You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
494 lines
16 KiB
494 lines
16 KiB
package com.example.academicr;
|
|
|
|
import java.io.IOException;
|
|
import java.io.InputStream;
|
|
import java.io.InputStreamReader;
|
|
import java.io.Reader;
|
|
import java.io.UnsupportedEncodingException;
|
|
import java.net.HttpURLConnection;
|
|
import java.net.MalformedURLException;
|
|
import java.net.URL;
|
|
|
|
import android.app.Activity;
|
|
import android.app.AlertDialog;
|
|
import android.content.DialogInterface;
|
|
import android.content.Intent;
|
|
import android.content.pm.ActivityInfo;
|
|
import android.os.Bundle;
|
|
import android.os.StrictMode;
|
|
import android.view.Menu;
|
|
import android.view.MenuItem;
|
|
import android.view.View;
|
|
import android.view.Window;
|
|
import android.view.WindowManager;
|
|
import android.widget.Button;
|
|
import android.widget.TextView;
|
|
|
|
public class hop3 extends Activity {
|
|
|
|
@Override
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
super.onCreate(savedInstanceState);
|
|
requestWindowFeature(Window.FEATURE_NO_TITLE);//Òþ²Ø±êÌâ
|
|
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);//ÉèÖÃÈ«ÆÁ
|
|
setContentView(R.layout.hopthree);
|
|
if (android.os.Build.VERSION.SDK_INT > 9) {
|
|
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
|
|
StrictMode.setThreadPolicy(policy);
|
|
}
|
|
Intent intent=getIntent();
|
|
String input1=intent.getStringExtra("input1");
|
|
String input2=intent.getStringExtra("input2");
|
|
|
|
TextView startId = (TextView)findViewById(R.id.startid);
|
|
TextView endId = (TextView)findViewById(R.id.endid);
|
|
startId.setText(input1);
|
|
endId.setText(input2);
|
|
|
|
|
|
|
|
|
|
String result3 = null;
|
|
int len = 5000;
|
|
|
|
InputStream is = null;
|
|
try {
|
|
input1 = input1.replace(" ", "%20");
|
|
input2 = input2.replace(" ", "%20");
|
|
URL url = new URL("http://45.62.110.239:8080/bof333?id1="+input1+"&id2="+input2);
|
|
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
|
conn.setRequestMethod("GET");
|
|
conn.setDoInput(true);
|
|
// Starts the query
|
|
conn.connect();
|
|
//int response = conn.getResponseCode();
|
|
is = conn.getInputStream();
|
|
// Convert the InputStream into a string
|
|
result3 = readIt(is, len);
|
|
|
|
// Makes sure that the InputStream is closed after the app is
|
|
// finished using it.
|
|
} catch (MalformedURLException e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
} catch (IOException e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
} finally {
|
|
if (is != null) {
|
|
try {
|
|
is.close();
|
|
} catch (IOException e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|
|
|
|
System.out.println(result3);
|
|
|
|
//final String[] name;
|
|
//name=getname3(result3);
|
|
get get2=new get();
|
|
final String[] name;
|
|
name=get2.getname3(result3);
|
|
System.out.println(name[0]);
|
|
//String[] name1;
|
|
//name1=getname3(result);
|
|
|
|
/*TextView point11 = (TextView)findViewById(R.id.button11);
|
|
TextView point12 = (TextView)findViewById(R.id.button12);
|
|
TextView point13 = (TextView)findViewById(R.id.button13);
|
|
TextView point21 = (TextView)findViewById(R.id.button21);
|
|
TextView point22 = (TextView)findViewById(R.id.button22);
|
|
TextView point23 = (TextView)findViewById(R.id.button23);
|
|
point11.setText(name[0]);
|
|
point12.setText(name[1]);
|
|
point13.setText(name[2]);
|
|
point21.setText(name[3]);
|
|
point22.setText(name[4]);
|
|
point23.setText(name[5]);*/
|
|
|
|
Button Button11 = (Button)findViewById(R.id.button11);
|
|
Button11.setText(name[0]);
|
|
Button11.setOnClickListener(new View.OnClickListener() {
|
|
@Override
|
|
public void onClick(View v) {
|
|
// TODO Auto-generated method stub
|
|
//Õâ¸öµØ·½ÐèÒª±£´æÁãʱ
|
|
|
|
String paper_result = null;
|
|
int len = 500;
|
|
|
|
InputStream is = null;
|
|
try {
|
|
|
|
URL url = new URL("http://45.62.110.239:8080/paper?id="+name[0]);
|
|
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
|
conn.setRequestMethod("GET");
|
|
conn.setDoInput(true);
|
|
// Starts the query
|
|
conn.connect();
|
|
int response = conn.getResponseCode();
|
|
is = conn.getInputStream();
|
|
// Convert the InputStream into a string
|
|
paper_result = readIt(is, len);
|
|
|
|
// Makes sure that the InputStream is closed after the app is
|
|
// finished using it.
|
|
} catch (MalformedURLException e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
} catch (IOException e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
} finally {
|
|
if (is != null) {
|
|
try {
|
|
is.close();
|
|
} catch (IOException e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|
|
new AlertDialog.Builder(hop3.this)
|
|
.setTitle("Paper ID : "+ name[0])
|
|
.setMessage(paper_result)
|
|
.setNegativeButton("Close", new DialogInterface.OnClickListener() {
|
|
@Override
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
//do nothing - it will close on its own
|
|
}
|
|
})
|
|
.show();
|
|
|
|
}
|
|
});
|
|
Button Button12 = (Button)findViewById(R.id.button12);
|
|
Button12.setText(name[0]);
|
|
Button12.setOnClickListener(new View.OnClickListener() {
|
|
@Override
|
|
public void onClick(View v) {
|
|
// TODO Auto-generated method stub
|
|
//Õâ¸öµØ·½ÐèÒª±£´æÁãʱ
|
|
|
|
String paper_result = null;
|
|
int len = 500;
|
|
|
|
InputStream is = null;
|
|
try {
|
|
|
|
URL url = new URL("http://45.62.110.239:8080/paper?id="+name[1]);
|
|
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
|
conn.setRequestMethod("GET");
|
|
conn.setDoInput(true);
|
|
// Starts the query
|
|
conn.connect();
|
|
int response = conn.getResponseCode();
|
|
is = conn.getInputStream();
|
|
// Convert the InputStream into a string
|
|
paper_result = readIt(is, len);
|
|
|
|
// Makes sure that the InputStream is closed after the app is
|
|
// finished using it.
|
|
} catch (MalformedURLException e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
} catch (IOException e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
} finally {
|
|
if (is != null) {
|
|
try {
|
|
is.close();
|
|
} catch (IOException e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|
|
new AlertDialog.Builder(hop3.this)
|
|
.setTitle("Paper ID : "+ name[1])
|
|
.setMessage(paper_result)
|
|
.setNegativeButton("Close", new DialogInterface.OnClickListener() {
|
|
@Override
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
//do nothing - it will close on its own
|
|
}
|
|
})
|
|
.show();
|
|
|
|
}
|
|
});
|
|
|
|
Button Button13 = (Button)findViewById(R.id.button13);
|
|
Button13.setText(name[2]);
|
|
Button13.setOnClickListener(new View.OnClickListener() {
|
|
@Override
|
|
public void onClick(View v) {
|
|
// TODO Auto-generated method stub
|
|
//Õâ¸öµØ·½ÐèÒª±£´æÁãʱ
|
|
|
|
String paper_result = null;
|
|
int len = 500;
|
|
|
|
InputStream is = null;
|
|
try {
|
|
|
|
URL url = new URL("http://45.62.110.239:8080/paper?id="+name[2]);
|
|
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
|
conn.setRequestMethod("GET");
|
|
conn.setDoInput(true);
|
|
// Starts the query
|
|
conn.connect();
|
|
int response = conn.getResponseCode();
|
|
is = conn.getInputStream();
|
|
// Convert the InputStream into a string
|
|
paper_result = readIt(is, len);
|
|
|
|
// Makes sure that the InputStream is closed after the app is
|
|
// finished using it.
|
|
} catch (MalformedURLException e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
} catch (IOException e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
} finally {
|
|
if (is != null) {
|
|
try {
|
|
is.close();
|
|
} catch (IOException e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|
|
new AlertDialog.Builder(hop3.this)
|
|
.setTitle("Paper ID : "+ name[2])
|
|
.setMessage(paper_result)
|
|
.setNegativeButton("Close", new DialogInterface.OnClickListener() {
|
|
@Override
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
//do nothing - it will close on its own
|
|
}
|
|
})
|
|
.show();
|
|
|
|
}
|
|
});
|
|
|
|
Button Button21 = (Button)findViewById(R.id.button21);
|
|
Button21.setText(name[3]);
|
|
Button21.setOnClickListener(new View.OnClickListener() {
|
|
@Override
|
|
public void onClick(View v) {
|
|
// TODO Auto-generated method stub
|
|
//Õâ¸öµØ·½ÐèÒª±£´æÁãʱ
|
|
|
|
String paper_result = null;
|
|
int len = 500;
|
|
|
|
InputStream is = null;
|
|
try {
|
|
|
|
URL url = new URL("http://45.62.110.239:8080/paper?id="+name[3]);
|
|
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
|
conn.setRequestMethod("GET");
|
|
conn.setDoInput(true);
|
|
// Starts the query
|
|
conn.connect();
|
|
int response = conn.getResponseCode();
|
|
is = conn.getInputStream();
|
|
// Convert the InputStream into a string
|
|
paper_result = readIt(is, len);
|
|
|
|
// Makes sure that the InputStream is closed after the app is
|
|
// finished using it.
|
|
} catch (MalformedURLException e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
} catch (IOException e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
} finally {
|
|
if (is != null) {
|
|
try {
|
|
is.close();
|
|
} catch (IOException e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|
|
new AlertDialog.Builder(hop3.this)
|
|
.setTitle("Paper ID : "+ name[3])
|
|
.setMessage(paper_result)
|
|
.setNegativeButton("Close", new DialogInterface.OnClickListener() {
|
|
@Override
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
//do nothing - it will close on its own
|
|
}
|
|
})
|
|
.show();
|
|
|
|
}
|
|
});
|
|
|
|
Button Button22 = (Button)findViewById(R.id.button22);
|
|
Button22.setText(name[4]);
|
|
Button22.setOnClickListener(new View.OnClickListener() {
|
|
@Override
|
|
public void onClick(View v) {
|
|
// TODO Auto-generated method stub
|
|
//Õâ¸öµØ·½ÐèÒª±£´æÁãʱ
|
|
|
|
String paper_result = null;
|
|
int len = 500;
|
|
|
|
InputStream is = null;
|
|
try {
|
|
|
|
URL url = new URL("http://45.62.110.239:8080/paper?id="+name[4]);
|
|
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
|
conn.setRequestMethod("GET");
|
|
conn.setDoInput(true);
|
|
// Starts the query
|
|
conn.connect();
|
|
int response = conn.getResponseCode();
|
|
is = conn.getInputStream();
|
|
// Convert the InputStream into a string
|
|
paper_result = readIt(is, len);
|
|
|
|
// Makes sure that the InputStream is closed after the app is
|
|
// finished using it.
|
|
} catch (MalformedURLException e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
} catch (IOException e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
} finally {
|
|
if (is != null) {
|
|
try {
|
|
is.close();
|
|
} catch (IOException e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|
|
new AlertDialog.Builder(hop3.this)
|
|
.setTitle("Paper ID : "+ name[4])
|
|
.setMessage(paper_result)
|
|
.setNegativeButton("Close", new DialogInterface.OnClickListener() {
|
|
@Override
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
//do nothing - it will close on its own
|
|
}
|
|
})
|
|
.show();
|
|
|
|
}
|
|
});
|
|
|
|
Button Button23 = (Button)findViewById(R.id.button23);
|
|
Button23.setText(name[5]);
|
|
Button23.setOnClickListener(new View.OnClickListener() {
|
|
@Override
|
|
public void onClick(View v) {
|
|
// TODO Auto-generated method stub
|
|
//Õâ¸öµØ·½ÐèÒª±£´æÁãʱ
|
|
|
|
String paper_result = null;
|
|
int len = 500;
|
|
|
|
InputStream is = null;
|
|
try {
|
|
|
|
URL url = new URL("http://45.62.110.239:8080/paper?id="+name[5]);
|
|
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
|
conn.setRequestMethod("GET");
|
|
conn.setDoInput(true);
|
|
// Starts the query
|
|
conn.connect();
|
|
int response = conn.getResponseCode();
|
|
is = conn.getInputStream();
|
|
// Convert the InputStream into a string
|
|
paper_result = readIt(is, len);
|
|
|
|
// Makes sure that the InputStream is closed after the app is
|
|
// finished using it.
|
|
} catch (MalformedURLException e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
} catch (IOException e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
} finally {
|
|
if (is != null) {
|
|
try {
|
|
is.close();
|
|
} catch (IOException e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|
|
new AlertDialog.Builder(hop3.this)
|
|
.setTitle("Paper ID : "+ name[5])
|
|
.setMessage(paper_result)
|
|
.setNegativeButton("Close", new DialogInterface.OnClickListener() {
|
|
@Override
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
//do nothing - it will close on its own
|
|
}
|
|
})
|
|
.show();
|
|
|
|
}
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
public String readIt(InputStream stream, int len) throws IOException, UnsupportedEncodingException {
|
|
Reader reader = null;
|
|
reader = new InputStreamReader(stream, "UTF-8");
|
|
char[] buffer = new char[len];
|
|
reader.read(buffer);
|
|
return new String(buffer);
|
|
}
|
|
|
|
@Override
|
|
public boolean onCreateOptionsMenu(Menu menu) {
|
|
// Inflate the menu; this adds items to the action bar if it is present.
|
|
getMenuInflater().inflate(R.menu.main, menu);
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public boolean onOptionsItemSelected(MenuItem item) {
|
|
// Handle action bar item clicks here. The action bar will
|
|
// automatically handle clicks on the Home/Up button, so long
|
|
// as you specify a parent activity in AndroidManifest.xml.
|
|
int id = item.getItemId();
|
|
if (id == R.id.action_settings) {
|
|
return true;
|
|
}
|
|
return super.onOptionsItemSelected(item);
|
|
}
|
|
|
|
@Override
|
|
protected void onResume() {
|
|
/**
|
|
* ÉèÖÃΪºáÆÁ
|
|
*/
|
|
if(getRequestedOrientation()!=ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE){
|
|
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
|
}
|
|
super.onResume();
|
|
}
|
|
} |