SwipeListViewTouchListener touchListener = new SwipeListViewTouchListener(listview, new SwipeListViewTouchListener.OnSwipeCallback() {
private int position;
@
Override
public void onSwipeLeft(ListView listView, int[] reverseSortedPositions) {
String telefonoempresa = choferes.get(position).getTelefonoempresa();
if (telefonoempresa.contains("----------")) {
Toast.makeText(getApplicationContext(), "TELEFONO NO DISPONIBLE", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(getApplicationContext(), "RED LAR" + telefonoempresa, Toast.LENGTH_SHORT).show();
Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:" + telefonoempresa));
startActivity(intent);
}
}
@
Override
public void onSwipeRight(ListView listView, int[] reverseSortedPositions) {
String telefonoparticular = choferes.get(position).getTelefonoparticular();
if (telefonoparticular.contains("----------")) {
Toast.makeText(getApplicationContext(), "TELEFONO NO DISPONIBLE", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(getApplicationContext(), "TELEFONO PARTICULAR" + telefonoparticular, Toast.LENGTH_SHORT).show();
Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:" + telefonoparticular));
startActivity(intent);
}
}
}, true, false);
listview.setOnTouchListener(touchListener);