Add update method to IOsmAndAidlCallback
This commit is contained in:
parent
eb5969ecb5
commit
7c6344b197
8 changed files with 55 additions and 1 deletions
|
@ -4,4 +4,6 @@ import net.osmand.aidl.search.SearchResult;
|
|||
|
||||
interface IOsmAndAidlCallback {
|
||||
void onSearchComplete(in List<SearchResult> resultSet);
|
||||
|
||||
void startUpdate();
|
||||
}
|
|
@ -128,4 +128,6 @@ interface IOsmAndAidlInterface {
|
|||
boolean unmuteNavigation(in UnmuteNavigationParams params);
|
||||
|
||||
boolean search(in SearchParams params, IOsmAndAidlCallback callback);
|
||||
|
||||
boolean update(in IOsmAndAidlCallback callback);
|
||||
}
|
|
@ -79,12 +79,28 @@ class OsmandAidlHelper(private val app: TelegramApplication) {
|
|||
mSearchCompleteListener!!.onSearchComplete(resultSet)
|
||||
}
|
||||
}
|
||||
@Throws(RemoteException::class)
|
||||
override fun startUpdate() {
|
||||
if (mUpdateCompleteListener != null) {
|
||||
mUpdateCompleteListener!!.onUpdateComplete()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun setSearchCompleteListener(mSearchCompleteListener: SearchCompleteListener) {
|
||||
this.mSearchCompleteListener = mSearchCompleteListener
|
||||
}
|
||||
|
||||
private var mUpdateCompleteListener: UpdateCompleteListener? = null
|
||||
|
||||
interface UpdateCompleteListener {
|
||||
fun onUpdateComplete()
|
||||
}
|
||||
|
||||
fun setSearchCompleteListener(mUpdateCompleteListener: UpdateCompleteListener) {
|
||||
this.mUpdateCompleteListener = mUpdateCompleteListener
|
||||
}
|
||||
|
||||
/**
|
||||
* Class for interacting with the main interface of the service.
|
||||
*/
|
||||
|
@ -1007,4 +1023,16 @@ class OsmandAidlHelper(private val app: TelegramApplication) {
|
|||
}
|
||||
return false
|
||||
}
|
||||
|
||||
fun update(): Boolean {
|
||||
if (mIOsmAndAidlInterface != null) {
|
||||
try {
|
||||
return mIOsmAndAidlInterface!!.update(mIOsmAndAidlCallback)
|
||||
} catch (e: RemoteException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -130,7 +130,11 @@ class MyLocationTabFragment : Fragment(), TelegramListener {
|
|||
setupOptionsBtn(mainView.findViewById<ImageView>(R.id.options_title))
|
||||
}
|
||||
|
||||
imageContainer = mainView.findViewById<FrameLayout>(R.id.image_container)
|
||||
imageContainer = mainView.findViewById<FrameLayout>(R.id.image_container).apply {
|
||||
setOnClickListener {
|
||||
app.osmandAidlHelper.update()
|
||||
}
|
||||
}
|
||||
titleContainer = mainView.findViewById<LinearLayout>(R.id.title_container).apply {
|
||||
AndroidUtils.addStatusBarPadding19v(context, this)
|
||||
}
|
||||
|
|
|
@ -4,4 +4,6 @@ import net.osmand.aidl.search.SearchResult;
|
|||
|
||||
interface IOsmAndAidlCallback {
|
||||
void onSearchComplete(in List<SearchResult> resultSet);
|
||||
|
||||
void startUpdate();
|
||||
}
|
|
@ -128,4 +128,6 @@ interface IOsmAndAidlInterface {
|
|||
boolean unmuteNavigation(in UnmuteNavigationParams params);
|
||||
|
||||
boolean search(in SearchParams params, IOsmAndAidlCallback callback);
|
||||
|
||||
boolean update(in IOsmAndAidlCallback callback);
|
||||
}
|
|
@ -1552,4 +1552,8 @@ public class OsmandAidlApi {
|
|||
public interface SearchCompleteCallback {
|
||||
void onSearchComplete(List<SearchResult> resultSet);
|
||||
}
|
||||
|
||||
public interface UpdateCompleteCallback {
|
||||
void onUpdateComplete();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,6 +69,7 @@ public class OsmandAidlService extends Service {
|
|||
private static final Log LOG = PlatformUtil.getLog(OsmandAidlService.class);
|
||||
|
||||
private static final int MSG_RUN_SEARCH = 53;
|
||||
private static final int MSG_UPDATE = 54;
|
||||
private static final String DATA_KEY_RESULT_SET = "resultSet";
|
||||
|
||||
private ArrayList<IOsmAndAidlCallback> mRemoteCallbacks;
|
||||
|
@ -571,6 +572,15 @@ public class OsmandAidlService extends Service {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(IOsmAndAidlCallback callback) throws RemoteException {
|
||||
if (callback != null) {
|
||||
getApp().showShortToastMessage(callback.toString());
|
||||
callback.startUpdate();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue