Search in sources :

Example 6 with CompoundButton

use of android.widget.CompoundButton in project android_frameworks_base by ParanoidAndroid.

the class NotificationBuilderTest method setChecked.

private void setChecked(int id) {
    final CompoundButton b = (CompoundButton) findViewById(id);
    b.setChecked(true);
}
Also used : CompoundButton(android.widget.CompoundButton)

Example 7 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 8 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 9 with CompoundButton

use of android.widget.CompoundButton in project GT by Tencent.

the class GTCaptureActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.pi_capture);
    initLayout();
    tv_tcpdump_back = (TextView) findViewById(R.id.tcpdump_back_gt);
    tv_tcpdump_back.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            finish();
        }
    });
    tv_tcpdump_curFile.setText(curFilePath == null ? "" : curFilePath);
    tv_tcpdump_progress.setText(curFileSize == null ? "" : curFileSize + "KB");
    tv_param_switch = (TextView) findViewById(R.id.tcpdump_param_switch);
    tv_param_switch.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (!switch_param) {
                switch_param = true;
                tv_param_title.setVisibility(View.VISIBLE);
                fl_param.setVisibility(View.VISIBLE);
            } else {
                switch_param = false;
                et_param.setText(param);
                tv_param_title.setVisibility(View.GONE);
                fl_param.setVisibility(View.GONE);
            }
        }
    });
    btn_param_clear = (Button) findViewById(R.id.tcpdump_param_cancel);
    btn_param_clear.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            param = "";
            et_param.setText(param);
        }
    });
    et_param = (EditText) findViewById(R.id.tcpdump_param);
    et_param.setOnEditorActionListener(new OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            return (event.getKeyCode() == KeyEvent.KEYCODE_ENTER);
        }
    });
    tv_switch = (TextView) findViewById(R.id.tcpdump_switch);
    tv_switch.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // 获取权限过程比较耗时,交给菊花去处理
            Thread t = new Thread(new ProgressRunnable());
            t.start();
        }
    });
    cb_param_switch = (GTCheckBox) findViewById(R.id.cb_param_switch);
    cb_param_switch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                cur_param_switch_status = isChecked;
                tv_param_title.setVisibility(View.VISIBLE);
                fl_param.setVisibility(View.VISIBLE);
                String cur_param = et_param.getText().toString();
                if (cur_param.equals("") || cur_param.trim().equals("")) {
                    et_param.setText(default_param);
                }
            } else {
                cur_param_switch_status = isChecked;
                tv_param_title.setVisibility(View.GONE);
                fl_param.setVisibility(View.GONE);
            }
        }
    });
    tcpdumpSwitchHandler = new Handler() {

        public void handleMessage(Message msg) {
            switch(msg.what) {
                case // 启动抓包开始,控件状态置为红色,显示stop
                0:
                    switch_tcpdump = true;
                    tv_switch.setBackgroundResource(R.drawable.switch_off_border);
                    tv_switch.setText(getString(R.string.stop));
                    break;
                case // 抓包结束,控件状态置为绿色,显示start
                1:
                    switch_tcpdump = false;
                    tv_switch.setBackgroundResource(R.drawable.switch_on_border);
                    tv_switch.setText(getString(R.string.start));
                    break;
                case // 吐槽提示
                2:
                    String message = msg.obj == null ? "" : msg.obj.toString();
                    WidgetUtils.openToast(message);
                    // 有菊花则停止菊花
                    dismissProDialog();
                    break;
                case // 抓包文件发生大小变化时
                3:
                    curFileSize = msg.obj == null ? "" : msg.obj.toString();
                    tv_tcpdump_progress.setText(curFileSize + "KB");
                    break;
                case // 启动抓包完成,显示当前保存的抓包文件  TODO
                4:
                    curFilePath = msg.obj == null ? "" : msg.obj.toString();
                    tv_tcpdump_curFile.setText(curFilePath == null ? "" : curFilePath);
                    // 停止菊花
                    dismissProDialog();
                    break;
                case // 抓包之前的校验,转菊花
                5:
                    showProDialog();
                    break;
            }
        }
    };
    GTCaptureEngine.getInstance().addListener(this);
}
Also used : Message(android.os.Message) Handler(android.os.Handler) TextView(android.widget.TextView) View(android.view.View) KeyEvent(android.view.KeyEvent) OnClickListener(android.view.View.OnClickListener) OnEditorActionListener(android.widget.TextView.OnEditorActionListener) TextView(android.widget.TextView) CompoundButton(android.widget.CompoundButton)

Example 10 with CompoundButton

use of android.widget.CompoundButton in project SeriesGuide by UweTrottmann.

the class DataLiberationFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_data_liberation, container, false);
    unbinder = ButterKnife.bind(this, v);
    progressBar.setVisibility(View.GONE);
    // setup listeners
    buttonExport.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            tryDataLiberationAction(REQUEST_CODE_EXPORT);
        }
    });
    checkBoxImportWarning.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            updateImportButtonEnabledState();
        }
    });
    checkBoxShows.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            updateImportButtonEnabledState();
        }
    });
    checkBoxLists.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            updateImportButtonEnabledState();
        }
    });
    checkBoxMovies.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            updateImportButtonEnabledState();
        }
    });
    buttonImport.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            tryDataLiberationAction(REQUEST_CODE_IMPORT);
        }
    });
    // as we use Storage Access Framework in this case
    if (AndroidUtils.isKitKatOrHigher()) {
        buttonShowsExportFile.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                DataLiberationTools.selectExportFile(DataLiberationFragment.this, JsonExportTask.EXPORT_JSON_FILE_SHOWS, REQUEST_CODE_SHOWS_EXPORT_URI);
            }
        });
        buttonShowsImportFile.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                DataLiberationTools.selectImportFile(DataLiberationFragment.this, REQUEST_CODE_SHOWS_IMPORT_URI);
            }
        });
        buttonListsExportFile.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                DataLiberationTools.selectExportFile(DataLiberationFragment.this, JsonExportTask.EXPORT_JSON_FILE_LISTS, REQUEST_CODE_LISTS_EXPORT_URI);
            }
        });
        buttonListsImportFile.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                DataLiberationTools.selectImportFile(DataLiberationFragment.this, REQUEST_CODE_LISTS_IMPORT_URI);
            }
        });
        buttonMoviesExportFile.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                DataLiberationTools.selectExportFile(DataLiberationFragment.this, JsonExportTask.EXPORT_JSON_FILE_MOVIES, REQUEST_CODE_MOVIES_EXPORT_URI);
            }
        });
        buttonMoviesImportFile.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                DataLiberationTools.selectImportFile(DataLiberationFragment.this, REQUEST_CODE_MOVIES_IMPORT_URI);
            }
        });
    } else {
        buttonShowsExportFile.setVisibility(View.GONE);
        buttonShowsImportFile.setVisibility(View.GONE);
        buttonListsExportFile.setVisibility(View.GONE);
        buttonListsImportFile.setVisibility(View.GONE);
        buttonMoviesExportFile.setVisibility(View.GONE);
        buttonMoviesImportFile.setVisibility(View.GONE);
    }
    updateFileViews();
    return v;
}
Also used : OnCheckedChangeListener(android.widget.CompoundButton.OnCheckedChangeListener) OnClickListener(android.view.View.OnClickListener) BindView(butterknife.BindView) View(android.view.View) TextView(android.widget.TextView) CompoundButton(android.widget.CompoundButton)

Aggregations

CompoundButton (android.widget.CompoundButton)235 View (android.view.View)118 TextView (android.widget.TextView)95 OnCheckedChangeListener (android.widget.CompoundButton.OnCheckedChangeListener)60 ImageView (android.widget.ImageView)48 CheckBox (android.widget.CheckBox)42 AdapterView (android.widget.AdapterView)25 Button (android.widget.Button)22 DialogInterface (android.content.DialogInterface)21 LayoutInflater (android.view.LayoutInflater)20 OnClickListener (android.view.View.OnClickListener)18 Intent (android.content.Intent)17 SeekBar (android.widget.SeekBar)17 Switch (android.widget.Switch)17 SwitchCompat (android.support.v7.widget.SwitchCompat)15 AlertDialog (android.app.AlertDialog)13 ArrayList (java.util.ArrayList)12 Context (android.content.Context)11 OnClickListener (android.content.DialogInterface.OnClickListener)11 Cursor (android.database.Cursor)11