微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

android.util.SparseBooleanArray的实例源码

项目:ultrasonic    文件DragSortListView.java   
/**
 * Use this when an item has been deleted,to move the check state of all
 * following items up one step. If you have a choiceMode which is not none,* this method must be called when the order of items changes in an
 * underlying adapter which does not have stable IDs (see
 * {@link listadapter#hasstableIds()}). This is because without IDs,the
 * ListView has no way of kNowing which items have moved where,and cannot
 * update the check state accordingly.
 * 
 * See also further comments on {@link #moveCheckState(int,int)}.
 * 
 * @param position
 */
public void removeCheckState(int position) {
    SparseBooleanArray cip = getCheckedItemPositions();

    if (cip.size() == 0)
        return;
    int[] runStart = new int[cip.size()];
    int[] runEnd = new int[cip.size()];
    int rangeStart = position;
    int rangeEnd = cip.keyAt(cip.size() - 1) + 1;
    int runcount = buildrunList(cip,rangeStart,rangeEnd,runStart,runEnd);
    for (int i = 0; i != runcount; i++) {
        if (!(runStart[i] == position || (runEnd[i] < runStart[i] && runEnd[i] > position))) {
            // Only set a new check mark in front of this run if it does
            // not contain the deleted position. If it does,we only need
            // to make it one check mark shorter at the end.
            setItemChecked(rotate(runStart[i],-1,rangeEnd),true);
        }
        setItemChecked(rotate(runEnd[i],false);
    }
}
项目:godlibrary    文件ExpandableListViewCheckAdapter.java   
public ArrayMap<Integer,long[]> getIds() {
    ArrayMap<Integer,long[]> arrayMap = new ArrayMap<>();
    if (choiceMode == ListView.CHOICE_MODE_MULTIPLE) {
        for (Map.Entry<Integer,SparseBooleanArray> entry : multipleIds.entrySet()) {
            List<Integer> l = new ArrayList<>();
            SparseBooleanArray ids = entry.getValue();
            for (int i = 0; i < ids.size(); i++) {
                if (ids.valueAt(i)) {
                    l.add(ids.keyAt(i));
                }
            }
            long[] _ids = new long[l.size()];
            for (int i = 0; i < l.size(); i++) {
                _ids[i] = l.get(i);
            }
            arrayMap.put(entry.getKey(),_ids);
        }
    }
    return arrayMap;
}
项目:ExoPlayer-Offline    文件FakeExtractorInput.java   
private boolean checkXFully(boolean allowEndOfInput,int position,int length,SparseBooleanArray FailedPositions) throws IOException {
  if (simulateIOErrors && !FailedPositions.get(position)) {
    FailedPositions.put(position,true);
    peekPosition = readPosition;
    throw new SimulatedioException("Simulated IO error at position: " + position);
  }
  if (length > 0 && position == data.length) {
    if (allowEndOfInput) {
      return false;
    }
    throw new EOFException();
  }
  if (position + length > data.length) {
    throw new EOFException("Attempted to move past end of data: (" + position + " + "
        + length + ") > " + data.length);
  }
  return true;
}
项目:easyfilemanager    文件MultiSelectionUtil.java   
@Override
public void onDestroyActionMode(ActionMode actionMode) {
    mListener.onDestroyActionMode(actionMode);
    // Clear all the checked items
    SparseBooleanArray checkedPositions = mListView.getCheckedItemPositions();
    if (checkedPositions != null) {
        for (int i = 0; i < checkedPositions.size(); i++) {
            mListView.setItemChecked(checkedPositions.keyAt(i),false);
        }
    }
    // Restore the original onItemClickListener
    mListView.setonItemClickListener(mOldItemClickListener);
    // Clear the Action Mode
    mActionMode = null;
    // Reset the ListView's Choice Mode
    mListView.post(mSetChoiceModeNoneRunnable);
}
项目:easyfilemanager    文件MultiSelectionUtil.java   
@Override
public void onItemClick(AdapterView<?> adapterView,View view,long id) {
    // Check to see what the new checked state is,and then notify the listener
    final boolean checked = mListView.isItemChecked(position);
    mListener.onItemCheckedStateChanged(mActionMode,position,id,checked);
    boolean hasCheckedItem = checked;
    // Check to see if we have any checked items
    if (!hasCheckedItem) {
        SparseBooleanArray checkedItemPositions = mListView.getCheckedItemPositions();
        if (checkedItemPositions != null) {
            // Iterate through the SparseBooleanArray to see if there is a checked item
            int i = 0;
            while (!hasCheckedItem && i < checkedItemPositions.size()) {
                hasCheckedItem = checkedItemPositions.valueAt(i++);
            }
        }
    }
    // If we don't have any checked items,finish the action mode
    if (!hasCheckedItem) {
        mActionMode.finish();
    }
}
项目:NoticeDog    文件DragSortListView.java   
/**
 * Use this when an item has been deleted,and cannot
 * update the check state accordingly.
 * <p>
 * See also further comments on {@link #moveCheckState(int,int)}.
 *
 * @param position
 */
public void removeCheckState(int position) {
    SparseBooleanArray cip = getCheckedItemPositions();

    if (cip.size() == 0)
        return;
    int[] runStart = new int[cip.size()];
    int[] runEnd = new int[cip.size()];
    int rangeStart = position;
    int rangeEnd = cip.keyAt(cip.size() - 1) + 1;
    int runcount = buildrunList(cip,false);
    }
}
项目:TripleTap    文件GameFragment.java   
@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);

    // Get the SetGame
    SetGame game = mActionsListener.getSetGame();

    SparseBooleanArray checkedItemPositions = getCheckedItemPositions();
    int positionIndex = 0;
    // Loop through SparseBooleanArray and grab the positions that are checked
    for (int i = 0; i < checkedItemPositions.size(); i++) {
        if (checkedItemPositions.valueAt(i)) {
            mCheckedPositions[positionIndex] = checkedItemPositions.keyAt(i);
            positionIndex++;
        }
    }

    // Bundle objects
    outState.putParcelable(getString(R.string.bundle_key_game),Parcels.wrap(game));
    outState.putIntArray(getString(R.string.bundle_key_checked_positions),mCheckedPositions);
    outState.putInt(getString(R.string.bundle_key_checked_count),mCheckedCount);
}
项目:multi-copy    文件NotesFragment.java   
public void deleteRows(){
        //get Selected items
        SparseBooleanArray selected = notesAdapter.getmSelectedItems();

        //loop through selected items
        for (int i = (selected.size()-1) ;i >=0 ; i--){
            if (selected.valueAt(i)){
                //If the current id is selected remove the item via key
                deleteFromNoteRealm(selected.keyAt(i));
                notesAdapter.notifyDataSetChanged();
             }
        }

//        Toast.makeText(getContext(),selected.size() + " items deleted",Toast.LENGTH_SHORT).show();
        Snackbar snackbar = Snackbar.make(recyclerView,selected.size() + " Notes deleted",Snackbar.LENGTH_SHORT);
        snackbar.show();
        actionMode.finish();

    }
项目:FireFiles    文件MultiSelectionUtil.java   
@Override
public void onDestroyActionMode(ActionMode actionMode) {
    mListener.onDestroyActionMode(actionMode);
    // Clear all the checked items
    SparseBooleanArray checkedPositions = mListView.getCheckedItemPositions();
    if (checkedPositions != null) {
        for (int i = 0; i < checkedPositions.size(); i++) {
            mListView.setItemChecked(checkedPositions.keyAt(i),false);
        }
    }
    // Restore the original onItemClickListener
    mListView.setonItemClickListener(mOldItemClickListener);
    // Clear the Action Mode
    mActionMode = null;
    // Reset the ListView's Choice Mode
    mListView.post(mSetChoiceModeNoneRunnable);
}
项目:FireFiles    文件MultiSelectionUtil.java   
@Override
public void onItemClick(AdapterView<?> adapterView,finish the action mode
    if (!hasCheckedItem) {
        mActionMode.finish();
    }
}
项目:ShangHanLun    文件ATableView.java   
public NSIndexPath[] getIndexPathsForSelectedRows() {
    NSIndexPath[] indexPaths = null;

    SparseBooleanArray checkedList = getCheckedItemPositions();
    if (checkedList != null) {
        ArrayList<NSIndexPath> indexPathList = new ArrayList<NSIndexPath>();

        ATableViewAdapter adapter = getInternalAdapter();
        for (int i = 0; i < adapter.getCount(); i++) {
            if (checkedList.get(i)) {
                indexPathList.add(adapter.getIndexPath(i));
            }
        }

        indexPaths = indexPathList.toArray(new NSIndexPath[indexPathList
                .size()]);
    }

    return indexPaths;
}
项目:AmenEye    文件FoldableTextView.java   
/**
 * 初始化属性
 */
private void init(AttributeSet attrs) {
    mCollapsedStatus = new SparseBooleanArray();
    TypedArray typedArray = getContext().obtainStyledAttributes(attrs,R.styleable.FoldableTextView);
    mMaxCollapsedLines = typedArray.getInt(R.styleable.FoldableTextView_minLines,MAX_COLLAPSED_LInes);
    mAnimationDuration = typedArray.getInt(R.styleable.FoldableTextView_animDuration,DEFAULT_ANIM_DURATION);
    mExpandDrawable = typedArray.getDrawable(R.styleable.FoldableTextView_toggleSrcopen);
    mCollapseDrawable = typedArray.getDrawable(R.styleable.FoldableTextView_toggleSrcclose);

    if (mExpandDrawable == null) {
        mExpandDrawable = ContextCompat.getDrawable(getContext(),R.drawable.icon_green_arrow_up);
    }
    if (mCollapseDrawable == null) {
        mCollapseDrawable = ContextCompat.getDrawable(getContext(),R.drawable.icon_green_arrow_down);
    }
    contentTextColor = typedArray.getColor(R.styleable.FoldableTextView_textColors,DEFAULT_TEXT_COLOR);
    contentTextSize = typedArray.getDimension(R.styleable.FoldableTextView_textSize,DEFAULT_TEXT_SIZE);
    collapseExpandTextColor = typedArray.getColor(R.styleable.FoldableTextView_flagColor,DEFAULT_FLAG_COLOR);
    collapseExpandTextSize = typedArray.getDimension(R.styleable.FoldableTextView_flagSize,DEFAULT_TEXT_SIZE);
    gravity = typedArray.getInt(R.styleable.FoldableTextView_flagGravity,DEFAULT_FLAG_GraviTY);
    typedArray.recycle();
    // default visibility is gone
    setVisibility(GONE);
}
项目:simple-share-android    文件MultiSelectionUtil.java   
@Override
public void onDestroyActionMode(ActionMode actionMode) {
    mListener.onDestroyActionMode(actionMode);
    // Clear all the checked items
    SparseBooleanArray checkedPositions = mListView.getCheckedItemPositions();
    if (checkedPositions != null) {
        for (int i = 0; i < checkedPositions.size(); i++) {
            mListView.setItemChecked(checkedPositions.keyAt(i),false);
        }
    }
    // Restore the original onItemClickListener
    mListView.setonItemClickListener(mOldItemClickListener);
    // Clear the Action Mode
    mActionMode = null;
    // Reset the ListView's Choice Mode
    mListView.post(mSetChoiceModeNoneRunnable);
}
项目:simple-share-android    文件MultiSelectionUtil.java   
@Override
public void onItemClick(AdapterView<?> adapterView,finish the action mode
    if (!hasCheckedItem) {
        mActionMode.finish();
    }
}
项目:Veggietizer    文件HistoryActivity.java   
/**
 * Deletes the selected meat dish from the DB.
 *
 * @param params Unused.
 * @return Unused.
 */
@Override
protected Void doInBackground(Void... params) {
    SparseBooleanArray checkedEntries = listView.getCheckedItemPositions();
    Adapter adapter = listView.getAdapter();
    List<View> viewsToDelete = new LinkedList<>();
    List<Long> meatdishesToDelete = new LinkedList<>();

    for (int i = 0; i < adapter.getCount(); i++) {
        if (checkedEntries.get(i)) {
            viewsToDelete.add(adapter.getView(i,null,null));
        }
    }

    entriesToDelete = viewsToDelete.size();

    for (View v : viewsToDelete) {
        String meatdishesToDeleteStr = v.findViewById(R.id.imageView_history)
                .getContentDescription().toString();

        meatdishesToDelete.add(Long.valueOf(meatdishesToDeleteStr));
    }

    Model.deleteMeatdishes(getApplicationContext(),meatdishesToDelete);
    return null;
}
项目:android-chessclock    文件MultiSelectionUtil.java   
public boolean saveInstanceState(Bundle outBundle) {
    SparseBooleanArray checkedPositions = mListView.getCheckedItemPositions();
    if (mActionMode != null && checkedPositions != null) {
        ArrayList<Integer> positions = new ArrayList<Integer>();
        for (int i = 0; i < checkedPositions.size(); i++) {
            if (checkedPositions.valueAt(i)) {
                int position = checkedPositions.keyAt(i);
                positions.add(position);
            }
        }

        outBundle.putIntegerArrayList(getStateKey(),positions);
        return true;
    }
    return false;
}
项目:Exoplayer2Radio    文件TsExtractor.java   
/**
 * @param mode Mode for the extractor. One of {@link #MODE_MULTI_PMT},{@link #MODE_SINGLE_PMT}
 *     and {@link #MODE_HLS}.
 * @param timestampAdjuster A timestamp adjuster for offsetting and scaling sample timestamps.
 * @param payloadReaderFactory Factory for injecting a custom set of payload readers.
 */
public TsExtractor(@Mode int mode,TimestampAdjuster timestampAdjuster,TsPayloadReader.Factory payloadReaderFactory) {
  this.payloadReaderFactory = Assertions.checkNotNull(payloadReaderFactory);
  this.mode = mode;
  if (mode == MODE_SINGLE_PMT || mode == MODE_HLS) {
    timestampAdjusters = Collections.singletonList(timestampAdjuster);
  } else {
    timestampAdjusters = new ArrayList<>();
    timestampAdjusters.add(timestampAdjuster);
  }
  tsPacketBuffer = new ParsableByteArray(BUFFER_SIZE);
  tsScratch = new ParsableBitArray(new byte[3]);
  trackIds = new SparseBooleanArray();
  tsPayloadReaders = new SparseArray<>();
  continuityCounters = new SparseIntArray();
  resetPayloadReaders();
}
项目:lineagex86    文件ZenModeScheduleDaysSelection.java   
private int[] getDays() {
    final SparseBooleanArray rt = new SparseBooleanArray(mDays.size());
    for (int i = 0; i < mDays.size(); i++) {
        final int day = mDays.keyAt(i);
        if (!mDays.valueAt(i)) continue;
        rt.put(day,true);
    }
    final int[] rta = new int[rt.size()];
    for (int i = 0; i < rta.length; i++) {
        rta[i] = rt.keyAt(i);
    }
    Arrays.sort(rta);
    return rta;
}
项目:GitHub    文件CustomLayoutManager.java   
public State() {
    itemsFrames = new SparseArray<>();
    itemsAttached = new SparseBooleanArray();
    scrolledX = 0;
    scrolledY = 0;
    contentWidth = 0;
    contentHeight = 0;
    canScrollHorizontal = true;
    canScrollVertical = true;
    itemLineCount = 1;
    totalSpreadCount = 0;
}
项目:codedemos    文件EmptyUtil.java   
public static boolean isEmpty(Object obj) {
    if (obj == null) {
        return true;
    }
    if (obj instanceof String && obj.toString().length() == 0) {
        return true;
    }
    if (obj.getClass().isArray() && Array.getLength(obj) == 0) {
        return true;
    }
    if (obj instanceof Collection && ((Collection) obj).isEmpty()) {
        return true;
    }
    if (obj instanceof Map && ((Map) obj).isEmpty()) {
        return true;
    }
    if (obj instanceof SparseArray && ((SparseArray) obj).size() == 0) {
        return true;
    }
    if (obj instanceof SparseBooleanArray && ((SparseBooleanArray) obj).size() == 0) {
        return true;
    }
    if (obj instanceof SparseIntArray && ((SparseIntArray) obj).size() == 0) {
        return true;
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        if (obj instanceof SparseLongArray && ((SparseLongArray) obj).size() == 0) {
            return true;
        }
    }
    return false;
}
项目:ultrasonic    文件DragSortListView.java   
private static int findFirstSetIndex(SparseBooleanArray sba,int rangeStart,int rangeEnd) {
    int size = sba.size();
    int i = insertionIndexForKey(sba,rangeStart);
    while (i < size && sba.keyAt(i) < rangeEnd && !sba.valueAt(i))
        i++;
    if (i == size || sba.keyAt(i) >= rangeEnd)
        return -1;
    return i;
}
项目:ultrasonic    文件DragSortListView.java   
private static int insertionIndexForKey(SparseBooleanArray sba,int key) {
    int low = 0;
    int high = sba.size();
    while (high - low > 0) {
        int middle = (low + high) >> 1;
        if (sba.keyAt(middle) < key)
            low = middle + 1;
        else
            high = middle;
    }
    return low;
}
项目:Android-UtilCode    文件EmptyUtils.java   
/**
 * 判断对象是否为空
 *
 * @param obj 对象
 * @return {@code true}: 为空<br>{@code false}: 不为空
 */
public static boolean isEmpty(Object obj) {
    if (obj == null) {
        return true;
    }
    if (obj instanceof String && obj.toString().length() == 0) {
        return true;
    }
    if (obj.getClass().isArray() && Array.getLength(obj) == 0) {
        return true;
    }
    if (obj instanceof Collection && ((Collection) obj).isEmpty()) {
        return true;
    }
    if (obj instanceof Map && ((Map) obj).isEmpty()) {
        return true;
    }
    if (obj instanceof SparseArray && ((SparseArray) obj).size() == 0) {
        return true;
    }
    if (obj instanceof SparseBooleanArray && ((SparseBooleanArray) obj).size() == 0) {
        return true;
    }
    if (obj instanceof SparseIntArray && ((SparseIntArray) obj).size() == 0) {
        return true;
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        if (obj instanceof SparseLongArray && ((SparseLongArray) obj).size() == 0) {
            return true;
        }
    }
    return false;
}
项目:Android-UtilCode    文件EmptyUtilsTest.java   
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
@Test
public void isEmpty() throws Exception {
    String string = "";
    String string1 = " ";
    int[][] arr = new int[][]{};
    int[] arr1 = null;
    LinkedList<Integer> list = new LinkedList<>();
    HashMap<String,Integer> map = new HashMap<>();
    SparseArray<String> sa = new SparseArray<>();
    SparseBooleanArray sba = new SparseBooleanArray();
    SparseIntArray sia = new SparseIntArray();
    SparseLongArray sla = new SparseLongArray();

    assertthat(EmptyUtils.isEmpty(string)).isTrue();
    assertthat(EmptyUtils.isEmpty(string1)).isFalse();
    assertthat(EmptyUtils.isEmpty(arr)).isTrue();
    assertthat(EmptyUtils.isEmpty(arr1)).isTrue();
    assertthat(EmptyUtils.isEmpty(list)).isTrue();
    assertthat(EmptyUtils.isEmpty(map)).isTrue();
    assertthat(EmptyUtils.isEmpty(sa)).isTrue();
    assertthat(EmptyUtils.isEmpty(sba)).isTrue();
    assertthat(EmptyUtils.isEmpty(sia)).isTrue();
    assertthat(EmptyUtils.isEmpty(sla)).isTrue();

    assertthat(!EmptyUtils.isNotEmpty(string)).isTrue();
    assertthat(!EmptyUtils.isNotEmpty(string1)).isFalse();
    assertthat(!EmptyUtils.isNotEmpty(arr)).isTrue();
    assertthat(!EmptyUtils.isNotEmpty(arr1)).isTrue();
    assertthat(!EmptyUtils.isNotEmpty(list)).isTrue();
    assertthat(!EmptyUtils.isNotEmpty(map)).isTrue();
    assertthat(!EmptyUtils.isNotEmpty(sa)).isTrue();
    assertthat(!EmptyUtils.isNotEmpty(sba)).isTrue();
    assertthat(!EmptyUtils.isNotEmpty(sia)).isTrue();
    assertthat(!EmptyUtils.isNotEmpty(sla)).isTrue();
}
项目:SimpleNotes    文件MultiChoiceImplementation.java   
@Override
public boolean onActionItemClicked(ActionMode actionMode,MenuItem menuItem) {
    SparseBooleanArray sparseBooleanArray = listView.getCheckedItemPositions();
    switch (menuItem.getItemId()) {
        case R.id.delete_all_action:
            //SparseBooleanArray sparseBooleanArray = listView.getCheckedItemPositions();
            // Перебираем с конца,чтобы не нарушать порядок нумерации в списке
            for (int i = (sparseBooleanArray.size() - 1); i >= 0; i--) {
                if (sparseBooleanArray.valueAt(i)) {
                    parentActivity.notes.remove(sparseBooleanArray.keyAt(i));
                }
            }
            actionMode.finish();
            parentActivity.adapter.notifyDataSetChanged();
            parentActivity.listView.smoothScrollToPosition(0);
            Toast.makeText(parentActivity,R.string.deleted_successfully_toast,Toast.LENGTH_LONG).show();
            return true;
        case R.id.copy_all_action:
            StringBuilder textTocopy = new StringBuilder("");
            String label = "Notes text";
            for (int i = 0; i < sparseBooleanArray.size(); i++) {
                if (sparseBooleanArray.valueAt(i)) {
                    textTocopy.append(parentActivity.notes.get(sparseBooleanArray.keyAt(i)).getText());
                    textTocopy.append("\n");
                }
            }
            ClipboardManager clipboard = (ClipboardManager) parentActivity.getSystemService(CLIPBOARD_SERVICE);
            ClipData clip = ClipData.newPlainText(label,textTocopy.toString());
            clipboard.setPrimaryClip(clip);
            actionMode.finish();
            Toast.makeText(parentActivity,R.string.copied_to_clipboard_toast,Toast.LENGTH_LONG).show();
            return true;
        default:
            return false;
    }
}
项目:godlibrary    文件FragmentListView.java   
public long[] getCheckedItemIds() {
    SparseBooleanArray ids = adapterCheckLin.getCheckedItemIds();
    List<Integer> list = new ArrayList<>();
    for (int i = 0; i < ids.size(); i++) {
        if (ids.valueAt(i)) {
            list.add(ids.keyAt(i));
        }
    }
    long[] _ids = new long[list.size()];
    for (int i = 0; i < list.size(); i++) {
        _ids[i] = list.get(i);
    }
    return _ids;
}
项目:godlibrary    文件CheckLayout.java   
public static long[] getCheckedItemIds(ListView listview) {
    List<Integer> list = new ArrayList<>();
    //listview.getCheckedItemPositions(); 为触发过选择的item,选中 为true 取消false
    SparseBooleanArray sp = listview.getCheckedItemPositions();
    for (int i = 0; i < sp.size(); i++) {
        if (sp.valueAt(i)) {
            list.add(sp.keyAt(i));
        }
    }
    long[] ids = new long[list.size()];
    for (int i = 0; i < list.size(); i++) {
        ids[i] = list.get(i);
    }
    return ids;
}
项目:airgram    文件TsExtractor.java   
public TsExtractor(PtsTimestampAdjuster ptsTimestampAdjuster,int workaroundFlags) {
  this.ptsTimestampAdjuster = ptsTimestampAdjuster;
  this.workaroundFlags = workaroundFlags;
  tsPacketBuffer = new ParsableByteArray(TS_PACKET_SIZE);
  tsScratch = new ParsableBitArray(new byte[3]);
  tsPayloadReaders = new SparseArray<>();
  tsPayloadReaders.put(TS_PAT_PID,new PatReader());
  streamTypes = new SparseBooleanArray();
}
项目:markor    文件MarkorSingleton.java   
public void copySelectednotes(SparseBooleanArray checkedindices,BaseAdapter notesAdapter,String destination) {
    for (int i = 0; i < checkedindices.size(); i++) {
        if (checkedindices.valueAt(i)) {
            File file = (File) notesAdapter.getItem(checkedindices.keyAt(i));
            copyFile(file,destination);
        }
    }
}
项目:Quran    文件Quranlistadapter.java   
public Quranlistadapter(Context context,RecyclerView recyclerView,QuranRow[] items,boolean isEditable) {
  inflater = LayoutInflater.from(context);
  this.recyclerView = recyclerView;
  elements = items;
  this.context = context;
  checkedState = new SparseBooleanArray();
  this.isEditable = isEditable;
}
项目:Quran    文件QariDownloadInfo.java   
QariDownloadInfo(QariItem item,List<Integer> suras) {
  this.qariItem = item;
  this.partialSuras = new SparseBooleanArray();
  this.downloadedSuras = new SparseBooleanArray();
  for (int i = 0,surasSize = suras.size(); i < surasSize; i++) {
    Integer sura = suras.get(i);
    this.downloadedSuras.put(sura,true);
  }
}
项目:ExoPlayer-Offline    文件FakeExtractorInput.java   
private FakeExtractorInput(byte[] data,boolean simulateUnkNownLength,boolean simulatePartialReads,boolean simulateIOErrors) {
  this.data = data;
  this.simulateUnkNownLength = simulateUnkNownLength;
  this.simulatePartialReads = simulatePartialReads;
  this.simulateIOErrors = simulateIOErrors;
  partiallySatisfiedTargetPositions = new SparseBooleanArray();
  FailedReadPositions = new SparseBooleanArray();
  FailedPeekPositions = new SparseBooleanArray();
}
项目:SpaceRace    文件scoreCounter.java   
@NonNull
public Map<LatLng,SparseBooleanArray> getAnswerCorrectnessMap () {
    Map<LatLng,SparseBooleanArray> res = new HashMap<>();

    for (LatLng id : pointMap.keySet()) {
        SparseBooleanArray isCorrectList = new SparseBooleanArray();

        for (score score : pointMap.get(id)) {
            isCorrectList.put(score.getQuestionId(),score.isCorrect());
        }
    }
    return res;
}
项目:RLibrary    文件ExpandableTextView.java   
/**
 * 在列表中,使用此方法设置文本信息
 */
public void setText(CharSequence text,SparseBooleanArray collapsedStatus,int position) {
    mCollapsedStatus = collapsedStatus;
    mPosition = position;
    boolean isCollapsed = collapsedStatus.get(position,true);
    clearanimation();
    mCollapsed = isCollapsed;
    //mButton.setimageDrawable(mCollapsed ? mExpandDrawable : mCollapseDrawable);
    setText(text);
    getLayoutParams().height = ViewGroup.LayoutParams.WRAP_CONTENT;
    requestLayout();
}
项目:NoticeDog    文件DragSortListView.java   
private static int findFirstSetIndex(SparseBooleanArray sba,rangeStart);
    while (i < size && sba.keyAt(i) < rangeEnd && !sba.valueAt(i))
        i++;
    if (i == size || sba.keyAt(i) >= rangeEnd)
        return -1;
    return i;
}
项目:NoticeDog    文件DragSortListView.java   
private static int insertionIndexForKey(SparseBooleanArray sba,int key) {
    int low = 0;
    int high = sba.size();
    while (high - low > 0) {
        int middle = (low + high) >> 1;
        if (sba.keyAt(middle) < key)
            low = middle + 1;
        else
            high = middle;
    }
    return low;
}
项目:WhatsAppStatusSaver    文件FloatAdapter.java   
public FloatAdapter(Context context,ArrayList<String> statuses){
    mContext = context;
    statusPaths = statuses;
    selectedPicturesstatuses = new ArrayList<>();
    selectedVidoesstatuses = new ArrayList<>();
    mPicturesCheckStates = new SparseBooleanArray(statuses.size());
    mVideosCheckStates = new SparseBooleanArray(statuses.size());
}
项目:AndroidUtilCode-master    文件EmptyUtils.java   
/**
 * 判断对象是否为空
 *
 * @param obj 对象
 * @return {@code true}: 为空<br>{@code false}: 不为空
 */
public static boolean isEmpty(Object obj) {
    if (obj == null) {
        return true;
    }
    if (obj instanceof String && obj.toString().length() == 0) {
        return true;
    }
    if (obj.getClass().isArray() && Array.getLength(obj) == 0) {
        return true;
    }
    if (obj instanceof Collection && ((Collection) obj).isEmpty()) {
        return true;
    }
    if (obj instanceof Map && ((Map) obj).isEmpty()) {
        return true;
    }
    if (obj instanceof SparseArray && ((SparseArray) obj).size() == 0) {
        return true;
    }
    if (obj instanceof SparseBooleanArray && ((SparseBooleanArray) obj).size() == 0) {
        return true;
    }
    if (obj instanceof SparseIntArray && ((SparseIntArray) obj).size() == 0) {
        return true;
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        if (obj instanceof SparseLongArray && ((SparseLongArray) obj).size() == 0) {
            return true;
        }
    }
    return false;
}
项目:AndroidUtilCode-master    文件EmptyUtilsTest.java   
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
@Test
public void isEmpty() throws Exception {
    String string = "";
    String string1 = " ";
    int[][] arr = new int[][]{};
    int[] arr1 = null;
    LinkedList<Integer> list = new LinkedList<>();
    HashMap<String,Integer> map = new HashMap<>();
    SparseArray<String> sa = new SparseArray<>();
    SparseBooleanArray sba = new SparseBooleanArray();
    SparseIntArray sia = new SparseIntArray();
    SparseLongArray sla = new SparseLongArray();

    assertthat(EmptyUtils.isEmpty(string)).isTrue();
    assertthat(EmptyUtils.isEmpty(string1)).isFalse();
    assertthat(EmptyUtils.isEmpty(arr)).isTrue();
    assertthat(EmptyUtils.isEmpty(arr1)).isTrue();
    assertthat(EmptyUtils.isEmpty(list)).isTrue();
    assertthat(EmptyUtils.isEmpty(map)).isTrue();
    assertthat(EmptyUtils.isEmpty(sa)).isTrue();
    assertthat(EmptyUtils.isEmpty(sba)).isTrue();
    assertthat(EmptyUtils.isEmpty(sia)).isTrue();
    assertthat(EmptyUtils.isEmpty(sla)).isTrue();

    assertthat(!EmptyUtils.isNotEmpty(string)).isTrue();
    assertthat(!EmptyUtils.isNotEmpty(string1)).isFalse();
    assertthat(!EmptyUtils.isNotEmpty(arr)).isTrue();
    assertthat(!EmptyUtils.isNotEmpty(arr1)).isTrue();
    assertthat(!EmptyUtils.isNotEmpty(list)).isTrue();
    assertthat(!EmptyUtils.isNotEmpty(map)).isTrue();
    assertthat(!EmptyUtils.isNotEmpty(sa)).isTrue();
    assertthat(!EmptyUtils.isNotEmpty(sba)).isTrue();
    assertthat(!EmptyUtils.isNotEmpty(sia)).isTrue();
    assertthat(!EmptyUtils.isNotEmpty(sla)).isTrue();
}
项目:orgzly-android    文件ListViewUtils.java   
public static TreeSet<Long> getCheckedIds(ListView listView) {
    TreeSet<Long> ids = new TreeSet<>();

    SparseBooleanArray checked = listView.getCheckedItemPositions();

    for (int i = 0; i < checked.size(); i++) {
        if (checked.valueAt(i)) {
            long id = listView.getItemIdAtPosition(checked.keyAt(i));
            ids.add(id);
        }
    }

    return ids;
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。