List of usage examples for android.util SparseBooleanArray SparseBooleanArray
public SparseBooleanArray()
From source file:com.arksh.summer.ui.zone.widget.ExpandableTextView.java
/** * ?//from w w w . j av a2s . c o m * @param attrs */ private void init(AttributeSet attrs) { mCollapsedStatus = new SparseBooleanArray(); TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.ExpandableTextView); mMaxCollapsedLines = typedArray.getInt(R.styleable.ExpandableTextView_maxCollapsedLines, MAX_COLLAPSED_LINES); mAnimationDuration = typedArray.getInt(R.styleable.ExpandableTextView_animDuration, DEFAULT_ANIM_DURATION); mExpandDrawable = typedArray.getDrawable(R.styleable.ExpandableTextView_expandDrawable); mCollapseDrawable = typedArray.getDrawable(R.styleable.ExpandableTextView_collapseDrawable); textCollapse = typedArray.getString(R.styleable.ExpandableTextView_textCollapse); textExpand = typedArray.getString(R.styleable.ExpandableTextView_textExpand); showExpandCollapseDrawable = typedArray .getBoolean(R.styleable.ExpandableTextView_showExpandCollapseDrawable, true); if (showExpandCollapseDrawable) { if (mExpandDrawable == null) { mExpandDrawable = ContextCompat.getDrawable(getContext(), R.drawable.icon_green_arrow_down); } if (mCollapseDrawable == null) { mCollapseDrawable = ContextCompat.getDrawable(getContext(), R.drawable.icon_green_arrow_up); } } if (TextUtils.isEmpty(textCollapse)) { textCollapse = getContext().getString(R.string.shink); } if (TextUtils.isEmpty(textExpand)) { textExpand = getContext().getString(R.string.expand); } contentTextColor = typedArray.getColor(R.styleable.ExpandableTextView_contentTextColor, ContextCompat.getColor(getContext(), R.color.light_gray)); contentTextSize = typedArray.getDimension(R.styleable.ExpandableTextView_contentTextSize, DisplayUtil.sp2px(14)); collapseExpandTextColor = typedArray.getColor(R.styleable.ExpandableTextView_collapseExpandTextColor, ContextCompat.getColor(getContext(), R.color.main_color)); collapseExpandTextSize = typedArray.getDimension(R.styleable.ExpandableTextView_collapseExpandTextSize, DisplayUtil.sp2px(14)); grarity = typedArray.getInt(R.styleable.ExpandableTextView_collapseExpandGrarity, Gravity.LEFT); typedArray.recycle(); // enforces vertical orientation setOrientation(LinearLayout.VERTICAL); // default visibility is gone setVisibility(GONE); }
From source file:recycle.com.example.nandy.dynamicdemo.widget.dynamic.ExpandableTextView.java
/** * ?/*from w w w. j ava 2 s.c o m*/ * @param attrs */ private void init(AttributeSet attrs) { mCollapsedStatus = new SparseBooleanArray(); TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.ExpandableTextView); mMaxCollapsedLines = typedArray.getInt(R.styleable.ExpandableTextView_maxCollapsedLines, MAX_COLLAPSED_LINES); mAnimationDuration = typedArray.getInt(R.styleable.ExpandableTextView_animDuration, DEFAULT_ANIM_DURATION); mExpandDrawable = typedArray.getDrawable(R.styleable.ExpandableTextView_expandDrawable); mCollapseDrawable = typedArray.getDrawable(R.styleable.ExpandableTextView_collapseDrawable); textCollapse = typedArray.getString(R.styleable.ExpandableTextView_textCollapse); textExpand = typedArray.getString(R.styleable.ExpandableTextView_textExpand); showExpandCollapseDrawable = typedArray .getBoolean(R.styleable.ExpandableTextView_showExpandCollapseDrawable, true); if (showExpandCollapseDrawable) { if (mExpandDrawable == null) { mExpandDrawable = ContextCompat.getDrawable(getContext(), R.drawable.icon_green_arrow_down); } if (mCollapseDrawable == null) { mCollapseDrawable = ContextCompat.getDrawable(getContext(), R.drawable.icon_green_arrow_up); } } if (TextUtils.isEmpty(textCollapse)) { textCollapse = getContext().getString(R.string.shink); } if (TextUtils.isEmpty(textExpand)) { textExpand = getContext().getString(R.string.expand); } contentTextColor = typedArray.getColor(R.styleable.ExpandableTextView_contentTextColor, ContextCompat.getColor(getContext(), R.color.white)); contentTextSize = typedArray.getDimension(R.styleable.ExpandableTextView_contentTextSize, DensityUtil.sp2px(14)); collapseExpandTextColor = typedArray.getColor(R.styleable.ExpandableTextView_collapseExpandTextColor, ContextCompat.getColor(getContext(), R.color.black)); collapseExpandTextSize = typedArray.getDimension(R.styleable.ExpandableTextView_collapseExpandTextSize, DensityUtil.sp2px(14)); grarity = typedArray.getInt(R.styleable.ExpandableTextView_collapseExpandGrarity, Gravity.LEFT); typedArray.recycle(); // enforces vertical orientation setOrientation(LinearLayout.VERTICAL); // default visibility is gone setVisibility(GONE); }
From source file:org.mariotaku.twidere.activity.AccountSelectorActivity.java
@Override public void onLoadFinished(final Loader<Cursor> loader, final Cursor cursor) { mAdapter.swapCursor(cursor);/*from ww w . j a va 2 s . c o m*/ final SparseBooleanArray checked = new SparseBooleanArray(); cursor.moveToFirst(); if (mSelectedIds.size() == 0) { if (mAllowSelectNone) return; while (!cursor.isAfterLast()) { final boolean is_activated = cursor .getInt(cursor.getColumnIndexOrThrow(Accounts.IS_ACTIVATED)) == 1; final long user_id = cursor.getLong(cursor.getColumnIndexOrThrow(Accounts.ACCOUNT_ID)); if (is_activated) { mSelectedIds.add(user_id); } mAdapter.setItemChecked(cursor.getPosition(), is_activated); cursor.moveToNext(); } } else { while (!cursor.isAfterLast()) { final long user_id = cursor.getLong(cursor.getColumnIndexOrThrow(Accounts.ACCOUNT_ID)); if (mSelectedIds.contains(user_id)) { checked.put(cursor.getPosition(), true); mAdapter.setItemChecked(cursor.getPosition(), true); } cursor.moveToNext(); } } }
From source file:org.jnrain.mobile.accounts.kbs.KBSRegisterActivity.java
protected synchronized void initValidationMapping() { if (validatedMap == null) { validatedMap = new SparseBooleanArray(); for (int id : FIXED_VALIDATION_FIELD_IDS) { validatedMap.put(id, false); }/*from w w w .ja v a2 s . co m*/ // dynamic fields validatedMap.put(R.id.editPhone, false); } }
From source file:android.support.v7.graphics.Palette.java
private Palette(List<Swatch> swatches, List<Target> targets) { mSwatches = swatches;/* w w w .j a v a2s . c o m*/ mTargets = targets; mUsedColors = new SparseBooleanArray(); mSelectedSwatches = new ArrayMap<>(); mMaxPopulation = findMaxPopulation(); }
From source file:org.totschnig.myexpenses.fragment.TransactionList.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setHasOptionsMenu(true);// w w w. j ava 2s .c o m mappedCategoriesPerGroup = new SparseBooleanArray(); mAccount = Account.getInstanceFromDb(getArguments().getLong(KEY_ACCOUNTID)); if (mAccount == null) { return; } mGrouping = mAccount.grouping; mType = mAccount.type; mCurrency = mAccount.currency.getCurrencyCode(); mOpeningBalance = mAccount.openingBalance.getAmountMinor(); MyApplication.getInstance().getSettings().registerOnSharedPreferenceChangeListener(this); }
From source file:org.kontalk.util.SystemUtils.java
/** * Provides clone functionality for the {@link SparseBooleanArray}. * See https://code.google.com/p/android/issues/detail?id=39242 *//*from ww w .j a v a2 s. c o m*/ public static SparseBooleanArray cloneSparseBooleanArray(SparseBooleanArray array) { final SparseBooleanArray clone = new SparseBooleanArray(); synchronized (array) { final int size = array.size(); for (int i = 0; i < size; i++) { int key = array.keyAt(i); clone.put(key, array.get(key)); } } return clone; }
From source file:de.azapps.mirakel.helper.TaskDialogHelpers.java
@SuppressWarnings("boxing") public static void handleRecurrence(final FragmentActivity activity, final Task task, final boolean isDue, final ExecInterface callback) { final FragmentManager fm = activity.getSupportFragmentManager(); Optional<Recurring> recurringOptional = isDue ? task.getRecurrence() : task.getRecurringReminder(); boolean isExact = false; if (recurringOptional.isPresent()) { Recurring recurring = recurringOptional.get(); isExact = recurring.isExact();/* w w w . java 2s. c o m*/ Log.d(TAG, "exact: " + isExact); if (recurring.getDerivedFrom().isPresent()) { final Optional<Recurring> master = Recurring.get(recurring.getDerivedFrom().get()); if (master.isPresent()) { recurring = master.get(); } } } final RecurrencePickerDialog rp = RecurrencePickerDialog.newInstance(new OnRecurrenceSetListener() { @Override public void onCustomRecurrenceSetInterval(final boolean isDue, final int intervalYears, final int intervalMonths, final int intervalDays, final int intervalHours, final int intervalMinutes, @NonNull final Optional<Calendar> startDate, @NonNull final Optional<Calendar> endDate, final boolean isExact) { final Recurring r = Recurring.newRecurring("", intervalMinutes, intervalHours, intervalDays, intervalMonths, intervalYears, isDue, startDate, endDate, true, isExact, new SparseBooleanArray()); setRecurence(task, isDue, r.getId(), callback); } @Override public void onCustomRecurrenceSetWeekdays(final boolean isDue, @NonNull final List<Integer> weekdays, @NonNull final Optional<Calendar> startDate, @NonNull final Optional<Calendar> endDate, final boolean isExact) { final SparseBooleanArray weekdaysArray = new SparseBooleanArray(); for (final int day : weekdays) { weekdaysArray.put(day, true); } final Recurring r = Recurring.newRecurring("", 0, 0, 0, 0, 0, isDue, startDate, endDate, true, isExact, weekdaysArray); setRecurence(task, isDue, r.getId(), callback); } @Override public void onNoRecurrenceSet() { setRecurence(task, isDue, -1, callback); } @Override public void onRecurrenceSet(final Recurring r) { setRecurence(task, isDue, r.getId(), callback); } }, recurringOptional, isDue, MirakelCommonPreferences.isDark(), isExact); rp.show(fm, "reccurence"); }
From source file:com.dwdesign.tweetings.fragment.AccountsFragment.java
@Override public void onLoadFinished(final Loader<Cursor> loader, final Cursor data) { mCursor = data;//from w w w .j a v a2 s. c o m mAdapter.swapCursor(data); final SparseBooleanArray checked = new SparseBooleanArray(); data.moveToFirst(); //if (mSelectedIds.size() == 0) { while (!data.isAfterLast()) { final boolean is_activated = data.getInt(data.getColumnIndexOrThrow(Accounts.IS_ACTIVATED)) == 1; final long user_id = data.getLong(data.getColumnIndexOrThrow(Accounts.USER_ID)); //if (is_activated) { //mSelectedIds.add(user_id); //} //View v = (View) getListView().getItemAtPosition(data.getPosition()); //CheckBox cb = (CheckBox) v.findViewById(R.id.checkbox); //cb.setChecked(is_activated); //mAdapter.setItemChecked(data.getPosition(), is_activated); data.moveToNext(); } /*} else { while (!cursor.isAfterLast()) { final long user_id = cursor.getLong(cursor.getColumnIndexOrThrow(Accounts.ACCOUNT_ID)); if (mSelectedIds.contains(user_id)) { checked.put(cursor.getPosition(), true); mAdapter.setItemChecked(cursor.getPosition(), true); } cursor.moveToNext(); } }*/ }
From source file:com.rc.droid_stalker.components.NetworkStats.java
/** * Return list of unique UIDs known by this data structure. */// w w w . j a va2 s. c om public int[] getUniqueUids() { final SparseBooleanArray uids = new SparseBooleanArray(); for (int uid : this.uid) { uids.put(uid, true); } final int size = uids.size(); final int[] result = new int[size]; for (int i = 0; i < size; i++) { result[i] = uids.keyAt(i); } return result; }