/** * Defines the choice behavior for the Container allowing multi-select etc. * * @see <a href= * "http://developer.android.com/reference/android/widget/AbsListView.html#attr_android:choiceMode" * >List View's Choice Mode</a> */ public void setChoiceMode(int choiceMode) { mChoiceMode = choiceMode; if (mChoiceActionMode != null) { mChoiceActionMode.finish(); mChoiceActionMode = null; } if (mChoiceMode != CHOICE_MODE_NONE) { if (mCheckStates == null) { mCheckStates = new SimpleArrayMap<IndexPath, Boolean>(); } if (mChoiceMode == CHOICE_MODE_MULTIPLE_MODAL) { clearChoices(); setLongClickable(true); } } }
/** * @param start offset relative to its parent * @param end offset relative to its parent */ public void setRange(int start, int end) { mRange = Range.create(start, end); if (!mChildren.isEmpty()) { SimpleArrayMap<Range<Integer>, T> newMap = new SimpleArrayMap<>(); for (int i = 0, size = mChildren.size(); i < size; i++) { T rangeStyle = mChildren.valueAt(i); int newStart = rangeStyle.getOriginStartOffset() + start; int newEnd = rangeStyle.getOriginEndOffset() + start; Range<Integer> newRange = Range.create(newStart, newEnd); newMap.put(newRange, rangeStyle); rangeStyle.setRange(newStart, newEnd); } mChildren.clear(); mChildren.putAll(newMap); } }
LoaderManagerImpl getLoaderManager(String who, boolean started, boolean create) { if (this.mAllLoaderManagers == null) { this.mAllLoaderManagers = new SimpleArrayMap(); } LoaderManagerImpl lm = (LoaderManagerImpl) this.mAllLoaderManagers.get(who); if (lm != null) { lm.updateHostController(this); return lm; } else if (!create) { return lm; } else { lm = new LoaderManagerImpl(who, this, started); this.mAllLoaderManagers.put(who, lm); return lm; } }
SimpleArrayMap<String, LoaderManager> retainLoaderNonConfig() { boolean retainLoaders = false; if (this.mAllLoaderManagers != null) { int i; int N = this.mAllLoaderManagers.size(); LoaderManagerImpl[] loaders = new LoaderManagerImpl[N]; for (i = N - 1; i >= 0; i--) { loaders[i] = (LoaderManagerImpl) this.mAllLoaderManagers.valueAt(i); } for (i = 0; i < N; i++) { LoaderManagerImpl lm = loaders[i]; if (lm.mRetaining) { retainLoaders = true; } else { lm.doDestroy(); this.mAllLoaderManagers.remove(lm.mWho); } } } if (retainLoaders) { return this.mAllLoaderManagers; } return null; }
public final Object onRetainNonConfigurationInstance() { if (this.mStopped) { doReallyStop(true); } Object custom = onRetainCustomNonConfigurationInstance(); List<Fragment> fragments = this.mFragments.retainNonConfig(); SimpleArrayMap<String, LoaderManager> loaders = this.mFragments.retainLoaderNonConfig(); if (fragments == null && loaders == null && custom == null) { return null; } Object nci = new NonConfigurationInstances(); nci.custom = custom; nci.fragments = fragments; nci.loaders = loaders; return nci; }
@Nullable JobInvocation prepareJob(JobCallback callback, Bundle bundle) { JobInvocation job = prefixedCoder.decodeIntentBundle(bundle); if (job == null) { Log.e(TAG, "unable to decode job"); sendResultSafely(callback, JobService.RESULT_FAIL_NORETRY); return null; } synchronized (callbacks) { SimpleArrayMap<String, JobCallback> map = callbacks.get(job.getService()); if (map == null) { map = new SimpleArrayMap<>(1); callbacks.put(job.getService(), map); } map.put(job.getTag(), callback); } return job; }
/** * Stops the job if it is running. * * <p>Needed to avoid possibility of sending job result before the reschedule request is received * by Google Play services. */ static void onSchedule(Job job) { // Stop if running synchronized (callbacks) { SimpleArrayMap<String, JobCallback> jobs = callbacks.get(job.getService()); if (jobs == null) { // not running return; } JobCallback jobCallback = jobs.get(job.getTag()); if (jobCallback == null) { // not running return; } JobInvocation key = new JobInvocation.Builder() .setTag(job.getTag()) .setService(job.getService()) .setTrigger(job.getTrigger()) .build(); ExecutionDelegator.stopJob(key, false /* must not send the result */); } }
@Nullable @WorkerThread public static SimpleArrayMap<String, Task> getTasks(Context context) { LogUtils.d(TAG, "Loading tasks"); try { SimpleArrayMap<String, Task> ret; String json = getString(context, KEY_TASKS); if (TextUtils.isEmpty(json)) { ret = new SimpleArrayMap<>(); } else { ret = TasksPersistence.fromJson(json); } LogUtils.d(TAG, "Loaded tasks " + ret); return ret; } catch (JSONException e) { LogUtils.e(TAG, e); return null; } }
public static String toJson(SimpleArrayMap<String, Task> tasks) throws JSONException { JSONObject root = new JSONObject(); JSONObject jsonTasks = new JSONObject(); for (int i = 0; i < tasks.size(); ++i) { String cardId = tasks.keyAt(i); Task task = tasks.valueAt(i); jsonTasks.put(cardId, toJson(task)); } root.put(KEY_TASKS, jsonTasks); String json = root.toString(); LogUtils.d(TAG, "Generated tasks JSON " + json); return json; }
public static SimpleArrayMap<String, Task> fromJson(String json) throws JSONException { LogUtils.d(TAG, "Parsing " + json); JSONObject root = new JSONObject(json); JSONObject jsonTasks = root.getJSONObject(KEY_TASKS); SimpleArrayMap<String, Task> tasks = new SimpleArrayMap<>(); Iterator<String> iterator = jsonTasks.keys(); while (iterator.hasNext()) { String cardId = iterator.next(); JSONObject jsonTask = jsonTasks.getJSONObject(cardId); tasks.put(cardId, fromJson(cardId, jsonTask)); } return tasks; }
private ExtendableSavedState(Parcel in, ClassLoader loader) { super(in, loader); int size = in.readInt(); String[] keys = new String[size]; in.readStringArray(keys); Bundle[] states = new Bundle[size]; in.readTypedArray(states, Bundle.CREATOR); extendableStates = new SimpleArrayMap<>(size); for (int i = 0; i < size; i++) { extendableStates.put(keys[i], states[i]); } }
Method forName(String methodName) { Method handler = immediateHandlers.get(methodName); if (handler != null) { return handler; } SimpleArrayMap<String, Method> wildcardHandlers = this.wildcardHandlers; int size = wildcardHandlers.size(); for (int i = 0; i < size; i++) { String wildcard = wildcardHandlers.keyAt(i); if (methodName.matches(wildcard.replace("*", ".*?"))) { return wildcardHandlers.get(wildcard); } } return fallback; }
final LoaderManagerImpl getLoaderManager(String paramString, boolean paramBoolean1, boolean paramBoolean2) { if (this.mAllLoaderManagers == null) { this.mAllLoaderManagers = new SimpleArrayMap(); } LoaderManagerImpl localLoaderManagerImpl = (LoaderManagerImpl)this.mAllLoaderManagers.get(paramString); if (localLoaderManagerImpl == null) { if (paramBoolean2) { localLoaderManagerImpl = new LoaderManagerImpl(paramString, this, paramBoolean1); this.mAllLoaderManagers.put(paramString, localLoaderManagerImpl); } return localLoaderManagerImpl; } localLoaderManagerImpl.mHost = this; return localLoaderManagerImpl; }
public void onCreate(Bundle paramBundle) { FragmentController localFragmentController1 = this.mFragments; localFragmentController1.mHost.mFragmentManager.attachController(localFragmentController1.mHost, localFragmentController1.mHost, null); super.onCreate(paramBundle); NonConfigurationInstances localNonConfigurationInstances = (NonConfigurationInstances)getLastNonConfigurationInstance(); if (localNonConfigurationInstances != null) { FragmentController localFragmentController3 = this.mFragments; SimpleArrayMap localSimpleArrayMap = localNonConfigurationInstances.loaders; localFragmentController3.mHost.mAllLoaderManagers = localSimpleArrayMap; } if (paramBundle != null) { Parcelable localParcelable = paramBundle.getParcelable("android:support:fragments"); FragmentController localFragmentController2 = this.mFragments; List localList = null; if (localNonConfigurationInstances != null) { localList = localNonConfigurationInstances.fragments; } localFragmentController2.mHost.mFragmentManager.restoreAllState(localParcelable, localList); } this.mFragments.mHost.mFragmentManager.dispatchCreate(); }
@Override protected Void doInBackground(Void... params) { int size; MediaWrapper MediaWrapper; ArrayList<MediaWrapper> mediaList = mMediaLibrary.getVideoItems(); size = mediaList == null ? 0 : mediaList.size(); mMediaIndex = new SimpleArrayMap<String, Integer>(size); for (int i = 0 ; i < size ; ++i){ MediaWrapper = mediaList.get(i); mMediaIndex.put(MediaWrapper.getLocation(), Integer.valueOf(i)); publishProgress(MediaWrapper); } return null; }
public final Object onRetainNonConfigurationInstance() { if (mStopped) { doReallyStop(true); } Object obj = onRetainCustomNonConfigurationInstance(); List list = mFragments.retainNonConfig(); SimpleArrayMap simplearraymap = mFragments.retainLoaderNonConfig(); if (list == null && simplearraymap == null && obj == null) { return null; } else { NonConfigurationInstances nonconfigurationinstances = new NonConfigurationInstances(); nonconfigurationinstances.custom = obj; nonconfigurationinstances.fragments = list; nonconfigurationinstances.loaders = simplearraymap; return nonconfigurationinstances; } }
@Override public void setOnItemLongClickListener(OnItemLongClickListener listener) { super.setOnItemLongClickListener(listener); if (mCheckStates==null) { mCheckStates = new SimpleArrayMap<IndexPath, Boolean>(); } }
public ArrayMap<String, String> getSettings() { ArrayMap<String, String> allSetts= new ArrayMap<>(); allSetts.putAll((SimpleArrayMap<String,String>) settings.get(0).getSpecs()); allSetts.putAll((SimpleArrayMap<String,String>) settings.get(1).getSpecs()); allSetts.putAll((SimpleArrayMap<String,String>) settings.get(2).getSpecs()); return allSetts; }
private void setTag(String key, Object tag) { if (mKeyedTags == null) { mKeyedTags = new SimpleArrayMap<>(); } mKeyedTags.put(key, tag); }
private <T> int getTaskId(SimpleArrayMap<Integer, T> taskList) { for (int i = 0; i < Integer.MAX_VALUE; i++) { if (!taskList.containsKey(i)) { return i; } } throw new IllegalStateException("no more task ids available"); }
public BreventResponse(Collection<String> brevent, Collection<String> priority, SimpleArrayMap<String, SparseIntArray> processes, Collection<String> trustAgents, boolean supportStopped, boolean supportStandby, long daemonTime, long serverTime, boolean granted, Collection<String> androidProcesses, Collection<String> fullPowerList, boolean supportUpgrade, String alipaySum, String vpn, Collection<String> packages, boolean supportAppops, boolean alipaySin, boolean promotion, boolean forceStopped) { super(BreventProtocol.STATUS_RESPONSE); mBrevent = brevent; mPriority = priority; mProcesses = processes; mTrustAgents = trustAgents; mSupportStopped = supportStopped; mSupportStandby = supportStandby; mDaemonTime = daemonTime; mServerTime = serverTime; mGranted = granted; mAndroidProcesses = androidProcesses; mFullPowerList = fullPowerList; mSupportUpgrade = supportUpgrade; mAlipaySum = alipaySum; mVpn = vpn; mPackages = packages; mSupportAppops = supportAppops; mAlipaySin = alipaySin; mPromotion = promotion; mForceStopped = forceStopped; }
@NonNull static SimpleArrayMap<String, SparseIntArray> readSimpleArrayMap(Parcel in) { int size = in.readInt(); if (size <= 0) { return new SimpleArrayMap<>(); } SimpleArrayMap<String, SparseIntArray> map = new SimpleArrayMap<>(size); for (int i = 0; i < size; ++i) { map.put(in.readString(), readSparseIntArray(in)); } return map; }
static void writeSimpleArrayMap(Parcel dest, @Nullable SimpleArrayMap<String, SparseIntArray> map) { if (map == null) { dest.writeInt(-1); } else { int size = map.size(); dest.writeInt(size); for (int i = 0; i < size; ++i) { dest.writeString(map.keyAt(i)); writeSparseIntArray(dest, map.valueAt(i)); } } }
@Override public void onJobFinished(@NonNull JobInvocation js, @JobResult int result) { synchronized (callbacks) { try { SimpleArrayMap<String, JobCallback> map = callbacks.get(js.getService()); if (map == null) { return; } JobCallback callback = map.remove(js.getTag()); if (callback == null) { return; } if (map.isEmpty()) { callbacks.remove(js.getService()); } if (needsToBeRescheduled(js, result)) { reschedule(js); } else { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "sending jobFinished for " + js.getTag() + " = " + result); } sendResultSafely(callback, result); } } finally { if (callbacks.isEmpty()) { // Safe to call stopSelf, even if we're being bound to stopSelf(latestStartId); } } } }
@NonNull public static List<Sound> getAllSounds() { List<Sound> sounds = new ArrayList<>(); SimpleArrayMap<String, List<Sound>> map = getSounds(); for (int i = 0; i < map.size(); i++) { sounds.addAll(getSounds().get(map.valueAt(i))); } return sounds; }
/** * 设置需要横跨的下标和跨度 * * @param map key代表下标 * value代表跨度 */ public void setSpan(SimpleArrayMap<Integer, Integer> map) { this.mNeedSpanMap.clear(); this.mNeedSpanMap.putAll(map); if (this.mZoomHoverAdapter != null) { changeAdapter(); } }
/** * 设置跨度列表信息 * * @param map */ public void setSpanList(SimpleArrayMap<Integer, ZoomHoverSpan> map) { this.mSpanMap.clear(); this.mSpanMap.putAll(map); if (mZoomHoverAdapter != null) { //如果adapter不为null重新布局 changeAdapter(); } }
@Override public void onAggregatedDataAdded(SimpleArrayMap<String, Integer> map) { if (map.containsKey(XD)) { startAnimation(R.drawable.ic_emoji_xd, map.get(XD)); } if (map.containsKey(LIKE)) { startAnimation(R.drawable.ic_emoji_like, map.get(LIKE)); } if (map.containsKey(LOVE)) { startAnimation(R.drawable.ic_emoji_heart, map.get(LOVE)); } }
@CheckResult public static boolean saveTasks(Context context, SimpleArrayMap<String, Task> tasks) { try { return saveString(context, KEY_TASKS, TasksPersistence.toJson(tasks)); } catch (JSONException e) { LogUtils.e(TAG, e); return false; } }
@Override public Boolean loadInBackground() { SimpleArrayMap<String, Task> tasks = Facade.getTasks(getContext()); if (tasks != null) { Task task = tasks.get(mCardId); if (task == null) { tasks.put(mCardId, new Task( mCardId, mIncPomodoros ? 1 : 0, mTime )); } else { int pomodoros = task.getPodomoros(); if (mIncPomodoros) { ++pomodoros; } tasks.put(mCardId, new Task( task.getCardId(), pomodoros, task.getTotalTime() + mTime )); } TomateApp.get().getTaskCache().setTasks(tasks); return Facade.saveTasks(getContext(), tasks); } return Boolean.FALSE; }
@Override public void onLoadFinished(Loader<SimpleArrayMap<String, Task>> loader, SimpleArrayMap<String, Task> tasks) { if (tasks != null) { TomateApp.get().getTaskCache().setTasks(tasks); } mTasksLoaded = true; if (mRemaining < 0L) { goNext(this); } }
private void doExecuteSelectedTest() { QuickTest test = mQuickTests.get(getValue(R.id.home_quick_test)); SimpleArrayMap<Integer, String> params = new SimpleArrayMap<>(); for (Integer paramsId : test.getRequiredParameters()) { params.put(paramsId, getValue(paramsId)); } test.execute(mLogger, getActivity(), params); }