Skip to content

Commit

Permalink
sort #2
Browse files Browse the repository at this point in the history
  • Loading branch information
biplobsd committed Jun 9, 2020
1 parent 6c23a2a commit 881221e
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 11 deletions.
27 changes: 22 additions & 5 deletions libs/kv/start_screen.kv
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ BoxLayout:
adaptive_size: True
size_hint_y: .4
pos_hint: {"center_x": .5}
padding: 0, 0, 0, 30
# padding: 0, 0, 0, 30
MDTextButton:
id: Smirror
font_size: sp(10)
Expand All @@ -164,41 +164,58 @@ BoxLayout:
padding: 10
id: header_text
MDBoxLayout:
# size_hint_x: .83
size_hint_x: .7
size_hint_y: .1
MDSeparator:
MDTextButton:
pos_hint: {"center_y": .5, "center_x": .5}
font_size: sp(10)
custom_color: get_color_from_hex(colors[app.theme_cls.primary_palette]["300"])
text: "SERVER"
active: False
on_release:
app.sort_Change(self, backdrop_front_layer.data)
MDSeparator:
MDBoxLayout:
size_hint_x: .37
size_hint_x: .4
size_hint_y: .1
MDSeparator:
MDTextButton:
pos_hint: {"center_y": .5, "center_x": .5}
font_size: sp(10)
custom_color: get_color_from_hex(colors[app.theme_cls.primary_palette]["300"])
text: "SIZE"
active: False
on_release:
app.sort_Change(self, backdrop_front_layer.data)
MDSeparator:
MDBoxLayout:
size_hint_x: .31
size_hint_x: .3
size_hint_y: .1
MDSeparator:
MDTextButton:
pos_hint: {"center_y": .5, "center_x": .5}
font_size: sp(10)
custom_color: get_color_from_hex(colors[app.theme_cls.primary_palette]["300"])
text: "TIME"
active: False
on_release:
app.sort_Change(self, backdrop_front_layer.data)


MDSeparator:
MDBoxLayout:
size_hint_x: .24
size_hint_x: .3
size_hint_y: .1
MDSeparator:
MDTextButton:
pos_hint: {"center_y": .5, "center_x": .5}
font_size: sp(10)
custom_color: get_color_from_hex(colors[app.theme_cls.primary_palette]["300"])
text: "SPEED"
active: False
on_release:
app.sort_Change(self, backdrop_front_layer.data)
MDSeparator:
KitchenSinkBackdropFrontLayer:
id: backdrop_front_layer
Expand Down
28 changes: 22 additions & 6 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ def mirrorPic(self):
caller=self.root.ids.Smirror, items=items, width_mult=5,
opening_time=0.2,
use_icon_item=False,
position='bottom',
position='auto',
max_height=0,
callback=self.set_mirror,
)
Expand Down Expand Up @@ -700,12 +700,11 @@ def proxySpeedTest(self, proxys, protocol, mirror):
unsort.append(
{'IP': proxy_ip,
'SIZE': filesizeM,
'TIME': sec_to_mins(delta),
'TIME': delta,
'SPEED': int(speed)}
)
sort = sorted(unsort, key=lambda x: x['SPEED'], reverse=True)
sort = self.sort_Type(unsort)
self.save_UpdateDB(sort)
self.show_List(sort)
self.root.ids.totalpb.value += 1
comP = (self.root.ids.totalpb.value/len(proxys))*100
self.root.ids.totalpbText.text = f"{round(comP)}%"
Expand All @@ -720,19 +719,36 @@ def proxySpeedTest(self, proxys, protocol, mirror):
self.running.get_nowait()
print("Finished!")

def show_List(self, data):
def sort_Change(self, inst, ckid):
if ckid and inst.active:
self.sort_Type(self.data_lists, mode=inst.text, reverse=False)
inst.active = False
elif ckid and inst.active == False:
self.sort_Type(self.data_lists, mode=inst.text, reverse=True)
inst.active = True


def sort_Type(self, unsort, mode='SPEED', reverse=True):
if mode == 'SERVER':mode = 'IP'

sort = sorted(unsort, key=lambda x: x[mode], reverse=reverse)
self.show_List(sort)
return sort

def show_List(self, data):
self.root.ids.backdrop_front_layer.data = []
for parServer in data:
self.root.ids.backdrop_front_layer.data.append(
{
"viewclass": "ProxyShowList",
"text": parServer['IP'],
"text1": f"{parServer['SIZE']} MB",
"text2": parServer['TIME'],
"text2": sec_to_mins(float(parServer['TIME'])),
"text3": f"{size(parServer['SPEED'], system=alternative)}/s",
"on_release": lambda x=parServer['IP']: self.copy_proxyip(x),
}
)
self.data_lists = data
def copy_proxyip(self, data):
toast(f"Copied: {data}")
Clipboard.copy(data)
Expand Down

0 comments on commit 881221e

Please sign in to comment.