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:activities.PaintActivity.java

public void enableChildsOnTouch(ViewGroup viewGroup, boolean enabled) {
    int cnt = viewGroup.getChildCount();
    for (int i = 0; i < cnt; i++) {
        View v = viewGroup.getChildAt(i);
        if (v instanceof ViewGroup) {
            enableChildsOnTouch((ViewGroup) v, enabled);
        } else {//from w w  w.  j  ava  2s . c o m
            v.setEnabled(enabled);

        }
    }
}

From source file:com.android.calendar.selectcalendars.SelectCalendarsSimpleAdapter.java

@Override
public View getView(final int position, View convertView, ViewGroup parent) {
    if (position >= mRowCount) {
        return null;
    }/*ww  w .  j a v  a  2 s.c  o m*/
    String name = mData[position].displayName;
    boolean selected = mData[position].selected;

    int color = Utils.getDisplayColorFromColor(mData[position].color);
    View view;
    if (convertView == null) {
        view = mInflater.inflate(mLayout, parent, false);
        final View delegate = view.findViewById(R.id.color);
        final View delegateParent = (View) delegate.getParent();
        delegateParent.post(new Runnable() {

            @Override
            public void run() {
                final Rect r = new Rect();
                delegate.getHitRect(r);
                r.top -= mColorViewTouchAreaIncrease;
                r.bottom += mColorViewTouchAreaIncrease;
                r.left -= mColorViewTouchAreaIncrease;
                r.right += mColorViewTouchAreaIncrease;
                delegateParent.setTouchDelegate(new TouchDelegate(r, delegate));
            }
        });
    } else {
        view = convertView;
    }

    TextView calendarName = (TextView) view.findViewById(R.id.calendar);
    calendarName.setText(name);

    View colorView = view.findViewById(R.id.color);
    colorView.setBackgroundColor(color);
    colorView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            // Purely for sanity check--view should be disabled if account has no more colors
            if (!hasMoreColors(position)) {
                return;
            }

            if (mColorPickerDialog == null) {
                mColorPickerDialog = CalendarColorPickerDialog.newInstance(mData[position].id, mIsTablet);
            } else {
                mColorPickerDialog.setCalendarId(mData[position].id);
            }
            mFragmentManager.executePendingTransactions();
            if (!mColorPickerDialog.isAdded()) {
                mColorPickerDialog.show(mFragmentManager, COLOR_PICKER_DIALOG_TAG);
            }
        }
    });

    int textColor;
    if (selected) {
        textColor = mColorCalendarVisible;
    } else {
        textColor = mColorCalendarHidden;
    }
    calendarName.setTextColor(textColor);

    CheckBox syncCheckBox = (CheckBox) view.findViewById(R.id.sync);
    if (syncCheckBox != null) {

        // Full screen layout
        syncCheckBox.setChecked(selected);

        colorView.setEnabled(hasMoreColors(position));
        LayoutParams layoutParam = calendarName.getLayoutParams();
        TextView secondaryText = (TextView) view.findViewById(R.id.status);
        if (!TextUtils.isEmpty(mData[position].ownerAccount) && !mData[position].ownerAccount.equals(name)
                && !mData[position].ownerAccount.endsWith("calendar.google.com")) {
            int secondaryColor;
            if (selected) {
                secondaryColor = mColorCalendarSecondaryVisible;
            } else {
                secondaryColor = mColorCalendarSecondaryHidden;
            }
            secondaryText.setText(mData[position].ownerAccount);
            secondaryText.setTextColor(secondaryColor);
            secondaryText.setVisibility(View.VISIBLE);
            layoutParam.height = LayoutParams.WRAP_CONTENT;
        } else {
            secondaryText.setVisibility(View.GONE);
            layoutParam.height = LayoutParams.MATCH_PARENT;
        }

        calendarName.setLayoutParams(layoutParam);

    } else {
        // Tablet layout
        view.findViewById(R.id.color).setEnabled(selected && hasMoreColors(position));
        view.setBackgroundDrawable(getBackground(position, selected));
        ViewGroup.LayoutParams newParams = view.getLayoutParams();
        if (position == mData.length - 1) {
            newParams.height = BOTTOM_ITEM_HEIGHT;
        } else {
            newParams.height = NORMAL_ITEM_HEIGHT;
        }
        view.setLayoutParams(newParams);
        CheckBox visibleCheckBox = (CheckBox) view.findViewById(R.id.visible_check_box);
        if (visibleCheckBox != null) {
            visibleCheckBox.setChecked(selected);
        }
    }
    view.invalidate();
    return view;
}

From source file:org.deviceconnect.android.deviceplugin.linking.setting.LinkingDeviceActivity.java

private void setVibrationButton() {
    View view = findViewById(R.id.select_vibration_off);
    if (view != null) {
        view.setOnClickListener(new View.OnClickListener() {
            @Override/* ww w. j  a  v  a  2  s. c  o m*/
            public void onClick(final View v) {
                showVibrationPattern(new OnSelectedListener() {
                    @Override
                    public void onSelected(final String name, final Integer id) {
                        Button btn = (Button) findViewById(R.id.select_vibration_off);
                        if (btn != null) {
                            btn.setText(name);
                        }
                        updateVibrationOffSetting(id);
                    }
                });
            }
        });
        view.setEnabled(mDevice.isSupportVibration());
    }

    View onView = findViewById(R.id.select_vibration_on);
    if (onView != null) {
        onView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                showVibrationPattern(new OnSelectedListener() {
                    @Override
                    public void onSelected(final String name, final Integer id) {
                        Button btn = (Button) findViewById(R.id.select_vibration_on);
                        if (btn != null) {
                            btn.setText(name);
                        }
                        updateVibrationOnSetting(id);
                    }
                });
            }
        });
        onView.setEnabled(mDevice.isSupportVibration());
    }

    Button onBtn = (Button) findViewById(R.id.vibration_on);
    if (onBtn != null) {
        onBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(final View v) {
                onClickVibration(true);
            }
        });
        onBtn.setEnabled(mDevice.isSupportVibration());
    }

    Button offBtn = (Button) findViewById(R.id.vibration_off);
    if (offBtn != null) {
        offBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(final View v) {
                onClickVibration(false);
            }
        });
        offBtn.setEnabled(mDevice.isSupportVibration());
    }
}

From source file:org.deviceconnect.android.deviceplugin.linking.setting.LinkingDeviceActivity.java

private void setLightButton() {
    View offView = findViewById(R.id.select_light_off);
    if (offView != null) {
        offView.setOnClickListener(new View.OnClickListener() {
            @Override/* w ww  .  j av  a 2 s  .  c om*/
            public void onClick(final View v) {
                showLEDPattern(new OnSelectedListener() {
                    @Override
                    public void onSelected(final String name, final Integer id) {
                        Button btn = ((Button) findViewById(R.id.select_light_off));
                        if (btn != null) {
                            btn.setText(name);
                        }
                        updateLightOffSetting(id);
                    }
                });
            }
        });
        offView.setEnabled(mDevice.isSupportLED());
    }

    View colorView = findViewById(R.id.select_light_on_color);
    if (colorView != null) {
        colorView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                showLEDColor(new OnSelectedListener() {
                    @Override
                    public void onSelected(final String name, final Integer id) {
                        Button btn = ((Button) findViewById(R.id.select_light_on_color));
                        if (btn != null) {
                            btn.setText(name);
                        }
                        updateLightColorSetting(id);
                    }
                });
            }
        });
        colorView.setEnabled(mDevice.isSupportLED());
    }

    View patternView = findViewById(R.id.select_light_on_pattern);
    if (patternView != null) {
        patternView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(final View v) {
                showLEDPattern(new OnSelectedListener() {
                    @Override
                    public void onSelected(final String name, final Integer id) {
                        Button btn = ((Button) findViewById(R.id.select_light_on_pattern));
                        if (btn != null) {
                            btn.setText(name);
                        }
                        updateLightOffSetting(id);
                    }
                });
            }
        });
        patternView.setEnabled(mDevice.isSupportLED());
    }

    Button onBtn = (Button) findViewById(R.id.on);
    if (onBtn != null) {
        onBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(final View v) {
                onClickLED(true);
            }
        });
        onBtn.setEnabled(mDevice.isSupportLED());
    }

    Button offBtn = (Button) findViewById(R.id.off);
    if (offBtn != null) {
        offBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(final View v) {
                onClickLED(false);
            }
        });
        offBtn.setEnabled(mDevice.isSupportLED());
    }
}

From source file:com.odoo.OdooActivity.java

private void setupAccountBox() {
    mDrawerAccountContainer = (LinearLayout) findViewById(R.id.accountList);
    View chosenAccountView = findViewById(R.id.drawerAccountView);
    OUser currentUser = OUser.current(this);
    if (currentUser == null) {
        chosenAccountView.setVisibility(View.GONE);
        mDrawerAccountContainer.setVisibility(View.GONE);
        return;// w w w. ja  v  a 2 s .co m
    } else {
        chosenAccountView.setVisibility(View.VISIBLE);
        mDrawerAccountContainer.setVisibility(View.INVISIBLE);
    }

    ImageView avatar = (ImageView) chosenAccountView.findViewById(R.id.profile_image);
    TextView name = (TextView) chosenAccountView.findViewById(R.id.profile_name_text);
    TextView url = (TextView) chosenAccountView.findViewById(R.id.profile_url_text);

    name.setText(currentUser.getName());
    url.setText((currentUser.isOAuthLogin()) ? currentUser.getInstanceURL() : currentUser.getHost());

    if (!currentUser.getAvatar().equals("false")) {
        Bitmap bitmap = BitmapUtils.getBitmapImage(this, currentUser.getAvatar());
        if (bitmap != null)
            avatar.setImageBitmap(bitmap);
    }

    // Setting Accounts
    List<OUser> accounts = OdooAccountManager.getAllAccounts(this);
    if (accounts.size() > 0) {
        chosenAccountView.setEnabled(true);
        ImageView boxIndicator = (ImageView) findViewById(R.id.expand_account_box_indicator);
        boxIndicator.setVisibility(View.VISIBLE);
        chosenAccountView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mAccountBoxExpanded = !mAccountBoxExpanded;
                accountBoxToggle();
            }
        });
        populateAccountList(currentUser, accounts);
    }
}

From source file:com.KittleApps.app.TransCalc.EventListener.java

@Override
public void onClick(View view) {
    View v;
    EditText active;/*  www .  java 2s  . c  o  m*/
    int id = view.getId();
    switch (id) {
    case R.id.del:
        mHandler.onDelete();
        break;

    case R.id.clear:
        mHandler.onClear();
        break;

    case R.id.equal:
        if (mHandler.getText().contains(mX) || mHandler.getText().contains(mY)) {
            if (!mHandler.getText().contains("=")) {
                mHandler.insert("=");
                returnToBasic();
            }
            break;
        }
        mHandler.onEnter();
        break;

    case R.id.hex:
        mHandler.setText(mHandler.mBaseModule.setMode(Mode.HEXADECIMAL));
        view.setBackgroundResource(R.color.pressed_color);
        ((View) view.getParent()).findViewById(R.id.bin).setBackgroundResource(R.drawable.btn_function);
        ((View) view.getParent()).findViewById(R.id.dec).setBackgroundResource(R.drawable.btn_function);
        for (int i : mHandler.mBaseModule.bannedResourceInBinary) {
            if (mPager != null) {
                v = mPager.findViewById(i);
            } else {
                v = mSmallPager.findViewById(i);
                if (v == null)
                    v = mLargePager.findViewById(i);
            }
            v.setEnabled(true);
        }
        break;

    case R.id.bin:
        mHandler.setText(mHandler.mBaseModule.setMode(Mode.BINARY));
        view.setBackgroundResource(R.color.pressed_color);
        ((View) view.getParent()).findViewById(R.id.hex).setBackgroundResource(R.drawable.btn_function);
        ((View) view.getParent()).findViewById(R.id.dec).setBackgroundResource(R.drawable.btn_function);
        for (int i : mHandler.mBaseModule.bannedResourceInBinary) {
            if (mPager != null) {
                v = mPager.findViewById(i);
            } else {
                v = mSmallPager.findViewById(i);
                if (v == null)
                    v = mLargePager.findViewById(i);
            }
            v.setEnabled(false);
        }
        break;

    case R.id.dec:
        mHandler.setText(mHandler.mBaseModule.setMode(Mode.DECIMAL));
        view.setBackgroundResource(R.color.pressed_color);
        ((View) view.getParent()).findViewById(R.id.bin).setBackgroundResource(R.drawable.btn_function);
        ((View) view.getParent()).findViewById(R.id.hex).setBackgroundResource(R.drawable.btn_function);
        for (int i : mHandler.mBaseModule.bannedResourceInBinary) {
            if (mPager != null) {
                v = mPager.findViewById(i);
            } else {
                v = mSmallPager.findViewById(i);
                if (v == null)
                    v = mLargePager.findViewById(i);
            }
            v.setEnabled(true);
        }
        for (int i : mHandler.mBaseModule.bannedResourceInDecimal) {
            if (mPager != null) {
                v = mPager.findViewById(i);
            } else {
                v = mSmallPager.findViewById(i);
                if (v == null)
                    v = mLargePager.findViewById(i);
            }
            v.setEnabled(false);
        }
        break;

    case R.id.matrix:
        mHandler.insert(MatrixView.PATTERN);
        returnToBasic();
        break;

    case R.id.matrix_inverse:
        mHandler.insert(MatrixInverseView.PATTERN);
        returnToBasic();
        break;

    case R.id.matrix_transpose:
        mHandler.insert(MatrixTransposeView.PATTERN);
        returnToBasic();
        break;

    case R.id.plus_row:
        v = mHandler.mDisplay.getActiveEditText();
        if (v instanceof MatrixEditText)
            ((MatrixEditText) v).getMatrixView().addRow();
        break;

    case R.id.minus_row:
        v = mHandler.mDisplay.getActiveEditText();
        if (v instanceof MatrixEditText)
            ((MatrixEditText) v).getMatrixView().removeRow();
        break;

    case R.id.plus_col:
        v = mHandler.mDisplay.getActiveEditText();
        if (v instanceof MatrixEditText)
            ((MatrixEditText) v).getMatrixView().addColumn();
        break;

    case R.id.minus_col:
        v = mHandler.mDisplay.getActiveEditText();
        if (v instanceof MatrixEditText)
            ((MatrixEditText) v).getMatrixView().removeColumn();
        break;

    case R.id.next:
        active = mHandler.mDisplay.getActiveEditText();
        if (active.getSelectionStart() == active.getText().length()) {
            v = mHandler.mDisplay.getActiveEditText().focusSearch(View.FOCUS_FORWARD);
            if (v != null)
                v.requestFocus();
            active = mHandler.mDisplay.getActiveEditText();
            active.setSelection(0);
        } else {
            active.setSelection(active.getSelectionStart() + 1);
        }
        break;

    case R.id.sign:
        active = mHandler.mDisplay.getActiveEditText();
        int selection = active.getSelectionStart();
        if (active.getText().toString().matches(Logic.NUMBER)) {
            if (active.getText().toString().startsWith(String.valueOf(Logic.MINUS))) {
                active.setText(active.getText().toString().substring(1));
                selection--;
            } else {
                active.setText(Logic.MINUS + active.getText().toString());
                selection++;
            }
            if (selection > active.length())
                selection--;
            if (selection < 0)
                selection = 0;
            active.setSelection(selection);
        }
        break;

    case R.id.parentheses:
        if (mHandler.getText().equals(mErrorString))
            mHandler.setText("");
        if (mHandler.getText().contains("=")) {
            String[] equation = mHandler.getText().split("=");
            if (equation.length > 1) {
                mHandler.setText(equation[0] + "=(" + equation[1] + ")");
            } else {
                mHandler.setText(equation[0] + "=()");
            }
        } else {
            mHandler.setText("(" + mHandler.getText() + ")");
        }
        returnToBasic();
        break;

    case R.id.mod:
        if (mHandler.getText().equals(mErrorString))
            mHandler.setText("");
        if (mHandler.getText().contains("=")) {
            String[] equation = mHandler.getText().split("=");
            if (equation.length > 1) {
                mHandler.setText(equation[0] + "=" + mModString + "(" + equation[1] + ",");
            } else {
                mHandler.insert(mModString + "(");
            }
        } else {
            if (mHandler.getText().length() > 0) {
                mHandler.setText(mModString + "(" + mHandler.getText() + ",");
            } else {
                mHandler.insert(mModString + "(");
            }
        }
        returnToBasic();
        break;

    case R.id.easter:
        Toast.makeText(mContext, R.string.easter_egg, Toast.LENGTH_SHORT).show();
        break;

    default:
        if (view instanceof Button) {
            if (mHandler.getText().equals(mErrorString))
                mHandler.setText("");
            String text = ((Button) view).getText().toString();
            if (text.equals(mDX) || text.equals(mDY)) {
                // Do nothing
            } else if (text.length() >= 2) {
                // Add paren after sin, cos, ln, etc. from buttons
                text += "(";
            }
            mHandler.insert(text);
            returnToBasic();
        }
    }
}

From source file:openscience.crowdsource.video.experiments.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler(this));
    setContentView(R.layout.activity_main);
    setTaskBarColored(this);

    Button consoleButton = (Button) findViewById(R.id.btn_consoleMain);
    consoleButton.setOnClickListener(new View.OnClickListener() {
        @Override//from www .java 2 s  .c  o  m
        public void onClick(View v) {
            Intent logIntent = new Intent(MainActivity.this, ConsoleActivity.class);
            startActivity(logIntent);
        }
    });

    Button infoButton = (Button) findViewById(R.id.btn_infoMain);
    infoButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent aboutIntent = new Intent(MainActivity.this, InfoActivity.class);
            startActivity(aboutIntent);
        }
    });

    initConsole();

    startStopCam = (Button) findViewById(R.id.btn_capture);
    startStopCam.setOnClickListener(new Button.OnClickListener() {
        public void onClick(View v) {
            createDirIfNotExist(externalSDCardOpenscienceTmpPath);
            String takenPictureFilPath = String.format(
                    externalSDCardOpenscienceTmpPath + File.separator + "%d.jpg", System.currentTimeMillis());
            AppConfigService.updateActualImagePath(takenPictureFilPath);
            Intent aboutIntent = new Intent(MainActivity.this, CaptureActivity.class);
            startActivity(aboutIntent);
        }
    });

    recognize = (Button) findViewById(R.id.suggest);
    recognize.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            final RecognitionScenario recognitionScenario = RecognitionScenarioService
                    .getSelectedRecognitionScenario();
            if (recognitionScenario == null) {
                AppLogger.logMessage(" Please select an image recognition scenario first! \n");
                return;
            }

            if (recognitionScenario.getState() == RecognitionScenario.State.NEW) {
                AlertDialog.Builder clarifyDialogBuilder = new AlertDialog.Builder(MainActivity.this);
                clarifyDialogBuilder
                        .setMessage(Html.fromHtml("Please download this scenario first or select another one."))
                        .setCancelable(false)
                        .setPositiveButton("continue", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int id) {
                                dialog.cancel();
                                LoadScenarioFilesAsyncTask loadScenarioFilesAsyncTask = new LoadScenarioFilesAsyncTask();
                                loadScenarioFilesAsyncTask.execute(recognitionScenario);
                                recognitionScenario.setLoadScenarioFilesAsyncTask(loadScenarioFilesAsyncTask);
                                Intent mainIntent = new Intent(MainActivity.this, ScenariosActivity.class);
                                startActivity(mainIntent);
                            }
                        }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int id) {
                                dialog.cancel();
                            }
                        });
                final AlertDialog clarifyDialog = clarifyDialogBuilder.create();
                clarifyDialog.show();
                return;
            }

            if (recognitionScenario.getState() == RecognitionScenario.State.DOWNLOADING_IN_PROGRESS) {
                AlertDialog.Builder clarifyDialogBuilder = new AlertDialog.Builder(MainActivity.this);
                clarifyDialogBuilder.setMessage(Html.fromHtml("Download is in progress, please wait ..."))
                        .setCancelable(false)
                        .setPositiveButton("continue", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int id) {
                                dialog.cancel();
                            }
                        });
                final AlertDialog clarifyDialog = clarifyDialogBuilder.create();
                clarifyDialog.show();
                return;
            }

            if (isCameraStarted) {
                captureImageFromCameraPreviewAndPredict(true);
                return;
            }

            // Call prediction
            predictImage(AppConfigService.getActualImagePath());
        }
    });

    final View selectedScenarioTopBar = findViewById(R.id.selectedScenarioTopBar);
    selectedScenarioTopBar.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent selectScenario = new Intent(MainActivity.this, ScenariosActivity.class);
            startActivity(selectScenario);

        }
    });
    selectedScenarioTopBar.setEnabled(false);

    final TextView selectedScenarioText = (TextView) findViewById(R.id.selectedScenarioText);
    selectedScenarioText.setText(PRELOADING_TEXT);

    imageView = (ImageView) findViewById(R.id.imageView1);

    btnOpenImage = (Button) findViewById(R.id.btn_ImageOpen);
    btnOpenImage.setOnClickListener(new Button.OnClickListener() {
        public void onClick(View v) {
            Intent i = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
            startActivityForResult(i, REQUEST_IMAGE_SELECT);
        }
    });

    // Lazy preload scenarios
    RecognitionScenarioService.initRecognitionScenariosAsync(new RecognitionScenarioService.ScenariosUpdater() {
        @Override
        public void update() {
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    RecognitionScenario selectedRecognitionScenario = RecognitionScenarioService
                            .getSelectedRecognitionScenario();
                    selectedScenarioText.setText(selectedRecognitionScenario.getTitle());
                    updateViewFromState();
                }
            });
        }
    });

    SharedPreferences sharedPreferences = getSharedPreferences(
            AppConfigService.CROWDSOURCE_VIDEO_EXPERIMENTS_ON_ANDROID_PREFERENCES, MODE_PRIVATE);
    if (sharedPreferences.getBoolean(AppConfigService.SHARED_PREFERENCES, true)) {
        AppLogger.logMessage(welcome);
        sharedPreferences.edit().putBoolean(AppConfigService.SHARED_PREFERENCES, false).apply();
    }

    this.glSurfaceView = new GLSurfaceView(this);
    this.glSurfaceView.setRenderer(this);
    ((ViewGroup) imageView.getParent()).addView(this.glSurfaceView);

    initAppConfig(this);

    client2 = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build();

    final TextView resultPreviewText = (TextView) findViewById(R.id.resultPreviewtText);
    resultPreviewText.setText(AppConfigService.getPreviewRecognitionText());
    AppConfigService.registerPreviewRecognitionText(new AppConfigService.Updater() {
        @Override
        public void update(final String message) {
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    View imageButtonsBar = (View) findViewById(R.id.imageButtonBar);
                    imageButtonsBar.setVisibility(View.VISIBLE);
                    imageButtonsBar.setEnabled(true);
                    resultPreviewText.setText(message);
                }
            });

        }
    });
    updateViewFromState();
}

From source file:com.yadadeya.yadadeya.widget.SlidingTabLayout.java

public void populateTabStrip(int frCount, int selectedFr) {
    // final ViewPagerAdapter adapter = (ViewPagerAdapter) mViewPager.getAdapter();
    final OnClickListener tabClickListener = new TabClickListener();

    for (int i = 0; i < frCount; i++) {
        View tabView = null;
        TextView tabTitleView = null;//from w  ww  .  j a v a 2 s  . c  o m

        ImageView tabIconView = null;

        /*if (mTabViewLayoutId != 0) {
        // If there is a custom tab view layout id set, try and inflate it
        tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip,
                false);
        tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId);
        }
                
        if (tabView == null) {
        tabView = createDefaultTabView(getContext());
        }
                
        if (tabTitleView == null && TextView.class.isInstance(tabView)) {
        tabTitleView = (TextView) tabView;
        }*/

        /* if (mDistributeEvenly) {
        LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams();
        lp.width = 0;
        lp.weight = 1;
         }*/

        if (tabView == null) {
            tabView = createDefaultImageView(getContext());
        }

        if (tabIconView == null && ImageView.class.isInstance(tabView)) {
            tabIconView = (ImageView) tabView;
        }

        tabIconView.setImageDrawable(getResources().getDrawable(getDrawableId(i)));
        if (selectedFr == i) {
            tabIconView.setSelected(true);
        }

        //tabTitleView.setText(adapter.getPageTitle(i));
        tabView.setOnClickListener(tabClickListener);

        if (i == 2) {
            tabView.setEnabled(false);
            //tabView.setBackgroundColor(getResources().getColor(R.color.guillotine_background));

        }

        String desc = mContentDescriptions.get(i, null);
        if (desc != null) {
            tabView.setContentDescription(desc);
        }

        mTabStrip.addView(tabView);
        if (i == selectedFr) {
            tabView.setSelected(true);
            tabView.setBackgroundColor(Color.parseColor("#40000000"));
        }
    }
}

From source file:com.wanikani.androidnotifier.ItemsFragment.java

@Override
public void enableSorting(boolean errors, boolean unlock, boolean available, boolean mistakes) {
    View view;

    view = parent.findViewById(R.id.btn_sort_errors);
    view.setEnabled(errors);

    view = parent.findViewById(R.id.btn_sort_time);
    view.setEnabled(unlock);/*from w  w  w .  j a  v a  2s.co m*/

    view = parent.findViewById(R.id.btn_sort_available);
    view.setEnabled(available);

    view = parent.findViewById(R.id.btn_sort_toxicity);
    view.setEnabled(mistakes);
}

From source file:com.stanleyidesis.quotograph.ui.activity.LWQSettingsActivity.java

void setupViewPagerAndTabs() {
    viewPager.setOffscreenPageLimit(3);/*from  w  ww.  j  a v a 2s .  c o m*/
    viewPager.setAdapter(new PagerAdapter() {

        @Override
        public Object instantiateItem(ViewGroup container, int position) {
            switch (position) {
            case 0:
                return wallpaperPreviewWrapper;
            case 1:
                return playlistWrapper;
            default:
                return settingsWrapper;
            }
        }

        @Override
        public int getCount() {
            return 3;
        }

        @Override
        public boolean isViewFromObject(View view, Object object) {
            return view == object;
        }

        @Override
        public CharSequence getPageTitle(int position) {
            return "";
        }
    });
    viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            switch (position) {
            case 0:
                if (activityState != stateSkipWallpaper) {
                    setBackgroundAlpha(BackgroundWallpaperState.OBSCURED.screenAlpha * positionOffset);
                }
                // Fab Add
                fabAdd.setScaleX(positionOffset);
                fabAdd.setScaleY(positionOffset);
                // Content
                content.setAlpha(positionOffset);
                // At .3, share is gone, at .6, save is gone, and at 1, skip is gone
                shareButton.setTranslationY((1f - (1f - (Math.min(positionOffset, 1 / 3f) / (1 / 3f))))
                        * shareButton.getHeight() * 3);
                saveButton.setTranslationY((1f - (1f - (Math.min(positionOffset, 2 / 3f) / (2 / 3f))))
                        * saveButton.getHeight() * 3);
                skipButton.setTranslationY((1f - (1f - positionOffset)) * skipButton.getHeight() * 3);
                break;
            case 1:
                fabAdd.setScaleX(1f - positionOffset);
                fabAdd.setScaleY(1f - positionOffset);
            }
        }

        @Override
        public void onPageSelected(int position) {
            // Content
            content.setAlpha(position == 0 ? 0f : 1f);

            // Add Fab
            fabAdd.setScaleX(position == 1 ? 1f : 0f);
            fabAdd.setScaleY(position == 1 ? 1f : 0f);
            fabAdd.setEnabled(position == 1);

            // Tooltips
            if (position == 1) {
                // Log screen view
                AnalyticsUtils.trackScreenView(AnalyticsUtils.SCREEN_PLAYLIST);
                showTutorialTip(TutorialTooltips.ADD);
            } else if (position == 2) {
                // Log screen view
                AnalyticsUtils.trackScreenView(AnalyticsUtils.SCREEN_SETTINGS);
                // Delay it just a little because the view messes up otherwise
                new Handler().postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        showTutorialTip(TutorialTooltips.SETTING);
                    }
                }, 200);
            } else {
                // Log screen view
                AnalyticsUtils.trackScreenView(AnalyticsUtils.SCREEN_WALLPAPER_PREVIEW);
            }

            // Action Buttons
            View[] buttons = new View[] { shareButton, saveButton, skipButton };
            for (View button : buttons) {
                button.setTranslationY(position == 0 ? 0f : button.getHeight() * 3f);
                button.setEnabled(position == 0);
            }

            if (activityState == stateSkipWallpaper) {
                return;
            }
            // Background
            setBackgroundAlpha(position == 0 ? BackgroundWallpaperState.REVEALED.screenAlpha
                    : BackgroundWallpaperState.OBSCURED.screenAlpha);
        }

        @Override
        public void onPageScrollStateChanged(int state) {
        }
    });
    tabLayout.setSelectedTabIndicatorColor(getResources().getColor(R.color.palette_500));
    tabLayout.setupWithViewPager(viewPager);
    tabLayout.getTabAt(0).setIcon(R.drawable.selectable_preview_button);
    tabLayout.getTabAt(0).setContentDescription("Preview Quotograph");
    tabLayout.getTabAt(1).setIcon(R.drawable.selectable_playlist_button);
    tabLayout.getTabAt(1).setContentDescription("Playlist");
    tabLayout.getTabAt(2).setIcon(R.drawable.selectable_settings_button);
    tabLayout.getTabAt(2).setContentDescription("Settings");
}