|
|
@@ -2,6 +2,7 @@ package com.usai.redant.apexdrivers.Detail;
|
|
|
|
|
|
import android.app.ProgressDialog;
|
|
|
import android.content.Context;
|
|
|
+import android.content.DialogInterface;
|
|
|
import android.content.Intent;
|
|
|
import android.graphics.Color;
|
|
|
import android.graphics.drawable.BitmapDrawable;
|
|
|
@@ -32,6 +33,7 @@ import android.widget.TextView;
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
import com.usai.redant.apexdrivers.ApexDriverApplication;
|
|
|
+import com.usai.redant.apexdrivers.Detail.Model.DetailActionModel;
|
|
|
import com.usai.redant.apexdrivers.Detail.Model.DetailActionSelectionModel;
|
|
|
import com.usai.redant.apexdrivers.Detail.Model.DetailLocationModel;
|
|
|
import com.usai.redant.apexdrivers.Detail.Model.DetailSubActionModel;
|
|
|
@@ -52,6 +54,7 @@ import java.util.ArrayList;
|
|
|
|
|
|
import static com.usai.redant.apexdrivers.Detail.Model.DetailSubActionModel.DetailActionSubType.DetailActionSubTypeAccept;
|
|
|
import static com.usai.redant.apexdrivers.Detail.Model.DetailSubActionModel.DetailActionSubType.DetailActionSubTypeEnum;
|
|
|
+import static com.usai.redant.apexdrivers.Detail.Model.DetailSubActionModel.DetailActionSubType.DetailActionSubTypeUpdate;
|
|
|
import static com.usai.redant.rautils.Utils.Network.RESULT_TRUE;
|
|
|
|
|
|
public class DetailActivity extends AppCompatActivity implements DetailAdapter.DetailActionDelegate {
|
|
|
@@ -317,20 +320,65 @@ public class DetailActivity extends AppCompatActivity implements DetailAdapter.D
|
|
|
showWindow(view,actionModel.enums);
|
|
|
}
|
|
|
|
|
|
+ private void showUpdate(DetailSubActionModel model) {
|
|
|
+
|
|
|
+ Intent intent = UpdateActivity.build(mCtx,mOrderID,model.actionID,model.actionTitle,mOrderType2);
|
|
|
+ mCtx.startActivity(intent);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Detail Action
|
|
|
* */
|
|
|
|
|
|
@Override
|
|
|
- public void performAction(View view,DetailSubActionModel actionModel) {
|
|
|
+ public void performAction(final View view, final DetailSubActionModel actionModel) {
|
|
|
+
|
|
|
+ if (actionModel.alert) {
|
|
|
+
|
|
|
+ new AlertDialog.Builder(mCtx)
|
|
|
+ .setTitle(actionModel.alertTitle)
|
|
|
+ .setMessage(actionModel.alertMsg)
|
|
|
+ .setNegativeButton("Cancel",null)
|
|
|
+ .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(DialogInterface dialog, int which) {
|
|
|
+ handleAction(view,actionModel);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .show();
|
|
|
+
|
|
|
+ } else {
|
|
|
+ handleAction(view,actionModel);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void navigationTo(DetailLocationModel locationModel) {
|
|
|
+
|
|
|
+ Uri gmmIntentUri = Uri.parse("google.navigation:q=" + locationModel.location + "&mode=d");
|
|
|
+ Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
|
|
|
+ mapIntent.setPackage("com.google.android.apps.maps");
|
|
|
+ if (mapIntent.resolveActivity(getPackageManager()) != null) {
|
|
|
+ startActivity(mapIntent);
|
|
|
+ } else {
|
|
|
+ Toast.makeText(mCtx,"There is no google map",Toast.LENGTH_LONG).show();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void handleAction(View view,DetailSubActionModel actionModel) {
|
|
|
|
|
|
switch (actionModel.actionType) {
|
|
|
case DetailSubActionModel.DetailActionType.DetailActionTypeLocal: {
|
|
|
|
|
|
if (actionModel.actionSubType == DetailActionSubTypeEnum) {
|
|
|
handleEnumAction(view,actionModel);
|
|
|
+ } else if (actionModel.actionSubType == DetailActionSubTypeUpdate) {
|
|
|
+ showUpdate(actionModel);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
}
|
|
|
break;
|
|
|
case DetailSubActionModel.DetailActionType.DetailActionTypeRemote: {
|
|
|
@@ -345,21 +393,6 @@ public class DetailActivity extends AppCompatActivity implements DetailAdapter.D
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void navigationTo(DetailLocationModel locationModel) {
|
|
|
-
|
|
|
- Uri gmmIntentUri = Uri.parse("google.navigation:q=" + locationModel.location + "&mode=d");
|
|
|
- Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
|
|
|
- mapIntent.setPackage("com.google.android.apps.maps");
|
|
|
- if (mapIntent.resolveActivity(getPackageManager()) != null) {
|
|
|
- startActivity(mapIntent);
|
|
|
- } else {
|
|
|
- Toast.makeText(mCtx,"There is no google map",Toast.LENGTH_LONG).show();
|
|
|
- }
|
|
|
-
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -498,14 +531,41 @@ public class DetailActivity extends AppCompatActivity implements DetailAdapter.D
|
|
|
@Override
|
|
|
public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
|
|
|
|
|
|
+ final DetailActionSelectionModel model = models.get(position);
|
|
|
|
|
|
- if (popupWindow != null) {
|
|
|
- popupWindow.dismiss();
|
|
|
- }
|
|
|
+ if (position != 0) {
|
|
|
+
|
|
|
+ DetailActionSelectionModel currentModel = models.get(0);
|
|
|
+
|
|
|
+ new AlertDialog.Builder(mCtx)
|
|
|
+ .setTitle("Warning")
|
|
|
+ .setMessage("the " + currentModel.actionTitle + " is not done,are you sure to update " + model.actionTitle + " now?")
|
|
|
+ .setNegativeButton("Cancel",null)
|
|
|
+ .setPositiveButton("YES", new DialogInterface.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(DialogInterface dialog, int which) {
|
|
|
+ if (popupWindow != null) {
|
|
|
+ popupWindow.dismiss();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ Intent intent = UpdateActivity.build(mCtx,mOrderID,model.actionID,model.actionTitle,mOrderType2);
|
|
|
+ mCtx.startActivity(intent);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .show();
|
|
|
|
|
|
- DetailActionSelectionModel model = models.get(position);
|
|
|
- Intent intent = UpdateActivity.build(mCtx,mOrderID,model.actionID,model.actionTitle,mOrderType2);
|
|
|
- mCtx.startActivity(intent);
|
|
|
+ } else {
|
|
|
+
|
|
|
+ if (popupWindow != null) {
|
|
|
+ popupWindow.dismiss();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ Intent intent = UpdateActivity.build(mCtx,mOrderID,model.actionID,model.actionTitle,mOrderType2);
|
|
|
+ mCtx.startActivity(intent);
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
}
|