Example usage for android.util SparseBooleanArray SparseBooleanArray

List of usage examples for android.util SparseBooleanArray SparseBooleanArray

Introduction

In this page you can find the example usage for android.util SparseBooleanArray SparseBooleanArray.

Prototype

public SparseBooleanArray() 

Source Link

Document

Creates a new SparseBooleanArray containing no mappings.

Usage

From source file:Main.java

public static SparseBooleanArray cloneSBArray(SparseBooleanArray arr) {
    try {//from w ww .  j a va 2 s .c om
        return arr.clone();
    } catch (Exception e) {
        // Happens when using HC - should clone manually
        int size = arr.size();
        SparseBooleanArray clone = new SparseBooleanArray();
        for (int i = 0; i < size; i++) {
            if (arr.get(arr.keyAt(i))) {
                clone.put(arr.keyAt(i), true);
            }
        }
        return clone;
    }
}

From source file:im.ene.lab.msrv.Adapter.java

public Adapter() {
    super();
    selectedItems = new SparseBooleanArray();
    setHasStableIds(true); // force stable Id for selection
}

From source file:com.akhbulatov.wordkeeper.adapter.WordAdapter.java

public WordAdapter(Cursor cursor) {
    super(cursor);
    mSelectedWords = new SparseBooleanArray();
}

From source file:com.money.manager.ex.investment.PortfolioCursorAdapter.java

public PortfolioCursorAdapter(Context context, Cursor cursor) {
    super(context, cursor, -1);

    this.mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    mHeadersAccountIndex = new HashMap<>();
    mCheckedPosition = new SparseBooleanArray();
    mContext = context;//  w  w  w  . jav a 2  s. com
}

From source file:com.money.manager.ex.investment.StocksCursorAdapter.java

public StocksCursorAdapter(Context context, Cursor cursor) {
    super(context, cursor, Constants.NOT_SET);

    this.mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    mHeadersAccountIndex = new HashMap<>();
    mCheckedPosition = new SparseBooleanArray();
    mContext = context;/*from  w w  w  .  ja va2s.  c o  m*/
}

From source file:com.github.jobs.ui.dialog.RemoveServicesDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final ArrayList<Parcelable> services = getArguments().getParcelableArrayList(ARG_SERVICES);
    CharSequence[] items = new CharSequence[services.size()];
    for (int i = 0, servicesSize = services.size(); i < servicesSize; i++) {
        TemplateService service = (TemplateService) services.get(i);
        items[i] = getString(R.string.service_list_item, service.getType(), service.getData());
    }//from ww  w.  j a  v a2 s . co m
    final SparseBooleanArray checked = new SparseBooleanArray();
    return new AlertDialog.Builder(getActivity()).setTitle(R.string.title_remove_services)
            .setMultiChoiceItems(items, null, new DialogInterface.OnMultiChoiceClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which, boolean isChecked) {
                    checked.put(which, isChecked);
                }
            }).setPositiveButton(R.string.remove_selected_services, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    // get a list of the services to delete
                    ArrayList<TemplateService> toRemove = new ArrayList<TemplateService>();
                    for (int i = 0; i < checked.size(); i++) {
                        if (checked.valueAt(i)) {
                            int index = checked.keyAt(i);
                            toRemove.add((TemplateService) services.get(index));
                        }
                    }
                    // fire service deletion
                    FragmentActivity activity = getActivity();
                    if (activity instanceof EditTemplateActivity) {
                        EditTemplateActivity editTemplateActivity = (EditTemplateActivity) activity;
                        editTemplateActivity.removeServices(toRemove);
                    }
                }
            }).setNegativeButton(R.string.cancel, null).create();
}

From source file:com.andremion.louvre.sample.MediaTypeFilterDialog.java

public MediaTypeFilterDialog() {
    mSelectedTypes = new SparseBooleanArray();
}

From source file:com.dm.material.dashboard.candybar.adapters.RequestAdapter.java

public RequestAdapter(@NonNull Context context, @NonNull SparseArrayCompat<Request> requests) {
    mContext = context;/*w  w w .ja va 2 s.c  o m*/
    mRequests = requests;
    mIsPremiumRequestEnabled = Preferences.getPreferences(mContext).isPremiumRequestEnabled();
    mTextColorSecondary = ColorHelper.getAttributeColor(mContext, android.R.attr.textColorSecondary);
    mTextColorAccent = ColorHelper.getAttributeColor(mContext, R.attr.colorAccent);
    mSelectedItems = new SparseBooleanArray();
}

From source file:com.money.manager.ex.adapter.AllDataAdapter.java

public AllDataAdapter(Context context, Cursor c, TypeCursor typeCursor) {
    super(context, c, -1);
    this.mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    this.mApplication = (MoneyManagerApplication) context.getApplicationContext();
    // create hash map
    mHeadersAccountIndex = new HashMap<Integer, Integer>();
    // create sparse array boolean checked
    mCheckedPosition = new SparseBooleanArray();

    mTypeCursor = typeCursor;//  www.  ja v  a2s  .  c o  m

    mCore = new Core(context);
    mContext = context;

    setFieldFromTypeCursor();
}

From source file:com.zzb.mynew.view.ExpandableTextView.java

/**
 * ?// w ww . ja va  2 s.com
 * @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);
}