Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(166)

Unified Diff: ui/android/overscroll_refresh.cc

Issue 2528823002: Separate SwipeRefreshHandler and ContentViewCore (Closed)
Patch Set: Remove unused SwipeRefreshHandler.mNativeSwipeRefreshHandler field Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/android/overscroll_refresh.cc
diff --git a/ui/android/overscroll_refresh.cc b/ui/android/overscroll_refresh.cc
index c4dd023ab920d78bddeb43336651dc19c4cc8dee..e85e7aee716a34cbfebcb257cd84cb249c9708ca 100644
--- a/ui/android/overscroll_refresh.cc
+++ b/ui/android/overscroll_refresh.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "jni/SwipeRefreshHandler_jni.h"
#include "ui/android/overscroll_refresh.h"
#include "base/logging.h"
@@ -15,12 +16,15 @@ const float kMinFlingVelocityForActivation = -500.f;
} // namespace
-OverscrollRefresh::OverscrollRefresh(OverscrollRefreshHandler* handler)
+using base::android::AttachCurrentThread;
+
+OverscrollRefresh::OverscrollRefresh(
+ const base::android::JavaRef<jobject>& handler)
: scrolled_to_top_(true),
overflow_y_hidden_(false),
scroll_consumption_state_(DISABLED),
- handler_(handler) {
- DCHECK(handler);
+ handler_(nullptr, handler.obj()) {
boliu 2016/12/01 00:01:57 huh odd, null is actually ok here, but I don't see
+ DCHECK(!handler_.is_null());
}
OverscrollRefresh::~OverscrollRefresh() {
@@ -28,7 +32,7 @@ OverscrollRefresh::~OverscrollRefresh() {
void OverscrollRefresh::Reset() {
scroll_consumption_state_ = DISABLED;
- handler_->PullReset();
+ Java_SwipeRefreshHandler_reset(AttachCurrentThread(), handler_);
}
void OverscrollRefresh::OnScrollBegin() {
@@ -51,7 +55,10 @@ void OverscrollRefresh::OnScrollUpdateAck(bool was_consumed) {
return;
}
- scroll_consumption_state_ = handler_->PullStart() ? ENABLED : DISABLED;
+ bool pull_started =
+ Java_SwipeRefreshHandler_start(AttachCurrentThread(), handler_);
+
+ scroll_consumption_state_ = pull_started ? ENABLED : DISABLED;
}
bool OverscrollRefresh::WillHandleScrollUpdate(
@@ -67,7 +74,8 @@ bool OverscrollRefresh::WillHandleScrollUpdate(
return false;
case ENABLED:
- handler_->PullUpdate(scroll_delta.y());
+ Java_SwipeRefreshHandler_pull(AttachCurrentThread(), handler_,
+ scroll_delta.y());
return true;
}
@@ -97,7 +105,8 @@ void OverscrollRefresh::OnFrameUpdated(
void OverscrollRefresh::Release(bool allow_refresh) {
if (scroll_consumption_state_ == ENABLED)
- handler_->PullRelease(allow_refresh);
+ Java_SwipeRefreshHandler_release(AttachCurrentThread(), handler_,
+ allow_refresh);
scroll_consumption_state_ = DISABLED;
}

Powered by Google App Engine
This is Rietveld 408576698