{"id":224289,"date":"2014-05-27T13:57:03","date_gmt":"2014-05-27T09:57:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=224289"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=224289","title":{"rendered":"<span class=\"post_title\">\u041d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 MarkerInfoWindow \u0434\u043b\u044f osmdroid<\/span>"},"content":{"rendered":"<div class=\"content html_format\">     \t\u0421\u0442\u0430\u0442\u044c\u044f \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0430 \u0434\u043b\u044f \u0442\u0435\u0445, \u0443 \u043a\u043e\u0433\u043e \u0442\u0440\u0443\u0434\u043d\u043e\u0441\u0442\u0438 \u0441 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c infoWindow \u0432 osmdroid \u0438 \u0440\u0430\u0431\u043e\u0442\u043e\u0439 \u0441 AsyncTask \u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u0440\u0430\u043d\u044c\u0448\u0435 \u043d\u0435 \u0434\u0435\u043b\u0430\u043b \u043d\u0438\u0447\u0435\u0433\u043e \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0433\u043e \ud83d\ude42 \u0417\u0434\u0435\u0441\u044c \u044f \u043f\u0438\u0441\u0430\u043b \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u044f \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u043b \u043e\u043a\u043e\u0448\u043a\u043e \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0431 \u0430\u0432\u0442\u043e\u043c\u043e\u0431\u0438\u043b\u0435 \u0432 \u0441\u0435\u0440\u0432\u0438\u0441\u0435 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442\u0430.<br \/>  \u0421\u0443\u0442\u044c \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0440\u0438 \u043d\u0430\u0436\u0430\u0442\u0438\u0438 \u043d\u0430 \u043c\u0430\u0440\u043a\u0435\u0440, \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0431\u0435\u0440\u0443\u0442\u0441\u044f \u0438\u0437 \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u0434\u0440\u0443\u0433\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u0434\u0433\u0440\u0443\u0436\u0430\u044e\u0442\u0441\u044f \u0438\u0437 API, \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0432 \u0411\u0414 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u044e\u0442\u0441\u044f \u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u0435 InfoWindow.<br \/>  \u041d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u0441 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f xml \u0444\u0430\u0439\u043b\u0430 \u0441 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c infoWindow, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u043e\u043b\u044f \u0441 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430\u043c\u0438 \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u0435\u0432 \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442\u0430.<br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/168\/089\/61b\/16808961b3c37c5c7df9cecdde56971e.jpg\" alt=\"image\"\/><br \/>  MarkerInfoWindow \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0432 Title, Description, Subdescription, \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0442\u043e\u043b\u044c\u043a\u043e Descripton \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043d\u0443\u0436\u043d\u044b\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439. \u0411\u0443\u0434\u0435\u043c \u0432\u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0442\u0443\u0434\u0430 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0432\u0438\u0434\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0441 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0430\u043c\u0438.<br \/>  \u0420\u0430\u0437\u043c\u0435\u0442\u043a\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:  <\/p>\n<pre><code class=\"java\">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt; &lt;LinearLayout xmlns:android=&quot;http:\/\/schemas.android.com\/apk\/res\/android&quot;     android:layout_width=&quot;wrap_content&quot;     android:layout_height=&quot;wrap_content&quot;     android:orientation=&quot;horizontal&quot;     android:background=&quot;@drawable\/balloon_overlay_white&quot; &gt;     &lt;ImageView android:id=&quot;@+id\/bubble_image&quot;         android:layout_width=&quot;65dp&quot;         android:layout_height=&quot;65dp&quot;         android:visibility=&quot;gone&quot; \/&gt;     &lt;RelativeLayout         android:layout_width=&quot;wrap_content&quot;         android:layout_height=&quot;wrap_content&quot;         android:paddingLeft=&quot;5dp&quot;         android:orientation=&quot;vertical&quot; &gt;             &lt;TextView android:id=&quot;@+id\/bubble_title&quot;                 android:layout_width=&quot;wrap_content&quot;                 android:layout_height=&quot;wrap_content&quot;                 android:textColor=&quot;#000000&quot;                 android:maxEms=&quot;17&quot;                 android:layout_gravity=&quot;left&quot;                 android:layout_weight=&quot;1&quot;                 android:text=&quot;Title&quot;                 android:textSize=&quot;18dp&quot;                 android:textIsSelectable=&quot;false&quot; \/&gt;             &lt;Button android:id=&quot;@+id\/bubble_moreinfo&quot;                 android:background=&quot;@drawable\/btn_moreinfo&quot;                 android:visibility=&quot;gone&quot;                 android:layout_width=&quot;wrap_content&quot;                 android:layout_height=&quot;wrap_content&quot;                 android:layout_gravity=&quot;right&quot;                 android:layout_weight=&quot;0&quot; \/&gt;         &lt;TextView android:id=&quot;@+id\/bubble_description&quot;             android:layout_width=&quot;wrap_content&quot;             android:layout_height=&quot;wrap_content&quot;             android:textSize=&quot;14dp&quot;             android:maxEms=&quot;17&quot;             android:text=&quot;Description&quot;             android:layout_toRightOf=&quot;@+id\/model&quot;             android:layout_below=&quot;@+id\/bubble_title&quot;             android:lineSpacingExtra=&quot;3dp&quot;             android:layout_marginLeft=&quot;3dp&quot; \/&gt;         &lt;TextView android:id=&quot;@+id\/model&quot;             android:layout_width=&quot;wrap_content&quot;             android:layout_height=&quot;wrap_content&quot;             android:textColor=&quot;#ff6c6c6c&quot;             android:textSize=&quot;14dp&quot;             android:maxEms=&quot;17&quot;             android:text=&quot;@string\/model&quot;             android:layout_below=&quot;@+id\/bubble_title&quot;             android:layout_alignRight=&quot;@+id\/organization&quot; \/&gt;         &lt;TextView android:id=&quot;@+id\/group&quot;             android:layout_width=&quot;wrap_content&quot;             android:layout_height=&quot;wrap_content&quot;             android:textColor=&quot;#ff6c6c6c&quot;             android:textSize=&quot;14dp&quot;             android:maxEms=&quot;17&quot;             android:text=&quot;@string\/group&quot;             android:layout_below=&quot;@+id\/model&quot;             android:layout_alignRight=&quot;@+id\/organization&quot; \/&gt;         &lt;TextView android:id=&quot;@+id\/organization&quot;             android:layout_width=&quot;wrap_content&quot;             android:layout_height=&quot;wrap_content&quot;             android:textColor=&quot;#ff6c6c6c&quot;             android:textSize=&quot;14dp&quot;             android:maxEms=&quot;17&quot;             android:text=&quot;@string\/organization&quot;             android:layout_below=&quot;@+id\/group&quot; \/&gt;         &lt;TextView android:id=&quot;@+id\/speed&quot;             android:layout_width=&quot;wrap_content&quot;             android:layout_height=&quot;wrap_content&quot;             android:textColor=&quot;#ff6c6c6c&quot;             android:textSize=&quot;14dp&quot;             android:maxEms=&quot;17&quot;             android:text=&quot;@string\/speed&quot;             android:layout_below=&quot;@+id\/organization&quot;             android:layout_alignRight=&quot;@+id\/organization&quot; \/&gt;         &lt;TextView android:id=&quot;@+id\/update&quot;             android:layout_width=&quot;wrap_content&quot;             android:layout_height=&quot;wrap_content&quot;             android:textColor=&quot;#ff6c6c6c&quot;             android:textSize=&quot;14dp&quot;             android:maxEms=&quot;17&quot;             android:text=&quot;@string\/update&quot;             android:layout_below=&quot;@+id\/speed&quot;             android:layout_alignRight=&quot;@+id\/organization&quot; \/&gt;         &lt;TextView android:id=&quot;@+id\/bubble_subdescription&quot;             android:layout_width=&quot;wrap_content&quot;             android:layout_height=&quot;wrap_content&quot;             android:textColor=&quot;#000000&quot;             android:textSize=&quot;10dp&quot;             android:maxEms=&quot;17&quot;             android:text=&quot;Address&quot;             android:layout_below=&quot;@+id\/update&quot; \/&gt;     &lt;\/RelativeLayout&gt; &lt;\/LinearLayout&gt; <\/code><\/pre>\n<p>  \u0414\u0430\u043b\u0435\u0435, \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043d\u0443\u0436\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u043f\u0438\u0448\u0435\u043c \u0441\u0432\u043e\u0439 \u043a\u043b\u0430\u0441\u0441 CarInfoWindow:  <\/p>\n<pre><code class=\"java\">public class CarInfoWindow extends MarkerInfoWindow {      Car mCar;     Marker mMarker;     CarInfoTask carInfoTask;     Boolean stopped = false;     Drawable icon;     String active;      public CarInfoWindow(int layoutResId, MapView mapView) {         super(layoutResId, mapView);     }     \/\/\u043f\u0440\u0438 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c asyncTask     @Override     public void onOpen(final Object item) {         if (!stopped) {             carInfoTask = new CarInfoTask();             carInfoTask.execute(item);         }         super.onOpen(item);     }     \/\/\u043f\u0440\u0438 \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u0438 \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u0438\u043a\u043e\u043d\u043a\u0443 \u043c\u0430\u0440\u043a\u0435\u0440\u0430     @Override     public void onClose() {         stopped = false;         super.onClose();          if (!(mCar.getLastUpdate() == null)) {             if (((System.currentTimeMillis() - Long.parseLong(mCar.getLastUpdate())) \/ 3600000) &gt; 1) {                 active = &quot;0&quot;; \/\/car is not active             }             else {                 active = &quot;1&quot;;             }         }         String fileName = Environment.getExternalStorageDirectory()+&quot;\/automap\/cars\/icons\/&quot;+mCar.getIconIndex()+&quot;\/&quot;+active+&quot;\/icon.png&quot;;         icon = Utils.loadIcon(fileName, Float.parseFloat(mCar.getDirection()), mCar.getIconType());         mMarker.setIcon(icon);     }  \t     class CarInfoTask extends AsyncTask&lt;Object, String, Void&gt; {          @Override         protected void onPreExecute() {             super.onPreExecute();         }  \t\t         @Override         \/\/\u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043f\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u044d\u0442\u043e\u043c \u043c\u0435\u0442\u043e\u0434\u0435         protected Void doInBackground(Object... params) {             try { \t\t\/\/\u0437\u0430\u0434\u0430\u0435\u043c \u043d\u0443\u0436\u043d\u044b\u0439 \u043c\u0430\u0440\u043a\u0435\u0440, \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d \u043e\u0431\u044a\u0435\u043a\u0442 Car \u0441 \u043d\u0443\u0436\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438                 mMarker = (Marker)params[0];                 mCar = (Car) mMarker.getRelatedObject(); \t\t\/\/\u0414\u0430\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0432 infoWindow                 String markName;                 String carModelName;                 String groupName;                 String carLastUpdate;                 Context context = getView().getContext();                  \/\/\u0431\u0435\u0440\u0435\u043c token, \u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u043e\u0431\u044a\u0435\u043a\u0442\u0430                 Token token = Prefs.getToken(getView().getContext());                 String markId = mCar.getMarkId();                 String modelId = mCar.getModelId();                 String orgId = mCar.getOrganizationId();                 String groupId = mCar.getGroupId();                 carLastUpdate = mCar.getLastUpdate();  \t\t\/\/\u0447\u0442\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u0434\u0435\u043b\u0430\u0435\u043c                 String formattedDate = &quot;&quot;;                 if (!(carLastUpdate == null)) {                     long unixSeconds = Long.parseLong(carLastUpdate);                     Date date = new Date(unixSeconds);                     SimpleDateFormat sdf = new SimpleDateFormat(&quot;dd.MM.yyyy  HH:mm:ss &quot;);                     formattedDate = sdf.format(date);                 }                  String organizationName = DbHelper.getInstance(context).getOrganizationStatById(orgId).getName();                 List&lt;Mark&gt; marksList = null;                 List&lt;CarModel&gt; carModelsList = null;                 List&lt;Group&gt; groupsList = null; \t\t\t\t                 \/\/\u0434\u0435\u043b\u0430\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441 \u0432 API, \u0431\u0435\u0440\u0435\u043c mark \u0438 model \u043f\u043e id                 try {                     \/\/\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c retrofit                     carModelsList = Api.getService(context).getModels(token.getValue(), markId);                      int size = carModelsList.size();                     for (int i=0; i&lt;size; i++) {                         \/\/\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c cupboard \u0434\u043b\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0411\u0414                         DbHelper.getInstance(context).insertCarModels(carModelsList.get(i));                      }                      groupsList = Api.getService(context).getGroups(token.getValue(), orgId);                     size = groupsList.size();                     for (int i=0; i&lt;size; i++) {                         DbHelper.getInstance(context).insertGroups(groupsList.get(i));                     }                  } catch (Exception e) {                     e.printStackTrace();                 }                 markName = DbHelper.getInstance(context).getMarkById(markId).getName();                 carModelName = DbHelper.getInstance(context).getCarModelById(modelId).getName();                 groupName = DbHelper.getInstance(context).getGroupById(groupId).getName(); \t\t\t\t                 \/\/\u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u043d\u0443\u0436\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u044e\u0434\u0430 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0432 UI.                  publishProgress(organizationName, markName, carModelName, groupName, formattedDate);  \t\t\t\t\/\/values[0] = organizationName, values[1] = markName \u0438 \u0442.\u0434.              } catch (Exception e) {                 e.printStackTrace();             }             return null;         }          @Override         protected void onProgressUpdate(String... values) {             super.onProgressUpdate(values);             \/\/\u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 textView, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u044b\u043b\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u043e\u043c publishProgress()             mMarker.hideInfoWindow();             mMarker.setTitle(mCar.getCarNo() + &quot; (&quot; + values[1] + &quot;)&quot;);             mMarker.setSnippet(                     values[2] + &quot;\\n&quot; +                     values[3] + &quot;\\n&quot; +                     values[0] + &quot;\\n&quot; +                     mCar.getSpeed() + &quot;\\n&quot; +                     values[4]             );             mMarker.setSubDescription(&quot;&quot;);              \/\/\u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u0438\u043a\u043e\u043d\u043a\u0443 \u043c\u0430\u0440\u043a\u0435\u0440\u0430             String fileName = Environment.getExternalStorageDirectory()+&quot;\/automap\/cars\/icons\/&quot;+mCar.getIconIndex()+&quot;\/2\/icon.png&quot;;             icon = Utils.loadIcon(fileName, Float.parseFloat(mCar.getDirection()), mCar.getIconType());             mMarker.setIcon(icon);         }         \/\/\u043c\u0435\u0442\u043e\u0434, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043c\u044b \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c asyncTask         @Override         protected void onPostExecute(Void result) {             stopped = true;             mMarker.showInfoWindow();             super.onPostExecute(result);         }     } } <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043c\u0430\u0440\u043a\u0435\u0440\u0430 \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c \u043a \u043c\u0430\u0440\u043a\u0435\u0440\u0443 \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u0442\u044c \u043d\u0443\u0436\u043d\u043e\u0435 \u043e\u043a\u043d\u043e  <\/p>\n<pre><code class=\"java\">marker.setInfoWindow(infoWindow); <\/code><\/pre>\n<p>\u2003<br \/>  \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u0440\u043e\u0434\u0435\u043b\u0430\u043d\u043d\u044b\u0445 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0439 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043d\u0435\u0447\u0442\u043e \u0432\u0440\u043e\u0434\u0435:<br \/>   <img decoding=\"async\" src=\"http:\/\/cs540109.vk.me\/c618316\/v618316610\/604b\/m9lGKayruec.jpg\" alt=\"image\"\/><br \/>  P.S. \u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u043c\u0430\u0440\u043a\u0435\u0440 \u2014 \u0438\u043a\u043e\u043d\u043a\u0430 \u0433\u0440\u0443\u0437\u043e\u0432\u0438\u043a\u0430, \u0430 \u0432 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u044d\u0442\u043e Alfa Romeo, \u0432\u0441\u0451 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432\u0435\u0440\u043d\u043e \ud83d\ude42<br \/>  <a name=\"habracut\"><\/a>      \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/224289\/\"> http:\/\/habrahabr.ru\/post\/224289\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">     \t\u0421\u0442\u0430\u0442\u044c\u044f \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0430 \u0434\u043b\u044f \u0442\u0435\u0445, \u0443 \u043a\u043e\u0433\u043e \u0442\u0440\u0443\u0434\u043d\u043e\u0441\u0442\u0438 \u0441 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c infoWindow \u0432 osmdroid \u0438 \u0440\u0430\u0431\u043e\u0442\u043e\u0439 \u0441 AsyncTask \u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u0440\u0430\u043d\u044c\u0448\u0435 \u043d\u0435 \u0434\u0435\u043b\u0430\u043b \u043d\u0438\u0447\u0435\u0433\u043e \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0433\u043e \ud83d\ude42 \u0417\u0434\u0435\u0441\u044c \u044f \u043f\u0438\u0441\u0430\u043b \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u044f \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u043b \u043e\u043a\u043e\u0448\u043a\u043e \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0431 \u0430\u0432\u0442\u043e\u043c\u043e\u0431\u0438\u043b\u0435 \u0432 \u0441\u0435\u0440\u0432\u0438\u0441\u0435 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442\u0430.<br \/>  \u0421\u0443\u0442\u044c \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0440\u0438 \u043d\u0430\u0436\u0430\u0442\u0438\u0438 \u043d\u0430 \u043c\u0430\u0440\u043a\u0435\u0440, \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0431\u0435\u0440\u0443\u0442\u0441\u044f \u0438\u0437 \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u0434\u0440\u0443\u0433\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u0434\u0433\u0440\u0443\u0436\u0430\u044e\u0442\u0441\u044f \u0438\u0437 API, \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0432 \u0411\u0414 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u044e\u0442\u0441\u044f \u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u0435 InfoWindow.<br \/>  \u041d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u0441 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f xml \u0444\u0430\u0439\u043b\u0430 \u0441 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c infoWindow, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u043e\u043b\u044f \u0441 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430\u043c\u0438 \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u0435\u0432 \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442\u0430.<br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/168\/089\/61b\/16808961b3c37c5c7df9cecdde56971e.jpg\" alt=\"image\"\/><br \/>  MarkerInfoWindow \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0432 Title, Description, Subdescription, \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0442\u043e\u043b\u044c\u043a\u043e Descripton \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043d\u0443\u0436\u043d\u044b\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439. \u0411\u0443\u0434\u0435\u043c \u0432\u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0442\u0443\u0434\u0430 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0432\u0438\u0434\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0441 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0430\u043c\u0438.<br \/>  \u0420\u0430\u0437\u043c\u0435\u0442\u043a\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:  <\/p>\n<pre><code class=\"java\">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt; &lt;LinearLayout xmlns:android=&quot;http:\/\/schemas.android.com\/apk\/res\/android&quot;     android:layout_width=&quot;wrap_content&quot;     android:layout_height=&quot;wrap_content&quot;     android:orientation=&quot;horizontal&quot;     android:background=&quot;@drawable\/balloon_overlay_white&quot; &gt;     &lt;ImageView android:id=&quot;@+id\/bubble_image&quot;         android:layout_width=&quot;65dp&quot;         android:layout_height=&quot;65dp&quot;         android:visibility=&quot;gone&quot; \/&gt;     &lt;RelativeLayout         android:layout_width=&quot;wrap_content&quot;         android:layout_height=&quot;wrap_content&quot;         android:paddingLeft=&quot;5dp&quot;         android:orientation=&quot;vertical&quot; &gt;             &lt;TextView android:id=&quot;@+id\/bubble_title&quot;                 android:layout_width=&quot;wrap_content&quot;                 android:layout_height=&quot;wrap_content&quot;                 android:textColor=&quot;#000000&quot;                 android:maxEms=&quot;17&quot;                 android:layout_gravity=&quot;left&quot;                 android:layout_weight=&quot;1&quot;                 android:text=&quot;Title&quot;                 android:textSize=&quot;18dp&quot;                 android:textIsSelectable=&quot;false&quot; \/&gt;             &lt;Button android:id=&quot;@+id\/bubble_moreinfo&quot;                 android:background=&quot;@drawable\/btn_moreinfo&quot;                 android:visibility=&quot;gone&quot;                 android:layout_width=&quot;wrap_content&quot;                 android:layout_height=&quot;wrap_content&quot;                 android:layout_gravity=&quot;right&quot;                 android:layout_weight=&quot;0&quot; \/&gt;         &lt;TextView android:id=&quot;@+id\/bubble_description&quot;             android:layout_width=&quot;wrap_content&quot;             android:layout_height=&quot;wrap_content&quot;             android:textSize=&quot;14dp&quot;             android:maxEms=&quot;17&quot;             android:text=&quot;Description&quot;             android:layout_toRightOf=&quot;@+id\/model&quot;             android:layout_below=&quot;@+id\/bubble_title&quot;             android:lineSpacingExtra=&quot;3dp&quot;             android:layout_marginLeft=&quot;3dp&quot; \/&gt;         &lt;TextView android:id=&quot;@+id\/model&quot;             android:layout_width=&quot;wrap_content&quot;             android:layout_height=&quot;wrap_content&quot;             android:textColor=&quot;#ff6c6c6c&quot;             android:textSize=&quot;14dp&quot;             android:maxEms=&quot;17&quot;             android:text=&quot;@string\/model&quot;             android:layout_below=&quot;@+id\/bubble_title&quot;             android:layout_alignRight=&quot;@+id\/organization&quot; \/&gt;         &lt;TextView android:id=&quot;@+id\/group&quot;             android:layout_width=&quot;wrap_content&quot;             android:layout_height=&quot;wrap_content&quot;             android:textColor=&quot;#ff6c6c6c&quot;             android:textSize=&quot;14dp&quot;             android:maxEms=&quot;17&quot;             android:text=&quot;@string\/group&quot;             android:layout_below=&quot;@+id\/model&quot;             android:layout_alignRight=&quot;@+id\/organization&quot; \/&gt;         &lt;TextView android:id=&quot;@+id\/organization&quot;             android:layout_width=&quot;wrap_content&quot;             android:layout_height=&quot;wrap_content&quot;             android:textColor=&quot;#ff6c6c6c&quot;             android:textSize=&quot;14dp&quot;             android:maxEms=&quot;17&quot;             android:text=&quot;@string\/organization&quot;             android:layout_below=&quot;@+id\/group&quot; \/&gt;         &lt;TextView android:id=&quot;@+id\/speed&quot;             android:layout_width=&quot;wrap_content&quot;             android:layout_height=&quot;wrap_content&quot;             android:textColor=&quot;#ff6c6c6c&quot;             android:textSize=&quot;14dp&quot;             android:maxEms=&quot;17&quot;             android:text=&quot;@string\/speed&quot;             android:layout_below=&quot;@+id\/organization&quot;             android:layout_alignRight=&quot;@+id\/organization&quot; \/&gt;         &lt;TextView android:id=&quot;@+id\/update&quot;             android:layout_width=&quot;wrap_content&quot;             android:layout_height=&quot;wrap_content&quot;             android:textColor=&quot;#ff6c6c6c&quot;             android:textSize=&quot;14dp&quot;             android:maxEms=&quot;17&quot;             android:text=&quot;@string\/update&quot;             android:layout_below=&quot;@+id\/speed&quot;             android:layout_alignRight=&quot;@+id\/organization&quot; \/&gt;         &lt;TextView android:id=&quot;@+id\/bubble_subdescription&quot;             android:layout_width=&quot;wrap_content&quot;             android:layout_height=&quot;wrap_content&quot;             android:textColor=&quot;#000000&quot;             android:textSize=&quot;10dp&quot;             android:maxEms=&quot;17&quot;             android:text=&quot;Address&quot;             android:layout_below=&quot;@+id\/update&quot; \/&gt;     &lt;\/RelativeLayout&gt; &lt;\/LinearLayout&gt; <\/code><\/pre>\n<p>  \u0414\u0430\u043b\u0435\u0435, \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043d\u0443\u0436\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u043f\u0438\u0448\u0435\u043c \u0441\u0432\u043e\u0439 \u043a\u043b\u0430\u0441\u0441 CarInfoWindow:  <\/p>\n<pre><code class=\"java\">public class CarInfoWindow extends MarkerInfoWindow {      Car mCar;     Marker mMarker;     CarInfoTask carInfoTask;     Boolean stopped = false;     Drawable icon;     String active;      public CarInfoWindow(int layoutResId, MapView mapView) {         super(layoutResId, mapView);     }     \/\/\u043f\u0440\u0438 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c asyncTask     @Override     public void onOpen(final Object item) {         if (!stopped) {             carInfoTask = new CarInfoTask();             carInfoTask.execute(item);         }         super.onOpen(item);     }     \/\/\u043f\u0440\u0438 \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u0438 \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u0438\u043a\u043e\u043d\u043a\u0443 \u043c\u0430\u0440\u043a\u0435\u0440\u0430     @Override     public void onClose() {         stopped = false;         super.onClose();          if (!(mCar.getLastUpdate() == null)) {             if (((System.currentTimeMillis() - Long.parseLong(mCar.getLastUpdate())) \/ 3600000) &gt; 1) {                 active = &quot;0&quot;; \/\/car is not active             }             else {                 active = &quot;1&quot;;             }         }         String fileName = Environment.getExternalStorageDirectory()+&quot;\/automap\/cars\/icons\/&quot;+mCar.getIconIndex()+&quot;\/&quot;+active+&quot;\/icon.png&quot;;         icon = Utils.loadIcon(fileName, Float.parseFloat(mCar.getDirection()), mCar.getIconType());         mMarker.setIcon(icon);     }  \t     class CarInfoTask extends AsyncTask&lt;Object, String, Void&gt; {          @Override         protected void onPreExecute() {             super.onPreExecute();         }  \t\t         @Override         \/\/\u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043f\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u044d\u0442\u043e\u043c \u043c\u0435\u0442\u043e\u0434\u0435         protected Void doInBackground(Object... params) {             try { \t\t\/\/\u0437\u0430\u0434\u0430\u0435\u043c \u043d\u0443\u0436\u043d\u044b\u0439 \u043c\u0430\u0440\u043a\u0435\u0440, \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d \u043e\u0431\u044a\u0435\u043a\u0442 Car \u0441 \u043d\u0443\u0436\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438                 mMarker = (Marker)params[0];                 mCar = (Car) mMarker.getRelatedObject(); \t\t\/\/\u0414\u0430\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0432 infoWindow                 String markName;                 String carModelName;                 String groupName;                 String carLastUpdate;                 Context context = getView().getContext();                  \/\/\u0431\u0435\u0440\u0435\u043c token, \u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u043e\u0431\u044a\u0435\u043a\u0442\u0430                 Token token = Prefs.getToken(getView().getContext());                 String markId = mCar.getMarkId();                 String modelId = mCar.getModelId();                 String orgId = mCar.getOrganizationId();                 String groupId = mCar.getGroupId();                 carLastUpdate = mCar.getLastUpdate();  \t\t\/\/\u0447\u0442\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u0434\u0435\u043b\u0430\u0435\u043c                 String formattedDate = &quot;&quot;;                 if (!(carLastUpdate == null)) {                     long unixSeconds = Long.parseLong(carLastUpdate);                     Date date = new Date(unixSeconds);                     SimpleDateFormat sdf = new SimpleDateFormat(&quot;dd.MM.yyyy  HH:mm:ss &quot;);                     formattedDate = sdf.format(date);                 }                  String organizationName = DbHelper.getInstance(context).getOrganizationStatById(orgId).getName();                 List&lt;Mark&gt; marksList = null;                 List&lt;CarModel&gt; carModelsList = null;                 List&lt;Group&gt; groupsList = null; \t\t\t\t                 \/\/\u0434\u0435\u043b\u0430\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441 \u0432 API, \u0431\u0435\u0440\u0435\u043c mark \u0438 model \u043f\u043e id                 try {                     \/\/\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c retrofit                     carModelsList = Api.getService(context).getModels(token.getValue(), markId);                      int size = carModelsList.size();                     for (int i=0; i&lt;size; i++) {                         \/\/\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c cupboard \u0434\u043b\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0411\u0414                         DbHel<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-224289","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/224289","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=224289"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/224289\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=224289"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=224289"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=224289"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}