Tabnine Logo
SparseArray
Code IndexAdd Tabnine to your IDE (free)

How to use
SparseArray
in
com.lody.virtual.helper.collection

Best Java code snippets using com.lody.virtual.helper.collection.SparseArray (Showing top 20 results out of 315)

origin: android-hacker/VirtualXposed

public E put(String name, int uid, E value) {
  SparseArray<E> uids = mMap.get(name);
  if (uids == null) {
    uids = new SparseArray<E>(2);
    mMap.put(name, uids);
  }
  uids.put(uid, value);
  return value;
}
origin: android-hacker/VirtualXposed

@Override
public void readPersistenceData(Parcel p) {
  SparseArray<VDeviceInfo> infos = mService.getDeviceInfos();
  infos.clear();
  int size = p.readInt();
  while (size-- > 0) {
    int userId = p.readInt();
    VDeviceInfo info = new VDeviceInfo(p);
    infos.put(userId, info);
  }
}
origin: android-hacker/VirtualXposed

/**
 * Alias for {@link #delete(int)}.
 */
public void remove(int key) {
  delete(key);
}
origin: android-hacker/VirtualXposed

@Override
public void writePersistenceData(Parcel p) {
  mGlobalConfig.writeToParcel(p, 0);
  p.writeInt(mLocConfigs.size());
  for (int i = 0; i < mLocConfigs.size(); i++) {
    int userId = mLocConfigs.keyAt(i);
    Map<String, VLocConfig> pkgs = mLocConfigs.valueAt(i);
    p.writeInt(userId);
    p.writeMap(pkgs);
  }
}
origin: android-hacker/VirtualXposed

private VLocConfig getOrCreateConfig(int userId, String pkg) {
  Map<String, VLocConfig> pkgs = mLocConfigs.get(userId);
  if (pkgs == null) {
    pkgs = new HashMap<>();
    mLocConfigs.put(userId, pkgs);
  }
  VLocConfig config = pkgs.get(pkg);
  if (config == null) {
    config = new VLocConfig();
    config.mode = MODE_CLOSE;
    pkgs.put(pkg, config);
  }
  return config;
}
origin: android-hacker/VirtualXposed

@Override
public String getAppProcessName(int pid) {
  synchronized (mPidsSelfLocked) {
    ProcessRecord r = mPidsSelfLocked.get(pid);
    if (r != null) {
      return r.processName;
    }
  }
  return null;
}
origin: android-hacker/VirtualXposed

/**
 * Given an index in the range <code>0...size()-1</code>, returns
 * the key from the <code>index</code>th key-value mapping that this
 * SparseArray stores.
 */
public int keyAt(int index) {
  if (mGarbage) {
    gc();
  }
  return mKeys[index];
}
origin: android-hacker/VirtualXposed

public E remove(String name, int uid) {
  SparseArray<E> uids = mMap.get(name);
  if (uids != null) {
    final E old = uids.removeReturnOld(uid);
    if (uids.size() == 0) {
      mMap.remove(name);
    }
    return old;
  }
  return null;
}
origin: android-hacker/VirtualXposed

/**
 * Puts a key/value pair into the array, optimizing for the case where
 * the key is greater than all existing keys in the array.
 */
public void append(int key, E value) {
  if (mSize != 0 && key <= mKeys[mSize - 1]) {
    put(key, value);
    return;
  }
  if (mGarbage && mSize >= mKeys.length) {
    gc();
  }
  int pos = mSize;
  if (pos >= mKeys.length) {
    int n =  ContainerHelpers.idealIntArraySize(pos + 1);
    int[] nkeys = new int[n];
    Object[] nvalues = new Object[n];
    // Log.e("SparseArray", "grow " + mKeys.length + " to " + n);
    System.arraycopy(mKeys, 0, nkeys, 0, mKeys.length);
    System.arraycopy(mValues, 0, nvalues, 0, mValues.length);
    mKeys = nkeys;
    mValues = nvalues;
  }
  mKeys[pos] = key;
  mValues[pos] = value;
  mSize = pos + 1;
}
origin: android-hacker/VirtualXposed

  void stopSession() {
    if (clientJobService != null) {
      try {
        clientJobService.stopJob(jobParams);
      } catch (RemoteException e) {
        e.printStackTrace();
      }
    }
    mJobSessions.remove(jobId);
    unbindService(this);
  }
}
origin: android-hacker/VirtualXposed

@Override
public void updateDeviceInfo(int userId, VDeviceInfo info) throws RemoteException {
  synchronized (mDeviceInfos) {
    if (info != null) {
      mDeviceInfos.put(userId, info);
      mPersistenceLayer.save();
    }
  }
}
origin: android-hacker/VirtualXposed

/**
 * Remove a range of mappings as a batch.
 *
 * @param index Index to begin at
 * @param size Number of mappings to remove
 */
public void removeAtRange(int index, int size) {
  final int end = Math.min(mSize, index + size);
  for (int i = index; i < end; i++) {
    removeAt(i);
  }
}
origin: android-hacker/VirtualXposed

@Override
public void writePersistenceData(Parcel p) {
  SparseArray<VDeviceInfo> infos = mService.getDeviceInfos();
  int size = infos.size();
  p.writeInt(size);
  for (int i = 0; i < size; i++) {
    int userId = infos.keyAt(i);
    VDeviceInfo info = infos.valueAt(i);
    p.writeInt(userId);
    info.writeToParcel(p, 0);
  }
}
origin: android-hacker/VirtualXposed

@Override
public VDeviceInfo getDeviceInfo(int userId) throws RemoteException {
  VDeviceInfo info;
  synchronized (mDeviceInfos) {
    info = mDeviceInfos.get(userId);
    if (info == null) {
      info = generateDeviceInfo();
      mDeviceInfos.put(userId, info);
      mPersistenceLayer.save();
    }
  }
  return info;
}
origin: android-hacker/VirtualXposed

@Override
public String getInitialPackage(int pid) {
  synchronized (mPidsSelfLocked) {
    ProcessRecord r = mPidsSelfLocked.get(pid);
    if (r != null) {
      return r.info.packageName;
    }
    return null;
  }
}
origin: android-hacker/VirtualXposed

/**
 * Returns the number of key-value mappings that this SparseArray
 * currently stores.
 */
public int size() {
  if (mGarbage) {
    gc();
  }
  return mSize;
}
origin: darkskygit/VirtualApp

public E remove(String name, int uid) {
  SparseArray<E> uids = mMap.get(name);
  if (uids != null) {
    final E old = uids.removeReturnOld(uid);
    if (uids.size() == 0) {
      mMap.remove(name);
    }
    return old;
  }
  return null;
}
origin: darkskygit/VirtualApp

/**
 * Puts a key/value pair into the array, optimizing for the case where
 * the key is greater than all existing keys in the array.
 */
public void append(int key, E value) {
  if (mSize != 0 && key <= mKeys[mSize - 1]) {
    put(key, value);
    return;
  }
  if (mGarbage && mSize >= mKeys.length) {
    gc();
  }
  int pos = mSize;
  if (pos >= mKeys.length) {
    int n =  ContainerHelpers.idealIntArraySize(pos + 1);
    int[] nkeys = new int[n];
    Object[] nvalues = new Object[n];
    // Log.e("SparseArray", "grow " + mKeys.length + " to " + n);
    System.arraycopy(mKeys, 0, nkeys, 0, mKeys.length);
    System.arraycopy(mValues, 0, nvalues, 0, mValues.length);
    mKeys = nkeys;
    mValues = nvalues;
  }
  mKeys[pos] = key;
  mValues[pos] = value;
  mSize = pos + 1;
}
origin: android-hacker/VirtualXposed

private void onProcessDead(ProcessRecord record) {
  mProcessNames.remove(record.processName, record.vuid);
  mPidsSelfLocked.remove(record.pid);
  processDead(record);
  record.lock.open();
}
origin: android-hacker/VirtualXposed

synchronized (mProcessNames) {
  mProcessNames.put(app.processName, app.vuid, app);
  mPidsSelfLocked.put(app.pid, app);
com.lody.virtual.helper.collectionSparseArray

Javadoc

A copy of the current platform (currently android.os.Build.VERSION_CODES#KITKATversion of android.util.SparseArray; provides a removeAt() method and other things.

Most used methods

  • <init>
    Creates a new SparseArray containing no mappings that will not require any additional memory allocat
  • clear
    Removes all key-value mappings from this SparseArray.
  • delete
    Removes the mapping from the specified key, if there was any.
  • gc
  • get
    Gets the Object mapped from the specified key, or the specified Object if no such mapping has been m
  • keyAt
    Given an index in the range 0...size()-1, returns the key from the indexth key-value mapping that th
  • put
    Adds a mapping from the specified key to the specified value, replacing the previous mapping from th
  • remove
    Alias for #delete(int).
  • removeAt
    Removes the mapping at the specified index.
  • removeReturnOld
  • size
    Returns the number of key-value mappings that this SparseArray currently stores.
  • valueAt
    Given an index in the range 0...size()-1, returns the value from the indexth key-value mapping that
  • size,
  • valueAt

Popular in Java

  • Making http post requests using okhttp
  • getContentResolver (Context)
  • scheduleAtFixedRate (Timer)
  • setScale (BigDecimal)
  • BufferedImage (java.awt.image)
    The BufferedImage subclass describes an java.awt.Image with an accessible buffer of image data. All
  • DecimalFormat (java.text)
    A concrete subclass of NumberFormat that formats decimal numbers. It has a variety of features desig
  • SimpleDateFormat (java.text)
    Formats and parses dates in a locale-sensitive manner. Formatting turns a Date into a String, and pa
  • ResourceBundle (java.util)
    ResourceBundle is an abstract class which is the superclass of classes which provide Locale-specifi
  • TimeUnit (java.util.concurrent)
    A TimeUnit represents time durations at a given unit of granularity and provides utility methods to
  • Join (org.hibernate.mapping)
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now