android.util.SparseArray Java Examples

The following examples show how to use android.util.SparseArray. 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: DvbParser.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
/**
 * Parses a page composition segment, as defined by ETSI EN 300 743 7.2.2.
 */
private static PageComposition parsePageComposition(ParsableBitArray data, int length) {
  int timeoutSecs = data.readBits(8);
  int version = data.readBits(4);
  int state = data.readBits(2);
  data.skipBits(2);
  int remainingLength = length - 2;

  SparseArray<PageRegion> regions = new SparseArray<>();
  while (remainingLength > 0) {
    int regionId = data.readBits(8);
    data.skipBits(8); // Skip reserved.
    int regionHorizontalAddress = data.readBits(16);
    int regionVerticalAddress = data.readBits(16);
    remainingLength -= 6;
    regions.put(regionId, new PageRegion(regionHorizontalAddress, regionVerticalAddress));
  }

  return new PageComposition(timeoutSecs, version, state, regions);
}
 
Example #2
Source File: Recycler.java    From AndroidAnimationExercise with Apache License 2.0 6 votes vote down vote up
static Scrap retrieveFromScrap(SparseArray<Scrap> scrapViews, int position) {
	int size = scrapViews.size();
	if (size > 0) {
		// See if we still have a view for this position.
		Scrap result = scrapViews.get(position, null);
		if (result != null) {
			scrapViews.remove(position);
			return result;
		}
		int index = size - 1;
		result = scrapViews.valueAt(index);
		scrapViews.removeAt(index);
		result.valid = false;
		return result;
	}
	return null;
}
 
Example #3
Source File: Recycler.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
static Scrap retrieveFromScrap(SparseArray<Scrap> scrapViews, int position) {
	int size = scrapViews.size();
	if (size > 0) {
		// See if we still have a view for this position.
		Scrap result = scrapViews.get(position, null);
		if (result != null) {
			scrapViews.remove(position);
			return result;
		}
		int index = size - 1;
		result = scrapViews.valueAt(index);
		scrapViews.removeAt(index);
		result.valid = false;
		return result;
	}
	return null;
}
 
Example #4
Source File: CPUFragment.java    From KernelAdiutor with GNU General Public License v3.0 6 votes vote down vote up
private void refreshCores(SparseArray<SwitchView> array, int[] freqs) {
    for (int i = 0; i < array.size(); i++) {
        SwitchView switchView = array.valueAt(i);
        if (switchView != null) {
            final int core = array.keyAt(i);
            int freq = freqs[core];

            String freqText = freq == 0 ? getString(R.string.offline) : (freq / 1000)
                    + getString(R.string.mhz);
            switchView.clearOnSwitchListener();
            switchView.setChecked(freq != 0);
            switchView.setSummary(getString(R.string.core, core + 1) + " - " + freqText);
            switchView.addOnSwitchListener((switchView1, isChecked) -> {
                if (core == 0) {
                    Utils.toast(R.string.no_offline_core, getActivity());
                } else {
                    mCPUFreq.onlineCpu(core, isChecked, true, getActivity());
                }
            });
        }
    }
}
 
Example #5
Source File: CoordinatorLayout.java    From ticdesign with Apache License 2.0 6 votes vote down vote up
@Override
protected void onRestoreInstanceState(Parcelable state) {
    final SavedState ss = (SavedState) state;
    super.onRestoreInstanceState(ss.getSuperState());

    final SparseArray<Parcelable> behaviorStates = ss.behaviorStates;

    for (int i = 0, count = getChildCount(); i < count; i++) {
        final View child = getChildAt(i);
        final int childId = child.getId();
        final LayoutParams lp = getResolvedLayoutParams(child);
        final Behavior b = lp.getBehavior();

        if (childId != NO_ID && b != null) {
            Parcelable savedState = behaviorStates.get(childId);
            if (savedState != null) {
                b.onRestoreInstanceState(this, child, savedState);
            }
        }
    }
}
 
Example #6
Source File: OppoVolumePanel.java    From Noyze with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("deprecation")
@Override public void onCreate() {
    parentOnCreate();
    oneVolume = false;
    Context context = getContext();
    LayoutInflater inflater = LayoutInflater.from(context);

    // Load default PA color if the user doesn't have a preference.
    root = (ViewGroup) inflater.inflate(R.layout.oppo_volume_adjust, null);

    mPanel = (ViewGroup) root.findViewById(R.id.visible_panel);
    mSliderGroup = (ViewGroup) root.findViewById(R.id.slider_group);

    loadSystemSettings();

    if (null == mStreamControls)
        mStreamControls = new SparseArray<StreamControl>(StreamResources.STREAMS.length);

    // Change the icon to use for Bluetooth Music.
    MusicMode.BLUETOOTH.iconResId = R.drawable.oppo_ic_audio_bt;
    MusicMode.BLUETOOTH.iconMuteResId = R.drawable.oppo_ic_audio_bt_mute;

    mLayout = root;
}
 
Example #7
Source File: ChatUsersActivity.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
private TLObject getAnyParticipant(int userId) {
    boolean updated = false;
    for (int a = 0; a < 3; a++) {
        SparseArray<TLObject> map;
        if (a == 0) {
            map = contactsMap;
        } else if (a == 1) {
            map = botsMap;
        } else {
            map = participantsMap;
        }
        TLObject p = map.get(userId);
        if (p != null) {
            return p;
        }
    }
    return null;
}
 
Example #8
Source File: ProviderTvFragment.java    From xipl with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (savedInstanceState == null) {
        mFragmentSparseArray = new SparseArray<>();
        setupUI();
        showRows();
        getMainFragmentRegistry().registerFragment(PageRow.class, new TvFragmentFactory());

        if (getSearchActivity() != null) {
            TypedValue value = new TypedValue();
            TypedArray array = getActivity().obtainStyledAttributes(value.data, new int[] {android.R.attr.colorAccent});
            setSearchAffordanceColor(array.getColor(0, 0));
            setOnSearchClickedListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Intent intent = new Intent(getActivity(), getSearchActivity());
                    startActivity(intent);
                }
            });
            array.recycle();
        }
    }
}
 
Example #9
Source File: ScanRecordCompat.java    From AndroidBleManager with Apache License 2.0 6 votes vote down vote up
/**
 * Returns a string composed from a {@link SparseArray}.
 */
static String toString(SparseArray<byte[]> array) {
    if (array == null) {
        return "null";
    }
    if (array.size() == 0) {
        return "{}";
    }
    StringBuilder buffer = new StringBuilder();
    buffer.append('{');
    for (int i = 0; i < array.size(); ++i) {
        buffer.append(array.keyAt(i)).append("=").append(Arrays.toString(array.valueAt(i)));
    }
    buffer.append('}');
    return buffer.toString();
}
 
Example #10
Source File: MatroskaExtractor.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
MatroskaExtractor(EbmlReader reader, @Flags int flags) {
  this.reader = reader;
  this.reader.init(new InnerEbmlReaderOutput());
  seekForCuesEnabled = (flags & FLAG_DISABLE_SEEK_FOR_CUES) == 0;
  varintReader = new VarintReader();
  tracks = new SparseArray<>();
  scratch = new ParsableByteArray(4);
  vorbisNumPageSamples = new ParsableByteArray(ByteBuffer.allocate(4).putInt(-1).array());
  seekEntryIdBytes = new ParsableByteArray(4);
  nalStartCode = new ParsableByteArray(NalUnitUtil.NAL_START_CODE);
  nalLength = new ParsableByteArray(4);
  sampleStrippedBytes = new ParsableByteArray();
  subtitleSample = new ParsableByteArray();
  encryptionInitializationVector = new ParsableByteArray(ENCRYPTION_IV_SIZE);
  encryptionSubsampleData = new ParsableByteArray();
}
 
Example #11
Source File: SeatHelper.java    From Huochexing12306 with Apache License 2.0 6 votes vote down vote up
public static SparseArray<String> getSeatTypes() {
	if (seatTypes == null){
		seatTypes = new SparseArray<String>();
		seatTypes.put(SWZ, "商务座");
		seatTypes.put(TZ, "特等座");
		seatTypes.put(ZY, "一等座");
		seatTypes.put(ZE, "二等座");
		seatTypes.put(GR, "高级软卧");
		seatTypes.put(RW, "软卧");
		seatTypes.put(RZ, "软座");
		seatTypes.put(YW, "硬卧");
		seatTypes.put(YZ, "硬座");
		seatTypes.put(WZ, "无座");
	}
	return seatTypes;
}
 
Example #12
Source File: HdmiControlService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@ServiceThreadOnly
private void updateSafeMhlInput() {
    assertRunOnServiceThread();
    List<HdmiDeviceInfo> inputs = Collections.emptyList();
    SparseArray<HdmiMhlLocalDeviceStub> devices = mMhlController.getAllLocalDevices();
    for (int i = 0; i < devices.size(); ++i) {
        HdmiMhlLocalDeviceStub device = devices.valueAt(i);
        HdmiDeviceInfo info = device.getInfo();
        if (info != null) {
            if (inputs.isEmpty()) {
                inputs = new ArrayList<>();
            }
            inputs.add(device.getInfo());
        }
    }
    synchronized (mLock) {
        mMhlDevices = inputs;
    }
}
 
Example #13
Source File: TaskService.java    From Pretty-Zhihu with Apache License 2.0 6 votes vote down vote up
@Override
public boolean handleMessage(Message msg) {
    switch (msg.what) {
        case MSG_HUNT_COMPLETE:
            @SuppressWarnings("unchecked") SparseArray<List<String>> urls = (SparseArray<List<String>>) msg.obj;
            for (int i = 0; i < urls.size(); i++) {
                List<Picture> pictures = new ArrayList<>();
                int questionId = urls.keyAt(i);
                for (String url : urls.valueAt(i)) {
                    if (mPrettyRepository.getPicture(url, questionId) == null) {
                        Picture picture = new Picture(null, questionId, url);
                        mPrettyRepository.insertOrUpdate(picture);
                        pictures.add(picture);
                    }
                }
                if (pictures.size() > 0) {
                    EventBus.getDefault().post(new NewPictureEvent(questionId, pictures));
                    mTaskObservable.notifyFetch(questionId, pictures);
                }
            }
            break;
    }
    return false;
}
 
Example #14
Source File: CachedContentIndex.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates an instance supporting either or both of database and legacy storage.
 *
 * @param databaseProvider Provides the database in which the index is stored, or {@code null} to
 *     use only legacy storage.
 * @param legacyStorageDir The directory in which any legacy storage is stored, or {@code null} to
 *     use only database storage.
 * @param legacyStorageSecretKey A 16 byte AES key for reading, and optionally writing, legacy
 *     storage.
 * @param legacyStorageEncrypt Whether to encrypt when writing to legacy storage. Must be false if
 *     {@code legacyStorageSecretKey} is null.
 * @param preferLegacyStorage Whether to use prefer legacy storage if both storage types are
 *     enabled. This option is only useful for downgrading from database storage back to legacy
 *     storage.
 */
public CachedContentIndex(
    @Nullable DatabaseProvider databaseProvider,
    @Nullable File legacyStorageDir,
    @Nullable byte[] legacyStorageSecretKey,
    boolean legacyStorageEncrypt,
    boolean preferLegacyStorage) {
  Assertions.checkState(databaseProvider != null || legacyStorageDir != null);
  keyToContent = new HashMap<>();
  idToKey = new SparseArray<>();
  removedIds = new SparseBooleanArray();
  newIds = new SparseBooleanArray();
  Storage databaseStorage =
      databaseProvider != null ? new DatabaseStorage(databaseProvider) : null;
  Storage legacyStorage =
      legacyStorageDir != null
          ? new LegacyStorage(
              new File(legacyStorageDir, FILE_NAME_ATOMIC),
              legacyStorageSecretKey,
              legacyStorageEncrypt)
          : null;
  if (databaseStorage == null || (legacyStorage != null && preferLegacyStorage)) {
    storage = legacyStorage;
    previousStorage = databaseStorage;
  } else {
    storage = databaseStorage;
    previousStorage = legacyStorage;
  }
}
 
Example #15
Source File: TriggerProperty.java    From graphhopper-navigation-android with MIT License 5 votes vote down vote up
static SparseArray<Number[]> getSparseArray(RouteProgress previousRouteProgress, RouteProgress routeProgress) {
  // Build hashMap matching the trigger properties to their corresponding current values.
  SparseArray<Number[]> statementObjects = new SparseArray<>(13);
  statementObjects.put(TriggerProperty.STEP_DISTANCE_TOTAL_METERS,
    new Number[] {routeProgress.currentLegProgress().currentStep().distance()});
  statementObjects.put(TriggerProperty.STEP_DURATION_TOTAL_SECONDS,
    new Number[] {routeProgress.currentLegProgress().currentStep().duration()});
  statementObjects.put(TriggerProperty.STEP_DISTANCE_REMAINING_METERS,
    new Number[] {routeProgress.currentLegProgress().currentStepProgress().distanceRemaining()});
  statementObjects.put(TriggerProperty.STEP_DURATION_REMAINING_SECONDS,
    new Number[] {routeProgress.currentLegProgress().currentStepProgress().durationRemaining()});
  statementObjects.put(TriggerProperty.STEP_DISTANCE_TRAVELED_METERS,
    new Number[] {routeProgress.currentLegProgress().currentStepProgress().distanceTraveled()});
  statementObjects.put(TriggerProperty.STEP_INDEX,
    new Number[] {routeProgress.currentLegProgress().stepIndex()});
  statementObjects.put(TriggerProperty.NEW_STEP,
    new Number[] {
      previousRouteProgress.currentLegProgress().stepIndex(),
      routeProgress.currentLegProgress().stepIndex()});
  statementObjects.put(TriggerProperty.LAST_STEP,
    new Number[] {routeProgress.currentLegProgress().stepIndex(),
      (routeProgress.currentLeg().steps().size() - 2)});
  statementObjects.put(TriggerProperty.FIRST_STEP,
    new Number[] {routeProgress.currentLegProgress().stepIndex(), 0});
  statementObjects.put(TriggerProperty.NEXT_STEP_DURATION_SECONDS,
    new Number[] {
      routeProgress.currentLegProgress().upComingStep() != null
        ? routeProgress.currentLegProgress().upComingStep().duration() : 0});
  statementObjects.put(TriggerProperty.NEXT_STEP_DISTANCE_METERS,
    new Number[] {
      routeProgress.currentLegProgress().upComingStep() != null
        ? routeProgress.currentLegProgress().upComingStep().distance() : 0});
  statementObjects.put(TriggerProperty.FIRST_LEG, new Number[] {routeProgress.legIndex(), 0});
  statementObjects.put(TriggerProperty.LAST_LEG, new Number[] {routeProgress.legIndex(),
    (routeProgress.directionsRoute().legs().size() - 1)});
  return statementObjects;
}
 
Example #16
Source File: AdapterHolder.java    From KJFrameForAndroid with Apache License 2.0 5 votes vote down vote up
private AdapterHolder(ViewGroup parent, int layoutId, int position) {
    this.mPosition = position;
    this.mViews = new SparseArray<View>();
    mConvertView = LayoutInflater.from(parent.getContext()).inflate(
            layoutId, parent, false);
    // setTag
    mConvertView.setTag(this);
}
 
Example #17
Source File: DefaultTrackSelector.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private static boolean areSelectionOverridesEqual(
    SparseArray<Map<TrackGroupArray, SelectionOverride>> first,
    SparseArray<Map<TrackGroupArray, SelectionOverride>> second) {
  int firstSize = first.size();
  if (second.size() != firstSize) {
    return false;
  }
  for (int indexInFirst = 0; indexInFirst < firstSize; indexInFirst++) {
    int indexInSecond = second.indexOfKey(first.keyAt(indexInFirst));
    if (indexInSecond < 0
        || !areSelectionOverridesEqual(
            first.valueAt(indexInFirst), second.valueAt(indexInSecond))) {
      return false;
    }
  }
  return true;
}
 
Example #18
Source File: UserRestrictionsUtils.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * Merges a sparse array of restrictions bundles into one.
 */
@Nullable
public static Bundle mergeAll(SparseArray<Bundle> restrictions) {
    if (restrictions.size() == 0) {
        return null;
    } else {
        final Bundle result = new Bundle();
        for (int i = 0; i < restrictions.size(); i++) {
            merge(result, restrictions.valueAt(i));
        }
        return result;
    }
}
 
Example #19
Source File: Trigger.java    From graphhopper-navigation-android with MIT License 5 votes vote down vote up
@Override
public boolean isOccurring(SparseArray<Number[]> statementObjects) {
  for (Statement statement : statements) {
    if (statement.isOccurring(statementObjects)) {
      return true;
    }
  }
  return false;
}
 
Example #20
Source File: ListWidgetProvider.java    From OmniList with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected RemoteViews getRemoteViews(Context context,
                                     int widgetId,
                                     boolean isSmall,
                                     boolean isSingleLine,
                                     SparseArray<PendingIntent> map) {
    if (isSmall) {
        return configSmall(context, map);
    } else if (isSingleLine) {
        return configSingleLine(context, map);
    } else {
        return configList(context, widgetId, map);
    }
}
 
Example #21
Source File: WeekCalendarView.java    From OmniList with GNU Affero General Public License v3.0 5 votes vote down vote up
public void setOnLoadWeekTaskListener(OnLoadWeekTaskListener onLoadWeekTaskListener) {
    this.onLoadWeekTaskListener = onLoadWeekTaskListener;
    int length = mWeekAdapter.getCount();
    SparseArray<WeekView> views = mWeekAdapter.getViews();
    for (int i=0;i<length;i++) {
        views.valueAt(i).setOnLoadWeekTaskListener(onLoadWeekTaskListener);
    }
}
 
Example #22
Source File: RequestThrottler.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/** @return the {@link Throttler} for a given UID. */
@SuppressFBWarnings("LI_LAZY_INIT_STATIC")
public static RequestThrottler getForUid(Context context, int uid) {
    if (sUidToThrottler == null) {
        sUidToThrottler = new SparseArray<>();
        purgeOldEntries(context);
    }
    RequestThrottler throttler = sUidToThrottler.get(uid);
    if (throttler == null) {
        throttler = new RequestThrottler(context, uid);
        sUidToThrottler.put(uid, throttler);
    }
    return throttler;
}
 
Example #23
Source File: NetdEventListenerService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
static NetworkMetricsSnapshot collect(long timeMs, SparseArray<NetworkMetrics> networkMetrics) {
    NetworkMetricsSnapshot snapshot = new NetworkMetricsSnapshot();
    snapshot.timeMs = timeMs;
    for (int i = 0; i < networkMetrics.size(); i++) {
        NetworkMetrics.Summary s = networkMetrics.valueAt(i).getPendingStats();
        if (s != null) {
            snapshot.stats.add(s);
        }
    }
    return snapshot;
}
 
Example #24
Source File: CachedContentIndex.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns an id which isn't used in the given array. If the maximum id in the array is smaller
 * than {@link java.lang.Integer#MAX_VALUE} it just returns the next bigger integer. Otherwise it
 * returns the smallest unused non-negative integer.
 */
//@VisibleForTesting
public static int getNewId(SparseArray<String> idToKey) {
  int size = idToKey.size();
  int id = size == 0 ? 0 : (idToKey.keyAt(size - 1) + 1);
  if (id < 0) { // In case if we pass max int value.
    // TODO optimization: defragmentation or binary search?
    for (id = 0; id < size; id++) {
      if (id != idToKey.keyAt(id)) {
        break;
      }
    }
  }
  return id;
}
 
Example #25
Source File: TsExtractor.java    From Exoplayer_VLC with Apache License 2.0 5 votes vote down vote up
public TsExtractor(boolean shouldSpliceIn, long firstSampleTimestamp, BufferPool bufferPool) {
  super(shouldSpliceIn);
  this.firstSampleTimestamp = firstSampleTimestamp;
  this.bufferPool = bufferPool;
  tsScratch = new ParsableBitArray(new byte[3]);
  tsPacketBuffer = new ParsableByteArray(TS_PACKET_SIZE);
  sampleQueues = new SparseArray<SampleQueue>();
  tsPayloadReaders = new SparseArray<TsPayloadReader>();
  tsPayloadReaders.put(TS_PAT_PID, new PatReader());
  lastPts = Long.MIN_VALUE;
}
 
Example #26
Source File: CrazyAdapter.java    From MultiTypeRecyclerViewAdapter with Apache License 2.0 5 votes vote down vote up
public CrazyAdapter(@NonNull RecyclerViewAdapterHelper<T> helper, @NonNull SparseArray<Class<? extends CrazyViewHolder>> manager) {
    mHelper = helper;
    mHelper.bindAdapter(this);
    mData = mHelper.getData();
    mResourceManager = manager;
    init();
}
 
Example #27
Source File: DownloadActivity.java    From YouTube-In-Background with MIT License 5 votes vote down vote up
private void getYoutubeDownloadUrl(String youtubeLink)
{
    new YouTubeExtractor(this)
    {
        @Override
        public void onExtractionComplete(SparseArray<YtFile> ytFiles, VideoMeta vMeta)
        {
            mainProgressBar.setVisibility(View.GONE);
            if (ytFiles == null) {
                TextView tv = new TextView(getActivityContext());
                tv.setText(R.string.app_update);
                tv.setMovementMethod(LinkMovementMethod.getInstance());
                mainLayout.addView(tv);
                return;
            }
            formatsToShowList = new ArrayList<>();
            for (int i = 0, itag; i < ytFiles.size(); i++) {
                itag = ytFiles.keyAt(i);
                YtFile ytFile = ytFiles.get(itag);

                if (ytFile.getFormat().getHeight() == -1 || ytFile.getFormat().getHeight() >= 360) {
                    addFormatToList(ytFile, ytFiles);
                }
            }
            Collections.sort(formatsToShowList, new Comparator<YouTubeFragmentedVideo>()
            {
                @Override
                public int compare(YouTubeFragmentedVideo lhs, YouTubeFragmentedVideo rhs)
                {
                    return lhs.height - rhs.height;
                }
            });
            for (YouTubeFragmentedVideo files : formatsToShowList) {
                addButtonToMainLayout(vMeta.getTitle(), files);
            }
        }
    }.extract(youtubeLink, true, false);
}
 
Example #28
Source File: Manager.java    From BlueSTSDK_Android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * register a new device id or add feature to an already defined device
 * <p>the change will affect only the node discover after this call</p>
 * @param deviceId device type that will use the feature, it can be a new device id
 * @param features array of feature that we will add, the index of the feature will be used
 *                 as feature mask. the feature mask must have only one bit to 1
 * @throws InvalidFeatureBitMaskException throw when a feature is a position that is not a
 * power of 2
 */
public static void addFeatureToNode(byte deviceId,SparseArray<Class<? extends Feature>> features)
        throws InvalidFeatureBitMaskException {
    SparseArray<Class<? extends Feature>> updateMe;
    if(!sFeatureMapDecoder.containsKey(deviceId)){
        updateMe = BLENodeDefines.FeatureCharacteristics.DEFAULT_MASK_TO_FEATURE.clone();
        sFeatureMapDecoder.put(deviceId,updateMe);
    }else{
        updateMe = sFeatureMapDecoder.get(deviceId);
    }//if-else

    SparseArray<Class<? extends Feature>> addMe = features.clone();

    long mask=1;
    //we test all the 32bit of the feature mask
    for(int i=0; i<32; i++ ){
        Class<? extends Feature> featureClass = addMe.get((int)mask);
        if (featureClass != null) {
            updateMe.append((int) mask, featureClass);
            addMe.remove((int)mask);
        }
        mask=mask<<1;
    }//for

    if(addMe.size()!=0)
        throw new InvalidFeatureBitMaskException("Not all elements have a single bit in " +
                "as key");
}
 
Example #29
Source File: DataBindParser.java    From android-databinding with Apache License 2.0 5 votes vote down vote up
/**
 * apply the data by target view, often used for adapter
 * @param info  may be {@link com.heaven7.databinding.core.DataBindParser.ImagePropertyBindInfo}
 */
private static void applyDataReally(View v, int layoutId,PropertyBindInfo info, ViewHelper vp,
                                    IDataResolver dr,SparseArray<ListenerImplContext> mListenerMap,
                                    EventParseCaretaker caretaker) {
    if(info instanceof ImagePropertyBindInfo){
        checkAndGetImageApplier().apply((ImageView) v, dr, (ImagePropertyBindInfo) info);
        //applyImageProperty(v, dr, (ImagePropertyBindInfo) info);
    }else {
        final int id = v.hashCode();
        caretaker.beginParse(id, layoutId, info.propertyName, mListenerMap);
        final Object val = info.realExpr.evaluate(dr);
        caretaker.endParse();
        apply(null, v, id, layoutId, info.propertyName, val, mListenerMap);
    }
}
 
Example #30
Source File: MapStore.java    From intra42 with Apache License 2.0 5 votes vote down vote up
public Location get(int x, int y) {
    if (x < 0 || y < 0)
        return null;
    SparseArray<Location> col = super.get(x);
    if (col == null)
        return null;
    return col.get(y);
}