Java Code Examples for android.content.IntentFilter#countActions()
The following examples show how to use
android.content.IntentFilter#countActions() .
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: IntentResolver.java From AndroidComponentPlugin with Apache License 2.0 | 6 votes |
public ArrayList<F> findFilters(IntentFilter matching) { if (matching.countDataSchemes() == 1) { // Fast case. return collectFilters(mSchemeToFilter.get(matching.getDataScheme(0)), matching); } else if (matching.countDataTypes() != 0 && matching.countActions() == 1) { // Another fast case. return collectFilters(mTypedActionToFilter.get(matching.getAction(0)), matching); } else if (matching.countDataTypes() == 0 && matching.countDataSchemes() == 0 && matching.countActions() == 1) { // Last fast case. return collectFilters(mActionToFilter.get(matching.getAction(0)), matching); } else { ArrayList<F> res = null; for (F cur : mFilters) { if (filterEquals(cur, matching)) { if (res == null) { res = new ArrayList<>(); } res.add(cur); } } return res; } }
Example 2
Source File: LocalBroadcastManager.java From guideshow with MIT License | 6 votes |
/** * Register a receive for any local broadcasts that match the given IntentFilter. * * @param receiver The BroadcastReceiver to handle the broadcast. * @param filter Selects the Intent broadcasts to be received. * * @see #unregisterReceiver */ public void registerReceiver(BroadcastReceiver receiver, IntentFilter filter) { synchronized (mReceivers) { ReceiverRecord entry = new ReceiverRecord(filter, receiver); ArrayList<IntentFilter> filters = mReceivers.get(receiver); if (filters == null) { filters = new ArrayList<IntentFilter>(1); mReceivers.put(receiver, filters); } filters.add(filter); for (int i=0; i<filter.countActions(); i++) { String action = filter.getAction(i); ArrayList<ReceiverRecord> entries = mActions.get(action); if (entries == null) { entries = new ArrayList<ReceiverRecord>(1); mActions.put(action, entries); } entries.add(entry); } } }
Example 3
Source File: IntentResolver.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
public ArrayList<F> findFilters(IntentFilter matching) { if (matching.countDataSchemes() == 1) { // Fast case. return collectFilters(mSchemeToFilter.get(matching.getDataScheme(0)), matching); } else if (matching.countDataTypes() != 0 && matching.countActions() == 1) { // Another fast case. return collectFilters(mTypedActionToFilter.get(matching.getAction(0)), matching); } else if (matching.countDataTypes() == 0 && matching.countDataSchemes() == 0 && matching.countActions() == 1) { // Last fast case. return collectFilters(mActionToFilter.get(matching.getAction(0)), matching); } else { ArrayList<F> res = null; for (F cur : mFilters) { if (filterEquals(cur, matching)) { if (res == null) { res = new ArrayList<>(); } res.add(cur); } } return res; } }
Example 4
Source File: LocalBroadcastManager.java From CodenameOne with GNU General Public License v2.0 | 6 votes |
/** * Register a receive for any local broadcasts that match the given IntentFilter. * * @param receiver The BroadcastReceiver to handle the broadcast. * @param filter Selects the Intent broadcasts to be received. * * @see #unregisterReceiver */ public void registerReceiver(BroadcastReceiver receiver, IntentFilter filter) { synchronized (mReceivers) { ReceiverRecord entry = new ReceiverRecord(filter, receiver); ArrayList<IntentFilter> filters = mReceivers.get(receiver); if (filters == null) { filters = new ArrayList<IntentFilter>(1); mReceivers.put(receiver, filters); } filters.add(filter); for (int i=0; i<filter.countActions(); i++) { String action = filter.getAction(i); ArrayList<ReceiverRecord> entries = mActions.get(action); if (entries == null) { entries = new ArrayList<ReceiverRecord>(1); mActions.put(action, entries); } entries.add(entry); } } }
Example 5
Source File: IntentResolver.java From container with GNU General Public License v3.0 | 6 votes |
public ArrayList<F> findFilters(IntentFilter matching) { if (matching.countDataSchemes() == 1) { // Fast case. return collectFilters(mSchemeToFilter.get(matching.getDataScheme(0)), matching); } else if (matching.countDataTypes() != 0 && matching.countActions() == 1) { // Another fast case. return collectFilters(mTypedActionToFilter.get(matching.getAction(0)), matching); } else if (matching.countDataTypes() == 0 && matching.countDataSchemes() == 0 && matching.countActions() == 1) { // Last fast case. return collectFilters(mActionToFilter.get(matching.getAction(0)), matching); } else { ArrayList<F> res = null; for (F cur : mFilters) { if (filterEquals(cur, matching)) { if (res == null) { res = new ArrayList<>(); } res.add(cur); } } return res; } }
Example 6
Source File: LocalBroadcastManager.java From android-sdk with MIT License | 6 votes |
/** * Register a receive for any local broadcasts that match the given IntentFilter. * * @param receiver The BroadcastReceiver to handle the broadcast. * @param filter Selects the Intent broadcasts to be received. * @see #unregisterReceiver */ public void registerReceiver(BroadcastReceiver receiver, IntentFilter filter) { synchronized (mReceivers) { ReceiverRecord entry = new ReceiverRecord(filter, receiver); ArrayList<IntentFilter> filters = mReceivers.get(receiver); if (filters == null) { filters = new ArrayList<>(1); mReceivers.put(receiver, filters); } filters.add(filter); for (int i = 0; i < filter.countActions(); i++) { String action = filter.getAction(i); ArrayList<ReceiverRecord> entries = mActions.get(action); if (entries == null) { entries = new ArrayList<>(1); mActions.put(action, entries); } entries.add(entry); } } }
Example 7
Source File: BaseService.java From libcommon with Apache License 2.0 | 6 votes |
@Override public void onCreate() { super.onCreate(); if (DEBUG) Log.v(TAG, "onCreate:"); final Context app_context = getApplicationContext(); synchronized (mSync) { mLocalBroadcastManager = LocalBroadcastManager.getInstance(getApplicationContext()); final IntentFilter filter = createIntentFilter(); if ((filter != null) && filter.countActions() > 0) { mLocalBroadcastManager.registerReceiver(mLocalBroadcastReceiver, filter); } if (mAsyncHandler == null) { mAsyncHandler = HandlerThreadHandler.createHandler(getClass().getSimpleName()); } } }
Example 8
Source File: Utils.java From Noyze with Apache License 2.0 | 5 votes |
/** * Creates a new IntentFilter, the product of both inputs. */ public static IntentFilter merge(IntentFilter a, IntentFilter b) { IntentFilter both = new IntentFilter(a); for (int i = 0, e = b.countActions(); i < e; ++i) both.addAction(b.getAction(i)); return both; }
Example 9
Source File: LocalBroadcastManager.java From guideshow with MIT License | 5 votes |
/** * Unregister a previously registered BroadcastReceiver. <em>All</em> * filters that have been registered for this BroadcastReceiver will be * removed. * * @param receiver The BroadcastReceiver to unregister. * * @see #registerReceiver */ public void unregisterReceiver(BroadcastReceiver receiver) { synchronized (mReceivers) { ArrayList<IntentFilter> filters = mReceivers.remove(receiver); if (filters == null) { return; } for (int i=0; i<filters.size(); i++) { IntentFilter filter = filters.get(i); for (int j=0; j<filter.countActions(); j++) { String action = filter.getAction(j); ArrayList<ReceiverRecord> receivers = mActions.get(action); if (receivers != null) { for (int k=0; k<receivers.size(); k++) { if (receivers.get(k).receiver == receiver) { receivers.remove(k); k--; } } if (receivers.size() <= 0) { mActions.remove(action); } } } } } }
Example 10
Source File: LocalBroadcastManager.java From android-sdk with MIT License | 5 votes |
/** * Unregister a previously registered BroadcastReceiver. <em>All</em> * filters that have been registered for this BroadcastReceiver will be * removed. * * @param receiver The BroadcastReceiver to unregister. * @see #registerReceiver */ public void unregisterReceiver(BroadcastReceiver receiver) { synchronized (mReceivers) { ArrayList<IntentFilter> filters = mReceivers.remove(receiver); if (filters == null) { return; } for (int i = 0; i < filters.size(); i++) { IntentFilter filter = filters.get(i); for (int j = 0; j < filter.countActions(); j++) { String action = filter.getAction(j); ArrayList<ReceiverRecord> receivers = mActions.get(action); if (receivers != null) { for (int k = 0; k < receivers.size(); k++) { if (receivers.get(k).receiver == receiver) { receivers.remove(k); k--; } } if (receivers.size() <= 0) { mActions.remove(action); } } } } } }
Example 11
Source File: LocalBroadcastManager.java From CodenameOne with GNU General Public License v2.0 | 5 votes |
/** * Unregister a previously registered BroadcastReceiver. <em>All</em> * filters that have been registered for this BroadcastReceiver will be * removed. * * @param receiver The BroadcastReceiver to unregister. * * @see #registerReceiver */ public void unregisterReceiver(BroadcastReceiver receiver) { synchronized (mReceivers) { ArrayList<IntentFilter> filters = mReceivers.remove(receiver); if (filters == null) { return; } for (int i=0; i<filters.size(); i++) { IntentFilter filter = filters.get(i); for (int j=0; j<filter.countActions(); j++) { String action = filter.getAction(j); ArrayList<ReceiverRecord> receivers = mActions.get(action); if (receivers != null) { for (int k=0; k<receivers.size(); k++) { if (receivers.get(k).receiver == receiver) { receivers.remove(k); k--; } } if (receivers.size() <= 0) { mActions.remove(action); } } } } } }
Example 12
Source File: LocalBroadcastManager.java From Dashchan with Apache License 2.0 | 5 votes |
/** * Unregister a previously registered BroadcastReceiver. <em>All</em> filters that have been registered for this * BroadcastReceiver will be removed. * * @param receiver * The BroadcastReceiver to unregister. * * @see #registerReceiver */ public void unregisterReceiver(BroadcastReceiver receiver) { synchronized (mReceivers) { ArrayList<IntentFilter> filters = mReceivers.remove(receiver); if (filters == null) { return; } for (int i = 0; i < filters.size(); i++) { IntentFilter filter = filters.get(i); for (int j = 0; j < filter.countActions(); j++) { String action = filter.getAction(j); ArrayList<ReceiverRecord> receivers = mActions.get(action); if (receivers != null) { for (int k = 0; k < receivers.size(); k++) { if (receivers.get(k).receiver == receiver) { receivers.remove(k); k--; } } if (receivers.size() <= 0) { mActions.remove(action); } } } } } }
Example 13
Source File: Utils.java From Noyze with Apache License 2.0 | 5 votes |
/** * Creates a new IntentFilter, the product of both inputs. */ public static IntentFilter merge(IntentFilter a, IntentFilter b) { IntentFilter both = new IntentFilter(a); for (int i = 0, e = b.countActions(); i < e; ++i) both.addAction(b.getAction(i)); return both; }
Example 14
Source File: LocalBroadcastManager.java From iMoney with Apache License 2.0 | 5 votes |
public void unregisterReceiver(BroadcastReceiver receiver) { HashMap var2 = this.mReceivers; synchronized (this.mReceivers) { ArrayList filters = (ArrayList) this.mReceivers.remove(receiver); if (filters != null) { for (int i = 0; i < filters.size(); ++i) { IntentFilter filter = (IntentFilter) filters.get(i); for (int j = 0; j < filter.countActions(); ++j) { String action = filter.getAction(j); ArrayList receivers = (ArrayList) this.mActions.get(action); if (receivers != null) { for (int k = 0; k < receivers.size(); ++k) { if (((LocalBroadcastManager.ReceiverRecord) receivers.get(k)).receiver == receiver) { receivers.remove(k); --k; } } if (receivers.size() <= 0) { this.mActions.remove(action); } } } } } } }
Example 15
Source File: PmHostSvc.java From springreplugin with Apache License 2.0 | 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 16
Source File: LocalBroadcastManager.java From android-recipes-app with Apache License 2.0 | 5 votes |
/** * Unregister a previously registered BroadcastReceiver. <em>All</em> * filters that have been registered for this BroadcastReceiver will be * removed. * * @param receiver The BroadcastReceiver to unregister. * * @see #registerReceiver */ public void unregisterReceiver(BroadcastReceiver receiver) { synchronized (mReceivers) { ArrayList<IntentFilter> filters = mReceivers.remove(receiver); if (filters == null) { return; } for (int i=0; i<filters.size(); i++) { IntentFilter filter = filters.get(i); for (int j=0; j<filter.countActions(); j++) { String action = filter.getAction(j); ArrayList<ReceiverRecord> receivers = mActions.get(action); if (receivers != null) { for (int k=0; k<receivers.size(); k++) { if (receivers.get(k).receiver == receiver) { receivers.remove(k); k--; } } if (receivers.size() <= 0) { mActions.remove(action); } } } } } }
Example 17
Source File: LocalBroadcastManager.java From koala--Android-Plugin-Runtime- with Apache License 2.0 | 5 votes |
/** * Unregister a previously registered BroadcastReceiver. <em>All</em> * filters that have been registered for this BroadcastReceiver will be * removed. * * @param receiver * The BroadcastReceiver to unregister. * * @see #registerReceiver */ public void unregisterReceiver(BroadcastReceiver receiver) { synchronized (mReceivers) { ArrayList<IntentFilter> filters = mReceivers.remove(receiver); if (filters == null) { return; } for (int i = 0; i < filters.size(); i++) { IntentFilter filter = filters.get(i); for (int j = 0; j < filter.countActions(); j++) { String action = filter.getAction(j); ArrayList<ReceiverRecord> receivers = mActions.get(action); if (receivers != null) { for (int k = 0; k < receivers.size(); k++) { if (receivers.get(k).receiver == receiver) { receivers.remove(k); k--; } } if (receivers.size() <= 0) { mActions.remove(action); } } } } } }
Example 18
Source File: LocalBroadcastManager.java From letv with Apache License 2.0 | 5 votes |
public void unregisterReceiver(BroadcastReceiver receiver) { synchronized (this.mReceivers) { ArrayList<IntentFilter> filters = (ArrayList) this.mReceivers.remove(receiver); if (filters == null) { return; } for (int i = 0; i < filters.size(); i++) { IntentFilter filter = (IntentFilter) filters.get(i); for (int j = 0; j < filter.countActions(); j++) { String action = filter.getAction(j); ArrayList<ReceiverRecord> receivers = (ArrayList) this.mActions.get(action); if (receivers != null) { int k = 0; while (k < receivers.size()) { if (((ReceiverRecord) receivers.get(k)).receiver == receiver) { receivers.remove(k); k--; } k++; } if (receivers.size() <= 0) { this.mActions.remove(action); } } } } } }
Example 19
Source File: IntentResolver.java From container with GNU General Public License v3.0 | 4 votes |
private boolean filterEquals(IntentFilter f1, IntentFilter f2) { int s1 = f1.countActions(); int s2 = f2.countActions(); if (s1 != s2) { return false; } for (int i = 0; i < s1; i++) { if (!f2.hasAction(f1.getAction(i))) { return false; } } s1 = f1.countCategories(); s2 = f2.countCategories(); if (s1 != s2) { return false; } for (int i = 0; i < s1; i++) { if (!f2.hasCategory(f1.getCategory(i))) { return false; } } s1 = f1.countDataTypes(); s2 = f2.countDataTypes(); if (s1 != s2) { return false; } s1 = f1.countDataSchemes(); s2 = f2.countDataSchemes(); if (s1 != s2) { return false; } for (int i = 0; i < s1; i++) { if (!f2.hasDataScheme(f1.getDataScheme(i))) { return false; } } s1 = f1.countDataAuthorities(); s2 = f2.countDataAuthorities(); if (s1 != s2) { return false; } s1 = f1.countDataPaths(); s2 = f2.countDataPaths(); if (s1 != s2) { return false; } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { s1 = f1.countDataSchemeSpecificParts(); s2 = f2.countDataSchemeSpecificParts(); if (s1 != s2) { return false; } } return true; }
Example 20
Source File: IntentResolver.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
public static boolean filterEquals(IntentFilter f1, IntentFilter f2) { int s1 = f1.countActions(); int s2 = f2.countActions(); if (s1 != s2) { return false; } for (int i=0; i<s1; i++) { if (!f2.hasAction(f1.getAction(i))) { return false; } } s1 = f1.countCategories(); s2 = f2.countCategories(); if (s1 != s2) { return false; } for (int i=0; i<s1; i++) { if (!f2.hasCategory(f1.getCategory(i))) { return false; } } s1 = f1.countDataTypes(); s2 = f2.countDataTypes(); if (s1 != s2) { return false; } for (int i=0; i<s1; i++) { if (!f2.hasExactDataType(f1.getDataType(i))) { return false; } } s1 = f1.countDataSchemes(); s2 = f2.countDataSchemes(); if (s1 != s2) { return false; } for (int i=0; i<s1; i++) { if (!f2.hasDataScheme(f1.getDataScheme(i))) { return false; } } s1 = f1.countDataAuthorities(); s2 = f2.countDataAuthorities(); if (s1 != s2) { return false; } for (int i=0; i<s1; i++) { if (!f2.hasDataAuthority(f1.getDataAuthority(i))) { return false; } } s1 = f1.countDataPaths(); s2 = f2.countDataPaths(); if (s1 != s2) { return false; } for (int i=0; i<s1; i++) { if (!f2.hasDataPath(f1.getDataPath(i))) { return false; } } s1 = f1.countDataSchemeSpecificParts(); s2 = f2.countDataSchemeSpecificParts(); if (s1 != s2) { return false; } for (int i=0; i<s1; i++) { if (!f2.hasDataSchemeSpecificPart(f1.getDataSchemeSpecificPart(i))) { return false; } } return true; }