List of usage examples for android.view View setClickable
public void setClickable(boolean clickable)
From source file:com.tiancaicc.springfloatingactionmenu.SpringFloatingActionMenu.java
private View generateRevealCircle() { int diameter = mFAB.getType() == FloatingActionButton.TYPE_NORMAL ? Utils.getDimension(mContext, R.dimen.fab_size_normal) : Utils.getDimension(mContext, R.dimen.fab_size_mini); View view = new View(mContext); OvalShape ovalShape = new OvalShape(); ShapeDrawable shapeDrawable = new ShapeDrawable(ovalShape); shapeDrawable.getPaint().setColor(ContextCompat.getColor(mContext, mRevealColor)); view.setBackgroundDrawable(shapeDrawable); LayoutParams lp = new LayoutParams(diameter, diameter); view.setLayoutParams(lp);//w w w . j a v a 2 s . c o m // Make view clickable to avoid clicks on any view located behind the menu view.setClickable(true); // note it is invisible, but will be visible while animating view.setVisibility(View.GONE); return view; }
From source file:com.facebook.litho.MountState.java
/** * Installs the click listeners that will dispatch the click handler * defined in the component's props. Unconditionally set the clickable * flag on the view./*from ww w .ja v a 2 s . co m*/ */ private static void setClickHandler(EventHandler<ClickEvent> clickHandler, View view) { if (clickHandler == null) { return; } ComponentClickListener listener = getComponentClickListener(view); if (listener == null) { listener = new ComponentClickListener(); setComponentClickListener(view, listener); } listener.setEventHandler(clickHandler); view.setClickable(true); }
From source file:it.gmariotti.cardslib.library.view.CardViewNative.java
/** * Reset all partial listeners//from w ww.j a v a 2s . c o m */ protected void resetPartialListeners() { View viewClickable = decodeAreaOnClickListener(Card.CLICK_LISTENER_HEADER_VIEW); if (viewClickable != null) viewClickable.setClickable(false); viewClickable = decodeAreaOnClickListener(Card.CLICK_LISTENER_THUMBNAIL_VIEW); if (viewClickable != null) viewClickable.setClickable(false); viewClickable = decodeAreaOnClickListener(Card.CLICK_LISTENER_CONTENT_VIEW); if (viewClickable != null) viewClickable.setClickable(false); }
From source file:com.vest.album.fragment.CameraBasicFragment.java
@Override public void onClick(View view) { switch (view.getId()) { case R.id.camera_picture: { takePicture();/*from w w w . ja v a 2 s . c om*/ view.setVisibility(View.GONE); break; } case R.id.camera_cancel_btn: { callback.onPhotoError("1"); } break; case R.id.camera_sure_btn: { view.setClickable(false); view.setFocusable(false); view.setEnabled(false); sureSave(); } break; } }
From source file:com.arlib.floatingsearchview.util.view.MenuView.java
/** * Shows all the menu items that were hidden by hideIfRoomItems(boolean withAnim) * * @param withAnim/*from w ww . ja v a 2 s.co m*/ */ public void showIfRoomItems(boolean withAnim) { if (mMenu == -1) return; cancelChildAnimListAndClear(); if (mMenuItems.isEmpty()) return; anims = new ArrayList<>(); for (int i = 0; i < getChildCount(); i++) { final View currentView = getChildAt(i); if (i < mActionItems.size()) { ImageView action = (ImageView) currentView; final MenuItem actionItem = mActionItems.get(i); action.setImageDrawable(Util.setIconColor(actionItem.getIcon(), mActionIconColor)); action.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mMenuCallback != null) mMenuCallback.onMenuItemSelected(mMenuBuilder, actionItem); } }); } //todo go over logic int animDuration = withAnim ? SHOW_IF_ROOM_ITEMS_ANIM_DURATION : 0; Interpolator interpolator = new DecelerateInterpolator(); //todo check logic if (i > mActionShowAlwaysItems.size() - 1) interpolator = new LinearInterpolator(); currentView.setClickable(true); anims.add(ViewPropertyObjectAnimator.animate(currentView).addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { currentView.setTranslationX(0); } }).setInterpolator(interpolator).setDuration(animDuration).translationX(0).get()); anims.add(ViewPropertyObjectAnimator.animate(currentView).addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { currentView.setScaleX(1.0f); } }).setInterpolator(interpolator).setDuration(animDuration).scaleX(1.0f).get()); anims.add(ViewPropertyObjectAnimator.animate(currentView).addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { currentView.setScaleY(1.0f); } }).setInterpolator(interpolator).setDuration(animDuration).scaleY(1.0f).get()); anims.add(ViewPropertyObjectAnimator.animate(currentView).addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { currentView.setAlpha(1.0f); } }).setInterpolator(interpolator).setDuration(animDuration).alpha(1.0f).get()); } AnimatorSet animSet = new AnimatorSet(); //temporary, from laziness if (!withAnim) animSet.setDuration(0); animSet.playTogether(anims.toArray(new ObjectAnimator[anims.size()])); animSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (mOnVisibleWidthChanged != null) mOnVisibleWidthChanged.onVisibleWidthChanged( (getChildCount() * (int) ACTION_DIMENSION_PX) - (mHasOverflow ? Util.dpToPx(8) : 0)); } }); animSet.start(); }
From source file:com.speedtong.example.ui.chatting.ChattingActivity.java
public void start(View view) { lastSendMsg.clear();//from w w w .java 2 s. c o m if (view != null) { view.setClickable(false); gooo = true; } if (!gooo) { toast.setText("??"); toast.show(); return; } // new Thread() { // @Override // public void run() { if (MockUtil.isTimeUp()) { Log.e("Time's up", "----------------------------------------"); return; } sendTime = System.currentTimeMillis(); int index = MockUtil.getSendType(); // if (index == 0) { String txt = MockUtil.txt(); handleSendTextMessage(txt); lastSendMsg.put(K_TXT, txt); // } else if (index == 1) { long len = 428318; String path = sdpath + "/yuntongxun/image/image3.png"; lastSendMsg.put(K_LENGTH, String.valueOf(len)); lastSendMsg.put(K_PATH, path); handleSendFileAttachMessage(len, path); // } else if (index == 2) { long len = 73158; String path = sdpath + "/yuntongxun/voice/voice_91.amr"; lastSendMsg.put(K_LENGTH, String.valueOf(len)); lastSendMsg.put(K_PATH, path); handleSendFileAttachMessage(len, path); // } else if (index == 3) { long len = 1147016; String path = sdpath + "/yuntongxun/video/video_20.mp4"; lastSendMsg.put(K_LENGTH, String.valueOf(len)); lastSendMsg.put(K_PATH, path); handleSendFileAttachMessage(len, path); } // } // }.start(); }
From source file:com.bt.download.android.gui.adapters.TransferListAdapter.java
@Override public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) { Transfer item = getGroupItem(groupPosition); if (convertView == null || convertView instanceof TextView) { // convertView could be a dummy view due to an issue with the slide menu layout request order try {//from w w w . j a v a 2 s .c om convertView = View.inflate(context.get(), R.layout.view_transfer_list_item, null); } catch (Throwable e) { // creating a dummy view to avoid a force close due to a NPE // next time the "if" will try to recover the actual layout convertView = new TextView(context.get()); ((TextView) convertView).setText("Rendering error"); } } try { boolean clickable = item.getItems().size() == 0; convertView.setOnClickListener(clickable ? viewOnClickListener : null); convertView.setOnLongClickListener(clickable ? viewOnLongClickListener : null); convertView.setClickable(clickable); convertView.setLongClickable(clickable); setupGroupIndicator(convertView, isExpanded, item); convertView.setTag(item); populateGroupView(convertView, item); } catch (Throwable e) { Log.e(TAG, "Fatal error getting the group view: " + e.getMessage(), e); } return convertView; }
From source file:com.aslanoba.hwc.SettingsActivity.java
/** * Reload list control from existing settings list. */// w w w . j a v a 2s. c om public void refreshList() { // Filter the settings list to only include the settings the customer wants // to show. m_filteredSettings = new Vector<SettingsListItem>(); for (int i = 0; i < m_lstSettings.size(); i++) { SettingsListItem oItem = m_lstSettings.get(i); switch (oItem.m_iPropId) { case PropertyID.CONNECTION_AUTO_REGISTRATION_HINT: if (CustomizationHelper.getInstance().isConnectionRegistrationMethodVisible()) { m_filteredSettings.add(oItem); } break; case PropertyID.CONNECTION_SERVER_NAME: if (CustomizationHelper.getInstance().isConnectionServerNameVisible()) { m_filteredSettings.add(oItem); } break; case PropertyID.CONNECTION_USER_NAME: if (CustomizationHelper.getInstance().isConnectionUserNameVisible()) { m_filteredSettings.add(oItem); } break; case PropertyID.CONNECTION_SERVER_PORT: if (CustomizationHelper.getInstance().isConnectionServerPortVisible()) { m_filteredSettings.add(oItem); } break; case PropertyID.CONNECTION_ACTIVATION_CODE: if (CustomizationHelper.getInstance().isConnectionActivationCodeVisible()) { m_filteredSettings.add(oItem); } break; case PropertyID.CONNECTION_FARM_ID: if (CustomizationHelper.getInstance().isConnectionFarmIdVisible()) { m_filteredSettings.add(oItem); } break; case PropertyID.ADVANCED_RELAY_SVR_URL_TEMPLATE: if (CustomizationHelper.getInstance().isConnectionUrlSuffixVisible()) { m_filteredSettings.add(oItem); } break; case PropertyID.CONNECTION_PASSWORD: if (CustomizationHelper.getInstance().isConnectionPasswordVisible()) { m_filteredSettings.add(oItem); } break; case PropertyID.CONNECTION_USE_HTTPS: if (CustomizationHelper.getInstance().isConnectionHTTPSVisible()) { m_filteredSettings.add(oItem); } break; } } // Create placeholders in adapter data structure so it knows how many items // to display. We will fill in the actual display data in getView() based on the // position ArrayList<HashMap<String, String>> lst = new ArrayList<HashMap<String, String>>(); for (int i = 0; i < m_filteredSettings.size(); i++) lst.add(new HashMap<String, String>()); // While we are setting a list adapter, we are only using it to hold the // structure of the list. We will actually override its data in getView() // before displaying it. setListAdapter(new SimpleAdapter(this, lst, R.layout.settings_row, new String[] { "text1", "text2" }, new int[] { android.R.id.text1, android.R.id.text2 }) { /** * Override for the getView() method. This allows us to alter the display * attributes on a line-by-line basis. We also use this opportunity to * fill in the text fields with the right values. */ @Override public View getView(int iPos, View oConvertView, ViewGroup oParent) { SettingsListItem oItem = m_filteredSettings.get(iPos); setItemState(oItem); // create view for this row from xml layout file View oView = m_oInflater.inflate(R.layout.settings_row, null); // for some reason, the logic in this method call seems to be reversed, // but it works this way oView.setClickable(oItem.m_bLocked); // set up the label text view TextView tvLabel = (TextView) oView.findViewById(android.R.id.text1); if (tvLabel != null) { tvLabel.setText(getItemLabel(oItem)); tvLabel.setEnabled(!oItem.m_bLocked); } // set up the value text view TextView tvValue = (TextView) oView.findViewById(android.R.id.text2); if (tvValue != null) { String sValue = oItem.getDisplayText(); if (oItem.m_bPassword) tvValue.setText(sValue.length() > 0 ? "******" : ""); else tvValue.setText(sValue); tvValue.setEnabled(!oItem.m_bLocked); // Please note that attempting to setInputType here to mask the password value crashes // HTC desire HD device. To avoid that we are working around by displaying asterix in // password field. } return oView; } }); }
From source file:org.appcelerator.titanium.view.TiUIView.java
private void doSetClickable(View view, boolean clickable) { if (view == null) { return;/*from w w w. j a v a 2s .co m*/ } if (!clickable) { view.setOnClickListener(null); // This will set clickable to true in the view, so make sure it stays here so the next line turns it off. view.setClickable(false); view.setOnLongClickListener(null); view.setLongClickable(false); } else if (!(view instanceof AdapterView)) { // n.b.: AdapterView throws if click listener set. // n.b.: setting onclicklistener automatically sets clickable to true. setOnClickListener(view); setOnLongClickListener(view); } }
From source file:com.facebook.litho.MountState.java
private static void unsetViewAttributes(MountItem item) { final Component<?> component = item.getComponent(); if (!isMountViewSpec(component)) { return;/*from ww w .jav a 2s. c om*/ } final View view = (View) item.getContent(); final NodeInfo nodeInfo = item.getNodeInfo(); if (nodeInfo != null) { if (nodeInfo.getClickHandler() != null) { unsetClickHandler(view); } if (nodeInfo.getLongClickHandler() != null) { unsetLongClickHandler(view); } if (nodeInfo.getTouchHandler() != null) { unsetTouchHandler(view); } if (nodeInfo.getInterceptTouchHandler() != null) { unsetInterceptTouchEventHandler(view); } unsetViewTag(view); unsetViewTags(view, nodeInfo.getViewTags()); if (!TextUtils.isEmpty(nodeInfo.getContentDescription())) { unsetContentDescription(view); } } view.setClickable(MountItem.isViewClickable(item.getFlags())); view.setLongClickable(MountItem.isViewLongClickable(item.getFlags())); unsetFocusable(view, item); if (item.getImportantForAccessibility() != IMPORTANT_FOR_ACCESSIBILITY_AUTO) { unsetImportantForAccessibility(view); } unsetAccessibilityDelegate(view); final ViewNodeInfo viewNodeInfo = item.getViewNodeInfo(); if (viewNodeInfo != null && !isHostSpec(component)) { unsetViewPadding(view, viewNodeInfo); unsetViewBackground(view, viewNodeInfo); unsetViewForeground(view, viewNodeInfo); unsetViewLayoutDirection(view, viewNodeInfo); } }