List of usage examples for android.util TypedValue TypedValue
TypedValue
From source file:com.miz.functions.MizLib.java
/** * Add a margin with a combined height of the ActionBar and Status bar to the top of a given View contained in a FrameLayout * @param c//from w w w . j a v a2 s .co m * @param v */ public static void addActionBarAndStatusBarMargin(Context c, View v, FrameLayout.LayoutParams layoutParams) { int mActionBarHeight = 0, mStatusBarHeight = 0; TypedValue tv = new TypedValue(); if (c.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) mActionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, c.getResources().getDisplayMetrics()); else mActionBarHeight = 0; // No ActionBar style (pre-Honeycomb or ActionBar not in theme) if (hasKitKat()) mStatusBarHeight = convertDpToPixels(c, 25); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); params.setMargins(0, mActionBarHeight + mStatusBarHeight, 0, 0); params.gravity = layoutParams.gravity; v.setLayoutParams(params); }
From source file:com.evandroid.musica.fragment.LyricsViewFragment.java
public void checkPreferencesChanges() { boolean screenOn = PreferenceManager.getDefaultSharedPreferences(getActivity()) .getBoolean("pref_force_screen_on", false); boolean dyslexic = PreferenceManager.getDefaultSharedPreferences(getActivity()) .getBoolean("pref_opendyslexic", false); TextSwitcher switcher = (TextSwitcher) getActivity().findViewById(R.id.switcher); View lrcView = getActivity().findViewById(R.id.lrc_view); if (switcher != null) { switcher.setKeepScreenOn(screenOn); if (switcher.getCurrentView() != null) ((TextView) switcher.getCurrentView()).setTypeface( LyricsTextFactory.FontCache.get(dyslexic ? "dyslexic" : "light", getActivity())); View nextView = switcher.getNextView(); if (nextView != null) { ((TextView) nextView).setTypeface( LyricsTextFactory.FontCache.get(dyslexic ? "dyslexic" : "light", getActivity())); }/*from ww w.j a v a 2 s . c o m*/ } if (lrcView != null) lrcView.setKeepScreenOn(screenOn); SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); TypedValue outValue = new TypedValue(); getActivity().getTheme().resolveAttribute(R.attr.themeName, outValue, false); if ("Night".equals(outValue.string) != NightTimeVerifier.check(getActivity()) || "Dark".equals(outValue.string) == sharedPrefs.getString("pref_theme", "0").equals("0")) { getActivity().finish(); Intent intent = new Intent(getActivity(), MainLyricActivity.class); intent.setAction("android.intent.action.MAIN"); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivity(intent); } }
From source file:com.cgearc.yummy.Act_Main.java
private int getActionBarHeight() { int actionBarHeight = 0; TypedValue tv = new TypedValue(); if (getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) { actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, getResources().getDisplayMetrics()); }/*from w w w . j av a 2 s . com*/ return actionBarHeight; }
From source file:com.github.shareme.gwsmaterialuikit.library.mscrollbar.MaterialScrollBar.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) private int fetchAccentColour(Context context) { TypedValue typedValue = new TypedValue(); TypedArray b = context.obtainStyledAttributes(typedValue.data, new int[] { android.R.attr.colorAccent }); int colour = b.getColor(0, 0); b.recycle();/*from ww w .j av a 2s. c o m*/ return colour; }
From source file:com.actionbarsherlock.internal.ActionBarSherlockCompat.java
private boolean initializePanelMenu() { Context context = mActivity;//getContext(); // If we have an action bar, initialize the menu with a context themed for it. if (wActionBar != null) { TypedValue outValue = new TypedValue(); Resources.Theme currentTheme = context.getTheme(); currentTheme.resolveAttribute(R.attr.actionBarWidgetTheme, outValue, true); final int targetThemeRes = outValue.resourceId; if (targetThemeRes != 0 /*&& context.getThemeResId() != targetThemeRes*/) { context = new ContextThemeWrapper(context, targetThemeRes); }//from w w w . jav a2s . co m } mMenu = new MenuBuilder(context); mMenu.setCallback(this); return true; }
From source file:com.miz.functions.MizLib.java
/** * Add a margin with a height of the ActionBar to the top of a given View contained in a FrameLayout * @param c/*www. j a v a 2 s. c o m*/ * @param v */ public static void addActionBarMarginBottom(Context c, View v) { int mActionBarHeight = 0; TypedValue tv = new TypedValue(); if (c.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) mActionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, c.getResources().getDisplayMetrics()); else mActionBarHeight = 0; // No ActionBar style (pre-Honeycomb or ActionBar not in theme) FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); params.setMargins(0, 0, 0, mActionBarHeight); v.setLayoutParams(params); }
From source file:ac.robinson.mediaphone.MediaPhoneActivity.java
private void loadAllPreferences() { SharedPreferences mediaPhoneSettings = PreferenceManager .getDefaultSharedPreferences(MediaPhoneActivity.this); Resources res = getResources(); // bluetooth observer configureBluetoothObserver(mediaPhoneSettings, res); // importing confirmation boolean confirmImporting = res.getBoolean(R.bool.default_confirm_importing); try {//from ww w .j a v a2 s .c o m confirmImporting = mediaPhoneSettings.getBoolean(getString(R.string.key_confirm_importing), confirmImporting); } catch (Exception e) { confirmImporting = res.getBoolean(R.bool.default_confirm_importing); } MediaPhone.IMPORT_CONFIRM_IMPORTING = confirmImporting; // delete after import boolean deleteAfterImport = res.getBoolean(R.bool.default_delete_after_importing); try { deleteAfterImport = mediaPhoneSettings.getBoolean(getString(R.string.key_delete_after_importing), deleteAfterImport); } catch (Exception e) { deleteAfterImport = res.getBoolean(R.bool.default_delete_after_importing); } MediaPhone.IMPORT_DELETE_AFTER_IMPORTING = deleteAfterImport; // minimum frame duration TypedValue resourceValue = new TypedValue(); res.getValue(R.attr.default_minimum_frame_duration, resourceValue, true); float minimumFrameDuration; try { minimumFrameDuration = mediaPhoneSettings.getFloat(getString(R.string.key_minimum_frame_duration), resourceValue.getFloat()); if (minimumFrameDuration <= 0) { throw new NumberFormatException(); } } catch (Exception e) { minimumFrameDuration = resourceValue.getFloat(); } MediaPhone.PLAYBACK_EXPORT_MINIMUM_FRAME_DURATION = Math.round(minimumFrameDuration * 1000); // word duration res.getValue(R.attr.default_word_duration, resourceValue, true); float wordDuration; try { wordDuration = mediaPhoneSettings.getFloat(getString(R.string.key_word_duration), resourceValue.getFloat()); if (wordDuration <= 0) { throw new NumberFormatException(); } } catch (Exception e) { wordDuration = resourceValue.getFloat(); } MediaPhone.PLAYBACK_EXPORT_WORD_DURATION = Math.round(wordDuration * 1000); // screen orientation int requestedOrientation = res.getInteger(R.integer.default_screen_orientation); try { String requestedOrientationString = mediaPhoneSettings .getString(getString(R.string.key_screen_orientation), null); requestedOrientation = Integer.valueOf(requestedOrientationString); } catch (Exception e) { requestedOrientation = res.getInteger(R.integer.default_screen_orientation); } setRequestedOrientation(requestedOrientation); // other preferences loadPreferences(mediaPhoneSettings); }
From source file:com.actionbarsherlock.internal.app.ActionBarImpl.java
public Context getThemedContext() { if (mThemedContext == null) { TypedValue outValue = new TypedValue(); Resources.Theme currentTheme = mContext.getTheme(); currentTheme.resolveAttribute(R.attr.actionBarWidgetTheme, outValue, true); final int targetThemeRes = outValue.resourceId; if (targetThemeRes != 0) { //XXX && mContext.getThemeResId() != targetThemeRes) { mThemedContext = new ContextThemeWrapper(mContext, targetThemeRes); } else {/* w ww . ja v a 2 s .c om*/ mThemedContext = mContext; } } return mThemedContext; }
From source file:com.ayuget.redface.ui.activity.ReplyActivity.java
/** * Returns toolbar height, in px//from w ww .j a v a 2 s .co m */ protected int getToolbarHeight() { TypedValue tv = new TypedValue(); getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true); return getResources().getDimensionPixelSize(tv.resourceId); }
From source file:android_network.hetnet.vpn_service.AdapterRule.java
@Override public void onBindViewHolder(final ViewHolder holder, final int position) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); // Get rule//from ww w. j a v a 2 s. co m final Rule rule = listFiltered.get(position); // Handle expanding/collapsing holder.llApplication.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { rule.expanded = !rule.expanded; notifyItemChanged(position); } }); // Show if non default rules holder.itemView.setBackgroundColor(rule.changed ? colorChanged : Color.TRANSPARENT); // Show expand/collapse indicator holder.ivExpander.setImageLevel(rule.expanded ? 1 : 0); // Show application icon if (rule.info.applicationInfo == null || rule.info.applicationInfo.icon == 0) Picasso.with(context).load(android.R.drawable.sym_def_app_icon).into(holder.ivIcon); else { Uri uri = Uri .parse("android.resource://" + rule.info.packageName + "/" + rule.info.applicationInfo.icon); Picasso.with(context).load(uri).resize(iconSize, iconSize).into(holder.ivIcon); } // Show application label holder.tvName.setText(rule.name); // Show application state int color = rule.system ? colorOff : colorText; if (!rule.internet || !rule.enabled) color = Color.argb(128, Color.red(color), Color.green(color), Color.blue(color)); holder.tvName.setTextColor(color); // Show rule count new AsyncTask<Object, Object, Long>() { @Override protected void onPreExecute() { holder.tvHosts.setVisibility(View.GONE); } @Override protected Long doInBackground(Object... objects) { return DatabaseHelper.getInstance(context).getRuleCount(rule.info.applicationInfo.uid); } @Override protected void onPostExecute(Long rules) { if (rules > 0) { holder.tvHosts.setVisibility(View.VISIBLE); holder.tvHosts.setText(Long.toString(rules)); } } }.execute(); boolean screen_on = prefs.getBoolean("screen_on", true); // Wi-Fi settings holder.cbWifi.setEnabled(rule.apply); holder.cbWifi.setAlpha(wifiActive ? 1 : 0.5f); holder.cbWifi.setOnCheckedChangeListener(null); holder.cbWifi.setChecked(rule.wifi_blocked); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { Drawable wrap = DrawableCompat.wrap(CompoundButtonCompat.getButtonDrawable(holder.cbWifi)); DrawableCompat.setTint(wrap, rule.apply ? (rule.wifi_blocked ? colorOff : colorOn) : colorGrayed); } holder.cbWifi.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) { rule.wifi_blocked = isChecked; updateRule(rule, true, listAll); } }); holder.ivScreenWifi.setEnabled(rule.apply); holder.ivScreenWifi.setAlpha(wifiActive ? 1 : 0.5f); holder.ivScreenWifi.setVisibility(rule.screen_wifi && rule.wifi_blocked ? View.VISIBLE : View.INVISIBLE); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { Drawable wrap = DrawableCompat.wrap(holder.ivScreenWifi.getDrawable()); DrawableCompat.setTint(wrap, rule.apply ? colorOn : colorGrayed); } // Mobile settings holder.cbOther.setEnabled(rule.apply); holder.cbOther.setAlpha(otherActive ? 1 : 0.5f); holder.cbOther.setOnCheckedChangeListener(null); holder.cbOther.setChecked(rule.other_blocked); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { Drawable wrap = DrawableCompat.wrap(CompoundButtonCompat.getButtonDrawable(holder.cbOther)); DrawableCompat.setTint(wrap, rule.apply ? (rule.other_blocked ? colorOff : colorOn) : colorGrayed); } holder.cbOther.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) { rule.other_blocked = isChecked; updateRule(rule, true, listAll); } }); holder.ivScreenOther.setEnabled(rule.apply); holder.ivScreenOther.setAlpha(otherActive ? 1 : 0.5f); holder.ivScreenOther.setVisibility(rule.screen_other && rule.other_blocked ? View.VISIBLE : View.INVISIBLE); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { Drawable wrap = DrawableCompat.wrap(holder.ivScreenOther.getDrawable()); DrawableCompat.setTint(wrap, rule.apply ? colorOn : colorGrayed); } holder.tvRoaming.setTextColor(rule.apply ? colorOff : colorGrayed); holder.tvRoaming.setAlpha(otherActive ? 1 : 0.5f); holder.tvRoaming.setVisibility( rule.roaming && (!rule.other_blocked || rule.screen_other) ? View.VISIBLE : View.INVISIBLE); // Expanded configuration section holder.llConfiguration.setVisibility(rule.expanded ? View.VISIBLE : View.GONE); // Show application details holder.tvUid .setText(rule.info.applicationInfo == null ? "?" : Integer.toString(rule.info.applicationInfo.uid)); holder.tvPackage.setText(rule.info.packageName); holder.tvVersion.setText(rule.info.versionName + '/' + rule.info.versionCode); holder.tvDescription.setVisibility(rule.description == null ? View.GONE : View.VISIBLE); holder.tvDescription.setText(rule.description); // Show application state holder.tvInternet.setVisibility(rule.internet ? View.GONE : View.VISIBLE); holder.tvDisabled.setVisibility(rule.enabled ? View.GONE : View.VISIBLE); // Show traffic statistics holder.tvStatistics .setVisibility(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N ? View.GONE : View.VISIBLE); holder.tvStatistics.setText(context.getString(R.string.msg_mbday, rule.upspeed, rule.downspeed)); // Show related holder.btnRelated.setVisibility(rule.relateduids ? View.VISIBLE : View.GONE); holder.btnRelated.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent main = new Intent(context, MainActivity.class); main.putExtra(MainActivity.EXTRA_SEARCH, Integer.toString(rule.info.applicationInfo.uid)); context.startActivity(main); } }); // Launch application settings holder.ibSettings.setVisibility(rule.settings == null ? View.GONE : View.VISIBLE); holder.ibSettings.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { context.startActivity(rule.settings); } }); // Data saver holder.ibDatasaver.setVisibility(rule.datasaver == null ? View.GONE : View.VISIBLE); holder.ibDatasaver.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { context.startActivity(rule.datasaver); } }); // Launch application holder.ibLaunch.setVisibility(rule.launch == null ? View.GONE : View.VISIBLE); holder.ibLaunch.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { context.startActivity(rule.launch); } }); // Apply holder.cbApply.setEnabled(rule.pkg); holder.cbApply.setOnCheckedChangeListener(null); holder.cbApply.setChecked(rule.apply); holder.cbApply.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) { rule.apply = isChecked; updateRule(rule, true, listAll); } }); // Show Wi-Fi screen on condition holder.llScreenWifi.setVisibility(screen_on ? View.VISIBLE : View.GONE); holder.cbScreenWifi.setEnabled(rule.wifi_blocked && rule.apply); holder.cbScreenWifi.setOnCheckedChangeListener(null); holder.cbScreenWifi.setChecked(rule.screen_wifi); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { Drawable wrap = DrawableCompat.wrap(holder.ivWifiLegend.getDrawable()); DrawableCompat.setTint(wrap, colorOn); } holder.cbScreenWifi.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { rule.screen_wifi = isChecked; updateRule(rule, true, listAll); } }); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { Drawable wrap = DrawableCompat.wrap(holder.ivOtherLegend.getDrawable()); DrawableCompat.setTint(wrap, colorOn); } // Show mobile screen on condition holder.llScreenOther.setVisibility(screen_on ? View.VISIBLE : View.GONE); holder.cbScreenOther.setEnabled(rule.other_blocked && rule.apply); holder.cbScreenOther.setOnCheckedChangeListener(null); holder.cbScreenOther.setChecked(rule.screen_other); holder.cbScreenOther.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { rule.screen_other = isChecked; updateRule(rule, true, listAll); } }); // Show roaming condition holder.cbRoaming.setEnabled((!rule.other_blocked || rule.screen_other) && rule.apply); holder.cbRoaming.setOnCheckedChangeListener(null); holder.cbRoaming.setChecked(rule.roaming); holder.cbRoaming.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override @TargetApi(Build.VERSION_CODES.M) public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { rule.roaming = isChecked; updateRule(rule, true, listAll); // Request permissions if (isChecked && !Util.hasPhoneStatePermission(context)) context.requestPermissions(new String[] { Manifest.permission.READ_PHONE_STATE }, MainActivity.REQUEST_ROAMING); } }); // Reset rule holder.btnClear.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Util.areYouSure(view.getContext(), R.string.msg_clear_rules, new Util.DoubtListener() { @Override public void onSure() { holder.cbApply.setChecked(true); holder.cbWifi.setChecked(rule.wifi_default); holder.cbOther.setChecked(rule.other_default); holder.cbScreenWifi.setChecked(rule.screen_wifi_default); holder.cbScreenOther.setChecked(rule.screen_other_default); holder.cbRoaming.setChecked(rule.roaming_default); } }); } }); // Live holder.ivLive.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { live = !live; TypedValue tv = new TypedValue(); view.getContext().getTheme().resolveAttribute(live ? R.attr.iconPause : R.attr.iconPlay, tv, true); holder.ivLive.setImageResource(tv.resourceId); if (live) AdapterRule.this.notifyDataSetChanged(); } }); // Show logging is disabled boolean log_app = prefs.getBoolean("log_app", false); holder.tvNoLog.setVisibility(log_app ? View.GONE : View.VISIBLE); holder.tvNoLog.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { context.startActivity(new Intent(context, ActivitySettings.class)); } }); // Show filtering is disabled boolean filter = prefs.getBoolean("filter", false); holder.tvNoFilter.setVisibility(filter ? View.GONE : View.VISIBLE); holder.tvNoFilter.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { context.startActivity(new Intent(context, ActivitySettings.class)); } }); // Show access rules if (rule.expanded) { // Access the database when expanded only final AdapterAccess badapter = new AdapterAccess(context, DatabaseHelper.getInstance(context).getAccess(rule.info.applicationInfo.uid)); holder.lvAccess.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, final int bposition, long bid) { PackageManager pm = context.getPackageManager(); Cursor cursor = (Cursor) badapter.getItem(bposition); final long id = cursor.getLong(cursor.getColumnIndex("ID")); final int version = cursor.getInt(cursor.getColumnIndex("version")); final int protocol = cursor.getInt(cursor.getColumnIndex("protocol")); final String daddr = cursor.getString(cursor.getColumnIndex("daddr")); final int dport = cursor.getInt(cursor.getColumnIndex("dport")); long time = cursor.getLong(cursor.getColumnIndex("time")); int block = cursor.getInt(cursor.getColumnIndex("block")); PopupMenu popup = new PopupMenu(context, context.findViewById(R.id.vwPopupAnchor)); popup.inflate(R.menu.access); popup.getMenu().findItem(R.id.menu_host).setTitle(Util.getProtocolName(protocol, version, false) + " " + daddr + (dport > 0 ? "/" + dport : "")); // markPro(popup.getMenu().findItem(R.id.menu_allow), ActivityPro.SKU_FILTER); // markPro(popup.getMenu().findItem(R.id.menu_block), ActivityPro.SKU_FILTER); // Whois final Intent lookupIP = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.tcpiputils.com/whois-lookup/" + daddr)); if (pm.resolveActivity(lookupIP, 0) == null) popup.getMenu().removeItem(R.id.menu_whois); else popup.getMenu().findItem(R.id.menu_whois) .setTitle(context.getString(R.string.title_log_whois, daddr)); // Lookup port final Intent lookupPort = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.speedguide.net/port.php?port=" + dport)); if (dport <= 0 || pm.resolveActivity(lookupPort, 0) == null) popup.getMenu().removeItem(R.id.menu_port); else popup.getMenu().findItem(R.id.menu_port) .setTitle(context.getString(R.string.title_log_port, dport)); popup.getMenu().findItem(R.id.menu_time) .setTitle(SimpleDateFormat.getDateTimeInstance().format(time)); popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { switch (menuItem.getItemId()) { case R.id.menu_whois: context.startActivity(lookupIP); return true; case R.id.menu_port: context.startActivity(lookupPort); return true; case R.id.menu_allow: if (true) { DatabaseHelper.getInstance(context).setAccess(id, 0); ServiceSinkhole.reload("allow host", context); } // context.startActivity(new Intent(context, ActivityPro.class)); return true; case R.id.menu_block: if (true) { DatabaseHelper.getInstance(context).setAccess(id, 1); ServiceSinkhole.reload("block host", context); } // context.startActivity(new Intent(context, ActivityPro.class)); return true; case R.id.menu_reset: DatabaseHelper.getInstance(context).setAccess(id, -1); ServiceSinkhole.reload("reset host", context); return true; } return false; } }); if (block == 0) popup.getMenu().removeItem(R.id.menu_allow); else if (block == 1) popup.getMenu().removeItem(R.id.menu_block); popup.show(); } }); holder.lvAccess.setAdapter(badapter); } else { holder.lvAccess.setAdapter(null); holder.lvAccess.setOnItemClickListener(null); } // Clear access log holder.btnClearAccess.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Util.areYouSure(view.getContext(), R.string.msg_reset_access, new Util.DoubtListener() { @Override public void onSure() { DatabaseHelper.getInstance(context).clearAccess(rule.info.applicationInfo.uid, true); if (!live) notifyDataSetChanged(); if (rv != null) rv.scrollToPosition(position); } }); } }); // Notify on access holder.cbNotify.setEnabled(prefs.getBoolean("notify_access", false) && rule.apply); holder.cbNotify.setOnCheckedChangeListener(null); holder.cbNotify.setChecked(rule.notify); holder.cbNotify.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) { rule.notify = isChecked; updateRule(rule, true, listAll); } }); }