Example #1
0
  /** Initialize the views. */
  private void initializeUI() {
    setCustomContentView(R.layout.activity_add_city, R.string.screen_name_city_select);
    btnBack = (Button) findViewById(R.id.nav_back_button);
    btnLoaction = (Button) findViewById(R.id.nav_location_button);
    btnBack.setVisibility(View.VISIBLE);
    btnLoaction.setVisibility(View.VISIBLE);

    hotCityListGridView = (GridView) findViewById(R.id.hot_city_list_grid_view);
    searchCityEditText = (AutoCompleteTextView) findViewById(R.id.search_name_edit_text);

    defaultHotCityList = getResources().getStringArray(R.array.hot_city_list);
    hotCityListGridView.setAdapter(new CityAdapter());
    hotCityListGridView.setOnItemClickListener(onItemClickListener);
    searchCityEditText.addTextChangedListener(searchWatcher);

    adapter =
        new ArrayAdapter<String>(
            AddCitiyActivity.this, // 定义匹配源的adapter
            android.R.layout.simple_dropdown_item_1line,
            seachResultCityArrayList);
    searchCityEditText.setAdapter(adapter);
    searchCityEditText.setOnItemSelectedListener(onItemSelectedListener);

    btnBack.setOnClickListener(onClickListener);
  }
Example #2
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    setHasOptionsMenu(true);

    View v = inflater.inflate(R.layout.fragment_vendorgrid, null);

    mGvVendors = (GridView) v.findViewById(R.id.gv_vendorlist);
    mActvSearch = (AutoCompleteTextView) v.findViewById(R.id.actv_search);

    mSearchAdapter = new SearchGridAdapter();
    mVendorAdapter = new VendorGridAdapter();
    mGvVendors.setAdapter(mVendorAdapter);
    mGvVendors.setOnItemClickListener(mOnVendorClickListener);

    mActvSearch.addTextChangedListener(mOnSearchTextWatcher);
    if (!mSearchWasVisible) {
      mActvSearch.setVisibility(View.GONE);
    }
    getActivity().setTitle(R.string.app_name);

    if (getActivity() instanceof ActivityMain) {
      ((ActivityMain) getActivity()).setOnBackKeyListener(this);
    }

    return v;
  }
  private void setUpOk(View view) {
    airlinename = (AutoCompleteTextView) view.findViewById(R.id.airlinename);
    airlineid = (EditText) view.findViewById(R.id.airlineid);
    airlinename.addTextChangedListener(
        new TextWatcher() {
          public void afterTextChanged(Editable arg0) {
            System.out.println(arg0.toString());
            if (airlines.get(arg0.toString()) != null) {
              checkFinished();
            }
          }

          public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {}

          public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {}
        });
    airlineid.addTextChangedListener(
        new TextWatcher() {
          public void onTextChanged(CharSequence s, int start, int before, int count) {}

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

          public void afterTextChanged(Editable s) {
            if (s.toString().length() >= 1) {
              checkFinished();
            }
          }
        });
  }
  @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 #5
0
  private void initTitleButton() {
    search_title_search = (ImageButton) findViewById(R.id.search_title_search_id);
    search_title_textview = (AutoCompleteTextView) findViewById(R.id.search_title_textview_id);
    search_title_return = (ImageButton) findViewById(R.id.search_title_return_id);

    // 返回按钮响应

    // 文本框响应
    search_title_textview.addTextChangedListener(this);
    search_title_textview.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (position >= 0) {
              try {
                LatLng latlng =
                    new LatLng(
                        latLonPointList.get(position).getLatitude(),
                        latLonPointList.get(position).getLongitude());
                getAddress(latlng);
              } catch (NullPointerException e) {
                e.printStackTrace(System.out);
              }
            }
          }
        });

    // 搜索按钮响应
  }
  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 #7
0
 private void setSendToAddressText(String addressStr) {
   // Remove listener before changing input, to avoid infinite recursion
   sendToAddressView.removeTextChangedListener(receivingAddressListener);
   sendToAddressView.setOnFocusChangeListener(null);
   sendToAddressView.setText(addressStr);
   sendToAddressView.addTextChangedListener(receivingAddressListener);
   sendToAddressView.setOnFocusChangeListener(receivingAddressListener);
 }
  @Override
  public void onCreate(Bundle bundle) {
    super.onCreate(bundle);

    BootstrapApplication.component().inject(this);

    accountManager = AccountManager.get(this);

    final Intent intent = getIntent();
    email = intent.getStringExtra(PARAM_USERNAME);
    authTokenType = intent.getStringExtra(PARAM_AUTHTOKEN_TYPE);
    confirmCredentials = intent.getBooleanExtra(PARAM_CONFIRM_CREDENTIALS, false);

    requestNewAccount = email == null;

    setContentView(layout.login_activity);

    ButterKnife.bind(this);

    emailText.setAdapter(
        new ArrayAdapter<String>(this, simple_dropdown_item_1line, userEmailAccounts()));

    passwordText.setOnKeyListener(
        new OnKeyListener() {

          public boolean onKey(final View v, final int keyCode, final KeyEvent event) {
            if (event != null
                && ACTION_DOWN == event.getAction()
                && keyCode == KEYCODE_ENTER
                && signInButton.isEnabled()) {
              handleLogin(signInButton);
              return true;
            }
            return false;
          }
        });

    passwordText.setOnEditorActionListener(
        new OnEditorActionListener() {

          public boolean onEditorAction(
              final TextView v, final int actionId, final KeyEvent event) {
            if (actionId == IME_ACTION_DONE && signInButton.isEnabled()) {
              handleLogin(signInButton);
              return true;
            }
            return false;
          }
        });

    emailText.addTextChangedListener(watcher);
    passwordText.addTextChangedListener(watcher);

    final TextView signUpText = (TextView) findViewById(id.tv_signup);
    signUpText.setMovementMethod(LinkMovementMethod.getInstance());
    signUpText.setText(Html.fromHtml(getString(string.signup_link)));
  }
 @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的变化
 }
 /** 设置页面监听 */
 private void setUpMap() {
   Button searButton = (Button) findViewById(R.id.searchButton);
   searButton.setOnClickListener(this);
   Button nextButton = (Button) findViewById(R.id.nextButton);
   nextButton.setOnClickListener(this);
   searchText = (AutoCompleteTextView) findViewById(R.id.keyWord);
   searchText.addTextChangedListener(this); // 添加文本输入框监听事件
   editCity = (EditText) findViewById(R.id.city);
   aMap.setOnMarkerClickListener(this); // 添加点击marker监听事件
   aMap.setInfoWindowAdapter(this); // 添加显示infowindow监听事件
 }
Example #11
0
  @Override
  public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.main);
    selection = (TextView) findViewById(R.id.selection);
    edit = (AutoCompleteTextView) findViewById(R.id.edit);
    edit.addTextChangedListener(this);

    edit.setAdapter(
        new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, items));
  }
  protected void addListeners() {
    TextChangedListener textChangedListener = new TextChangedListener();
    EditorActionListener editorActionListener = new EditorActionListener();
    FocusChangeListener focusChangeListener = new FocusChangeListener();

    emailEdit.addTextChangedListener(textChangedListener);
    emailEdit.setOnEditorActionListener(editorActionListener);
    emailEdit.setOnFocusChangeListener(focusChangeListener);
    passwordEdit.addTextChangedListener(textChangedListener);
    passwordEdit.setOnEditorActionListener(editorActionListener);
    passwordEdit.setOnFocusChangeListener(focusChangeListener);
  }
 private void addWatchers() {
   if (!watchers) {
     watchers = true;
     nameWatcher = new TextErrorWatcher(getActivity(), nameText, false);
     brandWatcher = new TextErrorWatcher(getActivity(), brandBox, false);
     categoryWatcher = new TextErrorWatcher(getActivity(), categoryBox, false);
     priceWatcher = new TextErrorWatcher(getActivity(), priceText, true);
     sizeWatcher = new TextErrorWatcher(getActivity(), sizeText, true);
     nameText.addTextChangedListener(nameWatcher);
     brandBox.addTextChangedListener(brandWatcher);
     categoryBox.addTextChangedListener(categoryWatcher);
     priceText.addTextChangedListener(priceWatcher);
     sizeText.addTextChangedListener(sizeWatcher);
   } else {
     nameWatcher.afterTextChanged(nameText.getEditableText());
     brandWatcher.afterTextChanged(brandBox.getEditableText());
     categoryWatcher.afterTextChanged(categoryBox.getEditableText());
     priceWatcher.afterTextChanged(priceText.getEditableText());
     sizeWatcher.afterTextChanged(sizeText.getEditableText());
   }
 }
Example #14
0
  public void login(View view) {
    editText = (EditText) findViewById(R.id.editText);
    textView = (TextView) findViewById(R.id.textView);
    textView2 = (TextView) findViewById(R.id.textView2);
    textView3 = (TextView) findViewById(R.id.textView3);
    user = editText.getText().toString();
    textView.setText(user);
    functions.count_roses(
        Home.this,
        user,
        new Functions.VolleyCallback() {
          @Override
          public void onSuccess(int[] result) {
            textView2.setText("" + result[0]);
            textView3.setText("" + result[1]);
          }
        });

    functions.get_users(
        Home.this,
        new Functions.VolleyCallback1() {
          @Override
          public void onSuccess(String[] result) {
            arrayAdapter =
                new ArrayAdapter<String>(
                    getApplicationContext(), R.layout.support_simple_spinner_dropdown_item, result);
            autoCompleteTextView.setAdapter(arrayAdapter);
          }
        });
    autoCompleteTextView.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            receiver = arrayAdapter.getItem(position).toString();
          }
        });
    autoCompleteTextView.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) {
            receiver = null;
          }

          @Override
          public void afterTextChanged(Editable s) {}
        });
  }
Example #15
0
  private void init(final Context context) {
    LayoutInflater mInflater =
        (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    mInflater.inflate(R.layout.jdb_expand_editext_layout, this);
    mProgressBar = (ProgressBar) findViewById(R.id.progress);
    mRightView = (ImageView) findViewById(R.id.icon_right);
    checkStatusOfIcon(mRightView, rightIconVisiable);
    mLeftView = (ImageView) findViewById(R.id.icon_left);
    checkStatusOfIcon(mLeftView, leftIconVisiable);
    mRightView.setOnClickListener(this);
    mTextView = (AutoCompleteTextView) findViewById(R.id.edittext);
    mTextView.setHint(this.hint);
    mTextView.setFocusableInTouchMode(enabled);
    if (this.password)
      mTextView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
    mTextView.addTextChangedListener(
        new TextWatcher() {
          @Override
          public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {}

          @Override
          public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
            if (withProgress) {
              if (mCanLoad) {
                if (charSequence.length() >= threshold) {
                  if (onEditCompleted != null)
                    onEditCompleted.startSearch(ExpandEditText.this, charSequence.toString());
                } else {
                  if (onEditCompleted != null) onEditCompleted.endSearch(ExpandEditText.this);
                }
              } else {
                mCanLoad = !mCanLoad;
              }
            } else {
              // 有内容显示
              if (charSequence.length() >= 1) mRightView.setVisibility(View.VISIBLE);
              else mRightView.setVisibility(View.GONE);
            }
          }

          @Override
          public void afterTextChanged(Editable editable) {}
        });
  }
Example #16
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_poisearch);
    lif = LayoutInflater.from(this);
    // 初始化搜索模块,注册搜索事件监听
    mPoiSearch = PoiSearch.newInstance();
    mPoiSearch.setOnGetPoiSearchResultListener(this);
    mSuggestionSearch = SuggestionSearch.newInstance();
    mSuggestionSearch.setOnGetSuggestionResultListener(this);
    keyWorldsView = (AutoCompleteTextView) findViewById(R.id.searchkey);
    sugAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line);
    keyWorldsView.setAdapter(sugAdapter);
    mBaiduMap =
        ((SupportMapFragment) (getSupportFragmentManager().findFragmentById(R.id.map)))
            .getBaiduMap();
    poi_lv = (ListView) findViewById(R.id.poi_lv);
    poiResultAdapter = new PoiResultAdapter();
    poiResultAdapter2 = new PoiResultAdapter2();
    poi_lv.setAdapter(poiResultAdapter);
    poi_lv.setOnItemClickListener(this);

    /** 当输入关键字变化时,动态更新建议列表 */
    keyWorldsView.addTextChangedListener(
        new TextWatcher() {

          @Override
          public void afterTextChanged(Editable arg0) {}

          @Override
          public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {}

          @Override
          public void onTextChanged(CharSequence cs, int arg1, int arg2, int arg3) {
            if (cs.length() <= 0) {
              return;
            }
            /** 使用建议搜索服务获取建议列表,结果在onSuggestionResult()中更新 */
            mSuggestionSearch.requestSuggestion(
                (new SuggestionSearchOption()).keyword(cs.toString()).city(city));
          }
        });
  }
Example #17
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());
  }
Example #18
0
  public EditSipUri(Context context, AttributeSet attrs) {
    super(context, attrs);
    setGravity(Gravity.CENTER_HORIZONTAL);
    setOrientation(VERTICAL);
    LayoutInflater inflater = LayoutInflater.from(context);
    inflater.inflate(R.layout.edit_sip_uri, this, true);

    dialUser = (AutoCompleteTextView) findViewById(R.id.dialtxt_user);
    accountChooserButtonText = (AccountChooserButton) findViewById(R.id.accountChooserButtonText);
    domainTextHelper = (TextView) findViewById(R.id.dialtxt_domain_helper);
    completeList = (ListView) findViewById(R.id.autoCompleteList);

    autoCompleteAdapter = new ContactsAutocompleteAdapter(context);

    // Map events
    accountChooserButtonText.setOnAccountChangeListener(
        new OnAccountChangeListener() {
          @Override
          public void onChooseAccount(SipProfile account) {
            updateDialTextHelper();
            long accId = SipProfile.INVALID_ID;
            if (account != null) {
              accId = account.id;
            }
            autoCompleteAdapter.setSelectedAccount(accId);
          }
        });
    dialUser.addTextChangedListener(this);

    if (isInEditMode()) {
      // Don't bind cursor in this case
      return;
    }
    Cursor c = ContactsWrapper.getInstance().getContactsPhones(context);
    contactsAdapter = new ContactAdapter(context, c);
    completeList.setAdapter(contactsAdapter);
    completeList.setOnItemClickListener(this);

    dialUser.setAdapter(autoCompleteAdapter);
  }
Example #19
0
  @Override
  public void updateView(final ViewDataBinding binding) {
    final TaskitemTextBinding b = (TaskitemTextBinding) binding;
    b.setTaskitem(this);
    final AutoCompleteTextView textview = (AutoCompleteTextView) b.taskitemDetailTextText;
    textview.setText(getValue());
    if (mSuggestions != null && mSuggestions.size() > 0) {
      if (mSuggestionAdapter == null) {
        mSuggestionAdapter =
            new ArrayAdapter<>(
                textview.getContext(), android.R.layout.simple_dropdown_item_1line, mSuggestions);
      }
      textview.setAdapter(mSuggestionAdapter);
    }

    final Object tag = textview.getTag();
    if (tag instanceof TextWatcher) {
      textview.removeTextChangedListener((TextWatcher) tag);
    }
    textview.addTextChangedListener(this);
    textview.setTag(this);
  }
 private void initAutoCompleteTextView() {
   mAutoCompleteTextView = (AutoCompleteTextView) findViewById(R.id.address);
   mAdapter = new NavAutoCompleteAdapter(this);
   mAutoCompleteTextView.setAdapter(mAdapter);
   mAutoCompleteTextView.setOnItemClickListener(
       new OnItemClickListener() {
         @Override
         public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
           NavigationInfo navigationInfo = mAdapter.getNavigationInfo(position);
           if (navigationInfo != null) {
             mTitle.setText(navigationInfo.getTitle());
           }
         }
       });
   mAutoCompleteTextView.setOnFocusChangeListener(
       new OnFocusChangeListener() {
         @Override
         public void onFocusChange(View v, boolean hasFocus) {
           mQuickBar.setVisibility(hasFocus && mIsPortrait ? View.VISIBLE : View.INVISIBLE);
         }
       });
   onConfigurationChanged(getResources().getConfiguration());
   mAutoCompleteTextView.setDropDownHorizontalOffset(-76);
   mTitle = (EditText) findViewById(R.id.title);
   mClearAddress = (ImageView) findViewById(R.id.clear_address_button);
   mClearTitle = (ImageView) findViewById(R.id.clear_title_button);
   mAutoCompleteTextView.addTextChangedListener(new ClearTextWatcher(mClearAddress));
   mTitle.addTextChangedListener(new ClearTextWatcher(mClearTitle));
   mClearAddress.setOnClickListener(this);
   mClearTitle.setOnClickListener(this);
   ReflectHelper.invokeMethod(
       mAutoCompleteTextView,
       "setCornerListView",
       new Class[] {boolean.class},
       new Object[] {true});
 }
  /** 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 #22
0
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    AppContext app = AppContext.getInstance();
    setContentView(R.layout.routeplan);
    CharSequence titleLable = "路线规划功能";
    setTitle(titleLable);
    // 初始化地图
    mMapView = (MapView) findViewById(R.id.bmapView);

    // GeoPoint mGeoPoint = new GeoPoint((int) (31.224078 * 1E6), (int)
    // (121.540419 * 1E6));

    mMapController = mMapView.getController();
    // 设置地图的中心点
    mMapView.setBuiltInZoomControls(false);
    // mMapView.getController().setCenter(mGeoPoint);
    mMapView.getController().setZoom(12);
    mMapView.getController().enableClick(true);

    // 初始化按键
    mBtnDrive = (Button) findViewById(R.id.drive);
    mBtnTransit = (Button) findViewById(R.id.transit);
    mBtnWalk = (Button) findViewById(R.id.walk);
    mBtnPre = (Button) findViewById(R.id.pre);
    mBtnNext = (Button) findViewById(R.id.next);
    mBtnPre.setVisibility(View.INVISIBLE);
    mBtnNext.setVisibility(View.INVISIBLE);

    // 处理搜索按钮响应
    editSt = (AutoCompleteTextView) findViewById(R.id.start);
    editEn = (AutoCompleteTextView) findViewById(R.id.end);
    adapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line);
    editEn.setAdapter(adapter);
    editSt.setAdapter(adapter);

    editSt.addTextChangedListener(
        new TextWatcher() {

          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {
            // mSearch.poiSearchInCity("上海", editEn.getText().toString());
            ptStart = null;
            if (s.length() <= 0) {
              return;
            }
            /** 使用建议搜索服务获取建议列表,结果在onSuggestionResult()中更新 */
            mSearch.suggestionSearch(s.toString(), "上海");
          }

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

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

    editEn.addTextChangedListener(
        new TextWatcher() {

          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {
            // mSearch.poiSearchInCity("上海", editEn.getText().toString());
            ptEnd = null;
            if (s.length() <= 0) {
              return;
            }
            /** 使用建议搜索服务获取建议列表,结果在onSuggestionResult()中更新 */
            mSearch.suggestionSearch(s.toString(), "上海");
          }

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

          @Override
          public void afterTextChanged(Editable s) {}
        });
    // 按键点击事件
    OnClickListener clickListener =
        new OnClickListener() {
          public void onClick(View v) {
            // 发起搜索
            SearchButtonProcess(v);
          }
        };
    OnClickListener nodeClickListener =
        new OnClickListener() {
          public void onClick(View v) {
            // 浏览路线节点
            nodeClick(v);
          }
        };

    mBtnDrive.setOnClickListener(clickListener);
    mBtnTransit.setOnClickListener(clickListener);
    mBtnWalk.setOnClickListener(clickListener);
    mBtnPre.setOnClickListener(nodeClickListener);
    mBtnNext.setOnClickListener(nodeClickListener);
    // 创建 弹出泡泡图层
    createPaopao();

    // 地图点击事件处理
    mMapView.regMapTouchListner(
        new MKMapTouchListener() {

          @Override
          public void onMapClick(GeoPoint point) {
            // 在此处理地图点击事件
            // 消隐pop
            if (pop != null) {
              pop.hidePop();
            }
          }

          @Override
          public void onMapDoubleClick(GeoPoint point) {}

          @Override
          public void onMapLongClick(GeoPoint point) {}
        });
    // 初始化搜索模块,注册事件监听
    mSearch = new MKSearch();
    // mSearch.geocode("栖山路1460弄28号", "上海");

    mSearch.init(
        app.mBMapManager,
        new MKSearchListener() {

          public void onGetDrivingRouteResult(MKDrivingRouteResult res, int error) {
            pb.dismiss();
            // 起点或终点有歧义,需要选择具体的城市列表或地址列表
            if (error == MKEvent.ERROR_ROUTE_ADDR) {
              // 遍历所有地址
              Toast.makeText(RoutePlanDemo.this, "起点或终点有歧义,需要选择具体的地址列表", Toast.LENGTH_LONG).show();
              return;
            }
            // 错误号可参考MKEvent中的定义
            if (error != 0 || res == null) {
              Toast.makeText(RoutePlanDemo.this, "抱歉,未找到结果", Toast.LENGTH_SHORT).show();
              return;
            }

            searchType = 0;
            routeOverlay = new RouteOverlay(RoutePlanDemo.this, mMapView);
            // 此处仅展示一个方案作为示例
            routeOverlay.setData(res.getPlan(0).getRoute(0));
            // 清除其他图层
            mMapView.getOverlays().clear();
            // 添加路线图层
            mMapView.getOverlays().add(routeOverlay);
            // 执行刷新使生效
            mMapView.refresh();
            // 使用zoomToSpan()绽放地图,使路线能完全显示在地图上
            mMapView
                .getController()
                .zoomToSpan(routeOverlay.getLatSpanE6(), routeOverlay.getLonSpanE6());
            // 移动地图到起点
            mMapView.getController().animateTo(res.getStart().pt);
            // 将路线数据保存给全局变量
            route = res.getPlan(0).getRoute(0);
            // 重置路线节点索引,节点浏览时使用
            nodeIndex = -1;
            mBtnPre.setVisibility(View.VISIBLE);
            mBtnNext.setVisibility(View.VISIBLE);
          }

          public void onGetTransitRouteResult(MKTransitRouteResult res, int error) {
            pb.dismiss();
            // 起点或终点有歧义,需要选择具体的城市列表或地址列表
            if (error == MKEvent.ERROR_ROUTE_ADDR) {
              // 遍历所有地址
              // ArrayList<MKPoiInfo> stPois =
              // res.getAddrResult().mStartPoiList;
              // ArrayList<MKPoiInfo> enPois =
              // res.getAddrResult().mEndPoiList;
              // listAddress = new ArrayList<String>();
              // for (int i = 0; i < enPois.size(); i++) {
              // listAddress.add(enPois.get(i).name);
              // System.out.println("stPois.get(i).name------------"+enPois.get(i).name);
              // }
              //
              // ArrayList<MKCityListInfo> stCities =
              // res.getAddrResult().mStartCityList;
              // ArrayList<MKCityListInfo> enCities =
              // res.getAddrResult().mEndCityList;
              Toast.makeText(RoutePlanDemo.this, "起点或终点有歧义,需要选择具体的地址列表", Toast.LENGTH_LONG).show();
              return;
            }
            if (error != 0 || res == null) {
              Toast.makeText(RoutePlanDemo.this, "抱歉,未找到结果", Toast.LENGTH_SHORT).show();
              return;
            }

            searchType = 1;
            transitOverlay = new TransitOverlay(RoutePlanDemo.this, mMapView);
            // 此处仅展示一个方案作为示例
            transitOverlay.setData(res.getPlan(0));
            // 清除其他图层
            mMapView.getOverlays().clear();
            // 添加路线图层
            mMapView.getOverlays().add(transitOverlay);
            // 执行刷新使生效
            mMapView.refresh();
            // 使用zoomToSpan()绽放地图,使路线能完全显示在地图上
            mMapView
                .getController()
                .zoomToSpan(transitOverlay.getLatSpanE6(), transitOverlay.getLonSpanE6());
            // 移动地图到起点
            mMapView.getController().animateTo(res.getStart().pt);
            // 重置路线节点索引,节点浏览时使用
            nodeIndex = 0;
            mBtnPre.setVisibility(View.VISIBLE);
            mBtnNext.setVisibility(View.VISIBLE);
          }

          public void onGetWalkingRouteResult(MKWalkingRouteResult res, int error) {
            pb.dismiss();
            // 起点或终点有歧义,需要选择具体的城市列表或地址列表
            if (error == MKEvent.ERROR_ROUTE_ADDR) {
              // 遍历所有地址
              Toast.makeText(RoutePlanDemo.this, "起点或终点有歧义,需要选择具体的地址列表", Toast.LENGTH_LONG).show();
              return;
            }
            if (error != 0 || res == null) {
              Toast.makeText(RoutePlanDemo.this, "抱歉,未找到结果", Toast.LENGTH_SHORT).show();
              return;
            }

            searchType = 2;
            routeOverlay = new RouteOverlay(RoutePlanDemo.this, mMapView);
            // 此处仅展示一个方案作为示例
            routeOverlay.setData(res.getPlan(0).getRoute(0));
            // 清除其他图层
            mMapView.getOverlays().clear();
            // 添加路线图层
            mMapView.getOverlays().add(routeOverlay);
            // 执行刷新使生效
            mMapView.refresh();
            // 使用zoomToSpan()绽放地图,使路线能完全显示在地图上
            mMapView
                .getController()
                .zoomToSpan(routeOverlay.getLatSpanE6(), routeOverlay.getLonSpanE6());
            // 移动地图到起点
            mMapView.getController().animateTo(res.getStart().pt);
            // 将路线数据保存给全局变量
            route = res.getPlan(0).getRoute(0);
            // 重置路线节点索引,节点浏览时使用
            nodeIndex = -1;
            mBtnPre.setVisibility(View.VISIBLE);
            mBtnNext.setVisibility(View.VISIBLE);
          }

          // 通过 经度纬度 找到地址
          //
          //
          public void onGetAddrResult(MKAddrInfo res, int error) {
            if (res == null) {
              return;
            }

            // 判断该地址附近是否有POI(Point of Interest,即兴趣点)
            if (null != res.poiList) {
              // 将地址信息、兴趣点信息显示在TextView上
              editSt.setText(res.poiList.get(0).name);
              ptStart =
                  new GeoPoint(
                      (int) (res.poiList.get(0).pt.getLatitudeE6()),
                      (int) (res.poiList.get(0).pt.getLongitudeE6()));

              mSearch.poiSearchInCity("上海", editEn.getText().toString());
            } else {
              Toast.makeText(RoutePlanDemo.this, "抱歉,没找到您的当前位置", Toast.LENGTH_LONG).show();
            }
          }

          public void onGetPoiResult(MKPoiResult res, int arg1, int error) {
            System.out.println(res + "-------------res");
            if (pb1 != null) pb1.dismiss();
            // 错误号可参考MKEvent中的定义
            if (error != 0 || res == null) {
              Toast.makeText(RoutePlanDemo.this, "抱歉,未找到结果", Toast.LENGTH_LONG).show();
              return;
            }
            // 将地图移动到第一个POI中心点
            if (res.getCurrentNumPois() > 0) {
              // 将poi结果显示到地图上
              try {
                MyPoiOverlay poiOverlay = new MyPoiOverlay(RoutePlanDemo.this, mMapView, mSearch);
                ArrayList<MKPoiInfo> list = new ArrayList<MKPoiInfo>();
                res.getAllPoi().get(0).name = editEn.getText().toString();
                list.add(res.getAllPoi().get(0)); // 只加一项
                // editEn.setText(res.getAllPoi().get(0).name);
                ptEnd =
                    new GeoPoint(
                        (int) (res.getAllPoi().get(0).pt.getLatitudeE6()),
                        (int) (res.getAllPoi().get(0).pt.getLongitudeE6()));

                poiOverlay.setData(list);

                mMapView.getOverlays().clear();
                mMapView.getOverlays().add(poiOverlay);

                mMapView.refresh();
                // 当ePoiType为2(公交线路)或4(地铁线路)时, poi坐标为空
                for (MKPoiInfo info : res.getAllPoi()) {
                  if (info.pt != null) {
                    mMapView.getController().animateTo(info.pt);
                    break;
                  }
                }
              } catch (Exception e) {
                e.printStackTrace();
              }
            } else if (res.getCityListNum() > 0) {
              // 当输入关键字在本市没有找到,但在其他城市找到时,返回包含该关键字信息的城市列表
              String strInfo = "在";
              for (int i = 0; i < res.getCityListNum(); i++) {
                strInfo += res.getCityListInfo(i).city;
                strInfo += ",";
              }
              strInfo += "找到结果";
              Toast.makeText(RoutePlanDemo.this, strInfo, Toast.LENGTH_LONG).show();
            }
          }

          public void onGetBusDetailResult(MKBusLineResult result, int iError) {}

          @Override
          public void onGetSuggestionResult(MKSuggestionResult res, int arg1) {
            // if (!isFirstEdit) {
            if (res == null || res.getAllSuggestions() == null) {
              return;
            }
            adapter.clear();
            for (MKSuggestionInfo info : res.getAllSuggestions()) {
              if (info.key != null) adapter.add(info.key);
            }
            adapter.notifyDataSetChanged();

            // } else {
            // if (res == null || res.getAllSuggestions() == null) {
            // return;
            // }
            // editEn.setText(res.getAllSuggestions().get(0).key);
            // isFirstEdit = false;
            // }
          }

          @Override
          public void onGetPoiDetailSearchResult(int type, int iError) {}

          @Override
          public void onGetShareUrlResult(MKShareUrlResult result, int type, int error) {}
        });
    editEn.setText(getIntent().getStringExtra(WebViewActivity.ENDSTR));
    pb1 = new ProgressDialog(this);
    pb1.setMessage("正在定位...");
    pb1.show();
    new Thread() {
      public void run() {
        try {
          Thread.sleep(0);
        } catch (InterruptedException e) {
          e.printStackTrace();
        }
        runOnUiThread(
            new Runnable() {
              @Override
              public void run() {
                // mSearch.suggestionSearch(editEn.getText().toString(),
                // "上海");
                // mSearch.poiSearchInCity("上海",
                // editEn.getText().toString());
                // 定位初始化
                mLocClient = new LocationClient(RoutePlanDemo.this);
                locData = new LocationData();
                mLocClient.registerLocationListener(myListener);
                LocationClientOption option = new LocationClientOption();
                option.setOpenGps(true); // 打开gps
                option.setCoorType("bd09ll"); // 设置坐标类型
                option.setScanSpan(1000);
                mLocClient.setLocOption(option);
                mLocClient.start();
              }
            });
      }
    }.start();

    pb = new ProgressDialog(this);
    pb.setMessage("正在搜索...");
    // 定位图层初始化
    // myLocationOverlay = new locationOverlay(mMapView);
    // // 设置定位数据
    // myLocationOverlay.setData(locData);
    // // 添加定位图层
    // mMapView.getOverlays().add(myLocationOverlay);
    // myLocationOverlay.enableCompass();
    // // 修改定位数据后刷新图层生效
    // mMapView.refresh();
  }
Example #23
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));
  }
  @TargetApi(Build.VERSION_CODES.HONEYCOMB)
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View view = inflater.inflate(R.layout.fragment_edit_poi, container, false);
    final OsmandSettings settings = getMyApplication().getSettings();
    boolean isLightTheme = settings.OSMAND_THEME.get() == OsmandSettings.OSMAND_LIGHT_THEME;

    if (savedInstanceState != null) {
      Map<String, String> mp = (Map<String, String>) savedInstanceState.getSerializable(TAGS_LIST);
      editPoiData.updateTags(mp);
    }

    Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar);
    toolbar.setTitle(R.string.poi_create_title);
    toolbar.setNavigationIcon(R.drawable.abc_ic_ab_back_mtrl_am_alpha);
    toolbar.setNavigationOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            dismissCheckForChanges();
          }
        });

    viewPager = (ViewPager) view.findViewById(R.id.viewpager);
    String basicTitle = getResources().getString(R.string.tab_title_basic);
    String extendedTitle = getResources().getString(R.string.tab_title_advanced);
    final MyAdapter pagerAdapter =
        new MyAdapter(getChildFragmentManager(), basicTitle, extendedTitle);
    viewPager.setAdapter(pagerAdapter);
    viewPager.addOnPageChangeListener(
        new ViewPager.OnPageChangeListener() {
          @Override
          public void onPageScrolled(int i, float v, int i1) {}

          @Override
          public void onPageSelected(int i) {
            ((OnFragmentActivatedListener) pagerAdapter.getItem(i)).onFragmentActivated();
          }

          @Override
          public void onPageScrollStateChanged(int i) {}
        });

    final TabLayout tabLayout = (TabLayout) view.findViewById(R.id.tab_layout);
    tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);

    // Hack due to bug in design support library v22.2.1
    // https://code.google.com/p/android/issues/detail?id=180462
    // TODO remove in new version
    if (ViewCompat.isLaidOut(tabLayout)) {
      tabLayout.setupWithViewPager(viewPager);
    } else {
      tabLayout.addOnLayoutChangeListener(
          new View.OnLayoutChangeListener() {
            @Override
            public void onLayoutChange(
                View v,
                int left,
                int top,
                int right,
                int bottom,
                int oldLeft,
                int oldTop,
                int oldRight,
                int oldBottom) {
              tabLayout.setupWithViewPager(viewPager);
              tabLayout.removeOnLayoutChangeListener(this);
            }
          });
    }

    ImageButton onlineDocumentationButton =
        (ImageButton) view.findViewById(R.id.onlineDocumentationButton);
    onlineDocumentationButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            getActivity()
                .startActivity(
                    new Intent(
                        Intent.ACTION_VIEW,
                        Uri.parse("https://wiki.openstreetmap.org/wiki/Map_Features")));
          }
        });

    final int colorId = isLightTheme ? R.color.inactive_item_orange : R.color.dash_search_icon_dark;
    final int color = getResources().getColor(colorId);
    onlineDocumentationButton.setImageDrawable(
        getMyApplication().getIconsCache().getPaintedContentIcon(R.drawable.ic_action_help, color));
    final ImageButton poiTypeButton = (ImageButton) view.findViewById(R.id.poiTypeButton);
    poiTypeButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            DialogFragment fragment = PoiTypeDialogFragment.createInstance(editPoiData.amenity);
            fragment.show(getChildFragmentManager(), "PoiTypeDialogFragment");
          }
        });

    EditText poiNameEditText = (EditText) view.findViewById(R.id.poiNameEditText);
    poiNameEditText.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) {}

          @Override
          public void afterTextChanged(Editable s) {
            if (!getEditPoiData().isInEdit()) {
              if (!TextUtils.isEmpty(s)) {
                getEditPoiData().putTag(OSMSettings.OSMTagKey.NAME.getValue(), s.toString());
              } else {
                getEditPoiData().removeTag(OSMSettings.OSMTagKey.NAME.getValue());
              }
            }
          }
        });
    poiNameEditText.setText(node.getTag(OSMSettings.OSMTagKey.NAME));
    poiTypeTextInputLayout = (TextInputLayout) view.findViewById(R.id.poiTypeTextInputLayout);
    poiTypeEditText = (AutoCompleteTextView) view.findViewById(R.id.poiTypeEditText);
    poiTypeEditText.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) {}

          @Override
          public void afterTextChanged(Editable s) {
            if (!getEditPoiData().isInEdit()) {
              getEditPoiData().putTag(EditPoiData.POI_TYPE_TAG, s.toString());
            }
          }
        });
    poiNameEditText.setOnEditorActionListener(mOnEditorActionListener);
    poiTypeEditText.setOnEditorActionListener(mOnEditorActionListener);
    poiTypeEditText.setText(editPoiData.amenity.getSubType());

    Button saveButton = (Button) view.findViewById(R.id.saveButton);
    saveButton.setText(R.string.shared_string_save);
    saveButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            save();
          }
        });
    Button cancelButton = (Button) view.findViewById(R.id.cancelButton);
    cancelButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            FragmentManager fragmentManager = getActivity().getSupportFragmentManager();
            fragmentManager.beginTransaction().remove(EditPoiDialogFragment.this).commit();
            fragmentManager.popBackStack();
          }
        });
    setAdapterForPoiTypeEditText();
    setCancelable(false);
    return view;
  }
  /** 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

          }
        });
  }
  void init() {
    onClickListener =
        new OnViewClickListener() {
          @Override
          public void onClick(View v) {
            super.onClick(v);
            switch (v.getId()) {
              case R.id.purpose_currency_ibtn:
                AlertDialog dialog =
                    new AlertDialog.Builder(context)
                        .setIcon(android.R.drawable.ic_dialog_info)
                        .setAdapter(
                            new ListAdapter() {

                              @Override
                              public void unregisterDataSetObserver(DataSetObserver observer) {
                                // TODO Auto-generated method stub

                              }

                              @Override
                              public void registerDataSetObserver(DataSetObserver observer) {
                                // TODO Auto-generated method stub

                              }

                              @Override
                              public boolean isEmpty() {
                                // TODO Auto-generated method stub
                                return false;
                              }

                              @Override
                              public boolean hasStableIds() {
                                // TODO Auto-generated method stub
                                return false;
                              }

                              @Override
                              public int getViewTypeCount() {
                                // TODO Auto-generated method stub
                                return 1;
                              }

                              @Override
                              public View getView(
                                  int position, View convertView, ViewGroup parent) {

                                TextView tv;
                                if (convertView != null) {
                                  tv = (TextView) convertView;
                                } else {
                                  tv = new TextView(context);
                                }
                                String tableNameString =
                                    purposeCurrencyTablesResponseModel
                                        .getTablewrapperList()
                                        .get(position)
                                        .getTableName();
                                tv.setText(tableNameString);
                                return tv;
                              }

                              @Override
                              public int getItemViewType(int position) {
                                // TODO Auto-generated method stub
                                return position;
                              }

                              @Override
                              public long getItemId(int position) {
                                // TODO Auto-generated method stub
                                return position;
                              }

                              @Override
                              public Object getItem(int position) {
                                // TODO Auto-generated method stub
                                return purposeCurrencyTablesResponseModel
                                    .getTablewrapperList()
                                    .get(position);
                              }

                              @Override
                              public int getCount() {
                                // TODO Auto-generated method stub
                                return purposeCurrencyTablesResponseModel
                                    .getTablewrapperList()
                                    .size();
                              }

                              @Override
                              public boolean isEnabled(int position) {
                                // TODO Auto-generated method stub
                                return true;
                              }

                              @Override
                              public boolean areAllItemsEnabled() {
                                // TODO Auto-generated method stub
                                return false;
                              }
                            },
                            new DialogInterface.OnClickListener() {

                              @Override
                              public void onClick(DialogInterface dialog, int which) {
                                purpose_currency_et.setText(
                                    (String)
                                        ((AlertDialog) dialog)
                                            .getListView()
                                            .getAdapter()
                                            .getItem(which));
                                dialog.dismiss();
                              }
                            })
                        .show();
                break;
              case R.id.confirmation_btn:
                onConfirm();
                break;
              case R.id.birth_data_et:
              case R.id.data_ibtn:
                final Calendar calender = Calendar.getInstance();
                new DatePickerDialog(
                        context,
                        new OnDateSetListener() {
                          @Override
                          public void onDateSet(
                              DatePicker view, int year, int monthOfYear, int dayOfMonth) {
                            calender.set(year, monthOfYear, dayOfMonth);
                            setDate(calender.getTimeInMillis());
                          }
                        },
                        calender.get(Calendar.YEAR),
                        calender.get(Calendar.MONDAY),
                        calender.get(Calendar.DATE))
                    .show();
                break;
              default:
                break;
            }
          }
        };
    super.init();
    tabHost = (TabHost) contentView.findViewById(R.id.tabhost);
    tabHost.setup();
    Button icon = (Button) mLayoutInflater.inflate(R.layout.payment_tab_left_btn, null);
    icon.setText(R.string.phone_top_up_recent_payment_tab_name);
    tabHost.addTab(
        tabHost
            .newTabSpec(RECENTPAYMENT_TAB)
            .setIndicator(icon /*, getResources().getDrawable(R.drawable.mumule)*/)
            .setContent(R.id.tab1));

    icon = (Button) mLayoutInflater.inflate(R.layout.payment_tab_right_btn, null);
    icon.setText(R.string.phone_top_up_new_payment_tab_name);
    tabHost.addTab(tabHost.newTabSpec(NEWPAYMENT_TAB).setIndicator(icon).setContent(R.id.tab2));
    tabHost.setCurrentTab(1);
    recent_content = (TableLayout) contentView.findViewById(R.id.recent_content);
    user_my_card_sbtn = (SwitchButton) contentView.findViewById(R.id.user_my_card_sbtn);
    user_my_card_sbtn.setOnCheckedChangeListener(
        new OnCheckedChangeListener() {

          @Override
          public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            showInputBeneficiary(!isChecked);
            onCheckForConfirm(false);
          }
        });
    beneficiary_rg = (TableLayout) contentView.findViewById(R.id.beneficiary_rg);
    input_benificiary_content = contentView.findViewById(R.id.input_benificiary_content);
    beneficiary_name_et = (AutoCompleteTextView) contentView.findViewById(R.id.name_et);
    beneficiary_name_et.postDelayed(
        new Runnable() {

          @Override
          public void run() {
            // TODO Auto-generated method stub
            beneficiary_name_et.setText("");
          }
        },
        3000);
    beneficiary_name_et.addTextChangedListener(confirmTextChangeListener);
    beneficiary_name_et.setOnEditorActionListener(
        new OnEditorActionListener() {

          @Override
          public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            iban_et.setFocusable(true);
            iban_et.requestFocus();
            iban_et.setFocusableInTouchMode(true);
            return true;
          }
        });
    beneficiary_ibtn = (ImageButton) contentView.findViewById(R.id.phonebook_btn);
    iban_et = (EditText) contentView.findViewById(R.id.phone_et);
    iban_et.postDelayed(
        new Runnable() {

          @Override
          public void run() {
            // TODO Auto-generated method stub
            iban_et.setText("");
          }
        },
        3000);
    iban_et.addTextChangedListener(confirmTextChangeListener);
    add_phonebook_sbtn = (SwitchButton) contentView.findViewById(R.id.add_phonebook_sbtn);
    add_phonebook_sbtn.setOnCheckedChangeListener(this);
    currency_tv = (TextView) contentView.findViewById(R.id.currency_tv);
    currency_tv.setText(NewPaymentDataUtils.getCurrency());
    amount_et = (EditText) contentView.findViewById(R.id.amount_et);
    amount_et.addTextChangedListener(confirmTextChangeListener);
    new AmountItalyInputFilter(amount_et, null);
    description_of_payment_et = (EditText) contentView.findViewById(R.id.description_of_payment_et);
    description_of_payment_et.setOnEditorActionListener(
        new OnEditorActionListener() {

          @Override
          public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            KeyBoardUtils.hideSoftInputFromWindow(
                context, description_of_payment_et.getWindowToken());
            return false;
          }
        });
    description_of_payment_et.addTextChangedListener(confirmTextChangeListener);
    des_length_alerter_tv = (TextView) contentView.findViewById(R.id.des_length_alerter_tv);
    mDesLimitTextChangedListener =
        new DesLimitTextChangedListener(context, description_of_payment_et, des_length_alerter_tv);
    purpose_currency_liner = (LinearLayout) contentView.findViewById(R.id.purpose_currency_liner);
    purpose_currency_et = (EditText) contentView.findViewById(R.id.purpose_currency_et);
    purpose_currency_et.addTextChangedListener(confirmTextChangeListener);
    purpose_currency_ibtn = (ImageButton) contentView.findViewById(R.id.purpose_currency_ibtn);
    purpose_currency_ibtn.setOnClickListener(onClickListener);

    birth_date_container = (LinearLayout) contentView.findViewById(R.id.birth_date_container);
    birth_data_et = (EditText) birth_date_container.findViewById(R.id.birth_data_et);
    data_ibtn = (ImageButton) birth_date_container.findViewById(R.id.data_ibtn);
    birth_data_et.setOnClickListener(onClickListener);
    data_ibtn.setOnClickListener(onClickListener);

    confirmation_btn = (Button) contentView.findViewById(R.id.confirmation_btn);
    confirmation_btn.setOnClickListener(mOnConfirmClickListener);
    confirmation_btn.setOnTouchListener(mOnConfirmTouchListener);
    mDesLimitTextChangedListener.setDestriptionMaxLenth(DES_LENGTH_OFF);
  }
Example #27
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    toolbar = (Toolbar) findViewById(R.id.toolbarmain);
    toolbar.setTitle("Prepare Towing");
    setSupportActionBar(toolbar);

    settings = PreferenceManager.getDefaultSharedPreferences(this);

    // Set up the tow pilot name input, including autocomplete and hasAccount check
    contactlistmanager = new ContactListManager(this);

    towPilotCheckmark = (ImageView) findViewById(R.id.towPilotCheckmark);

    towPilotNameIn = (AutoCompleteTextView) findViewById(R.id.towPilotNameIn);
    towPilotNameIn.setAdapter(contactlistmanager.getContactNameListAdapter());
    towPilotNameIn.addTextChangedListener(
        new TextWatcher() {
          public void onTextChanged(CharSequence s, int start, int before, int count) {
            Contact selected = contactlistmanager.findContactFromName(String.valueOf(s));
            selectedTowPilot = selected;
            if (selected == null) {
              towPilotCheckmark.setBackgroundResource(0);
            } else {
              if (selected.hasAccount) {
                towPilotCheckmark.setBackgroundResource(R.mipmap.green_checkmark);
              } else {
                towPilotCheckmark.setBackgroundResource(R.mipmap.new_icon_blue);
              }
            }
          }

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

          public void afterTextChanged(Editable s) {}
        });

    // Set up towplane input
    towPlaneIn = (EditText) findViewById(R.id.towPlaneIn);
    towPlaneIn.setText(
        settings.getString("lasttowplane", settings.getString("towplane_default_reg", "")));

    // Set up Datepicker
    datepicker = (DatePicker) findViewById(R.id.datePicker);
    today = Calendar.getInstance();
    datepicker.init(
        today.get(Calendar.YEAR),
        today.get(Calendar.MONTH),
        today.get(Calendar.DAY_OF_MONTH),
        new DatePicker.OnDateChangedListener() {
          @Override
          public void onDateChanged(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
            Calendar c = Calendar.getInstance();
            c.set(year, monthOfYear, dayOfMonth);
            selecteddate = c.getTime();

            dayLogFileNameSuffix =
                String.valueOf(year)
                    + "_"
                    + String.valueOf(monthOfYear + 1)
                    + "_"
                    + String.valueOf(dayOfMonth);

            Log.e("DATEPICKER", dayLogFileNameSuffix);

            if (loadDayLog()) {
              found_daylog = true;
              resumeDayButton.setVisibility(View.VISIBLE);
            } else {
              found_daylog = false;
              resumeDayButton.setVisibility(View.INVISIBLE);
            }
          }
        });

    Log.e("DATEPICKER", "Inited object, " + datepicker);

    // Start new day button
    startDayButton = (Button) findViewById(R.id.startDayButton);
    ColoringUtil.colorMe(startDayButton, getResources().getColor(R.color.colorPrimary));
    startDayButton.setTextColor(getResources().getColor(R.color.white));
    startDayButton.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            if (found_daylog) {
              new AlertDialog.Builder(MainActivity.this)
                  .setMessage(
                      "There is already a log for this date. "
                          + "Are you sure you want to overwrite it?")
                  .setCancelable(false)
                  .setPositiveButton(
                      "Yes",
                      new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {
                          startNewDay();
                        }
                      })
                  .setNegativeButton("No", null)
                  .show();

            } else {
              startNewDay();
            }
          }
        });

    // Resume day button
    resumeDayButton = (Button) findViewById(R.id.resumeDayButton);
    ColoringUtil.colorMe(resumeDayButton, getResources().getColor(R.color.resumeday_button));
    resumeDayButton.setTextColor(getResources().getColor(R.color.white));
    resumeDayButton.setVisibility(View.INVISIBLE);
    resumeDayButton.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            String action = "resume";
            Intent intent = new Intent(MainActivity.this, DayOverviewActivity.class);
            Bundle bundle = bundleDayInfo();
            bundle.putSerializable("action", action);
            bundle.putSerializable("reason", "Resuming day");
            intent.putExtras(bundle);
            startActivityForResult(intent, 0);
          }
        });

    // Various dialogs for the menus
    daylogdialog = getPrevLogsAlertDialog();
    loadfikencontactsdialog = getLoadFikenContactsAlertDialog();
  }
  /** 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

          }
        });
  }
Example #29
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.fragment_send, container, false);

    sendToAddressView = (AutoCompleteTextView) view.findViewById(R.id.send_to_address);
    sendToAddressViewAdapter = new ReceivingAddressViewAdapter(application);
    sendToAddressView.setAdapter(sendToAddressViewAdapter);
    sendToAddressView.setOnFocusChangeListener(receivingAddressListener);
    sendToAddressView.addTextChangedListener(receivingAddressListener);

    sendToStaticAddressView = (AddressView) view.findViewById(R.id.send_to_address_static);
    sendToStaticAddressView.setOnClickListener(addressOnClickListener);

    sendCoinAmountView = (AmountEditView) view.findViewById(R.id.send_coin_amount);
    sendCoinAmountView.resetType(sendAmountType);
    if (sendAmount != null) sendCoinAmountView.setAmount(sendAmount, false);

    AmountEditView sendLocalAmountView = (AmountEditView) view.findViewById(R.id.send_local_amount);
    sendLocalAmountView.setFormat(FiatType.FRIENDLY_FORMAT);

    amountCalculatorLink = new CurrencyCalculatorLink(sendCoinAmountView, sendLocalAmountView);
    amountCalculatorLink.setExchangeDirection(config.getLastExchangeDirection());
    amountCalculatorLink.setExchangeRate(getCurrentRate());

    addressError = (TextView) view.findViewById(R.id.address_error_message);
    addressError.setVisibility(View.GONE);
    amountError = (TextView) view.findViewById(R.id.amount_error_message);
    amountError.setVisibility(View.GONE);
    amountWarning = (TextView) view.findViewById(R.id.amount_warning_message);
    amountWarning.setVisibility(View.GONE);

    scanQrCodeButton = (ImageButton) view.findViewById(R.id.scan_qr_code);
    scanQrCodeButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            handleScan();
          }
        });

    eraseAddressButton = (ImageButton) view.findViewById(R.id.erase_address);
    eraseAddressButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            clearAddress(true);
            updateView();
          }
        });

    sendConfirmButton = (Button) view.findViewById(R.id.send_confirm);
    sendConfirmButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            validateAddress();
            validateAmount();
            if (everythingValid()) handleSendConfirm();
            else requestFocusFirst();
          }
        });

    return view;
  }
Example #30
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;
          }
        });
  }