Updated osmo card
This commit is contained in:
parent
ef52cb178f
commit
8b6542702b
2 changed files with 17 additions and 12 deletions
|
@ -52,6 +52,7 @@
|
||||||
<include layout="@layout/check_item_rel"/>
|
<include layout="@layout/check_item_rel"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
|
@ -44,7 +44,7 @@ public class DashOsMoFragment extends DashBaseFragment implements OsMoGroups.OsM
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCloseDash() {
|
public void onCloseDash() {
|
||||||
if (plugin != null && plugin.getGroups() !=null){
|
if (plugin != null && plugin.getGroups() != null) {
|
||||||
plugin.getGroups().removeUiListener(this);
|
plugin.getGroups().removeUiListener(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ public class DashOsMoFragment extends DashBaseFragment implements OsMoGroups.OsM
|
||||||
@Override
|
@Override
|
||||||
public void onOpenDash() {
|
public void onOpenDash() {
|
||||||
plugin = OsmandPlugin.getEnabledPlugin(OsMoPlugin.class);
|
plugin = OsmandPlugin.getEnabledPlugin(OsMoPlugin.class);
|
||||||
if (plugin!=null){
|
if (plugin != null) {
|
||||||
plugin.getGroups().addUiListeners(this);
|
plugin.getGroups().addUiListeners(this);
|
||||||
}
|
}
|
||||||
setupOsMoView();
|
setupOsMoView();
|
||||||
|
@ -164,14 +164,13 @@ public class DashOsMoFragment extends DashBaseFragment implements OsMoGroups.OsM
|
||||||
List<OsMoGroupsStorage.OsMoDevice> devices =
|
List<OsMoGroupsStorage.OsMoDevice> devices =
|
||||||
new ArrayList<>(mainGroup.getVisibleGroupUsers(plugin.getService().getMyGroupTrackerId()));
|
new ArrayList<>(mainGroup.getVisibleGroupUsers(plugin.getService().getMyGroupTrackerId()));
|
||||||
|
|
||||||
while (devices.size() > 3){
|
while (devices.size() > 3) {
|
||||||
devices.remove(devices.size() - 1);
|
devices.remove(devices.size() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
setupDeviceViews(contentList, devices);
|
setupDeviceViews(contentList, devices);
|
||||||
if (devices.size() < 3 && groups.size() > 0) {
|
if (devices.size() < 3 && groups.size() > 0) {
|
||||||
setupGroupsViews(3-devices.size(), groups, contentList);
|
setupGroupsViews(3 - devices.size(), groups, contentList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,15 +205,15 @@ public class DashOsMoFragment extends DashBaseFragment implements OsMoGroups.OsM
|
||||||
LayoutInflater inflater = getActivity().getLayoutInflater();
|
LayoutInflater inflater = getActivity().getLayoutInflater();
|
||||||
for (final OsMoGroupsStorage.OsMoDevice device : devices) {
|
for (final OsMoGroupsStorage.OsMoDevice device : devices) {
|
||||||
View v = inflater.inflate(R.layout.dash_osmo_item, null, false);
|
View v = inflater.inflate(R.layout.dash_osmo_item, null, false);
|
||||||
final ImageButton showOnMap = (ImageButton)v.findViewById(R.id.show_on_map);
|
final ImageButton showOnMap = (ImageButton) v.findViewById(R.id.show_on_map);
|
||||||
showOnMap.setImageDrawable(markerIcon);
|
showOnMap.setImageDrawable(markerIcon);
|
||||||
final String name = device.getVisibleName();
|
final String name = device.getVisibleName();
|
||||||
showOnMap.setOnClickListener(new View.OnClickListener() {
|
showOnMap.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
Location loc = device.getLastLocation();
|
Location loc = device.getLastLocation();
|
||||||
if (loc == null){
|
if (loc == null) {
|
||||||
Toast.makeText(getActivity(), R.string.osmo_device_not_found,Toast.LENGTH_SHORT).show();
|
Toast.makeText(getActivity(), R.string.osmo_device_not_found, Toast.LENGTH_SHORT).show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
getMyApplication().getSettings().setMapLocationToShow(loc.getLatitude(),
|
getMyApplication().getSettings().setMapLocationToShow(loc.getLatitude(),
|
||||||
|
@ -244,7 +243,7 @@ public class DashOsMoFragment extends DashBaseFragment implements OsMoGroups.OsM
|
||||||
getContentIcon(R.drawable.ic_person));
|
getContentIcon(R.drawable.ic_person));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (device.isActive()){
|
if (device.isActive()) {
|
||||||
|
|
||||||
}
|
}
|
||||||
((TextView) v.findViewById(R.id.name)).setText(name);
|
((TextView) v.findViewById(R.id.name)).setText(name);
|
||||||
|
@ -271,18 +270,23 @@ public class DashOsMoFragment extends DashBaseFragment implements OsMoGroups.OsM
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void launchOsMoGroupsActivity(){
|
private void launchOsMoGroupsActivity() {
|
||||||
Intent intent = new Intent(getActivity(), OsMoGroupsActivity.class);
|
Intent intent = new Intent(getActivity(), OsMoGroupsActivity.class);
|
||||||
getActivity().startActivity(intent);
|
getActivity().startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void groupsListChange(String operation, OsMoGroupsStorage.OsMoGroup group) {
|
public void groupsListChange(String operation, OsMoGroupsStorage.OsMoGroup group) {
|
||||||
updateConnectedDevices(getView());
|
getActivity().runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
updateConnectedDevices(getView());
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deviceLocationChanged(OsMoGroupsStorage.OsMoDevice device) {
|
public void deviceLocationChanged(OsMoGroupsStorage.OsMoDevice device) {
|
||||||
updateConnectedDevices(getView());
|
//
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue