android.support.v4.util.SimpleArrayMap Java Examples

The following examples show how to use android.support.v4.util.SimpleArrayMap. 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: FreeFlowContainer.java    From FreeFlow with Apache License 2.0 6 votes vote down vote up
/**
 * 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);
		}
	}
}
 
Example #2
Source File: FragmentHostCallback.java    From letv with Apache License 2.0 6 votes vote down vote up
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;
    }
}
 
Example #3
Source File: FragmentHostCallback.java    From letv with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #4
Source File: GooglePlayReceiver.java    From firebase-jobdispatcher-android with Apache License 2.0 6 votes vote down vote up
/**
 * 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 */);
}
 
Example #5
Source File: FragmentActivity.java    From letv with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #6
Source File: GooglePlayReceiver.java    From firebase-jobdispatcher-android with Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example #7
Source File: FreeFlowContainer.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
/**
 * 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);
		}
	}
}
 
Example #8
Source File: FreeFlowContainer.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
/**
 * 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);
		}
	}
}
 
Example #9
Source File: VideoGridFragment.java    From VCL-Android with Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example #10
Source File: HomeFragment.java    From gcm with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #11
Source File: LayoutInflaterCompat.java    From Neptune with Apache License 2.0 5 votes vote down vote up
/**
 * 处理android support库Fragment的缓存
 */
private void resetSupportFragmentClassMap(Context context, String fname) {
    SimpleArrayMap<String, Class<?>> classMap = getSupportFragmentClassMap();
    if (classMap != null) {
        Class<?> clazz = classMap.get(fname);
        if (clazz != null && !verifyClassLoader(context, clazz)) {
            PluginDebugLog.runtimeFormatLog(TAG, "find same support fragment class name in LayoutInflater cache and remove it %s", fname);
            clazz = null;
            classMap.remove(fname);
        }
    }
}
 
Example #12
Source File: GetTokenQuickTest.java    From gcm with Apache License 2.0 5 votes vote down vote up
@Override
public void execute(Logger logger, Context context, SimpleArrayMap<Integer, String> params) {
    final String senderId = params.get(R.id.home_sender_id);

    InstanceIdHelper instanceIdHelper = new InstanceIdHelper(context);
    instanceIdHelper.getTokenInBackground(senderId, "GCM", null);
}
 
Example #13
Source File: MusicFragment.java    From VCL-Android with Apache License 2.0 5 votes vote down vote up
@Override
protected void onPreExecute() {
    setTitle(getString(R.string.app_name_full));
    mAdapter.clear();
    mMediaItemMap = new SimpleArrayMap<String, ListItem>();
    mMediaItemList = new ArrayList<ListItem>();
    ((BrowserActivityInterface)getActivity()).showProgress(true);
}
 
Example #14
Source File: FragmentActivity.java    From adt-leanback-support with Apache License 2.0 5 votes vote down vote up
LoaderManagerImpl getLoaderManager(String who, boolean started, boolean create) {
    if (mAllLoaderManagers == null) {
        mAllLoaderManagers = new SimpleArrayMap<String, LoaderManagerImpl>();
    }
    LoaderManagerImpl lm = mAllLoaderManagers.get(who);
    if (lm == null) {
        if (create) {
            lm = new LoaderManagerImpl(who, this, started);
            mAllLoaderManagers.put(who, lm);
        }
    } else {
        lm.updateActivity(this);
    }
    return lm;
}
 
Example #15
Source File: FragmentActivity.java    From android-recipes-app with Apache License 2.0 5 votes vote down vote up
LoaderManagerImpl getLoaderManager(String who, boolean started, boolean create) {
    if (mAllLoaderManagers == null) {
        mAllLoaderManagers = new SimpleArrayMap<String, LoaderManagerImpl>();
    }
    LoaderManagerImpl lm = mAllLoaderManagers.get(who);
    if (lm == null) {
        if (create) {
            lm = new LoaderManagerImpl(who, this, started);
            mAllLoaderManagers.put(who, lm);
        }
    } else {
        lm.updateActivity(this);
    }
    return lm;
}
 
Example #16
Source File: FragmentActivity.java    From V.FlyoutTest with MIT License 5 votes vote down vote up
LoaderManagerImpl getLoaderManager(String who, boolean started, boolean create) {
    if (mAllLoaderManagers == null) {
        mAllLoaderManagers = new SimpleArrayMap<String, LoaderManagerImpl>();
    }
    LoaderManagerImpl lm = mAllLoaderManagers.get(who);
    if (lm == null) {
        if (create) {
            lm = new LoaderManagerImpl(who, this, started);
            mAllLoaderManagers.put(who, lm);
        }
    } else {
        lm.updateActivity(this);
    }
    return lm;
}
 
Example #17
Source File: FragmentActivity.java    From guideshow with MIT License 5 votes vote down vote up
LoaderManagerImpl getLoaderManager(String who, boolean started, boolean create) {
    if (mAllLoaderManagers == null) {
        mAllLoaderManagers = new SimpleArrayMap<String, LoaderManagerImpl>();
    }
    LoaderManagerImpl lm = mAllLoaderManagers.get(who);
    if (lm == null) {
        if (create) {
            lm = new LoaderManagerImpl(who, this, started);
            mAllLoaderManagers.put(who, lm);
        }
    } else {
        lm.updateActivity(this);
    }
    return lm;
}
 
Example #18
Source File: RetrieveService.java    From wear-notify-for-reddit with Apache License 2.0 5 votes vote down vote up
private void sendPostsToWearable(@NonNull List<Post> posts, @NonNull final String msg,
                                 @Nullable SimpleArrayMap<String, Asset> assets) {
    if (mGoogleApiClient.isConnected()) {
        // convert to json for sending to watch and to save to shared prefs
        // don't need to preserve the order like having separate String lists, can more easily add/remove fields
        PutDataMapRequest mapRequest = PutDataMapRequest.create(Constants.PATH_REDDIT_POSTS);
        DataMap dataMap = mapRequest.getDataMap();

        if (assets != null && !assets.isEmpty()) {
            for (int i = 0; i < assets.size(); i++) {
                dataMap.putAsset(assets.keyAt(i), assets.valueAt(i));
            }
        }

        dataMap.putLong("timestamp", System.currentTimeMillis());
        dataMap.putString(Constants.KEY_REDDIT_POSTS, mGson.toJson(posts));
        dataMap.putBoolean(Constants.KEY_DISMISS_AFTER_ACTION,
                mUserStorage.openOnPhoneDismissesAfterAction());
        dataMap.putIntegerArrayList(Constants.KEY_ACTION_ORDER,
                mWearableActionStorage.getSelectedActionIds());

        PutDataRequest request = mapRequest.asPutDataRequest();
        Wearable.DataApi.putDataItem(mGoogleApiClient, request)
                .setResultCallback(dataItemResult -> {
                    Timber.d(msg + ", final timestamp: " + mUserStorage.getTimestamp() + " result: " + dataItemResult
                            .getStatus());

                    if (dataItemResult.getStatus().isSuccess()) {
                        if (mGoogleApiClient.isConnected()) {
                            mGoogleApiClient.disconnect();
                        }
                    } else {
                        Timber.d("Failed to send posts to wearable " + dataItemResult.getStatus()
                                .getStatusMessage());
                    }
                });
    }
}
 
Example #19
Source File: FreeFlowContainer.java    From FreeFlow with Apache License 2.0 5 votes vote down vote up
@Override
public void setOnItemLongClickListener(OnItemLongClickListener listener) {
	super.setOnItemLongClickListener(listener);
	if (mCheckStates==null) {
		mCheckStates = new SimpleArrayMap<IndexPath, Boolean>(); 
	}
}
 
Example #20
Source File: GooglePlayReceiver.java    From firebase-jobdispatcher-android with Apache License 2.0 5 votes vote down vote up
@Override
public void onJobFinished(@NonNull JobInvocation js, @JobResult int result) {
  try {
    JobCallback callback;
    synchronized (callbacks) {
      SimpleArrayMap<String, JobCallback> map = callbacks.get(js.getService());
      if (map == null) {
        return;
      }
      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 {
    synchronized (callbacks) {
      if (callbacks.isEmpty()) {
        // Safe to call stopSelf, even if we're being bound to
        stopSelf(latestStartId);
      }
    }
  }
}
 
Example #21
Source File: ZoomHoverGridView.java    From CustomViewSets with Apache License 2.0 5 votes vote down vote up
/**
 * 设置跨度列表信息
 *
 * @param map
 */
public void setSpanList(SimpleArrayMap<Integer, ZoomHoverSpan> map) {
    this.mSpanMap.clear();
    this.mSpanMap.putAll(map);
    if (mZoomHoverAdapter != null) {
        //如果adapter不为null重新布局
        changeAdapter();
    }
}
 
Example #22
Source File: ZoomHoverView.java    From CustomViewSets with Apache License 2.0 5 votes vote down vote up
/**
 * 设置需要横跨的下标和跨度
 *
 * @param map key代表下标
 *            value代表跨度
 */
public void setSpan(SimpleArrayMap<Integer, Integer> map) {
    this.mNeedSpanMap.clear();
    this.mNeedSpanMap.putAll(map);
    if (this.mZoomHoverAdapter != null) {
        changeAdapter();
    }
}
 
Example #23
Source File: SparkleAnimationPresenter.java    From SparkleMotion with MIT License 4 votes vote down vote up
public SparkleAnimationPresenter() {
    mAnimations = new SimpleArrayMap<>(3);
    mDecorAnimations = new SimpleArrayMap<>(3);
    mAnimatedViews = new ArrayList<>(3);
}
 
Example #24
Source File: LayoutInflaterCompat.java    From Neptune with Apache License 2.0 4 votes vote down vote up
private static SimpleArrayMap<String, Class<?>> getSupportFragmentClassMap() {
    if (sSupportFragmentClassMap == null) {
        sSupportFragmentClassMap = ReflectionUtils.on(android.support.v4.app.Fragment.class).get("sClassMap");
    }
    return sSupportFragmentClassMap;
}
 
Example #25
Source File: EmptyUtils.java    From timecat with Apache License 2.0 4 votes vote down vote up
/**
 * 判断对象是否为空
 *
 * @param obj 对象
 * @return {@code true}: 为空<br>{@code false}: 不为空
 */
public static boolean isEmpty(final 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 SimpleArrayMap && ((SimpleArrayMap) 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;
        }
    }
    if (obj instanceof LongSparseArray && ((LongSparseArray) obj).size() == 0) {
        return true;
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        if (obj instanceof android.util.LongSparseArray && ((android.util.LongSparseArray) obj).size() == 0) {
            return true;
        }
    }
    return false;
}
 
Example #26
Source File: FragmentHostCallback.java    From letv with Apache License 2.0 4 votes vote down vote up
void restoreLoaderNonConfig(SimpleArrayMap<String, LoaderManager> loaderManagers) {
    this.mAllLoaderManagers = loaderManagers;
}
 
Example #27
Source File: FragmentController.java    From letv with Apache License 2.0 4 votes vote down vote up
public SimpleArrayMap<String, LoaderManager> retainLoaderNonConfig() {
    return this.mHost.retainLoaderNonConfig();
}
 
Example #28
Source File: FragmentController.java    From letv with Apache License 2.0 4 votes vote down vote up
public void restoreLoaderNonConfig(SimpleArrayMap<String, LoaderManager> loaderManagers) {
    this.mHost.restoreLoaderNonConfig(loaderManagers);
}
 
Example #29
Source File: ObjectUtils.java    From AndroidUtilCode with Apache License 2.0 4 votes vote down vote up
/**
 * Return whether object is empty.
 *
 * @param obj The object.
 * @return {@code true}: yes<br>{@code false}: no
 */
public static boolean isEmpty(final Object obj) {
    if (obj == null) {
        return true;
    }
    if (obj.getClass().isArray() && Array.getLength(obj) == 0) {
        return true;
    }
    if (obj instanceof CharSequence && obj.toString().length() == 0) {
        return true;
    }
    if (obj instanceof Collection && ((Collection) obj).isEmpty()) {
        return true;
    }
    if (obj instanceof Map && ((Map) obj).isEmpty()) {
        return true;
    }
    if (obj instanceof SimpleArrayMap && ((SimpleArrayMap) 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;
        }
    }
    if (obj instanceof LongSparseArray && ((LongSparseArray) obj).size() == 0) {
        return true;
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        if (obj instanceof android.util.LongSparseArray
                && ((android.util.LongSparseArray) obj).size() == 0) {
            return true;
        }
    }
    return false;
}
 
Example #30
Source File: ObjectUtils.java    From AndroidUtilCode with Apache License 2.0 4 votes vote down vote up
public static boolean isEmpty(final SimpleArrayMap obj) {
    return obj == null || obj.isEmpty();
}