Merge pull request 'SD-216 - fix back button functionality for recordings and history tabs' (#16) from fix/SD-216-back-navigation-broken into develop
Reviewed-on: #16
This commit is contained in:
commit
7b45edb624
@ -3,6 +3,7 @@ package com.safemobile.safedispatch;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.DatePickerDialog;
|
||||
import android.app.Dialog;
|
||||
import android.graphics.Color;
|
||||
@ -124,6 +125,18 @@ public class HistoryActivity extends AppCompatActivity implements OnMapReadyCall
|
||||
googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, 14));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setMessage(getString(R.string.exit))
|
||||
.setCancelable(false)
|
||||
.setNeutralButton(getString(R.string.logout), (dialog, id) -> parentTab.whenBackPressed(AppParams.ActivityResult.logout))
|
||||
.setPositiveButton(getString(R.string.ext), (dialog, id) -> parentTab.whenBackPressed(AppParams.ActivityResult.exit))
|
||||
.setNegativeButton(getString(R.string.cancel), (dialog, id) -> dialog.cancel());
|
||||
AlertDialog alert = builder.create();
|
||||
alert.show();
|
||||
}
|
||||
|
||||
private void setDate() {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
endDate = calendar.getTime();
|
||||
|
@ -42,6 +42,7 @@ public class RecordingsActivity extends Activity {
|
||||
private GridView gridView;
|
||||
private RecordingsGridViewAdapter adapter;
|
||||
private View convertViewRecording;
|
||||
private boolean isRecordingPlaying = false;
|
||||
|
||||
private int playingPosition = -1;
|
||||
|
||||
@ -89,6 +90,7 @@ public class RecordingsActivity extends Activity {
|
||||
gridView.setAdapter(adapter);
|
||||
|
||||
gridView.setOnItemClickListener(onItemClickListener);
|
||||
gridView.setOnTouchListener((v, event) -> isRecordingPlaying);
|
||||
|
||||
if (recHandle == null && !AppParams.DEMO)
|
||||
recHandle = new RecordingHandle(AppParams.IP);
|
||||
@ -171,12 +173,17 @@ public class RecordingsActivity extends Activity {
|
||||
SM.Debug("onResume");
|
||||
}
|
||||
|
||||
|
||||
|
||||
private final OnItemClickListener onItemClickListener = new OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> arg0, View view, int position, long arg3) {
|
||||
|
||||
// disable grid scrolling and item click
|
||||
gridView.setEnabled(false);
|
||||
if (isRecordingPlaying)
|
||||
return;
|
||||
|
||||
isRecordingPlaying = true;
|
||||
setConvertViewRecording(view);
|
||||
|
||||
// change background to playing
|
||||
@ -262,7 +269,7 @@ public class RecordingsActivity extends Activity {
|
||||
adapter.changePlaying(getPlayingPosition(), false);
|
||||
|
||||
// enable grid
|
||||
gridView.setEnabled(true);
|
||||
isRecordingPlaying = false;
|
||||
|
||||
// set playing Recording position to -1
|
||||
setPlayingPosition(-1);
|
||||
|
Loading…
Reference in New Issue
Block a user