Skip to content

Commit fe89929

Browse files
committed
refactor(sample): Update usage details
1 parent cdf3732 commit fe89929

7 files changed

Lines changed: 196 additions & 193 deletions

File tree

‎agentweb-download/src/main/java/com/just/agentweb/download/Extra.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
public class Extra implements Serializable, Cloneable {
3030

3131
/**
32-
* 强制下肢
32+
* 强制下载
3333
*/
3434
protected boolean mIsForceDownload = false;
3535
/**

‎agentweb-download/src/main/java/com/just/agentweb/download/SerialExecutor.java‎

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -27,28 +27,30 @@
2727
* @since 1.0.0
2828
*/
2929
public class SerialExecutor implements Executor {
30-
static final Executor THREAD_POOL_EXECUTOR = AsyncTask.THREAD_POOL_EXECUTOR;
31-
final ArrayDeque<Runnable> mTasks = new ArrayDeque<Runnable>();
32-
Runnable mActive;
30+
static final Executor THREAD_POOL_EXECUTOR = AsyncTask.THREAD_POOL_EXECUTOR;
31+
final ArrayDeque<Runnable> mTasks = new ArrayDeque<Runnable>();
32+
Runnable mActive;
3333

34-
public synchronized void execute(final Runnable r) {
35-
mTasks.offer(new Runnable() {
36-
public void run() {
37-
try {
38-
r.run();
39-
} finally {
40-
scheduleNext();
41-
}
42-
}
43-
});
44-
if (mActive == null) {
45-
scheduleNext();
46-
}
47-
}
34+
@Override
35+
public synchronized void execute(final Runnable r) {
36+
mTasks.offer(new Runnable() {
37+
@Override
38+
public void run() {
39+
try {
40+
r.run();
41+
} finally {
42+
scheduleNext();
43+
}
44+
}
45+
});
46+
if (mActive == null) {
47+
scheduleNext();
48+
}
49+
}
4850

49-
protected synchronized void scheduleNext() {
50-
if ((mActive = mTasks.poll()) != null) {
51-
THREAD_POOL_EXECUTOR.execute(mActive);
52-
}
53-
}
51+
protected synchronized void scheduleNext() {
52+
if ((mActive = mTasks.poll()) != null) {
53+
THREAD_POOL_EXECUTOR.execute(mActive);
54+
}
55+
}
5456
}

‎sample/src/main/java/com/just/agentweb/sample/fragment/BounceWebFragment.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ public class BounceWebFragment extends AgentWebFragment {
2626
public static BounceWebFragment getInstance(Bundle bundle) {
2727

2828
BounceWebFragment mBounceWebFragment = new BounceWebFragment();
29-
if (mBounceWebFragment != null)
29+
if (mBounceWebFragment != null){
3030
mBounceWebFragment.setArguments(bundle);
31-
31+
}
3232
return mBounceWebFragment;
3333
}
3434

‎sample/src/main/java/com/just/agentweb/sample/fragment/CustomIndicatorFragment.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@
1919
public class CustomIndicatorFragment extends AgentWebFragment {
2020
public static CustomIndicatorFragment getInstance(Bundle bundle) {
2121
CustomIndicatorFragment mCustomIndicatorFragment = new CustomIndicatorFragment();
22-
if (bundle != null)
22+
if (bundle != null){
2323
mCustomIndicatorFragment.setArguments(bundle);
24+
}
2425
return mCustomIndicatorFragment;
2526
}
2627

‎sample/src/main/java/com/just/agentweb/sample/fragment/CustomSettingsFragment.java‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,13 @@ public class CustomSettingsFragment extends AgentWebFragment {
1515
public static AgentWebFragment getInstance(Bundle bundle) {
1616

1717
CustomSettingsFragment mCustomSettingsFragment = new CustomSettingsFragment();
18-
if (bundle != null)
18+
if (bundle != null){
1919
mCustomSettingsFragment.setArguments(bundle);
20-
20+
}
2121
return mCustomSettingsFragment;
2222

2323
}
2424

25-
2625
@Override
2726
public IAgentWebSettings getSettings() {
2827
return new CustomSettings();

‎sample/src/main/java/com/just/agentweb/sample/fragment/CustomWebViewFragment.java‎

Lines changed: 86 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -24,90 +24,90 @@
2424
public class CustomWebViewFragment extends AgentWebFragment {
2525

2626

27-
private MarkdownView mMarkdownWebView;
28-
private EditText markdownEditText;
29-
30-
public static final CustomWebViewFragment getInstance(Bundle bundle){
31-
32-
CustomWebViewFragment mCustomWebViewFragment=new CustomWebViewFragment();
33-
if(bundle!=null)
34-
mCustomWebViewFragment.setArguments(bundle);
35-
return mCustomWebViewFragment;
36-
}
37-
38-
@Nullable
39-
@Override
40-
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
41-
return inflater.inflate(R.layout.markdown_view, container, false);
42-
}
43-
@Override
44-
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
45-
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_UNSPECIFIED);
46-
//MarkdownView 是 WebView 的一个子类
47-
mMarkdownWebView = new MarkdownView(getActivity());
48-
markdownEditText = (EditText) view.findViewById(R.id.markdownText);
49-
50-
LinearLayout.LayoutParams lp=new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,0);
51-
lp.weight=1f;
52-
mAgentWeb = AgentWeb.with(this)//
53-
.setAgentWebParent((ViewGroup) view, lp)//
54-
.closeIndicator()//
55-
.setWebViewClient(mWebViewClient)
56-
.setWebView(mMarkdownWebView)
57-
.setSecurityType(AgentWeb.SecurityType.STRICT_CHECK)
58-
.createAgentWeb()//
59-
.ready()//
60-
.go(null);
61-
62-
63-
64-
65-
String text="## AgentWeb 功能\n" +
66-
"***\n\n" +
67-
"1. 支持进度条以及自定义进度条\n" +
68-
"2. 支持文件下载\n" +
69-
"3. 支持文件下载断点续传\n" +
70-
"4. 支持下载通知形式提示进度\n" +
71-
"5. 简化 Javascript 通信 \n" +
72-
"6. 支持 Android 4.4 Kitkat 以及其他版本文件上传\n" +
73-
"7. 支持注入 Cookies\n" +
74-
"8. 加强 Web 安全\n" +
75-
"9. 支持全屏播放视频\n" +
76-
"10. 兼容低版本 Js 安全通信\n" +
77-
"11. 更省电 。\n" +
78-
"12. 支持调起微信支付\n" +
79-
"13. 支持调起支付宝(请参照sample)\n" +
80-
"14. 默认支持定位";
81-
82-
markdownEditText.setText(text);
83-
84-
updateMarkdownView();
85-
86-
markdownEditText.addTextChangedListener(new TextWatcher() {
87-
88-
89-
90-
@Override
91-
public void afterTextChanged(Editable s) {
92-
93-
}
94-
95-
@Override
96-
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
97-
98-
@Override
99-
public void onTextChanged(CharSequence s, int start, int before, int count) {
100-
updateMarkdownView();
101-
}
102-
});
103-
104-
105-
initView(view);
106-
107-
}
108-
109-
110-
private void updateMarkdownView() {
111-
mMarkdownWebView.loadMarkdown(markdownEditText.getText().toString());
112-
}
27+
private MarkdownView mMarkdownWebView;
28+
private EditText markdownEditText;
29+
30+
public static final CustomWebViewFragment getInstance(Bundle bundle) {
31+
32+
CustomWebViewFragment mCustomWebViewFragment = new CustomWebViewFragment();
33+
if (bundle != null) {
34+
mCustomWebViewFragment.setArguments(bundle);
35+
}
36+
return mCustomWebViewFragment;
37+
}
38+
39+
@Nullable
40+
@Override
41+
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
42+
return inflater.inflate(R.layout.markdown_view, container, false);
43+
}
44+
45+
@Override
46+
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
47+
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_UNSPECIFIED);
48+
//MarkdownView 是 WebView 的一个子类
49+
mMarkdownWebView = new MarkdownView(getActivity());
50+
markdownEditText = (EditText) view.findViewById(R.id.markdownText);
51+
52+
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0);
53+
lp.weight = 1f;
54+
mAgentWeb = AgentWeb.with(this)//
55+
.setAgentWebParent((ViewGroup) view, lp)//
56+
.closeIndicator()//
57+
.setWebViewClient(mWebViewClient)
58+
.setWebView(mMarkdownWebView)
59+
.setSecurityType(AgentWeb.SecurityType.STRICT_CHECK)
60+
.createAgentWeb()//
61+
.ready()//
62+
.go(null);
63+
64+
65+
String text = "## AgentWeb 功能\n" +
66+
"***\n\n" +
67+
"1. 支持进度条以及自定义进度条\n" +
68+
"2. 支持文件下载\n" +
69+
"3. 支持文件下载断点续传\n" +
70+
"4. 支持下载通知形式提示进度\n" +
71+
"5. 简化 Javascript 通信 \n" +
72+
"6. 支持 Android 4.4 Kitkat 以及其他版本文件上传\n" +
73+
"7. 支持注入 Cookies\n" +
74+
"8. 加强 Web 安全\n" +
75+
"9. 支持全屏播放视频\n" +
76+
"10. 兼容低版本 Js 安全通信\n" +
77+
"11. 更省电 。\n" +
78+
"12. 支持调起微信支付\n" +
79+
"13. 支持调起支付宝(请参照sample)\n" +
80+
"14. 默认支持定位";
81+
82+
markdownEditText.setText(text);
83+
84+
updateMarkdownView();
85+
86+
markdownEditText.addTextChangedListener(new TextWatcher() {
87+
88+
89+
@Override
90+
public void afterTextChanged(Editable s) {
91+
92+
}
93+
94+
@Override
95+
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
96+
}
97+
98+
@Override
99+
public void onTextChanged(CharSequence s, int start, int before, int count) {
100+
updateMarkdownView();
101+
}
102+
});
103+
104+
105+
initView(view);
106+
107+
}
108+
109+
110+
private void updateMarkdownView() {
111+
mMarkdownWebView.loadMarkdown(markdownEditText.getText().toString());
112+
}
113113
}

0 commit comments

Comments
 (0)