Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fastdevelop
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
高超
fastdevelop
Commits
9cc36a03
Commit
9cc36a03
authored
Apr 04, 2019
by
gao.chao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
组件化工具-延时回调
parent
3d9d83f3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
77 additions
and
32 deletions
+77
-32
app/src/main/java/com/mayi/demo/FunctionActivity.java
+16
-12
call/src/main/java/com/gc/call/CallManage.java
+60
-19
map/src/main/java/com/mayi/fastdevelop/map/LocationUtils.java
+1
-1
No files found.
app/src/main/java/com/mayi/demo/FunctionActivity.java
View file @
9cc36a03
...
@@ -5,10 +5,14 @@ import android.support.annotation.Nullable;
...
@@ -5,10 +5,14 @@ import android.support.annotation.Nullable;
import
android.view.View
;
import
android.view.View
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.gc.call.CallConstant
;
import
com.gc.call.CallManage
;
import
com.gc.call.CallParticipationBean
;
import
com.gc.call.CallReturnBean
;
import
com.gc.call.CallReturnListener
;
import
com.mayi.fastdevelop.base.BaseAPI
;
import
com.mayi.fastdevelop.base.BaseAPI
;
import
com.mayi.fastdevelop.base.BaseActivity
;
import
com.mayi.fastdevelop.base.BaseActivity
;
import
com.mayi.fastdevelop.base.BasePresenter
;
import
com.mayi.fastdevelop.base.BasePresenter
;
import
com.mayi.fastdevelop.bean.LocationBean
;
import
com.mayi.fastdevelop.bean.UserInfo
;
import
com.mayi.fastdevelop.bean.UserInfo
;
import
com.mayi.fastdevelop.comnon.Constant
;
import
com.mayi.fastdevelop.comnon.Constant
;
import
com.mayi.fastdevelop.okhttp.NetWorkBuilder
;
import
com.mayi.fastdevelop.okhttp.NetWorkBuilder
;
...
@@ -102,17 +106,17 @@ public class FunctionActivity extends BaseActivity {
...
@@ -102,17 +106,17 @@ public class FunctionActivity extends BaseActivity {
findViewById
(
R
.
id
.
b8
).
setOnClickListener
(
new
OnMultiClickListener
()
{
findViewById
(
R
.
id
.
b8
).
setOnClickListener
(
new
OnMultiClickListener
()
{
@Override
@Override
public
void
onMultiClick
(
View
v
)
{
public
void
onMultiClick
(
View
v
)
{
// LocationUtils.startLocation(v.getContext(), new LocationUtils.LocationCallback() {
CallParticipationBean
bean
=
new
CallParticipationBean
();
// @Override
bean
.
setTag
(
"map_location"
);
// public void onFail(String msg) {
bean
.
setContext
(
FunctionActivity
.
this
);
// showToast(msg
);
bean
.
setLooper
(
CallConstant
.
LOOPER_NO_MAIN
);
// }
bean
.
setListener
(
new
CallReturnListener
()
{
//
@Override
// @Override
public
void
onReturn
(
CallReturnBean
bean
)
{
// public void onSuccess(LocationBean bean) {
showToast
(
JSON
.
toJSONString
(
bean
));
// showToast(JSON.toJSONString(bean));
}
// }
});
// }
);
CallManage
.
getInstance
().
handleTarget
(
bean
);
}
}
});
});
}
}
...
...
call/src/main/java/com/gc/call/CallManage.java
View file @
9cc36a03
...
@@ -28,6 +28,7 @@ public class CallManage {
...
@@ -28,6 +28,7 @@ public class CallManage {
map
.
put
(
callTarget
.
getTag
(),
callTarget
);
map
.
put
(
callTarget
.
getTag
(),
callTarget
);
}
}
//处理call
public
void
handleTarget
(
final
CallParticipationBean
bean
)
{
public
void
handleTarget
(
final
CallParticipationBean
bean
)
{
Log
.
i
(
TAG
,
"handleTarget:"
+
bean
.
getTag
());
Log
.
i
(
TAG
,
"handleTarget:"
+
bean
.
getTag
());
CallTarget
callTarget
=
map
.
get
(
bean
.
getTag
());
CallTarget
callTarget
=
map
.
get
(
bean
.
getTag
());
...
@@ -37,31 +38,86 @@ public class CallManage {
...
@@ -37,31 +38,86 @@ public class CallManage {
callReturn
.
setMsg
(
"没有找到对应的CallTarget"
);
callReturn
.
setMsg
(
"没有找到对应的CallTarget"
);
callReturn
.
setCode
(
CallConstant
.
CODE_NO_TARGET
);
callReturn
.
setCode
(
CallConstant
.
CODE_NO_TARGET
);
bean
.
getListener
().
onReturn
(
callReturn
);
bean
.
getListener
().
onReturn
(
callReturn
);
bean
.
getListener
().
onReturn
(
callReturn
);
}
}
}
else
{
}
else
{
if
(
callTarget
instanceof
CallImmediatelyHandlerTarget
)
{
if
(
callTarget
instanceof
CallImmediatelyHandlerTarget
)
{
onImmediatelyHandler
(
bean
,
(
CallImmediatelyHandlerTarget
)
callTarget
);
onImmediatelyHandler
(
bean
,
(
CallImmediatelyHandlerTarget
)
callTarget
);
}
else
if
(
callTarget
instanceof
CallTimeHandTarget
)
{
}
else
if
(
callTarget
instanceof
CallTimeHandTarget
)
{
onTimeHandHandler
(
bean
,
(
CallTimeHandTarget
)
callTarget
);
}
}
}
}
}
}
private
void
onImmediatelyHandler
(
final
CallParticipationBean
bean
,
final
CallImmediatelyHandlerTarget
target
)
{
//处理耗时不能立刻返回的call
private
void
onTimeHandHandler
(
final
CallParticipationBean
bean
,
final
CallTimeHandTarget
target
)
{
handler
.
post
(
new
Runnable
()
{
handler
.
post
(
new
Runnable
()
{
@Override
@Override
public
void
run
()
{
public
void
run
()
{
if
(
bean
.
getLooper
()
==
CallConstant
.
LOOPER_MAIN
)
{
if
(
bean
.
getLooper
()
==
CallConstant
.
LOOPER_MAIN
)
{
target
.
delayProcessing
(
bean
,
new
CallTimeHandlerListener
()
{
@Override
public
void
timeHandler
(
CallReturnBean
c
)
{
if
(
bean
.
getListener
()
!=
null
)
{
bean
.
getListener
().
onReturn
(
c
);
}
}
});
}
else
if
(
bean
.
getLooper
()
==
CallConstant
.
LOOPER_NO_MAIN
)
{
AsyncTask
asyncTask
=
new
AsyncTask
()
{
@Override
protected
Object
doInBackground
(
Object
[]
objects
)
{
target
.
delayProcessing
(
bean
,
new
CallTimeHandlerListener
()
{
@Override
public
void
timeHandler
(
CallReturnBean
c
)
{
if
(
bean
.
getListener
()
!=
null
)
{
bean
.
getListener
().
onReturn
(
c
);
}
}
});
return
null
;
}
};
asyncTask
.
execute
();
}
else
if
(
bean
.
getLooper
()
==
CallConstant
.
LOOPER_NO_MAIN_HANDLER_AND_MIAN_RETURN
)
{
AsyncTask
asyncTask
=
new
AsyncTask
()
{
@Override
protected
CallReturnBean
doInBackground
(
Object
[]
objects
)
{
target
.
delayProcessing
(
bean
,
new
CallTimeHandlerListener
()
{
@Override
public
void
timeHandler
(
final
CallReturnBean
c
)
{
handler
.
post
(
new
Runnable
()
{
handler
.
post
(
new
Runnable
()
{
@Override
@Override
public
void
run
()
{
public
void
run
()
{
CallReturnBean
c
=
target
.
onHandle
(
bean
);
if
(
bean
.
getListener
()
!=
null
)
{
if
(
bean
.
getListener
()
!=
null
)
{
bean
.
getListener
().
onReturn
(
c
);
bean
.
getListener
().
onReturn
(
c
);
}
}
}
}
});
});
}
});
return
null
;
}
};
asyncTask
.
execute
();
}
}
});
}
//处理不耗时能立刻返回的call
private
void
onImmediatelyHandler
(
final
CallParticipationBean
bean
,
final
CallImmediatelyHandlerTarget
target
)
{
handler
.
post
(
new
Runnable
()
{
@Override
public
void
run
()
{
if
(
bean
.
getLooper
()
==
CallConstant
.
LOOPER_MAIN
)
{
CallReturnBean
c
=
target
.
onHandle
(
bean
);
if
(
bean
.
getListener
()
!=
null
)
{
bean
.
getListener
().
onReturn
(
c
);
}
}
else
if
(
bean
.
getLooper
()
==
CallConstant
.
LOOPER_NO_MAIN
)
{
}
else
if
(
bean
.
getLooper
()
==
CallConstant
.
LOOPER_NO_MAIN
)
{
AsyncTask
asyncTask
=
new
AsyncTask
()
{
AsyncTask
asyncTask
=
new
AsyncTask
()
{
@Override
@Override
...
@@ -96,20 +152,5 @@ public class CallManage {
...
@@ -96,20 +152,5 @@ public class CallManage {
});
});
}
}
// private CallReturnBean onImmediatelyHandle(CallParticipationBean bean) {
// CallTarget callTarget = map.get(bean.getTag());
// if (callTarget != null) {
// if (callTarget instanceof CallImmediatelyHandlerTarget) {
// return ((CallImmediatelyHandlerTarget) callTarget).onHandle(bean);
// }
// } else {
// CallReturnBean callReturn = new CallReturnBean();
// callReturn.setMsg("没有找到对应的CallTarget");
// callReturn.setCode(CallConstant.CODE_NO_TARGET);
// bean.getListener().onReturn(callReturn);
// return callReturn;
// }
// return null;
// }
}
}
map/src/main/java/com/mayi/fastdevelop/map/LocationUtils.java
View file @
9cc36a03
...
@@ -20,7 +20,7 @@ public class LocationUtils {
...
@@ -20,7 +20,7 @@ public class LocationUtils {
public
void
onLocationChanged
(
AMapLocation
amapLocation
)
{
public
void
onLocationChanged
(
AMapLocation
amapLocation
)
{
if
(
amapLocation
!=
null
)
{
if
(
amapLocation
!=
null
)
{
if
(
amapLocation
.
getErrorCode
()
==
0
)
{
if
(
amapLocation
.
getErrorCode
()
==
0
)
{
LogUtils
.
e
(
"amapLocation"
+
amapLocation
);
LogUtils
.
i
(
"amapLocation"
+
amapLocation
);
if
(
callback
!=
null
)
{
if
(
callback
!=
null
)
{
LocationBean
bean
=
new
LocationBean
();
LocationBean
bean
=
new
LocationBean
();
bean
.
setAddress
(
amapLocation
.
getAddress
());
bean
.
setAddress
(
amapLocation
.
getAddress
());
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment