Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class SearchGroup extends MainActivity implements TextWatcher {
- private AutoCompleteTextView group;
- protected String[] spisokGrp = {"ИВ-14-1", "ИВ-14-2", "ИВ-14-21", "ИВ-201", "ИВ-202",
- "ИВ-301", "ИВ-302", "ИВ-401", "ИВ-402", "ИП-14-22", "ИП-14-3", "ИП-14-4", "ИП-203",
- "ИП-204", "ИП-303", "ИП-304", "ИП-312", "ИП-403", "ИП-404", "ИП-411", "РА-14-5", "РА-14-6",
- "РА-205", "РА-305", "РА-314", "РА-405", "РА-414", "РЭ-14-7С", "СР-14-12", "СР-14-13",
- "СР-208", "СР-308", "СР-408", "ТМ-14-9", "ТМ-206", "ТМ-306", "ТМ-406", "ТО-14-8", "ТО-210", "ТО-310",
- "ТО-410", "УД-14-11", "УД-211", "УД-213К", "УК-14-10", "УК-207", "УК-307", "УК-311", "УК-407",
- "ЭЭ-14-23", "ЭЭ-313", "ЮС-14-14", "ЮС-14-15К", "ЮС-14-16К", "ЮС-209", "ЮС-212К", "ЮС-309"};
- protected Intent intent;
- private String groupName;
- private String nameGroup;
- private searchGroup sG;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.srchgroup);
- group = (AutoCompleteTextView) findViewById(R.id.editText);
- group.addTextChangedListener(this);
- group.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_dropdown_item_1line, spisokGrp));
- sG=new searchGroup();
- /**button.setOnClickListener(this);*/
- }
- class searchGroup extends AsyncTask<Void, Void, Void> {
- Elements nameGrp;
- @Override
- protected Void doInBackground(Void... params) {
- groupName = group.getText().toString().toUpperCase();
- Document doc = null;
- try {
- doc = Jsoup.connect("http://pkgh.edu.ru/obuchenie/shedule-of-classes.html").get();
- } catch (IOException e) {
- e.printStackTrace();
- }
- if (doc != null) {
- nameGrp = doc.select("h4.expanded");
- nameGroup = nameGrp.html();
- }
- return null;
- }
- protected void onPostExecute(Void result) {
- intent.putExtra("nameGroup", nameGroup);
- }
- }
- public void click(View view) {
- int i;
- boolean bool;
- sG.execute();
- groupName = group.getText().toString().toUpperCase();
- intent = new Intent(this, MainActivity.class);
- bool = false;
- do {
- for (i = 0; i < spisokGrp.length; i++) {
- if (groupName.equals(spisokGrp[i])) {
- groupName = spisokGrp[i];
- bool = true;
- intent.putExtra("group", groupName);
- startActivity(intent);
- } else {
- Toast.makeText(this, "Неверный ввод", Toast.LENGTH_SHORT).show();
- bool = true;
- }
- }
- } while (!bool);
- }
- @Override
- public void afterTextChanged(Editable arg0) {
- // TODO Auto-generated method stub
- }
- @Override
- public void beforeTextChanged(CharSequence s, int start, int count, int after) {
- // TODO Auto-generated method stub
- }
- @Override
- public void onTextChanged(CharSequence s, int start, int before, int count) {
- // TODO Auto-generated method stub
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement