Example usage for android.view View setEnabled

List of usage examples for android.view View setEnabled

Introduction

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

Prototype

@RemotableViewMethod
public void setEnabled(boolean enabled) 

Source Link

Document

Set the enabled state of this view.

Usage

From source file:com.wuzhanglao.niubi.utils.transformer.BaseTransformer.java

/**
 * Called each {@link #transformPage(android.view.View, float)} before {{@link #onTransform(android.view.View, float)}.
 * <p>/*from   w w w  .  j  a v a 2s.  c  o  m*/
 * 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);
    if (isPagingEnabled())
        page.setTranslationX(0f);
    else
        page.setTranslationX(-width * position);

    if (hideOffscreenPages()) {
        page.setAlpha(position <= -1f || position >= 1f ? 0f : 1f);
        page.setEnabled(false);
    } else {
        page.setEnabled(true);
        page.setAlpha(1f);
    }
}

From source file:com.heqi.kharazim.ui.fragment.tab.PagerSlidingTabStrip.java

public void setAllTabEnabled(boolean isEnabled) {
    for (int i = 0; i < tabsContainer.getChildCount(); ++i) {
        View tab = tabsContainer.getChildAt(i);
        tab.setEnabled(isEnabled);
    }/*from w ww.j  a v  a  2s .c  o  m*/
}

From source file:com.battlelancer.seriesguide.ui.ShowFragment.java

private void populateShow() {
    if (mShowCursor == null) {
        return;/*from   w  ww  .j a  v a2s .  c o m*/
    }

    // title
    mShowTitle = mShowCursor.getString(ShowQuery.TITLE);
    mShowPoster = mShowCursor.getString(ShowQuery.POSTER);

    // status
    if (mShowCursor.getInt(ShowQuery.STATUS) == 1) {
        mTextViewStatus.setTextColor(getResources().getColor(
                Utils.resolveAttributeToResourceId(getActivity().getTheme(), R.attr.textColorSgGreen)));
        mTextViewStatus.setText(getString(R.string.show_isalive));
    } else {
        mTextViewStatus.setTextColor(Color.GRAY);
        mTextViewStatus.setText(getString(R.string.show_isnotalive));
    }

    // release time
    String releaseDay = mShowCursor.getString(ShowQuery.RELEASE_DAY);
    long releaseTime = mShowCursor.getLong(ShowQuery.RELEASE_TIME_MS);
    String releaseCountry = mShowCursor.getString(ShowQuery.RELEASE_COUNTRY);
    if (!TextUtils.isEmpty(releaseDay)) {
        String[] values = TimeTools.formatToShowReleaseTimeAndDay(getActivity(), releaseTime, releaseCountry,
                releaseDay);
        mTextViewReleaseTime.setText(values[1] + " " + values[0]);
    } else {
        mTextViewReleaseTime.setText(null);
    }

    // runtime
    mTextViewRuntime.setText(getString(R.string.runtime_minutes, mShowCursor.getInt(ShowQuery.RUNTIME)));

    // network
    mTextViewNetwork.setText(mShowCursor.getString(ShowQuery.NETWORK));

    // favorite button
    final boolean isFavorite = mShowCursor.getInt(ShowQuery.IS_FAVORITE) == 1;
    mButtonFavorite.setEnabled(true);
    Utils.setCompoundDrawablesRelativeWithIntrinsicBounds(mButtonFavorite, 0,
            Utils.resolveAttributeToResourceId(getActivity().getTheme(),
                    isFavorite ? R.attr.drawableStar : R.attr.drawableStar0),
            0, 0);
    mButtonFavorite.setText(isFavorite ? R.string.context_unfavorite : R.string.context_favorite);
    CheatSheet.setup(mButtonFavorite, isFavorite ? R.string.context_unfavorite : R.string.context_favorite);
    mButtonFavorite.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            // disable until action is complete
            v.setEnabled(false);
            ShowTools.get(v.getContext()).storeIsFavorite(getShowTvdbId(), !isFavorite);
        }
    });

    // overview
    mTextViewOverview.setText(mShowCursor.getString(ShowQuery.OVERVIEW));

    // country for release time calculation
    // show "unknown" if country is not supported
    mTextViewReleaseCountry.setText(
            TimeTools.isUnsupportedCountry(releaseCountry) ? getString(R.string.unknown) : releaseCountry);

    // original release
    String firstRelease = mShowCursor.getString(ShowQuery.FIRST_RELEASE);
    Utils.setValueOrPlaceholder(mTextViewFirstRelease,
            TimeTools.getShowReleaseYear(firstRelease, releaseTime, releaseCountry));

    // content rating
    Utils.setValueOrPlaceholder(mTextViewContentRating, mShowCursor.getString(ShowQuery.CONTENT_RATING));
    // genres
    Utils.setValueOrPlaceholder(mTextViewGenres,
            Utils.splitAndKitTVDBStrings(mShowCursor.getString(ShowQuery.GENRES)));

    // TVDb rating
    String tvdbRating = mShowCursor.getString(ShowQuery.TVDB_RATING);
    if (!TextUtils.isEmpty(tvdbRating)) {
        mTextViewTvdbRating.setText(tvdbRating);
    }

    // last edit
    long lastEditRaw = mShowCursor.getLong(ShowQuery.LAST_EDIT_MS);
    if (lastEditRaw > 0) {
        mTextViewLastEdit.setText(DateUtils.formatDateTime(getActivity(), lastEditRaw * 1000,
                DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_TIME));
    } else {
        mTextViewLastEdit.setText(R.string.unknown);
    }

    // IMDb button
    String imdbId = mShowCursor.getString(ShowQuery.IMDBID);
    ServiceUtils.setUpImdbButton(imdbId, mButtonImdb, TAG, getActivity());

    // TVDb button
    ServiceUtils.setUpTvdbButton(getShowTvdbId(), mButtonTvdb, TAG);

    // trakt button
    ServiceUtils.setUpTraktButton(getShowTvdbId(), mButtonTrakt, TAG);

    // web search button
    ServiceUtils.setUpWebSearchButton(mShowTitle, mButtonWebSearch, TAG);

    // shout button
    mButtonComments.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent i = new Intent(getActivity(), TraktShoutsActivity.class);
            i.putExtras(TraktShoutsActivity.createInitBundleShow(mShowTitle, getShowTvdbId()));
            ActivityCompat.startActivity(getActivity(), i, ActivityOptionsCompat
                    .makeScaleUpAnimation(v, 0, 0, v.getWidth(), v.getHeight()).toBundle());
            fireTrackerEvent("Shouts");
        }
    });

    // poster, full screen poster button
    final View posterContainer = getView().findViewById(R.id.containerShowPoster);
    final ImageView posterView = (ImageView) posterContainer.findViewById(R.id.imageViewShowPoster);
    Utils.loadPoster(getActivity(), posterView, mShowPoster);
    posterContainer.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent fullscreen = new Intent(getActivity(), FullscreenImageActivity.class);
            fullscreen.putExtra(FullscreenImageActivity.InitBundle.IMAGE_PATH,
                    TheTVDB.buildScreenshotUrl(mShowPoster));
            ActivityCompat.startActivity(getActivity(), fullscreen, ActivityOptionsCompat
                    .makeScaleUpAnimation(v, 0, 0, v.getWidth(), v.getHeight()).toBundle());
        }
    });

    // background
    ImageView background = (ImageView) getView().findViewById(R.id.imageViewShowPosterBackground);
    Utils.loadPosterBackground(getActivity(), background, mShowPoster);

    onLoadTraktRatings(true);
}

From source file:com.pluscubed.velociraptor.settings.SettingsActivity.java

private void enableDisableAllChildren(boolean enable, ViewGroup viewgroup) {
    for (int i = 0; i < viewgroup.getChildCount(); i++) {
        View child = viewgroup.getChildAt(i);
        child.setEnabled(enable);
        if (child instanceof ViewGroup) {
            enableDisableAllChildren(enable, (ViewGroup) child);
        }/*from ww  w .j a v a2  s. c  o  m*/
    }
}

From source file:com.feedhenry.armark.HelloFragment.java

private void cloudCallAlmacenes(final View v, final TextView responseTextView) {
    try {//from w  w w.  j  a  v a2  s .  c o  m
        JSONObject params = new JSONObject("{fecha: '2015-09-11' }");

        FHCloudRequest request = FH.buildCloudRequest("almacenes", "POST", null, params);
        request.executeAsync(new FHActCallback() {
            @Override
            public void success(FHResponse fhResponse) {
                Log.d(TAG, "cloudCall - success");
                v.setEnabled(true);
                //responseTextView.setText(fhResponse.getJson().toString());

                int Id;
                String RazonSocial;
                String resp = "";

                JSONArray array = fhResponse.getArray();

                for (int i = 0; i < array.length(); i++) {
                    JSONObject row = array.getJSONObject(i);
                    Id = row.getInt("Id");
                    RazonSocial = row.getString("RazonSocial");

                    resp += "Id : " + Id + ", Razon Social : " + RazonSocial + "\n";
                }

                responseTextView.setText(resp);

            }

            @Override
            public void fail(FHResponse fhResponse) {
                Log.d(TAG, "cloudCall - fail");
                Log.e(TAG, fhResponse.getErrorMessage(), fhResponse.getError());
                v.setEnabled(true);
                responseTextView.setText(fhResponse.getErrorMessage());
            }
        });
    } catch (Exception e) {
        Log.e(TAG, e.getMessage(), e.getCause());
    }
}

From source file:com.feedhenry.armark.HelloFragment.java

private void cloudCallCategorias(final View v, final TextView responseTextView) {
    try {// w  w w.j a  v  a2  s  .  co  m
        JSONObject params = new JSONObject("{fecha: '2015-09-11' }");

        FHCloudRequest request = FH.buildCloudRequest("categorias", "POST", null, params);
        request.executeAsync(new FHActCallback() {
            @Override
            public void success(FHResponse fhResponse) {
                Log.d(TAG, "cloudCall - success");
                v.setEnabled(true);
                //responseTextView.setText(fhResponse.getJson().toString());

                int Id;
                String Nombre;
                String resp = "";

                JSONArray array = fhResponse.getArray();

                for (int i = 0; i < array.length(); i++) {
                    JSONObject row = array.getJSONObject(i);
                    Id = row.getInt("Id");
                    Nombre = row.getString("Nombre");

                    resp += "Id : " + Id + ", Nombre : " + Nombre + "\n";
                }

                responseTextView.setText(resp);

            }

            @Override
            public void fail(FHResponse fhResponse) {
                Log.d(TAG, "cloudCall - fail");
                Log.e(TAG, fhResponse.getErrorMessage(), fhResponse.getError());
                v.setEnabled(true);
                responseTextView.setText(fhResponse.getErrorMessage());
            }
        });
    } catch (Exception e) {
        Log.e(TAG, e.getMessage(), e.getCause());
    }
}

From source file:com.feedhenry.armark.HelloFragment.java

private void cloudCallPromociones(final View v, final TextView responseTextView) {
    try {//from   ww w . j  a v  a  2s  .  c  o m
        JSONObject params = new JSONObject("{fecha: '2015-09-11' }");

        FHCloudRequest request = FH.buildCloudRequest("promociones", "POST", null, params);
        request.executeAsync(new FHActCallback() {
            @Override
            public void success(FHResponse fhResponse) {
                Log.d(TAG, "cloudCall - success");
                v.setEnabled(true);
                // responseTextView.setText(fhResponse.getJson().toString());

                int Id;
                String Descripcion;
                String resp = "";

                JSONArray array = fhResponse.getArray();

                for (int i = 0; i < array.length(); i++) {
                    JSONObject row = array.getJSONObject(i);
                    Id = row.getInt("Id");
                    Descripcion = row.getString("Descripcion");

                    resp += "Id : " + Id + ", Descripcion : " + Descripcion + "\n";
                }

                responseTextView.setText(resp);

            }

            @Override
            public void fail(FHResponse fhResponse) {
                Log.d(TAG, "cloudCall - fail");
                Log.e(TAG, fhResponse.getErrorMessage(), fhResponse.getError());
                v.setEnabled(true);
                responseTextView.setText(fhResponse.getErrorMessage());
            }
        });
    } catch (Exception e) {
        Log.e(TAG, e.getMessage(), e.getCause());
    }
}

From source file:com.feedhenry.armark.HelloFragment.java

public void cloudCallUsuario(final View v, final TextView responseTextView) {
    try {// w  ww.  j a  va  2  s .  com
        JSONObject params = new JSONObject("{correo: 'breinergonza@hotmail.com', password: '123456' }");

        FHCloudRequest request = FH.buildCloudRequest("login", "POST", null, params);
        request.executeAsync(new FHActCallback() {
            @Override
            public void success(FHResponse fhResponse) {
                Log.d(TAG, "cloudCall - success");
                v.setEnabled(true);
                responseTextView.setText(fhResponse.getJson().toString());
            }

            @Override
            public void fail(FHResponse fhResponse) {
                Log.d(TAG, "cloudCall - fail");
                Log.e(TAG, fhResponse.getErrorMessage(), fhResponse.getError());
                v.setEnabled(true);
                responseTextView.setText(fhResponse.getErrorMessage());
            }
        });
    } catch (Exception e) {
        Log.e(TAG, e.getMessage(), e.getCause());
    }
}

From source file:org.matrix.console.activity.SettingsActivity.java

private void refreshGCMEntries() {
    GcmRegistrationManager gcmRegistrationManager = Matrix.getInstance(this).getSharedGcmRegistrationManager();

    final CheckBox gcmBox = (CheckBox) findViewById(R.id.checkbox_useGcm);
    gcmBox.setChecked(gcmRegistrationManager.useGCM() && gcmRegistrationManager.is3rdPartyServerRegistred());

    // check if the GCM registration has not been rejected.
    boolean gcmButEnabled = gcmRegistrationManager.useGCM() || gcmRegistrationManager.isGCMRegistred();
    View parentView = (View) gcmBox.getParent();

    parentView.setEnabled(gcmButEnabled);
    gcmBox.setEnabled(gcmButEnabled);//from ww w .ja v  a 2 s  .  c om
    parentView.setAlpha(gcmButEnabled ? 1.0f : 0.5f);
}

From source file:com.example.hippoweex.ui.widget.FragmentTabHost.java

public void setOnTabClickListener(final OnTabClickListener onTabClickListener) {
    this.onTabClickListener = onTabClickListener;

    for (int i = 0; i < getTabWidget().getChildCount(); i++) {
        final View tabView = getTabWidget().getChildTabViewAt(i);
        final int index = i;
        if (tabView != null && onTabClickListener != null) {
            tabView.setOnClickListener(new OnClickListener() {
                @Override/*ww w.  ja  v a  2s.  c  o  m*/
                public void onClick(View v) {
                    tabView.setEnabled(false);
                    String tag = mTabs.get(index).getTag();
                    boolean isSwitch = onTabClickListener.onTabClick(tag);
                    tabView.setEnabled(true);
                    if (isSwitch) {
                        setCurrentTab(index);
                    }
                }
            });
        }
    }
}