Example usage for android.view View.OnClickListener View.OnClickListener

List of usage examples for android.view View.OnClickListener View.OnClickListener

Introduction

In this page you can find the example usage for android.view View.OnClickListener View.OnClickListener.

Prototype

View.OnClickListener

Source Link

Usage

From source file:com.mendhak.gpslogger.GpsMainActivity.java

public void setUpNavigationDrawer(Bundle savedInstanceState) {

    final DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);

    drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, getToolbar(), R.string.navigation_drawer_open,
            R.string.navigation_drawer_close) {

        public void onDrawerClosed(View view) {
            invalidateOptionsMenu();/*from w  ww  .j  a  v a 2  s  .  c  o  m*/
        }

        public void onDrawerOpened(View drawerView) {
            invalidateOptionsMenu();
        }
    };

    drawerHeader = new AccountHeaderBuilder().withActivity(this).withCompactStyle(true)
            .withAccountHeader(R.layout.smaller_header).withSavedInstance(savedInstanceState)
            .withProfileImagesVisible(false)
            .withHeaderBackground(new ColorDrawable(getResources().getColor(R.color.accentColor)))
            .withOnAccountHeaderListener(new AccountHeader.OnAccountHeaderListener() {

                @Override
                public boolean onProfileChanged(View view, IProfile profile, boolean currentProfile) {

                    //Add new profile
                    if (profile.getIdentifier() == 101) {
                        new MaterialDialog.Builder(GpsMainActivity.this)
                                .title(getString(R.string.profile_create_new))
                                .inputType(InputType.TYPE_CLASS_TEXT).negativeText(R.string.cancel)
                                .input("", "", false, new MaterialDialog.InputCallback() {
                                    @Override
                                    public void onInput(@NonNull MaterialDialog materialDialog,
                                            CharSequence charSequence) {
                                        String profileName = charSequence.toString().trim();
                                        if (!Strings.isNullOrEmpty(profileName)) {
                                            final String[] ReservedChars = { "|", "\\", "?", "*", "<", "\"",
                                                    ":", ">", ".", "/", "'", ";" };

                                            for (String c : ReservedChars) {
                                                profileName = profileName.replace(c, "");
                                            }

                                            EventBus.getDefault()
                                                    .post(new ProfileEvents.CreateNewProfile(profileName));
                                        }
                                    }
                                }).show();
                        return true;
                    }

                    //Clicked on profile name
                    String newProfileName = profile.getName().getText();
                    EventBus.getDefault().post(new ProfileEvents.SwitchToProfile(newProfileName));

                    refreshProfileIcon(profile.getName().getText());
                    return true;
                }
            })
            .withOnAccountHeaderItemLongClickListener(new AccountHeader.OnAccountHeaderItemLongClickListener() {
                @Override
                public boolean onProfileLongClick(View view, final IProfile iProfile, boolean b) {
                    if (iProfile.getIdentifier() > 150) {

                        if (preferenceHelper.getCurrentProfileName().equals(iProfile.getName().getText())) {
                            Dialogs.alert(getString(R.string.sorry),
                                    getString(R.string.profile_switch_before_delete), GpsMainActivity.this);
                        } else {
                            new MaterialDialog.Builder(GpsMainActivity.this)
                                    .title(getString(R.string.profile_delete))
                                    .content(iProfile.getName().getText()).positiveText(R.string.ok)
                                    .negativeText(R.string.cancel)
                                    .onPositive(new MaterialDialog.SingleButtonCallback() {
                                        @Override
                                        public void onClick(@NonNull MaterialDialog materialDialog,
                                                @NonNull DialogAction dialogAction) {
                                            EventBus.getDefault().post(new ProfileEvents.DeleteProfile(
                                                    iProfile.getName().getText()));
                                        }
                                    }).show();
                        }
                    }
                    return false;
                }
            }).build();

    populateProfilesList();

    materialDrawer = new DrawerBuilder().withActivity(this).withSavedInstance(savedInstanceState)
            .withToolbar(getToolbar()).withActionBarDrawerToggle(drawerToggle).withDrawerGravity(Gravity.LEFT)
            .withAccountHeader(drawerHeader).withSelectedItem(-1).build();

    materialDrawer.addItem(GpsLoggerDrawerItem.newPrimary(R.string.pref_general_title,
            R.string.pref_general_summary, R.drawable.settings, 1000));
    materialDrawer.addItem(GpsLoggerDrawerItem.newPrimary(R.string.pref_logging_title,
            R.string.pref_logging_summary, R.drawable.loggingsettings, 1001));
    materialDrawer.addItem(GpsLoggerDrawerItem.newPrimary(R.string.pref_performance_title,
            R.string.pref_performance_summary, R.drawable.performance, 1002));
    materialDrawer.addItem(new DividerDrawerItem());

    materialDrawer.addItem(GpsLoggerDrawerItem.newPrimary(R.string.pref_autosend_title,
            R.string.pref_autosend_summary, R.drawable.autosend, 1003));
    materialDrawer.addItem(
            GpsLoggerDrawerItem.newSecondary(R.string.gdocs_setup_title, R.drawable.googledrive, 1004));
    materialDrawer
            .addItem(GpsLoggerDrawerItem.newSecondary(R.string.dropbox_setup_title, R.drawable.dropbox, 1005));
    materialDrawer.addItem(GpsLoggerDrawerItem.newSecondary(R.string.autoemail_title, R.drawable.email, 1006));
    materialDrawer
            .addItem(GpsLoggerDrawerItem.newSecondary(R.string.autoftp_setup_title, R.drawable.ftp, 1007));
    materialDrawer
            .addItem(GpsLoggerDrawerItem.newSecondary(R.string.opengts_setup_title, R.drawable.opengts, 1008));
    materialDrawer.addItem(
            GpsLoggerDrawerItem.newSecondary(R.string.osm_setup_title, R.drawable.openstreetmap, 1009));
    materialDrawer.addItem(
            GpsLoggerDrawerItem.newSecondary(R.string.owncloud_setup_title, R.drawable.owncloud, 1010));
    materialDrawer.addItem(new DividerDrawerItem());

    materialDrawer
            .addStickyFooterItem(GpsLoggerDrawerItem.newSecondary(R.string.menu_faq, R.drawable.helpfaq, 1011));
    materialDrawer
            .addStickyFooterItem(GpsLoggerDrawerItem.newSecondary(R.string.menu_exit, R.drawable.exit, 1012));

    materialDrawer.setOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
        @Override
        public boolean onItemClick(View view, int i, IDrawerItem iDrawerItem) {

            switch (iDrawerItem.getIdentifier()) {
            case 1000:
                launchPreferenceScreen(MainPreferenceActivity.PREFERENCE_FRAGMENTS.GENERAL);
                break;
            case 1001:
                launchPreferenceScreen(MainPreferenceActivity.PREFERENCE_FRAGMENTS.LOGGING);
                break;
            case 1002:
                launchPreferenceScreen(MainPreferenceActivity.PREFERENCE_FRAGMENTS.PERFORMANCE);
                break;
            case 1003:
                launchPreferenceScreen(MainPreferenceActivity.PREFERENCE_FRAGMENTS.UPLOAD);
                break;
            case 1004:
                launchPreferenceScreen(MainPreferenceActivity.PREFERENCE_FRAGMENTS.GDOCS);
                break;
            case 1005:
                launchPreferenceScreen(MainPreferenceActivity.PREFERENCE_FRAGMENTS.DROPBOX);
                break;
            case 1006:
                launchPreferenceScreen(MainPreferenceActivity.PREFERENCE_FRAGMENTS.EMAIL);
                break;
            case 1007:
                launchPreferenceScreen(MainPreferenceActivity.PREFERENCE_FRAGMENTS.FTP);
                break;
            case 1008:
                launchPreferenceScreen(MainPreferenceActivity.PREFERENCE_FRAGMENTS.OPENGTS);
                break;
            case 1009:
                launchPreferenceScreen(MainPreferenceActivity.PREFERENCE_FRAGMENTS.OSM);
                break;
            case 1010:
                launchPreferenceScreen(MainPreferenceActivity.PREFERENCE_FRAGMENTS.OWNCLOUD);
                break;
            case 1011:
                Intent faqtivity = new Intent(getApplicationContext(), Faqtivity.class);
                startActivity(faqtivity);
                break;
            case 1012:
                EventBus.getDefault().post(new CommandEvents.RequestStartStop(false));
                finish();
                break;

            }
            return false;
        }
    });

    ImageButton helpButton = (ImageButton) findViewById(R.id.imgHelp);
    helpButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent faqtivity = new Intent(getApplicationContext(), Faqtivity.class);
            startActivity(faqtivity);
        }
    });

}

From source file:fr.paug.droidcon.ui.BaseActivity.java

private void populateAccountList(List<Account> accounts) {
    mAccountListContainer.removeAllViews();

    LayoutInflater layoutInflater = LayoutInflater.from(this);
    for (Account account : accounts) {
        View itemView = layoutInflater.inflate(R.layout.list_item_account, mAccountListContainer, false);
        ((TextView) itemView.findViewById(R.id.profile_email_text)).setText(account.name);
        final String accountName = account.name;
        itemView.setOnClickListener(new View.OnClickListener() {
            @Override// w  w  w. ja v a  2s  .co m
            public void onClick(View view) {
                ConnectivityManager cm = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);
                NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
                if (activeNetwork == null || !activeNetwork.isConnected()) {
                    // if there's no network, don't try to change the selected account
                    Toast.makeText(BaseActivity.this, R.string.no_connection_cant_login, Toast.LENGTH_SHORT)
                            .show();
                    mDrawerLayout.closeDrawer(Gravity.START);
                    return;
                } else {
                    LOGD(TAG, "User requested switch to account: " + accountName);
                    AccountUtils.setActiveAccount(BaseActivity.this, accountName);
                    onAccountChangeRequested();
                    startLoginProcess();
                    mAccountBoxExpanded = false;
                    setupAccountBoxToggle();
                    mDrawerLayout.closeDrawer(Gravity.START);
                    setupAccountBox();
                }
            }
        });
        mAccountListContainer.addView(itemView);
    }
}

From source file:nf.frex.android.FrexActivity.java

private void preparePropertiesDialog(final Dialog dialog) {

    final Registry<Fractal> fractals = Registries.fractals;
    int fractalTypeIndex = fractals.getIndex(view.getFractalId());

    final Spinner fractalTypeSpinner = (Spinner) dialog.findViewById(R.id.fractal_type_spinner);
    final SeekBar iterationsSeekBar = (SeekBar) dialog.findViewById(R.id.num_iterations_seek_bar);
    final EditText iterationsEditText = (EditText) dialog.findViewById(R.id.num_iterations_edit_text);
    final CheckBox juliaModeCheckBox = (CheckBox) dialog.findViewById(R.id.julia_mode_fractal_check_box);
    final CheckBox decoratedFractal = (CheckBox) dialog.findViewById(R.id.decorated_fractal_check_box);
    final Button okButton = (Button) dialog.findViewById(R.id.ok_button);
    final Button cancelButton = (Button) dialog.findViewById(R.id.cancel_button);

    juliaModeCheckBox.setEnabled(true);// w w  w .  j  a va2  s  .  c o m

    ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item,
            fractals.getIds());
    arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    fractalTypeSpinner.setAdapter(arrayAdapter);
    fractalTypeSpinner.setSelection(fractalTypeIndex, true);
    fractalTypeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View spinnerView, int position, long id) {
            Fractal fractal = fractals.getValue(position);
            iterationsEditText.setText(fractal.getDefaultIterMax() + "");
            boolean sameFractal = view.getFractalId().equals(fractals.getId(position));
            if (!sameFractal) {
                juliaModeCheckBox.setChecked(false);
            }
            juliaModeCheckBox.setEnabled(sameFractal);
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });

    iterationsEditText.setText(view.getIterMax() + "", TextView.BufferType.NORMAL);

    final double iterationsMin = 1;
    final double iterationsMax = 3;
    final SeekBarConfigurer iterationsSeekBarConfigurer = SeekBarConfigurer.create(iterationsSeekBar,
            iterationsMin, iterationsMax, true, view.getIterMax());
    iterationsSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            if (fromUser) {
                int iterMax = iterationsSeekBarConfigurer.getValueInt();
                iterationsEditText.setText(iterMax + "", TextView.BufferType.NORMAL);
            }
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
        }
    });

    iterationsEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            try {
                int iterMax = Integer.parseInt(v.getText().toString());
                iterationsSeekBarConfigurer.setValue(iterMax);
                return true;
            } catch (NumberFormatException e) {
                return false;
            }
        }
    });

    decoratedFractal.setChecked(view.isDecoratedFractal());

    juliaModeCheckBox.setChecked(view.isJuliaModeFractal());

    okButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            int iterMax;
            try {
                iterMax = Integer.parseInt(iterationsEditText.getText().toString());
            } catch (NumberFormatException e) {
                Toast.makeText(FrexActivity.this, getString(R.string.error_msg, e.getLocalizedMessage()),
                        Toast.LENGTH_SHORT).show();
                return;
            }
            dialog.dismiss();
            String oldConfigName = view.getConfigName();
            String newFractalId = fractals.getId(fractalTypeSpinner.getSelectedItemPosition());
            Fractal fractal = fractals.getValue(fractalTypeSpinner.getSelectedItemPosition());
            String oldFractalId = view.getFractalId();
            boolean newJuliaModeFractal = juliaModeCheckBox.isChecked();
            boolean oldJuliaModeFractal = view.isJuliaModeFractal();
            view.setFractalId(newFractalId);
            view.setIterMax(iterMax);
            view.setDecoratedFractal(decoratedFractal.isChecked());
            view.setJuliaModeFractal(newJuliaModeFractal);
            boolean fractalTypeChanged = !oldFractalId.equals(newFractalId);
            if (fractalTypeChanged) {
                if (oldConfigName.contains(oldFractalId.toLowerCase())) {
                    view.setConfigName(newFractalId.toLowerCase());
                }
                view.setRegion(fractal.getDefaultRegion());
                view.setBailOut(fractal.getDefaultBailOut());
            }
            boolean juliaModeChanged = oldJuliaModeFractal != newJuliaModeFractal;
            if (fractalTypeChanged || juliaModeChanged) {
                view.getRegionHistory().clear();
                view.getRegionHistory().add(fractal.getDefaultRegion().clone());
            }
            view.recomputeAll();
        }
    });
    cancelButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog.dismiss();
        }
    });
}

From source file:nf.frex.android.FrexActivity.java

private void prepareDecorationsDialog(final Dialog dialog) {
    final Registry<DistanceFunction> distanceFunctions = Registries.distanceFunctions;
    int checkedIndex = distanceFunctions.getIndex(view.getDistanceFunctionId());

    ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item,
            distanceFunctions.getIds());
    arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

    final Spinner distanceFunctionSpinner = (Spinner) dialog.findViewById(R.id.distance_function_spinner);
    distanceFunctionSpinner.setAdapter(arrayAdapter);
    distanceFunctionSpinner.setSelection(checkedIndex, false);

    final SeekBarConfigurer dilationSeekBarConfigurer = SeekBarConfigurer.create(
            (SeekBar) dialog.findViewById(R.id.dilation_seek_bar), -3.0, 1.0, true, view.getDistanceDilation());
    final SeekBarConfigurer translateXSeekBarConfigurer = SeekBarConfigurer.create(
            (SeekBar) dialog.findViewById(R.id.transl_x_seek_bar), -2.5, 2.5, false,
            view.getDistanceTranslateX());
    final SeekBarConfigurer translateYSeekBarConfigurer = SeekBarConfigurer.create(
            (SeekBar) dialog.findViewById(R.id.transl_y_seek_bar), -2.5, 2.5, false,
            view.getDistanceTranslateY());

    final CheckBox turbulenceCheckBox = (CheckBox) dialog.findViewById(R.id.turbulence);
    turbulenceCheckBox.setChecked(view.getGeneratorConfig().isTurbulenceEnabled());

    final SeekBarConfigurer turbIntensSeekBarConfigurer = SeekBarConfigurer.create(
            (SeekBar) dialog.findViewById(R.id.turb_intens_seek_bar), -1.0, 1.0, true,
            view.getGeneratorConfig().getTurbulenceIntensity());
    final SeekBarConfigurer turbScaleSeekBarConfigurer = SeekBarConfigurer.create(
            (SeekBar) dialog.findViewById(R.id.turb_scale_seek_bar), -1.0, 1.0, true,
            view.getGeneratorConfig().getTurbulenceScale());

    Button randomButton = (Button) dialog.findViewById(R.id.random_button);
    randomButton.setOnClickListener(new View.OnClickListener() {
        @Override/*from  w  w  w.  ja v a2  s  .  co  m*/
        public void onClick(View v) {
            distanceFunctionSpinner.setSelection((int) (Math.random() * distanceFunctions.getSize()));
            dilationSeekBarConfigurer.setRandomValue();
            translateXSeekBarConfigurer.setRandomValue();
            translateYSeekBarConfigurer.setRandomValue();
            if (Math.random() < 0.5) {
                turbIntensSeekBarConfigurer.setRandomValue();
                turbScaleSeekBarConfigurer.setRandomValue();
            }
        }
    });

    Button okButton = (Button) dialog.findViewById(R.id.ok_button);
    okButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            int index = distanceFunctionSpinner.getSelectedItemPosition();
            dialog.dismiss();
            view.setDecoratedFractal(true);
            view.setDistanceFunctionId(distanceFunctions.getId(index));
            view.setDistanceDilation(dilationSeekBarConfigurer.getValue());
            view.setDistanceTranslateX(translateXSeekBarConfigurer.getValue());
            view.setDistanceTranslateY(translateYSeekBarConfigurer.getValue());
            view.getGeneratorConfig().setTurbulenceEnabled(turbulenceCheckBox.isChecked());
            view.getGeneratorConfig().setTurbulenceIntensity(turbIntensSeekBarConfigurer.getValue());
            view.getGeneratorConfig().setTurbulenceScale(turbScaleSeekBarConfigurer.getValue());
            view.recomputeAll();
        }
    });
    Button cancelButton = (Button) dialog.findViewById(R.id.cancel_button);
    cancelButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog.dismiss();
        }
    });
}

From source file:com.javielinux.tweettopics2.TweetTopicsActivity.java

public void refreshActionBarColumns() {

    int currentPosition = pager.getCurrentItem();

    layoutBackgroundColumnsBar.removeAllViews();

    int padding = (int) getResources().getDimension(R.dimen.default_padding);
    //int sizeButton = (int) getResources().getDimension(R.dimen.actionbar_columns_height);

    for (int i = 1; i < fragmentAdapter.getFragmentList().size(); i++) {

        ImageView view = new ImageView(this);
        view.setPadding(padding, padding, padding, padding);
        view.setImageBitmap(ColumnsUtils.getButtonWithTitle(this, fragmentAdapter.getFragmentList().get(i),
                true, currentPosition == i ? Color.GREEN : Color.BLACK));
        view.setTag(i);/*from   www. j  av  a 2  s.com*/
        view.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (layoutMainOptionsColumns.getVisibility() != View.VISIBLE) {
                    showActionBarIndicatorAndMovePager((Integer) view.getTag());
                }
            }
        });
        view.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View view) {
                int pos = (Integer) view.getTag();
                int[] loc = new int[2];
                view.getLocationOnScreen(loc);
                showOptionsColumns(loc[0], pos, true);
                return false;
            }
        });
        layoutBackgroundColumnsBar.addView(view);
    }
}

From source file:com.vuze.android.remote.fragment.TorrentListFragment.java

private void setupExpando(View view, int id_header, int id_body) {
    ViewGroup vgHeader = (ViewGroup) view.findViewById(id_header);
    final ViewGroup vgBody = (ViewGroup) view.findViewById(id_body);
    if (vgBody == null || vgHeader == null) {
        return;/*from  www.  j  a v a  2  s .c o m*/
    }
    listHeaderViewGroups.add(vgHeader);
    vgHeader.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            sidelistInFocus = true;
            // Consume touch event if user clicked the active sidelist view to
            // expand it
            // Otherwise, the active sidelist content would be collaped
            return expandSideListWidth(true) && sidebarViewActive == vgBody;
        }
    });
    vgHeader.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (!sidelistIsExpanded && canSideListExpand()) {
                return;
            }
            boolean same = sidebarViewActive == vgBody;
            if (sidebarViewActive != null) {
                sidebarViewActive.setVisibility(View.GONE);
            }
            if (same) {
                sidebarViewActive = null;
                if (hideUnselectedSideHeaders) {
                    for (ViewGroup vgHeader : listHeaderViewGroups) {
                        vgHeader.setVisibility(View.VISIBLE);
                    }
                }
            } else {
                vgBody.setVisibility(View.VISIBLE);
                sidebarViewActive = vgBody;

                if (hideUnselectedSideHeaders) {
                    for (ViewGroup vgHeader : listHeaderViewGroups) {
                        vgHeader.setVisibility(vgHeader == v ? View.VISIBLE : View.GONE);
                    }
                }
            }

            if (tvSideFilterText != null && listSideFilter != null) {
                tvSideFilterText.setVisibility(tvSideFilterText.getText().length() == 0
                        && ((View) listSideFilter).getVisibility() == View.GONE ? View.GONE : View.VISIBLE);
            }

        }
    });
}

From source file:com.dragon4.owo.ar_trace.ARCore.MixView.java

public void initButtonViews() {
    parentButtonView = (LinearLayout) mainArView.findViewById(R.id.ar_mixview_parent_buttonview);
    parentCategoryView = (LinearLayout) mainArView.findViewById(R.id.ar_mixview_parent_categoryview);

    mainArView.findViewById(R.id.ar_mixview_search_erase).setOnClickListener(new View.OnClickListener() {
        @Override//from   w w  w .j av  a2 s  .co  m
        public void onClick(View view) {
            searchText.setText("");
        }
    });

    mainArView.findViewById(R.id.ar_mixview_category).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            parentButtonView.setVisibility(View.GONE);
            parentCategoryView.setVisibility(View.VISIBLE);
        }
    });
    mainArView.findViewById(R.id.ar_mixview_category_hide).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            parentCategoryView.setVisibility(View.GONE);
            parentButtonView.setVisibility(View.VISIBLE);
        }
    });

    mainArView.findViewById(R.id.ar_mixview_write_review).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

            // TODO: 2017. 2. 12. wrieReviewActivity

            NGeoPoint nGeoPoint = naverFragment.getCurrentLocation();
            if (nGeoPoint == null)
                Toast.makeText(context, "? ?  ? .",
                        Toast.LENGTH_SHORT).show();
            else {
                Intent intent = new Intent(context, SearchCategoryListActivity.class);

                intent.putExtra("lat", nGeoPoint.getLatitude());
                intent.putExtra("lon", nGeoPoint.getLongitude());
                mainArView.setVisibility(View.GONE);
                ((Activity) context).startActivityForResult(intent, WRITE_REVIEW);
            }
        }
    });

    buttonViewLayout = (LinearLayout) mainArView.findViewById(R.id.ar_mixview_buttonview);
    final Button hideBtn = (Button) mainArView.findViewById(R.id.ar_mixview_buttonview_hide);
    hideBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (buttonViewLayout.getVisibility() == View.GONE) {
                buttonViewLayout.setVisibility(View.VISIBLE);
                hideBtn.setBackgroundResource(R.drawable.icon_menu_up);
            } else if (buttonViewLayout.getVisibility() == View.VISIBLE) {
                buttonViewLayout.setVisibility(View.GONE);
                hideBtn.setBackgroundResource(R.drawable.icon_menu_down);
            }
        }
    });
}

From source file:fr.paug.droidcon.ui.BaseActivity.java

private View makeNavDrawerItem(final int itemId, ViewGroup container) {
    boolean selected = getSelfNavDrawerItem() == itemId;
    int layoutToInflate = 0;
    if (itemId == NAVDRAWER_ITEM_SEPARATOR) {
        layoutToInflate = R.layout.navdrawer_separator;
    } else if (itemId == NAVDRAWER_ITEM_SEPARATOR_SPECIAL) {
        layoutToInflate = R.layout.navdrawer_separator;
    } else {// w w w. java2  s .co m
        layoutToInflate = R.layout.navdrawer_item;
    }
    View view = getLayoutInflater().inflate(layoutToInflate, container, false);

    if (isSeparator(itemId)) {
        // we are done
        UIUtils.setAccessibilityIgnore(view);
        return view;
    }

    ImageView iconView = (ImageView) view.findViewById(R.id.icon);
    TextView titleView = (TextView) view.findViewById(R.id.title);
    int iconId = itemId >= 0 && itemId < NAVDRAWER_ICON_RES_ID.length ? NAVDRAWER_ICON_RES_ID[itemId] : 0;
    int titleId = itemId >= 0 && itemId < NAVDRAWER_TITLE_RES_ID.length ? NAVDRAWER_TITLE_RES_ID[itemId] : 0;

    // set icon and text
    iconView.setVisibility(iconId > 0 ? View.VISIBLE : View.GONE);
    if (iconId > 0) {
        iconView.setImageResource(iconId);
    }
    titleView.setText(getString(titleId));

    formatNavDrawerItem(view, itemId, selected);

    view.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onNavDrawerItemClicked(itemId);
        }
    });

    return view;
}

From source file:com.dragon4.owo.ar_trace.ARCore.MixView.java

public void initSearchbar() {
    final ListView searchListView = (ListView) mainArView.findViewById(R.id.ar_mixview_search_list);

    searchbar = (LinearLayout) mainArView.findViewById(R.id.ar_mixview_searchbar);
    hideSearchbar = (Button) mainArView.findViewById(R.id.ar_mixview_hide_searchbar);
    searchBtn = (Button) mainArView.findViewById(R.id.ar_mixview_search);
    searchBtn.setOnClickListener(new View.OnClickListener() {
        @Override/*from  ww w  .  j  a v a2  s.co  m*/
        public void onClick(View view) {
            parentButtonView.setVisibility(View.GONE);
            searchbar.setVisibility(View.VISIBLE);
        }
    });
    hideSearchbar.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            searchbar.setVisibility(View.GONE);
            parentButtonView.setVisibility(View.VISIBLE);
        }
    });

    searchText = (EditText) mainArView.findViewById(R.id.ar_mixview_search_text);
    searchText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, android.view.KeyEvent event) {
            switch (actionId) {
            case EditorInfo.IME_ACTION_SEARCH:
                String queryString = searchText.getText().toString();
                Intent intent = new Intent(context, SearchKeywordListActivity.class);
                intent.putExtra("searchName", queryString);
                InputMethodManager imm = (InputMethodManager) context
                        .getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(mainArView.getWindowToken(), 0);
                mainArView.setVisibility(View.GONE);
                ((Activity) context).startActivityForResult(intent, SEARCH_LIST);
                break;
            default:
                Toast.makeText(context, "", Toast.LENGTH_LONG).show();
                return false;
            }
            return true;
        }
    });

    TextWatcher watcher = new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

        }

        @Override
        public void onTextChanged(final CharSequence charSequence, int i, int i1, int i2) {
            new Thread(new Runnable() {
                @Override
                public void run() {
                    String queryString = searchText.getText().toString();
                    try {
                        List<ARMarker> searchList = null;
                        String encodedQueryString = URLEncoder.encode(queryString, "UTF-8");

                        String tempCallbackUrl = "http://ac.map.naver.com/ac?q=" + encodedQueryString
                                + "&st=10&r_lt=10&r_format=json";
                        String rawData = new NaverHttpHandler().execute(tempCallbackUrl).get();
                        Log.i("rawData", rawData);

                        JSONObject root = new JSONObject(rawData);
                        JSONArray dataArray = root.getJSONArray("items");
                        JSONArray locationData = dataArray.getJSONArray(0);

                        Log.i("dataArray", locationData.toString());

                        final ArrayList<String> list = new ArrayList<>();
                        for (int index = 0; index < locationData.length(); index++)
                            list.add(locationData.getString(index).substring(2,
                                    locationData.getString(index).length() - 2));

                        ((Activity) context).runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                SearchViewAdapter adapter = new SearchViewAdapter(inflater);
                                adapter.setDataList(list);
                                adapter.setCurrentText(charSequence.toString());
                                searchListView.setAdapter(adapter);
                                searchListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                                    @Override
                                    public void onItemClick(AdapterView<?> adapterView, View view, int i,
                                            long l) {
                                        String queryString = list.get(i);
                                        searchText.setText(queryString);
                                    }
                                });
                            }
                        });
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    } catch (ExecutionException e) {
                        e.printStackTrace();
                    } catch (UnsupportedEncodingException e) {
                        e.printStackTrace();
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                }
            }).start();
        }

        @Override
        public void afterTextChanged(Editable editable) {

        }
    };
    searchText.addTextChangedListener(watcher);
}

From source file:com.dragon4.owo.ar_trace.ARCore.MixView.java

public void initNaverMap() {
    naverFragment = new FragmentMapview();
    naverFragment.setArguments(new Bundle());

    final Button expandView = (Button) mainArView.findViewById(R.id.ar_mixview_naverview_expand);
    expandView.setOnClickListener(new View.OnClickListener() {
        boolean isFull = false;

        @Override/*ww  w  . j a  v  a2 s.c o  m*/
        public void onClick(View view) {
            RelativeLayout navermapWrapper = (RelativeLayout) mainArView
                    .findViewById(R.id.ar_mixview_naverview_wrapper);
            if (isFull) {
                RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
                        (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, naver_map_width,
                                Resources.getSystem().getDisplayMetrics()),
                        (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, naver_map_height,
                                Resources.getSystem().getDisplayMetrics()));
                int tenMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10,
                        Resources.getSystem().getDisplayMetrics());
                params.setMargins(0, tenMargin, tenMargin, 0);
                params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
                params.addRule(RelativeLayout.ALIGN_PARENT_TOP);
                navermapWrapper.setLayoutParams(params);
                expandView.setBackgroundResource(R.drawable.ic_minimap_zoom_in);
                isFull = false;
            } else {
                RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT,
                        LayoutParams.MATCH_PARENT);
                params.setMargins(0, 0, 0, 0);
                navermapWrapper.setLayoutParams(params);
                expandView.setBackgroundResource(R.drawable.ic_minimap_zoom_out);
                isFull = true;
            }
        }
    });

    try {
        FragmentTransaction fragmentTransaction = ((FragmentActivity) context).getSupportFragmentManager()
                .beginTransaction();
        fragmentTransaction.add(R.id.ar_mixview_naverview, naverFragment);
        fragmentTransaction.commit();
    } catch (Exception e) {
        e.printStackTrace();
        Log.i(TAG, "Only FragmentActivity can use naver maps");
    }
}