Commit bb94711e authored by Amit Kumar's avatar Amit Kumar 💻
Browse files

Fix race condition using main handler and clean logs

parent e3bda33c
Pipeline #137344 passed with stage
in 8 minutes and 20 seconds
......@@ -47,6 +47,7 @@ build/
.idea/markdown-navigator*
.idea/compiler.xml
.idea/jarRepositories.xml
.idea/deploymentTargetDropDown.xml
projectFilesBackup/
gradle.xml
......
......@@ -12,18 +12,6 @@ open class InsettableFrameLayout(mContext: Context, attrs: AttributeSet?) : Fram
mContext, attrs
), Insettable {
/*val insets: Rect
get() {
var tempInsets = Rect()
if (this.windowInsets != null) {
tempInsets.left = this.windowInsets!!.systemWindowInsetLeft
tempInsets.top = this.windowInsets!!.systemWindowInsetTop
tempInsets.right = this.windowInsets!!.systemWindowInsetRight
tempInsets.bottom = this.windowInsets!!.systemWindowInsetBottom
}
return tempInsets
}*/
@JvmField
val mInsets = Rect()
......@@ -65,6 +53,19 @@ open class InsettableFrameLayout(mContext: Context, attrs: AttributeSet?) : Fram
}
}
}
override fun generateLayoutParams(attrs: AttributeSet?): LayoutParams =
LayoutParams(context, attrs)
override fun generateDefaultLayoutParams(): LayoutParams = LayoutParams(
FrameLayout.LayoutParams.WRAP_CONTENT,
FrameLayout.LayoutParams.WRAP_CONTENT
)
override fun checkLayoutParams(p: ViewGroup.LayoutParams?): Boolean = p is LayoutParams
override fun generateLayoutParams(lp: ViewGroup.LayoutParams): LayoutParams = LayoutParams(lp)
open class LayoutParams : FrameLayout.LayoutParams {
var ignoreInsets = false
......@@ -80,6 +81,6 @@ open class InsettableFrameLayout(mContext: Context, attrs: AttributeSet?) : Fram
}
constructor(width: Int, height: Int) : super(width, height)
constructor(lp: ViewGroup.LayoutParams?) : super(lp!!)
constructor(lp: ViewGroup.LayoutParams) : super(lp)
}
}
......@@ -294,7 +294,6 @@ public class LauncherPagedView extends PagedView<PageIndicatorDots> implements V
for (int i = 0; i < orderedScreenIds.size(); i++) {
int screenId = orderedScreenIds.get(i);
insertNewWorkspaceScreenBeforeEmptyScreen(screenId);
Log.d(TAG, "bindScreens() called with: orderedScreenIds = [" + orderedScreenIds + "]");
}
}
......@@ -770,18 +769,7 @@ public class LauncherPagedView extends PagedView<PageIndicatorDots> implements V
final CellLayout layout;
if (container == Constants.CONTAINER_HOTSEAT) {
layout = mLauncher.getHotseat().getLayout();
// Hide folder title in the hotseat
//TODO: Enable when supporting folders
/*if (child instanceof FolderIcon) {
((FolderIcon) child).setTextVisible(false);
}*/
} else {
// Show folder title if not in the hotseat
//TODO: Enable when supporting folders
/*if (child instanceof FolderIcon) {
((FolderIcon) child).setTextVisible(true);
}*/
layout = getScreenWithId(screenId);
}
......@@ -799,8 +787,8 @@ public class LauncherPagedView extends PagedView<PageIndicatorDots> implements V
lp = new GridLayout.LayoutParams(rowSpec, colSpec);
} else {
lp = (CellLayout.LayoutParams) genericLp;
lp.rowSpec = GridLayout.spec(GridLayout.UNDEFINED);
lp.columnSpec = GridLayout.spec(GridLayout.UNDEFINED);
lp.rowSpec = rowSpec;
lp.columnSpec = colSpec;
}
lp.setGravity(Gravity.CENTER);
......@@ -830,10 +818,6 @@ public class LauncherPagedView extends PagedView<PageIndicatorDots> implements V
}
public void addInScreenFromBind(View child, LauncherItem info) {
Log.d(
TAG,
"addInScreenFromBind() called with: child = [" + child + "], info = [" + info + "]"
);
addInScreen(child, info.container, info.screenId, info.cell);
}
......@@ -1273,7 +1257,6 @@ public class LauncherPagedView extends PagedView<PageIndicatorDots> implements V
@Override
public boolean isDropEnabled() {
Log.d(TAG, "isDropEnabled() called");
return true;
}
......@@ -1521,10 +1504,8 @@ public class LauncherPagedView extends PagedView<PageIndicatorDots> implements V
launcherItem.cell = j;
launcherItem.screenId = screenId;
launcherItem.container = container;
Log.i(TAG, "updateDatabase: "+launcherItem);
if (launcherItem.itemType == Constants.ITEM_TYPE_FOLDER) {
FolderItem folderItem = (FolderItem) launcherItem;
Log.i(TAG, "updateDatabaseFolder: "+launcherItem);
items.add(folderItem);
for (int k = 0; k < folderItem.items.size(); k++) {
LauncherItem item = folderItem.items.get(k);
......
......@@ -598,7 +598,6 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
if (layoutChildren) {
final int childHeight = child.getMeasuredHeight();
final int childTop = verticalCenter - childHeight / 2;
Log.i(TAG, "getPageScrolls: "+childLeft+" "+childTop+" "+childRight+" "+ (childTop+childHeight));
child.layout(childLeft, childTop, childRight, childTop + childHeight);
}
......
......@@ -81,6 +81,7 @@ public class Hotseat extends CellLayout implements Insettable {
public void setInsets(Rect insets) {
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) getLayoutParams();
VariantDeviceProfile grid = mLauncher.getDeviceProfile();
insets = grid.getInsets();
lp.gravity = Gravity.BOTTOM;
lp.width = ViewGroup.LayoutParams.MATCH_PARENT;
lp.height = grid.getHotseatBarSizePx() + insets.bottom;
......@@ -88,7 +89,6 @@ public class Hotseat extends CellLayout implements Insettable {
getLayout().setPadding(padding.left, padding.top, padding.right, padding.bottom);
setLayoutParams(lp);
InsettableFrameLayout.Companion.dispatchInsets(this, insets);
Log.i(TAG, "setInsets: called");
}
@Override
......
......@@ -10,7 +10,6 @@ import android.content.Context;
import android.graphics.Rect;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewDebug;
......@@ -295,11 +294,9 @@ public abstract class BaseDragLayer<T extends BaseDraggingActivity> extends Inse
int[] temp = new int[2];
getLocationOnScreen(temp);
Log.i("BaseDragLayer", "getViewRectRelativeToSelf iNWindow: "+x+" "+y);
v.getLocationInWindow(loc);
int vX = loc[0];
int vY = loc[1];
Log.i("BaseDragLayer", "getViewRectRelativeToSelf ofView: "+vX+" "+vY);
int left = vX - x;
int top = vY - y;
......@@ -439,6 +436,7 @@ public abstract class BaseDragLayer<T extends BaseDraggingActivity> extends Inse
int count = getChildCount();
for (int i = 0; i < count; i++) {
View child = getChildAt(i);
final FrameLayout.LayoutParams flp = (FrameLayout.LayoutParams) child.getLayoutParams();
if (flp instanceof LayoutParams) {
final LayoutParams lp = (LayoutParams) flp;
......
......@@ -273,12 +273,12 @@ open class CellLayout @JvmOverloads constructor(
params: LayoutParams,
markCells: Boolean
): Boolean {
val lp: LayoutParams = params
// Hotseat icons - remove text
if (child is IconTextView) {
val bubbleChild: IconTextView = child
bubbleChild.setTextVisibility(mContainerType != HOTSEAT)
}
......
......@@ -28,6 +28,7 @@ import android.location.LocationManager
import android.net.Uri
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.os.Process
import android.os.StrictMode
import android.os.StrictMode.VmPolicy
......@@ -200,6 +201,8 @@ class TestActivity : BaseDraggingActivity(), AutoCompleteAdapter.OnSuggestionCli
private var mFolderAppsViewPager: ViewPager? = null
private var mFolderTitleInput: BlissInput? = null
private val mainHandler = Handler(Looper.getMainLooper())
private val mWeatherReceiver: BroadcastReceiver = object : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
if (!intent.getBooleanExtra(WeatherUpdateService.EXTRA_UPDATE_CANCELLED, false)) {
......@@ -1081,7 +1084,7 @@ class TestActivity : BaseDraggingActivity(), AutoCompleteAdapter.OnSuggestionCli
.observeOn(AndroidSchedulers.mainThread())
.subscribeWith(object : DisposableObserver<List<LauncherItem>>() {
override fun onNext(launcherItems: List<LauncherItem>) {
showApps(launcherItems)
mainHandler.post { showApps(launcherItems) }
}
override fun onError(e: Throwable) {
......
......@@ -26,6 +26,7 @@ import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
......@@ -39,6 +40,7 @@ import foundation.e.blisslauncher.features.test.TestActivity;
import foundation.e.blisslauncher.features.test.TouchController;
import foundation.e.blisslauncher.features.test.anim.Interpolators;
import foundation.e.blisslauncher.features.test.graphics.WorkspaceAndHotseatScrim;
import foundation.e.blisslauncher.uioverrides.UiFactory;
/**
* A ViewGroup that coordinates dragging across its descendants
......
......@@ -420,11 +420,7 @@ public class DragView extends View {
setLayoutParams(lp);
move(touchX, touchY);
// Post the animation to skip other expensive work happening on the first frame
post(new Runnable() {
public void run() {
mAnim.start();
}
});
post(() -> mAnim.start());
}
public void cancelAnimation() {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment