if (rawDragInfo instanceof ShortcutInfo) {
ShortcutInfo dragInfo = (ShortcutInfo) rawDragInfo;
for (ComponentName componentName : cns) {
- // Added null checks to prevent NPE we've seen in the wild
- if (dragInfo != null && dragInfo.intent != null) {
+ if (dragInfo.intent != null) {
ComponentName cn = dragInfo.intent.getComponent();
boolean isSameComponent = cn != null && (cn.equals(componentName) ||
packageNames.contains(cn.getPackageName()));
public void onAnimationEnd(Animator animation) {
mState = STATE_OPEN;
- if (onCompleteRunnable != null) {
- onCompleteRunnable.run();
- }
-
+ onCompleteRunnable.run();
mContent.setFocusOnFirstChild();
}
});
}
public void onFocusChange(View v, boolean hasFocus) {
- if (v == mFolderName && hasFocus) {
- startEditingFolderName();
- } else if (v == mFolderName && !hasFocus) {
- dismissEditingName();
+ if (v == mFolderName) {
+ if (hasFocus) {
+ startEditingFolderName();
+ } else {
+ dismissEditingName();
+ }
}
}
ArrayList<ItemInfo> addShortcuts = new ArrayList<ItemInfo>();
while (iter.hasNext()) {
final PendingInstallShortcutInfo pendingInfo = iter.next();
- final Intent intent = pendingInfo.launchIntent;
// If the intent specifies a package, make sure the package exists
String packageName = pendingInfo.getTargetPackage();
if (!TextUtils.isEmpty(packageName)) {
UserHandleCompat myUserHandle = UserHandleCompat.myUserHandle();
if (!LauncherModel.isValidPackage(context, packageName, myUserHandle)) {
- if (DBG) Log.d(TAG, "Ignoring shortcut for absent package:" + intent);
+ if (DBG) Log.d(TAG, "Ignoring shortcut for absent package: "
+ + pendingInfo.launchIntent);
continue;
}
}
return packageName;
}
- public boolean isLuncherActivity() {
+ public boolean isLauncherActivity() {
return activityInfo != null;
}
}
}
return new PendingInstallShortcutInfo(data, context);
- } catch (JSONException e) {
- Log.d(TAG, "Exception reading shortcut to add: " + e);
- } catch (URISyntaxException e) {
+ } catch (JSONException | URISyntaxException e) {
Log.d(TAG, "Exception reading shortcut to add: " + e);
}
return null;
*/
private static PendingInstallShortcutInfo convertToLauncherActivityIfPossible(
PendingInstallShortcutInfo original) {
- if (original.isLuncherActivity()) {
+ if (original.isLauncherActivity()) {
// Already an activity target
return original;
}
pendingInfo.spanY = item.spanY;
pendingInfo.minSpanX = item.minSpanX;
pendingInfo.minSpanY = item.minSpanY;
- Bundle options = null;
- WidgetHostViewLoader.getDefaultOptionsForWidget(this, pendingInfo);
+ Bundle options = WidgetHostViewLoader.getDefaultOptionsForWidget(this, pendingInfo);
int newWidgetId = mAppWidgetHost.allocateAppWidgetId();
boolean success = mAppWidgetManager.bindAppWidgetIdIfAllowed(
try {
Key key = Key.parseFrom(Base64.decode(backupKey, Base64.DEFAULT));
if (key.checksum != checkKey(key)) {
- key = null;
throw new InvalidBackupException("invalid key read from stream" + backupKey);
}
return key;
- } catch (InvalidProtocolBufferNanoException e) {
- throw new InvalidBackupException(e);
- } catch (IllegalArgumentException e) {
+ } catch (InvalidProtocolBufferNanoException | IllegalArgumentException e) {
throw new InvalidBackupException(e);
}
}
* @param journal a Journal protocol buffer
*/
private void writeJournal(ParcelFileDescriptor newState, Journal journal) {
- FileOutputStream outStream = null;
try {
- outStream = new FileOutputStream(newState.getFileDescriptor());
+ FileOutputStream outStream = new FileOutputStream(newState.getFileDescriptor());
final byte[] journalBytes = writeCheckedBytes(journal);
outStream.write(journalBytes);
outStream.close();
ComponentName componentName = intent.getComponent();
if (componentName == null) {
- Log.d(TAG, "Missing component found in getShortcutInfo: " + componentName);
+ Log.d(TAG, "Missing component found in getShortcutInfo");
return null;
}
boolean willCreateUserFolder(ItemInfo info, View dropOverView, boolean considerTimeout) {
if (dropOverView != null) {
CellLayout.LayoutParams lp = (CellLayout.LayoutParams) dropOverView.getLayoutParams();
- if (lp.useTmpCoords && (lp.tmpCellX != lp.cellX || lp.tmpCellY != lp.tmpCellY)) {
+ if (lp.useTmpCoords && (lp.tmpCellX != lp.cellX || lp.tmpCellY != lp.cellY)) {
return false;
}
}
boolean willAddToExistingUserFolder(Object dragInfo, View dropOverView) {
if (dropOverView != null) {
CellLayout.LayoutParams lp = (CellLayout.LayoutParams) dropOverView.getLayoutParams();
- if (lp.useTmpCoords && (lp.tmpCellX != lp.cellX || lp.tmpCellY != lp.tmpCellY)) {
+ if (lp.useTmpCoords && (lp.tmpCellX != lp.cellX || lp.tmpCellY != lp.cellY)) {
return false;
}
}
if (v == null || hasntMoved || !mCreateUserFolderOnDrop) return false;
mCreateUserFolderOnDrop = false;
- final long screenId = (targetCell == null) ? mDragInfo.screenId : getIdForScreen(target);
+ final long screenId = getIdForScreen(target);
boolean aboveShortcut = (v.getTag() instanceof ShortcutInfo);
boolean willBecomeShortcut = (newView.getTag() instanceof ShortcutInfo);
boolean isWidget = pendingInfo.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET
|| pendingInfo.itemType == LauncherSettings.Favorites.ITEM_TYPE_CUSTOM_APPWIDGET;
- View finalView = isWidget ? ((PendingAddWidgetInfo) pendingInfo).boundWidget : null;
+ AppWidgetHostView finalView = isWidget ?
+ ((PendingAddWidgetInfo) pendingInfo).boundWidget : null;
- if (finalView instanceof AppWidgetHostView && updateWidgetSize) {
- AppWidgetHostView awhv = (AppWidgetHostView) finalView;
- AppWidgetResizeFrame.updateWidgetSizeRanges(awhv, mLauncher, item.spanX,
+ if (finalView != null && updateWidgetSize) {
+ AppWidgetResizeFrame.updateWidgetSizeRanges(finalView, mLauncher, item.spanX,
item.spanY);
}
AppWidgetHost host, int requestCode) {
try {
host.startAppWidgetConfigureActivityForResult(activity, widgetId, 0, requestCode, null);
- } catch (ActivityNotFoundException e) {
- Toast.makeText(activity, R.string.activity_not_found, Toast.LENGTH_SHORT).show();
- } catch (SecurityException e) {
+ } catch (ActivityNotFoundException | SecurityException e) {
Toast.makeText(activity, R.string.activity_not_found, Toast.LENGTH_SHORT).show();
}
}