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.rockerhieu.emojicon.EmojiconsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.emojicons, container, false);
    final ViewPager emojisPager = (ViewPager) view.findViewById(R.id.emojis_pager);
    emojisPager.setOnPageChangeListener(this);
    // we handle recents
    EmojiconRecents recents = this;
    mEmojisAdapter = new EmojisPagerAdapter(getFragmentManager(),
            Arrays.asList(EmojiconRecentsGridFragment.newInstance(mUseSystemDefault),
                    EmojiconGridFragment.newInstance(People.DATA, recents, mUseSystemDefault),
                    EmojiconGridFragment.newInstance(Nature.DATA, recents, mUseSystemDefault),
                    EmojiconGridFragment.newInstance(Objects.DATA, recents, mUseSystemDefault),
                    EmojiconGridFragment.newInstance(Places.DATA, recents, mUseSystemDefault),
                    EmojiconGridFragment.newInstance(Symbols.DATA, recents, mUseSystemDefault)));
    emojisPager.setAdapter(mEmojisAdapter);

    mEmojiTabs = new View[6];
    mEmojiTabs[0] = view.findViewById(R.id.emojis_tab_0_recents);
    mEmojiTabs[1] = view.findViewById(R.id.emojis_tab_1_people);
    mEmojiTabs[2] = view.findViewById(R.id.emojis_tab_2_nature);
    mEmojiTabs[3] = view.findViewById(R.id.emojis_tab_3_objects);
    mEmojiTabs[4] = view.findViewById(R.id.emojis_tab_4_cars);
    mEmojiTabs[5] = view.findViewById(R.id.emojis_tab_5_punctuation);
    for (int i = 0; i < mEmojiTabs.length; i++) {
        final int position = i;
        mEmojiTabs[i].setOnClickListener(new View.OnClickListener() {
            @Override//from   w  w  w.j av a  2 s . c  o  m
            public void onClick(View v) {
                emojisPager.setCurrentItem(position);
            }
        });
    }
    view.findViewById(R.id.emojis_backspace)
            .setOnTouchListener(new RepeatListener(1000, 50, new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (mOnEmojiconBackspaceClickedListener != null) {
                        mOnEmojiconBackspaceClickedListener.onEmojiconBackspaceClicked(v);
                    }
                }
            }));

    // get last selected page
    mRecentsManager = EmojiconRecentsManager.getInstance(view.getContext());
    int page = mRecentsManager.getRecentPage();
    // last page was recents, check if there are recents to use
    // if none was found, go to page 1
    if (page == 0 && mRecentsManager.size() == 0) {
        page = 1;
    }

    if (page == 0) {
        onPageSelected(page);
    } else {
        emojisPager.setCurrentItem(page, false);
    }
    return view;
}

From source file:uk.ac.hutton.ics.buntata.fragment.ImageFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_node_image, container, false);

    unbinder = ButterKnife.bind(this, view);

    if (transition && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        imageView.setTransitionName(getString(R.string.transition_node_image_view));
    }/* ww w .ja va 2  s .c o  m*/

    if (!isFullscreen) {
        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                /* If it's a leaf node, open the details activity */
                Intent intent = new Intent(getActivity().getApplicationContext(), ImageViewPagerActivity.class);

                /* Depending on the android version, transition views or just slide */
                List<Pair<View, String>> pairs = new ArrayList<>();
                pairs.add(Pair.create(view, getString(R.string.transition_node_details_view)));
                pairs.add(Pair.create(view, getString(R.string.transition_node_image_view)));

                /* Pass parameters */
                Bundle args = new Bundle();
                args.putInt(NodeDetailsActivity.PARAM_DATASOURCE_ID, datasourceId);
                args.putInt(NodeDetailsActivity.PARAM_PREFERED_FIRST_MEDIUM, mediumId);
                args.putInt(NodeDetailsActivity.PARAM_NODE_ID, nodeId);
                intent.putExtras(args);

                ActivityOptionsCompat options = ActivityOptionsCompat
                        .makeSceneTransitionAnimation(getActivity(), pairs.toArray(new Pair[pairs.size()]));

                startActivity(intent, options.toBundle());
            }
        });
    }

    return view;
}

From source file:org.anothermonitor.ActivityPreferences.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_preferences);
    mPrefs = getSharedPreferences(getString(R.string.app_name) + "Prefs", MODE_PRIVATE);
    res = getResources();// www.ja va2 s  .  co m
    navigationBarHeight = res
            .getDimensionPixelSize(res.getIdentifier("navigation_bar_height", "dimen", "android"));

    mLTabs = (LinearLayout) findViewById(R.id.LTabs);

    if (Build.VERSION.SDK_INT >= 19) {
        getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);

        sSW = res.getConfiguration().smallestScreenWidthDp;

        int statusBarHeight = res
                .getDimensionPixelSize(res.getIdentifier("status_bar_height", "dimen", "android"));

        if (!ViewConfiguration.get(this).hasPermanentMenuKey()
                && (res.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT || sSW > 560)) {
            getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
            FrameLayout nb = (FrameLayout) findViewById(R.id.LNavigationBar);
            nb.setVisibility(View.VISIBLE);
            ((FrameLayout.LayoutParams) nb.getLayoutParams()).height = navigationBarHeight;
        }

        int paddingTop = mLTabs.getPaddingTop();
        int paddingBottom = mLTabs.getPaddingBottom();
        int paddingLeft = mLTabs.getPaddingLeft();
        int paddingRight = mLTabs.getPaddingRight();
        mLTabs.setPadding(paddingLeft, paddingTop + statusBarHeight, paddingRight, paddingBottom);
    }

    findViewById(R.id.TVTabMain).setActivated(true);
    findViewById(R.id.TVTabMain).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mVP.setCurrentItem(0);
        }
    });
    findViewById(R.id.TVTabShowRecord).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mVP.setCurrentItem(1);
        }
    });

    mVP = (ViewPager) findViewById(R.id.VP);
    mVP.setAdapter(new MyPreferencesAdapter());
    //      mVP.setOffscreenPageLimit(2);
    mVP.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            int currentItem = 0;
            if (position == 1)
                currentItem = 2;
            mLTabs.getChildAt(currentItem).setActivated(true);
            mLTabs.getChildAt(previousSelected).setActivated(false);
            previousSelected = currentItem;
        }

        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
        }

        @Override
        public void onPageScrollStateChanged(int arg0) {
        }
    });
    mVP.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            mVP.getViewTreeObserver().removeGlobalOnLayoutListener(this);
            if (currentItem != -1)
                mVP.setCurrentItem(currentItem, false);
        }
    });

    if (savedInstanceState != null && !savedInstanceState.isEmpty()) {
        mB = savedInstanceState;
        currentItem = savedInstanceState.getInt(C.currentItem);

        currentItem = savedInstanceState.getInt(C.currentItem);
        currentItem = savedInstanceState.getInt(C.currentItem);
        currentItem = savedInstanceState.getInt(C.currentItem);
    }
}

From source file:com.scto.filerenamer.MainActivity.java

/** Called when the activity is first created. */
@Override/*  w w  w . j a v  a2  s  . c  o m*/
public void onCreate(Bundle savedInstanceState) {
    try {
        mSharedPreferences = Prefs.getSharedPreferences(this);
    } catch (NullPointerException e) {
        if (BuildConfig.DEBUG) {
            Log.w("[" + TAG + "]", "mSharedPreferences == NullPointerException :" + e.getMessage());
        }
    }

    mSharedPreferences.registerOnSharedPreferenceChangeListener(this);

    if (Prefs.getThemeType(this) == false) {
        mThemeId = R.style.AppTheme_Light;
        setTheme(mThemeId);
    } else {
        mThemeId = R.style.AppTheme_Dark;
        setTheme(mThemeId);
    }

    //Eula.showDisclaimer( this );
    Eula.showEula(this, getApplicationContext());

    mActionBar = getActionBar();
    if (mActionBar != null) {
        mActionBar.setDisplayHomeAsUpEnabled(false);
        mActionBar.setDisplayShowHomeEnabled(true);
        mActionBar.setDisplayShowTitleEnabled(true);
    } else {
        if (BuildConfig.DEBUG) {
            Log.w("[" + TAG + "]", "mActionBar == null");
        }
    }

    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        this.setTitle(extras.getString("dir") + " :: " + getString(R.string.app_name));
    } else {
        this.setTitle(" :: " + getString(R.string.app_name));
    }

    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    tvDisplay = (TextView) findViewById(R.id.tvDisplay);

    bRename = (Button) findViewById(R.id.bRename);
    bSettings = (Button) findViewById(R.id.bSettings);
    bHelp = (Button) findViewById(R.id.bHelp);
    bExit = (Button) findViewById(R.id.bExit);

    bRename.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Intent openAndroidFileBrowser = new Intent("com.scto.filerenamer.ANDROIDFILEBROWSER");
            openAndroidFileBrowser.putExtra("what", "renamer");
            openAndroidFileBrowser.putExtra("theme", mThemeId);
            startActivity(openAndroidFileBrowser);
        }
    });

    bSettings.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Intent openPreferencesActivity = new Intent("com.scto.filerenamer.PREFERENCESACTIVITY");
            startActivity(openPreferencesActivity);
        }
    });

    bHelp.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            FragmentManager fm = getSupportFragmentManager();
            HelpDialog helpDialog = new HelpDialog();
            helpDialog.show(fm, "dlg_help");
        }
    });

    bExit.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            FragmentManager fm = getSupportFragmentManager();
            ExitDialog exitDialog = new ExitDialog();
            exitDialog.show(fm, "dlg_exit");
        }
    });

    /*
    ChangeLog cl = new ChangeLog( this );
    if( cl.firstRun() )
    {
       cl.getLogDialog().show();
    }
    */
    init();
}

From source file:com.dgsd.android.ShiftTracker.Fragment.WeekFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_week, container, false);

    mAdapter = new WeekAdapter(getActivity(), null, mStartJulianDay);

    mList = (StickyListHeadersListView) v.findViewById(R.id.list);
    mList.setLayoutAnimation(Anim.getListViewFadeInAnimator());
    mList.setAdapter(mAdapter);/*  www. j  av a  2s .  c o  m*/
    mList.setOnItemClickListener(this);

    registerForContextMenu(mList);

    mTotalText = (TextView) v.findViewById(R.id.total_text);

    mStatsWrapper = (ViewGroup) v.findViewById(R.id.stats_wrapper);
    mStatsWrapper.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (StApp.isFreeApp(getActivity())) {
                if (mLinkToPaidAppFragment != null && mLinkToPaidAppFragment.isResumed())
                    return; //Already showing

                mLinkToPaidAppFragment = LinkToPaidAppFragment
                        .newInstance(getString(R.string.summary_unavailable_message));
                mLinkToPaidAppFragment.show(getSherlockActivity().getSupportFragmentManager(), null);
            } else {
                if (mHoursAndIncomeFragment != null && mHoursAndIncomeFragment.isResumed())
                    return; //Already showing!

                mHoursAndIncomeFragment = HoursAndIncomeSummaryFragment.newInstance(mStartJulianDay + 6);
                mHoursAndIncomeFragment.show(getSherlockActivity().getSupportFragmentManager(), null);
            }
        }
    });
    return v;
}

From source file:ua.org.gdg.devfest.iosched.ui.SessionFeedbackFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_session_feedback, null);

    mTitle = (TextView) rootView.findViewById(R.id.session_title);

    mSessionRatingFeedbackBar = RatingBarHelper.create(rootView.findViewById(R.id.session_rating_container));
    mQ1FeedbackBar = RatingBarHelper.create(rootView.findViewById(R.id.session_feedback_q1_container));
    mQ2FeedbackBar = RatingBarHelper.create(rootView.findViewById(R.id.session_feedback_q2_container));
    mQ3FeedbackBar = RatingBarHelper.create(rootView.findViewById(R.id.session_feedback_q3_container));

    mQ4RadioGroup = (RadioGroup) rootView.findViewById(R.id.session_feedback_q4);

    mComments = (EditText) rootView.findViewById(R.id.session_feedback_comments);

    if (mVariableHeightHeader) {
        View headerView = rootView.findViewById(R.id.header_session);
        ViewGroup.LayoutParams layoutParams = headerView.getLayoutParams();
        layoutParams.height = ViewGroup.LayoutParams.WRAP_CONTENT;
        headerView.setLayoutParams(layoutParams);
    }//from  w  ww.  j av a  2 s. co  m

    rootView.findViewById(R.id.submit_feedback_button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            submitAllFeedback();
            LOGD("Tracker", "Feedback: " + mTitleString);
            getActivity().finish();
        }
    });
    return rootView;
}

From source file:com.brq.wallet.activity.main.TransactionHistoryFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    _root = inflater.inflate(R.layout.main_transaction_history_view, container, false);

    _root.findViewById(R.id.btRescan).setOnClickListener(new View.OnClickListener() {
        @Override//from   w  ww  .j a  v a 2 s. com
        public void onClick(View view) {
            _mbwManager.getSelectedAccount().dropCachedData();
            _mbwManager.getWalletManager(false).startSynchronization();
        }
    });

    return _root;
}

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

/**
 * {@inheritDoc}//  ww w.  j  a va2 s.c  o  m
 */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Retrieves the call from manager.
    String callKey = getArguments().getString(EXTRA_CALL_KEY);
    Call call = CallManager.getActiveCall(callKey);

    if (call != null) {
        // Gets first media aware call peer
        Iterator<? extends CallPeer> callPeers = call.getCallPeers();
        if (callPeers.hasNext()) {
            CallPeer callPeer = callPeers.next();
            if (callPeer instanceof MediaAwareCallPeer<?, ?, ?>) {
                this.mediaAwarePeer = (MediaAwareCallPeer<?, ?, ?>) callPeer;
            }
        }
    }
    // Retrieves security control for master stream(AUDIO)
    if (mediaAwarePeer != null) {
        SrtpControl srtpCtrl = mediaAwarePeer.getMediaHandler().getEncryptionMethod(MediaType.AUDIO);

        if (srtpCtrl instanceof ZrtpControl) {
            this.masterControl = (ZrtpControl) srtpCtrl;
        }
    }

    View content = inflater.inflate(R.layout.zrtp_info_dialog, container, false);

    View confirmBtn = content.findViewById(R.id.security_confirm);
    confirmBtn.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            // Confirms / clears SAS confirmation status
            masterControl.setSASVerification(!masterControl.isSecurityVerified());

            updateVerificationStatus();
            notifySasVerified(masterControl.isSecurityVerified());
        }
    });

    getDialog().setTitle(R.string.service_gui_SECURITY_INFO);

    return content;
}

From source file:org.geometerplus.android.fbreader.bookmark.EditBookmarkActivity.java

@Override
public void onCreate(Bundle bundle) {
    super.onCreate(bundle);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.edit_bookmark);

    myBookmark = FBReaderIntents.getBookmarkExtra(getIntent());
    if (myBookmark == null) {
        finish();//from   w w  w.j a  v  a2s  .co m
        return;
    }

    final DisplayMetrics dm = getResources().getDisplayMetrics();
    final int width = Math.min((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 500, dm),
            dm.widthPixels * 9 / 10);
    final int height = Math.min((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 350, dm),
            dm.heightPixels * 9 / 10);

    final TabHost tabHost = (TabHost) findViewById(R.id.edit_bookmark_tabhost);
    tabHost.setLayoutParams(new FrameLayout.LayoutParams(new ViewGroup.LayoutParams(width, height)));
    tabHost.setup();

    addTab(tabHost, "text", R.id.edit_bookmark_content_text);
    addTab(tabHost, "style", R.id.edit_bookmark_content_style);
    addTab(tabHost, "delete", R.id.edit_bookmark_content_delete);

    final ZLStringOption currentTabOption = new ZLStringOption("LookNFeel", "EditBookmark", "text");
    tabHost.setCurrentTabByTag(currentTabOption.getValue());
    tabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() {
        public void onTabChanged(String tag) {
            if (!"delete".equals(tag)) {
                currentTabOption.setValue(tag);
            }
        }
    });

    final EditText editor = (EditText) findViewById(R.id.edit_bookmark_text);
    editor.setText(myBookmark.getText());
    final int len = editor.getText().length();
    editor.setSelection(len, len);

    final Button saveTextButton = (Button) findViewById(R.id.edit_bookmark_save_text_button);
    saveTextButton.setEnabled(false);
    saveTextButton.setText(myResource.getResource("saveText").getValue());
    saveTextButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            myCollection.bindToService(EditBookmarkActivity.this, new Runnable() {
                public void run() {
                    myBookmark.setText(editor.getText().toString());
                    myCollection.saveBookmark(myBookmark);
                    saveTextButton.setEnabled(false);
                }
            });
        }
    });
    editor.addTextChangedListener(new TextWatcher() {
        @Override
        public void onTextChanged(CharSequence sequence, int start, int before, int count) {
            final String originalText = myBookmark.getText();
            saveTextButton.setEnabled(!originalText.equals(editor.getText().toString()));
        }

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

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

    final Button deleteButton = (Button) findViewById(R.id.edit_bookmark_delete_button);
    deleteButton.setText(myResource.getResource("deleteBookmark").getValue());
    deleteButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            myCollection.bindToService(EditBookmarkActivity.this, new Runnable() {
                public void run() {
                    myCollection.deleteBookmark(myBookmark);
                    finish();
                }
            });
        }
    });
}

From source file:uk.ac.hutton.ics.buntata.activity.MainActivity.java

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

    ButterKnife.bind(this);

    /* Make sure the default preferences are set */
    PreferenceUtils.setDefaults(this);
    NodeManager.clearCaches();/* w  w w . j av  a 2 s .c  o m*/
    DatasourceService.init(this);

    /* Initialize the internal database for track history keeping */
    new LogEntryManager(this).initializeDatabase();

    DatasourceService.getAllAdvanced(this, false, false,
            new RemoteCallback<List<BuntataDatasourceAdvanced>>(this) {
                @Override
                public void onSuccess(List<BuntataDatasourceAdvanced> result) {
                    boolean updateAvailable = false;

                    for (BuntataDatasourceAdvanced adv : result) {
                        updateAvailable = adv
                                .getState() == BuntataDatasourceAdvanced.InstallState.INSTALLED_HAS_UPDATE;

                        if (updateAvailable)
                            break;
                    }

                    long timeSince = System.currentTimeMillis() - lastUpdateCheck;

                    /* Only check for updates if it has been at least 2 hours */
                    if (updateAvailable && timeSince > 1000 * 60 * 60 * 2) {
                        /* Show a Snackbar with a button to open the datasource activity */
                        int textColor = ContextCompat.getColor(MainActivity.this,
                                android.R.color.primary_text_dark);
                        SnackbarUtils.create(getSnackbarParentView(), R.string.snackbar_updates_available,
                                textColor, ContextCompat.getColor(MainActivity.this, R.color.colorPrimaryDark),
                                5000).setAction(R.string.generic_show, new View.OnClickListener() {
                                    @Override
                                    public void onClick(View v) {
                                        startActivityForResult(
                                                new Intent(getApplicationContext(), DatasourceActivity.class),
                                                REQUEST_DATA_SOURCE);
                                    }
                                }).setActionTextColor(textColor).show();

                        lastUpdateCheck = System.currentTimeMillis();
                    }
                }
            });
}