Search in sources :

Example 66 with CompoundButton

use of android.widget.CompoundButton in project BlurEffectForAndroidDesign by PomepuyN.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    setContentView(R.layout.activity_main);
    // Get the screen width
    final int screenWidth = ImageUtils.getScreenWidth(this);
    // Find the view
    mBlurredImage = (ImageView) findViewById(R.id.blurred_image);
    mNormalImage = (ImageView) findViewById(R.id.normal_image);
    mBlurredImageHeader = (ScrollableImageView) findViewById(R.id.blurred_image_header);
    mSwitch = (Switch) findViewById(R.id.background_switch);
    mList = (ListView) findViewById(R.id.list);
    // prepare the header ScrollableImageView
    mBlurredImageHeader.setScreenWidth(screenWidth);
    // Action for the switch
    mSwitch.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                mBlurredImage.setAlpha(alpha);
            } else {
                mBlurredImage.setAlpha(0f);
            }
        }
    });
    // Try to find the blurred image
    final File blurredImage = new File(getFilesDir() + BLURRED_IMG_PATH);
    if (!blurredImage.exists()) {
        // launch the progressbar in ActionBar
        setProgressBarIndeterminateVisibility(true);
        new Thread(new Runnable() {

            @Override
            public void run() {
                // No image found => let's generate it!
                BitmapFactory.Options options = new BitmapFactory.Options();
                options.inSampleSize = 2;
                Bitmap image = BitmapFactory.decodeResource(getResources(), R.drawable.image, options);
                Bitmap newImg = Blur.fastblur(MainActivity.this, image, 12);
                ImageUtils.storeImage(newImg, blurredImage);
                runOnUiThread(new Runnable() {

                    @Override
                    public void run() {
                        updateView(screenWidth);
                        // And finally stop the progressbar
                        setProgressBarIndeterminateVisibility(false);
                    }
                });
            }
        }).start();
    } else {
        // The image has been found. Let's update the view
        updateView(screenWidth);
    }
    String[] strings = getResources().getStringArray(R.array.list_content);
    // Prepare the header view for our list
    headerView = new View(this);
    headerView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, TOP_HEIGHT));
    mList.addHeaderView(headerView);
    mList.setAdapter(new ArrayAdapter<String>(this, R.layout.list_item, strings));
    mList.setOnScrollListener(new OnScrollListener() {

        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {
        }

        /**
			 * Listen to the list scroll. This is where magic happens ;)
			 */
        @Override
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
            // Calculate the ratio between the scroll amount and the list
            // header weight to determinate the top picture alpha
            alpha = (float) -headerView.getTop() / (float) TOP_HEIGHT;
            // Apply a ceil
            if (alpha > 1) {
                alpha = 1;
            }
            // Apply on the ImageView if needed
            if (mSwitch.isChecked()) {
                mBlurredImage.setAlpha(alpha);
            }
            // Parallax effect : we apply half the scroll amount to our
            // three views
            mBlurredImage.setTop(headerView.getTop() / 2);
            mNormalImage.setTop(headerView.getTop() / 2);
            mBlurredImageHeader.handleScroll(headerView.getTop() / 2);
        }
    });
}
Also used : OnCheckedChangeListener(android.widget.CompoundButton.OnCheckedChangeListener) LayoutParams(android.widget.AbsListView.LayoutParams) AbsListView(android.widget.AbsListView) ImageView(android.widget.ImageView) AbsListView(android.widget.AbsListView) View(android.view.View) ListView(android.widget.ListView) Bitmap(android.graphics.Bitmap) OnScrollListener(android.widget.AbsListView.OnScrollListener) BitmapFactory(android.graphics.BitmapFactory) File(java.io.File) CompoundButton(android.widget.CompoundButton)

Example 67 with CompoundButton

use of android.widget.CompoundButton in project HoloEverywhere by Prototik.

the class ListMenuItemView method setChecked.

public void setChecked(boolean checked) {
    CompoundButton compoundButton;
    if (mItemData.isExclusiveCheckable()) {
        if (mRadioButton == null) {
            insertRadioButton();
        }
        compoundButton = mRadioButton;
    } else {
        if (mCheckBox == null) {
            insertCheckBox();
        }
        compoundButton = mCheckBox;
    }
    compoundButton.setChecked(checked);
}
Also used : CompoundButton(android.widget.CompoundButton)

Example 68 with CompoundButton

use of android.widget.CompoundButton in project KeepScore by nolanlawson.

the class SavedGameAdapter method getView.

@Override
public View getView(int position, View view, ViewGroup parent) {
    // view wrapper optimization per Romain Guy
    final Context context = parent.getContext();
    ViewWrapper viewWrapper;
    if (view == null) {
        LayoutInflater vi = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        view = vi.inflate(R.layout.saved_game_item, parent, false);
        viewWrapper = new ViewWrapper(view);
        view.setTag(viewWrapper);
    } else {
        viewWrapper = (ViewWrapper) view.getTag();
    }
    TextView titleTextView = viewWrapper.getTitleTextView();
    TextView numPlayersTextView = viewWrapper.getNumPlayersTextView();
    TextView subtitleTextView = viewWrapper.getSubtitleTextView();
    TextView savedTextView = viewWrapper.getSavedTextView();
    CheckBox checkBox = viewWrapper.getCheckBox();
    final GameSummary game = getItem(position);
    StringBuilder gameTitle = new StringBuilder();
    if (!TextUtils.isEmpty(game.getName())) {
        gameTitle.append(game.getName()).append(" ").append(context.getString(R.string.text_game_name_separator)).append(" ");
    }
    // Player 1, Player 2, Player3 etc.
    gameTitle.append(TextUtils.join(", ", CollectionUtil.transformWithIndices(game.getPlayerNames(), new FunctionWithIndex<String, CharSequence>() {

        @Override
        public CharSequence apply(String playerName, int index) {
            return PlayerScore.toDisplayName(playerName, index, context);
        }
    })));
    titleTextView.setText(gameTitle);
    numPlayersTextView.setText(Integer.toString(game.getPlayerNames().size()));
    numPlayersTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX, context.getResources().getDimensionPixelSize(// two
    game.getPlayerNames().size() >= 10 ? // digit
    R.dimen.saved_game_num_players_text_size_two_digits : R.dimen.saved_game_num_players_text_size_one_digit));
    int numRounds = game.getNumRounds();
    int roundsResId = numRounds == 1 ? R.string.text_format_rounds_singular : R.string.text_format_rounds;
    String rounds = String.format(context.getString(roundsResId), numRounds);
    subtitleTextView.setText(rounds);
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(getContext().getString(R.string.date_format), Locale.getDefault());
    savedTextView.setText(simpleDateFormat.format(new Date(game.getDateSaved())));
    checkBox.setOnCheckedChangeListener(null);
    checkBox.setChecked(checked.contains(game));
    checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                checked.add(game);
            } else {
                checked.remove(game);
            }
            if (onCheckChangedRunnable != null) {
                onCheckChangedRunnable.run();
            }
        }
    });
    log.d("saved long is: %s", game.getDateSaved());
    return view;
}
Also used : Context(android.content.Context) OnCheckedChangeListener(android.widget.CompoundButton.OnCheckedChangeListener) GameSummary(com.nolanlawson.keepscore.db.GameSummary) Date(java.util.Date) CheckBox(android.widget.CheckBox) LayoutInflater(android.view.LayoutInflater) TextView(android.widget.TextView) SimpleDateFormat(java.text.SimpleDateFormat) CompoundButton(android.widget.CompoundButton)

Example 69 with CompoundButton

use of android.widget.CompoundButton in project android-stackblur by kikoso.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    _stackBlurManager = new StackBlurManager(getBitmapFromAsset(this, "android_platform_256.png"));
    _seekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            onBlur();
        }
    });
    _toggleButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                IMAGE_TO_ANALYZE = "image_transparency.png";
                _stackBlurManager = new StackBlurManager(getBitmapFromAsset(getApplicationContext(), IMAGE_TO_ANALYZE));
                onBlur();
            } else {
                IMAGE_TO_ANALYZE = "android_platform_256.png";
                _stackBlurManager = new StackBlurManager(getBitmapFromAsset(getApplicationContext(), IMAGE_TO_ANALYZE));
                onBlur();
            }
        }
    });
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.blur_modes, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    _typeSelectSpinner.setAdapter(adapter);
    _typeSelectSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            setBlurMode(position);
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });
}
Also used : SeekBar(android.widget.SeekBar) OnSeekBarChangeListener(android.widget.SeekBar.OnSeekBarChangeListener) InjectView(roboguice.inject.InjectView) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) StackBlurManager(com.enrique.stackblur.StackBlurManager) AdapterView(android.widget.AdapterView) CompoundButton(android.widget.CompoundButton)

Example 70 with CompoundButton

use of android.widget.CompoundButton in project k-9 by k9mail.

the class EditIdentity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mIdentity = (Identity) getIntent().getSerializableExtra(EXTRA_IDENTITY);
    mIdentityIndex = getIntent().getIntExtra(EXTRA_IDENTITY_INDEX, -1);
    String accountUuid = getIntent().getStringExtra(EXTRA_ACCOUNT);
    mAccount = Preferences.getPreferences(this).getAccount(accountUuid);
    if (mIdentityIndex == -1) {
        mIdentity = new Identity();
    }
    setContentView(R.layout.edit_identity);
    /*
         * If we're being reloaded we override the original account with the one
         * we saved
         */
    if (savedInstanceState != null && savedInstanceState.containsKey(EXTRA_IDENTITY)) {
        mIdentity = (Identity) savedInstanceState.getSerializable(EXTRA_IDENTITY);
    }
    mDescriptionView = (EditText) findViewById(R.id.description);
    mDescriptionView.setText(mIdentity.getDescription());
    mNameView = (EditText) findViewById(R.id.name);
    mNameView.setText(mIdentity.getName());
    mEmailView = (EditText) findViewById(R.id.email);
    mEmailView.setText(mIdentity.getEmail());
    mReplyTo = (EditText) findViewById(R.id.reply_to);
    mReplyTo.setText(mIdentity.getReplyTo());
    //      mAccountAlwaysBcc = (EditText)findViewById(R.id.bcc);
    //      mAccountAlwaysBcc.setText(mIdentity.getAlwaysBcc());
    mSignatureLayout = (LinearLayout) findViewById(R.id.signature_layout);
    mSignatureUse = (CheckBox) findViewById(R.id.signature_use);
    mSignatureView = (EditText) findViewById(R.id.signature);
    mSignatureUse.setChecked(mIdentity.getSignatureUse());
    mSignatureUse.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                mSignatureLayout.setVisibility(View.VISIBLE);
                mSignatureView.setText(mIdentity.getSignature());
            } else {
                mSignatureLayout.setVisibility(View.GONE);
            }
        }
    });
    if (mSignatureUse.isChecked()) {
        mSignatureView.setText(mIdentity.getSignature());
    } else {
        mSignatureLayout.setVisibility(View.GONE);
    }
}
Also used : Identity(com.fsck.k9.Identity) CompoundButton(android.widget.CompoundButton)

Aggregations

CompoundButton (android.widget.CompoundButton)249 View (android.view.View)129 TextView (android.widget.TextView)102 OnCheckedChangeListener (android.widget.CompoundButton.OnCheckedChangeListener)63 ImageView (android.widget.ImageView)50 CheckBox (android.widget.CheckBox)45 AdapterView (android.widget.AdapterView)27 Intent (android.content.Intent)26 Button (android.widget.Button)24 DialogInterface (android.content.DialogInterface)23 LayoutInflater (android.view.LayoutInflater)23 OnClickListener (android.view.View.OnClickListener)20 Switch (android.widget.Switch)18 SeekBar (android.widget.SeekBar)17 SwitchCompat (android.support.v7.widget.SwitchCompat)15 AlertDialog (android.app.AlertDialog)14 RecyclerView (android.support.v7.widget.RecyclerView)13 ArrayList (java.util.ArrayList)13 LinearLayout (android.widget.LinearLayout)12 OnClickListener (android.content.DialogInterface.OnClickListener)11