當前位置: 首頁>>代碼示例>>Java>>正文


Java LongSparseArray類代碼示例

本文整理匯總了Java中android.support.v4.util.LongSparseArray的典型用法代碼示例。如果您正苦於以下問題:Java LongSparseArray類的具體用法?Java LongSparseArray怎麽用?Java LongSparseArray使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


LongSparseArray類屬於android.support.v4.util包,在下文中一共展示了LongSparseArray類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: sameNameFilterExists

import android.support.v4.util.LongSparseArray; //導入依賴的package包/類
/**
 * Checks if filter with the same name (ignoring case) already exists.
 */
private boolean sameNameFilterExists(String name) {
    LongSparseArray<Filter> filters = FiltersClient.INSTANCE.getByNameIgnoreCase(getContext(), name);

    if (isEditingExistingFilter()) {
        long id = getArguments().getLong(ARG_ID);

        for (int i = 0; i < filters.size(); i++) {
            long filterId = filters.keyAt(i);
            Filter filter = filters.get(filterId);

            // Ignore currently edited filter
            if (name.equalsIgnoreCase(filter.getName()) && id != filterId) {
                return true;
            }
        }

        return false;

    } else { // New filter
        return filters.size() > 0;
    }
}
 
開發者ID:orgzly,項目名稱:orgzly-android,代碼行數:26,代碼來源:FilterFragment.java

示例2: addContacts

import android.support.v4.util.LongSparseArray; //導入依賴的package包/類
@Override
protected void addContacts(List<Contact> contacts, LongSparseArray<ContactNumber> singleContactNumbers) {
    // prepare returning arguments - data of the chosen contacts
    ArrayList<String> names = new ArrayList<>();
    ArrayList<String> numbers = new ArrayList<>();
    ArrayList<Integer> types = new ArrayList<>();
    for (Contact contact : contacts) {
        ContactNumber contactNumber = singleContactNumbers.get(contact.id);
        if (contactNumber != null) {
            // add single number of the contact
            names.add(contact.name);
            numbers.add(contactNumber.number);
            types.add(contactNumber.type);
        } else {
            // all numbers of the contact
            for (ContactNumber _contactNumber : contact.numbers) {
                names.add(contact.name);
                numbers.add(_contactNumber.number);
                types.add(_contactNumber.type);
            }
        }
    }

    // return arguments
    Intent intent = new Intent();
    intent.putStringArrayListExtra(CONTACT_NAMES, names);
    intent.putStringArrayListExtra(CONTACT_NUMBERS, numbers);
    intent.putIntegerArrayListExtra(CONTACT_NUMBER_TYPES, types);
    getActivity().setResult(Activity.RESULT_OK, intent);
    getActivity().finish();
}
 
開發者ID:kaliturin,項目名稱:BlackList,代碼行數:32,代碼來源:GetContactsFragment.java

示例3: getClusters

import android.support.v4.util.LongSparseArray; //導入依賴的package包/類
@Override
public Set<? extends Cluster<T>> getClusters(double zoom) {
  long numCells = (long) Math.ceil(256 * Math.pow(2, zoom) / GRID_SIZE);
  SphericalMercatorProjection proj = new SphericalMercatorProjection(numCells);

  HashSet<Cluster<T>> clusters = new HashSet<>();
  LongSparseArray<StaticCluster<T>> sparseArray = new LongSparseArray<StaticCluster<T>>();

  synchronized (mItems) {
    for (T item : mItems) {
      Point p = proj.toPoint(item.getPosition());

      long coord = getCoord(numCells, p.x, p.y);

      StaticCluster<T> cluster = sparseArray.get(coord);
      if (cluster == null) {
        cluster = new StaticCluster<T>(proj.toLatLng(new Point(Math.floor(p.x) + .5, Math.floor(p.y) + .5)));
        sparseArray.put(coord, cluster);
        clusters.add(cluster);
      }
      cluster.add(item);
    }
  }

  return clusters;
}
 
開發者ID:mapbox,項目名稱:mapbox-plugins-android,代碼行數:27,代碼來源:GridBasedAlgorithm.java

示例4: onCreate

import android.support.v4.util.LongSparseArray; //導入依賴的package包/類
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Bundle bundle = this.getArguments();
    if (bundle != null) {
        selecting = bundle.getBoolean("select", false);
        selectedLabelId = bundle.getLong("selected_label_id", -1L);
    } else {
        selecting = false;
    }
    if(savedInstanceState != null) {
        selectedLabelId = savedInstanceState.getLong("selected_label_id", -1L);
        selectedIds = savedInstanceState.getParcelable("myLongSparseBooleanArray");
    }

    if (selectedIds == null){
        selectedIds = new LongSparseArray<>();
    }

    setHasOptionsMenu(true);
}
 
開發者ID:danlls,項目名稱:Todule-android,代碼行數:23,代碼來源:ToduleLabelFragment.java

示例5: parsePrecomps

import android.support.v4.util.LongSparseArray; //導入依賴的package包/類
private static void parsePrecomps(
    @Nullable JSONArray assetsJson, LottieComposition composition) {
  if (assetsJson == null) {
    return;
  }
  int length = assetsJson.length();
  for (int i = 0; i < length; i++) {
    JSONObject assetJson = assetsJson.optJSONObject(i);
    JSONArray layersJson = assetJson.optJSONArray("layers");
    if (layersJson == null) {
      continue;
    }
    List<Layer> layers = new ArrayList<>(layersJson.length());
    LongSparseArray<Layer> layerMap = new LongSparseArray<>();
    for (int j = 0; j < layersJson.length(); j++) {
      Layer layer = Layer.Factory.newInstance(layersJson.optJSONObject(j), composition);
      layerMap.put(layer.getId(), layer);
      layers.add(layer);
    }
    String id = assetJson.optString("id");
    composition.precomps.put(id, layers);
  }
}
 
開發者ID:alibaba,項目名稱:atlas,代碼行數:24,代碼來源:LottieComposition.java

示例6: setChoiceMode

import android.support.v4.util.LongSparseArray; //導入依賴的package包/類
@TargetApi(11)
public void setChoiceMode(int choiceMode) {
    this.mChoiceMode = choiceMode;
    if (VERSION.SDK_INT >= 11 && this.mChoiceActionMode != null) {
        if (VERSION.SDK_INT >= 11) {
            ((ActionMode) this.mChoiceActionMode).finish();
        }
        this.mChoiceActionMode = null;
    }
    if (this.mChoiceMode != 0) {
        if (this.mCheckStates == null) {
            this.mCheckStates = new SparseArrayCompat();
        }
        if (this.mCheckedIdStates == null && this.mAdapter != null && this.mAdapter.hasStableIds()) {
            this.mCheckedIdStates = new LongSparseArray();
        }
        if (VERSION.SDK_INT >= 11 && this.mChoiceMode == 3) {
            clearChoices();
            setLongClickable(true);
        }
    }
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:23,代碼來源:AbsHListView.java

示例7: getCachedDelegateDrawable

import android.support.v4.util.LongSparseArray; //導入依賴的package包/類
private Drawable getCachedDelegateDrawable(@NonNull Context context, long key) {
    Drawable drawable = null;
    synchronized (this.mDelegateDrawableCacheLock) {
        LongSparseArray<WeakReference<ConstantState>> cache = (LongSparseArray) this.mDelegateDrawableCaches.get(context);
        if (cache == null) {
        } else {
            WeakReference<ConstantState> wr = (WeakReference) cache.get(key);
            if (wr != null) {
                ConstantState entry = (ConstantState) wr.get();
                if (entry != null) {
                    drawable = entry.newDrawable(context.getResources());
                } else {
                    cache.delete(key);
                }
            }
        }
    }
    return drawable;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:20,代碼來源:AppCompatDrawableManager.java

示例8: getCachedDrawable

import android.support.v4.util.LongSparseArray; //導入依賴的package包/類
private Drawable getCachedDrawable(@NonNull final Context context, final long key) {
    synchronized (mDrawableCacheLock) {
        final LongSparseArray<WeakReference<ConstantState>> cache
                = mDrawableCaches.get(context);
        if (cache == null) {
            return null;
        }

        final WeakReference<ConstantState> wr = cache.get(key);
        if (wr != null) {
            // We have the key, and the secret
            ConstantState entry = wr.get();
            if (entry != null) {
                return entry.newDrawable(context.getResources());
            } else {
                // Our entry has been purged
                cache.delete(key);
            }
        }
    }
    return null;
}
 
開發者ID:ximsfei,項目名稱:Android-skin-support,代碼行數:23,代碼來源:SkinCompatDrawableManager.java

示例9: addDrawableToCache

import android.support.v4.util.LongSparseArray; //導入依賴的package包/類
private boolean addDrawableToCache(@NonNull final Context context, final long key,
                                   @NonNull final Drawable drawable) {
    final ConstantState cs = drawable.getConstantState();
    if (cs != null) {
        synchronized (mDrawableCacheLock) {
            LongSparseArray<WeakReference<ConstantState>> cache = mDrawableCaches.get(context);
            if (cache == null) {
                cache = new LongSparseArray<>();
                mDrawableCaches.put(context, cache);
            }
            cache.put(key, new WeakReference<ConstantState>(cs));
        }
        return true;
    }
    return false;
}
 
開發者ID:ximsfei,項目名稱:Android-skin-support,代碼行數:17,代碼來源:SkinCompatDrawableManager.java

示例10: BasicDownloader

import android.support.v4.util.LongSparseArray; //導入依賴的package包/類
/**
 * Create a new instance.
 * 
 * @param aContext
 *            the context to use for accessing the content provider etc
 * @param aPolicyProvider
 *            the download policy provider to use
 * @param aStatusUpdater
 *            the download status updater to use
 */
public BasicDownloader(final Context aContext,
    final DownloadPolicyProvider aPolicyProvider,
    final DownloadStatusUpdater aStatusUpdater) {
    Log.d(LOG_TAG, "BasicDownloader()");

    downloader = Executors.newFixedThreadPool(MAX_DOWNLOAD_THREADS,
        new MinPriorityThreadFactory(this.getClass()
            .getSimpleName()));

    context = aContext;
    statusUpdater = aStatusUpdater;
    policyProvider = aPolicyProvider;

    runningDownloads = new LongSparseArray<>();
    wifiLocks = new LongSparseArray<>();
    final WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    int wifiMode = WifiManager.WIFI_MODE_FULL;
    if (android.os.Build.VERSION.SDK_INT >= ANDROID_SDK_VERSION_12) {
        wifiMode = WifiManager.WIFI_MODE_FULL_HIGH_PERF;
    }
    wifiLock = wifiManager.createWifiLock(wifiMode, this.getClass().getSimpleName());

    startReadingQueueFromContentProvider();
}
 
開發者ID:jtran064,項目名稱:PlatePicks-Android,代碼行數:35,代碼來源:BasicDownloader.java

示例11: showStoreLatestApps

import android.support.v4.util.LongSparseArray; //導入依賴的package包/類
private void showStoreLatestApps(StoreLatestApps card, int position) {
  Map<View, Long> apps = new HashMap<>();
  LongSparseArray<String> appsPackages = new LongSparseArray<>();

  appsContainer.removeAllViews();
  View latestAppView;
  ImageView latestAppIcon;
  TextView latestAppName;
  for (App latestApp : card.getApps()) {
    latestAppView = inflater.inflate(R.layout.social_timeline_latest_app, appsContainer, false);
    latestAppIcon = (ImageView) latestAppView.findViewById(R.id.social_timeline_latest_app_icon);
    latestAppName = (TextView) latestAppView.findViewById(R.id.social_timeline_latest_app_name);
    ImageLoader.with(itemView.getContext())
        .load(latestApp.getIcon(), latestAppIcon);
    latestAppName.setText(latestApp.getName());
    appsContainer.addView(latestAppView);
    apps.put(latestAppView, latestApp.getId());
    appsPackages.put(latestApp.getId(), latestApp.getPackageName());
  }

  setStoreLatestAppsListeners(card, apps, appsPackages, position);
}
 
開發者ID:Aptoide,項目名稱:aptoide-client-v8,代碼行數:23,代碼來源:StoreLatestAppsViewHolder.java

示例12: showStoreLatestApps

import android.support.v4.util.LongSparseArray; //導入依賴的package包/類
private void showStoreLatestApps(SocialStore card, int position) {
  Map<View, Long> apps = new HashMap<>();
  LongSparseArray<String> appsPackages = new LongSparseArray<>();

  appsContainer.removeAllViews();
  View latestAppView;
  ImageView latestAppIcon;
  TextView latestAppName;
  for (App latestApp : card.getApps()) {
    latestAppView = inflater.inflate(R.layout.social_timeline_latest_app, appsContainer, false);
    latestAppIcon = (ImageView) latestAppView.findViewById(R.id.social_timeline_latest_app_icon);
    latestAppName = (TextView) latestAppView.findViewById(R.id.social_timeline_latest_app_name);
    ImageLoader.with(itemView.getContext())
        .load(latestApp.getIcon(), latestAppIcon);
    latestAppName.setText(latestApp.getName());
    appsContainer.addView(latestAppView);
    apps.put(latestAppView, latestApp.getId());
    appsPackages.put(latestApp.getId(), latestApp.getPackageName());
  }

  setStoreLatestAppsListeners(card, apps, appsPackages, position);
}
 
開發者ID:Aptoide,項目名稱:aptoide-client-v8,代碼行數:23,代碼來源:SocialStoreViewHolder.java

示例13: showStoreLatestApps

import android.support.v4.util.LongSparseArray; //導入依賴的package包/類
private void showStoreLatestApps(AggregatedStore card) {
  Map<View, Long> apps = new HashMap<>();
  LongSparseArray<String> appsPackages = new LongSparseArray<>();

  appsContainer.removeAllViews();
  View latestAppView;
  ImageView latestAppIcon;
  TextView latestAppName;
  for (App latestApp : card.getApps()) {
    latestAppView = inflater.inflate(R.layout.social_timeline_latest_app, appsContainer, false);
    latestAppIcon = (ImageView) latestAppView.findViewById(R.id.social_timeline_latest_app_icon);
    latestAppName = (TextView) latestAppView.findViewById(R.id.social_timeline_latest_app_name);
    ImageLoader.with(itemView.getContext())
        .load(latestApp.getIcon(), latestAppIcon);
    latestAppName.setText(latestApp.getName());
    appsContainer.addView(latestAppView);
    apps.put(latestAppView, latestApp.getId());
    appsPackages.put(latestApp.getId(), latestApp.getPackageName());
  }
  setStoreLatestAppsListeners(card, apps, appsPackages);
}
 
開發者ID:Aptoide,項目名稱:aptoide-client-v8,代碼行數:22,代碼來源:AggregatedStoreViewHolder.java

示例14: getExistingReminders

import android.support.v4.util.LongSparseArray; //導入依賴的package包/類
/**
 * Returns map of <reminder_id, reminder_object>
 *
 * @param eventId
 * @return
 */
private LongSparseArray<DbCalendarReminderSensor> getExistingReminders(long eventId) {

    long deviceId = PreferenceProvider.getInstance(context).getCurrentDeviceId();

    List<DbCalendarReminderSensor> list = daoProvider
            .getCalendarReminderSensorDao()
            .getAllByEventId(eventId, deviceId);

    LongSparseArray<DbCalendarReminderSensor> map = new LongSparseArray<>(list.size());

    for (DbCalendarReminderSensor reminder : list) {
        map.put(reminder.getReminderId(), reminder);
    }

    return map;
}
 
開發者ID:Telecooperation,項目名稱:assistance-platform-client-sdk-android,代碼行數:23,代碼來源:CalendarSensor.java

示例15: parseLayers

import android.support.v4.util.LongSparseArray; //導入依賴的package包/類
private static void parseLayers(JsonReader reader, LottieComposition composition,
    List<Layer> layers, LongSparseArray<Layer> layerMap) throws IOException {
  int imageCount = 0;
  reader.beginArray();
  while (reader.hasNext()) {
    Layer layer = LayerParser.parse(reader, composition);
    if (layer.getLayerType() == Layer.LayerType.Image) {
      imageCount++;
    }
    layers.add(layer);
    layerMap.put(layer.getId(), layer);

    if (imageCount > 4) {
      L.warn("You have " + imageCount + " images. Lottie should primarily be " +
          "used with shapes. If you are using Adobe Illustrator, convert the Illustrator layers" +
          " to shape layers.");
    }
  }
  reader.endArray();
}
 
開發者ID:airbnb,項目名稱:lottie-android,代碼行數:21,代碼來源:LottieCompositionParser.java


注:本文中的android.support.v4.util.LongSparseArray類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。