Java 类android.util.ArrayMap 实例源码
项目:traypreferences
文件:XmlUtils.java
/**
* Like {@link #readThisMapXml}, but returns an ArrayMap instead of HashMap.
* @hide
*/
public static final ArrayMap<String, ?> readThisArrayMapXml(XmlPullParser parser, String endTag,
String[] name, ReadMapCallback callback)
throws XmlPullParserException, java.io.IOException
{
ArrayMap<String, Object> map = new ArrayMap<>();
int eventType = parser.getEventType();
do {
if (eventType == parser.START_TAG) {
Object val = readThisValueXml(parser, name, callback, true);
map.put(name[0], val);
} else if (eventType == parser.END_TAG) {
if (parser.getName().equals(endTag)) {
return map;
}
throw new XmlPullParserException(
"Expected " + endTag + " end tag at: " + parser.getName());
}
eventType = parser.next();
} while (eventType != parser.END_DOCUMENT);
throw new XmlPullParserException(
"Document ended before " + endTag + " end tag");
}
项目:lineagex86
文件:AppNotificationSettings.java
public static void applyConfigActivities(PackageManager pm, ArrayMap<String, AppRow> rows,
List<ResolveInfo> resolveInfos) {
if (DEBUG) Log.d(TAG, "Found " + resolveInfos.size() + " preference activities"
+ (resolveInfos.size() == 0 ? " ;_;" : ""));
for (ResolveInfo ri : resolveInfos) {
final ActivityInfo activityInfo = ri.activityInfo;
final ApplicationInfo appInfo = activityInfo.applicationInfo;
final AppRow row = rows.get(appInfo.packageName);
if (row == null) {
if (DEBUG) Log.v(TAG, "Ignoring notification preference activity ("
+ activityInfo.name + ") for unknown package "
+ activityInfo.packageName);
continue;
}
if (row.settingsIntent != null) {
if (DEBUG) Log.v(TAG, "Ignoring duplicate notification preference activity ("
+ activityInfo.name + ") for package "
+ activityInfo.packageName);
continue;
}
row.settingsIntent = new Intent(APP_NOTIFICATION_PREFS_CATEGORY_INTENT)
.setClassName(activityInfo.packageName, activityInfo.name);
}
}
项目:TIIEHenry-Android-SDK
文件:ZipUtil.java
public void unZip(ArrayMap<String,File> files) throws IOException, FileExistsException {
if (!zipFile.exists())
throw new FileNotFoundException(zipFile.toString());
FileInputStream fis= new FileInputStream(zipFile);
CheckedInputStream cos = new CheckedInputStream(fis, checksum);
ZipInputStream zis = new ZipInputStream(new BufferedInputStream(cos));
try {
unZip(zis, files);
} finally {
if (zis != null) {
try {
zis.close();
} catch (IOException e) {
throw e;
}
}
}
}
项目:CommentView
文件:CanvasAreaView.java
@TargetApi(Build.VERSION_CODES.KITKAT)
public void setContentAreaForJsonFile(String str) {
try {
final ArrayMap fields = getFields();
ArrayMap[] methods = getMethods();
final ArrayMap arrayMap = methods[0];
final ArrayMap arrayMap2 = methods[1];
// setCanvasArea(CanvasUIEngine.g().inflateCanvasArea((CanvasHost) this, str, new CanvasUIEngineInflateListener() {
// public void didInflatedArea(CanvasArea canvasArea, String str) {
// if (fields.containsKey(str)) {
// Field field = (Field) fields.get(str);
// field.setAccessible(true);
// try {
// field.set(CanvasAreaView.this, canvasArea);
// } catch (IllegalAccessException e) {
// e.printStackTrace();
// throw new RuntimeException(e.getMessage());
// }
// }
// if (arrayMap.containsKey(str)) {
// canvasArea.clickListener = CanvasAreaView.getListener((Method) arrayMap.get(str), canvasArea, CanvasAreaView.this);
// }
// if (arrayMap2.containsKey(str)) {
// canvasArea.longClickListener = CanvasAreaView.getLongListener((Method) arrayMap2.get(str), canvasArea, CanvasAreaView.this);
// }
// }
// }));
} catch (NoSuchMethodException e) {
e.printStackTrace();
throw new RuntimeException(e.getMessage());
} catch (IllegalAccessException e2) {
e2.printStackTrace();
throw new RuntimeException(e2.getMessage());
} catch (InvocationTargetException e3) {
e3.printStackTrace();
throw new RuntimeException(e3.getMessage());
}
}
项目:Android-Router
文件:ParamsWrapperTest.java
@TargetApi(Build.VERSION_CODES.KITKAT)
@Test
public void checkObj() throws JSONException {
String json = "{'a':1,'b':'2'}";
ParamsWrapper wrapper = new ParamsWrapper(json);
String json2 = "{'c':1,'d':'2'}";
List<String> arr2 = new ArrayList<>();
arr2.add("a");
arr2.add("b");
Map<String, Object> map2 = new ArrayMap<>();
map2.put("A","1");
map2.put("B","2");
wrapper.append(json2);
wrapper.append(arr2);
wrapper.append(map2);
System.out.println();
}
项目:BWS-Android
文件:BioIdWebserviceClientExtended.java
@VisibleForTesting
protected HttpRequest createNewTokenRequest(@NonNull String bcid, @NonNull String task) {
try {
Map<String, String> queryParameters = new ArrayMap<>(3);
queryParameters.put("id", BuildConfig.BIOID_APP_ID);
queryParameters.put("bcid", bcid);
queryParameters.put("task", task);
return withDefaultTimeout(
HttpRequest.get(BWS_BASE_URL + "/extension/token", queryParameters, true)
.basic(BuildConfig.BIOID_APP_ID, BuildConfig.BIOID_APP_SECRET)
.accept(CONTENT_TYPE_TEXT));
} catch (HttpRequest.HttpRequestException e) {
throw new NoConnectionException(e);
}
}
项目:IFWManager
文件:IntentResolver.java
private final void addFilter(ArrayMap<String, F[]> map, String name, F filter) {
F[] array = map.get(name);
if (array == null) {
array = newArray(2);
map.put(name, array);
array[0] = filter;
} else {
final int N = array.length;
int i = N;
while (i > 0 && array[i-1] == null) {
i--;
}
if (i < N) {
array[i] = filter;
} else {
F[] newa = newArray((N*3)/2);
System.arraycopy(array, 0, newa, 0, N);
newa[N] = filter;
map.put(name, newa);
}
}
}
项目:homeDash
文件:SensorReader.java
public void getBatteryReading(SensorDataListener listener){
IntentFilter intentFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
Intent batteryStatus = context.registerReceiver(null, intentFilter);
int batteryStatusIntExtra = batteryStatus.getIntExtra(BatteryManager.EXTRA_STATUS, -1);
boolean isCharging = batteryStatusIntExtra == BatteryManager.BATTERY_STATUS_CHARGING ||
batteryStatusIntExtra == BatteryManager.BATTERY_STATUS_FULL;
int chargePlug = batteryStatus.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1);
boolean usbCharge = chargePlug == BatteryManager.BATTERY_PLUGGED_USB;
boolean acCharge = chargePlug == BatteryManager.BATTERY_PLUGGED_AC;
int level = batteryStatus.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
int scale = batteryStatus.getIntExtra(BatteryManager.EXTRA_SCALE, -1);
float batteryPct = level / (float)scale;
Log.i(TAG, "AC connected: "+acCharge);
Log.i(TAG, "USB connected: "+usbCharge);
Log.i(TAG, "Battery charging: "+ isCharging);
Log.i(TAG, "Battery Level: "+ batteryPct);
ArrayMap<String, String> map = new ArrayMap<>(3);
map.put(SENSOR, "Battery");
map.put(VALUE, Integer.toString(level));
map.put(UNIT, BATTERYSENSOR_UNIT);
map.put("charging", Boolean.toString(isCharging));
map.put("acPlugged", Boolean.toString(acCharge));
map.put("usbPlugged", Boolean.toString(usbCharge));
listener.sensorData(map);
}
项目:XPrivacy
文件:XmlUtils.java
/**
* Like {@link #readThisMapXml}, but returns an ArrayMap instead of HashMap.
* @hide
*/
public static final ArrayMap<String, ?> readThisArrayMapXml(XmlPullParser parser, String endTag,
String[] name, ReadMapCallback callback)
throws XmlPullParserException, java.io.IOException
{
ArrayMap<String, Object> map = new ArrayMap<>();
int eventType = parser.getEventType();
do {
if (eventType == parser.START_TAG) {
Object val = readThisValueXml(parser, name, callback, true);
map.put(name[0], val);
} else if (eventType == parser.END_TAG) {
if (parser.getName().equals(endTag)) {
return map;
}
throw new XmlPullParserException(
"Expected " + endTag + " end tag at: " + parser.getName());
}
eventType = parser.next();
} while (eventType != parser.END_DOCUMENT);
throw new XmlPullParserException(
"Document ended before " + endTag + " end tag");
}
项目:AndroidProjectsClient
文件:BaseActivity.java
private void removeActivityFromTransitionManager() {
final Class transitionManagerClass = TransitionManager.class;
try {
final Field runningTransitionsField = transitionManagerClass
.getDeclaredField("sRunningTransitions");
runningTransitionsField.setAccessible(true);
//noinspection unchecked
final ThreadLocal<WeakReference<ArrayMap<ViewGroup, ArrayList<Transition>>>> runningTransitions
= (ThreadLocal<WeakReference<ArrayMap<ViewGroup, ArrayList<Transition>>>>)
runningTransitionsField.get(transitionManagerClass);
if(runningTransitions.get() == null || runningTransitions.get().get() == null) {
return;
}
ArrayMap map = runningTransitions.get().get();
View decorView = getWindow().getDecorView();
if(map.containsKey(decorView)) {
map.remove(decorView);
}
} catch(Exception ignored) {
}
}
项目:Morpheus
文件:AttributeMapperUnitTest.java
@Test
public void testmapAttributeToObjectJSONObject() throws Exception {
JSONObject jsonObject = mock(JSONObject.class);
Deserializer mockDeserializer = mock(Deserializer.class);
AttributeMapper attributeMapper = new AttributeMapper(mockDeserializer, new Gson());
JSONObject mockJSONObject = mock(JSONObject.class);
Iterator mockIter = mock(Iterator.class);
when(jsonObject.get("map")).thenReturn(new JSONObject());
when(jsonObject.getJSONObject("map")).thenReturn(mockJSONObject);
when(mockIter.hasNext()).thenReturn(true, true, false);
when(mockIter.next()).thenReturn("Key 1", "Key 2");
when(mockJSONObject.keys()).thenReturn(mockIter);
when(mockJSONObject.get(anyString())).thenReturn("String");
Article article = new Article();
Field field = Article.class.getDeclaredField("map");
attributeMapper.mapAttributeToObject(article, jsonObject, field, "map");
ArgumentCaptor<ArrayMap> mapArgumentCaptor = ArgumentCaptor.forClass(ArrayMap.class);
verify(mockDeserializer).setField(Matchers.<Resource>anyObject(), eq("map"), mapArgumentCaptor.capture());
assertNotNull(mapArgumentCaptor);
}
项目:NyanpasuTile
文件:RecyclerView.java
/**
* A LayoutManager may want to layout a view just to animate disappearance.
* This method handles those views and triggers remove animation on them.
*/
private void processDisappearingList(ArrayMap<View, Rect> appearingViews) {
final int count = mDisappearingViewsInLayoutPass.size();
for (int i = 0; i < count; i ++) {
View view = mDisappearingViewsInLayoutPass.get(i);
ViewHolder vh = getChildViewHolderInt(view);
final ItemHolderInfo info = mState.mPreLayoutHolderMap.remove(vh);
if (!mState.isPreLayout()) {
mState.mPostLayoutHolderMap.remove(vh);
}
if (appearingViews.remove(view) != null) {
mLayout.removeAndRecycleView(view, mRecycler);
continue;
}
if (info != null) {
animateDisappearance(info);
} else {
// let it disappear from the position it becomes visible
animateDisappearance(new ItemHolderInfo(vh, view.getLeft(), view.getTop(),
view.getRight(), view.getBottom()));
}
}
mDisappearingViewsInLayoutPass.clear();
}
项目:nearby-beacons
文件:EddystoneScannerService.java
@Override
public void onCreate() {
super.onCreate();
sRunning = true;
mNotificationManager =
(NotificationManager) getSystemService(NOTIFICATION_SERVICE);
BluetoothManager manager =
(BluetoothManager) getSystemService(BLUETOOTH_SERVICE);
mBluetoothLeScanner = manager.getAdapter().getBluetoothLeScanner();
mDetectedBeacons = new ArrayMap<>();
startScanning();
}
项目:ApkLauncher
文件:IntentResolver.java
private final void addFilter(ArrayMap<String, F[]> map, String name, F filter) {
F[] array = map.get(name);
if (array == null) {
array = newArray(2);
map.put(name, array);
array[0] = filter;
} else {
final int N = array.length;
int i = N;
while (i > 0 && array[i-1] == null) {
i--;
}
if (i < N) {
array[i] = filter;
} else {
F[] newa = newArray((N*3)/2);
System.arraycopy(array, 0, newa, 0, N);
newa[N] = filter;
map.put(name, newa);
}
}
}
项目:SinaWeibo_Android
文件:XmlUtils.java
/**
* Like {@link #readThisMapXml}, but returns an ArrayMap instead of HashMap.
* @hide
*/
@TargetApi(Build.VERSION_CODES.KITKAT)
public static final ArrayMap<String, ?> readThisArrayMapXml(XmlPullParser parser, String endTag,
String[] name, ReadMapCallback callback)
throws XmlPullParserException, IOException
{
ArrayMap<String, Object> map = new ArrayMap<>();
int eventType = parser.getEventType();
do {
if (eventType == parser.START_TAG) {
Object val = readThisValueXml(parser, name, callback, true);
map.put(name[0], val);
} else if (eventType == parser.END_TAG) {
if (parser.getName().equals(endTag)) {
return map;
}
throw new XmlPullParserException(
"Expected " + endTag + " end tag at: " + parser.getName());
}
eventType = parser.next();
} while (eventType != parser.END_DOCUMENT);
throw new XmlPullParserException(
"Document ended before " + endTag + " end tag");
}
项目:buck
文件:ResourcesLoader.java
@TargetApi(KITKAT)
public List<LoadedApkInternal> getLoadedApks()
throws NoSuchFieldException, IllegalAccessException {
List<LoadedApkInternal> loadedApks = new ArrayList<>();
for (String field : new String[] {"mPackages", "mResourcePackages"}) {
ArrayMap packages =
(ArrayMap) Reflect.getField(activityThread, sActivityThreadClass, field);
for (Object loadedApkRef : packages.values()) {
Object loadedApk = ((WeakReference) loadedApkRef).get();
if (loadedApk == null) {
continue;
}
loadedApks.add(new LoadedApkInternal(loadedApk));
}
}
return loadedApks;
}
项目:buck
文件:ResourcesLoader.java
@TargetApi(NOUGAT)
private static void updateResourceKeys(Context context, String originalResourcePath)
throws InvocationTargetException, IllegalAccessException, NoSuchFieldException, IOException {
List<String> exoResourcePaths = getExoPaths(context);
if (exoResourcePaths.isEmpty()) {
return;
}
String resDir = exoResourcePaths.get(0);
String[] splitResDirs =
exoResourcePaths
.subList(1, exoResourcePaths.size())
.toArray(new String[exoResourcePaths.size() - 1]);
ArrayMap<?, ?> resourceImpls = ResourcesManagerInternal.getInstance().getResourceImpls();
ArrayMap<Object, Object> newResourceImpls = new ArrayMap<>(resourceImpls.size());
for (Map.Entry<?, ?> entry : resourceImpls.entrySet()) {
Object key = entry.getKey();
ResourcesKeyInternal keyInternal = new ResourcesKeyInternal(key);
if (keyInternal.getResDir().equals(originalResourcePath)) {
keyInternal.setResDir(resDir);
keyInternal.setSplitResDirs(splitResDirs);
newResourceImpls.put(key, entry.getValue());
}
}
ResourcesManagerInternal.getInstance().setResourceImpls(newResourceImpls);
}
项目:TIIEHenry-Android-SDK
文件:ZipUtil.java
public void unZipAll(File outPath) throws FileNotFoundException, IOException {
FileInputStream fis= new FileInputStream(zipFile);
CheckedInputStream cos = new CheckedInputStream(fis, checksum);
ZipInputStream zis = new ZipInputStream(new BufferedInputStream(cos));
ArrayMap<String,File> files=new ArrayMap<>();
ZipEntry entry;
while ((entry = zis.getNextEntry()) != null) {
String entryName=entry.getName();
files.put(entryName, new File(outPath, entryName));
}
zis.close();
unZip(files);
}
项目:TIIEHenry-Android-SDK
文件:ZipUtil.java
private void unZip(ZipInputStream zis, ArrayMap<String,File> files) throws FileExistsException, IOException {
ZipEntry entry;
while ((entry = zis.getNextEntry()) != null) {
String entryName=entry.getName();
File outFile=files.get(entryName);
if (entry.isDirectory()) {
outFile.mkdirs();
} else {
if (outFile != null) {
if (outFile.exists())
throw new FileExistsException(outFile);
if (!outFile.getParentFile().exists() && !outFile.getParentFile().mkdirs())
throw new IOException("can't mkdirs:" + outFile.getParent());
if (onUpdateListener != null)
onUpdateListener.onUpdate(entryName, outFile);
BufferedOutputStream dest = new BufferedOutputStream(new FileOutputStream(outFile), buffer.length);
int count;
while ((count = zis.read(buffer, 0, buffer.length)) != -1) {
dest.write(buffer, 0, count);
}
dest.flush();
dest.close();
}
}
}
}
项目:TIIEHenry-Android-SDK
文件:Path.java
public boolean copyTo(File path, boolean recover)throws FileExistsException, IOException {
if (isFile()) {
if (path.exists())
throw new FileExistsException(path.toString());
if (!canRead())
throw new IOException("Couldn't read file:" + path.getParent());
path.getParentFile().mkdirs();
if ((!path.exists()) || recover) {
InputStream in=getInputStream();
OutputStream out=new FileOutputStream(path);
copyStream(in, out);
in.close();
out.close();
}
} else if (isDirectory()) {
path.mkdirs();
ArrayMap<String, File> map=getDirMap();
Iterator iter = map.entrySet().iterator();
while (iter.hasNext()) {
Map.Entry entry = (Map.Entry) iter.next();
String name = (String) entry.getKey();
File sourceFile=(File) entry.getValue();
new Path(sourceFile).copyTo(path.getPath() + separator + name, recover);
}
}
return true;
}
项目:TIIEHenry-Android-SDK
文件:Path.java
private void addFileToMap(ArrayMap<String,File> size, String namePerfix, File dir) {
for (File f:dir.listFiles()) {
String fname=f.getName();
if (f.isFile()) {
size.put(namePerfix + fname, f);
} else if (f.isDirectory()) {
size.put(namePerfix + fname + "/", f);
addFileToMap(size, namePerfix + fname + "/", f);
}
}
}
项目:TIIEHenry-Android-SDK
文件:Path.java
public ArrayMap<String,File> getDirMap() {
if (!isDirectory())
return null;
ArrayMap<String,File> size=new ArrayMap<>();
addFileToMap(size, "", this);
return size;
}
项目:ProgressManager
文件:a.java
NonConfigurationInstances retainNonConfigurationInstances() {
Object activity = onRetainNonConfigurationInstance();
HashMap<String, Object> children = onRetainNonConfigurationChildInstances();
FragmentManagerNonConfig fragments = mFragments.retainNestedNonConfig();
// We're already stopped but we've been asked to retain.
// Our fragments are taken care of but we need to mark the loaders for retention.
// In order to do this correctly we need to restart the loaders first before
// handing them off to the next activity.
mFragments.doLoaderStart();
mFragments.doLoaderStop(true);
ArrayMap<String, LoaderManager> loaders = mFragments.retainLoaderNonConfig();
if (activity == null && children == null && fragments == null && loaders == null
&& mVoiceInteractor == null) {
return null;
}
NonConfigurationInstances nci = new NonConfigurationInstances();
nci.activity = activity;
nci.children = children;
nci.fragments = fragments;
nci.loaders = loaders;
if (mVoiceInteractor != null) {
mVoiceInteractor.retainInstance();
nci.voiceInteractor = mVoiceInteractor;
}
return nci;
}
项目:ProgressManager
文件:a.java
NonConfigurationInstances retainNonConfigurationInstances() {
Object activity = onRetainNonConfigurationInstance();
HashMap<String, Object> children = onRetainNonConfigurationChildInstances();
FragmentManagerNonConfig fragments = mFragments.retainNestedNonConfig();
// We're already stopped but we've been asked to retain.
// Our fragments are taken care of but we need to mark the loaders for retention.
// In order to do this correctly we need to restart the loaders first before
// handing them off to the next activity.
mFragments.doLoaderStart();
mFragments.doLoaderStop(true);
ArrayMap<String, LoaderManager> loaders = mFragments.retainLoaderNonConfig();
if (activity == null && children == null && fragments == null && loaders == null
&& mVoiceInteractor == null) {
return null;
}
NonConfigurationInstances nci = new NonConfigurationInstances();
nci.activity = activity;
nci.children = children;
nci.fragments = fragments;
nci.loaders = loaders;
if (mVoiceInteractor != null) {
mVoiceInteractor.retainInstance();
nci.voiceInteractor = mVoiceInteractor;
}
return nci;
}
项目:ProgressManager
文件:a.java
NonConfigurationInstances retainNonConfigurationInstances() {
Object activity = onRetainNonConfigurationInstance();
HashMap<String, Object> children = onRetainNonConfigurationChildInstances();
FragmentManagerNonConfig fragments = mFragments.retainNestedNonConfig();
// We're already stopped but we've been asked to retain.
// Our fragments are taken care of but we need to mark the loaders for retention.
// In order to do this correctly we need to restart the loaders first before
// handing them off to the next activity.
mFragments.doLoaderStart();
mFragments.doLoaderStop(true);
ArrayMap<String, LoaderManager> loaders = mFragments.retainLoaderNonConfig();
if (activity == null && children == null && fragments == null && loaders == null
&& mVoiceInteractor == null) {
return null;
}
NonConfigurationInstances nci = new NonConfigurationInstances();
nci.activity = activity;
nci.children = children;
nci.fragments = fragments;
nci.loaders = loaders;
if (mVoiceInteractor != null) {
mVoiceInteractor.retainInstance();
nci.voiceInteractor = mVoiceInteractor;
}
return nci;
}
项目:ProgressManager
文件:a.java
NonConfigurationInstances retainNonConfigurationInstances() {
Object activity = onRetainNonConfigurationInstance();
HashMap<String, Object> children = onRetainNonConfigurationChildInstances();
FragmentManagerNonConfig fragments = mFragments.retainNestedNonConfig();
// We're already stopped but we've been asked to retain.
// Our fragments are taken care of but we need to mark the loaders for retention.
// In order to do this correctly we need to restart the loaders first before
// handing them off to the next activity.
mFragments.doLoaderStart();
mFragments.doLoaderStop(true);
ArrayMap<String, LoaderManager> loaders = mFragments.retainLoaderNonConfig();
if (activity == null && children == null && fragments == null && loaders == null
&& mVoiceInteractor == null) {
return null;
}
NonConfigurationInstances nci = new NonConfigurationInstances();
nci.activity = activity;
nci.children = children;
nci.fragments = fragments;
nci.loaders = loaders;
if (mVoiceInteractor != null) {
mVoiceInteractor.retainInstance();
nci.voiceInteractor = mVoiceInteractor;
}
return nci;
}
项目:ProgressManager
文件:a.java
NonConfigurationInstances retainNonConfigurationInstances() {
Object activity = onRetainNonConfigurationInstance();
HashMap<String, Object> children = onRetainNonConfigurationChildInstances();
FragmentManagerNonConfig fragments = mFragments.retainNestedNonConfig();
// We're already stopped but we've been asked to retain.
// Our fragments are taken care of but we need to mark the loaders for retention.
// In order to do this correctly we need to restart the loaders first before
// handing them off to the next activity.
mFragments.doLoaderStart();
mFragments.doLoaderStop(true);
ArrayMap<String, LoaderManager> loaders = mFragments.retainLoaderNonConfig();
if (activity == null && children == null && fragments == null && loaders == null
&& mVoiceInteractor == null) {
return null;
}
NonConfigurationInstances nci = new NonConfigurationInstances();
nci.activity = activity;
nci.children = children;
nci.fragments = fragments;
nci.loaders = loaders;
if (mVoiceInteractor != null) {
mVoiceInteractor.retainInstance();
nci.voiceInteractor = mVoiceInteractor;
}
return nci;
}
项目:ProgressManager
文件:a.java
NonConfigurationInstances retainNonConfigurationInstances() {
Object activity = onRetainNonConfigurationInstance();
HashMap<String, Object> children = onRetainNonConfigurationChildInstances();
FragmentManagerNonConfig fragments = mFragments.retainNestedNonConfig();
// We're already stopped but we've been asked to retain.
// Our fragments are taken care of but we need to mark the loaders for retention.
// In order to do this correctly we need to restart the loaders first before
// handing them off to the next activity.
mFragments.doLoaderStart();
mFragments.doLoaderStop(true);
ArrayMap<String, LoaderManager> loaders = mFragments.retainLoaderNonConfig();
if (activity == null && children == null && fragments == null && loaders == null
&& mVoiceInteractor == null) {
return null;
}
NonConfigurationInstances nci = new NonConfigurationInstances();
nci.activity = activity;
nci.children = children;
nci.fragments = fragments;
nci.loaders = loaders;
if (mVoiceInteractor != null) {
mVoiceInteractor.retainInstance();
nci.voiceInteractor = mVoiceInteractor;
}
return nci;
}
项目:ProgressManager
文件:a.java
NonConfigurationInstances retainNonConfigurationInstances() {
Object activity = onRetainNonConfigurationInstance();
HashMap<String, Object> children = onRetainNonConfigurationChildInstances();
FragmentManagerNonConfig fragments = mFragments.retainNestedNonConfig();
// We're already stopped but we've been asked to retain.
// Our fragments are taken care of but we need to mark the loaders for retention.
// In order to do this correctly we need to restart the loaders first before
// handing them off to the next activity.
mFragments.doLoaderStart();
mFragments.doLoaderStop(true);
ArrayMap<String, LoaderManager> loaders = mFragments.retainLoaderNonConfig();
if (activity == null && children == null && fragments == null && loaders == null
&& mVoiceInteractor == null) {
return null;
}
NonConfigurationInstances nci = new NonConfigurationInstances();
nci.activity = activity;
nci.children = children;
nci.fragments = fragments;
nci.loaders = loaders;
if (mVoiceInteractor != null) {
mVoiceInteractor.retainInstance();
nci.voiceInteractor = mVoiceInteractor;
}
return nci;
}
项目:ProgressManager
文件:a.java
NonConfigurationInstances retainNonConfigurationInstances() {
Object activity = onRetainNonConfigurationInstance();
HashMap<String, Object> children = onRetainNonConfigurationChildInstances();
FragmentManagerNonConfig fragments = mFragments.retainNestedNonConfig();
// We're already stopped but we've been asked to retain.
// Our fragments are taken care of but we need to mark the loaders for retention.
// In order to do this correctly we need to restart the loaders first before
// handing them off to the next activity.
mFragments.doLoaderStart();
mFragments.doLoaderStop(true);
ArrayMap<String, LoaderManager> loaders = mFragments.retainLoaderNonConfig();
if (activity == null && children == null && fragments == null && loaders == null
&& mVoiceInteractor == null) {
return null;
}
NonConfigurationInstances nci = new NonConfigurationInstances();
nci.activity = activity;
nci.children = children;
nci.fragments = fragments;
nci.loaders = loaders;
if (mVoiceInteractor != null) {
mVoiceInteractor.retainInstance();
nci.voiceInteractor = mVoiceInteractor;
}
return nci;
}
项目:ProgressManager
文件:a.java
NonConfigurationInstances retainNonConfigurationInstances() {
Object activity = onRetainNonConfigurationInstance();
HashMap<String, Object> children = onRetainNonConfigurationChildInstances();
FragmentManagerNonConfig fragments = mFragments.retainNestedNonConfig();
// We're already stopped but we've been asked to retain.
// Our fragments are taken care of but we need to mark the loaders for retention.
// In order to do this correctly we need to restart the loaders first before
// handing them off to the next activity.
mFragments.doLoaderStart();
mFragments.doLoaderStop(true);
ArrayMap<String, LoaderManager> loaders = mFragments.retainLoaderNonConfig();
if (activity == null && children == null && fragments == null && loaders == null
&& mVoiceInteractor == null) {
return null;
}
NonConfigurationInstances nci = new NonConfigurationInstances();
nci.activity = activity;
nci.children = children;
nci.fragments = fragments;
nci.loaders = loaders;
if (mVoiceInteractor != null) {
mVoiceInteractor.retainInstance();
nci.voiceInteractor = mVoiceInteractor;
}
return nci;
}
项目:ProgressManager
文件:a.java
NonConfigurationInstances retainNonConfigurationInstances() {
Object activity = onRetainNonConfigurationInstance();
HashMap<String, Object> children = onRetainNonConfigurationChildInstances();
FragmentManagerNonConfig fragments = mFragments.retainNestedNonConfig();
// We're already stopped but we've been asked to retain.
// Our fragments are taken care of but we need to mark the loaders for retention.
// In order to do this correctly we need to restart the loaders first before
// handing them off to the next activity.
mFragments.doLoaderStart();
mFragments.doLoaderStop(true);
ArrayMap<String, LoaderManager> loaders = mFragments.retainLoaderNonConfig();
if (activity == null && children == null && fragments == null && loaders == null
&& mVoiceInteractor == null) {
return null;
}
NonConfigurationInstances nci = new NonConfigurationInstances();
nci.activity = activity;
nci.children = children;
nci.fragments = fragments;
nci.loaders = loaders;
if (mVoiceInteractor != null) {
mVoiceInteractor.retainInstance();
nci.voiceInteractor = mVoiceInteractor;
}
return nci;
}
项目:FTC2016
文件:Util.java
/**
* Gets the primary activity without calling from an Activity class
*
* @return the main Activity
*/
@SuppressWarnings("unchecked")
@TargetApi(Build.VERSION_CODES.KITKAT)
public static Activity getActivity() {
/*ActivityManager am = (ActivityManager)getContext().getSystemService(Context.ACTIVITY_SERVICE);
ComponentName cn = am.getRunningTasks(1).get(0).topActivity;*/
try {
Class activityThreadClass = Class.forName("android.app.ActivityThread");
Object activityThread = activityThreadClass.getMethod("currentActivityThread").invoke(null);
Field activitiesField = activityThreadClass.getDeclaredField("mActivities");
activitiesField.setAccessible(true);
ArrayMap activities = (ArrayMap) activitiesField.get(activityThread);
for (Object activityRecord : activities.values()) {
Class activityRecordClass = activityRecord.getClass();
Field pausedField = activityRecordClass.getDeclaredField("paused");
pausedField.setAccessible(true);
if (!pausedField.getBoolean(activityRecord)) {
Field activityField = activityRecordClass.getDeclaredField("activity");
activityField.setAccessible(true);
return (Activity) activityField.get(activityRecord);
}
}
} catch (final java.lang.Throwable e) {
// handle exception
throw new IllegalArgumentException("No activity could be retrieved!");
}
throw new IllegalArgumentException("No activity could be found!");
}
项目:CommentView
文件:CanvasAreaView.java
@TargetApi(Build.VERSION_CODES.KITKAT)
private ArrayMap<String, Field> getFields() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
ArrayMap<String, Field> arrayMap = new ArrayMap();
for (Field field : getClass().getDeclaredFields()) {
// if (field.getAnnotation(CanvasField.class) != null && CanvasArea.class.isAssignableFrom(field.getType())) {
// arrayMap.put(field.getName(), field);
// }
}
return arrayMap;
}
项目:CommentView
文件:CanvasAreaView.java
@TargetApi(Build.VERSION_CODES.KITKAT)
private ArrayMap<String, Method>[] getMethods() {
ArrayMap<String, Method>[] arrayMapArr = new ArrayMap[]{new ArrayMap(), new ArrayMap()};
for (Method method : getClass().getDeclaredMethods()) {
// for (Annotation annotation : method.getAnnotations()) {
// if (annotation instanceof CanvasOnClick) {
// CanvasOnClick canvasOnClick = (CanvasOnClick) annotation;
// if (canvasOnClick.values().length != 0) {
// for (Object put : canvasOnClick.values()) {
// arrayMapArr[0].put(put, method);
// }
// }
// if (!(canvasOnClick.value().equals("0") || arrayMapArr[0].containsKey(canvasOnClick.value()))) {
// arrayMapArr[0].put(canvasOnClick.value(), method);
// }
// } else if (annotation instanceof CanvasOnLongClick) {
// CanvasOnLongClick canvasOnLongClick = (CanvasOnLongClick) annotation;
// if (canvasOnLongClick.values().length != 0) {
// for (Object put2 : canvasOnLongClick.values()) {
// arrayMapArr[1].put(put2, method);
// }
// }
// if (!(canvasOnLongClick.value().equals("0") || arrayMapArr[1].containsKey(canvasOnLongClick.value()))) {
// arrayMapArr[1].put(canvasOnLongClick.value(), method);
// }
// }
// }
}
return arrayMapArr;
}
项目:HtmlNative
文件:ViewTypeRelations.java
static void registerExtraView(@NonNull String htmlType, @NonNull String androidViewClassName) {
if (sExtraTagClassTable == null) {
sExtraTagClassTable = new ArrayMap<>();
}
sExtraTagClassTable.put(htmlType, androidViewClassName);
}
项目:RobotIGS
文件:Util.java
/**
* Gets the primary activity without calling from an Activity class
*
* @return the main Activity
*/
@SuppressWarnings("unchecked")
@TargetApi(Build.VERSION_CODES.KITKAT)
public static Activity getActivity() {
/*ActivityManager am = (ActivityManager)getContext().getSystemService(Context.ACTIVITY_SERVICE);
ComponentName cn = am.getRunningTasks(1).get(0).topActivity;*/
try {
Class activityThreadClass = Class.forName("android.app.ActivityThread");
Object activityThread = activityThreadClass.getMethod("currentActivityThread").invoke(null);
Field activitiesField = activityThreadClass.getDeclaredField("mActivities");
activitiesField.setAccessible(true);
ArrayMap activities = (ArrayMap) activitiesField.get(activityThread);
for (Object activityRecord : activities.values()) {
Class activityRecordClass = activityRecord.getClass();
Field pausedField = activityRecordClass.getDeclaredField("paused");
pausedField.setAccessible(true);
if (!pausedField.getBoolean(activityRecord)) {
Field activityField = activityRecordClass.getDeclaredField("activity");
activityField.setAccessible(true);
return (Activity) activityField.get(activityRecord);
}
}
} catch (final java.lang.Throwable e) {
// handle exception
throw new IllegalArgumentException("No activity could be retrieved!");
}
throw new IllegalArgumentException("No activity could be found!");
}
项目:Synapse
文件:Versatile.java
/**
* Solve TransitionManager leak problem
*/
public static void removeActivityFromTransitionManager(Activity activity) {
final Class transitionManagerClass = TransitionManager.class;
try {
final Field runningTransitionsField = transitionManagerClass.getDeclaredField("sRunningTransitions");
if (runningTransitionsField == null) {
return;
}
runningTransitionsField.setAccessible(true);
//noinspection unchecked
final ThreadLocal<WeakReference<ArrayMap<ViewGroup, ArrayList<Transition>>>> runningTransitions
= (ThreadLocal<WeakReference<ArrayMap<ViewGroup, ArrayList<Transition>>>>)
runningTransitionsField.get(transitionManagerClass);
if (runningTransitions == null
|| runningTransitions.get() == null
|| runningTransitions.get().get() == null) {
return;
}
final ArrayMap map = runningTransitions.get().get();
final View decorView = activity.getWindow().getDecorView();
if (map.containsKey(decorView)) {
map.remove(decorView);
}
} catch (Exception e) {
e.printStackTrace();
}
}
项目:wg_planer
文件:TestServerCalls.java
@Override
public ApiResponse<User> createUser(User user) {
switch (testCase) {
case SUCCESS: {
return new ApiResponse<User>(200, new ArrayMap<String, List<String>>(), user);
}
case FAILURE: {
return new ApiResponse<User>(0, null, null);
}
default: {
return null;
}
}
}
项目:OpenYOLO-Android
文件:CollectionConverter.java
@NonNull
private static <T, U> Map<T, U> createMap(int size) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
return new ArrayMap<>(size);
} else {
return new HashMap<>();
}
}