Java Code Examples for android.view.View.setEnabled()

The following are Jave code examples for showing how to use setEnabled() of the android.view.View class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: Android-DFU-App   File: UARTButtonAdapter.java   Source Code and License Vote up 8 votes
@Override
public View getView(final int position, final View convertView, final ViewGroup parent) {
	View view = convertView;
	if (view == null) {
		final LayoutInflater inflater = LayoutInflater.from(parent.getContext());
		view = inflater.inflate(R.layout.feature_uart_button, parent, false);
	}
	view.setEnabled(isEnabled(position));
	view.setActivated(mEditMode);

	// Update image
	final Command command = (Command) getItem(position);
	final ImageView image = (ImageView) view;
	final boolean active = command != null && command.isActive();
	if (active) {
		final int icon = command.getIconIndex();
		image.setImageResource(R.drawable.uart_button);
		image.setImageLevel(icon);
	} else
		image.setImageDrawable(null);

	return view;
}
 
Example 2
Project: easlider   File: BaseTransformer.java   Source Code and License Vote up 7 votes
protected void onPreTransform(View page, float position) {
    final float width = page.getWidth();

    page.setRotationX(0);
    page.setRotationY(0);
    page.setRotation(0);
    page.setScaleX(1);
    page.setScaleY(1);
    page.setPivotX(0);
    page.setPivotY(0);
    page.setTranslationY(0);
    page.setTranslationX(isPagingEnabled() ? 0f : -width * position);

    if (hideOffscreenPages()) {
        page.setAlpha(position <= -1f || position >= 1f ? 0f : 1f);
        page.setEnabled(false);
    } else {
        page.setEnabled(true);
        page.setAlpha(1f);
    }
}
 
Example 3
Project: GitHub   File: MaterialDialog.java   Source Code and License Vote up 7 votes
protected void invalidateInputMinMaxIndicator(int currentLength, boolean emptyDisabled) {
    if (inputMinMax != null) {
        if (builder.inputMaxLength > 0) {
            inputMinMax.setText(String.format(Locale.getDefault(), "%d/%d", currentLength, builder.inputMaxLength));
            inputMinMax.setVisibility(View.VISIBLE);
        } else inputMinMax.setVisibility(View.GONE);
        final boolean isDisabled = (emptyDisabled && currentLength == 0) ||
                (builder.inputMaxLength > 0 && currentLength > builder.inputMaxLength) ||
                currentLength < builder.inputMinLength;
        final int colorText = isDisabled ? builder.inputRangeErrorColor : builder.contentColor;
        final int colorWidget = isDisabled ? builder.inputRangeErrorColor : builder.widgetColor;
        if (builder.inputMaxLength > 0)
            inputMinMax.setTextColor(colorText);
        MDTintHelper.setTint(input, colorWidget);
        final View positiveAb = getActionButton(DialogAction.POSITIVE);
        positiveAb.setEnabled(!isDisabled);
    }
}
 
Example 4
Project: Expert-Android-Programming   File: ABaseTransformer.java   Source Code and License Vote up 7 votes
/**
 * Called each {@link #transformPage(View, float)} before {{@link #onTransform(View, float)}.
 * <p>
 * The default implementation attempts to reset all view properties. This is useful when toggling transforms that do
 * not modify the same page properties. For instance changing from a transformation that applies rotation to a
 * transformation that fades can inadvertently leave a fragment stuck with a rotation or with some degree of applied
 * alpha.
 * 
 * @param page
 *            Apply the transformation to this page
 * @param position
 *            Position of page relative to the current front-and-center position of the pager. 0 is front and
 *            center. 1 is one full page position to the right, and -1 is one page position to the left.
 */
protected void onPreTransform(View page, float position) {
	final float width = page.getWidth();

	page.setRotationX(0);
	page.setRotationY(0);
	page.setRotation(0);
	page.setScaleX(1);
	page.setScaleY(1);
	page.setPivotX(0);
	page.setPivotY(0);
	page.setTranslationY(0);
	page.setTranslationX(isPagingEnabled() ? 0f : -width * position);

	if (hideOffscreenPages()) {
		page.setAlpha(position <= -1f || position >= 1f ? 0f : 1f);
		page.setEnabled(false);
	} else {
		page.setEnabled(true);
		page.setAlpha(1f);
	}
}
 
Example 5
Project: chromium-for-android-56-debug-video   File: AppMenuAdapter.java   Source Code and License Vote up 7 votes
private void setupStandardMenuItemViewHolder(StandardMenuItemViewHolder holder,
        View convertView, final MenuItem item) {
    // Set up the icon.
    Drawable icon = item.getIcon();
    holder.image.setImageDrawable(icon);
    holder.image.setVisibility(icon == null ? View.GONE : View.VISIBLE);
    holder.image.setChecked(item.isChecked());
    holder.text.setText(item.getTitle());
    holder.text.setContentDescription(item.getTitleCondensed());

    boolean isEnabled = item.isEnabled();
    // Set the text color (using a color state list).
    holder.text.setEnabled(isEnabled);
    // This will ensure that the item is not highlighted when selected.
    convertView.setEnabled(isEnabled);

    convertView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            mAppMenu.onItemClick(item);
        }
    });
}
 
Example 6
Project: FontProvider   File: FontViewHolder.java   Source Code and License Vote up 6 votes
private void startDownload(View v, boolean allowDownloadOverMetered) {
    v.setEnabled(false);

    List<String> files = FontManager.getFiles(getData(), v.getContext(), true);
    List<Long> ids = FontManager.download(getData(), files, v.getContext(), allowDownloadOverMetered);

    mBroadcastReceiver = new DownloadBroadcastReceiver(ids);

    FontViewHolder.this.itemView.getContext().registerReceiver(
            mBroadcastReceiver, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
}
 
Example 7
Project: access-brute-forcer   File: CredentialProbingTask.java   Source Code and License Vote up 6 votes
/**
 * {@inheritDoc}
 */
@Override
protected void onPreExecute() {
    //Disable action view
    for (View b : this.actionViews) {
        b.setEnabled(false);
    }
}
 
Example 8
Project: recyclerview-android   File: RecursiveEnableBehavior.java   Source Code and License Vote up 6 votes
private void setEnabledRecursively(@NonNull final View view, final boolean enabled) {
    view.setEnabled(enabled);

    if (view instanceof ViewGroup) {
        final ViewGroup viewGroup = (ViewGroup) view;
        final int childCount = viewGroup.getChildCount();
        for (int index = 0; index < childCount; index++) {
            final View child = viewGroup.getChildAt(index);
            setEnabledRecursively(child, enabled);
        }
    }
}
 
Example 9
Project: PlusGram   File: MarkersActivity.java   Source Code and License Vote up 6 votes
public void clickSave(View v) {
    if (mSlate.isEmpty()) return;

    v.setEnabled(false);
    final String filename = System.currentTimeMillis() + ".png";
    saveDrawing(filename);
    v.setEnabled(true);
}
 
Example 10
Project: simple-share-android   File: DirectoryFragment.java   Source Code and License Vote up 6 votes
@Override
public View getView(int position, View convertView, ViewGroup parent) {
	if (position < mCursorCount) {
		return getDocumentView(position, convertView, parent);
	} else {
		position -= mCursorCount;
		convertView = mFooters.get(position).getView(convertView, parent);
		// Only the view itself is disabled; contents inside shouldn't
		// be dimmed.
		convertView.setEnabled(false);
		return convertView;
	}
}
 
Example 11
Project: easyfilemanager   File: DirectoryFragment.java   Source Code and License Vote up 6 votes
@Override
public View getView(int position, View convertView, ViewGroup parent) {
	if (position < mCursorCount) {
		return getDocumentView(position, convertView, parent);
	} else {
		position -= mCursorCount;
		convertView = mFooters.get(position).getView(convertView, parent);
		// Only the view itself is disabled; contents inside shouldn't
		// be dimmed.
		convertView.setEnabled(false);
		return convertView;
	}
}
 
Example 12
Project: VerificationCodeInput   File: VerificationCodeInput.java   Source Code and License Vote up 6 votes
@Override
public void setEnabled(boolean enabled) {
    int childCount = getChildCount();

    for (int i = 0; i < childCount; i++) {
        View child = getChildAt(i);
        child.setEnabled(enabled);
    }
}
 
Example 13
Project: keepass2android   File: AfcSearchView.java   Source Code and License Vote up 6 votes
@Override
public void setEnabled(boolean enabled) {
    if (isEnabled() == enabled)
        return;

    for (View v : new View[] { mButtonSearch, mTextSearch, mButtonClear })
        v.setEnabled(enabled);
    super.setEnabled(enabled);
}
 
Example 14
Project: JewelryUI   File: FabAnimatorPreL.java   Source Code and License Vote up 6 votes
@Override
final void revealOff(final View fab, final View transformView, final RevealCallback callback) {
    SupportAnimator animator = ViewAnimationUtils.createCircularReveal(
            transformView,
            getCenterX(fab),
            getCenterY(fab),
            (float) Math.hypot(transformView.getWidth(), transformView.getHeight()) / 2,
            fab.getWidth() / 2);
    animator.setInterpolator(REVEAL_INTERPOLATOR);
    animator.addListener(new SupportAnimator.AnimatorListener() {
        @Override
        public void onAnimationStart() {
            callback.onRevealStart();
        }

        @Override
        public void onAnimationEnd() {
            transformView.setVisibility(View.INVISIBLE);
            callback.onRevealEnd();
        }

        @Override
        public void onAnimationCancel() {
            //
        }

        @Override
        public void onAnimationRepeat() {
            //
        }
    });
    if (transformView.getVisibility() == View.VISIBLE) {
        animator.setDuration((int) getRevealAnimationDuration());
        animator.start();
        transformView.setEnabled(true);
    }
}
 
Example 15
Project: CFAlertDialog   File: CFAlertDialog.java   Source Code and License Vote up 6 votes
private void setViewEnabled(ViewGroup layout, boolean enabled) {
    layout.setEnabled(enabled);
    for (int i = 0; i < layout.getChildCount(); i++) {
        View child = layout.getChildAt(i);
        if (child instanceof ViewGroup) {
            setViewEnabled((ViewGroup) child, enabled);
        } else {
            child.setEnabled(enabled);
        }
    }
}
 
Example 16
Project: SuperRecyclerView   File: SuperRecyclerAdapter.java   Source Code and License Vote up 5 votes
private void enabled(View view, Object object) {
    view.setEnabled(transformToBoolean(object));
}
 
Example 17
Project: GitHub   File: ButterKnifeTest.java   Source Code and License Vote up 5 votes
@Override public void set(@NonNull View view, Boolean value, int index) {
  view.setEnabled(value);
}
 
Example 18
Project: aos-Video   File: CustomListPreference.java   Source Code and License Vote up 5 votes
public View getView(int position, View converView, ViewGroup viewGroup){
    View v = super.getView(position, converView, viewGroup);
    v.setEnabled(isEnabled(position));
    return v;
}
 
Example 19
Project: data-mediator   File: AndroidBinder.java   Source Code and License Vote up 5 votes
@Override
protected void apply(Property prop, View view, Object newValue) {
    view.setEnabled((Boolean) newValue);
}
 
Example 20
Project: android_Json2view   File: AdapterHelper.java   Source Code and License Vote up 5 votes
public void setEnabled(int viewId, boolean enabled)
{
    View view = retrieveView(viewId);
    view.setEnabled(enabled);
}