Java Code Examples for java.util.HashMap.Entry

The following are Jave code examples for showing how to use Entry of the java.util.HashMap class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: WebPLP   File: PLPAddressBus.java   View Source Code Vote up 6 votes
/**
 * This method will check if given data present in the given address is an instruction or not
 * @param addr address whose value needs to be verified whether it is an instruction or not
 * @return true if it is an instruction or else false
 */
public synchronized boolean isInstruction(long addr)
{
	boolean bInstr = false;
	
	for(HashMap.Entry<String, IOMemoryModule> entry : modules.entrySet())
	{
		IOMemoryModule mod = entry.getValue();
		if(mod.isAddressWithModule(addr))
		{
			if(mod.isInstruction(addr))
				bInstr = true;
			break;
		}
	}
	
	return bInstr;
}
 
Example 2
Project: chromium-for-android-56-debug-video   File: WebappRegistry.java   View Source Code Vote up 6 votes
/**
 * Deletes the data of all web apps whose url matches |urlFilter|.
 * @param urlFilter The filter object to check URLs.
 */
@VisibleForTesting
void unregisterWebappsForUrlsImpl(UrlFilter urlFilter) {
    Iterator<HashMap.Entry<String, WebappDataStorage>> it = mStorages.entrySet().iterator();
    while (it.hasNext()) {
        HashMap.Entry<String, WebappDataStorage> entry = it.next();
        WebappDataStorage storage = entry.getValue();
        if (urlFilter.matchesUrl(storage.getUrl())) {
            storage.delete();
            it.remove();
        }
    }

    if (mStorages.isEmpty()) {
        mPreferences.edit().clear().apply();
    } else {
        mPreferences.edit().putStringSet(KEY_WEBAPP_SET, mStorages.keySet()).apply();
    }
}
 
Example 3
Project: SWDemo   File: SmallVideoViewLiveAdapter.java   View Source Code Vote up 6 votes
@Override
protected void customizedInit(HashMap<Integer, SurfaceView> uids, boolean force) {
    for (HashMap.Entry<Integer, SurfaceView> entry : uids.entrySet()) {
        if (entry.getKey() != exceptedUid) {
            entry.getValue().setZOrderOnTop(true);
            entry.getValue().setZOrderMediaOverlay(true);
            mUsers.add(new VideoStatusData(entry.getKey(), entry.getValue(), VideoStatusData.DEFAULT_STATUS, VideoStatusData.DEFAULT_VOLUME));
        }
    }

    if (force || mItemWidth == 0 || mItemHeight == 0) {
        WindowManager windowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
        DisplayMetrics outMetrics = new DisplayMetrics();
        windowManager.getDefaultDisplay().getMetrics(outMetrics);
        mItemWidth = outMetrics.widthPixels / 4;
        mItemHeight = outMetrics.heightPixels / 4;
    }
}
 
Example 4
Project: PlusGram   File: ContactsController.java   View Source Code Vote up 6 votes
public HashMap<Integer, Contact> getContactsCopy(HashMap<Integer, Contact> original) {
    HashMap<Integer, Contact> ret = new HashMap<>();
    for (HashMap.Entry<Integer, Contact> entry : original.entrySet()) {
        Contact copyContact = new Contact();
        Contact originalContact = entry.getValue();
        copyContact.phoneDeleted.addAll(originalContact.phoneDeleted);
        copyContact.phones.addAll(originalContact.phones);
        copyContact.phoneTypes.addAll(originalContact.phoneTypes);
        copyContact.shortPhones.addAll(originalContact.shortPhones);
        copyContact.first_name = originalContact.first_name;
        copyContact.last_name = originalContact.last_name;
        copyContact.id = originalContact.id;
        ret.put(copyContact.id, copyContact);
    }
    return ret;
}
 
Example 5
Project: weex-3d-map   File: TestFlow.java   View Source Code Vote up 6 votes
public void testStep(Object testStepkey,  Object testStepValue) {

        HashMap testSteps = (HashMap) testStepValue;
        Iterator iter = testSteps.entrySet().iterator();
        Log.e(TAG,"testSteps keyset==" + testSteps.keySet().toString());

        while (iter.hasNext()) {
            HashMap.Entry entry = (HashMap.Entry) iter.next();
            Object testStepAction = entry.getKey();
            Log.e(TAG,"testSteps testStepAction==" + testStepAction.toString());

            Object testStepActionValue = entry.getValue();
            Log.e(TAG,"testSteps testStepActionValue==" + testStepActionValue.toString());

            testAction(testStepAction, testStepActionValue);
        }

    }
 
Example 6
Project: SWDemo   File: SmallVideoViewLiveAdapter.java   View Source Code Vote up 6 votes
@Override
public void notifyUiChanged(HashMap<Integer, SurfaceView> uids, int uidExcluded, HashMap<Integer, Integer> status, HashMap<Integer, Integer> volume) {
    mUsers.clear();

    for (HashMap.Entry<Integer, SurfaceView> entry : uids.entrySet()) {
        log.debug("notifyUiChanged " + entry.getKey() + " " + uidExcluded);

        if (entry.getKey() != uidExcluded) {
            entry.getValue().setZOrderOnTop(true);
            entry.getValue().setZOrderMediaOverlay(true);
            mUsers.add(new VideoStatusData(entry.getKey(), entry.getValue(), VideoStatusData.DEFAULT_STATUS, VideoStatusData.DEFAULT_VOLUME));
        }
    }

    notifyDataSetChanged();
}
 
Example 7
Project: BigDataFortuneTelling   File: PermissionHelper.java   View Source Code Vote up 5 votes
private ArrayList<String> getNoGrantedPermission(Context activity, boolean isShouldRationale) {

        ArrayList<String> permissions = new ArrayList<>();

        Iterator iterator = PERMISSION_MAP.entrySet().iterator();
        while (iterator.hasNext()) {
            HashMap.Entry<Integer, String> entry = (HashMap.Entry<Integer, String>) iterator.next();
            String requestPermission = entry.getValue();
            int checkSelfPermission = -1;
            try {
                checkSelfPermission = ContextCompat.checkSelfPermission(activity, requestPermission);
            } catch (RuntimeException e) {
                Log.e(TAG, "RuntimeException:" + e.getMessage());
                return null;
            }

            if (checkSelfPermission != PackageManager.PERMISSION_GRANTED) {
                if (shouldShowRequestPermissionRationale(requestPermission)) {
                    if (isShouldRationale) {
                        permissions.add(requestPermission);
                    }
                } else {
                    if (!isShouldRationale) {
                        permissions.add(requestPermission);
                    }
                }
            }
        }
        return permissions;
    }
 
Example 8
Project: PlusGram   File: EmojiView.java   View Source Code Vote up 5 votes
private void sortEmoji() {
    recentEmoji.clear();
    for (HashMap.Entry<String, Integer> entry : emojiUseHistory.entrySet()) {
        recentEmoji.add(entry.getKey());
    }
    Collections.sort(recentEmoji, new Comparator<String>() {
        @Override
        public int compare(String lhs, String rhs) {
            Integer count1 = emojiUseHistory.get(lhs);
            Integer count2 = emojiUseHistory.get(rhs);
            if (count1 == null) {
                count1 = 0;
            }
            if (count2 == null) {
                count2 = 0;
            }
            if (count1 > count2) {
                return -1;
            } else if (count1 < count2) {
                return 1;
            }
            return 0;
        }
    });
    while (recentEmoji.size() > 50) {
        recentEmoji.remove(recentEmoji.size() - 1);
    }
}
 
Example 9
Project: PlusGram   File: LruCache.java   View Source Code Vote up 5 votes
/**
 * @param maxSize the maximum size of the cache before returning. May be -1
 *     to evict even 0-sized elements.
 */
private void trimToSize(int maxSize, String justAdded) {
    synchronized (this) {
        Iterator<HashMap.Entry<String, BitmapDrawable>> iterator = map.entrySet().iterator();
        while (iterator.hasNext()) {
            if (size <= maxSize || map.isEmpty()) {
                break;
            }
            HashMap.Entry<String, BitmapDrawable> entry = iterator.next();

            String key = entry.getKey();
            if (justAdded != null && justAdded.equals(key)) {
                continue;
            }
            BitmapDrawable value = entry.getValue();
            size -= safeSizeOf(key, value);
            iterator.remove();

            String[] args = key.split("@");
            if (args.length > 1) {
                ArrayList<String> arr = mapFilters.get(args[0]);
                if (arr != null) {
                    arr.remove(args[1]);
                    if (arr.isEmpty()) {
                        mapFilters.remove(args[0]);
                    }
                }
            }

            entryRemoved(true, key, value, null);
        }
    }
}
 
Example 10
Project: WebPLP   File: PLPAddressBus.java   View Source Code Vote up 5 votes
/**
 * This method will read the data from the module
 * @param addr address whose data needs to be read
 * @return read object else error code
 */
public synchronized Long read(long addr)
{
	Long value = null;
	
	for(HashMap.Entry<String, IOMemoryModule> entry : modules.entrySet())
	{
		IOMemoryModule mod = entry.getValue();
		if(mod.isAddressWithModule(addr))
		{
			if(!mod.isPhantom())
				value = mod.read(addr);
			else
			{
				//verify: why are we even calling read of the module if not interested in its value
				mod.read(addr);
			}
			
			break;
		}
		
		
	}
	
	if(value == null && isMapped(addr))
	{
		 //Constants.PLP_SIM_MODULE_NO_DATA_ON_READ;
		return null;
	}
	else if(!isMapped(addr))
	{
		//return Constants.PLP_SIM_UNMAPPED_MEMORY_ACCESS;
		return null;
	}
	
	
	return value;
}
 
Example 11
Project: chromium-for-android-56-debug-video   File: WebappRegistry.java   View Source Code Vote up 5 votes
/**
 * Deletes the data for all "old" web apps, as well as all WebAPKs that have been uninstalled in
 * the last month. "Old" web apps have not been opened by the user in the last 3 months, or have
 * had their last used time set to 0 by the user clearing their history. Cleanup is run, at
 * most, once a month.
 * @param currentTime The current time which will be checked to decide if the task should be run
 *                    and if a web app should be cleaned up.
 */
public void unregisterOldWebapps(long currentTime) {
    if ((currentTime - mPreferences.getLong(KEY_LAST_CLEANUP, 0)) < FULL_CLEANUP_DURATION) {
        return;
    }

    Iterator<HashMap.Entry<String, WebappDataStorage>> it = mStorages.entrySet().iterator();
    while (it.hasNext()) {
        HashMap.Entry<String, WebappDataStorage> entry = it.next();
        WebappDataStorage storage = entry.getValue();
        String webApkPackage = storage.getWebApkPackageName();
        if (webApkPackage != null) {
            if (isWebApkInstalled(webApkPackage)) {
                continue;
            }
        } else if ((currentTime - storage.getLastUsedTime())
                < WEBAPP_UNOPENED_CLEANUP_DURATION) {
            continue;
        }
        storage.delete();
        it.remove();
    }

    mPreferences.edit()
            .putLong(KEY_LAST_CLEANUP, currentTime)
            .putStringSet(KEY_WEBAPP_SET, mStorages.keySet())
            .apply();
}
 
Example 12
Project: postmark-java   File: Parameters.java   View Source Code Vote up 5 votes
/**
 * It will convert group of parameter to a simple string.
 *
 * @return parameters transformed to proper string format API client accepts
 */
public String toString() {
    StringBuilder parameterString = new StringBuilder();

    int count = 0;
    for (HashMap.Entry<String, String> entry : parameters.entrySet()) {
        parameterString.append(count==0 ? "?" : "&");
        parameterString.append(entry.getKey());
        parameterString.append("=");
        parameterString.append(entry.getValue());
        count++;
    }

    return parameterString.toString();
}
 
Example 13
Project: airgram   File: LruCache.java   View Source Code Vote up 5 votes
/**
 * @param maxSize the maximum size of the cache before returning. May be -1
 *     to evict even 0-sized elements.
 */
private void trimToSize(int maxSize, String justAdded) {
    synchronized (this) {
        Iterator<HashMap.Entry<String, BitmapDrawable>> iterator = map.entrySet().iterator();
        while (iterator.hasNext()) {
            if (size <= maxSize || map.isEmpty()) {
                break;
            }
            HashMap.Entry<String, BitmapDrawable> entry = iterator.next();

            String key = entry.getKey();
            if (justAdded != null && justAdded.equals(key)) {
                continue;
            }
            BitmapDrawable value = entry.getValue();
            size -= safeSizeOf(key, value);
            iterator.remove();

            String[] args = key.split("@");
            if (args.length > 1) {
                ArrayList<String> arr = mapFilters.get(args[0]);
                if (arr != null) {
                    arr.remove(args[1]);
                    if (arr.isEmpty()) {
                        mapFilters.remove(args[0]);
                    }
                }
            }

            entryRemoved(true, key, value, null);
        }
    }
}
 
Example 14
Project: OpenVideoCall-Android   File: VideoViewAdapterUtil.java   View Source Code Vote up 5 votes
public static void composeDataItem1(final ArrayList<UserStatusData> users, HashMap<Integer, SurfaceView> uids, int localUid) {
    for (HashMap.Entry<Integer, SurfaceView> entry : uids.entrySet()) {
        if (DEBUG) {
            log.debug("composeDataItem1 " + (entry.getKey() & 0xFFFFFFFFL) + " " + (localUid & 0xFFFFFFFFL) + " " + users.size() + " " + entry.getValue());
        }
        SurfaceView surfaceV = entry.getValue();
        surfaceV.setZOrderOnTop(false);
        surfaceV.setZOrderMediaOverlay(false);
        searchUidsAndAppend(users, entry, localUid, UserStatusData.DEFAULT_STATUS, UserStatusData.DEFAULT_VOLUME, null);
    }

    removeNotExisted(users, uids, localUid);
}
 
Example 15
Project: springreplugin   File: PluginLoader.java   View Source Code Vote up 5 votes
/**
 * 调整插件中 Activity 的默认 TaskAffinity
 *
 * @param plugin 插件名称
 */
private void adjustPluginTaskAffinity(String plugin, ApplicationInfo appInfo) {
    if (appInfo == null) {
        return;
    }

    Bundle bdl = appInfo.metaData;
    if (bdl != null) {
        boolean useDefault = bdl.getBoolean("use_default_task_affinity", true);
        if (LOG) {
            LogDebug.d(TaskAffinityStates.TAG, "useDefault = " + useDefault);
        }

        if (!useDefault) {
            if (LOG) {
                LogDebug.d(TaskAffinityStates.TAG, String.format("替换插件 %s 中默认的 TaskAffinity", plugin));
            }

            String defaultPluginTaskAffinity = appInfo.packageName;
            for (HashMap.Entry<String, ActivityInfo> entry : mComponents.getActivityMap().entrySet()) {
                ActivityInfo info = entry.getValue();
                if (LOG) {
                    if (info != null) {
                        LogDebug.d(TaskAffinityStates.TAG, String.format("%s.taskAffinity = %s ", info.name, info.taskAffinity));
                    }
                }

                // 如果是默认 TaskAffinity
                if (info != null && info.taskAffinity.equals(defaultPluginTaskAffinity)) {
                    info.taskAffinity = info.taskAffinity + "." + plugin;
                    if (LOG) {
                        LogDebug.d(TaskAffinityStates.TAG, String.format("修改 %s 的 TaskAffinity 为 %s", info.name, info.taskAffinity));
                    }
                }
            }
        }
    }
}
 
Example 16
Project: springreplugin   File: PmHostSvc.java   View Source Code Vote up 5 votes
@Override
public void regReceiver(String plugin, Map rcvFilMap) throws RemoteException {
    PluginInfo pi = RePluginOS.getPlugin(plugin, false);
    if (pi == null || pi.getFrameworkVersion() < 4) {
        return;
    }

    HashMap<String, List<IntentFilter>> receiverFilterMap = (HashMap<String, List<IntentFilter>>) rcvFilMap;

    // 遍历此插件中所有静态声明的 Receiver
    for (HashMap.Entry<String, List<IntentFilter>> entry : receiverFilterMap.entrySet()) {
        if (mReceiverProxy == null) {
            mReceiverProxy = new PluginReceiverProxy();
            mReceiverProxy.setActionPluginMap(mActionPluginComponents);
        }

        /* 保存 action-plugin-receiver 的关系 */
        String receiver = entry.getKey();
        List<IntentFilter> filters = entry.getValue();

        if (filters != null) {
            for (IntentFilter filter : filters) {
                int actionCount = filter.countActions();
                while (actionCount >= 1) {
                    saveAction(filter.getAction(actionCount - 1), plugin, receiver);
                    actionCount--;
                }

                // 注册 Receiver
                mContext.registerReceiver(mReceiverProxy, filter);
            }
        }
    }
}
 
Example 17
Project: StarshipFighters   File: SoundManager.java   View Source Code Vote up 4 votes
public  void disposeAllSound() {
	for (HashMap.Entry<String, Sound> sounds : soundManager.entrySet()) {
		sounds.getValue().dispose();
	}
}
 
Example 18
Project: OpenVideoCall-Android   File: VideoViewAdapterUtil.java   View Source Code Vote up 4 votes
public static void composeDataItem(final ArrayList<UserStatusData> users, HashMap<Integer, SurfaceView> uids,
                                   int localUid,
                                   HashMap<Integer, Integer> status,
                                   HashMap<Integer, Integer> volume,
                                   HashMap<Integer, VideoInfoData> video, int uidExcepted) {
    for (HashMap.Entry<Integer, SurfaceView> entry : uids.entrySet()) {
        int uid = entry.getKey();

        if (uid == uidExcepted && uidExcepted != 0) {
            continue;
        }

        boolean local = uid == 0 || uid == localUid;

        Integer s = null;
        if (status != null) {
            s = status.get(uid);
            if (local && s == null) { // check again
                s = status.get(uid == 0 ? localUid : 0);
            }
        }
        Integer v = null;
        if (volume != null) {
            v = volume.get(uid);
            if (local && v == null) { // check again
                v = volume.get(uid == 0 ? localUid : 0);
            }
        }
        if (v == null) {
            v = UserStatusData.DEFAULT_VOLUME;
        }
        VideoInfoData i;
        if (video != null) {
            i = video.get(uid);
            if (local && i == null) { // check again
                i = video.get(uid == 0 ? localUid : 0);
            }
        } else {
            i = null;
        }
        if (DEBUG) {
            log.debug("composeDataItem " + users + " " + entry + " " + (localUid & 0XFFFFFFFFL) + " " + s + " " + v + " " + i + " " + local + " " + (uid & 0XFFFFFFFFL) + " " + (uidExcepted & 0XFFFFFFFFL));
        }
        searchUidsAndAppend(users, entry, localUid, s, v, i);
    }

    removeNotExisted(users, uids, localUid);
}
 
Example 19
Project: springreplugin   File: PluginReceiverProxy.java   View Source Code Vote up 4 votes
@Override
public void onReceive(Context context, Intent intent) {
    if (intent == null || mActionPluginComponents == null) {
        return;
    }

    String action = intent.getAction();
    if (!TextUtils.isEmpty(action)) {

        if (LOG) {
            LogDebug.d(TAG, String.format("代理 Receiver 收到 action: %s ", action));
        }

        // 根据 action 取得 map<plugin, List<receiver>>
        HashMap<String, List<String>> pc = mActionPluginComponents.get(action);
        if (pc != null) {

            // 遍历每一个插件
            for (HashMap.Entry<String, List<String>> entry : pc.entrySet()) {
                String plugin = entry.getKey();
                if (entry.getValue() == null) {
                    continue;
                }

                // 拷贝数据,防止多线程问题
                List<String> receivers = new ArrayList<>(entry.getValue());
                // 此插件所有声明的 receiver
                for (String receiver : receivers) {
                    try {
                        // 在对应进程接收广播, 如果进程未启动,则拉起之
                        int process = getProcessOfReceiver(plugin, receiver);

                        // todo 合并 IPluginClient 和 IPluginHost
                        if (process == IPluginManager.PROCESS_PERSIST) {
                            IPluginHost host = PluginProcessMain.getPluginHost();
                            host.onReceive(plugin, receiver, intent);
                        } else {
                            IPluginClient client = RePluginOS.startPluginProcess(plugin, process, new PluginBinderInfo(PluginBinderInfo.NONE_REQUEST));
                            client.onReceive(plugin, receiver, intent);
                        }

                    } catch (Throwable e) {
                        if (LOG) {
                            Log.d(TAG, e.toString());
                        }
                    }
                }
            }
        }
    }
}
 
Example 20
Project: L2jBrasil   File: L2FastMap.java   View Source Code Vote up 0 votes
public Map.Entry<K, V> getNext(HashMap.Entry<K, V> priv);