Skip to content

Commit 714e999

Browse files
committed
Upload file
1 parent 5f632ef commit 714e999

2 files changed

Lines changed: 14 additions & 33 deletions

File tree

common/src/main/java/com/omarea/overscroll/OverScrollDelegate.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ private static PathPointsHolder buildFlingBackPathPointsHolder() {
115115
public static final int OS_FLING = 4;
116116

117117
private static final int DRAG_BACK_DURATION = 420;
118-
private static final int FLING_BACK_DURATION = 550;
118+
private static final int FLING_BACK_DURATION = 700;
119119

120120
private static final int INVALID_POINTER = -1;
121121

@@ -131,7 +131,7 @@ private static PathPointsHolder buildFlingBackPathPointsHolder() {
131131

132132
private final View mView;
133133
private final OverScrollable mOverScrollable;
134-
private boolean mEnableDragOverScroll = true;
134+
private boolean mEnableDragOverScroll = false;
135135
private boolean mEnableFlingOverScroll = true;
136136
private OverScrollStyle mStyle;
137137

@@ -247,7 +247,7 @@ public void recyclerViewAbsorbGlows(int velocityX, int velocityY) {
247247
private void onAbsorb(final int velocityY) {
248248
// offset the start of fling 1px
249249
mOffsetY = velocityY > 0 ? -1 : 1;
250-
final float overY = velocityY * 0.07f;
250+
final float overY = velocityY * 0.1f;
251251
log("velocityY->" + velocityY + " overY->" + overY);
252252
mScroller.start(overY, FLING_BACK_DURATION, sFlingBackPathPointsHolder);
253253
setState(OS_FLING);

krscript/src/main/java/com/omarea/krscript/ui/DialogLogFragment.kt

Lines changed: 11 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,14 @@ import android.widget.ProgressBar
1818
import android.widget.ScrollView
1919
import android.widget.TextView
2020
import android.widget.Toast
21-
import androidx.fragment.app.DialogFragment
2221
import com.omarea.common.ui.DialogHelper
2322
import com.omarea.krscript.R
2423
import com.omarea.krscript.databinding.KrDialogLogBinding
2524
import com.omarea.krscript.executor.ShellExecutor
2625
import com.omarea.krscript.model.RunnableNode
2726
import com.omarea.krscript.model.ShellHandlerBase
2827

29-
class DialogLogFragment : DialogFragment() {
28+
class DialogLogFragment : androidx.fragment.app.DialogFragment() {
3029

3130
private var binding: KrDialogLogBinding? = null
3231
private var running = false
@@ -68,8 +67,9 @@ class DialogLogFragment : DialogFragment() {
6867
if (node.reloadPage) {
6968
binding?.btnHide?.visibility = View.GONE
7069
}
71-
val handler = openExecutor(node)
72-
ShellExecutor().execute(activity, node, script, onExit, params, handler)
70+
openExecutor(node)?.let { shellHandler ->
71+
ShellExecutor().execute(activity, node, script, onExit, params, shellHandler)
72+
}
7373
} ?: dismissAllowingStateLoss()
7474
}
7575

@@ -131,7 +131,7 @@ class DialogLogFragment : DialogFragment() {
131131

132132
binding?.actionProgress?.isIndeterminate = true
133133

134-
val handler = MyShellHandler(object : IActionEventHandler {
134+
return MyShellHandler(object : IActionEventHandler {
135135
override fun onCompleted() {
136136
running = false
137137
onExit.run()
@@ -169,22 +169,8 @@ class DialogLogFragment : DialogFragment() {
169169
binding?.btnCancel?.visibility = View.GONE
170170
}
171171
}
172-
},
173-
binding?.shellOutput,
174-
binding?.actionProgress
175-
)
176-
177-
val scrollView = binding?.shellOutput?.parent as? ScrollView
178-
scrollView?.setOnScrollChangeListener { v, _, scrollY, _, _ ->
179-
val child = v.getChildAt(0) ?: return@setOnScrollChangeListener
180-
val diff = child.bottom - (v.height + scrollY)
181-
182-
// <= 2 để tránh sai số layout
183-
handler.setAutoScroll(diff <= 2)
184-
}
185172

186-
binding?.actionProgress?.isIndeterminate = true
187-
return handler
173+
}, binding?.shellOutput, binding?.actionProgress)
188174
}
189175

190176
@FunctionalInterface
@@ -206,10 +192,7 @@ class DialogLogFragment : DialogFragment() {
206192
private val scriptColor = getColor(R.color.kr_shell_log_script)
207193
private val endColor = getColor(R.color.kr_shell_log_end)
208194
private var hasError = false
209-
private var autoScroll = true
210-
fun setAutoScroll(enable: Boolean) {
211-
autoScroll = enable
212-
}
195+
213196
private fun getColor(resId: Int): Int {
214197
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
215198
context!!.getColor(resId)
@@ -266,12 +249,10 @@ class DialogLogFragment : DialogFragment() {
266249
}
267250

268251
override fun updateLog(msg: SpannableString?) {
269-
msg ?: return
270-
logView?.post {
271-
logView.append(msg)
272-
if (autoScroll) {
273-
(logView.parent as? ScrollView)
274-
?.fullScroll(ScrollView.FOCUS_DOWN)
252+
msg?.let {
253+
logView?.post {
254+
logView?.append(it)
255+
(logView?.parent as? ScrollView)?.fullScroll(ScrollView.FOCUS_DOWN)
275256
}
276257
}
277258
}

0 commit comments

Comments
 (0)