Skip to content

Commit

Permalink
Do a swipe to the bottom if all followers on the screen are skipped #78
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Mishchenko committed Sep 1, 2020
1 parent 5cdec49 commit 28f3338
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/action_handle_blogger.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import uiautomator2 as uiautomator

from src.globals import UI_TIMEOUT, UI_TIMEOUT_ITERATOR
from src.globals import UI_TIMEOUT_ITERATOR
from src.interaction_rect_checker import is_in_interaction_rect
from src.navigation import navigate, Tabs
from src.storage import FollowingStatus
Expand Down Expand Up @@ -108,6 +108,7 @@ def scrolled_to_top():
print("Iterate over visible followers")
random_sleep()
screen_iterated_followers = 0
screen_skipped_followers = 0

try:
for item in device(resourceId='com.instagram.android:id/follow_list_container',
Expand All @@ -123,8 +124,10 @@ def scrolled_to_top():

if not is_myself and storage.check_user_was_interacted(username):
print("@" + username + ": already interacted. Skip.")
screen_skipped_followers += 1
elif is_myself and storage.check_user_was_interacted_recently(username):
print("@" + username + ": already interacted in the last week. Skip.")
screen_skipped_followers += 1
else:
print("@" + username + ": interact")
user_name_view.click(timeout=UI_TIMEOUT)
Expand All @@ -150,13 +153,19 @@ def scrolled_to_top():
print(COLOR_OKGREEN + "Scrolled to top, finish." + COLOR_ENDC)
return
elif screen_iterated_followers > 0:
print(COLOR_OKGREEN + "Need to scroll now" + COLOR_ENDC)
need_swipe = screen_skipped_followers == screen_iterated_followers
list_view = device(resourceId='android:id/list',
className='android.widget.ListView')
if is_myself:
print(COLOR_OKGREEN + "Need to scroll now" + COLOR_ENDC)
list_view.scroll.toBeginning(max_swipes=1)
else:
list_view.scroll.toEnd(max_swipes=1)
if need_swipe:
print(COLOR_OKGREEN + "All followers skipped, let's do a swipe" + COLOR_ENDC)
list_view.fling.toEnd(max_swipes=5)
else:
print(COLOR_OKGREEN + "Need to scroll now" + COLOR_ENDC)
list_view.scroll.toEnd(max_swipes=1)
else:
print(COLOR_OKGREEN + "No followers were iterated, finish." + COLOR_ENDC)
return
Expand Down

0 comments on commit 28f3338

Please sign in to comment.