small changes
This commit is contained in:
parent
201845da3a
commit
b91931e833
@ -42,9 +42,8 @@ public class IconContextMenu implements DialogInterface.OnCancelListener,
|
|||||||
|
|
||||||
private static final int LIST_PREFERED_HEIGHT = 65;
|
private static final int LIST_PREFERED_HEIGHT = 65;
|
||||||
|
|
||||||
private IconMenuAdapter menuAdapter = null;
|
private IconMenuAdapter menuAdapter;
|
||||||
private Activity parentActivity = null;
|
private Activity parentActivity;
|
||||||
private int dialogId = 0;
|
|
||||||
|
|
||||||
private IconContextMenuOnClickListener clickHandler = null;
|
private IconContextMenuOnClickListener clickHandler = null;
|
||||||
|
|
||||||
@ -55,7 +54,6 @@ public class IconContextMenu implements DialogInterface.OnCancelListener,
|
|||||||
*/
|
*/
|
||||||
public IconContextMenu(Activity parent, int id) {
|
public IconContextMenu(Activity parent, int id) {
|
||||||
this.parentActivity = parent;
|
this.parentActivity = parent;
|
||||||
this.dialogId = id;
|
|
||||||
|
|
||||||
menuAdapter = new IconMenuAdapter(parentActivity);
|
menuAdapter = new IconMenuAdapter(parentActivity);
|
||||||
}
|
}
|
||||||
@ -89,19 +87,13 @@ public class IconContextMenu implements DialogInterface.OnCancelListener,
|
|||||||
public Dialog createMenu(String menuItitle) {
|
public Dialog createMenu(String menuItitle) {
|
||||||
final AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
|
final AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
|
||||||
builder.setTitle(menuItitle);
|
builder.setTitle(menuItitle);
|
||||||
builder.setAdapter(menuAdapter, new DialogInterface.OnClickListener() {
|
builder.setAdapter(menuAdapter, (dialoginterface, i) -> {
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialoginterface, int i) {
|
|
||||||
IconContextMenuItem item = (IconContextMenuItem) menuAdapter.getItem(i);
|
IconContextMenuItem item = (IconContextMenuItem) menuAdapter.getItem(i);
|
||||||
|
if (clickHandler != null)
|
||||||
if (clickHandler != null) {
|
|
||||||
clickHandler.onClick(item.actionTag);
|
clickHandler.onClick(item.actionTag);
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
builder.setInverseBackgroundForced(true);
|
builder.setInverseBackgroundForced(true);
|
||||||
|
|
||||||
AlertDialog dialog = builder.create();
|
AlertDialog dialog = builder.create();
|
||||||
dialog.setOnCancelListener(this);
|
dialog.setOnCancelListener(this);
|
||||||
dialog.setOnDismissListener(this);
|
dialog.setOnDismissListener(this);
|
||||||
@ -117,7 +109,7 @@ public class IconContextMenu implements DialogInterface.OnCancelListener,
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void cleanup() {
|
private void cleanup() {
|
||||||
parentActivity.dismissDialog(dialogId);
|
// parentActivity.dismissDialog(dialogId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -131,7 +123,7 @@ public class IconContextMenu implements DialogInterface.OnCancelListener,
|
|||||||
* Menu-like list adapter with icon
|
* Menu-like list adapter with icon
|
||||||
*/
|
*/
|
||||||
protected class IconMenuAdapter extends BaseAdapter {
|
protected class IconMenuAdapter extends BaseAdapter {
|
||||||
private Context context = null;
|
private Context context;
|
||||||
|
|
||||||
private ArrayList<IconContextMenuItem> mItems = new ArrayList<IconContextMenuItem>();
|
private ArrayList<IconContextMenuItem> mItems = new ArrayList<IconContextMenuItem>();
|
||||||
|
|
||||||
@ -193,6 +185,7 @@ public class IconContextMenu implements DialogInterface.OnCancelListener,
|
|||||||
textView.setTag(item);
|
textView.setTag(item);
|
||||||
textView.setText(item.text);
|
textView.setText(item.text);
|
||||||
textView.setCompoundDrawablesWithIntrinsicBounds(item.image, null, null, null);
|
textView.setCompoundDrawablesWithIntrinsicBounds(item.image, null, null, null);
|
||||||
|
textView.setTextColor(R.color.black);
|
||||||
|
|
||||||
return textView;
|
return textView;
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,6 @@ import android.os.Handler;
|
|||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.widget.AdapterView;
|
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.GridView;
|
import android.widget.GridView;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
@ -32,8 +31,6 @@ import android.widget.TextView;
|
|||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
|
||||||
|
|
||||||
import com.google.android.gms.maps.CameraUpdateFactory;
|
import com.google.android.gms.maps.CameraUpdateFactory;
|
||||||
import com.google.android.gms.maps.GoogleMap;
|
import com.google.android.gms.maps.GoogleMap;
|
||||||
@ -42,7 +39,6 @@ import com.google.android.gms.maps.SupportMapFragment;
|
|||||||
import com.google.android.gms.maps.model.BitmapDescriptor;
|
import com.google.android.gms.maps.model.BitmapDescriptor;
|
||||||
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
|
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
|
||||||
import com.google.android.gms.maps.model.LatLng;
|
import com.google.android.gms.maps.model.LatLng;
|
||||||
import com.google.android.gms.maps.model.Marker;
|
|
||||||
import com.google.android.gms.maps.model.MarkerOptions;
|
import com.google.android.gms.maps.model.MarkerOptions;
|
||||||
import com.safemobile.activities.AbstractLiveActivity;
|
import com.safemobile.activities.AbstractLiveActivity;
|
||||||
import com.safemobile.activities.AbstractSDParentActivity;
|
import com.safemobile.activities.AbstractSDParentActivity;
|
||||||
@ -142,12 +138,11 @@ public class LiveActivity extends AbstractLiveActivity implements OnMapReadyCall
|
|||||||
mapFragment.getMapAsync(this);
|
mapFragment.getMapAsync(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// create on vehicle long click menu
|
// create on vehicle long click menu
|
||||||
createIconContextMenu();
|
createIconContextMenu();
|
||||||
|
|
||||||
// image View for changing map type satellite or map
|
// image View for changing map type satellite or map
|
||||||
ImageView changeMapTypeImageView = (ImageView) findViewById(R.id.changeMapType);
|
ImageView changeMapTypeImageView = findViewById(R.id.changeMapType);
|
||||||
changeMapTypeImageView.setOnClickListener(v -> {
|
changeMapTypeImageView.setOnClickListener(v -> {
|
||||||
if (googleMap.getMapType() == GoogleMap.MAP_TYPE_SATELLITE) {
|
if (googleMap.getMapType() == GoogleMap.MAP_TYPE_SATELLITE) {
|
||||||
changeMapTypeImageView.setImageResource(R.drawable.satellite);
|
changeMapTypeImageView.setImageResource(R.drawable.satellite);
|
||||||
@ -158,7 +153,7 @@ public class LiveActivity extends AbstractLiveActivity implements OnMapReadyCall
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
ImageView changeTrafficImageView = (ImageView) findViewById(R.id.changeTraffic);
|
ImageView changeTrafficImageView = findViewById(R.id.changeTraffic);
|
||||||
changeTrafficImageView.setOnClickListener(v -> {
|
changeTrafficImageView.setOnClickListener(v -> {
|
||||||
if (googleMap.isTrafficEnabled()) {
|
if (googleMap.isTrafficEnabled()) {
|
||||||
changeTrafficImageView.setImageResource(R.drawable.traffic_off);
|
changeTrafficImageView.setImageResource(R.drawable.traffic_off);
|
||||||
@ -170,12 +165,12 @@ public class LiveActivity extends AbstractLiveActivity implements OnMapReadyCall
|
|||||||
});
|
});
|
||||||
|
|
||||||
// change tab header font
|
// change tab header font
|
||||||
TextView textView1 = (TextView) findViewById(R.id.textView1);
|
TextView textView1 = findViewById(R.id.textView1);
|
||||||
textView1.setTypeface(Typeface.createFromAsset(getAssets(), "Sketch_Block.ttf"));
|
textView1.setTypeface(Typeface.createFromAsset(getAssets(), "Sketch_Block.ttf"));
|
||||||
textView1.setTextSize(24);
|
textView1.setTextSize(24);
|
||||||
|
|
||||||
// get grid view and set empty data adapter
|
// get grid view and set empty data adapter
|
||||||
gridVehicle = (GridView) findViewById(R.id.gridVehicle);
|
gridVehicle = findViewById(R.id.gridVehicle);
|
||||||
|
|
||||||
if (AppParams.DEMO) {
|
if (AppParams.DEMO) {
|
||||||
disabledVehicles = new ArrayList<>();
|
disabledVehicles = new ArrayList<>();
|
||||||
@ -197,14 +192,16 @@ public class LiveActivity extends AbstractLiveActivity implements OnMapReadyCall
|
|||||||
threadUI.start();
|
threadUI.start();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// get vehicle menu creation
|
// get vehicle menu creation
|
||||||
gridVehicle.setOnItemLongClickListener(itemLongClickHandler);
|
gridVehicle.setOnItemLongClickListener((adapterView, view, i, l) -> {
|
||||||
|
contextMenuPosition = position;
|
||||||
|
iconContextMenu.createMenu(getString(R.string.options)).show();
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
LinearLayout slideLayout = findViewById(R.id.slidelayout);
|
||||||
LinearLayout slideLayout = (LinearLayout) findViewById(R.id.slidelayout);
|
ImageView slideLayoutImageView = findViewById(R.id.slideLayoutImage);
|
||||||
ImageView slideLayoutImageView = (ImageView) findViewById(R.id.slideLayoutImage);
|
LinearLayout linearLayoutVehicles = findViewById(R.id.layoutBig);
|
||||||
LinearLayout linearLayoutVehicles = (LinearLayout) findViewById(R.id.layoutBig);
|
|
||||||
slideLayout.setOnClickListener(v -> {
|
slideLayout.setOnClickListener(v -> {
|
||||||
if (showVehicle) {
|
if (showVehicle) {
|
||||||
linearLayoutVehicles.setVisibility(View.GONE);
|
linearLayoutVehicles.setVisibility(View.GONE);
|
||||||
@ -217,7 +214,7 @@ public class LiveActivity extends AbstractLiveActivity implements OnMapReadyCall
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
imageViewCheckAll = (ImageButton) findViewById(R.id.imageCheckAll);
|
imageViewCheckAll = findViewById(R.id.imageCheckAll);
|
||||||
imageViewCheckAll.setSelected(false);
|
imageViewCheckAll.setSelected(false);
|
||||||
imageViewCheckAll.setOnClickListener(arg0 -> {
|
imageViewCheckAll.setOnClickListener(arg0 -> {
|
||||||
for (int i = 0; i < displayedVehicles.size(); i++)
|
for (int i = 0; i < displayedVehicles.size(); i++)
|
||||||
@ -235,7 +232,7 @@ public class LiveActivity extends AbstractLiveActivity implements OnMapReadyCall
|
|||||||
|
|
||||||
Enumeration<Long> keyList = getParentTab().SuperVehHash.keys();
|
Enumeration<Long> keyList = getParentTab().SuperVehHash.keys();
|
||||||
while (keyList.hasMoreElements()) {
|
while (keyList.hasMoreElements()) {
|
||||||
(Objects.requireNonNull(getParentTab().SuperVehHash.get((long) keyList.nextElement()))).needUpdate = true;
|
(Objects.requireNonNull(getParentTab().SuperVehHash.get(keyList.nextElement()))).needUpdate = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// change button title
|
// change button title
|
||||||
@ -259,7 +256,7 @@ public class LiveActivity extends AbstractLiveActivity implements OnMapReadyCall
|
|||||||
displayVehicle(true, LAT_OUTLIMIT, LNG_OUTLIMIT);
|
displayVehicle(true, LAT_OUTLIMIT, LNG_OUTLIMIT);
|
||||||
});
|
});
|
||||||
|
|
||||||
displayButton = (Button) findViewById(R.id.buttonDisplay);
|
displayButton = findViewById(R.id.buttonDisplay);
|
||||||
displayButton.setText(getString(R.string.displayAll));
|
displayButton.setText(getString(R.string.displayAll));
|
||||||
|
|
||||||
|
|
||||||
@ -271,7 +268,7 @@ public class LiveActivity extends AbstractLiveActivity implements OnMapReadyCall
|
|||||||
|
|
||||||
Enumeration<Long> keyList = getParentTab().SuperVehHash.keys();
|
Enumeration<Long> keyList = getParentTab().SuperVehHash.keys();
|
||||||
while (keyList.hasMoreElements())
|
while (keyList.hasMoreElements())
|
||||||
(Objects.requireNonNull(getParentTab().SuperVehHash.get((long) keyList.nextElement()))).needUpdate = true;
|
(Objects.requireNonNull(getParentTab().SuperVehHash.get(keyList.nextElement()))).needUpdate = true;
|
||||||
|
|
||||||
// change button title
|
// change button title
|
||||||
if (displayButton.getText().toString().equals(getString(R.string.displayAll))) {
|
if (displayButton.getText().toString().equals(getString(R.string.displayAll))) {
|
||||||
@ -446,28 +443,6 @@ public class LiveActivity extends AbstractLiveActivity implements OnMapReadyCall
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* create context menu
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Dialog onCreateDialog(int id) {
|
|
||||||
if (id == 1) {
|
|
||||||
return iconContextMenu.createMenu(getString(R.string.options));
|
|
||||||
}
|
|
||||||
return super.onCreateDialog(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* list item long click handler
|
|
||||||
* used to show the context menu
|
|
||||||
*/
|
|
||||||
private final AdapterView.OnItemLongClickListener itemLongClickHandler = ((parent, view, position, id) -> {
|
|
||||||
// save position
|
|
||||||
contextMenuPosition = position;
|
|
||||||
showDialog(1);
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
|
|
||||||
public void displayVehicle(boolean withZoom, double latZoom, double lngZoom) {
|
public void displayVehicle(boolean withZoom, double latZoom, double lngZoom) {
|
||||||
if (googleMap != null) {
|
if (googleMap != null) {
|
||||||
googleMap.clear();
|
googleMap.clear();
|
||||||
@ -483,7 +458,7 @@ public class LiveActivity extends AbstractLiveActivity implements OnMapReadyCall
|
|||||||
BitmapDescriptor markerIcon = getProperBitmap(tmpSuper.getLargeIcon(), tmpSuper.name);
|
BitmapDescriptor markerIcon = getProperBitmap(tmpSuper.getLargeIcon(), tmpSuper.name);
|
||||||
markerOptions.icon(markerIcon);
|
markerOptions.icon(markerIcon);
|
||||||
|
|
||||||
Marker marker = this.googleMap.addMarker(markerOptions);
|
this.googleMap.addMarker(markerOptions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -491,7 +466,6 @@ public class LiveActivity extends AbstractLiveActivity implements OnMapReadyCall
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void showOpenedBalloon(boolean demo) {
|
public void showOpenedBalloon(boolean demo) {
|
||||||
int i =0;
|
|
||||||
//TODO: add show balloon
|
//TODO: add show balloon
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -561,9 +535,9 @@ public class LiveActivity extends AbstractLiveActivity implements OnMapReadyCall
|
|||||||
loadingDialog.setCancelable(true);
|
loadingDialog.setCancelable(true);
|
||||||
loadingDialog.setCanceledOnTouchOutside(false);
|
loadingDialog.setCanceledOnTouchOutside(false);
|
||||||
|
|
||||||
Button cancel = (Button) loadingDialog.findViewById(R.id.buttonCancel);
|
Button cancel = loadingDialog.findViewById(R.id.buttonCancel);
|
||||||
cancel.setVisibility(View.GONE);
|
cancel.setVisibility(View.GONE);
|
||||||
TextView textView1 = (TextView) loadingDialog.findViewById(R.id.textView1);
|
TextView textView1 = loadingDialog.findViewById(R.id.textView1);
|
||||||
textView1.setText(message);
|
textView1.setText(message);
|
||||||
|
|
||||||
loadingDialog.show();
|
loadingDialog.show();
|
||||||
@ -592,8 +566,7 @@ public class LiveActivity extends AbstractLiveActivity implements OnMapReadyCall
|
|||||||
disabledVehicles.add(!veh.status);
|
disabledVehicles.add(!veh.status);
|
||||||
|
|
||||||
// add vehicle to hash Table according to driver_id
|
// add vehicle to hash Table according to driver_id
|
||||||
if (tableHashOverlay.get((int) veh.driver_id) == null) // if doesn't exist
|
if (tableHashOverlay.get((int) veh.driver_id) == null) {
|
||||||
{
|
|
||||||
ArrayList<SuperVehicle> array = new ArrayList<>();
|
ArrayList<SuperVehicle> array = new ArrayList<>();
|
||||||
SuperVehicle superVehicle = new SuperVehicle(veh.sc_id, veh.imei, veh.lp, veh.name, veh.driver_id, veh.time_route, veh.GPS_reporting_interval, veh.is_stolen);
|
SuperVehicle superVehicle = new SuperVehicle(veh.sc_id, veh.imei, veh.lp, veh.name, veh.driver_id, veh.time_route, veh.GPS_reporting_interval, veh.is_stolen);
|
||||||
array.add(superVehicle);
|
array.add(superVehicle);
|
||||||
@ -610,7 +583,6 @@ public class LiveActivity extends AbstractLiveActivity implements OnMapReadyCall
|
|||||||
}
|
}
|
||||||
|
|
||||||
// set adapter
|
// set adapter
|
||||||
|
|
||||||
adapter = new VehiclesGridViewAdapter(activity, context, list, disabledVehicles);
|
adapter = new VehiclesGridViewAdapter(activity, context, list, disabledVehicles);
|
||||||
adapter.notifyDataSetChanged();
|
adapter.notifyDataSetChanged();
|
||||||
|
|
||||||
@ -629,7 +601,6 @@ public class LiveActivity extends AbstractLiveActivity implements OnMapReadyCall
|
|||||||
// show vehicles in gridView
|
// show vehicles in gridView
|
||||||
private void updateResultsUI() {
|
private void updateResultsUI() {
|
||||||
gridVehicle.setAdapter(adapter);
|
gridVehicle.setAdapter(adapter);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// hide loading dialog
|
// hide loading dialog
|
||||||
loadingDialog.cancel();
|
loadingDialog.cancel();
|
||||||
@ -688,11 +659,9 @@ public class LiveActivity extends AbstractLiveActivity implements OnMapReadyCall
|
|||||||
final Runnable updateOptionsRUN = this::updateOptionsUI;
|
final Runnable updateOptionsRUN = this::updateOptionsUI;
|
||||||
|
|
||||||
private void updateOptionsUI() {
|
private void updateOptionsUI() {
|
||||||
|
|
||||||
SM.Debug("REFRESHDisableEnable" + (Boolean.TRUE.equals(disabledVehicles.get(contextMenuPosition)) ? "true" : "false"));
|
SM.Debug("REFRESHDisableEnable" + (Boolean.TRUE.equals(disabledVehicles.get(contextMenuPosition)) ? "true" : "false"));
|
||||||
// change Enable/Disable in adapter
|
// change Enable/Disable in adapter
|
||||||
adapter.changeDisabled(contextMenuPosition, disabledVehicles.get(contextMenuPosition));
|
adapter.changeDisabled(contextMenuPosition, disabledVehicles.get(contextMenuPosition));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -782,7 +751,6 @@ public class LiveActivity extends AbstractLiveActivity implements OnMapReadyCall
|
|||||||
// zone and channel change intent
|
// zone and channel change intent
|
||||||
IntentFilter intentFilter = new IntentFilter(OperationCodes.UNIT_STATUS_UPDATE + "");
|
IntentFilter intentFilter = new IntentFilter(OperationCodes.UNIT_STATUS_UPDATE + "");
|
||||||
this.registerReceiver(mReceiver, intentFilter);
|
this.registerReceiver(mReceiver, intentFilter);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//The BroadcastReceiver that listens for Notification broadcasts
|
//The BroadcastReceiver that listens for Notification broadcasts
|
||||||
|
Loading…
Reference in New Issue
Block a user