Advertisement
Guest User

Untitled

a guest
Aug 3rd, 2015
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.37 KB | None | 0 0
  1. public class SearchGroup extends MainActivity implements TextWatcher {
  2. private AutoCompleteTextView group;
  3. protected String[] spisokGrp = {"ИВ-14-1", "ИВ-14-2", "ИВ-14-21", "ИВ-201", "ИВ-202",
  4. "ИВ-301", "ИВ-302", "ИВ-401", "ИВ-402", "ИП-14-22", "ИП-14-3", "ИП-14-4", "ИП-203",
  5. "ИП-204", "ИП-303", "ИП-304", "ИП-312", "ИП-403", "ИП-404", "ИП-411", "РА-14-5", "РА-14-6",
  6. "РА-205", "РА-305", "РА-314", "РА-405", "РА-414", "РЭ-14-7С", "СР-14-12", "СР-14-13",
  7. "СР-208", "СР-308", "СР-408", "ТМ-14-9", "ТМ-206", "ТМ-306", "ТМ-406", "ТО-14-8", "ТО-210", "ТО-310",
  8. "ТО-410", "УД-14-11", "УД-211", "УД-213К", "УК-14-10", "УК-207", "УК-307", "УК-311", "УК-407",
  9. "ЭЭ-14-23", "ЭЭ-313", "ЮС-14-14", "ЮС-14-15К", "ЮС-14-16К", "ЮС-209", "ЮС-212К", "ЮС-309"};
  10. protected Intent intent;
  11. private String groupName;
  12. private String nameGroup;
  13. private searchGroup sG;
  14.  
  15. @Override
  16. protected void onCreate(Bundle savedInstanceState) {
  17. super.onCreate(savedInstanceState);
  18. setContentView(R.layout.srchgroup);
  19. group = (AutoCompleteTextView) findViewById(R.id.editText);
  20. group.addTextChangedListener(this);
  21. group.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_dropdown_item_1line, spisokGrp));
  22. sG=new searchGroup();
  23. /**button.setOnClickListener(this);*/
  24. }
  25. class searchGroup extends AsyncTask<Void, Void, Void> {
  26. Elements nameGrp;
  27. @Override
  28. protected Void doInBackground(Void... params) {
  29. groupName = group.getText().toString().toUpperCase();
  30. Document doc = null;
  31. try {
  32. doc = Jsoup.connect("http://pkgh.edu.ru/obuchenie/shedule-of-classes.html").get();
  33. } catch (IOException e) {
  34. e.printStackTrace();
  35. }
  36. if (doc != null) {
  37. nameGrp = doc.select("h4.expanded");
  38. nameGroup = nameGrp.html();
  39. }
  40. return null;
  41. }
  42. protected void onPostExecute(Void result) {
  43. intent.putExtra("nameGroup", nameGroup);
  44. }
  45. }
  46. public void click(View view) {
  47. int i;
  48. boolean bool;
  49. sG.execute();
  50. groupName = group.getText().toString().toUpperCase();
  51. intent = new Intent(this, MainActivity.class);
  52. bool = false;
  53.  
  54. do {
  55. for (i = 0; i < spisokGrp.length; i++) {
  56. if (groupName.equals(spisokGrp[i])) {
  57. groupName = spisokGrp[i];
  58. bool = true;
  59. intent.putExtra("group", groupName);
  60. startActivity(intent);
  61. } else {
  62. Toast.makeText(this, "Неверный ввод", Toast.LENGTH_SHORT).show();
  63. bool = true;
  64. }
  65. }
  66. } while (!bool);
  67. }
  68.  
  69. @Override
  70. public void afterTextChanged(Editable arg0) {
  71. // TODO Auto-generated method stub
  72. }
  73.  
  74. @Override
  75. public void beforeTextChanged(CharSequence s, int start, int count, int after) {
  76. // TODO Auto-generated method stub
  77. }
  78.  
  79. @Override
  80. public void onTextChanged(CharSequence s, int start, int before, int count) {
  81. // TODO Auto-generated method stub
  82. }
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement