private void initGUI(View v) {
    nameText = (EditText) v.findViewById(R.id.text_name);
    brandBox = (AutoCompleteTextView) v.findViewById(R.id.text_brand);
    final ArrayAdapter<Brand> brands =
        new ArrayAdapter<Brand>(getActivity(), R.layout.listitem_default, EntityUtils.getBrands());
    brandBox.setAdapter(brands);
    brandBox.setOnItemClickListener(
        new OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            ScanUtils.brand = brands.getItem(position);
          }
        });
    brandBox.setOnEditorActionListener(
        new OnEditorActionListener() {

          @Override
          public boolean onEditorAction(TextView view, int id, KeyEvent event) {
            brandBox.dismissDropDown();
            return false;
          }
        });
    categoryBox = (AutoCompleteTextView) v.findViewById(R.id.text_category);
    final ArrayAdapter<Category> categories =
        new ArrayAdapter<Category>(
            getActivity(), R.layout.listitem_default, EntityUtils.getCategories());
    categoryBox.setAdapter(categories);
    categoryBox.setOnItemClickListener(
        new OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            ScanUtils.category = categories.getItem(position);
          }
        });
    categoryBox.setOnEditorActionListener(
        new OnEditorActionListener() {

          @Override
          public boolean onEditorAction(TextView view, int id, KeyEvent event) {
            categoryBox.dismissDropDown();
            return false;
          }
        });
    priceText = (EditText) v.findViewById(R.id.text_price);
    sizeText = (EditText) v.findViewById(R.id.text_size);
    unitSpinner = (Spinner) v.findViewById(R.id.spinner_unit);
    SpinnerAdapter units =
        new ArrayAdapter<String>(getActivity(), R.layout.listitem_default, getMeasures());
    unitSpinner.setAdapter(units);
    Button btnCreateProduct = (Button) v.findViewById(R.id.btn_create_product);
    btnCreateProduct.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View arg0) {
            checkInput();
          }
        });
    addInput();
  }
  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);
  }
示例#3
0
  public FindOnPage(final SuperTextActivity superTextActivity) {
    this.superTextActivity = superTextActivity;
    if (autoCompleteTextView == null) {
      autoCompleteTextView =
          (AutoCompleteTextView) superTextActivity.findViewById(R.id.auto_complete_text_view);
      setAutoCompleteAdapter();
      autoCompleteTextView.setOnItemClickListener(autoCompleteItemClick);
      autoCompleteTextView.setOnFocusChangeListener(autoComFocus);
      autoCompleteTextView.setOnEditorActionListener(autoComEnterClick);

      autoCompleteTextView.requestFocus();

      // open the keyboard focused in the edtSearch
      hideShowKeyboard(true, InputMethodManager.SHOW_IMPLICIT);
    }
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Log.d(TAG, "onCreate");
    ButterKnife.bind(this);
    app.component.inject(this);

    setSupportActionBar(toolbar);

    realm = Realm.getInstance(this);

    getListFromRealm();

    recentSearchesRecycler.setAdapter(new PreviousSearchesAdapter(this, previousSearchList));
    recentSearchesRecycler.setLayoutManager(new LinearLayoutManager(this));

    movieSearch.setAdapter(new MovieSearchAdapter(this, android.R.layout.simple_list_item_1));
    movieSearch.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            MovieBase selected = (MovieBase) parent.getItemAtPosition(position);
            bus.post(new TitleSearchEvent(selected.getTitle()));
          }
        });

    movieSearch.setOnEditorActionListener(
        new TextView.OnEditorActionListener() {
          @Override
          public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_SEARCH) {
              movieSearchInputLayout.setError(null);
              // check length of text
              if (movieSearch.getText().toString().trim().isEmpty()) {
                movieSearchInputLayout.setError(getString(R.string.search_box_empty));
                return false;
              }
              bus.post(new TitleSearchEvent(movieSearch.getText().toString().trim()));

              return true;
            }
            return false;
          }
        });
  }
  @AfterViews
  void init() {
    try {
      setRetainInstance(true);
      ((SoliciteActivity) getActivity()).exibirBarraInferior(true);
      ((SoliciteActivity) getActivity()).setInfo(R.string.selecione_o_local);
      ((SoliciteActivity) getActivity()).enableNextButton(valid);
      if (checkPlayServices()) {
        ((SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.mapaLocal))
            .getMapAsync(this);
      } else {
        Toast.makeText(
                getActivity(),
                "Necessitamos saber da sua localização. Por favor, autorize nas configurações do seu aparelho.",
                Toast.LENGTH_SHORT)
            .show();
      }

      PlacesAutoCompleteAdapter placesAutoCompleteAdapter =
          new PlacesAutoCompleteAdapter(
              getActivity(), R.layout.autocomplete_list_item, ExploreFragment.class);
      autocompleteEndereco.setTypeface(FontUtils.getRegular(getActivity()));
      autocompleteEndereco.setAdapter(placesAutoCompleteAdapter);
      autocompleteEndereco.setOnItemClickListener(this);
      autocompleteEndereco.setOnEditorActionListener(
          (v, actionId, event) -> {
            boolean handled = false;
            if (actionId == EditorInfo.IME_ACTION_SEARCH) {
              searchTask(v.getText().toString());
              ViewUtils.hideKeyboard(getActivity(), v);
              handled = true;
            }
            return handled;
          });
      tvNumero.setTypeface(FontUtils.getRegular(getActivity()));
      message.setTypeface(FontUtils.getSemibold(getActivity()));
      timerEnderecoTask(latitude, longitude);
      if (file != null && !file.isEmpty()) {
        marcador.setImageBitmap(ImageUtils.getScaled(getActivity(), "reports", file));
      }
    } catch (Exception e) {
      Log.e("ZUP", e.getMessage(), e);
      Crashlytics.logException(e);
    }
  }
示例#6
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.layout_signup, container, false);

    // Set up the signup form.
    mEmailView = (AutoCompleteTextView) view.findViewById(R.id.email);
    mUsername = (AutoCompleteTextView) view.findViewById(R.id.username);
    populateAutoComplete();
    mPassword1View = (EditText) view.findViewById(R.id.password1);
    mPassword2View = (EditText) view.findViewById(R.id.password2);
    mEmailView.setOnEditorActionListener(
        new TextView.OnEditorActionListener() {
          @Override
          public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) {
            if (id == EditorInfo.IME_ACTION_NEXT) {
              mUsername.requestFocus();
              return true;
            }
            return false;
          }
        });

    mUsername.setOnEditorActionListener(
        new TextView.OnEditorActionListener() {
          @Override
          public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) {
            if (id == EditorInfo.IME_ACTION_NEXT) {
              mPassword1View.requestFocus();
              return true;
            }
            return false;
          }
        });

    mPassword1View.setOnEditorActionListener(
        new TextView.OnEditorActionListener() {
          @Override
          public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) {
            if (id == R.id.next || id == EditorInfo.IME_NULL) {
              mPassword2View.requestFocus();
              return true;
            }
            return false;
          }
        });
    mPassword2View.setOnEditorActionListener(
        new TextView.OnEditorActionListener() {
          @Override
          public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) {
            if (id == R.id.signup || id == EditorInfo.IME_NULL) {
              attemptSignup();
              return true;
            }
            return false;
          }
        });

    Button mSignupButton = (Button) view.findViewById(R.id.sign_up_button);
    mSignupButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View arg0) {
            attemptSignup();
          }
        });
    return view;
  }
  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);
  }
  /** Inflate the layout for this fragment */
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.import_keys_server_fragment, container, false);

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

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

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

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

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

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

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

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

    return view;
  }
示例#9
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;
          }
        });
  }
示例#10
0
  @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;
  }
示例#11
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    String strUrl;

    setTitle(R.string.app_name);
    super.onCreate(savedInstanceState);

    WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
    multicastLock = wifi.createMulticastLock("multicastLock");
    multicastLock.setReferenceCounted(true);
    multicastLock.acquire();

    getWindow().requestFeature(Window.FEATURE_PROGRESS);
    getWindow().setFeatureInt(Window.FEATURE_PROGRESS, Window.PROGRESS_VISIBILITY_ON);

    setContentView(R.layout.main);
    mthis = this;

    settings = PreferenceManager.getDefaultSharedPreferences(MainActivity.this);

    SharedSettings.getInstance(this).loadPrefSettings();
    SharedSettings.getInstance().savePrefSettings();

    playerStatus = (RelativeLayout) findViewById(R.id.playerStatus);
    playerStatusText = (TextView) findViewById(R.id.playerStatusText);
    playerHwStatus = (TextView) findViewById(R.id.playerHwStatus);

    player = (MediaPlayer) findViewById(R.id.playerView);

    strUrl =
        settings.getString("connectionUrl", "rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov");

    player.getSurfaceView().setZOrderOnTop(true); // necessary
    SurfaceHolder sfhTrackHolder = player.getSurfaceView().getHolder();
    sfhTrackHolder.setFormat(PixelFormat.TRANSPARENT);

    HashSet<String> tempHistory = new HashSet<String>();
    tempHistory.add("rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov");
    tempHistory.add("http://hls.cn.ru/streaming/2x2tv/tvrec/playlist.m3u8");
    tempHistory.add("rtsp://rtmp.infomaniak.ch/livecast/latele");

    player.setOnTouchListener(
        new View.OnTouchListener() {
          @Override
          public boolean onTouch(View view, MotionEvent motionEvent) {
            switch (motionEvent.getAction() & MotionEvent.ACTION_MASK) {
              case MotionEvent.ACTION_DOWN:
                {
                  if (player.getState() == PlayerState.Paused) player.Play();
                  else if (player.getState() == PlayerState.Started) player.Pause();
                }
            }

            return true;
          }
        });

    edtIpAddressHistory = settings.getStringSet("connectionHistory", tempHistory);

    this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

    edtIpAddress = (AutoCompleteTextView) findViewById(R.id.edit_ipaddress);
    edtIpAddress.setText(strUrl);

    edtIpAddress.setOnEditorActionListener(
        new OnEditorActionListener() {
          @Override
          public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) {
              InputMethodManager in =
                  (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
              in.hideSoftInputFromWindow(
                  edtIpAddress.getApplicationWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
              return true;
            }
            return false;
          }
        });

    btnHistory = (Button) findViewById(R.id.button_history);

    // Array of choices
    btnHistory.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            InputMethodManager in =
                (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            in.hideSoftInputFromWindow(
                MainActivity.edtIpAddress.getApplicationWindowToken(),
                InputMethodManager.HIDE_NOT_ALWAYS);

            if (edtIpAddressHistory.size() <= 0) return;

            String urlHistory[] = {
              "rtsp://russiatoday.fms.visionip.tv/rt/Russia_al_yaum_1000k_1/1000k_1",
              "rtsp://www.tvarm.ru:1935/live/myStream1.sdp",
              "rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov",
              "rtsp://live240.impek.com/brtvhd",
              "http://tv.life.ru/lifetv/480p/index.m3u8"
            };

            MainActivity.edtIpAddressAdapter =
                new ArrayAdapter<String>(
                    MainActivity.this,
                    R.layout.history_item,
                    new ArrayList<String>(edtIpAddressHistory));
            MainActivity.edtIpAddress.setAdapter(MainActivity.edtIpAddressAdapter);
            MainActivity.edtIpAddress.showDropDown();
          }
        });

    btnShot = (Button) findViewById(R.id.button_shot);

    // Array of choices
    btnShot.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            if (player != null) {
              Log.e("SDL", "getVideoShot()");

              SharedSettings sett = SharedSettings.getInstance();
              if (sett.decoderType != 0) {
                Toast.makeText(
                        getApplicationContext(), "For Software Decoder Only!", Toast.LENGTH_SHORT)
                    .show();
                return;
              }

              // VideoShot frame = player.getVideoShot(200, 200);
              VideoShot frame = player.getVideoShot(-1, -1);
              if (frame == null) return;

              // get your custom_toast.xml ayout
              LayoutInflater inflater = getLayoutInflater();

              View layout =
                  inflater.inflate(
                      R.layout.videoshot_view,
                      (ViewGroup) findViewById(R.id.videoshot_toast_layout_id));

              ImageView image = (ImageView) layout.findViewById(R.id.videoshot_image);
              image.setImageBitmap(
                  getFrameAsBitmap(frame.getData(), frame.getWidth(), frame.getHeight()));

              // Toast...
              if (toastShot != null) toastShot.cancel();

              toastShot = new Toast(getApplicationContext());
              toastShot.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
              toastShot.setDuration(Toast.LENGTH_SHORT);
              toastShot.setView(layout);
              toastShot.show();
            }
          }
        });

    btnConnect = (Button) findViewById(R.id.button_connect);
    btnConnect.setOnClickListener(this);

    btnRecord = (Button) findViewById(R.id.button_record);
    btnRecord.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View arg0) {
            is_record = !is_record;

            if (is_record) {
              // start recording
              if (player != null) {
                int record_flags =
                    PlayerRecordFlags.forType(PlayerRecordFlags.PP_RECORD_AUTO_START)
                        | PlayerRecordFlags.forType(
                            PlayerRecordFlags.PP_RECORD_SPLIT_BY_TIME); // 1 - auto start
                int rec_split_time = 30;
                player.RecordSetup(getRecordPath(), record_flags, rec_split_time, 0, "");
                player.RecordStart();
              }
            } else {
              // stop recording
              if (player != null) {
                player.RecordStop();
              }
            }

            ImageView ivLed = (ImageView) findViewById(R.id.led);
            if (ivLed != null)
              ivLed.setImageResource((is_record ? R.drawable.led_red : R.drawable.led_green));
            btnRecord.setText(is_record ? "Stop Record" : "Start Record");
          }
        });

    RelativeLayout layout = (RelativeLayout) findViewById(R.id.main_view);
    layout.setOnTouchListener(
        new OnTouchListener() {
          public boolean onTouch(View v, MotionEvent event) {
            InputMethodManager inputManager =
                (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            if (getWindow() != null
                && getWindow().getCurrentFocus() != null
                && getWindow().getCurrentFocus().getWindowToken() != null)
              inputManager.hideSoftInputFromWindow(
                  getWindow().getCurrentFocus().getWindowToken(), 0);
            return true;
          }
        });

    playerStatusText.setText("DEMO VERSION");
    setShowControls();
  }
示例#12
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.category_fragment, container, false);
    mFakeBg = view.findViewById(R.id.fake_bg);
    mListView = (BaseListView) view.findViewById(android.R.id.list);
    int listPadding =
        (int) ShopApp.getContext().getResources().getDimension(R.dimen.list_item_padding);
    mListView.setPadding(0, listPadding / 2, 0, listPadding);
    mSearchUi = view.findViewById(R.id.search_ui);
    mSearchUi.setOnClickListener(mSearchClickListener);

    mTopView = inflater.inflate(R.layout.fake_top_for_search, null);
    mTopViewContent = mTopView.findViewById(R.id.top_view_content);
    mTopViewContent.setBackgroundColor(
        ShopApp.getContext().getResources().getColor(R.color.fake_search_background));
    mListView.addHeaderView(mTopView);

    mFakeSearchView = inflater.inflate(R.layout.fake_search_view, null);
    mIsFakeSearchViewPositioned = false;
    View fakeInput = mFakeSearchView.findViewById(R.id.fake_input);
    fakeInput.setOnClickListener(mSearchClickListener);
    View fakeButton = mFakeSearchView.findViewById(R.id.fake_button);
    fakeButton.setOnClickListener(mSearchClickListener);
    mFakeSearchView.setBackgroundColor(
        ShopApp.getContext().getResources().getColor(R.color.fake_search_background));
    mListView.addHeaderView(mFakeSearchView);
    mListView.setOnLayoutListener(this);

    mCategoryAdapter = new CategoryAdapter(getActivity());
    mCategoryListAdapter =
        new CategoryListAdapter(getActivity(), mCategoryAdapter, mItemClickListner);
    mListView.setAdapter(mCategoryListAdapter);
    ArrayList<Object> data = new ArrayList<Object>();
    data.add(1);
    mCategoryListAdapter.updateData(data);

    mSearchButton = mSearchUi.findViewById(R.id.search_button);
    mSearchButton.setOnClickListener(mSearchClickListener);
    mInput = (AutoCompleteTextView) mSearchUi.findViewById(R.id.input);
    mInput.setOnEditorActionListener(
        new OnEditorActionListener() {
          @Override
          public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE) {
              mSearchButton.performClick();
              return true;
            }
            return false;
          }
        });
    mInput.addTextChangedListener(
        new TextWatcher() {

          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {}

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

          @Override
          public void afterTextChanged(Editable s) {
            loadHint();
          }
        });
    mSearchEmptyArea = mSearchUi.findViewById(R.id.empty_area);
    mSearchEmptyArea.setOnClickListener(mSearchClickListener);
    mSearchHintListView = (ListView) mSearchEmptyArea.findViewById(android.R.id.list);
    mSearchHintListView.addHeaderView(inflater.inflate(R.layout.search_hint_list_top, null));
    mSearchHintListAdapter = new SearchHintListAdapter(getActivity());
    mSearchHintListView.setAdapter(mSearchHintListAdapter);
    mSearchHintListView.setOnItemClickListener(
        new OnItemClickListener() {

          @Override
          public void onItemClick(AdapterView<?> parent, View view, int positon, long id) {
            View v = view.findViewById(R.id.word);
            if (v != null && v instanceof TextView) {
              doSearch(((TextView) v).getText().toString());
            }
          }
        });

    mLoadingView = (EmptyLoadingView) view.findViewById(R.id.loading);

    return view;
  }
  /**
   * Create the view, pull out UI elements, and set up the listener for the "add cards" button
   *
   * @param inflater The LayoutInflater object that can be used to inflate any views in the
   *     fragment,
   * @param container If non-null, this is the parent view that the fragment's UI should be attached
   *     to. The fragment should not add the view itself, but this can be used to generate the
   *     LayoutParams of the view.
   * @param savedInstanceState If non-null, this fragment is being re-constructed from a previous
   *     saved state as given here.
   * @return The view to be displayed
   */
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View myFragmentView = inflater.inflate(R.layout.wishlist_frag, container, false);
    assert myFragmentView != null;

    TextView.OnEditorActionListener addCardListener =
        new TextView.OnEditorActionListener() {
          public boolean onEditorAction(TextView arg0, int arg1, KeyEvent arg2) {
            if (arg1 == EditorInfo.IME_ACTION_SEARCH) {
              addCardToWishlist();
              return true;
            }
            return false;
          }
        };

    /* set the autocomplete for card names */
    mNameField = (AutoCompleteTextView) myFragmentView.findViewById(R.id.name_search);
    mNameField.setAdapter(
        new AutocompleteCursorAdapter(
            this, new String[] {CardDbAdapter.KEY_NAME}, new int[] {R.id.text1}, mNameField));
    mNameField.setOnEditorActionListener(addCardListener);

    /* Default the number of cards field */
    mNumberField = (EditText) myFragmentView.findViewById(R.id.number_input);
    mNumberField.setText("1");
    mNumberField.setOnEditorActionListener(addCardListener);

    /* Grab other elements */
    mTotalPriceField = (TextView) myFragmentView.findViewById(R.id.priceText);
    mTotalPriceDivider = myFragmentView.findViewById(R.id.divider_total_price);
    mFoilCheckBox = (CheckBox) myFragmentView.findViewById(R.id.wishlistFoil);
    ListView listView = (ListView) myFragmentView.findViewById(R.id.wishlist);

    myFragmentView
        .findViewById(R.id.add_card)
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                addCardToWishlist();
              }
            });

    /* Set up the wishlist and adapter, it will be read in onResume() */
    mCompressedWishlist = new ArrayList<>();
    mWishlistAdapter = new WishlistArrayAdapter(mCompressedWishlist);
    listView.setAdapter(mWishlistAdapter);
    listView.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
            /* Show the dialog for this particular card */
            showDialog(DIALOG_UPDATE_CARD, mCompressedWishlist.get(position).mCard.name);
          }
        });
    listView.setOnItemLongClickListener(
        new AdapterView.OnItemLongClickListener() {
          @Override
          public boolean onItemLongClick(
              AdapterView<?> adapterView, View view, int position, long id) {
            /* Remove the card */
            mCompressedWishlist.remove(position);
            /* Save the wishlist */
            WishlistHelpers.WriteCompressedWishlist(getActivity(), mCompressedWishlist);

            /* Redraw the new wishlist */
            mWishlistAdapter.notifyDataSetChanged();
            sumTotalPrice();
            return true;
          }
        });
    return myFragmentView;
  }
示例#14
0
 /**
  * 设置键盘搜索监听器
  *
  * @param editorActionListener
  */
 public void setOnEditorActionListener(TextView.OnEditorActionListener editorActionListener) {
   mTextView.setOnEditorActionListener(editorActionListener);
 }