small changes
This commit is contained in:
parent
201845da3a
commit
b91931e833
@ -42,10 +42,9 @@ public class IconContextMenu implements DialogInterface.OnCancelListener,
|
||||
|
||||
private static final int LIST_PREFERED_HEIGHT = 65;
|
||||
|
||||
private IconMenuAdapter menuAdapter = null;
|
||||
private Activity parentActivity = null;
|
||||
private int dialogId = 0;
|
||||
|
||||
private IconMenuAdapter menuAdapter;
|
||||
private Activity parentActivity;
|
||||
|
||||
private IconContextMenuOnClickListener clickHandler = null;
|
||||
|
||||
/**
|
||||
@ -55,8 +54,7 @@ public class IconContextMenu implements DialogInterface.OnCancelListener,
|
||||
*/
|
||||
public IconContextMenu(Activity parent, int id) {
|
||||
this.parentActivity = parent;
|
||||
this.dialogId = id;
|
||||
|
||||
|
||||
menuAdapter = new IconMenuAdapter(parentActivity);
|
||||
}
|
||||
|
||||
@ -89,19 +87,13 @@ public class IconContextMenu implements DialogInterface.OnCancelListener,
|
||||
public Dialog createMenu(String menuItitle) {
|
||||
final AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
|
||||
builder.setTitle(menuItitle);
|
||||
builder.setAdapter(menuAdapter, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialoginterface, int i) {
|
||||
IconContextMenuItem item = (IconContextMenuItem) menuAdapter.getItem(i);
|
||||
|
||||
if (clickHandler != null) {
|
||||
clickHandler.onClick(item.actionTag);
|
||||
}
|
||||
}
|
||||
builder.setAdapter(menuAdapter, (dialoginterface, i) -> {
|
||||
IconContextMenuItem item = (IconContextMenuItem) menuAdapter.getItem(i);
|
||||
if (clickHandler != null)
|
||||
clickHandler.onClick(item.actionTag);
|
||||
});
|
||||
|
||||
builder.setInverseBackgroundForced(true);
|
||||
|
||||
AlertDialog dialog = builder.create();
|
||||
dialog.setOnCancelListener(this);
|
||||
dialog.setOnDismissListener(this);
|
||||
@ -117,7 +109,7 @@ public class IconContextMenu implements DialogInterface.OnCancelListener,
|
||||
}
|
||||
|
||||
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
|
||||
*/
|
||||
protected class IconMenuAdapter extends BaseAdapter {
|
||||
private Context context = null;
|
||||
private Context context;
|
||||
|
||||
private ArrayList<IconContextMenuItem> mItems = new ArrayList<IconContextMenuItem>();
|
||||
|
||||
@ -193,6 +185,7 @@ public class IconContextMenu implements DialogInterface.OnCancelListener,
|
||||
textView.setTag(item);
|
||||
textView.setText(item.text);
|
||||
textView.setCompoundDrawablesWithIntrinsicBounds(item.image, null, null, null);
|
||||
textView.setTextColor(R.color.black);
|
||||
|
||||
return textView;
|
||||
}
|
||||
|
@ -22,7 +22,6 @@ import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.Button;
|
||||
import android.widget.GridView;
|
||||
import android.widget.ImageButton;
|
||||
@ -32,8 +31,6 @@ import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
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.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.BitmapDescriptorFactory;
|
||||
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.safemobile.activities.AbstractLiveActivity;
|
||||
import com.safemobile.activities.AbstractSDParentActivity;
|
||||
@ -142,12 +138,11 @@ public class LiveActivity extends AbstractLiveActivity implements OnMapReadyCall
|
||||
mapFragment.getMapAsync(this);
|
||||
}
|
||||
|
||||
|
||||
// create on vehicle long click menu
|
||||
createIconContextMenu();
|
||||
|
||||
// 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 -> {
|
||||
if (googleMap.getMapType() == GoogleMap.MAP_TYPE_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 -> {
|
||||
if (googleMap.isTrafficEnabled()) {
|
||||
changeTrafficImageView.setImageResource(R.drawable.traffic_off);
|
||||
@ -170,12 +165,12 @@ public class LiveActivity extends AbstractLiveActivity implements OnMapReadyCall
|
||||
});
|
||||
|
||||
// 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.setTextSize(24);
|
||||
|
||||
// get grid view and set empty data adapter
|
||||
gridVehicle = (GridView) findViewById(R.id.gridVehicle);
|
||||
gridVehicle = findViewById(R.id.gridVehicle);
|
||||
|
||||
if (AppParams.DEMO) {
|
||||
disabledVehicles = new ArrayList<>();
|
||||
@ -197,14 +192,16 @@ public class LiveActivity extends AbstractLiveActivity implements OnMapReadyCall
|
||||
threadUI.start();
|
||||
});
|
||||
|
||||
|
||||
// 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 = (LinearLayout) findViewById(R.id.slidelayout);
|
||||
ImageView slideLayoutImageView = (ImageView) findViewById(R.id.slideLayoutImage);
|
||||
LinearLayout linearLayoutVehicles = (LinearLayout) findViewById(R.id.layoutBig);
|
||||
LinearLayout slideLayout = findViewById(R.id.slidelayout);
|
||||
ImageView slideLayoutImageView = findViewById(R.id.slideLayoutImage);
|
||||
LinearLayout linearLayoutVehicles = findViewById(R.id.layoutBig);
|
||||
slideLayout.setOnClickListener(v -> {
|
||||
if (showVehicle) {
|
||||
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.setOnClickListener(arg0 -> {
|
||||
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();
|
||||
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
|
||||
@ -259,7 +256,7 @@ public class LiveActivity extends AbstractLiveActivity implements OnMapReadyCall
|
||||
displayVehicle(true, LAT_OUTLIMIT, LNG_OUTLIMIT);
|
||||
});
|
||||
|
||||
displayButton = (Button) findViewById(R.id.buttonDisplay);
|
||||
displayButton = findViewById(R.id.buttonDisplay);
|
||||
displayButton.setText(getString(R.string.displayAll));
|
||||
|
||||
|
||||
@ -271,7 +268,7 @@ public class LiveActivity extends AbstractLiveActivity implements OnMapReadyCall
|
||||
|
||||
Enumeration<Long> keyList = getParentTab().SuperVehHash.keys();
|
||||
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
|
||||
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) {
|
||||
if (googleMap != null) {
|
||||
googleMap.clear();
|
||||
@ -483,7 +458,7 @@ public class LiveActivity extends AbstractLiveActivity implements OnMapReadyCall
|
||||
BitmapDescriptor markerIcon = getProperBitmap(tmpSuper.getLargeIcon(), tmpSuper.name);
|
||||
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) {
|
||||
int i =0;
|
||||
//TODO: add show balloon
|
||||
}
|
||||
|
||||
@ -561,9 +535,9 @@ public class LiveActivity extends AbstractLiveActivity implements OnMapReadyCall
|
||||
loadingDialog.setCancelable(true);
|
||||
loadingDialog.setCanceledOnTouchOutside(false);
|
||||
|
||||
Button cancel = (Button) loadingDialog.findViewById(R.id.buttonCancel);
|
||||
Button cancel = loadingDialog.findViewById(R.id.buttonCancel);
|
||||
cancel.setVisibility(View.GONE);
|
||||
TextView textView1 = (TextView) loadingDialog.findViewById(R.id.textView1);
|
||||
TextView textView1 = loadingDialog.findViewById(R.id.textView1);
|
||||
textView1.setText(message);
|
||||
|
||||
loadingDialog.show();
|
||||
@ -592,8 +566,7 @@ public class LiveActivity extends AbstractLiveActivity implements OnMapReadyCall
|
||||
disabledVehicles.add(!veh.status);
|
||||
|
||||
// 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<>();
|
||||
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);
|
||||
@ -610,7 +583,6 @@ public class LiveActivity extends AbstractLiveActivity implements OnMapReadyCall
|
||||
}
|
||||
|
||||
// set adapter
|
||||
|
||||
adapter = new VehiclesGridViewAdapter(activity, context, list, disabledVehicles);
|
||||
adapter.notifyDataSetChanged();
|
||||
|
||||
@ -629,7 +601,6 @@ public class LiveActivity extends AbstractLiveActivity implements OnMapReadyCall
|
||||
// show vehicles in gridView
|
||||
private void updateResultsUI() {
|
||||
gridVehicle.setAdapter(adapter);
|
||||
|
||||
try {
|
||||
// hide loading dialog
|
||||
loadingDialog.cancel();
|
||||
@ -688,11 +659,9 @@ public class LiveActivity extends AbstractLiveActivity implements OnMapReadyCall
|
||||
final Runnable updateOptionsRUN = this::updateOptionsUI;
|
||||
|
||||
private void updateOptionsUI() {
|
||||
|
||||
SM.Debug("REFRESHDisableEnable" + (Boolean.TRUE.equals(disabledVehicles.get(contextMenuPosition)) ? "true" : "false"));
|
||||
// change Enable/Disable in adapter
|
||||
adapter.changeDisabled(contextMenuPosition, disabledVehicles.get(contextMenuPosition));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -782,7 +751,6 @@ public class LiveActivity extends AbstractLiveActivity implements OnMapReadyCall
|
||||
// zone and channel change intent
|
||||
IntentFilter intentFilter = new IntentFilter(OperationCodes.UNIT_STATUS_UPDATE + "");
|
||||
this.registerReceiver(mReceiver, intentFilter);
|
||||
|
||||
}
|
||||
|
||||
//The BroadcastReceiver that listens for Notification broadcasts
|
||||
|
Loading…
Reference in New Issue
Block a user