Toggle navigation
Toggle navigation
This project
Loading...
Sign in
ios
/
YH_Explorer
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
gaoqiang xu
10 years ago
Commit
c0c307292f9e4ce9add5c169aa87e23c6f873f79
1 parent
fc4a5f1c
优化进度条
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
57 additions
and
14 deletions
YHExplorer/WebProgressView/YHWebViewProgress.m
YHExplorer/WebProgressView/YHWebViewProgressView.m
YHExplorer/YHLinkParser/YHLinkDefaultParser.m
YohoExplorerDemo/YohoExplorerDemo.xcodeproj/xcuserdata/gaoqiangxu.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
YohoExplorerDemo/YohoExplorerDemo/ViewController.m
YHExplorer/WebProgressView/YHWebViewProgress.m
View file @
c0c3072
...
...
@@ -10,9 +10,9 @@
NSString
*
completeRPCURLPath
=
@"/yhwebviewprogressproxy/complete"
;
static
const
float
YHWebViewProgressInitialValue
=
0
.
7
f
;
static
const
float
YHWebViewProgressInteractiveValue
=
0
.
9
f
;
static
const
float
YHWebViewProgressFinalProgressValue
=
0
.
9
f
;
static
const
float
YHWebViewProgressInitialValue
=
0
.
94
f
;
static
const
float
YHWebViewProgressInteractiveValue
=
0
.
95
f
;
static
const
float
YHWebViewProgressFinalProgressValue
=
0
.
96
f
;
@interface
YHWebViewProgress
()
@property
(
nonatomic
)
NSUInteger
loadingCount
;
...
...
@@ -53,10 +53,15 @@ static const float YHWebViewProgressFinalProgressValue = 0.9f;
{
float
progress
=
self
.
progress
;
float
maxProgress
=
self
.
interactive
?
YHWebViewProgressFinalProgressValue
:
YHWebViewProgressInteractiveValue
;
float
remainPercent
=
(
float
)
self
.
loadingCount
/
self
.
maxLoadCount
;
float
increment
=
(
maxProgress
-
progress
)
*
remainPercent
;
progress
+=
increment
;
progress
=
fminf
(
progress
,
maxProgress
);
if
(
self
.
loadingCount
==
0
)
{
progress
=
maxProgress
;
}
else
{
float
remainPercent
=
(
float
)
self
.
loadingCount
/
self
.
maxLoadCount
;
float
increment
=
(
maxProgress
-
progress
)
*
remainPercent
;
progress
+=
increment
;
progress
=
fminf
(
progress
,
maxProgress
);
}
[
self
setProgress
:
progress
];
}
...
...
@@ -133,7 +138,7 @@ static const float YHWebViewProgressFinalProgressValue = 0.9f;
self
.
loadingCount
++
;
self
.
maxLoadCount
=
fmax
(
self
.
loadingCount
,
self
.
loadingCount
)
;
self
.
maxLoadCount
=
self
.
loadingCount
;
[
self
startProgress
];
}
...
...
@@ -172,8 +177,10 @@ static const float YHWebViewProgressFinalProgressValue = 0.9f;
[
self
.
webViewProxy
webView
:
webView
didFailLoadWithError
:
error
];
}
_loadingCount
--
;
[
self
incrementProgress
];
if
(
error
&&
error
.
code
!=
NSURLErrorCancelled
)
{
self
.
loadingCount
--
;
[
self
incrementProgress
];
}
NSString
*
readyState
=
[
webView
stringByEvaluatingJavaScriptFromString
:
@"document.readyState"
];
...
...
@@ -186,7 +193,7 @@ static const float YHWebViewProgressFinalProgressValue = 0.9f;
BOOL
isNotRedirect
=
_currentURL
&&
[
_currentURL
isEqual
:
webView
.
request
.
mainDocumentURL
];
BOOL
complete
=
[
readyState
isEqualToString
:
@"complete"
];
if
((
complete
&&
isNotRedirect
)
||
error
)
{
if
((
complete
&&
isNotRedirect
)
||
(
error
&&
error
.
code
!=
NSURLErrorCancelled
)
)
{
[
self
completeProgress
];
}
}
...
...
YHExplorer/WebProgressView/YHWebViewProgressView.m
View file @
c0c3072
...
...
@@ -113,6 +113,7 @@
self
.
progressBarView
.
alpha
=
1
.
f
;
self
.
progressBarView
.
center
=
positionEnd
;
}
}
else
{
[
UIView
animateWithDuration
:
animated
?
self
.
fadeAnimationDuration
:
0
.
f
delay
:
0
...
...
@@ -125,14 +126,19 @@
CAAnimation
*
animationBounds
=
nil
;
if
(
progress
<
1
)
{
CGFloat
lastProgress
=
_progress
;
if
(
_progress
>
0
.
01
&&
[
self
.
progressBarView
.
layer
animationForKey
:
@"positionAnimation"
])
{
positionBegin
=
[
self
.
progressBarView
.
layer
.
presentationLayer
position
];
self
.
progressBarView
.
layer
.
position
=
positionBegin
;
CAKeyframeAnimation
*
animation
=
(
CAKeyframeAnimation
*
)[
self
.
progressBarView
.
layer
animationForKey
:
@"positionAnimation"
];
lastProgress
=
positionBegin
.
x
/
([[
animation
.
values
lastObject
]
CGPointValue
].
x
-
[[
animation
.
values
firstObject
]
CGPointValue
].
x
);
[
self
.
progressBarView
.
layer
removeAnimationForKey
:
@"positionAnimation"
];
}
CAKeyframeAnimation
*
keyFrameAnimation
=
[
CAKeyframeAnimation
animationWithKeyPath
:
@"position"
];
keyFrameAnimation
.
duration
=
kAnimationDurationMultiplier
*
(
progress
-
_p
rogress
)
*
10
;
keyFrameAnimation
.
duration
=
kAnimationDurationMultiplier
*
(
progress
-
lastP
rogress
)
*
10
;
keyFrameAnimation
.
keyTimes
=
@[
@0
,
@.3
,
@1
];
keyFrameAnimation
.
values
=
@[
[
NSValue
valueWithCGPoint
:
positionBegin
],
[
NSValue
valueWithCGPoint
:
CGPointMake
(
positionBegin
.
x
+
(
positionEnd
.
x
-
positionBegin
.
x
)
*
0
.
9
,
positionEnd
.
y
)],
...
...
@@ -171,6 +177,9 @@
-
(
void
)
animationDidStop
:
(
CAAnimation
*
)
anim
finished
:
(
BOOL
)
flag
{
if
(
!
flag
)
{
return
;
}
_progress
=
0
.
f
;
CABasicAnimation
*
animationOpacity
=
[
CABasicAnimation
animationWithKeyPath
:
@"opacity"
];
animationOpacity
.
fromValue
=
@1
;
...
...
YHExplorer/YHLinkParser/YHLinkDefaultParser.m
View file @
c0c3072
...
...
@@ -38,7 +38,8 @@ NSString * const YHLinkParseResult_OriginalUrlKey = @"YHLinkParseResult_Original
if
(
range
.
location
!=
NSNotFound
)
{
contentString
=
[
contentString
substringFromIndex
:
range
.
location
+
range
.
length
];
freshUrl
=
[
string
substringToIndex
:
range
.
location
];
if
([[
freshUrl
substringWithRange
:
NSMakeRange
(
freshUrl
.
length
-
1
,
1
)]
isEqualToString
:
@"?"
])
{
if
(
freshUrl
.
length
>
0
&&
[[
freshUrl
substringWithRange
:
NSMakeRange
(
freshUrl
.
length
-
1
,
1
)]
isEqualToString
:
@"?"
])
{
freshUrl
=
[
freshUrl
substringToIndex
:
freshUrl
.
length
-
1
];
}
}
else
{
...
...
YohoExplorerDemo/YohoExplorerDemo.xcodeproj/xcuserdata/gaoqiangxu.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
View file @
c0c3072
...
...
@@ -2,4 +2,30 @@
<Bucket
type =
"1"
version =
"2.0"
>
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID =
"Xcode.Breakpoint.FileBreakpoint"
>
<BreakpointContent
shouldBeEnabled =
"Yes"
ignoreCount =
"0"
continueAfterRunningActions =
"Yes"
filePath =
"../YHExplorer/WebProgressView/YHWebViewProgressView.m"
timestampString =
"460284588.269866"
startingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
startingLineNumber =
"91"
endingLineNumber =
"91"
landmarkName =
"-setProgress:animated:"
landmarkType =
"5"
>
<Actions>
<BreakpointActionProxy
ActionExtensionID =
"Xcode.BreakpointAction.DebuggerCommand"
>
<ActionContent
consoleCommand =
"p progress"
>
</ActionContent>
</BreakpointActionProxy>
</Actions>
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
...
...
YohoExplorerDemo/YohoExplorerDemo/ViewController.m
View file @
c0c3072
...
...
@@ -73,7 +73,7 @@
}
else
if
([
title
isEqualToString
:
@"链接跳转"
])
{
wv
.
url
=
@"http://sealedace.com/content/images/test/h5_test.html"
;
}
else
{
wv
.
url
=
@"http://
yohood.test.yoho.cn/brand/index/client/1
"
;
wv
.
url
=
@"http://
m.taobao.com
"
;
}
[
self
.
navigationController
pushViewController
:
wv
animated
:
YES
];
...
...
Please
register
or
login
to post a comment