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.grepsound.activities.MainActivity.java

private void setupNavigationDrawer(boolean locked) {
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);

    mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */
            mDrawerLayout, /* DrawerLayout object */
            mToolbar, /* nav drawer image to replace 'Up' caret */
            R.string.drawer_open, /* "open drawer" description for accessibility */
            R.string.drawer_close /* "close drawer" description for accessibility */) {

        public ColorDrawable toolbarDrawable;
        public int toolbarColor = getResources().getColor(R.color.holo_orange_light);

        public void onDrawerClosed(View view) {
            invalidateOptionsMenu(); // creates call to
            // onPrepareOptionsMenu()
            Log.i(TAG, "CLOSED");
        }/*from ww w . j av a  2 s .  c  o  m*/

        @Override
        public void onDrawerSlide(View drawerView, float slideOffset) {
            super.onDrawerSlide(drawerView, slideOffset);
            int ratioRed = Math.round(Color.red(toolbarColor) - Color.red(toolbarColor) * slideOffset);
            int ratioGreen = Math.round(Color.green(toolbarColor) - Color.green(toolbarColor) * slideOffset);
            int ratioBlue = Math.round(Color.blue(toolbarColor) - Color.blue(toolbarColor) * slideOffset);

            toolbarDrawable = new ColorDrawable(Math.round(0xFFFFFFFF * slideOffset));
            toolbarDrawable.setColor(Color.argb(255, ratioRed, ratioGreen, ratioBlue));

            getSupportActionBar().setBackgroundDrawable(toolbarDrawable);
        }

        public void onDrawerOpened(View drawerView) {
            invalidateOptionsMenu(); // creates call to
            Log.i(TAG, "OPEN");
            // onPrepareOptionsMenu()
        }

    };

    mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Log.i(TAG, "GOOD");
            if (getFragmentManager().getBackStackEntryCount() > 0)
                getFragmentManager().popBackStack();
            else {
                if (mDrawerLayout.isDrawerOpen(GravityCompat.START))
                    mDrawerLayout.closeDrawer(GravityCompat.START);
                else
                    mDrawerLayout.openDrawer(GravityCompat.START);
            }
        }
    });

    if (locked) {
        mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN);
        mDrawerLayout.setScrimColor(Color.TRANSPARENT);
    } else {
        mDrawerLayout.setDrawerListener(mDrawerToggle);
        mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
        mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
    }

    mDrawerToggle.setDrawerIndicatorEnabled(!locked);
    getSupportActionBar().setHomeButtonEnabled(!locked);
}

From source file:com.daniel.view.swipelistview.SwipeListViewTouchListener.java

/**
 * Set current item's back view//from   w  w  w.  ja  v a 2  s  .c om
 *
 * @param backView
 */
private void setBackView(View backView) {
    this.backView = backView;
    if (backView != null && frontView != null) {
        if (swipeMode == SwipeListView.SWIPE_MODE_LEFT || swipeMode == SwipeListView.SWIPE_MODE_BOTH) {
            setLeftOffset(frontView.getMeasuredWidth() - backView.getMeasuredWidth());
        } else if (swipeMode == SwipeListView.SWIPE_MODE_BOTH || swipeMode == SwipeListView.SWIPE_MODE_RIGHT) {
            setRightOffset(frontView.getMeasuredHeight() - backView.getMeasuredWidth());
        }
    }
    backView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            swipeListView.onClickBackView(downPosition);
        }
    });
}

From source file:io.oceanos.shaderbox.ShaderEditorActivity.java

private void setSymbolListener(int id, final char c) {
    findViewById(id).setOnClickListener(new View.OnClickListener() {
        @Override/*from  www.  j a va 2 s. c  o m*/
        public void onClick(View view) {
            editor.getText().insert(editor.getSelectionStart(), String.valueOf(c));
        }
    });
}

From source file:app.screen.ServiceControlFragment.java

/** wire the button to the db */
private void _wireDbButton() {
    // onClick behavior for button
    myViews.btn_testdb.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            new AsyncTask<Void, Void, Void>() {
                protected Void doInBackground(Void... voids) {

                    try {
                        getAppData().dbManager.test();
                    } catch (Exception e) {
                        AndroidUtils.logErr(IconPaths.MyApp,
                                String.format("ServiceControlFragment - problem running db test, error is: %s",
                                        e.toString()));
                    }//  ww  w  . ja va2s . c om
                    return null;
                }

                protected void onPreExecute() {
                    myViews.btn_testdb.setEnabled(false);
                }

                protected void onPostExecute(Void aVoid) {
                    myViews.btn_testdb.setEnabled(true);
                    Toast.makeText(activity, "DB Test Completed", Toast.LENGTH_SHORT).show();
                }
            }.execute();
        }
    });
}

From source file:org.cvasilak.jboss.mobile.app.fragments.RuntimeViewFragment.java

private void buildTable() {
    Map<String, List<String>> table = new HashMap<String, List<String>>();

    table.put("Server Status", Arrays.asList("Configuration", "JVM"));

    List<String> metrics = new ArrayList<String>(
            Arrays.asList("Data Sources", "JMS Destinations", "Transactions"));
    // 'Web' section metrics is compatible (for now) only with MANAGEMENT_VERSION_1
    // TODO ('Undertow' subsystem metrics can possible replace)
    if (application.getOperationsManager()
            .getVersion() == JBossOperationsManager.ManagementVersion.MANAGEMENT_VERSION_1) {
        metrics.add("Web");
    }/*from  ww w.j  a  va  2 s  .  c  o m*/

    table.put("Subsystem Metrics", metrics);

    if (application.getOperationsManager().isDomainController()) {
        table.put("Deployments", Arrays.asList("Deployment Content", "Server Groups"));
    } else {
        table.put("Deployments", Arrays.asList("Manage Deployments"));
    }

    MergeAdapter adapter = new MergeAdapter();

    // cater for domain mode and display a button
    // for the user to change the active server
    if (application.getOperationsManager().isDomainController()) {
        chooseServer = new Button(getActivity());
        chooseServer.setText(application.getOperationsManager().getDomainHost() + ":"
                + application.getOperationsManager().getDomainServer());
        chooseServer.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_servers_selection, 0);
        chooseServer.setTypeface(null, Typeface.ITALIC);
        chooseServer.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                showDomainHostChooser();
            }
        });

        adapter.addView(chooseServer);
    }

    for (Map.Entry<String, List<String>> entry : table.entrySet()) {
        // add section header
        TextView section = new TextView(getActivity());
        section.setBackgroundColor(Color.DKGRAY);
        section.setPadding(15, 10, 0, 10);
        section.setText(entry.getKey());
        adapter.addView(section);

        // add section data
        adapter.addAdapter(
                new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1, entry.getValue()));
    }

    setListAdapter(adapter);
}

From source file:dess15proj5.fau.cs.osr_amos.mobiletimerecording.ui.SelectedProjectFragment.java

/**
 * This method is called in the android lifecycle when the activity is created.
 *
 * @param savedInstanceState this param contains several key value pairs in order to save the instance state
 * methodtype initialization method/*from ww  w. j  a  va  2  s .  com*/
 */
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    setArgumentsFromSharedPreferences();
    setWidgets();
    if (attributesAreNull()) {
        setTextViewToNoProjectSelected();
    } else {
        projectNameTextView.setText(projectName);
        startStopBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (timer.isRunning()) {
                    stopCurrentSession(startStopBtn);
                } else if (isProjectRecordingExpired()) {
                    showToastFinalDateExpiredMessage();
                } else {
                    startNewSession(startStopBtn);
                }
            }

            private void startNewSession(FloatingActionButton button) {
                try {
                    SessionsDAO sessionsDAO = DataAccessObjectFactory.getInstance()
                            .createSessionsDAO(getActivity());
                    session = sessionsDAO.create(projectId, new Date());

                    SessionValidator sessionValidator = SessionValidator.getInstance(getActivity());
                    sessionValidator.checkDay(session);

                    timer.start();
                    button.setImageDrawable(
                            ContextCompat.getDrawable(getActivity(), R.drawable.ic_stop_white_24dp));
                    setRecordingBooleanInSharedPreferences(true);
                    setSessionIdInSharedPreferences(session.getId());
                } catch (SQLException e) {
                    Toast.makeText(getActivity(), "Could not start timer due to database errors!",
                            Toast.LENGTH_LONG).show();
                }
            }

            private void stopCurrentSession(FloatingActionButton button) {
                try {
                    session.setStopTime(new Date());

                    SessionsDAO sessionsDAO = DataAccessObjectFactory.getInstance()
                            .createSessionsDAO(getActivity());
                    sessionsDAO.update(session);

                    timer.stop();

                    button.setImageDrawable(
                            ContextCompat.getDrawable(getActivity(), R.drawable.ic_play_arrow_white_24dp));

                    addSessionsToAdapter();
                    setRecordingBooleanInSharedPreferences(false);
                } catch (SQLException e) {
                    Toast.makeText(getActivity(), "Could not stop timer due to database errors!",
                            Toast.LENGTH_LONG).show();
                }
            }
        });
    }
    setAdapterToSessionListView();
    setClickListenerToListView();
    addSessionsToAdapter();
    setClickListenerToFAB();
}

From source file:org.tigase.messenger.phone.pro.conversations.chat.ChatItemFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View root = inflater.inflate(R.layout.fragment_chatitem_list, container, false);
    ButterKnife.bind(this, root);

    message.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override//from www .j a  v a 2s.  co m
        public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) {
            if (id == R.id.send || id == EditorInfo.IME_NULL) {
                send();
                return true;
            }
            return false;
        }
    });
    message.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Container.setVisibility(View.GONE);
            iv_face_checked.setVisibility(View.VISIBLE);
            iv_face_normal.setVisibility(View.GONE);
        }
    });

    iv_face_normal.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Container.setVisibility(View.VISIBLE);
            iv_face_checked.setVisibility(View.VISIBLE);
            iv_face_normal.setVisibility(View.GONE);
            closeIME();
        }
    });
    iv_face_checked.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Container.setVisibility(View.GONE);
            iv_face_normal.setVisibility(View.VISIBLE);
            iv_face_checked.setVisibility(View.GONE);
        }
    });

    sendButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            send();
        }
    });
    message.addTextChangedListener(watcher);

    // recyclerView.addItemDecoration(new
    // DividerItemDecoration(getActivity(),
    // DividerItemDecoration.VERTICAL_LIST));

    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
    linearLayoutManager.setReverseLayout(true);

    recyclerView.setLayoutManager(linearLayoutManager);
    this.adapter = new MyChatItemRecyclerViewAdapter(getContext(), null, mListener) {
        @Override
        protected void onContentChanged() {
            refreshChatHistory();
        }
    };
    recyclerView.setAdapter(adapter);

    refreshChatHistory();
    return root;
}

From source file:com.klinker.android.theme_spotlight.activity.SpotlightActivity.java

private void setupDrawerButtons() {
    drawerButtons = new View[3];
    drawerButtons[0] = findViewById(R.id.evolve_button);
    drawerButtons[1] = findViewById(R.id.talon_button);
    drawerButtons[2] = findViewById(R.id.featured_button);

    drawerButtons[0].setOnClickListener(new View.OnClickListener() {
        @Override/*from w w  w  .  j a  v  a  2  s  . co  m*/
        public void onClick(View view) {
            switchFragments(0);
        }
    });
    drawerButtons[1].setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            switchFragments(1);
        }
    });
    drawerButtons[2].setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            switchFragments(2);
        }
    });
}

From source file:org.borderstone.tagtags.TTStartActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    this.setTheme(R.style.AppTheme);
    this.setContentView(R.layout.activity_start);

    Toolbar toolbar = (Toolbar) this.findViewById(R.id.toolbar);
    //toolbar.inflateMenu(R.menu.menu_start);
    toolbar.setTitle("TagTags");

    toolbar.setVisibility(View.VISIBLE);

    TTStartActivity.me = getApplicationContext();

    protocol.setAction("android.intent.action.PROTOCOL");
    settings.setAction("android.intent.action.SETTINGS");

    Constants.init(new File(this.getFilesDir(), "bsettings.txt"), this.getApplicationContext());
    Constants.fileListener = this;

    /*Load variables that are stored in a text file
      keeping version info and info about third party
      resources here, for easy editing*/
    try {/*w  ww .j av a 2s  .co m*/
        BufferedReader reader = new BufferedReader(
                new InputStreamReader(this.getResources().openRawResource(R.raw.appinfo)));

        String line = reader.readLine();

        String[] t;
        while (line != null) {
            t = line.split(":");
            if (line.startsWith("#thirdparty:"))
                thirdparty += t[1] + "\n";
            else if (line.startsWith("#recentchanges:"))
                recentchanges += "-- " + t[1] + "\n";

            line = reader.readLine();
        }

        //just to remove the final new line.
        if (!thirdparty.equals(""))
            thirdparty = thirdparty.substring(0, thirdparty.length() - 1);
        if (!recentchanges.equals(""))
            recentchanges = recentchanges.substring(0, recentchanges.length() - 1);
    } catch (Exception ignored) {
    }

    //Most of the code below is purely for aesthetics!

    txtPhilosophy = new BTitleLabel(this);
    txtPhilosophy.setTypeface(Typeface.DEFAULT_BOLD);
    txtPhilosophy.setLayoutParams(Constants.defaultParams);
    txtPhilosophy.setOnClickListener(this);
    txtPhilosophy.setTextColor(Color.BLACK);

    txtVersion = new BStandardLabel(this);
    txtVersion.setText("Recent changes:\n" + recentchanges);
    txtVersion.setLayoutParams(Constants.defaultParams);
    txtVersion.setTextColor(Color.BLACK);

    try {
        PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
        toolbar.setSubtitle("v. " + pInfo.versionName);
    } catch (PackageManager.NameNotFoundException ignored) {
    }

    toolbar.setNavigationIcon(R.drawable.drawer);

    ImageView slu = new ImageView(this);
    ImageView sites = new ImageView(this);

    slu.setImageResource(R.drawable.slulogo);
    sites.setImageResource(R.drawable.sites);

    LinearLayout llLogos = new LinearLayout(this);
    llLogos.setOrientation(LinearLayout.HORIZONTAL);
    llLogos.setGravity(Gravity.END | Gravity.CENTER_VERTICAL);

    llLogos.addView(slu);
    llLogos.addView(sites);

    setPhiloText();

    LinearLayout back = (LinearLayout) this.findViewById(R.id.back);
    back.setOrientation(LinearLayout.VERTICAL);

    txtPhilosophy.setLayoutParams(Constants.defaultParams);
    txtPhilosophy.setBackgroundResource(R.drawable.border);

    txtVersion.setLayoutParams(Constants.defaultParams);
    txtVersion.setBackgroundResource(R.drawable.border_recurring);

    back.addView(txtPhilosophy);
    back.addView(txtVersion);
    back.addView(llLogos);

    lblSettings = new BButton(this);
    lblDownload = new BButton(this);

    lblDownload.setIcon(R.drawable.download);
    lblSettings.setIcon(R.drawable.settings);

    lblSettings.setText("Settings");
    lblDownload.setText("Download from server");

    lblSettings.setOnClickListener(this);
    lblDownload.setOnClickListener(this);

    if (!checkPermissions()) {
        final Intent intro = new Intent();
        intro.setAction("android.intent.action.INTRO");

        this.startActivity(intro);
    }

    BTitleLabel lblProperties = new BTitleLabel(this);
    BTitleLabel lblLocal = new BTitleLabel(this);
    fileNavView = new BFileNavView(this, this);

    lblProperties.setTextSize(Constants.fontSize + 2);
    lblLocal.setTextSize(Constants.fontSize + 2);

    lblProperties.setText("PROPERTIES");
    lblProperties.setTextColor(Color.WHITE);
    lblProperties.setGravity(Gravity.CENTER);
    lblLocal.setText("LOCAL FILES");
    lblLocal.setTextColor(Color.WHITE);
    lblLocal.setGravity(Gravity.CENTER);

    final DrawerLayout drawerLayout = (DrawerLayout) this.findViewById(R.id.startDrawerLayout);
    final LinearLayout drawer = (LinearLayout) this.findViewById(R.id.drawer);
    drawer.setClickable(false);
    drawer.bringToFront();

    drawer.addView(lblProperties);
    drawer.addView(lblDownload);
    drawer.addView(lblSettings);
    drawer.addView(lblLocal);
    drawer.addView(fileNavView);

    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (!drawerLayout.isDrawerOpen(Gravity.LEFT))
                drawerLayout.openDrawer(Gravity.LEFT);
            else
                drawerLayout.closeDrawer(Gravity.LEFT);
        }
    });
}

From source file:org.jitsi.android.gui.call.VideoCallActivity.java

/**
 * Initializes the hangup button view./*from   www  . j a  v a 2 s  .  c om*/
 */
private void initHangupView() {
    ImageView hangupView = (ImageView) findViewById(R.id.callHangupButton);

    hangupView.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            // Start the hang up Thread, Activity will be closed later 
            // on call ended event
            CallManager.hangupCall(call);
        }
    });
}