@Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.create_account, container, false);
    username = (EditText) v.findViewById(R.id.create_account_username);
    username.addTextChangedListener(mTextWatcher);
    password = (EditText) v.findViewById(R.id.create_account_password);
    password.addTextChangedListener(mTextWatcher);
    confirmPassword = (EditText) v.findViewById(R.id.create_account_confirm_password);
    confirmPassword.addTextChangedListener(mTextWatcher);
    errorText = (TextView) v.findViewById(R.id.error_label);
    mSettingsWarningLabel = (TextView) v.findViewById(R.id.settings_warn_label);
    createButton = (Button) v.findViewById(R.id.next);
    createButton.setOnClickListener(this);
    serverEdit = (AutoCompleteTextView) v.findViewById(R.id.xmpp_server);
    ArrayAdapter<CharSequence> completeAdapter =
        ArrayAdapter.createFromResource(
            getActivity(), R.array.xmpp_server_list, R.layout.simple_combobox_item);

    serverEdit.setAdapter(completeAdapter);
    serverEdit.addTextChangedListener(mTextWatcher);
    // show the list on second click on the text view
    serverEdit.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            serverEdit.showDropDown();
          }
        });
    return v;
  }
Example #2
0
  // 初始化
  private void initView() {

    context = this;
    toast = new Toast(context);
    toast.setGravity(Gravity.TOP, 0, 50);
    isNetworkConnected(context);

    editTextUsername = (AutoCompleteTextView) findViewById(R.id.edittext_user_name);
    editTextPassword = (EditText) findViewById(R.id.edittext_user_password);
    loginButton = (Button) findViewById(R.id.button_login);
    editTextUsername.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            initAutoComplete("history", editTextUsername);
          }
        });
    //
    loginButton.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub

            // version_num = preferences.getInt("DataVerSion",0);

            DBName = editTextUsername.getText().toString();
            helper = new DBHelper(context, DBName + "_DB");
            mgr = new DBManager(helper);

            //
            //				SharedPreferences.Editor editor = preferences
            //						.edit();
            //				editor.putString(KEY_NAME, "admin");
            //				editor.putString(KEY_PASSWORD, "1");
            //				editor.commit();
            //				DBName = "admin";
            //
            //				UserInformationDataEntity userinformation = new UserInformationDataEntity();
            //				userinformation.setUsername("admin");
            //				userinformation.setPassword("1");
            //				mgr.addUserInformation(userinformation);

            confirm();
          }
        });
  }
Example #3
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);

    //
  }
  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();
  }
Example #5
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;
  }
  @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;
  }