Example #1
0
 /**
  * 初始化AutoCompleteTextView,最多显示5项提示,使 AutoCompleteTextView在一开始获得焦点时自动提示
  *
  * @param field 保存在sharedPreference中的字段名
  * @param auto 要操作的AutoCompleteTextView
  */
 private void initAutoComplete(String field, AutoCompleteTextView auto) {
   String[] hisArrays = getFieldHistInputData(field);
   if (hisArrays != null) {
     ArrayAdapter<String> adapter =
         new ArrayAdapter<String>(
             getActivity(), android.R.layout.simple_dropdown_item_1line, hisArrays);
     // 只保留最近的50条的记录
     if (hisArrays.length > 100) {
       String[] newArrays = new String[100];
       System.arraycopy(hisArrays, 0, newArrays, 0, 100);
       adapter =
           new ArrayAdapter<String>(
               getActivity(), android.R.layout.simple_dropdown_item_1line, newArrays);
     }
     auto.setAdapter(adapter);
     // auto.setDropDownHeight(350);
     auto.setThreshold(1);
     auto.setCompletionHint("历史记录");
     auto.setOnFocusChangeListener(
         new OnFocusChangeListener() {
           @Override
           public void onFocusChange(View v, boolean hasFocus) {
             AutoCompleteTextView view = (AutoCompleteTextView) v;
             if (hasFocus) {
               view.showDropDown();
             }
           }
         });
   }
 }
  private void init() {
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.advice);
    preferences = getSharedPreferences("image", MODE_PRIVATE);
    back = (ImageView) this.findViewById(R.id.back_advice);
    userName = (EditText) this.findViewById(R.id.user_name);
    userEmail = (AutoCompleteTextView) this.findViewById(R.id.user_email);
    /*emailPass = (EditText)this.findViewById(R.id.user_email_pass);*/
    adapter = new AutoTextViewAdapter(this);
    userEmail.setAdapter(adapter);
    userEmail.setThreshold(1); // 输入1个字符时就开始检测,默认为2个
    userEmail.addTextChangedListener(this); // 监听autoview的变化
    adviceInfo = (EditText) this.findViewById(R.id.advice_info);
    submit = (Button) this.findViewById(R.id.submit);
    submit.setOnClickListener(new SubmitListener());
    back.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            finish();
            overridePendingTransition(R.anim.push_below_in, R.anim.push_below_out);
          }
        });
    setBackground();
  }
Example #3
0
  private void func() {

    //        System.out.println("2");
    ArrayAdapter<String> adapter =
        new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, tagsData);
    actv1.setThreshold(1);
    actv1.setAdapter(adapter);
    //        System.out.println("3");
  }
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.activity_main);
   autoview = (AutoCompleteTextView) findViewById(R.id.auto_tv);
   adapter = new AutoTextViewAdapter(this);
   autoview.setAdapter(adapter);
   autoview.setThreshold(1); // 输入1个字符时就开始检测,默认为2个
   autoview.addTextChangedListener(this); // 监听autoview的变化
 }
Example #5
0
  public void getNameCity() {
    try {
      //  AutoCompleteTextView et2=(AutoCompleteTextView) findViewById(R.id.autoCompletecCity);
      ArrayAdapter adapter =
          new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, getId());
      city.setAdapter(adapter);

      city.setThreshold(1);
    } catch (Exception e) {
    }
  }
Example #6
0
  private AutoCompleteTextView setTextView(int id, int type) {
    Cursor c = Constants.dbAdapter.getHistoryByType(type);

    AutoCompleteTextView view = (AutoCompleteTextView) findViewById(id);
    if (c != null) {
      view.setThreshold(1);
      SearchCursorAdapter myCursorAdapterTitle = new SearchCursorAdapter(this, c, type);
      view.setAdapter(myCursorAdapterTitle);
    }
    return view;
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.contact);
    initializer();
    String emailaddress = pref.getString("keyemail", "");
    String contact1 = pref.getString("key1", "");
    String contact2 = pref.getString("key2", "");
    String contact3 = pref.getString("key3", "");
    String contact4 = pref.getString("key4", "");
    String contact5 = pref.getString("key5", "");
    mailsave.setText(emailaddress);
    scontact1.setText(contact1);
    scontact2.setText(contact2);
    scontact3.setText(contact3);
    scontact4.setText(contact4);
    scontact5.setText(contact5);
    ContactListAdapter adapter = new ContactListAdapter(this, cursor);
    ContentResolver content = getContentResolver();
    Cursor cursor =
        content.query(
            ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
            adapter.CONTACT_PROJECTION,
            null,
            null,
            null);

    actv1.setAdapter(adapter);
    actv2.setAdapter(adapter);
    actv3.setAdapter(adapter);
    actv4.setAdapter(adapter);
    actv5.setAdapter(adapter);

    actv1.setThreshold(0);
    actv2.setThreshold(0);
    actv3.setThreshold(0);
    actv4.setThreshold(0);
    actv5.setThreshold(0);
    save.setOnClickListener(this);
  }
  public void setAdapter(CardRecipientAdapter adapter) {
    beneficiary_name_et.setDropDownHorizontalOffset(5);
    beneficiary_name_et.setThreshold(1);
    beneficiary_name_et.setAdapter(adapter);
    beneficiary_name_et.setOnItemClickListener(
        new OnItemClickListener() {

          @Override
          public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            CardRecipient item = (CardRecipient) arg0.getAdapter().getItem(arg2);
            beneficiary_name_et.setText(item.getName());
            iban_et.setText(item.getCardNumber());
          }
        });
  }
Example #9
0
 private void bindDataToAutoCompleteTextView() {
   ArrayAdapter<String> adp =
       new ArrayAdapter<String>(
           this, android.R.layout.simple_spinner_dropdown_item, allRegistrationNumbers);
   autoCompleteRegNo.setThreshold(1);
   autoCompleteRegNo.setAdapter(adp);
   autoCompleteRegNo.setOnItemClickListener(
       new AdapterView.OnItemClickListener() {
         @Override
         public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
           try {
             showTruckDetails(allRegistrationNumbers.get(position));
           } catch (ParseException e) {
             e.printStackTrace();
           }
         }
       });
 }
Example #10
0
  private void populateATV() {

    ATV = (AutoCompleteTextView) findViewById(R.id.searchACTV);
    ArrayAdapter<String> ATVadapter =
        new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, buildingList);
    ATV.setThreshold(1);
    ATV.setAdapter(ATVadapter);
    ATV.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> ATV, View view, int position, long id) {

            String buildingName = ATV.getItemAtPosition(position).toString();
            // pop up a dialog
            popDialog(buildingName);
          }
        });
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    root = super.onCreateView(inflater, container, savedInstanceState);
    if (layoutId > 0) {

      data = new ArrayList();
      for (int i = 0; i < AreaFragment.eventList.size(); i++) {
        data.add(AreaFragment.eventList.get(i).getTitle());
      }
      adapter = new ArrayAdapter<>(getActivity(), R.layout.dropdown_event_list, data);
      area_autocomplete = (AutoCompleteTextView) root.findViewById(R.id.area_autocomplete);
      area_autocomplete.requestFocus();
      area_autocomplete.setThreshold(1); // will start working from first character
      area_autocomplete.setAdapter(adapter); // setting the adapter data into the
      area_autocomplete.setTextColor(Color.DKGRAY);
      area_autocomplete.setTextSize(16);
      area_autocomplete.setDropDownVerticalOffset(10);

      spinner_data = new ArrayList<>();
      spinner_data.add("1km");
      spinner_data.add("5km");
      spinner_data.add("10km");
      spinnerAdapter =
          new ArrayAdapter<>(
              getActivity(), android.R.layout.simple_spinner_dropdown_item, spinner_data);
      spinner = (Spinner) root.findViewById(R.id.area_distance_spinner);
      spinner.setPrompt("거리선택");
      spinner.setAdapter(spinnerAdapter);
    }
    /* ibwriteSchedule.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            EventBus.getDefault().post(new ChangeFragEvent(AreaFragment_Write.class, "이벤트작성"));
            ibfindSchedule.setVisibility(View.GONE);
            ibwriteSchedule.setVisibility(View.GONE);
            ibareaSchedule.setVisibility(View.GONE);
        }
    });*/

    return root;
  }
  // populate the autocomplete with users if database exists or files have been downloaded
  private void populateAutoComplete() {
    UserList userList1 = UserDB.getAllUsers();
    String[] usernameStrings = new String[userList1.size()];
    usersIDs = new int[userList1.size()];
    int count = 0;
    for (User temp : userList1) {
      usernameStrings[count] = temp.EmployeeNumber + " - " + temp.Surname;
      UserStringList.add(usernameStrings[count]);
      usersIDs[count] = temp.EmployeeID;
      count++;
    }
    ArrayAdapter adapter =
        new ArrayAdapter(this, android.R.layout.simple_list_item_1, usernameStrings);
    UsernameAutoCompleteTextView.setAdapter(adapter);
    UsernameAutoCompleteTextView.setThreshold(1);

    UsernameAutoCompleteTextView.setEnabled(true);
    PasswordInput.setEnabled(true);
    startRound.setEnabled(true);
  }
Example #13
0
 /**
  * 初始化AutoCompleteTextView,最多显示5项提示,使 AutoCompleteTextView在一开始获得焦点时自动提示
  *
  * @param field 保存在sharedPreference中的字段名
  * @param auto 要操作的AutoCompleteTextView
  */
 private void initAutoComplete(
     String[] arrDatas, String[] arrValues, String field, final AutoCompleteTextView auto) {
   if (arrDatas != null) {
     ArrayAdapter<String> adapter =
         new ArrayAdapter<String>(
             getActivity(), android.R.layout.simple_dropdown_item_1line, arrDatas);
     auto.setAdapter(adapter);
     // auto.setDropDownHeight(350);
     auto.setThreshold(1);
     auto.setOnFocusChangeListener(
         new OnFocusChangeListener() {
           @Override
           public void onFocusChange(View v, boolean hasFocus) {
             AutoCompleteTextView view = (AutoCompleteTextView) v;
             if (hasFocus) {
               view.showDropDown();
             }
           }
         });
   }
 }
Example #14
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.edit_contact);

    getActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.action_bar));
    getActionBar().setDisplayShowHomeEnabled(true);
    getActionBar().setDisplayShowTitleEnabled(false);

    Bundle extras = getIntent().getExtras();

    if (extras.containsKey("navigationSource"))
      _navigationSource = (NavigationSource) extras.get("navigationSource");

    ContactDataAccess contactDataAccess = new ContactDataAccess(this);
    _contact = contactDataAccess.getContact(extras.getLong("contactId"));

    _contacts = new ArrayList<MeetupContact>();

    _name = (AutoCompleteTextView) findViewById(R.id.name);
    _name.setText(_contact.getName());
    _name.addTextChangedListener(this);
    _name.setThreshold(2);
    MeetupContactDataAccess meetupContactDataAccess = new MeetupContactDataAccess(getBaseContext());
    _contacts = meetupContactDataAccess.getAllMeetupContacts(_contact.getGroupId());

    _meetupGroupContactsAdapter =
        new ArrayAdapter<MeetupContact>(this, R.layout.contacts_spinner_style, _contacts);
    _name.setAdapter(_meetupGroupContactsAdapter);

    _website = (EditText) findViewById(R.id.website);
    _website.setText(_contact.getWebsite());
    _email = (EditText) findViewById(R.id.email);
    _email.setText(_contact.getEmail());
    _phone = (EditText) findViewById(R.id.phone);
    _phone.addTextChangedListener(new PhoneNumberFormattingTextWatcher());
    _phone.setText(_contact.getPhone());
    _notes = (EditText) findViewById(R.id.notes);
    _notes.setText(_contact.getNotes());
  }
 @NonNull
 @Override
 public Dialog onCreateDialog(final Bundle savedInstanceState) {
   final Context wrapped = ThemeUtils.getDialogThemedContext(getActivity());
   final AlertDialog.Builder builder = new AlertDialog.Builder(wrapped);
   final View view =
       LayoutInflater.from(wrapped).inflate(R.layout.dialog_auto_complete_textview, null);
   builder.setView(view);
   mEditText = (AutoCompleteTextView) view.findViewById(R.id.edit_text);
   if (savedInstanceState != null) {
     mEditText.setText(savedInstanceState.getCharSequence(EXTRA_TEXT));
   }
   mUserAutoCompleteAdapter = new ComposeAutoCompleteAdapter(wrapped);
   final Bundle args = getArguments();
   mUserAutoCompleteAdapter.setAccountId(args.getLong(EXTRA_ACCOUNT_ID));
   mEditText.setAdapter(mUserAutoCompleteAdapter);
   mEditText.setThreshold(1);
   mEditText.setFilters(new InputFilter[] {new InputFilter.LengthFilter(20)});
   builder.setTitle(R.string.screen_name);
   builder.setPositiveButton(android.R.string.ok, this);
   builder.setNegativeButton(android.R.string.cancel, this);
   return builder.create();
 }
Example #16
0
  @Override
  public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    // TODO Auto-generated method stub
    super.onCreateOptionsMenu(menu, inflater);
    inflater.inflate(R.menu.menu_search, menu);
    mSMenuItem = menu.findItem(R.id.menu_search);
    mSearchView = new SearchView(getSherlockActivity().getSupportActionBar().getThemedContext());
    mSEditText =
        (AutoCompleteTextView)
            mSearchView.findViewById(com.actionbarsherlock.R.id.abs__search_src_text);
    mSMenuItem.setActionView(mSearchView);
    // mSEditText.setInputType(EditorInfo.TYPE_NULL);

    // mSView.setIconifiedByDefault(false);
    // mSearchView.setIconified(false);
    mSearchView.setOnQueryTextListener(this);
    mSearchView.setQueryHint(getSherlockActivity().getString(R.string.search_hint));
    mSEditText.setOnFocusChangeListener(this);
    mSEditText.setOnClickListener(this);
    mSEditText.setThreshold(100); // 防止
    mHander.sendEmptyMessageDelayed(0, 400);

    //
  }
Example #17
0
  private void initDialog() {

    dialogView = mInflater.inflate(R.layout.dialog_searchgame, null);
    LinearLayout ll = (LinearLayout) dialogView.findViewById(R.id.dialog);
    et_game = (AutoCompleteTextView) ll.findViewById(R.id.etname);
    btn_config = (Button) dialogView.findViewById(R.id.btn_config);
    btn_cancel = (Button) dialogView.findViewById(R.id.btn_cancel);
    btn_config.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            String text = et_game.getText().toString().trim();
            if (!StrUtil.isEmpty(text)) {
              tv_game.setText(text);
            }
            dialog.dismiss();
          }
        });
    btn_cancel.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            dialog.dismiss();
          }
        });

    et_game.setText("");
    et_game.addTextChangedListener(
        new TextWatcher() {

          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {
            // TODO Auto-generated method stub
            if (s.toString() != null && s.length() > 0) {
              search(s.toString());
            }
          }

          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            // TODO Auto-generated method stub

          }

          @Override
          public void afterTextChanged(Editable s) {
            // TODO Auto-generated method stub

          }
        });
    adapter_tip =
        new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, autoStrs);
    et_game.setThreshold(1);
    et_game.setAdapter(adapter_tip);

    dialog = new Dialog(this, R.style.bubble_dialog);
    Window window = dialog.getWindow();
    window.setGravity(Gravity.CENTER);
    dialog.setContentView(
        dialogView,
        new LayoutParams(diaplayWidth * 4 / 5, android.view.ViewGroup.LayoutParams.WRAP_CONTENT));
  }
Example #18
0
  private Dialog addItemDialog(final boolean isPrivate) {
    final Dialog dialog = new Dialog(this);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.dialog_add_item);
    dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
    final AutoCompleteTextView name = (AutoCompleteTextView) dialog.findViewById(R.id.name);
    final EditText quantity = (EditText) dialog.findViewById(R.id.ilosc);
    final Button cancel = (Button) dialog.findViewById(R.id.anuluj);
    Button add = (Button) dialog.findViewById(R.id.dodaj);
    final ImageView pin = (ImageView) dialog.findViewById(R.id.imageView);
    final Spinner unit = (Spinner) dialog.findViewById(R.id.spinner);
    final String[] units = getResources().getStringArray(R.array.units);

    unit.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, units));
    final boolean[] pinned = new boolean[] {false};

    if (articles.size() == 0) articles = Utils.getDefaultList(this);

    name.setAdapter(
        new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, articles));
    name.setThreshold(1);

    name.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            quantity.requestFocus();
          }
        });

    Utils.showKeyboard(this, name);

    cancel.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            Toast.makeText(MainActivity.this, "Anulowano", Toast.LENGTH_SHORT).show();
            dialog.dismiss();
          }
        });
    add.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            if (!Utils.isEmpty(MainActivity.this, name)) {
              Toast.makeText(MainActivity.this, "Dodano", Toast.LENGTH_SHORT).show();

              handleItemAdding(
                  name.getText().toString().trim(),
                  Utils.getQuantityValue(quantity) + " " + unit.getSelectedItem(),
                  isPrivate);

              Log.v(" main", Utils.getQuantityValue(quantity) + " " + unit.getSelectedItem());
              name.setText("");
              name.requestFocus();
              quantity.setText("1");
              if (!pinned[0]) dialog.dismiss();
            }
          }
        });
    pin.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            pinned[0] = !pinned[0];
            if (pinned[0]) pin.setImageResource(R.drawable.ic_pin_white_24dp);
            else pin.setImageResource(R.drawable.ic_pin_off_white_24dp);
          }
        });
    return dialog;
  }
Example #19
0
  public void init() {
    db.open();
    usersArray = db.getAllUsers();
    db.close();

    // usersArray.add(new UserInstance(1, "Cauchy", "Choi", "*****@*****.**",
    //		"4084991666", 2, 3));
    // usersArray.add(new UserInstance(2, "Tina", "Chen", "*****@*****.**", "6263761106", 2, 3));

    // Gets the contact list and saves it into contactList
    ContentResolver cr = getContentResolver();
    Cursor cursor = cr.query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null);
    if (cursor.getCount() > 0) {
      while (cursor.moveToNext()) {
        // Get name from contact list
        String name =
            cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
        // currentSearchList.add(name);
        contactList.add(name);
        // Log.d("Contact List", name);

        // Get phone number from contact list
        String contactId = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts._ID));
        String hasPhone =
            cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER));

        if (hasPhone.equalsIgnoreCase("1")) hasPhone = "true";
        else hasPhone = "false";

        if (Boolean.parseBoolean(hasPhone)) {
          Cursor phones =
              getContentResolver()
                  .query(
                      ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
                      null,
                      ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " = " + contactId,
                      null,
                      null);
          while (phones.moveToNext()) {
            String phoneNumber =
                phones
                    .getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER))
                    .replaceAll("\\D", "");
            // Log.d("TEST", phoneNumber);
            for (int i = 0; i < usersArray.size(); i++) {
              // Log.d("TEST1",
              // phones.getString(phones.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME)));
              if (usersArray.get(i).getUserPhone().equals(phoneNumber)) {
                currentSearchList.add(
                    phones.getString(
                        phones.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME)));
                fullSearchList.add(usersArray.get(i));
                currSearchList.add(usersArray.get(i));
              }
            }
          }
          phones.close();
        }
      }
    }

    // Sets up the adapter for AutoCompleteTextView
    textView = (AutoCompleteTextView) findViewById(R.id.autocomplete_names);
    adapter = new ArrayAdapter<String>(this, R.layout.search, currentSearchList);
    textView.setAdapter(adapter);
    textView.setThreshold(1);
    textView.setDropDownHeight(0);

    // Sets the current contact list
    mContactList = (GridView) findViewById(R.id.gridview);
    uAdapter = new SearchAdapter(this, fullSearchList, checkedUsers);
    mContactList.setAdapter(uAdapter);
    mContactList.requestFocus();
    mContactList.setOnItemClickListener(this);

    /*mContactList.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
        	Log.d("itemClick", "item clicked");
        	if (!checkedUsers.contains(parent.getItemAtPosition(position))) {
    			checkedUsers.add((UserInstance)parent.getItemAtPosition(position));
    		}
    		else {
    			checkedUsers.remove((UserInstance)parent.getItemAtPosition(position));
    		}
    		for (int i = 0; i < checkedUsers.size(); i++) {
    			Log.d("checkedUsers", checkedUsers.get(i).getUserFirstName() + " " + checkedUsers.get(i).getUserLastName());
    		}
            Toast.makeText(Search.this, "" + position, Toast.LENGTH_SHORT).show();
        }
    });*/

    adapter.registerDataSetObserver(
        new DataSetObserver() {
          @Override
          public void onChanged() {
            currSearchList.clear();
            currentSearchList.clear();
            for (int i = 0; i < fullSearchList.size(); i++) {
              if (textView
                      .getText()
                      .toString()
                      .toLowerCase()
                      .equals(
                          fullSearchList
                              .get(i)
                              .getUserFirstName()
                              .substring(0, textView.getText().toString().length())
                              .toLowerCase())
                  || textView
                      .getText()
                      .toString()
                      .toLowerCase()
                      .equals(
                          fullSearchList
                              .get(i)
                              .getUserLastName()
                              .substring(0, textView.getText().toString().length())
                              .toLowerCase())) {
                currSearchList.add(fullSearchList.get(i));
                Log.d(
                    "TEST",
                    fullSearchList.get(i).getUserFirstName()
                        + " "
                        + fullSearchList.get(i).getUserLastName());
              }
            }
            for (int i = 0; i < adapter.getCount(); i++) {
              Object item = adapter.getItem(i);
              currentSearchList.add(item.toString());
            }
            uAdapter = new SearchAdapter(Search.this, currSearchList, checkedUsers);
            mContactList.setAdapter(uAdapter);
          }

          @Override
          public void onInvalidated() {
            Log.d("OnInvalidated", "invalid data");
            currentSearchList.clear();
            currSearchList.clear();

            uAdapter = new SearchAdapter(Search.this, currSearchList, checkedUsers);
            mContactList.setAdapter(uAdapter);
          }
        });
  }
  @Override
  public void initializeMethods() {
    fechaCorte.setOnFocusChangeListener(
        new OnFocusChangeListener() {
          @Override
          public void onFocusChange(View v, boolean hasFocus) {
            if (hasFocus) {
              DatePickerDialog datePicker =
                  new DatePickerDialog(
                      getActivity(),
                      R.style.AppTheme,
                      new MyDialogDateListenerFactory(fechaCorte),
                      Calendar.getInstance().get(Calendar.YEAR),
                      Calendar.getInstance().get(Calendar.MONTH),
                      Calendar.getInstance().get(Calendar.DAY_OF_MONTH));
              datePicker.show();
            } else {
              validateField(fechaCorte);
            }
          }
        });
    ordenQuema.setOnFocusChangeListener(new MyOnFocusListenerFactory(null));
    // fechaCorte.setText(Calendar.getInstance().get(Calendar.DAY_OF_MONTH) + "/" +
    // Calendar.getInstance().get(Calendar.MONTH) + "/" +
    // Calendar.getInstance().get(Calendar.YEAR));
    fechaCorte.setText(new SimpleDateFormat("dd/MM/yyyy").format(Calendar.getInstance().getTime()));

    autoCompleteConductorCabezal.setOnFocusChangeListener(
        new OnFocusChangeListener() {
          @Override
          public void onFocusChange(View v, boolean hasFocus) {
            if (listaFormaTiro != null
                && (listaFormaTiro.getSelectedItem().toString().toLowerCase().equals("cabezal")
                    || listaFormaTiro.getSelectedItem().toString().toLowerCase().equals("mixto"))) {
              EditText field = (EditText) v;
              if (!hasFocus) {
                if (field.getText().toString().trim().equals("")
                    || field.getText().toString().trim().length() == 0
                    || field.getText().toString().trim().isEmpty()) {
                  field.setError("El campo " + field.getHint() + " es Requerido.");
                }
                try {
                  if (getContext().getEntityManager() != null) {
                    Entity result =
                        getContext()
                            .getEntityManager()
                            .findOnce(
                                EmpleadoCabezal.class,
                                EmpleadoCabezal.NOMBRE,
                                EmpleadoCabezal.ID_EMPLEADO + " = ?",
                                new String[] {field.getText().toString()});
                    if (result != null && result.getColumnValueList().size() > 0) {
                      txtDescConductorCabezal.setText(
                          result.getColumnValueList().getAsString(EmpleadoCabezal.NOMBRE));
                    } else {
                      txtDescConductorCabezal.setText("");
                      field.setError(
                          "El "
                              + field.getHint()
                              + " no se encuentra registrado en la base de datos.");
                    }
                  }
                } catch (Exception e) {
                  e.printStackTrace();
                  Log.e("Error", "Error al buscar el resultado: " + e.getMessage());
                }
              }
            }
          }
        });

    autoCompleteConductorCabezal.setOnKeyListener(
        new OnKeyListenerRefactory(
            getInformation(
                EmpleadoCabezal.class,
                EmpleadoCabezal.ID_EMPLEADO + " key, " + EmpleadoCabezal.NOMBRE + " value",
                null,
                null),
            txtDescConductorCabezal) {
          @Override
          public void beforeOnkeyValidate() {
            if (listaFormaTiro != null
                && (listaFormaTiro.getSelectedItem().toString().toLowerCase().equals("cabezal")
                    || listaFormaTiro.getSelectedItem().toString().toLowerCase().equals("mixto"))) {
              setValidateField(true);
            } else {
              setValidateField(false);
            }
          }
        });

    autoCompleteConductorCabezal.setAdapter(findCodigosEmpleados(EmpleadoCabezal.class));
    autoCompleteConductorCabezal.setThreshold(2);
    autoCompleteConductorCabezal.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (listaFormaTiro != null
                && (listaFormaTiro.getSelectedItem().toString().toLowerCase().equals("cabezal")
                    || listaFormaTiro.getSelectedItem().toString().toLowerCase().equals("mixto"))) {
              autoCompleteConductorCabezal
                  .getOnFocusChangeListener()
                  .onFocusChange(autoCompleteConductorCabezal, false);
            }
            getContext().hideKeyboard();
          }
        });
    autoCompleteListaCabezales.setAdapter(findCodigosVehiculos(Vehiculos.class, "B"));
    autoCompleteListaCabezales.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            autoCompleteConductorCabezal.requestFocus();
          }
        });
    autoCompleteListaCabezales.setOnFocusChangeListener(
        new View.OnFocusChangeListener() {
          @Override
          public void onFocusChange(View v, boolean hasFocus) {
            if (listaFormaTiro != null
                && (listaFormaTiro.getSelectedItem().toString().toLowerCase().equals("cabezal")
                    || listaFormaTiro.getSelectedItem().toString().toLowerCase().equals("mixto"))) {
              validateVehiculos(v, hasFocus, "B");
              if (hasFocus && ((AutoCompleteTextView) v).getText().length() <= 1)
                addInitValue((TextView) v, "B010" + ((AutoCompleteTextView) v).getText());
            }
          }
        });

    autoCompleteListaCabezales.setOnKeyListener(
        new View.OnKeyListener() {
          @Override
          public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (((AutoCompleteTextView) v).getText().length() <= 1)
              addInitValue((TextView) v, "B010" + ((AutoCompleteTextView) v).getText());
            return false;
          }
        });

    // Llenamos la lista en pantalla con las claves de corte.
    listaClaveCorte.setAdapter(getData(ClaveCorte.class, ClaveCorte.ID));

    // Llenamos la lista en pantalla con las Forma de Tiro.
    listaFormaTiro.setAdapter(getData(FormaTiro.class, FormaTiro.ID));

    listaFormaTiro.setOnItemSelectedListener(
        new AdapterView.OnItemSelectedListener() {
          @Override
          public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            try {
              switch (parent.getItemAtPosition(position).toString().toLowerCase()) {
                case "cabezal":
                case "mixto":
                  autoCompleteListaCabezales.setEnabled(true);
                  autoCompleteListaCabezales.invalidate();
                  autoCompleteConductorCabezal.setEnabled(true);
                  autoCompleteConductorCabezal.invalidate();
                  txtDescConductorCabezal.setEnabled(true);
                  txtDescConductorCabezal.invalidate();
                  getContext().getFormulario4Fragment().getListaCodigoVagones().setText("");
                  getContext().getFormulario4Fragment().getListaCodigoVagones().setEnabled(false);
                  getContext().getFormulario4Fragment().getListaCodigoVagones().invalidate();
                  break;
                case "directo":
                  autoCompleteListaCabezales.setText("");
                  autoCompleteListaCabezales.setEnabled(false);
                  autoCompleteListaCabezales.invalidate();
                  autoCompleteConductorCabezal.setText("");
                  autoCompleteConductorCabezal.setEnabled(false);
                  autoCompleteConductorCabezal.invalidate();
                  txtDescConductorCabezal.setText("");
                  txtDescConductorCabezal.setEnabled(false);
                  txtDescConductorCabezal.invalidate();
                  getContext().getFormulario4Fragment().getListaCodigoVagones().setEnabled(true);
                  getContext().getFormulario4Fragment().getListaCodigoVagones().invalidate();
                  break;
              }
            } catch (Exception ex) {
            }
          }

          @Override
          public void onNothingSelected(AdapterView<?> parent) {
            // Do nothing
          }
        });
  }
Example #21
0
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    // super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    super.onCreate(savedInstanceState);

    // Create the adView
    AdView adView = new AdView(this, AdSize.BANNER, "a14db7ec5158eb6");

    // Lookup your LinearLayout assuming it’s been given
    // the attribute android:id="@+id/mainLayout"
    LinearLayout layout = (LinearLayout) this.findViewById(R.id.adviewLinearLayout);
    // Add the adView to it
    layout.addView(adView);
    // Initiate a generic request to load it with an ad
    adView.loadAd(new AdRequest());

    locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

    if ((locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER))
        || (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER))) {
      registerLocationListeners();
    }

    SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);

    this.dh = new DataHelper(this);

    this.comune = (TextView) this.findViewById(R.id.DettaglioNomeComune);
    this.comuneProvincia = (TextView) this.findViewById(R.id.DettaglioProvinciaComune);
    this.lat_gradi_dec = (TextView) this.findViewById(R.id.latitudine);
    this.long_gradi_dec = (TextView) this.findViewById(R.id.longitudine);

    List<String> comuniList = this.dh.elencoComuni();
    ArrayAdapter<String> adapter =
        new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, comuniList);
    // comuniView = (AutoCompleteTextView) findViewById(R.id.sceltaComune);
    comuniView = (AutoCompleteTextView) findViewById(R.id.sceltaComune);
    comuniView.setThreshold(1);
    comuniView.setAdapter(adapter);
    String comuneDefault = sharedPrefs.getString("preference_comune_default", "");
    comuniView.setText(comuneDefault.trim());

    /* pulsante cerca */

    cercaButton = ((Button) findViewById(R.id.cercaButton));

    cercaButton.setOnClickListener(
        new Button.OnClickListener() {
          public void onClick(View arg0) {

            Comune comuneDett = new Comune();
            comuneDett = dh.getComuneByName(comuniView.getText().toString());
            Acqua gd = (Acqua) getApplication();

            gd.setComuneCorrente(comuneDett);
            try {

              String nomeComune = comuneDett.getNomecomune();

              if (nomeComune.length() > 40) {
                nomeComune = nomeComune.substring(0, 40);
                nomeComune = nomeComune + "...";
              }
              comune.setText(nomeComune);
              comuneProvincia.setText(" (" + comuneDett.getProvincia() + ")");
              lat_gradi_dec.setText(comuneDett.getLatitudine_display().toString());

              long_gradi_dec.setText(comuneDett.getLatitudine_display().toString());
              lat_gradi_dec.setTextColor(Color.CYAN);
              long_gradi_dec.setTextColor(Color.CYAN);
              handleFonti(comuneDett.getLatitudine(), comuneDett.getLongitudine());

            } catch (Exception e) {
              comune.setText("Comune non trovato, riprova!");
            }
          }
        });

    Button mappaButton = ((Button) findViewById(R.id.ElencoFontiMappaButton));
    mappaButton.setOnClickListener(
        new Button.OnClickListener() {
          public void onClick(View arg0) {

            startActivity(new Intent(AcquaActivity.this, MappaActivity.class));
          }
        });

    Button rilevaPosizioneButton = ((Button) findViewById(R.id.rileva_posizione));

    rilevaPosizioneButton.setOnClickListener(
        new Button.OnClickListener() {
          public void onClick(View arg0) {
            comune.setText("");
            comuniView.setText("");
            comuneProvincia.setText("");
            if (locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) {
              // Log.w(TAG, "abilitato networkprovider");

            }
            if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
              // Log.w(TAG, "abilitato gpsworkprovider");
            }

            if ((!locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER))
                && (!locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER))) {
              Builder builder = new AlertDialog.Builder(AcquaActivity.this);

              builder.setTitle(R.string.ElencoFontiNoLocationManagerTitle);
              ;

              builder.setMessage(R.string.ElencoFontiNoLocationManagerMessage);
              builder.setPositiveButton(
                  R.string.ElencoFontiNoLocationManagerOk,
                  new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface arg0, int arg1) {
                      Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
                      startActivityForResult(intent, REQUEST_CODE);
                    }
                  });
              builder.setNegativeButton(R.string.ElencoFontiNoLocationManagerAnnulla, null);

              builder.show();
            }

            // preso da
            // http://stackoverflow.com/questions/1608632/android-locationmanager-getlastknownlocation-returns-null
            Acqua gd = (Acqua) getApplication();

            if (currentLocation == null) {
              Toast.makeText(
                      getApplicationContext(),
                      R.string.ElencoFontiStoAspettandoWifiText,
                      Toast.LENGTH_SHORT)
                  .show();

              return;
            }

            current_latitude = currentLocation.getLatitude();
            current_longitude = currentLocation.getLongitude();
            Comune c = getComuneFromLocation(current_latitude, current_longitude);

            Acqua gdata = (Acqua) getApplication();

            Log.d(TAG, "latitudine display" + c.getLatitudine_display());
            lat_gradi_dec.setText(Double.toString(c.getLatitudine_display()));

            long_gradi_dec.setText(Double.toString(c.getLongitudine_display()));
            lat_gradi_dec.setTextColor(Color.CYAN);
            long_gradi_dec.setTextColor(Color.CYAN);
            comune.setText(c.getNomecomune());

            comuneProvincia.setText(" (" + c.getProvincia() + ") ");

            gd.setComuneCorrente(c);
            handleFonti(current_latitude, current_longitude);
          }
        });
  }
  /** Inflate the layout for this fragment */
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.import_keys_server_fragment, container, false);

    mSearchButton = view.findViewById(R.id.import_server_search);
    mQueryEditText = (AutoCompleteTextView) view.findViewById(R.id.import_server_query);
    mConfigButton = view.findViewById(R.id.import_server_config_button);
    mConfigLayout = view.findViewById(R.id.import_server_config);
    mServerSpinner = (Spinner) view.findViewById(R.id.import_server_spinner);

    // add keyservers to spinner
    mServerAdapter =
        new ArrayAdapter<String>(
            getActivity(),
            android.R.layout.simple_spinner_item,
            Preferences.getPreferences(getActivity()).getKeyServers());
    mServerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mServerSpinner.setAdapter(mServerAdapter);
    if (mServerAdapter.getCount() > 0) {
      mServerSpinner.setSelection(0);
    } else {
      mSearchButton.setEnabled(false);
    }

    List<String> namesAndEmails = ContactHelper.getContactNames(getActivity());
    namesAndEmails.addAll(ContactHelper.getContactMails(getActivity()));
    mQueryEditText.setThreshold(3);
    mQueryEditText.setAdapter(
        new ArrayAdapter<String>(
            getActivity(), android.R.layout.simple_spinner_dropdown_item, namesAndEmails));

    mSearchButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            String query = mQueryEditText.getText().toString();
            String keyServer = (String) mServerSpinner.getSelectedItem();
            search(query, keyServer);

            // close keyboard after pressing search
            InputMethodManager imm =
                (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(mQueryEditText.getWindowToken(), 0);
          }
        });

    mQueryEditText.setOnEditorActionListener(
        new TextView.OnEditorActionListener() {
          @Override
          public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_SEARCH) {
              String query = mQueryEditText.getText().toString();
              String keyServer = (String) mServerSpinner.getSelectedItem();
              search(query, keyServer);

              // Don't return true to let the keyboard close itself after pressing search
              return false;
            }
            return false;
          }
        });

    mConfigButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            if (mImportActivity.getViewPagerHeight() > ImportKeysActivity.VIEW_PAGER_HEIGHT) {
              mImportActivity.resizeViewPager(ImportKeysActivity.VIEW_PAGER_HEIGHT);
            } else {
              mImportActivity.resizeViewPager(ImportKeysActivity.VIEW_PAGER_HEIGHT + 41);
            }
          }
        });

    return view;
  }
  @Nullable
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_query_by_destination, null);
    mListView = (ListView) view.findViewById(android.R.id.list);

    mDbHelper = DbHelper.getInstance(getActivity());
    mIsInterfaceCyrillic = ((App) getActivity().getApplicationContext()).isCurrentLocaleCyrillic();

    mStartDestinationPoints =
        new ArrayList<DestinationPoint>(Arrays.asList(mDbHelper.destinationPoints));
    Comparator<DestinationPoint> comparator =
        mIsInterfaceCyrillic
            ? DestinationPoint.QQ_CYR_COMPARATOR
            : DestinationPoint.QQ_LAT_COMPARATOR;
    Collections.sort(mStartDestinationPoints, comparator);

    mStartPoint = (AutoCompleteTextView) view.findViewById(R.id.spinner_start_point);
    mEndPoint = (AutoCompleteTextView) view.findViewById(R.id.spinner_end_point);

    DestinationPointAdapter startPointAdapter =
        new DestinationPointAdapter(getActivity(), 0, mStartDestinationPoints);

    mStartPoint.setAdapter(startPointAdapter);
    mStartPoint.setThreshold(1);
    mStartPoint.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            if (mStartPoint.hasFocus()) {
              showDropDownIfPossible(mStartPoint);
            }
          }
        });
    mStartPoint.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            String selection = mStartPoint.getText().toString();
            Integer destinationID = mDbHelper.destinationToIdMapping.get(selection);
            if (destinationID == null) {
              mEndPoint.setAdapter(null);
              mListView.setAdapter(null);
            } else {
              mEndDestinationPoints =
                  getDestinationListFromArray(
                      mDbHelper.reachableDestinations[destinationID].reachableDestinationIds);
              DestinationPointAdapter endPointAdapter =
                  new DestinationPointAdapter(getActivity(), 0, mEndDestinationPoints);
              mEndPoint.setAdapter(endPointAdapter);
              setListAdapter();
            }
          }
        });
    mStartPoint.addTextChangedListener(
        new TextWatcher() {
          @Override
          public void beforeTextChanged(
              CharSequence charSequence, int start, int count, int after) {}

          @Override
          public void onTextChanged(CharSequence charSequence, int start, int before, int count) {
            // Log.d("autocomplete", "START: charseq="+charSequence+", start="+start+",
            // before="+before+", count="+count);
            if (before > 0 && charSequence.length() == 0) {
              // reset autocomplete's adapter when text is empty
              setListAdapter();
              showDropDownIfPossible(mStartPoint);
            }
          }

          @Override
          public void afterTextChanged(Editable editable) {}
        });

    mEndPoint.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            setListAdapter();
            hideKeyboard();
          }
        });
    mEndPoint.setThreshold(1);
    mEndPoint.addTextChangedListener(
        new TextWatcher() {
          @Override
          public void beforeTextChanged(
              CharSequence charSequence, int start, int count, int after) {}

          @Override
          public void onTextChanged(CharSequence charSequence, int start, int before, int count) {
            // Log.d("autocomplete", "END: charseq="+charSequence+", start="+start+",
            // before="+before+", count="+count);
            if (before > 0 && charSequence.length() == 0) {
              // reset autocomplete's adapter when text is empty
              setListAdapter();
              showDropDownIfPossible(mEndPoint);
            }
          }

          @Override
          public void afterTextChanged(Editable editable) {}
        });
    mEndPoint.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            if (mEndPoint.hasFocus()) {
              showDropDownIfPossible(mEndPoint);
            }
          }
        });
    mEndPoint.setOnFocusChangeListener(
        new View.OnFocusChangeListener() {
          @Override
          public void onFocusChange(View view, boolean hasFocus) {
            if (hasFocus) {
              showDropDownIfPossible(mEndPoint);
            }
          }
        });

    return view;
  }
Example #24
0
  // set up the search bar
  public void setUpSearchField() {
    final Button clearButton = (Button) findViewById(R.id.clear_search);
    clearButton.setVisibility(View.GONE);

    // create array containing all trail and bird names
    Set<String> keys = map.keySet();
    String[] trails = keys.toArray(new String[keys.size()]);
    String[] birdsAndTrails = new String[trails.length + TrailBirds.allBirds.length];
    for (int i = 0; i < trails.length; i++) {
      birdsAndTrails[i] = trails[i];
    }
    int k = trails.length;
    for (int j = 0; j < TrailBirds.allBirds.length; j++) {
      birdsAndTrails[k] = TrailBirds.allBirds[j];
      k++;
    }

    ArrayAdapter<String> adapter =
        new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, birdsAndTrails);
    final AutoCompleteTextView input = (AutoCompleteTextView) findViewById(R.id.search_text);
    input.setAdapter(adapter);
    input.setThreshold(1);
    input.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);

    // hide button, when field is empty
    input.addTextChangedListener(
        new TextWatcher() {
          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {
            if (input.getText().toString().equals("")) clearButton.setVisibility(View.GONE);
            else clearButton.setVisibility(View.VISIBLE);
          }

          @Override
          public void afterTextChanged(Editable s) {}
        });
    // perform search for selected suggestion
    input.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            performSearch(input.getText().toString());
            if (getCurrentFocus() != null) {
              InputMethodManager inputMethodManager =
                  (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
              inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
            }
          }
        });
    // perform search, hide keyboard when 'search' is clicked
    input.setOnEditorActionListener(
        new TextView.OnEditorActionListener() {
          @Override
          // perform search, and hide keyboard
          public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            performSearch(input.getText().toString());
            if (getCurrentFocus() != null) {
              InputMethodManager inputMethodManager =
                  (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
              inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
            }
            return false;
          }
        });
  }
  public void showSetBetDialog() {
    AlertDialog.Builder builder = new Builder(this);
    LayoutInflater infalInflater =
        (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    FrameLayout layout = (FrameLayout) infalInflater.inflate(R.layout.bet, null);

    final AutoCompleteTextView input =
        (AutoCompleteTextView) layout.findViewById(R.id.tv_bet_input);
    input.setInputType(InputType.TYPE_CLASS_NUMBER);

    LengthFilter filter = new LengthFilter(5);
    input.setFilters(new InputFilter[] {filter});
    input.setSelectAllOnFocus(true);
    input.setTextColor(Color.BLACK);
    input.setText("" + this.number);

    String[] betSuggestion = getResources().getStringArray(R.array.bet_suggestion);
    final ArrayAdapter<String> adapter =
        new ArrayAdapter<String>(this, R.layout.item_list_s, betSuggestion);
    adapter.setNotifyOnChange(true);
    input.setAdapter(adapter);
    input.setThreshold(1);
    input.setOnFocusChangeListener(
        new OnFocusChangeListener() {

          @Override
          public void onFocusChange(View v, boolean hasFocus) {
            if (input.isFocused()) {
              input.showDropDown();
            }
          }
        });

    input.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            if (input.isFocused()) {
              input.showDropDown();
            }
          }
        });

    builder.setView(layout);
    builder.setPositiveButton(
        getResources().getString(R.string.confirm_ok),
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int whichButton) {
            int number = PasswordGeneratorActivity.this.number;
            try {
              number = Integer.parseInt(input.getText().toString());
            } catch (Exception e) {
              // TODO: handle exception
            }
            if (number < 4) number = 4;
            else if (number > 21) number = 21;
            setTextNumberCharacter(number);
          }
        });
    builder.setNegativeButton(getResources().getString(R.string.confirm_cancel), null);
    builder.setIcon(R.drawable.ic_launcher);
    builder.create().show();
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_search);
    this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

    // initialize pop up window
    popupWindow = showMenu();
    img_navigation_icon = (ImageView) findViewById(R.id.img_navigation_icon);
    //   img_navigation_icon.setImageResource(R.drawable.back_icon);
    img_navigation_icon.setVisibility(View.VISIBLE);
    //   img_navigation_icon.setOnClickListener(mMenuButtonClickListener);

    txt_Titlebar = (TextView) findViewById(R.id.txt_Titlebar);
    txt_Titlebar.setText("Home");
    img_Menu = (ImageView) findViewById(R.id.navigation_icon);
    img_Menu.setVisibility(View.VISIBLE);
    img_Menu.setOnClickListener(mMenuButtonClickListener);

    int SDK_INT = android.os.Build.VERSION.SDK_INT;
    if (SDK_INT > 8) {
      StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
      StrictMode.setThreadPolicy(policy);
      // your codes here
    }
    if (Utils.isInternetConnected(SearchLocationActivity.this)) {
      try {
        gpsTracker = new GPSTracker(getApplicationContext());
        gpsTracker.getLocation();
      } catch (Exception e) {
        Utils.sendExceptionReport(e, getApplicationContext());
        e.printStackTrace();
      }
    } else {
      alert.showAlertDialog(
          SearchLocationActivity.this, getResources().getString(R.string.connection_not_available));
    }
    // Indore
    contactList = new ArrayList<String>();
    autoCompView = (AutoCompleteTextView) findViewById(R.id.edtSearchLocation);
    autoCompView.setThreshold(1);
    autoCompView.setAdapter(new GooglePlacesAutocompleteAdapter(this, R.layout.spinner_item));
    //   autoCompView.setAdapter(new
    // PlacesAutoCompleteAdapter(SearchLocationActivity.this,android.R.layout.simple_list_item_1));
    /*autoCompView.addTextChangedListener(new TextWatcher() {

    @Override
    public void beforeTextChanged(CharSequence s, int start, int count, int after) {

    }

    @Override
    public void onTextChanged(CharSequence s, int start, int before, int count) {
        if(placesDownloadTask!=null)
        {
            if(placesDownloadTask.getStatus() == AsyncTask.Status.PENDING ||
                    placesDownloadTask.getStatus() == AsyncTask.Status.RUNNING ||
                    placesDownloadTask.getStatus() == AsyncTask.Status.FINISHED)
            {
                Log.i("--placesDownloadTask--","progress_status : "+placesDownloadTask.getStatus());
                placesDownloadTask.cancel(true);
            }
        }
     */
    /*   //    handleIntent(getIntent());
    // shouldAutoComplete = true;
    // Creating a DownloadTask to download Google Places matching "s"
    placesDownloadTask = new DownloadTask(PLACES);

    // Getting url to the Google Places Autocomplete api
    String url = GooglePlaces.getAutoCompleteUrl(SearchLocationActivity.this, s.toString());
    Log.d("URL : ", url);

    // Start downloading Google Places
    // This causes to execute doInBackground() of DownloadTask class
    placesDownloadTask.execute(url);*/
    /*
        }

        @Override
        public void afterTextChanged(Editable s) {
        // shouldAutoComplete = true;
            // Creating a DownloadTask to download Google Places matching "s"
            placesDownloadTask = new DownloadTask(PLACES);

            // Getting url to the Google Places Autocomplete api
            String url = GooglePlaces.getAutoCompleteUrl(SearchLocationActivity.this, s.toString());
            Log.d("URL : ", url);

            // Start downloading Google Places
            // This causes to execute doInBackground() of DownloadTask class
            placesDownloadTask.execute(url);
        }
    });*/

    popupWindow.setOnDismissListener(
        new PopupWindow.OnDismissListener() {
          @Override
          public void onDismiss() {
            img_Menu.setImageResource(R.drawable.menu_icon);
          }
        });

    autoCompView.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            get_place_from_autocomplete = 1;
            term = resultList.get(position).getDescription();
            reference = resultList.get(position).getReference();

            // Creating a DownloadTask to download Places details of the selected place
            placeDetailsDownloadTask = new DownloadTask(PLACES_DETAILS);
            Log.d(TAG, " Log 1" + term + " " + reference);

            // Getting url to the Google Places details api
            String url = GooglePlaces.getPlaceDetailsUrl(SearchLocationActivity.this, reference);

            Log.d(TAG, "Detail URL :" + url);
            //  Utils.setProgress(SearchLocationActivity.this,true);
            // Start downloading Google Place Details
            // This causes to execute doInBackground() of DownloadTask class
            placeDetailsDownloadTask.execute(url);
            autoCompView.setText(term);
            //  Utils.setProgress(SearchLocationActivity.this,false);
          }
        });
    txtLookUpThisLocation = (TextView) findViewById(R.id.txtLookUpThisLocation);

    img_near_me = (ImageView) findViewById(R.id.img_near_me);
    img_near_me.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            if (Utils.isInternetConnected(SearchLocationActivity.this)) {
              Intent intent = new Intent(getApplicationContext(), DashBoardActivity.class);
              startActivity(intent);
            } else {
              alert.showAlertDialog(
                  SearchLocationActivity.this,
                  getResources().getString(R.string.connection_not_available));
            }
          }
        });

    txtLookUpThisLocation.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            if (autoCompView.getText().length() == 0) {
              alert.showAlertDialog(
                  SearchLocationActivity.this,
                  getResources().getString(R.string.enter_Confirmpassword));
            } else if (Utils.isInternetConnected(SearchLocationActivity.this)) {
              if (get_place_from_autocomplete == 1) {
                flag = 1;
                Intent intent = new Intent(getApplicationContext(), DashBoardActivity.class);
                intent.putExtra("R_LAT", restaurentLatitude);
                intent.putExtra("R_LON", restaurentLongitude);
                Log.d(TAG, " before pass" + restaurentLatitude + " " + restaurentLongitude);
                startActivity(intent);
                autoCompView.setText("");
                get_place_from_autocomplete = 0;
              } else {
                alert.showAlertDialog(
                    SearchLocationActivity.this,
                    "Unable to find this location.Please modified your location.");
                Log.d(TAG, " Show message : User enter the full address!!");
              }
            } else {
              alert.showAlertDialog(
                  SearchLocationActivity.this,
                  getResources().getString(R.string.connection_not_available));
            }
          }
        });
  }
  /** Functionality of book dialog box to show list of 66 books. */
  void bookDialogListDisplayedFunc(final Dialog dialog) {
    // initialize the widgets of this view
    final AutoCompleteTextView searchBox =
        (AutoCompleteTextView) dialog.findViewById(R.id.book_list_search_box);
    final ListView bookList = (ListView) dialog.findViewById(R.id.book_list);

    // set the adapter class to show the list of Books
    bookList.setAdapter(new BookListAdapter(bookNameArr, dialog));

    // set the text that enters to search
    searchBox.setThreshold(1);
    // set the list of the books to show by search
    ArrayAdapter<String> adapter =
        new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, bookNameArr);
    // search functionality to get book name of the list
    // that will works with dynamically text entered by user
    searchBox.addTextChangedListener(
        new TextWatcher() {

          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {
            // TODO Auto-generated method stub
            searchBookNameArr.clear();

            int searchTextlength = searchBox.getText().length();

            if (searchTextlength > 0) {
              for (int i = 0; i < bookNameArr.length; i++) {
                if (searchTextlength <= bookNameArr[i].length()) {
                  if (searchBox
                      .getText()
                      .toString()
                      .equalsIgnoreCase((String) bookNameArr[i].subSequence(0, searchTextlength))) {
                    searchBookNameArr.add(bookNameArr[i]);
                    Log.e("", " searched friend data " + searchBookNameArr);
                  }
                }
              }
            }
            // if search text is entered then
            // show the search items list
            if (searchBookNameArr.size() > 0) {
              String[] searchBookNameStringArr = searchBookNameArr.toArray(new String[0]);
              Log.i("", "searched book string array" + searchBookNameStringArr.length);
              bookList.setAdapter(new BookListAdapter(searchBookNameStringArr, dialog));
            } else // show the whole list of books
            {
              bookList.setAdapter(new BookListAdapter(bookNameArr, dialog));
            }
          }

          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            // TODO Auto-generated method stub

          }

          @Override
          public void afterTextChanged(Editable s) {
            // TODO Auto-generated method stub

          }
        });
  }
  /** Functionality of verses dialog box to show the list of verses for the selected chapter. */
  void verseDialogDisplayedFunc(final Dialog dialog) {
    // initialize the widgets of this view
    final AutoCompleteTextView searchBox =
        (AutoCompleteTextView) dialog.findViewById(R.id.verse_list_search_box);
    final GridView verseList = (GridView) dialog.findViewById(R.id.verse_list);
    TextView bookNameText = (TextView) dialog.findViewById(R.id.verse_list_bookname_txt);
    TextView chapterNameText =
        (TextView) dialog.findViewById(R.id.verse_list_chaptername_heading_txt);

    // set the heading text with chapter name and book name
    bookNameText.setText(selectedBookNameForHeading);
    chapterNameText.setText(selectedChapterName);

    // convert array list into string array of the verse list
    final String[] verseListArr = EBibleConstants.verseList.toArray(new String[0]);
    // set the adapter class to show the list of verses
    verseList.setAdapter(new ChapterListAdapter(verseListArr, dialog));

    // set the text that enters to search
    searchBox.setThreshold(1);
    // set the list of the verse to show by search
    ArrayAdapter<String> adapter =
        new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, verseListArr);
    // search functionality to get verse name of the list
    // that will works with dynamically text entered by user
    searchBox.addTextChangedListener(
        new TextWatcher() {

          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {
            // TODO Auto-generated method stub
            searchVerseNameArr.clear();

            int searchTextlength = searchBox.getText().length();

            if (searchTextlength > 0) {
              for (int i = 0; i < verseListArr.length; i++) {
                if (searchTextlength <= verseListArr[i].length()) {
                  if (searchBox
                      .getText()
                      .toString()
                      .equalsIgnoreCase(
                          (String) verseListArr[i].subSequence(0, searchTextlength))) {
                    searchVerseNameArr.add(verseListArr[i]);
                    Log.e("", " searched friend data " + searchVerseNameArr);
                  }
                }
              }
            }
            // if search text is entered then
            // show the search items list
            if (searchVerseNameArr.size() > 0) {
              String[] searchVerseNameStringArr = searchVerseNameArr.toArray(new String[0]);
              Log.i("", "searched verse string array" + searchVerseNameStringArr.length);
              verseList.setAdapter(new ChapterListAdapter(searchVerseNameStringArr, dialog));
            } else // show the whole list of verse
            {
              verseList.setAdapter(new ChapterListAdapter(verseListArr, dialog));
            }
          }

          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            // TODO Auto-generated method stub

          }

          @Override
          public void afterTextChanged(Editable s) {
            // TODO Auto-generated method stub

          }
        });
  }
  /** Functionality of chapter dialog box to show the list of chapters for the selected book. */
  void chapterDialogDisplayedFunc(final Dialog dialog) {
    // initialize the widgets of this view
    final AutoCompleteTextView searchBoxChapters =
        (AutoCompleteTextView) dialog.findViewById(R.id.chapter_list_search_box);
    final GridView chapterList = (GridView) dialog.findViewById(R.id.chapter_list);
    TextView bookName = (TextView) dialog.findViewById(R.id.chapter_list_bookname_txt);

    int numberOfChapters;
    // find the selected book
    if (selectedBookNameForHeading.equalsIgnoreCase("Genesis")) {
      numberOfChapters = 50;
      bookName.setText("Genesis");
      selectedBookName = "genesis";
    } else if (selectedBookNameForHeading.equalsIgnoreCase("John")) {
      numberOfChapters = 21;
      bookName.setText("John");
      selectedBookName = "john";
    } else if (selectedBookNameForHeading.equalsIgnoreCase("John1")) {
      numberOfChapters = 5;
      bookName.setText("John1");
      selectedBookName = "1john";
    } else if (selectedBookNameForHeading.equalsIgnoreCase("John2")) {
      numberOfChapters = 1;
      bookName.setText("John2");
      selectedBookName = "2john";
    } else {
      numberOfChapters = 1;
      bookName.setText("John3");
      selectedBookName = "3john";
    }
    // store the chapters counting into the array
    final String[] numberOfChaptersList = new String[numberOfChapters];
    for (int count = 0; count < numberOfChapters; count++) {
      int chapterNumber = count + 1;
      numberOfChaptersList[count] = "" + chapterNumber;

      Log.i("", "chapter list = " + numberOfChaptersList[count]);
    }

    // set the adapter class to show the list of Books
    chapterList.setAdapter(new ChapterListAdapter(numberOfChaptersList, dialog));

    // set the text that enters to search
    searchBoxChapters.setThreshold(1);
    // set the list of the books to show by search
    ArrayAdapter<String> adapter =
        new ArrayAdapter<String>(
            this, android.R.layout.simple_dropdown_item_1line, numberOfChaptersList);
    // search functionality to get book name of the list
    // that will works with dynamically text entered by user
    searchBoxChapters.addTextChangedListener(
        new TextWatcher() {

          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {
            // TODO Auto-generated method stub
            searchChapterNameArr.clear();

            int searchTextlength = searchBoxChapters.getText().length();
            Log.i("", "chapter list size = " + numberOfChaptersList.length);
            if (searchTextlength > 0) {
              for (int j = 0; j < numberOfChaptersList.length; j++) {
                Log.i("", "i = " + j);
                if (searchTextlength <= numberOfChaptersList[j].length()) {
                  if (searchBoxChapters
                      .getText()
                      .toString()
                      .equalsIgnoreCase(
                          (String) numberOfChaptersList[j].subSequence(0, searchTextlength))) {
                    searchChapterNameArr.add(numberOfChaptersList[j]);
                    Log.e("", " searched chapter= " + searchChapterNameArr);
                  }
                }
              }
            }
            // if search text is entered then
            // show the search items list
            if (searchChapterNameArr.size() > 0) {
              String[] searchBookNameStringArr = searchChapterNameArr.toArray(new String[0]);
              Log.i("", "searched chapter string array" + searchBookNameStringArr.length);
              chapterList.setAdapter(new ChapterListAdapter(searchBookNameStringArr, dialog));
            } else // show the whole list of books
            {
              chapterList.setAdapter(new ChapterListAdapter(numberOfChaptersList, dialog));
            }
          }

          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            // TODO Auto-generated method stub

          }

          @Override
          public void afterTextChanged(Editable s) {
            // TODO Auto-generated method stub

          }
        });
  }
Example #30
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the help for this fragment
    //        if(view == null)
    Log.d("init", "search fragment onCreateView");
    if (true) view = inflater.inflate(R.layout.fragment_search, container, false);
    if (true) {
      textView = (AutoCompleteTextView) view.findViewById(R.id.autocomplete_search);
      textView.setThreshold(1);

      if (mType == t_type.GROUP) {
        textView.setOnClickListener(this);
        textView.setOnItemClickListener(this);

        textView.setHint(R.string.group_search_placeholder);

        adapter =
            new ArrayAdapter<String>(
                getActivity(), R.layout.text_layout, StaticStorage.m_listGroupsName);
        textView.setAdapter(adapter);
        adapter.setNotifyOnChange(true);

        ListView list = (ListView) view.findViewById(R.id.recentList);
        final ArrayAdapter recent_adapter =
            new ArrayAdapter(
                inflater.getContext(),
                R.layout.detailed_item_list_item,
                new ArrayList(StaticStorage.m_recentGroups.values())) {
              @Override
              public View getView(int position, View convertView, ViewGroup parent) {
                View holder;
                Group group = (Group) getItem(position);
                if (convertView == null) {
                  // You should fetch the LayoutInflater once in your constructor
                  holder =
                      LayoutInflater.from(parent.getContext())
                          .inflate(R.layout.detailed_item_list_item, parent, false);
                } else {
                  holder = convertView;
                }

                TextView v = (TextView) holder.findViewById(R.id.detailed_item_list_item_text1);
                v.setText(group.m_info.m_name);
                v = (TextView) holder.findViewById(R.id.detailed_item_list_item_text2);
                v.setText(group.m_info.m_faculty.m_abbr);
                v = (TextView) holder.findViewById(R.id.detailed_item_list_item_text3);
                v.setText(group.m_info.m_spec);
                return holder;
              }
            };
        list.setAdapter(recent_adapter);
        // ListView Item Click Listener
        list.setOnItemClickListener(
            new AdapterView.OnItemClickListener() {

              @Override
              public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Group group = (Group) recent_adapter.getItem(position);

                Log.d("init", group.toString());
                if (((NavigationView) getActivity().findViewById(R.id.nav_view))
                    .getMenu()
                    .getItem(0)
                    .isChecked()) {
                  ((MainNavigationDrawer) getActivity()).createTree(group);
                  //                            new CreateFiles(getActivity(), group).execute();
                } else {
                  ((MainNavigationDrawer) getActivity())
                      .switchContent(TimeTableFragment.newInstance(group));
                  StaticStorage.m_recentGroups.put(group.m_info.m_id, group);
                }
              }
            });

        Button btn = (Button) view.findViewById(R.id.primat_list);
        btn.setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                if (!((MainNavigationDrawer) getActivity()).isOnline()) {
                  ((MainNavigationDrawer) getActivity()).askForInternet();
                  return;
                }
                if (StaticStorage.m_primatGroupsName.isEmpty()) {
                  new AlertDialog.Builder(getActivity())
                      .setTitle(getResources().getString(R.string.error))
                      .setMessage(getResources().getString(R.string.not_loaded))
                      .setPositiveButton(android.R.string.ok, null) // dismisses by default
                      .create()
                      .show();
                  return;
                }

                AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
                builder.setTitle(getResources().getString(R.string.str_depth));
                builder.setIcon(R.drawable.logo_amd_mod);
                //                        ListView modeList = new ListView(getActivity());
                final ArrayAdapter<String> modeAdapter =
                    new ArrayAdapter<String>(
                        getActivity(),
                        android.R.layout.simple_list_item_1,
                        android.R.id.text1,
                        StaticStorage.m_primatGroupsName);
                builder.setAdapter(
                    modeAdapter,
                    new DialogInterface.OnClickListener() {
                      @Override
                      public void onClick(DialogInterface dialog, int which) {
                        GroupInfo tmpGroup = StaticStorage.m_primatGroups.get(which);
                        new ServerGetTable(tmpGroup, getActivity()).execute();
                      }
                    });
                final Dialog dialog = builder.create();
                dialog.show();
              }
            });
        if (StaticStorage.m_listGroupsName.isEmpty()) {
          if (!((MainNavigationDrawer) getActivity()).isOnline())
            ((MainNavigationDrawer) getActivity()).askForInternet();
          else startDownloadListFaculties((ArrayAdapter<String>) textView.getAdapter());
        }

      } else {
        if (!((MainNavigationDrawer) getActivity()).isOnline())
          ((MainNavigationDrawer) getActivity()).askForInternet();
        textView.setOnItemClickListener(this);
        textView.setHint(R.string.lecturer_search_placeholder);
        adapter =
            new ArrayAdapter<String>(
                getActivity(), R.layout.text_layout, StaticStorage.m_listLecturerName);
        adapter.setNotifyOnChange(true);
        textView.setAdapter(adapter);
        textView.addTextChangedListener(this);

        ListView list = (ListView) view.findViewById(R.id.recentList);
        final ArrayAdapter recent_adapter =
            new ArrayAdapter(
                inflater.getContext(),
                R.layout.detailed_item_list_item,
                new ArrayList(StaticStorage.m_recentLecturers.values())) {
              @Override
              public View getView(int position, View convertView, ViewGroup parent) {
                View holder;
                Lecturer group = (Lecturer) getItem(position);
                if (convertView == null) {
                  // You should fetch the LayoutInflater once in your constructor
                  holder =
                      LayoutInflater.from(parent.getContext())
                          .inflate(R.layout.detailed_item_list_item, parent, false);
                } else {
                  holder = convertView;
                }

                TextView v = (TextView) holder.findViewById(R.id.detailed_item_list_item_text1);
                v.setText(group.m_info.m_fio);
                v = (TextView) holder.findViewById(R.id.detailed_item_list_item_text2);
                v.setText("");
                v = (TextView) holder.findViewById(R.id.detailed_item_list_item_text3);
                v.setText(group.m_info.m_chair);
                return holder;
              }
            };
        list.setAdapter(recent_adapter);
        // ListView Item Click Listener
        list.setOnItemClickListener(
            new AdapterView.OnItemClickListener() {

              @Override
              public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Lecturer lect = (Lecturer) recent_adapter.getItem(position);

                Log.d("init", lect.toString());
                if (((NavigationView) getActivity().findViewById(R.id.nav_view))
                    .getMenu()
                    .getItem(0)
                    .isChecked()) {
                  ((MainNavigationDrawer) getActivity()).createTree(lect);
                  //                            new CreateFiles(getActivity(), lect).execute();
                } else {
                  ((MainNavigationDrawer) getActivity())
                      .switchContent(TimeTableFragment.newInstance(lect));
                  StaticStorage.m_recentLecturers.put(lect.m_info.m_id, lect);
                }
              }
            });
        /*
        Button btn = (Button) view.findViewById(R.id.primat_list);
        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
                builder.setTitle(getResources().getString(R.string.str_depth));

                ListView modeList = new ListView(getActivity());
                ArrayAdapter<String> modeAdapter = new ArrayAdapter<String>(getActivity(),
                        android.R.help.simple_list_item_1, android.R.id.text1,
                        StaticStorage.m_primatLecturerName);
                modeList.setAdapter(modeAdapter);

                builder.setView(modeList);
                final Dialog dialog = builder.create();

                dialog.show();
            }
        });
        */
        Button btn = (Button) view.findViewById(R.id.primat_list);
        btn.setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                if (!((MainNavigationDrawer) getActivity()).isOnline())
                  ((MainNavigationDrawer) getActivity()).askForInternet();
                else new ServerGetPrimatLecturers(getActivity(), true).execute();
              }
            });
      }
    }

    //
    // ((CollapsingToolbarLayout)getActivity().findViewById(R.id.collapsing_toolbar_layout)).setTitle(getResources().getString(R.string.search));
    //
    // ((Toolbar)getActivity().findViewById(R.id.toolbar)).setTitle(getResources().getString(R.string.search));

    if (((NavigationView) getActivity().findViewById(R.id.nav_view))
        .getMenu()
        .getItem(0)
        .isChecked()) {
      if (mType == t_type.GROUP) {
        ((AppCompatActivity) getActivity())
            .getSupportActionBar()
            .setTitle(getResources().getString(R.string.choose_group));
      } else {
        ((AppCompatActivity) getActivity())
            .getSupportActionBar()
            .setTitle(getResources().getString(R.string.choose_lectname));
      }
    } else {
      ((AppCompatActivity) getActivity())
          .getSupportActionBar()
          .setTitle(getResources().getString(R.string.search));
    }

    return view;
  }