Java Code Examples for android.widget.CheckBox#setOnClickListener()

The following examples show how to use android.widget.CheckBox#setOnClickListener() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ItemActivity.java    From OpenMemories-Tweak with MIT License 6 votes vote down vote up
public SwitchItem(Context context, String title, Adapter adapter) {
    super(context);
    inflate(context, R.layout.view_switch, this);
    titleView = (TextView) findViewById(R.id.title);
    summaryView = (TextView) findViewById(R.id.summary);
    checkBox = (CheckBox) findViewById(R.id.checkbox);

    this.adapter = adapter;
    titleView.setText(title);

    checkBox.setOnClickListener(view -> {
        try {
            SwitchItem.this.adapter.setEnabled(checkBox.isChecked());
        } catch (Exception e) {
            showError(e);
        }
        update();
    });
}
 
Example 2
Source File: ErrorsActivity.java    From NightWatch with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    highCheckboxView = (CheckBox) findViewById(R.id.highSeverityCheckbox);
    mediumCheckboxView = (CheckBox) findViewById(R.id.midSeverityCheckbox);
    lowCheckboxView = (CheckBox) findViewById(R.id.lowSeverityCheckBox);

    highCheckboxView.setOnClickListener(checkboxListener);
    mediumCheckboxView.setOnClickListener(checkboxListener);
    lowCheckboxView.setOnClickListener(checkboxListener);

    updateErrors();
    errorList = (ListView) findViewById(R.id.errorList);
    adapter = new ErrorListAdapter(getApplicationContext(), errors);
    errorList.setAdapter(adapter);
}
 
Example 3
Source File: HeatmapsPlacesDemoActivity.java    From android-maps-utils with Apache License 2.0 6 votes vote down vote up
/**
 * Creates check box for a given search term
 *
 * @param keyword the search terms associated with the check box
 */
private void makeCheckBox(final String keyword) {
    mCheckboxLayout.setVisibility(View.VISIBLE);

    // Make new checkbox
    CheckBox checkBox = new CheckBox(this);
    checkBox.setText(keyword);
    checkBox.setTextColor(HEATMAP_COLORS[mOverlaysRendered]);
    checkBox.setChecked(true);
    checkBox.setOnClickListener(view -> {
        CheckBox c = (CheckBox) view;
        // Text is the keyword
        TileOverlay overlay = mOverlays.get(keyword);
        if (overlay != null) {
            overlay.setVisible(c.isChecked());
        }
    });
    mCheckboxLayout.addView(checkBox);
}
 
Example 4
Source File: ToSFragment.java    From Lunary-Ethereum-Wallet with GNU General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("ConstantConditions")
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    tos = (TextView) getView().findViewById(R.id.tostext);
    tos.setText(Html.fromHtml(loadTerms()));
    read = (CheckBox) getView().findViewById(R.id.checkBox);

    read.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            checked = read.isChecked();
        }
    });
}
 
Example 5
Source File: CustomProgressDialog.java    From commcare-android with Apache License 2.0 6 votes vote down vote up
private void setupDeterminateView(View view) {
    ProgressBar bar = view.findViewById(R.id.progress_bar_horizontal);
    bar.setProgress(progressBarProgress);
    bar.setMax(progressBarMax);
    if (progressBarIsVisible) {
        bar.setVisibility(View.VISIBLE);
    } else {
        bar.setVisibility(View.GONE);
    }

    if (usingCheckbox) {
        CheckBox cb = view.findViewById(R.id.progress_dialog_checkbox);
        cb.setVisibility(View.VISIBLE);
        cb.setText(checkboxText);
        cb.setOnClickListener(v -> isChecked = ((CheckBox)v).isChecked());
        if (isChecked) {
            cb.toggle();
        }
    }
}
 
Example 6
Source File: CheckboxPref.java    From oversec with GNU General Public License v3.0 6 votes vote down vote up
public CheckboxPref(Context context, String head, String body) {
    super(context);
    LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    inflater.inflate(R.layout.checkbox_pref, this);

    TextView title = (TextView) findViewById(R.id.pref_title);
    TextView sub = (TextView) findViewById(R.id.pref_sub);
    title.setText(head);
    sub.setText(body);

    final CheckBox cb = (CheckBox) findViewById(R.id.pref_checkbox);
    cb.setChecked(getValue());

    cb.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            setValue(
                    cb.isChecked());

        }
    });
}
 
Example 7
Source File: ActionBarFragmentMenu.java    From V.FlyoutTest with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.action_bar_fragment_menu);

    // Make sure the two menu fragments are created.
    FragmentManager fm = getSupportFragmentManager();
    FragmentTransaction ft = fm.beginTransaction();
    mFragment1 = (MenuFragment)fm.findFragmentByTag("f1");
    if (mFragment1 == null) {
        mFragment1 = new MenuFragment();
        ft.add(mFragment1, "f1");
    }
    mFragment2 = (Menu2Fragment)fm.findFragmentByTag("f2");
    if (mFragment2 == null) {
        mFragment2 = new Menu2Fragment();
        ft.add(mFragment2, "f2");
    }
    ft.commit();

    // Watch check box clicks.
    mCheckBox1 = (CheckBox)findViewById(R.id.menu1);
    mCheckBox1.setOnClickListener(mClickListener);
    mCheckBox2 = (CheckBox)findViewById(R.id.menu2);
    mCheckBox2.setOnClickListener(mClickListener);
    mCheckBox3 = (CheckBox)findViewById(R.id.menu3);
    mCheckBox3.setOnClickListener(mClickListener);
    mHasOptionsMenu = (CheckBox)findViewById(R.id.has_options_menu);
    mHasOptionsMenu.setOnClickListener(mClickListener);
    mMenuVisibility = (CheckBox)findViewById(R.id.menu_visibility);
    mMenuVisibility.setOnClickListener(mClickListener);

    // Make sure fragments start out with correct visibility.
    updateFragmentVisibility();
}
 
Example 8
Source File: FileExpandableAdapter.java    From ShareBox with Apache License 2.0 5 votes vote down vote up
@Override
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
    String f = (String) getChild(groupPosition, childPosition);
    FileExpandableInfo vh = (FileExpandableInfo) getGroup(groupPosition);
    if (convertView == null)
        convertView = LayoutInflater.from(mContext).inflate(R.layout.layout_file_item, parent, false);

    FileUtil.MediaFileType type = mTabHolder.getType();
    if (type == FileUtil.MediaFileType.APP && f.startsWith("/data/app") && mInstalledAppNames != null) {
        ((TextView) convertView.findViewById(R.id.text_name)).setText(mInstalledAppNames[childPosition]);
    } else {
        ((TextView) convertView.findViewById(R.id.text_name)).setText(FileUtil.INSTANCE.getFileName(f));
    }

    ImageView icon = (ImageView) convertView.findViewById(R.id.icon);
    icon.setImageDrawable(null);

    setChildViewThumb(type, f, icon);

    CheckBox check = (CheckBox) convertView.findViewById(R.id.check_box);
    check.setChecked(vh.isItemActivated(f));
    check.setTag(f);
    check.setTag(R.id.extra_tag, vh);
    check.setOnClickListener(mCheckOnClickListener);

    convertView.setTag(f);
    convertView.setOnClickListener(this);
    convertView.setOnLongClickListener(this);
    return convertView;
}
 
Example 9
Source File: ConfirmDialog.java    From ticdesign with Apache License 2.0 5 votes vote down vote up
private void init() {
    setContentView(R.layout.confirm_dialog_ticwear);
    mTitleTv = (TextView) findViewById(android.R.id.title);
    mMessageTv = (TextView) findViewById(R.id.message);
    mConfirmTv = (TextView) findViewById(R.id.confirm);
    mCheckbox = (CheckBox) findViewById(R.id.checkbox);
    FloatingActionButton negativeBtn = (FloatingActionButton) findViewById(R.id.cancel);
    mPositiveBtn = (FloatingActionButton) findViewById(R.id.ok);

    negativeBtn.setOnClickListener(this);
    mPositiveBtn.setOnClickListener(this);
    mCheckbox.setOnClickListener(this);

    updateButton(false);
}
 
Example 10
Source File: RecipeCheckboxArrayAdapter.java    From biermacht with Apache License 2.0 5 votes vote down vote up
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
  // View to return
  View row = convertView;

  if (row == null) {
    // Get inflater
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    row = inflater.inflate(R.layout.row_layout_checkbox, parent, false);
  }

  TextView textView = (TextView) row.findViewById(R.id.label);
  textView.setText(list.get(position).getRecipeName());
  final CheckBox checkBox = (CheckBox) row.findViewById(R.id.checkbox);

  // Set on click listener for checkbox
  checkBox.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
      checkedByName.put(list.get(position).getRecipeName(), checkBox.isChecked());
    }
  });

  // We also want one for the text view
  textView.setOnClickListener(new View.OnClickListener() {

    @Override
    public void onClick(View v) {
      checkBox.setChecked(! checkBox.isChecked());
      checkedByName.put(list.get(position).getRecipeName(), checkBox.isChecked());
    }
  });

  // Set the checkbox accordingly
  checkBox.setChecked(checkedByName.get(list.get(position).getRecipeName()));

  return row;
}
 
Example 11
Source File: ChatSettingsFragment.java    From actor-platform with GNU Affero General Public License v3.0 5 votes vote down vote up
protected void setupCheckbox(View root, int chbId, int contId, int titleId, OnClLstnr lstnr, Checker checker) {
    final CheckBox animationsAtoPlay = (CheckBox) root.findViewById(chbId);
    animationsAtoPlay.setChecked(checker.check());
    View.OnClickListener animListener = v -> {
        lstnr.onClick();
        animationsAtoPlay.setChecked(checker.check());
    };
    animationsAtoPlay.setOnClickListener(animListener);
    root.findViewById(contId).setOnClickListener(animListener);
    ((TextView) root.findViewById(titleId)).setTextColor(ActorSDK.sharedActor().style.getTextPrimaryColor());
}
 
Example 12
Source File: EncounterListFragment.java    From sana.mobile with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public View getView(final int pos, View inView, ViewGroup parent) {
    Log.i(TAG + ".mAdapter", "getView()");
    if (inView == null) {
        //LayoutInflater inflater = (LayoutInflater) context
        //        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        inView = mInflater.inflate(R.layout.encounterlist_item, parent, false);
    }

    final CheckBox cBox = (CheckBox) inView.findViewById(R.id.checkbox);
    // CheckBox
    cBox.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            // Need the size check
            CheckBox cb = (CheckBox) v.findViewById(R.id.checkbox);
            if (cb.isChecked()) {
                if (itemChecked.size() > 0)
                    itemChecked.set(pos, true);
            } else if (!cb.isChecked()) {
                if (itemChecked.size() > 0)
                    itemChecked.set(pos, false);
            }
        }
    });
    if (itemChecked.size() > 0)
        cBox.setChecked(itemChecked.get(pos));
    return super.getView(pos, inView, parent);
}
 
Example 13
Source File: ChangeRulesDialogFragment.java    From GameOfLife with MIT License 5 votes vote down vote up
private void setOnClickListener(CheckBox checkBox) {
    checkBox.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onCheckboxClicked();
        }
    });
}
 
Example 14
Source File: ActivitySavedRules.java    From LibreTasks with Apache License 2.0 5 votes vote down vote up
/**
 * Render a single Rule element in the list of all rules.
 * 
 * TODO(acase): Consider using convertView for performance
 * 
 * @return the view for this listview item
 */
public View getView(final int position, View convertView, ViewGroup parent) {
  // Initialize views
  View item = mInflater.inflate(layoutId, null);
  TextView text = (TextView) item.findViewById(R.id.text1);
  TextView desc = (TextView) item.findViewById(R.id.text2);
  CheckBox checkbox = (CheckBox) item.findViewById(R.id.checkbox);

  // Main text shouldn't be focusable so that the listview item is clickable
  text.setText(rules.get(position).getName());
  text.setFocusable(false);
  text.setClickable(false);

  // Rule description shouldn't be focusable so that the listview item is clickable
  desc.setText(rules.get(position).getDescription());
  desc.setFocusable(false);
  desc.setClickable(false);

  // Enable/disable rule checkbox, connect it to toggling event listener
  checkbox.setChecked(rules.get(position).getIsEnabled());
  checkbox.setFocusable(false);
  checkbox.setOnClickListener(new OnClickListener() {
    public void onClick(View v) {
      toggleRule(position);
    }
  });

  return item;
}
 
Example 15
Source File: FragmentMenu.java    From codeexamples-android with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.fragment_menu);
    
    // Make sure the two menu fragments are created.
    FragmentManager fm = getFragmentManager();
    FragmentTransaction ft = fm.beginTransaction();
    mFragment1 = fm.findFragmentByTag("f1");
    if (mFragment1 == null) {
        mFragment1 = new MenuFragment();
        ft.add(mFragment1, "f1");
    }
    mFragment2 = fm.findFragmentByTag("f2");
    if (mFragment2 == null) {
        mFragment2 = new Menu2Fragment();
        ft.add(mFragment2, "f2");
    }
    ft.commit();
    
    // Watch check box clicks.
    mCheckBox1 = (CheckBox)findViewById(R.id.menu1);
    mCheckBox1.setOnClickListener(mClickListener);
    mCheckBox2 = (CheckBox)findViewById(R.id.menu2);
    mCheckBox2.setOnClickListener(mClickListener);
    
    // Make sure fragments start out with correct visibility.
    updateFragmentVisibility();
}
 
Example 16
Source File: CreatePoiFragment.java    From AndroidApp with Mozilla Public License 2.0 4 votes vote down vote up
private void openingHoursLayoutSetup() {
    hoursSwitch24_7 = (Switch) getActivity().findViewById(R.id.hoursSwitch24_7);
    hoursSwitch24_7.setChecked(false);
    extendedOpeningHoursContainer = (LinearLayout) getActivity().findViewById(R.id.extendedOpeningHoursContainer);
    extendedOpeningHoursContainer.setVisibility(View.VISIBLE);
    openingHours = (TextView) getActivity().findViewById(R.id.openingHours);
    closingHours = (TextView) getActivity().findViewById(R.id.closingHours);

    //week CheckBoxes
    checkboxMonday = (CheckBox) getActivity().findViewById(R.id.checkboxMonday);
    checkboxTuesday = (CheckBox) getActivity().findViewById(R.id.checkboxTuesday);
    checkboxWednesday = (CheckBox) getActivity().findViewById(R.id.checkboxWednesday);
    checkboxThursday = (CheckBox) getActivity().findViewById(R.id.checkboxThursday);
    checkboxFriday = (CheckBox) getActivity().findViewById(R.id.checkboxFriday);
    checkboxSaturday = (CheckBox) getActivity().findViewById(R.id.checkboxSaturday);
    checkboxSunday = (CheckBox) getActivity().findViewById(R.id.checkboxSunday);
    checkboxAll = (CheckBox) getActivity().findViewById(R.id.checkboxAll);
    checkboxMonday.setOnClickListener(openingHoursViewListener);
    checkboxTuesday.setOnClickListener(openingHoursViewListener);
    checkboxWednesday.setOnClickListener(openingHoursViewListener);
    checkboxThursday.setOnClickListener(openingHoursViewListener);
    checkboxFriday.setOnClickListener(openingHoursViewListener);
    checkboxSaturday.setOnClickListener(openingHoursViewListener);
    checkboxSunday.setOnClickListener(openingHoursViewListener);
    checkboxAll.setOnClickListener(openingHoursViewListener);

    hoursSwitch24_7.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
            if (isChecked) {
                //do stuff when Switch is ON
                extendedOpeningHoursContainer.setVisibility(View.GONE);
            } else {
                //do stuff when Switch if OFF
                extendedOpeningHoursContainer.setVisibility(View.VISIBLE);
            }
        }
    });
    openingHours.setOnClickListener(openingHoursViewListener);
    closingHours.setOnClickListener(openingHoursViewListener);

}
 
Example 17
Source File: MountServerActivity.java    From samba-documents-provider with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);

  mCache = SambaProviderApplication.getDocumentCache(this);
  mTaskManager = SambaProviderApplication.getTaskManager(this);
  mShareManager = SambaProviderApplication.getServerManager(this);
  mClient = SambaProviderApplication.getSambaClient(this);

  mNeedPasswordCheckbox = (CheckBox) findViewById(R.id.needs_password);
  mNeedPasswordCheckbox.setOnClickListener(mPasswordStateChangeListener);

  mPasswordHideGroup = findViewById(R.id.password_hide_group);

  mSharePathEditText = (BrowsingAutocompleteTextView) findViewById(R.id.share_path);
  mSharePathEditText.setOnKeyListener(mMountKeyListener);

  mUsernameEditText = (EditText) findViewById(R.id.username);
  mDomainEditText = (EditText) findViewById(R.id.domain);
  mPasswordEditText = (EditText) findViewById(R.id.password);
  mPasswordEditText.setOnKeyListener(mMountKeyListener);

  final Button mMountShareButton = (Button) findViewById(R.id.mount);
  mMountShareButton.setOnClickListener(mMountListener);

  final Button cancel = (Button) findViewById(R.id.cancel);
  cancel.setOnClickListener(new OnClickListener() {
    @Override
    public void onClick(View view) {
      finish();
    }
  });

  setNeedsPasswordState(false);

  // Set MovementMethod to make it respond to clicks on hyperlinks
  final TextView gplv3Link = (TextView) findViewById(R.id.gplv3_link);
  gplv3Link.setMovementMethod(LinkMovementMethod.getInstance());

  mConnectivityManager = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);

  restoreSavedInstanceState(savedInstanceState);

  startBrowsing();
}
 
Example 18
Source File: NotificationSettingsActivity.java    From matrix-android-console with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    if (CommonActivityUtils.shouldRestartApp()) {
        CommonActivityUtils.restartApp(this);
    }

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_notification_settings);

    Intent intent = getIntent();
    if (!intent.hasExtra(EXTRA_MATRIX_ID)) {
        Log.e(LOG_TAG, "No matrix ID");
        finish();
        return;
    }

    mxSession = Matrix.getInstance(this).getSession(intent.getStringExtra(EXTRA_MATRIX_ID));

    if (null == mxSession) {
        Log.e(LOG_TAG, "No Valid session");
        finish();
        return;
    }

    mBingRulesManager = mxSession.getDataHandler().getBingRulesManager();

    mDisableAllButton = (Button)findViewById(R.id.notif_settings_disable_all_button);
    mDisableAllButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            allowUserUpdate(false);
            mBingRulesManager.toggleRule(mBingRuleSet.findDefaultRule(BingRule.RULE_ID_DISABLE_ALL), mOnBingRuleUpdateListener);
        }
    });

    mDisableAllTextView = (TextView)findViewById(R.id.notification_settings_disable_text);

    mPerWordList = (ListView)findViewById(R.id.listView_perWord);
    mPerRoomList = (ListView)findViewById(R.id.listView_perRoom);
    mPerSenderList = (ListView)findViewById(R.id.listView_perSender);

    mPerWordAdapter = new NotificationsRulesAdapter(this, mxSession, NotificationsRulesAdapter.PER_WORD_NOTIFICATION, R.layout.adapter_notifications_existing_item, R.layout.adapter_notifications_new_item);
    mPerRoomAdapter = new NotificationsRulesAdapter(this, mxSession, NotificationsRulesAdapter.PER_ROOM_NOTIFICATION, R.layout.adapter_notifications_existing_item, R.layout.adapter_notifications_new_item);
    mPerSenderAdapter = new NotificationsRulesAdapter(this, mxSession, NotificationsRulesAdapter.PER_SENDER_NOTIFICATION, R.layout.adapter_notifications_existing_item, R.layout.adapter_notifications_new_item);

    mPerWordList.setAdapter(mPerWordAdapter);
    mPerRoomList.setAdapter(mPerRoomAdapter);
    mPerSenderList.setAdapter(mPerSenderAdapter);

    mContainUserNameCheckBox = (CheckBox)findViewById(R.id.contain_my_user_name_check);
    mContainMyDisplayNameCheckBox = (CheckBox)findViewById(R.id.contain_my_display_name_check);
    mJustSendToMeCheckBox = (CheckBox)findViewById(R.id.just_sent_to_me_check);
    mInviteToNewRoomCheckBox = (CheckBox)findViewById(R.id.invite_to_new_room_check);
    mPeopleJoinLeaveCheckBox = (CheckBox)findViewById(R.id.people_leave_join_room_check);
    mReceiveACallCheckBox = (CheckBox)findViewById(R.id.receive_a_call_check);
    mSuppressFromBotsCheckBox = (CheckBox)findViewById(R.id.suppress_from_bots_check);

    mNotifyAllOthersCheckBox = (CheckBox)findViewById(R.id.notify_all_others_check);

    mAllSettingsLayout = (LinearLayout)findViewById(R.id.settings_items_layout);
    mEnableLayout = (LinearLayout)findViewById(R.id.notif_settings_disable_all_layout);

    // define imageView <-> rule ID map
    mRuleCheckBoxByRuleId.put(BingRule.RULE_ID_CONTAIN_USER_NAME, mContainUserNameCheckBox);
    mRuleCheckBoxByRuleId.put(BingRule.RULE_ID_CONTAIN_DISPLAY_NAME, mContainMyDisplayNameCheckBox);
    mRuleCheckBoxByRuleId.put(BingRule.RULE_ID_ONE_TO_ONE_ROOM, mJustSendToMeCheckBox);
    mRuleCheckBoxByRuleId.put(BingRule.RULE_ID_INVITE_ME, mInviteToNewRoomCheckBox);
    mRuleCheckBoxByRuleId.put(BingRule.RULE_ID_PEOPLE_JOIN_LEAVE, mPeopleJoinLeaveCheckBox);
    mRuleCheckBoxByRuleId.put(BingRule.RULE_ID_CALL, mReceiveACallCheckBox);
    mRuleCheckBoxByRuleId.put(BingRule.RULE_ID_SUPPRESS_BOTS_NOTIFICATIONS, mSuppressFromBotsCheckBox);
    mRuleCheckBoxByRuleId.put(BingRule.RULE_ID_ALL_OTHER_MESSAGES_ROOMS, mNotifyAllOthersCheckBox);

    for(String key : mRuleCheckBoxByRuleId.keySet()) {
        CheckBox checkBox = mRuleCheckBoxByRuleId.get(key);
        checkBox.setOnClickListener(mOnCheckBoxClickListener);
        mRuleIdByCheckBox.put(checkBox, key);
    }

    fullRefresh();
}
 
Example 19
Source File: PersonPopupAdapter.java    From arcusandroid with Apache License 2.0 4 votes vote down vote up
@Nullable
    @Override
    public View getView(final int position, @Nullable View convertView, ViewGroup parent) {
        if (convertView == null) {
            convertView = LayoutInflater.from(getContext()).inflate(R.layout.multicheckbox_item, parent, false);
        }

        final PersonModel mListData = getItem(position);

        TextView topText = (TextView) convertView.findViewById(R.id.tvTopText);
        TextView bottomText = (TextView) convertView.findViewById(R.id.tvBottomText);
        ImageView deviceImage = (ImageView) convertView.findViewById(R.id.imgPic);
        final CheckBox checkbox = (CheckBox) convertView.findViewById(R.id.checkbox);

        topText.setText(mListData.getFirstName() + " " + mListData.getLastName());

        // bottomText should be relation in presence model?
        bottomText.setText("");

        ModelSource<DeviceModel> m = DeviceModelProvider.instance().getModel("Address of model looking for");
        m.addModelListener(Listeners.runOnUiThread(new Listener<ModelEvent>() {
            public void onEvent(ModelEvent e) {
                if (e instanceof ModelAddedEvent) {
                    // model is loaded
                } else { // Handle other events? Deleted, Changed, ?
                }
            }
        }));
        m.load();

        if (m.get() != null) {
            deviceModel = m.get();
        }

        checkbox.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (position == 0) {
                    // unassign
                    NameDeviceFragmentController.getInstance().assignPersonToDevice(deviceModel, "UNSET");
                } else {
                    // assign person to device
                    NameDeviceFragmentController.getInstance().assignPersonToDevice(deviceModel,mListData.getAddress());
                }
                BackstackManager.getInstance().navigateBack();
            }
        });

        if (position == 0) {
//            ImageManager.with(getContext())
//                    .putSmallDeviceImage(deviceModel)
//                    .withTransformForStockImages(new BlackWhiteInvertTransformation(Invert.WHITE_TO_BLACK))
//                    .withTransform(new CropCircleTransformation())
//                    .into(deviceImage)
//                    .execute();
        } else {
//        ImageManager.with(getContext())
//                .putPersonImage("test")   // todo: put assigned person image
//                .withTransformForUgcImages(new CropCircleTransformation())
//                .withPlaceholder(R.drawable.icon_user_small_black)
//                .withError(R.drawable.icon_user_small_black)
//                .into(deviceImage)
//                .execute();
        }

        return (convertView);
    }
 
Example 20
Source File: MainActivity.java    From AndroidFontMetrics with MIT License 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    myFontMetricsView = (FontMetricsView) findViewById(R.id.viewWindow);
    mTextStringEditText = (EditText) findViewById(R.id.etTextString);
    mFontSizeEditText = (EditText) findViewById(R.id.etFontSize);

    mTextStringEditText.setText("My text line");
    mFontSizeEditText.setText("200");


    findViewById(R.id.updateButton).setOnClickListener(this);
    cbTop = (CheckBox) findViewById(R.id.cbTop);
    cbAscent = (CheckBox) findViewById(R.id.cbAscent);
    cbBaseline = (CheckBox) findViewById(R.id.cbBaseline);
    cbDescent = (CheckBox) findViewById(R.id.cbDescent);
    cbBottom = (CheckBox) findViewById(R.id.cbBottom);
    cbBounds = (CheckBox) findViewById(R.id.cbTextBounds);
    cbMeasuredWidth = (CheckBox) findViewById(R.id.cbWidth);

    cbTop.setOnClickListener(this);
    cbAscent.setOnClickListener(this);
    cbBaseline.setOnClickListener(this);
    cbDescent.setOnClickListener(this);
    cbBottom.setOnClickListener(this);
    cbBounds.setOnClickListener(this);
    cbMeasuredWidth.setOnClickListener(this);

    tvTop = (TextView) findViewById(R.id.tvTop);
    tvAscent = (TextView) findViewById(R.id.tvAscent);
    tvBaseline = (TextView) findViewById(R.id.tvBaseline);
    tvDescent = (TextView) findViewById(R.id.tvDescent);
    tvBottom = (TextView) findViewById(R.id.tvBottom);
    tvBounds = (TextView) findViewById(R.id.tvTextBounds);
    tvMeasuredWidth = (TextView) findViewById(R.id.tvWidth);
    tvLeading = (TextView) findViewById(R.id.tvLeadingValue);
    updateTextViews();

}