Example usage for android.widget CompoundButton setChecked

List of usage examples for android.widget CompoundButton setChecked

Introduction

In this page you can find the example usage for android.widget CompoundButton setChecked.

Prototype

@Override
public void setChecked(boolean checked) 

Source Link

Document

Changes the checked state of this button.

Usage

From source file:rikka.materialpreference.SwitchPreference.java

private void syncSwitchView(final View view) {
    if (view instanceof CompoundButton) {
        CompoundButton switchView = (CompoundButton) view;
        switchView.setOnCheckedChangeListener(null);

        if (!mSetInPost) {
            switchView.setChecked(mChecked);
        } else {/* w w w  . j  a  v  a2  s .c o m*/
            view.post(new Runnable() {
                @Override
                public void run() {
                    ((CompoundButton) view).setChecked(mChecked);
                    mSetInPost = false;
                }
            });
        }

        if (view instanceof Switch) {
            ((Switch) switchView).setTextOn(mSwitchOn);
            ((Switch) switchView).setTextOff(mSwitchOff);
        } else if (view instanceof SwitchCompat) {
            ((SwitchCompat) switchView).setTextOn(mSwitchOn);
            ((SwitchCompat) switchView).setTextOff(mSwitchOff);
        }

        switchView.setOnCheckedChangeListener(mListener);
    }
}

From source file:nl.hnogames.domoticz.Adapters.LocationAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    final ViewHolder holder;
    int layoutResourceId;

    final LocationInfo mLocationInfo = data.get(position);
    holder = new ViewHolder();

    layoutResourceId = R.layout.geo_row_location;
    LayoutInflater inflater = ((Activity) context).getLayoutInflater();
    convertView = inflater.inflate(layoutResourceId, parent, false);

    if (mSharedPrefs.darkThemeEnabled()) {
        (convertView.findViewById(R.id.row_wrapper))
                .setBackground(ContextCompat.getDrawable(context, R.drawable.bordershadowdark));
        (convertView.findViewById(R.id.row_global_wrapper))
                .setBackgroundColor(ContextCompat.getColor(context, R.color.background_dark));

        if ((convertView.findViewById(R.id.remove_button)) != null)
            (convertView.findViewById(R.id.remove_button))
                    .setBackground(ContextCompat.getDrawable(context, R.drawable.button_status_dark));
    }//from   ww w . j  av a 2 s  . c o  m

    holder.enable = (CheckBox) convertView.findViewById(R.id.enableSwitch);
    holder.name = (TextView) convertView.findViewById(R.id.location_name);
    holder.radius = (TextView) convertView.findViewById(R.id.location_radius);
    holder.country = (TextView) convertView.findViewById(R.id.location_country);
    holder.address = (TextView) convertView.findViewById(R.id.location_address);
    holder.connectedSwitch = (TextView) convertView.findViewById(R.id.location_connectedSwitch);
    holder.remove = (Button) convertView.findViewById(R.id.remove_button);

    if (mLocationInfo.getAddress() != null) {
        Address address = mLocationInfo.getAddress();

        String addressString;
        String countryString;

        if (address != null) {
            addressString = address.getAddressLine(0) + ", " + address.getLocality();
            countryString = address.getCountryName();
        } else {
            addressString = context.getString(R.string.unknown);
            countryString = context.getString(R.string.unknown);
        }
        holder.address.setText(addressString);
        holder.country.setText(countryString);
    }

    holder.name.setText(mLocationInfo.getName());
    holder.radius.setText(context.getString(R.string.radius) + ": " + mLocationInfo.getRadius());

    if (!UsefulBits.isEmpty(mLocationInfo.getSwitchName())) {
        holder.connectedSwitch
                .setText(context.getString(R.string.connectedSwitch) + ": " + mLocationInfo.getSwitchName());
    } else if (mLocationInfo.getSwitchIdx() > 0) {
        holder.connectedSwitch
                .setText(context.getString(R.string.connectedSwitch) + ": " + mLocationInfo.getSwitchIdx());
    } else {
        holder.connectedSwitch.setText(
                context.getString(R.string.connectedSwitch) + ": " + context.getString(R.string.not_available));
    }

    if (!UsefulBits.isEmpty(mLocationInfo.getValue()))
        holder.connectedSwitch.setText(holder.connectedSwitch.getText() + " - " + mLocationInfo.getValue());

    holder.remove.setId(mLocationInfo.getID());
    holder.remove.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            LocationInfo removeLocation = null;
            for (LocationInfo l : data) {
                if (l.getID() == v.getId()) {
                    removeLocation = l;
                }
            }
            if (removeLocation != null)
                handleRemoveButtonClick(removeLocation);
        }
    });

    holder.enable.setId(mLocationInfo.getID());
    holder.enable.setChecked(mLocationInfo.getEnabled());
    holder.enable.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            for (LocationInfo locationInfo : data) {
                if (locationInfo.getID() == buttonView.getId()) {
                    if (!handleEnableChanged(locationInfo, holder.enable.isChecked())) {
                        buttonView.setChecked(false);
                    } else {
                        buttonView.setChecked(true);
                    }
                    break;
                }
            }
        }
    });

    convertView.setTag(holder);
    return convertView;
}

From source file:org.odk.collect.android.widgets.SelectMultiWidgetGridLayout.java

@SuppressWarnings("unchecked")
public SelectMultiWidgetGridLayout(Context context, FormEntryPrompt prompt) {
    super(context, prompt);
    mPrompt = prompt;//from w w  w. j  av  a  2  s. co  m
    mCheckboxes = new ArrayList<CheckBox>();

    // SurveyCTO-added support for dynamic select content (from .csv files)
    XPathFuncExpr xPathFuncExpr = ExternalDataUtil.getSearchXPathExpression(prompt.getAppearanceHint());
    if (xPathFuncExpr != null) {
        mItems = ExternalDataUtil.populateExternalChoices(prompt, xPathFuncExpr);
    } else {
        mItems = prompt.getSelectChoices();
    }

    setOrientation(LinearLayout.VERTICAL);

    Vector<Selection> ve = new Vector<Selection>();
    if (prompt.getAnswerValue() != null) {
        ve = (Vector<Selection>) prompt.getAnswerValue().getValue();
    }
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    int screenWidth = size.x;
    int height = size.y;

    int halfScreenWidth = (int) (screenWidth * 0.5);
    int quarterScreenWidth = (int) (halfScreenWidth * 0.5);

    glayout = new GridLayout(getContext());
    glayout.setOrientation(0);
    glayout.setColumnCount(2);
    //glayout.setRowCount(2);

    int row_index = 0;
    int col_index = 0;

    if (mItems != null) {
        for (int i = 0; i < mItems.size(); i++) {
            // no checkbox group so id by answer + offset
            CheckBox c = new CheckBox(getContext());
            c.setTag(Integer.valueOf(i));
            c.setId(QuestionWidget.newUniqueId());
            c.setText(prompt.getSelectChoiceText(mItems.get(i)));
            c.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mAnswerFontsize);
            c.setFocusable(!prompt.isReadOnly());
            c.setEnabled(!prompt.isReadOnly());

            for (int vi = 0; vi < ve.size(); vi++) {
                // match based on value, not key
                if (mItems.get(i).getValue().equals(ve.elementAt(vi).getValue())) {
                    c.setChecked(true);
                    break;
                }

            }
            mCheckboxes.add(c);
            // when clicked, check for readonly before toggling
            c.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                @Override
                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                    if (!mCheckboxInit && mPrompt.isReadOnly()) {
                        if (buttonView.isChecked()) {
                            buttonView.setChecked(false);
                            Collect.getInstance().getActivityLogger().logInstanceAction(this,
                                    "onItemClick.deselect",
                                    mItems.get((Integer) buttonView.getTag()).getValue(), mPrompt.getIndex());
                        } else {
                            buttonView.setChecked(true);
                            Collect.getInstance().getActivityLogger().logInstanceAction(this,
                                    "onItemClick.select", mItems.get((Integer) buttonView.getTag()).getValue(),
                                    mPrompt.getIndex());
                        }
                    }
                }
            });

            String audioURI = null;
            audioURI = prompt.getSpecialFormSelectChoiceText(mItems.get(i), FormEntryCaption.TEXT_FORM_AUDIO);

            String imageURI;
            if (mItems.get(i) instanceof ExternalSelectChoice) {
                imageURI = ((ExternalSelectChoice) mItems.get(i)).getImage();
            } else {
                imageURI = prompt.getSpecialFormSelectChoiceText(mItems.get(i),
                        FormEntryCaption.TEXT_FORM_IMAGE);
            }

            String videoURI = null;
            videoURI = prompt.getSpecialFormSelectChoiceText(mItems.get(i), "video");

            String bigImageURI = null;
            bigImageURI = prompt.getSpecialFormSelectChoiceText(mItems.get(i), "big-image");

            MediaLayout mediaLayout = new MediaLayout(getContext());
            mediaLayout.setAVT(prompt.getIndex(), "." + Integer.toString(i), c, audioURI, imageURI, videoURI,
                    bigImageURI);
            // mediaLayout.setAVT(index, selectionDesignator, text, audioURI, imageURI, videoURI, bigImageURI);
            // addView(mediaLayout);

            row_index = i / 2 + 1;
            col_index = i % 2;

            int orientation = display.getOrientation();
            if (orientation == 1) {
                halfScreenWidth = height / 2;
            } else {
                halfScreenWidth = screenWidth / 2;
            }

            Spec row = GridLayout.spec(row_index);
            Spec col = GridLayout.spec(col_index);
            GridLayout.LayoutParams first = new GridLayout.LayoutParams(row, col);
            first.width = halfScreenWidth;
            // first.height = quarterScreenWidth * 2;
            glayout.addView(mediaLayout, first);

            // Last, add the dividing line between elements (except for the last element)
            ImageView divider = new ImageView(getContext());
            divider.setBackgroundResource(android.R.drawable.divider_horizontal_bright);
            if (i != mItems.size() - 1) {
                if (col_index == 0)
                    glayout.addView(divider);
            }

        }
    }
    addView(glayout);
    mCheckboxInit = false;

}

From source file:com.synox.android.ui.fragment.EditShareFragment.java

/**
 * Updates the UI with the current permissions in the edited {@OCShare}
 *
 * @param editShareView     Root view in the fragment.
 *//*from  w ww . j  av  a  2 s  .  c  o  m*/
private void refreshUiFromState(View editShareView) {
    if (editShareView != null) {
        setPermissionsListening(editShareView, false);

        TextView sharee_name = (TextView) editShareView.findViewById(R.id.sharee_name);
        sharee_name.setText(mShare.getSharedWithDisplayName());

        int sharePermissions = mShare.getPermissions();
        CompoundButton compound;

        compound = (CompoundButton) editShareView.findViewById(R.id.canShareSwitch);
        compound.setChecked((sharePermissions & OCShare.SHARE_PERMISSION_FLAG) > 0);

        compound = (CompoundButton) editShareView.findViewById(R.id.canEditSwitch);
        int anyUpdatePermission = OCShare.CREATE_PERMISSION_FLAG | OCShare.UPDATE_PERMISSION_FLAG
                | OCShare.DELETE_PERMISSION_FLAG;
        boolean canEdit = (sharePermissions & anyUpdatePermission) > 0;
        compound.setChecked(canEdit);

        if (mFile.isFolder()) {
            compound = (CompoundButton) editShareView.findViewById(R.id.canEditCreateCheckBox);
            compound.setChecked((sharePermissions & OCShare.CREATE_PERMISSION_FLAG) > 0);
            compound.setVisibility(canEdit ? View.VISIBLE : View.GONE);

            compound = (CompoundButton) editShareView.findViewById(R.id.canEditChangeCheckBox);
            compound.setChecked((sharePermissions & OCShare.UPDATE_PERMISSION_FLAG) > 0);
            compound.setVisibility(canEdit ? View.VISIBLE : View.GONE);

            compound = (CompoundButton) editShareView.findViewById(R.id.canEditDeleteCheckBox);
            compound.setChecked((sharePermissions & OCShare.DELETE_PERMISSION_FLAG) > 0);
            compound.setVisibility(canEdit ? View.VISIBLE : View.GONE);
        }

        setPermissionsListening(editShareView, true);

    }
}

From source file:com.androidinspain.deskclock.alarms.dataadapter.ExpandedAlarmViewHolder.java

private void bindDaysOfWeekButtons(Alarm alarm, Context context) {
    final List<Integer> weekdays = DataModel.getDataModel().getWeekdayOrder().getCalendarDays();
    for (int i = 0; i < weekdays.size(); i++) {
        final CompoundButton dayButton = dayButtons[i];
        if (alarm.daysOfWeek.isBitOn(weekdays.get(i))) {
            dayButton.setChecked(true);
            dayButton.setTextColor(ThemeUtils.resolveColor(context, android.R.attr.windowBackground));
        } else {//from   www .  j  a  va2  s .  co m
            dayButton.setChecked(false);
            dayButton.setTextColor(Color.WHITE);
        }
    }
    if (alarm.daysOfWeek.isRepeating()) {
        repeat.setChecked(true);
        repeatDays.setVisibility(View.VISIBLE);
    } else {
        repeat.setChecked(false);
        repeatDays.setVisibility(View.GONE);
    }
}

From source file:com.actionbarsherlock.internal.view.menu.ListMenuItemView.java

public void setChecked(boolean checked) {
    CompoundButton compoundButton;

    if (mItemData.isExclusiveCheckable()) {
        if (mRadioButton == null) {
            insertRadioButton();// w  ww  .jav  a  2 s. c o  m
        }
        compoundButton = mRadioButton;
    } else {
        if (mCheckBox == null) {
            insertCheckBox();
        }
        compoundButton = mCheckBox;
    }

    compoundButton.setChecked(checked);
}

From source file:com.actionbarsherlock.internal.view.menu.ListMenuItemView.java

public void setCheckable(boolean checkable) {

    if (!checkable && mRadioButton == null && mCheckBox == null) {
        return;//from   ww w.j  a v  a 2s . c om
    }

    if (mRadioButton == null) {
        insertRadioButton();
    }
    if (mCheckBox == null) {
        insertCheckBox();
    }

    // Depending on whether its exclusive check or not, the checkbox or
    // radio button will be the one in use (and the other will be otherCompoundButton)
    final CompoundButton compoundButton;
    final CompoundButton otherCompoundButton;

    if (mItemData.isExclusiveCheckable()) {
        compoundButton = mRadioButton;
        otherCompoundButton = mCheckBox;
    } else {
        compoundButton = mCheckBox;
        otherCompoundButton = mRadioButton;
    }

    if (checkable) {
        compoundButton.setChecked(mItemData.isChecked());

        final int newVisibility = checkable ? VISIBLE : GONE;
        if (compoundButton.getVisibility() != newVisibility) {
            compoundButton.setVisibility(newVisibility);
        }

        // Make sure the other compound button isn't visible
        if (otherCompoundButton.getVisibility() != GONE) {
            otherCompoundButton.setVisibility(GONE);
        }
    } else {
        mCheckBox.setVisibility(GONE);
        mRadioButton.setVisibility(GONE);
    }
}

From source file:com.cerema.cloud2.ui.fragment.EditShareFragment.java

/**
 * Updates the UI with the current permissions in the edited {@OCShare}
 *
 * @param editShareView     Root view in the fragment.
 *//*ww w. java 2  s  .  c  o  m*/
private void refreshUiFromState(View editShareView) {
    if (editShareView != null) {
        setPermissionsListening(editShareView, false);

        int sharePermissions = mShare.getPermissions();
        boolean isFederated = ShareType.FEDERATED.equals(mShare.getShareType());
        CompoundButton compound;

        compound = (CompoundButton) editShareView.findViewById(R.id.canShareSwitch);
        if (isFederated) {
            compound.setVisibility(View.INVISIBLE);
        }
        compound.setChecked((sharePermissions & OCShare.SHARE_PERMISSION_FLAG) > 0);

        compound = (CompoundButton) editShareView.findViewById(R.id.canEditSwitch);
        int anyUpdatePermission = OCShare.CREATE_PERMISSION_FLAG | OCShare.UPDATE_PERMISSION_FLAG
                | OCShare.DELETE_PERMISSION_FLAG;
        boolean canEdit = (sharePermissions & anyUpdatePermission) > 0;
        compound.setChecked(canEdit);

        if (mFile.isFolder() && !isFederated) {
            compound = (CompoundButton) editShareView.findViewById(R.id.canEditCreateCheckBox);
            compound.setChecked((sharePermissions & OCShare.CREATE_PERMISSION_FLAG) > 0);
            compound.setVisibility(canEdit ? View.VISIBLE : View.GONE);

            compound = (CompoundButton) editShareView.findViewById(R.id.canEditChangeCheckBox);
            compound.setChecked((sharePermissions & OCShare.UPDATE_PERMISSION_FLAG) > 0);
            compound.setVisibility(canEdit ? View.VISIBLE : View.GONE);

            compound = (CompoundButton) editShareView.findViewById(R.id.canEditDeleteCheckBox);
            compound.setChecked((sharePermissions & OCShare.DELETE_PERMISSION_FLAG) > 0);
            compound.setVisibility(canEdit ? View.VISIBLE : View.GONE);
        }

        setPermissionsListening(editShareView, true);

    }
}

From source file:de.j4velin.wifiAutoOff.Preferences.java

@SuppressLint("NewApi")
@Override//from  w  w w. j ava 2s. co m
public boolean onCreateOptionsMenu(final Menu menu) {
    getMenuInflater().inflate(R.menu.menu, menu);
    if (android.os.Build.VERSION.SDK_INT >= 11) {
        CompoundButton enable = (CompoundButton) menu.findItem(R.id.enable).getActionView();
        if (android.os.Build.VERSION.SDK_INT < 14) {
            enable.setText("Enable");
        }
        enable.setChecked(getPackageManager().getComponentEnabledSetting(
                new ComponentName(this, Receiver.class)) != PackageManager.COMPONENT_ENABLED_STATE_DISABLED);
        // disable initially if not checked
        if (!enable.isChecked()) {
            @SuppressWarnings("deprecation")
            PreferenceScreen ps = getPreferenceScreen();
            for (int i = 0; i < ps.getPreferenceCount(); i++) {
                ps.getPreference(i).setEnabled(false);
            }
        }
        enable.setOnCheckedChangeListener(new OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                @SuppressWarnings("deprecation")
                PreferenceScreen ps = getPreferenceScreen();
                // start at 1 to skip "status" preference
                for (int i = 1; i < ps.getPreferenceCount(); i++) {
                    ps.getPreference(i).setEnabled(isChecked);
                }
                getPackageManager().setComponentEnabledSetting(
                        new ComponentName(Preferences.this, Receiver.class),
                        isChecked ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED
                                : PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
                        PackageManager.DONT_KILL_APP);
                if (!isChecked)
                    stopService(new Intent(Preferences.this, ScreenChangeDetector.class));
                getPackageManager().setComponentEnabledSetting(
                        new ComponentName(Preferences.this, ScreenChangeDetector.class),
                        isChecked ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED
                                : PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
                        PackageManager.DONT_KILL_APP);
            }
        });
    }
    return true;
}

From source file:com.uwetrottmann.movies.ui.CheckInDialogFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View layout = inflater.inflate(R.layout.checkin_dialog, null);
    final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getSherlockActivity());

    // some required values
    final String imdbId = getArguments().getString(InitBundle.IMDBID);
    final String title = getArguments().getString(InitBundle.TITLE);

    // get share service enabled settings
    mGetGlueChecked = prefs.getBoolean(AppPreferences.KEY_SHAREWITHGETGLUE, false);
    mTraktChecked = prefs.getBoolean(AppPreferences.KEY_SHAREWITHTRAKT, false);

    // Message box
    mMessageBox = (EditText) layout.findViewById(R.id.message);

    // Paste title button
    layout.findViewById(R.id.paste).setOnClickListener(new OnClickListener() {
        @Override/*from  w w  w .j av  a 2 s. c om*/
        public void onClick(View v) {
            int start = mMessageBox.getSelectionStart();
            int end = mMessageBox.getSelectionEnd();
            mMessageBox.getText().replace(Math.min(start, end), Math.max(start, end), title, 0, title.length());
        }
    });

    // Clear button
    layout.findViewById(R.id.textViewClear).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            mMessageBox.setText(null);
        }
    });

    // GetGlue toggle
    mToggleGetGlueButton = (CompoundButton) layout.findViewById(R.id.toggleGetGlue);
    mToggleGetGlueButton.setChecked(mGetGlueChecked);
    mToggleGetGlueButton.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                if (!GetGlue.isAuthenticated(prefs)) {
                    if (!AndroidUtils.isNetworkConnected(getActivity())) {
                        Toast.makeText(getActivity(), R.string.offline, Toast.LENGTH_LONG).show();
                        buttonView.setChecked(false);
                        return;
                    } else {
                        // authenticate already here
                        Intent i = new Intent(getSherlockActivity(), GetGlueAuthActivity.class);
                        startActivity(i);
                    }
                }
            }

            mGetGlueChecked = isChecked;
            prefs.edit().putBoolean(AppPreferences.KEY_SHAREWITHGETGLUE, isChecked).commit();
            updateCheckInButtonState();
        }
    });

    // trakt toggle
    mToggleTraktButton = (CompoundButton) layout.findViewById(R.id.toggleTrakt);
    mToggleTraktButton.setChecked(mTraktChecked);
    mToggleTraktButton.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                if (!Utils.isTraktCredentialsValid(getActivity())) {
                    // authenticate already here
                    TraktCredentialsDialogFragment newFragment = TraktCredentialsDialogFragment.newInstance();
                    newFragment.show(getFragmentManager(), "traktdialog");
                }
            }

            mTraktChecked = isChecked;
            prefs.edit().putBoolean(AppPreferences.KEY_SHAREWITHTRAKT, isChecked).commit();
            updateCheckInButtonState();
        }
    });

    // Check in button
    mCheckinButton = layout.findViewById(R.id.checkinButton);
    updateCheckInButtonState();
    mCheckinButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (TextUtils.isEmpty(imdbId)) {
                return;
            }

            if (!AndroidUtils.isNetworkConnected(getActivity())) {
                Toast.makeText(getActivity(), R.string.offline, Toast.LENGTH_LONG).show();
                return;
            }

            final String message = mMessageBox.getText().toString();

            if (mGetGlueChecked) {
                if (!GetGlue.isAuthenticated(prefs)) {
                    // cancel if required auth data is missing
                    mToggleGetGlueButton.setChecked(false);
                    mGetGlueChecked = false;
                    updateCheckInButtonState();
                    return;
                } else {
                    // check in, use task on thread pool
                    AndroidUtils.executeAsyncTask(new CheckInTask(imdbId, message, getActivity()),
                            new Void[] {});
                }
            }

            if (mTraktChecked) {
                if (!Utils.isTraktCredentialsValid(getActivity())) {
                    // cancel if required auth data is missing
                    mToggleTraktButton.setChecked(false);
                    mTraktChecked = false;
                    updateCheckInButtonState();
                    return;
                } else {
                    // check in

                    // We want to remove any currently showing
                    // dialog, so make our own transaction and
                    // take care of that here.
                    FragmentTransaction ft = getFragmentManager().beginTransaction();
                    Fragment prev = getFragmentManager().findFragmentByTag("progress-dialog");
                    if (prev != null) {
                        ft.remove(prev);
                    }
                    ProgressDialog newFragment = ProgressDialog.newInstance();
                    newFragment.show(ft, "progress-dialog");

                    // start the trakt check in task
                    AndroidUtils.executeAsyncTask(
                            new TraktTask(getActivity(), getFragmentManager(), null).checkin(imdbId, message),
                            new Void[] { null });
                }
            }

            dismiss();
        }
    });

    return layout;
}