示例#1
0
  private void showDialog(String title, String message, int dialogType, int alertType) {

    switch (dialogType) {
      case DIALOG_TYPE_PROGRESS:
        reqProgress = new ProgressDialog(this);
        reqProgress.setTitle(title);
        reqProgress.setMessage(message);

        reqProgress.show();
        break;
      case DIALOG_TYPE_NOTIFY:
        reDialog = new AlertDialog.Builder(this).create();
        reDialog.setTitle(title);

        reDialog.setMessage(message);
        reDialog.show();
        break;

      case DIALOG_TYPE_ALERT:
        try {
          reDialog = new AlertDialog.Builder(this).create();
          reDialog.setTitle(title);

          reDialog.setMessage(message);
          if (alertType == ALERT_TYPE_SUCCESS) {

            reDialog.setButton(
                DialogInterface.BUTTON_NEUTRAL,
                "OK",
                new DialogInterface.OnClickListener() {

                  @Override
                  public void onClick(DialogInterface arg0, int arg1) {
                    // TODO Auto-generated method stub
                    finish();
                  }
                });
          } else if (alertType == ALERT_TYPE_FAILURE) {
            reDialog.setButton(
                DialogInterface.BUTTON_NEUTRAL,
                "OK",
                new DialogInterface.OnClickListener() {

                  @Override
                  public void onClick(DialogInterface arg0, int arg1) {
                    // TODO Auto-generated method stub

                  }
                });
          }
          reDialog.show();
        } catch (NullPointerException e) {
          e.printStackTrace();
        }
        break;
    }
  }
  private void showLogoutDialog() {
    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(MainActivity.this);
    alertDialogBuilder.setTitle("Logout");
    alertDialogBuilder
        .setMessage("Are you sure want to logout?")
        .setCancelable(false)
        .setPositiveButton(
            "Yes",
            new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int id) {
                mUserPreference.clear();
                Intent mIntent = new Intent(MainActivity.this, LoginActivity.class);
                startActivity(mIntent);
                finish();
              }
            })
        .setNegativeButton(
            "No",
            new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int id) {

                dialog.cancel();
              }
            });

    AlertDialog alertDialog = alertDialogBuilder.create();
    alertDialog.show();
  }
 /** Helper method for deleting the selected card. */
 private void deleteCard() {
   AlertDialog.Builder dialog = new AlertDialog.Builder(getActivity());
   dialog.setTitle("Delete this card?");
   dialog
       .setCancelable(false)
       .setPositiveButton(
           "OK",
           new DialogInterface.OnClickListener() {
             public void onClick(DialogInterface dialog, int id) {
               new DeleteCardWebTask().execute(mUser, mUserList);
               CardInfoDB cardInfoDB = new CardInfoDB(getActivity());
               ArtCard.CardInfo cardToRemove = MainActivity.getCurrentCard();
               cardInfoDB.deleteCardByArtistTitle(
                   cardToRemove.getArtist(), cardToRemove.getTitle());
               ArtCard.ITEMS.remove(MainActivity.getCurrentCard());
               cardInfoDB.closeDB();
             }
           })
       .setNegativeButton(
           "Cancel",
           new DialogInterface.OnClickListener() {
             public void onClick(DialogInterface dialog, int id) {
               dialog.cancel();
             }
           });
   AlertDialog alert = dialog.create();
   alert.show();
 }
示例#4
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    switch (id) {
      case R.id.action_logout:
        ParseUser.logOut();
        navigateToLogin();
        break;
      case R.id.action_edit_friends:
        Intent intent = new Intent(MainActivity.this, EditFriendsActivity.class);
        startActivity(intent);
        break;
      case R.id.action_camera:
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setItems(R.array.camera_choices, mDialogListener);
        AlertDialog dialog = builder.create();
        dialog.show();
    }

    return super.onOptionsItemSelected(item);
  }
  public static void show(Context context, ScheduleView.CourseList list) {
    LayoutInflater inflater =
        (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.dialog_schedule, null);
    RedPagerView view = (RedPagerView) layout.findViewById(R.id.course_viewpager);

    if (list.list.size() == 1 && list.list.get(0).getCourseType() == 2) {
      ViewGroup.LayoutParams params = view.getLayoutParams();
      params.height = DensityUtils.dp2px(context, 220);
      view.setLayoutParams(params);
    }

    AlertDialog dialog =
        new AlertDialog.Builder(context)
            .setTitle("详细信息")
            .setCancelable(true)
            .setView(
                layout,
                DensityUtils.dp2px(context, 12),
                DensityUtils.dp2px(context, 24),
                DensityUtils.dp2px(context, 12),
                DensityUtils.dp2px(context, 24))
            .create();

    CoursePagerAdapter adapter = new CoursePagerAdapter(context, inflater, list, dialog);
    view.setAdapter(adapter);
    dialog.show();
  }
  void showLongDialog(final int pos) {
    AlertDialog dialog =
        new AlertDialog.Builder(mContext)
            .setTitle("开发者选项")
            .setItems(
                R.array.array_device_dialog,
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int which) {
                    switch (which) {
                      case 0:
                        showTextInputDialog(pos, Constant.TYPE_MSG_FORMAT_AT);
                        break;
                      case 1:
                        showTextInputDialog(pos, Constant.TYPE_MSG_FORMAT_LUA);
                        break;
                      case 2:
                        requestRefresh(pos);

                        break;
                    }
                  }
                })
            .create();
    dialog.show();
  }
示例#7
0
  @SuppressLint("SetJavaScriptEnabled")
  protected void loginWebview(final OsmOAuth.AuthType type) {
    final WebView webview = new InputWebView(mFragment.getActivity());
    webview.getSettings().setJavaScriptEnabled(true);
    final AlertDialog dialog =
        new AlertDialog.Builder(mFragment.getActivity()).setView(webview).create();

    ThreadPool.getWorker()
        .execute(
            new Runnable() {
              @Override
              public void run() {
                final String[] auth =
                    (type == OsmOAuth.AuthType.FACEBOOK)
                        ? OsmOAuth.nativeGetFacebookAuthUrl()
                        : OsmOAuth.nativeGetGoogleAuthUrl();

                UiThread.run(
                    new Runnable() {
                      @Override
                      public void run() {
                        if (mFragment.isAdded()) loadWebviewAuth(dialog, webview, auth, type);
                      }
                    });
              }
            });

    dialog.show();
  }
示例#8
0
  public void showTelescopeDialog(final Activity activity) {
    LayoutInflater inflater = LayoutInflater.from(activity);
    TelescopeLayout content =
        (TelescopeLayout) inflater.inflate(R.layout.telescope_tutorial_dialog, null);
    final AlertDialog dialog =
        new AlertDialog.Builder(activity).setView(content).setCancelable(false).create();

    content.setLens(
        new Lens() {
          @Override
          public void onCapture(File file) {
            dialog.dismiss();

            Context toastContext =
                new ContextThemeWrapper(activity, android.R.style.Theme_DeviceDefault_Dialog);
            LayoutInflater toastInflater = LayoutInflater.from(toastContext);
            Toast toast = Toast.makeText(toastContext, "", Toast.LENGTH_SHORT);
            View toastView = toastInflater.inflate(R.layout.telescope_tutorial_toast, null);
            toast.setView(toastView);
            toast.setGravity(Gravity.CENTER, 0, 0);
            toast.show();
          }
        });

    dialog.show();
  }
  public void buttonDeleteClick(View view) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder
        .setMessage(getString(R.string.delete_thing_dialog_msg))
        .setTitle(getString(R.string.delete_thing_dialog_title))
        .setPositiveButton(
            getString(R.string.yes),
            new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int id) {
                ThingsDB db = new ThingsDB(PhotoLocationActivity.this);
                db.deleteThing(PhotoLocationActivity.this.thingId);
                db.cleanup();

                dialog.cancel();
                PhotoLocationActivity.this.finish();
              }
            })
        .setNegativeButton(
            getString(R.string.no),
            new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int id) {
                dialog.dismiss();
              }
            });
    AlertDialog dialog = builder.create();
    dialog.show();
  }
示例#10
0
 @Override
 public void renderDiskVideo(final List<String> entities) {
   final AlertDialog dialog =
       new AlertDialog.Builder(getActivity())
           .setTitle("提示")
           .setMessage("检测到新的文件,是否进行编辑")
           .setPositiveButton(
               "编辑",
               new DialogInterface.OnClickListener() {
                 @Override
                 public void onClick(DialogInterface dialog, int which) {
                   Intent intent = new Intent(getActivity(), MovieDiskActivity.class);
                   intent.putStringArrayListExtra(MOVIE_DISK_DATA, (ArrayList<String>) entities);
                   startActivityForResult(intent, MovieActivity.MOVIE_DISK_REQUEST_CODE);
                 }
               })
           .setNegativeButton(
               "取消",
               new DialogInterface.OnClickListener() {
                 @Override
                 public void onClick(DialogInterface dialog, int which) {
                   dialog.dismiss();
                 }
               })
           .create();
   dialog.show();
 }
 public static AlertDialog msgBoxYesNo(
     Context context,
     String title,
     String msg,
     final DialogInterface.OnClickListener listener,
     boolean canceledOnTouchOutside) {
   AlertDialog msgAlert = new AlertDialog.Builder(context).create();
   msgAlert.setTitle(title);
   msgAlert.setCanceledOnTouchOutside(canceledOnTouchOutside);
   msgAlert.setMessage(msg);
   msgAlert.setButton(
       DialogInterface.BUTTON_POSITIVE,
       context.getResources().getString(R.string.yes),
       new DialogInterface.OnClickListener() {
         @Override
         public void onClick(DialogInterface dialog, int which) {
           listener.onClick(dialog, MSG_BUTTON_YES);
         }
       });
   msgAlert.setButton(
       DialogInterface.BUTTON_NEGATIVE,
       context.getResources().getString(R.string.no),
       new DialogInterface.OnClickListener() {
         @Override
         public void onClick(DialogInterface dialog, int which) {
           listener.onClick(dialog, MSG_BUTTON_NO);
         }
       });
   msgAlert.show();
   return msgAlert;
 }
示例#12
0
 @Override
 public void onCityDelete(final City city) {
   final IActionUI context = this;
   // TODO: delete city on long press
   AlertDialog.Builder builder = new AlertDialog.Builder(this);
   builder.setTitle("Remove " + city.getName() + "?");
   builder.setPositiveButton(
       android.R.string.yes,
       new DialogInterface.OnClickListener() {
         public void onClick(DialogInterface dialog, int id) {
           // Start delete task!
           new DeleteCityThread(dataBase, city, context).start();
           dialog.dismiss();
         }
       });
   builder.setNegativeButton(
       android.R.string.no,
       new DialogInterface.OnClickListener() {
         public void onClick(DialogInterface dialog, int id) {
           dialog.dismiss();
         }
       });
   AlertDialog dialog = builder.create();
   dialog.show();
 }
  private void showDeleteDialog() {
    if (mDialogDel == null) {
      mDialogDel =
          new AlertDialog.Builder(this)
              .setTitle(R.string.dialog_ask_delete_title)
              .setMessage(R.string.dialog_ask_delete_summary)
              .setPositiveButton(
                  android.R.string.ok,
                  new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                      new DeleteTask().execute();
                    }
                  })
              .setNegativeButton(
                  android.R.string.cancel,
                  new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                      mDialogDel.dismiss();
                    }
                  })
              .create();
    }

    mDialogDel.show();
  }
示例#14
0
 public void buy(final Book book, final int position) {
   dialog =
       new AlertDialog.Builder(this)
           .setTitle(book.ordered == null ? "确定要预定吗?" : "确定要取消预定吗?")
           .setMessage("书名:" + book.book_name)
           .setPositiveButton(
               "确定",
               new DialogInterface.OnClickListener() {
                 @Override
                 public void onClick(DialogInterface dialog, int which) {
                   showLoadingDialog("操作中,请稍候...");
                   BookGetUtils.orderOneBook(
                       MainActivity.this,
                       new CacheUtils(MainActivity.this, CacheUtils.CacheType.FOR_ACCOUNT)
                           .getCache(CacheUtils.USER_NAME),
                       book.book_id,
                       book.ordered == null ? "1" : "0",
                       position,
                       handler);
                 }
               })
           .setNegativeButton(
               "取消",
               new DialogInterface.OnClickListener() {
                 @Override
                 public void onClick(DialogInterface dialog, int which) {
                   dialog.cancel();
                 }
               })
           .create();
   dialog.show();
 }
  private void addNewPodcast() {
    View dialogView = context.getLayoutInflater().inflate(R.layout.create_podcast, null);
    final TextView urlBox = (TextView) dialogView.findViewById(R.id.create_podcast_url);

    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder
        .setTitle(R.string.menu_add_podcast)
        .setView(dialogView)
        .setPositiveButton(
            R.string.common_ok,
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int id) {
                addNewPodcast(urlBox.getText().toString());
              }
            })
        .setNegativeButton(
            R.string.common_cancel,
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int id) {
                dialog.cancel();
              }
            })
        .setCancelable(true);

    AlertDialog dialog = builder.create();
    dialog.show();
  }
  private void showDeleteOrDownloadDialog(final int count, String downloadPath) {
    if (mDialogDelOrDownload == null) {
      mDialogDelOrDownload =
          new AlertDialog.Builder(this)
              .setTitle(R.string.dialog_ask_d_or_d_title)
              .setMessage(getString(R.string.dialog_ask_d_or_d_summary, count, downloadPath))
              .setPositiveButton(
                  R.string.dialog_ask_d_or_d_continue,
                  new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                      startDownload(count);
                    }
                  })
              .setNeutralButton(
                  R.string.dialog_ask_d_or_d_delete,
                  new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                      new DeleteTask().execute();
                    }
                  })
              .setNegativeButton(
                  android.R.string.cancel,
                  new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                      mDialogDelOrDownload.dismiss();
                    }
                  })
              .create();
    }

    mDialogDelOrDownload.show();
  }
  private void showTextInputDialog(final int pos, final String type) {

    String title = "发送运程" + type + "指令";

    LayoutInflater factory = LayoutInflater.from(mContext);
    final View textEntryView = factory.inflate(R.layout.dialog_text_input, null);

    final EditText et = (EditText) textEntryView.findViewById(R.id.et_message);

    AlertDialog dialog =
        new AlertDialog.Builder(mContext)
            .setTitle(title)
            .setView(textEntryView)
            .setPositiveButton(
                "ok",
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int whichButton) {

                    String msg = et.getEditableText().toString();
                    requestPushMsg(pos, type, msg);
                  }
                })
            .setNegativeButton(
                "cancel",
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int whichButton) {

                    dialog.cancel();
                  }
                })
            .create();
    dialog.show();
  }
  private void showDialog() {

    AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
    builder
        .setTitle("Выбирите действие.")
        .setMessage("Вы желаете подтвердить?")
        .setPositiveButton(
            "Да",
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int which) {
                String currTime = new SimpleDateFormat("HH:mm").format(new Date());
                list.add(new FragmentComponentsList(5, "Именено", "сегодня," + currTime));
                mAdapter.notifyDataSetChanged();
                initDeleteBtn();
              }
            })
        .setNegativeButton(
            "Нет",
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int which) {}
            });
    AlertDialog alertDialog = builder.create();
    alertDialog.show();
  }
示例#19
0
  // if user clicks and holds and item
  @Override
  public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
    held = true;
    final int currentPos = position;
    // make sure it is not empty
    if (!inventory.get(position).equals("No items in inventory")) {
      // delete the item form the database
      // dbHandler.deleteItem(inventory.get(position).split("     --     ")[0]);
      // Tell the user it was deleted
      // Toast.makeText(this, inventory.get(position).split("     --     ")[0] + " removed",
      // Toast.LENGTH_SHORT).show();
      AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
      alertDialogBuilder.setTitle("Update Item");
      final EditText input = new EditText(MainActivity.this);
      LinearLayout.LayoutParams lp =
          new LinearLayout.LayoutParams(
              LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
      input.setLayoutParams(lp);
      alertDialogBuilder.setView(input);
      alertDialogBuilder
          .setMessage("Set new amount")
          .setCancelable(true)
          .setPositiveButton(
              "Update",
              new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                  held = false;
                  dbHandler.updateItem(
                      inventory.get(currentPos).split("     --     ")[0],
                      Integer.valueOf(input.getText().toString()));
                  // clear the inventory list
                  inventory.clear();
                  // fill the list view
                  populateList();
                  adapter.notifyDataSetChanged();
                }
              })
          .setNegativeButton(
              "Delete",
              new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                  held = false;
                  dbHandler.deleteItem(inventory.get(currentPos).split("     --     ")[0]);
                  // clear the inventory list
                  inventory.clear();
                  // fill the list view
                  populateList();
                  adapter.notifyDataSetChanged();
                }
              });

      // create alert dialog
      AlertDialog alertDialog = alertDialogBuilder.create();

      // show it
      alertDialog.show();
    }
    return false;
  }
 /*
  * Creates an connect UI dialog
  */
 private void showConnectDialog() {
   EditText roomEditText = new EditText(this);
   alertDialog =
       Dialog.createConnectDialog(
           roomEditText,
           connectClickListener(roomEditText),
           cancelConnectDialogClickListener(),
           this);
   alertDialog.show();
 }
示例#21
0
 private void finalDecision() {
   if (serverSuccess == 1) {
     progressDialog.dismiss();
     Intent intent = new Intent(SelectSurvey.this, SurveyInformation.class);
     intent.putExtra("SURVEY_DATA", surveyData);
     startActivity(intent);
     finish();
   } else if (serverSuccess == 3) {
     progressDialog.dismiss();
     builder.setCancelable(false);
     builder.setTitle("User ID Incorrect");
     builder.setMessage(serverMessage);
     builder.setPositiveButton(
         "Okay",
         new DialogInterface.OnClickListener() {
           @Override
           public void onClick(DialogInterface dialog, int which) {
             editor.putBoolean(ApplicationHelper.SUCCESSFUL_LOGIN_HISTORY, false);
             editor.apply();
             dialog.cancel();
             startActivity(new Intent(SelectSurvey.this, Login.class));
             finish();
           }
         });
     alertDialog = builder.create();
     alertDialog.show();
   } else {
     progressDialog.dismiss();
     builder.setCancelable(false);
     builder.setTitle("Information");
     builder.setMessage(serverMessage);
     builder.setPositiveButton(
         "Okay",
         new DialogInterface.OnClickListener() {
           @Override
           public void onClick(DialogInterface dialog, int which) {
             dialog.cancel();
           }
         });
     alertDialog = builder.create();
     alertDialog.show();
   }
 }
示例#22
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {
      case R.id.action_update_repo:
        UpdateService.updateNow(this);
        return true;

      case R.id.action_manage_repos:
        startActivity(new Intent(this, ManageReposActivity.class));
        return true;

      case R.id.action_settings:
        Intent prefs = new Intent(getBaseContext(), PreferencesActivity.class);
        startActivityForResult(prefs, REQUEST_PREFS);
        return true;

      case R.id.action_swap:
        startActivity(new Intent(this, SwapWorkflowActivity.class));
        return true;

      case R.id.action_bluetooth_apk:
        /*
         * If Bluetooth has not been enabled/turned on, then enabling
         * device discoverability will automatically enable Bluetooth
         */
        Intent discoverBt = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
        discoverBt.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 121);
        startActivityForResult(discoverBt, REQUEST_ENABLE_BLUETOOTH);
        // if this is successful, the Bluetooth transfer is started
        return true;

      case R.id.action_about:
        View view = LayoutInflater.from(this).inflate(R.layout.about, null);

        String versionName = Utils.getVersionName(this);
        if (versionName != null) {
          ((TextView) view.findViewById(R.id.version)).setText(versionName);
        }

        AlertDialog alrt = new AlertDialog.Builder(this).setView(view).create();
        alrt.setTitle(R.string.about_title);
        alrt.setButton(
            AlertDialog.BUTTON_NEGATIVE,
            getString(R.string.ok),
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int whichButton) {}
            });
        alrt.show();
        return true;
    }
    return super.onOptionsItemSelected(item);
  }
  private void addFeedback(final String username) {
    Log.d("TarotFeedback", "username :: " + username);
    View dialogLayout = LayoutInflater.from(this).inflate(R.layout.feedback_alert_dialog, null);
    AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.AppCompatAlertDialogStyle);
    builder.setView(dialogLayout);
    EditText usernameEditText = (EditText) dialogLayout.findViewById(R.id.user_edittext);
    usernameEditText.setText(username);
    final CommentEditText commentEditText =
        (CommentEditText) dialogLayout.findViewById(R.id.feedback_edittext);
    final RatingBar feedbackRating = (RatingBar) dialogLayout.findViewById(R.id.rating);

    final AlertDialog customAlertDialog = builder.create();
    final Button saveButton = (Button) dialogLayout.findViewById(R.id.feedback_button);

    final Feedback feedbackFromPreference = readFromPreference();
    commentEditText.setText(feedbackFromPreference.getFeedback());
    feedbackRating.setRating((float) feedbackFromPreference.getRating());

    if (!TextUtils.isEmpty(feedbackFromPreference.getObjectId())) {
      saveButton.setText(R.string.update_button_label);
    }
    saveButton.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            String comment = commentEditText.getText().toString();
            String user = username;
            float rating = feedbackRating.getRating();
            if (TextUtils.isEmpty(comment)) {
              Toast.makeText(
                      TarotFeedbackActivity.this,
                      getString(R.string.save_error_2),
                      Toast.LENGTH_SHORT)
                  .show();
              return;
            }

            if (rating == 0.0f) {
              Toast.makeText(
                      TarotFeedbackActivity.this,
                      getString(R.string.save_error_1),
                      Toast.LENGTH_SHORT)
                  .show();
              return;
            }
            submitFeedback(
                comment, user, rating, feedbackFromPreference.getObjectId(), customAlertDialog);
          }
        });
    customAlertDialog.show();
  }
 private void showDeleteDialog() {
   AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
   builder
       .setMessage(R.string.video_dialog_delete_title)
       .setPositiveButton(
           R.string.video_dialog_delete_positive_button,
           new DialogInterface.OnClickListener() {
             @Override
             public void onClick(DialogInterface dialog, int id) {
               String ids = albumId == 0 ? "-1, -2" : String.valueOf(albumId);
               VKRequest deleteRequest =
                   VKApi.video()
                       .removeFromAlbum(
                           VKParameters.from(
                               VKApiConst.VIDEO_ID, videoList.get(clickedPosition).id,
                               VKApiConst.OWNER_ID, videoList.get(clickedPosition).owner_id,
                               VKApiConst.ALBUM_IDS, ids));
               deleteRequest.executeWithListener(
                   new VKRequest.VKRequestListener() {
                     @Override
                     public void onComplete(VKResponse response) {
                       super.onComplete(response);
                       Toast.makeText(
                               getActivity(),
                               getString(
                                   R.string.video_dialog_delete_success_toast,
                                   videoList.get(clickedPosition).title),
                               Toast.LENGTH_SHORT)
                           .show();
                       videoList.remove(clickedPosition);
                       videoAdapter.notifyItemRemoved(clickedPosition);
                       videoAdapter.notifyItemRangeChanged(
                           clickedPosition, videoAdapter.getItemCount());
                     }
                   });
             }
           })
       .setNegativeButton(
           R.string.video_dialog_delete_negative_button,
           (dialog, id) -> {
             dialog.cancel();
           });
   AlertDialog alertDialog = builder.create();
   alertDialog.show();
   alertDialog
       .getButton(DialogInterface.BUTTON_NEGATIVE)
       .setTextColor(getResources().getColor(R.color.colorPrimary));
   alertDialog
       .getButton(DialogInterface.BUTTON_POSITIVE)
       .setTextColor(getResources().getColor(R.color.colorPrimary));
 }
示例#25
0
    @Override
    public void onClick(final View v) {
      int position = (int) v.getTag();
      AlertDialog.Builder builder =
          new AlertDialog.Builder(
              new ContextThemeWrapper(v.getContext(), R.style.HomePageDialogboxCustom));

      if (position == 0) {
        Intent gotolistofpet = new Intent(v.getContext(), PetList.class);
        v.getContext().startActivity(gotolistofpet);
      }
      if (position == 1) {
        Intent gotoShopProduct = new Intent(v.getContext(), Pet_Shop_List.class);
        v.getContext().startActivity(gotoShopProduct);
      }
      if (position == 2) {
        Intent gotoCampaign = new Intent(v.getContext(), Campaign_List_ForAll.class);
        v.getContext().startActivity(gotoCampaign);
      }
      if (position == 3) {
        Intent gotoPetServices = new Intent(v.getContext(), PetServices.class);
        v.getContext().startActivity(gotoPetServices);
      }
      if (position == 4) {
        adapter = new DialogListAdapter(dialogListForPetClinic);
        final Intent gotoPetClinic = new Intent(v.getContext(), PetClinic.class);
        builder.setAdapter(
            adapter,
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialogInterface, int i) {
                if (i == 0) {
                  state = 0;
                  gotoPetClinic.putExtra("STATE_OF_CLICK", state);
                  v.getContext().startActivity(gotoPetClinic);

                } else if (i == 1) {
                  state = 1;
                  gotoPetClinic.putExtra("STATE_OF_CLICK", state);
                  v.getContext().startActivity(gotoPetClinic);
                }
              }
            });
        alertDialog = builder.create();
        alertDialog.show();
      }
      if (position == 5) {
        Intent gotolistofpet = new Intent(v.getContext(), PetMateList.class);
        v.getContext().startActivity(gotolistofpet);
      }
    }
 // Show a dialog that network is not available
 private static void showNetworkUnavailableDialog(Activity activity) {
   AlertDialog alertDialog = new AlertDialog.Builder(activity).create();
   alertDialog.setTitle("No Internet Access!");
   alertDialog.setMessage("Please check your connection and try again.");
   alertDialog.setButton(
       AlertDialog.BUTTON_NEUTRAL,
       "OK",
       new DialogInterface.OnClickListener() {
         public void onClick(DialogInterface dialog, int which) {
           dialog.dismiss();
         }
       });
   alertDialog.show();
 }
示例#27
0
 private void addMovie() {
   View movieView = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_movie, null, false);
   final EditText editText = (EditText) movieView.findViewById(R.id.et_add_movie_name);
   AlertDialog.Builder builder =
       new AlertDialog.Builder(getActivity())
           .setTitle("创建电影")
           .setView(movieView)
           .setPositiveButton(
               "确定",
               new DialogInterface.OnClickListener() {
                 @Override
                 public void onClick(DialogInterface dialog, int which) {
                   // 获取字符串
                   String[] results = editText.getText().toString().split("\\n");
                   List<Movie> movies = new ArrayList<Movie>();
                   for (String result : results) {
                     if (TextUtils.isEmpty(result)) {
                       continue;
                     }
                     Log.d("addMovie", result);
                     Movie movie = new Movie();
                     movie.setName(result);
                     movies.add(movie);
                   }
                   List<Movie> oldMovies = mAdapter.getDatum();
                   mPresenter.addMovies(movies, oldMovies);
                 }
               })
           .setNegativeButton(
               "取消",
               new DialogInterface.OnClickListener() {
                 @Override
                 public void onClick(DialogInterface dialog, int which) {
                   dialog.dismiss();
                 }
               });
   AlertDialog dialog = builder.create();
   dialog.show();
   movieView.requestFocus();
   // 延迟弹出弹出软键盘
   new Timer()
       .schedule(
           new TimerTask() {
             @Override
             public void run() {
               CommonHelper.openSoftKeyBoard(getActivity());
             }
           },
           200);
 }
示例#28
0
  public static void showShareDialog(final Context mContext, GCSavedSet savedSet) {
    AlertDialog.Builder alert = new AlertDialog.Builder(mContext);
    alert.setTitle(mContext.getString(R.string.share_code));
    alert.setIcon(R.drawable.ic_share_black_48dp);

    TextView input = new TextView(mContext);
    input.setTextIsSelectable(true);
    final String shareString = getShareString(savedSet);
    input.setText(shareString);
    input.setGravity(Gravity.CENTER_HORIZONTAL);
    input.setPadding(64, 32, 64, 32);
    alert.setView(input);

    alert.setPositiveButton(
        mContext.getString(R.string.copy),
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int whichButton) {
            ClipboardManager clipboard =
                (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
            ClipData clip = ClipData.newPlainText("Copied Text", shareString);
            clipboard.setPrimaryClip(clip);
            Toast.makeText(mContext, "Copied to clipboard", Toast.LENGTH_SHORT).show();
            dialog.dismiss();
          }
        });
    alert.setNegativeButton(
        mContext.getString(R.string.share),
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
            Intent sendIntent = new Intent();
            sendIntent.setAction(Intent.ACTION_SEND);
            sendIntent.putExtra(
                Intent.EXTRA_TEXT,
                "https://deeplink.me/glovercolorapp.com/entercode/" + shareString);
            sendIntent.setType("text/plain");
            mContext.startActivity(Intent.createChooser(sendIntent, "Share gloving set with"));
          }
        });
    alert.setNeutralButton(
        mContext.getString(R.string.cancel),
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
          }
        });
    AlertDialog alertDialog = alert.create();
    alertDialog.show();
  }
示例#29
0
  public void showMultihostSelectDialog(final ArrayList<HostBriefInfo> hosts) {
    String[] mPossibleItems = new String[hosts.size()];

    double distance =
        Tools.calculateDistanceBetween(
            hosts.get(0).getLatLng(), mLastDeviceLocation, mDistanceUnit);
    String distanceSummary =
        getString(R.string.distance_from_current, (int) distance, mDistanceUnit);

    LinearLayout customTitleView =
        (LinearLayout) getLayoutInflater().inflate(R.layout.multihost_dialog_header, null);
    TextView titleView = (TextView) customTitleView.findViewById(R.id.title);
    titleView.setText(
        getString(R.string.hosts_at_location, hosts.size(), hosts.get(0).getStreetCityAddress()));

    TextView distanceView = (TextView) customTitleView.findViewById(R.id.distance_from_current);
    distanceView.setText(distanceSummary);

    for (int i = 0; i < hosts.size(); i++) {
      mPossibleItems[i] = hosts.get(i).getFullname();
    }
    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
    alertDialogBuilder.setCustomTitle(customTitleView);

    alertDialogBuilder
        .setNegativeButton(
            R.string.ok,
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int which) {
                return;
              }
            })
        .setItems(
            mPossibleItems,
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int index) {
                Intent intent = new Intent(Maps2Activity.this, HostInformationActivity.class);
                HostBriefInfo briefHost = hosts.get(index);
                Host host = Host.createFromBriefInfo(hosts.get(index));
                intent.putExtra("host", host);
                intent.putExtra("id", briefHost.getId());
                startActivity(intent);
              }
            });
    AlertDialog alertDialog = alertDialogBuilder.create();
    alertDialog.show();
  }
示例#30
0
  public void add_pic_btn(View v) {
    tempImageView = (ImageView) v;
    chat_layout_emote.setVisibility(View.GONE);
    if (v.getTag().toString().equals(AddPicFragment.DEFAULT)) {
      AlertDialog dialog =
          new AlertDialog.Builder(this)
              .setItems(
                  new String[] {"相册", "拍照"},
                  new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                      menuClick(which);
                    }
                  })
              .create();
      dialog.setCanceledOnTouchOutside(true);
      dialog.show();
    } else {
      AlertDialog dialog =
          new AlertDialog.Builder(this)
              .setItems(
                  new String[] {"删除"},
                  new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                      menuDeleteClick();
                    }
                  })
              .create();
      dialog.setCanceledOnTouchOutside(true);
      dialog.show();
    }
    closeInput();
  }