Java Code Examples for android.widget.CompoundButton#getTag()

The following examples show how to use android.widget.CompoundButton#getTag() . 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: FileChooserDialog.java    From videocreator with Apache License 2.0 6 votes vote down vote up
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
    if (R.id.checkBox3 == buttonView.getId()) {
        if (isChecked) {
            selectIndex = (int) buttonView.getTag();
            if (weakCheckBox != null && weakCheckBox.get() != null) {
                CheckBox checkBox0 = weakCheckBox.get();
                if (buttonView != checkBox0) {
                    checkBox0.setChecked(false);
                }
            }
            weakCheckBox = new WeakReference<>((CheckBox) buttonView);
        } else {
            weakCheckBox.clear();
            weakCheckBox = null;
        }
    } else {
        selectIndex = -1;
        refreshData(mFileProvider.setFilter(!isChecked));
    }
}
 
Example 2
Source File: ExtendChatViewAdapter.java    From imsdk-android with MIT License 6 votes vote down vote up
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
    try {
        IMMessage message = (IMMessage) buttonView.getTag();
        if(isChecked)
        {
            sharingMsg.put(message.getId(),message);
        }
        else {
            sharingMsg.remove(message.getId());
        }
    }catch (Exception ex)
    {
        buttonView.setOnCheckedChangeListener(null);
        buttonView.setChecked(!isChecked);
        buttonView.setOnCheckedChangeListener(this);
    }
}
 
Example 3
Source File: ExcludeAppsFragment.java    From bitmask_android with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
    String packageName = (String) buttonView.getTag();

    if (isChecked) {
        Log.d("openvpn", "adding to allowed apps" + packageName);
        apps.add(packageName);

    } else {
        Log.d("openvpn", "removing from allowed apps" + packageName);
        apps.remove(packageName);
    }

    if (callback != null) {
        callback.onAppsExcluded(apps.size());
    }
}
 
Example 4
Source File: FolderActivity.java    From syncthing-android with Mozilla Public License 2.0 6 votes vote down vote up
@Override
public void onCheckedChanged(CompoundButton view, boolean isChecked) {
    switch (view.getId()) {
        case R.id.fileWatcher:
            mFolder.fsWatcherEnabled = isChecked;
            mFolderNeedsToUpdate = true;
            break;
        case R.id.folderPause:
            mFolder.paused = isChecked;
            mFolderNeedsToUpdate = true;
            break;
        case R.id.device_toggle:
            Device device = (Device) view.getTag();
            if (isChecked) {
                mFolder.addDevice(device.deviceID);
            } else {
                mFolder.removeDevice(device.deviceID);
            }
            mFolderNeedsToUpdate = true;
            break;
    }
}
 
Example 5
Source File: CaseStepAdapter.java    From SoloPi with Apache License 2.0 5 votes vote down vote up
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
    int position = (int) buttonView.getTag();
    MyDataWrapper dataWrapper = data.get(position);
    if (isChecked) {
        selectSet.add(dataWrapper.idx);
    } else {
        selectSet.remove(dataWrapper.idx);
    }

}
 
Example 6
Source File: LastFragment.java    From prayer-times-android with Apache License 2.0 5 votes vote down vote up
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
    if (!b) return;
    String newlang = (String) compoundButton.getTag();
    if (Preferences.LANGUAGE.get().equals(newlang)) return;
    Preferences.LANGUAGE.set(newlang);
    getActivity().recreate();
}
 
Example 7
Source File: LanguageFragment.java    From prayer-times-android with Apache License 2.0 5 votes vote down vote up
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
    if (!b)
        return;
    String newlang = (String) compoundButton.getTag();
    if (Preferences.LANGUAGE.get().equals(newlang))
        return;
    Preferences.LANGUAGE.set(newlang);

    getActivity().finish();
    getActivity().overridePendingTransition( 0, 0);
    startActivity(getActivity().getIntent());
    getActivity().overridePendingTransition( 0, 0);
}
 
Example 8
Source File: LastFragment.java    From prayer-times-android with Apache License 2.0 5 votes vote down vote up
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
    if (!b) return;
    String newlang = (String) compoundButton.getTag();
    if (Preferences.LANGUAGE.get().equals(newlang)) return;
    Preferences.LANGUAGE.set(newlang);
    getActivity().recreate();
}
 
Example 9
Source File: LanguageFragment.java    From prayer-times-android with Apache License 2.0 5 votes vote down vote up
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
    if (!b)
        return;
    String newlang = (String) compoundButton.getTag();
    if (Preferences.LANGUAGE.get().equals(newlang))
        return;
    Preferences.LANGUAGE.set(newlang);

    getActivity().finish();
    getActivity().overridePendingTransition( 0, 0);
    startActivity(getActivity().getIntent());
    getActivity().overridePendingTransition( 0, 0);
}
 
Example 10
Source File: UsageStatsAdapter.java    From AppOpsX with MIT License 5 votes vote down vote up
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
  Object tag = compoundButton.getTag();
  if(tag instanceof ViewHolder){
    ViewHolder holder = ((ViewHolder) tag);
    Pair<AppInfo, OpEntryInfo> pair = mDatas.get(holder.getAdapterPosition());

    Helper.setMode(compoundButton.getContext(),pair.first.packageName,pair.second,b)
        .subscribeOn(Schedulers.io())
        .observeOn(AndroidSchedulers.mainThread())
        .subscribe();

  }
}
 
Example 11
Source File: ExportAdapter.java    From AppOpsX with MIT License 5 votes vote down vote up
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
  Object tag = buttonView.getTag();
  if (tag instanceof ExportViewHolder) {
    ExportViewHolder holder = (ExportViewHolder) tag;
    handleCheck(holder, false);
  }
}
 
Example 12
Source File: PermissionGroupAdapter.java    From AppOpsX with MIT License 5 votes vote down vote up
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
  if (buttonView.getTag() instanceof PermissionChildItem && listener != null) {
    int groupPosition = (int) buttonView.getTag(R.id.groupPosition);
    int childPosition = (int) buttonView.getTag(R.id.childPosition);
    listener.onSwitch(groupPosition, childPosition, ((PermissionChildItem) buttonView.getTag()),
        isChecked);
  }
}
 
Example 13
Source File: DeveloperCard.java    From narrate-android with Apache License 2.0 5 votes vote down vote up
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
    if ( buttonView.getId() == R.id.settings_title ) {
        Settings.setDeveloperModeEnabled(false);
        Settings.setLoggingEnabled(false);
        mListener.onDisableDevOptions();
        return;
    }

    switch ((Integer)buttonView.getTag()) {
        case 0:
            Settings.setLoggingEnabled(isChecked);
            break;
    }
}
 
Example 14
Source File: MultiChoiceAdapterHelperBase.java    From MultiChoiceAdapter with Apache License 2.0 5 votes vote down vote up
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
    if (ignoreCheckedListener) {
        return;
    }
    int position = (Integer) buttonView.getTag();
    setItemChecked(position, isChecked);
}
 
Example 15
Source File: AddTokenActivity.java    From Upchain-wallet with GNU Affero General Public License v3.0 5 votes vote down vote up
public void onCheckedChanged(CompoundButton btn, boolean checked){
    TokenItem info = (TokenItem) btn.getTag();
    info.added = checked;
    LogUtils.d(info.toString() + ", checked:" + checked);

    if (checked) {
        addTokenViewModel.save(info.tokenInfo.address, info.tokenInfo.symbol, info.tokenInfo.decimals);
    }


}
 
Example 16
Source File: AppPermissionAdapter.java    From AppOpsX with MIT License 4 votes vote down vote up
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
  if (buttonView.getTag() instanceof OpEntryInfo && listener != null) {
    listener.onSwitch(((OpEntryInfo) buttonView.getTag()), isChecked);
  }
}
 
Example 17
Source File: SyncCard.java    From narrate-android with Apache License 2.0 4 votes vote down vote up
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
    switch (buttonView.getId()) {
        case R.id.settings_title:
            if (PermissionsUtil.checkAndRequest(mActivity, Manifest.permission.GET_ACCOUNTS, 100, R.string.permission_explanation_get_accounts, null)) {
                if (PermissionsUtil.checkAndRequest(mActivity, Manifest.permission.WRITE_EXTERNAL_STORAGE, 100, R.string.permission_explanation_write_storage, null)) {
                    super.onCheckedChanged(buttonView, isChecked);
                    Settings.setSyncEnabled(isChecked);
                    if (isChecked) {
                        if (Settings.getDropboxSyncEnabled() || Settings.getGoogleDriveSyncEnabled()) {
                            enableSync();
                        }
                    } else {
                        cancelSync();
                    }
                } else {
                    mTitle.setChecked(false);
                }
            } else {
                mTitle.setChecked(false);
            }
            return;
    }

    super.onCheckedChanged(buttonView, isChecked);
    switch ((Integer) buttonView.getTag()) {
        case 0:
            if (PermissionsUtil.checkAndRequest(mActivity, Manifest.permission.GET_ACCOUNTS, 100, R.string.permission_explanation_get_accounts, null)) {
                onGoogleDriveChanged(isChecked);
            } else {
                mGoogleDrivePref.setChecked(false);
            }
            break;
        case 1:
            if (PermissionsUtil.checkAndRequest(mActivity, Manifest.permission.GET_ACCOUNTS, 100, R.string.permission_explanation_get_accounts, null)) {
                onDropboxChanged(isChecked);
            } else {
                mDropboxPref.setChecked(false);
            }
            break;
        case 2:
            Settings.setSyncOnMobileData(isChecked);
            break;
    }
}
 
Example 18
Source File: DragReorderActionsPreference.java    From wear-notify-for-reddit with Apache License 2.0 4 votes vote down vote up
@Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
    Integer tag = (Integer) buttonView.getTag();
    if (tag != null) {
        mListener.onCheckedChanged(tag, isChecked);
    }
}
 
Example 19
Source File: MainActivity.java    From NYU-BusTracker-Android with Apache License 2.0 4 votes vote down vote up
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
    Stop s = (Stop) buttonView.getTag();
    s.setFavorite(isChecked);
    getSharedPreferences(Stop.FAVORITES_PREF, MODE_PRIVATE).edit().putBoolean(s.getID(), isChecked).commit();
}
 
Example 20
Source File: StockAdapter.java    From StickyItemDecoration with Apache License 2.0 4 votes vote down vote up
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
    int pos = (Integer) buttonView.getTag();
    mData.get(pos).getData().check = isChecked;
}