private void showExitDlg() {
    if (null != mExitDialog) {
      mExitDialog.show();
    } else {
      mExitDialog =
          new AlertDialog.Builder(CameraListActivity.this)
              .setTitle(R.string.exit_str)
              .setPositiveButton(
                  R.string.confirm,
                  new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                      CameraListActivity.this.finish();
                    }
                  })
              .setNegativeButton(
                  R.string.cancel,
                  new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                      dialog.dismiss();
                    }
                  })
              .create();
      mExitDialog.show();
    }
  }
  public void showAboutDialog() {
    if (null != mAboutDialog) {
      mAboutDialog.show();
    } else {
      View view = mLayoutInflater.inflate(R.layout.about_dialog, null);
      TextView aboutView = (TextView) view.findViewById(R.id.about);
      aboutView.setText(
          String.format(
              getString(R.string.about_str),
              getString(R.string.app_name),
              AppUtils.getAppVersionName(CameraListActivity.this)));
      mAboutDialog =
          new AlertDialog.Builder(this)
              .setView(view)
              .setTitle(R.string.about)
              .setPositiveButton(
                  R.string.confirm,
                  new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                      dialog.dismiss();
                    }
                  })
              .create();
      mAboutDialog.show();
    }
  }
  @Override
  protected void onPostExecute(String result) {
    super.onPostExecute(result);

    Button follow_btn = (Button) profileView.findViewById(R.id.follow_btn);

    if (resulting == null) {

      Dialog d = new Dialog(activity);
      d.setTitle("Something Wrong...Check Internet Connection ");
      d.show();

    } else {

      follow_btn.setText("follow");

      follow_btn.setBackgroundResource(R.drawable.abc_tab_unselected_pressed_holo);

      follow_btn.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {

              new FollowButton(coachIndex, profileView, activity).execute();
            }
          });

      Dialog d = new Dialog(activity);
      d.setTitle("unfollowed");
      d.show();
    }
  } // end post ex
  @Override
  public void onClick(View arg0) {
    // TODO Auto-generated method stub
    if (etLectNum.getText().toString().length() == 0) {
      Dialog d = new Dialog(this);
      d.setTitle("Lecture Number cannot be empty!");
      d.show();
    } else {
      lecture_number = Integer.parseInt(etLectNum.getText().toString());
      lecture_title = etLectTitle.getText().toString();
      lecture_description = etLectDescription.getText().toString();

      dbh = new DBHelper(this);

      if (getIntent().getExtras().getBoolean("Update")) {
        dbh.updateLecture(
            semSelected, courseSelected, lecture_number, lecture_title, lecture_description, "");
        Toast.makeText(
                getApplicationContext(),
                "Lecture " + lecture_number + " updated successfully!",
                Toast.LENGTH_SHORT)
            .show();

        Intent intent =
            new Intent(getApplicationContext(), com.aakash.studentmanager.LectureList.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);

      } else {

        Cursor rs = dbh.getLectureData(semSelected, courseSelected, lecture_number);

        rs.moveToFirst();
        if (rs.isAfterLast() == true) {

          dbh.insertLecture(
              semSelected, courseSelected, lecture_number, lecture_title, lecture_description, "");
          Toast.makeText(
                  getApplicationContext(),
                  "Lecture " + lecture_number + " added successfully!",
                  Toast.LENGTH_SHORT)
              .show();

          Intent intent =
              new Intent(getApplicationContext(), com.aakash.studentmanager.LectureList.class);
          intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
          startActivity(intent);
        } else {
          Dialog d = new Dialog(this);
          d.setTitle("Duplicate Entry:");
          TextView tv = new TextView(this);
          tv.setText("Lecture Number " + lecture_number + " already added!");
          d.setContentView(tv);
          d.show();
        }
      }
      dbh.close();
    }
  }
Exemple #5
0
 @SuppressWarnings("unchecked")
 @Override
 public void handleMessage(Message msg) {
   // TODO Auto-generated method stub
   super.handleMessage(msg);
   switch (msg.what) {
     case IS_REQUSTING:
       mDialog = Utils.createLoadingDialog(mContext, "正在请求设备周围WiFi列表...");
       mDialog.show();
       break;
     case REQUST_TIMEOUT:
       if (mDialog != null) mDialog.dismiss();
       if (handler.hasMessages(REQUST_TIMEOUT)) {
         handler.removeMessages(REQUST_TIMEOUT);
       }
       Toast.makeText(mContext, "请求WiFi列表失败,请重试! ", Toast.LENGTH_SHORT).show();
       break;
     case R.id.requst_wifi_list_id:
       if (handler.hasMessages(REQUST_TIMEOUT)) {
         handler.removeMessages(REQUST_TIMEOUT);
         if (mDialog != null) mDialog.dismiss();
         int resultCode = msg.arg1;
         if (resultCode == 0) {
           showWiFiListDialog((ArrayList<HashMap<String, Object>>) msg.obj);
         } else {
           Toast.makeText(mContext, "设备附近暂时没有WiFi信号! ", Toast.LENGTH_SHORT).show();
         }
       } else {
         handler.removeMessages(R.id.requst_wifi_list_id);
       }
       break;
     case IS_SETTING:
       mDialog = Utils.createLoadingDialog(mContext, "正在配置设备WiFi网络...");
       mDialog.show();
       break;
     case SET_TIMEOUT:
       if (mDialog != null) mDialog.dismiss();
       if (handler.hasMessages(SET_TIMEOUT)) {
         handler.removeMessages(SET_TIMEOUT);
       }
       Toast.makeText(mContext, "配置设备WiFi网络超时,请重试! ", Toast.LENGTH_SHORT).show();
       break;
     case R.id.set_term_wifi_id:
       if (handler.hasMessages(SET_TIMEOUT)) {
         handler.removeMessages(SET_TIMEOUT);
         if (mDialog != null) mDialog.dismiss();
         int resultCode = msg.arg1;
         if (resultCode == 1) {
           Toast.makeText(mContext, "配置设备WiFi网络成功! ", Toast.LENGTH_SHORT).show();
         } else {
           Toast.makeText(mContext, "配置设备WiFi网络失败,请重试! ", Toast.LENGTH_SHORT).show();
         }
       } else {
         handler.removeMessages(R.id.set_term_wifi_id);
       }
       break;
   }
 }
  public void showAddCameraDlg() {
    if (null != mAddCameraDlg) {
      mAddCameraDlg.show();
    } else {
      View view = mLayoutInflater.inflate(R.layout.add_camera_dialog, null);
      final EditText cidView = (EditText) view.findViewById(R.id.cid);
      final EditText passwordView = (EditText) view.findViewById(R.id.password);
      mAddCameraDlg =
          new AlertDialog.Builder(this)
              .setView(view)
              .setTitle(R.string.add_camera_dlg_title)
              .setPositiveButton(
                  R.string.confirm,
                  new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                      String cid = cidView.getText().toString();
                      String pwd = passwordView.getText().toString();
                      if (null == cid || null == pwd) {
                        Toast.makeText(
                                CameraListActivity.this, R.string.empty_info, Toast.LENGTH_LONG)
                            .show();
                        return;
                      }
                      if ("".equals(cid) || "".equals(pwd)) {
                        Toast.makeText(
                                CameraListActivity.this, R.string.empty_info, Toast.LENGTH_LONG)
                            .show();
                        return;
                      }
                      long cidLong = 0;
                      try {
                        cidLong = Long.parseLong(cid);
                      } catch (NumberFormatException e) {
                        Toast.makeText(
                                CameraListActivity.this, R.string.invalid_cid, Toast.LENGTH_LONG)
                            .show();
                        return;
                      }
                      addStreamer(cidLong, DEFAULT_USER, pwd);
                    }
                  })
              .setNegativeButton(
                  R.string.cancel,
                  new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                      dialog.dismiss();
                    }
                  })
              .create();
      mAddCameraDlg.show();
    }
  }
  private void showSayhiDialog() {
    if (null == sayhiDialog) {
      sayhiView = LayoutInflater.from(mContext).inflate(R.layout.dialog_sayhi, null);

      final EditText etContent = (EditText) sayhiView.findViewById(R.id.et_sayhi);

      etContent.setText("看了你的资料,我发现你应该就是我一直在寻找的那个人,能认识吗? 期待你的回复!");

      sayhiDialog = new Dialog(mContext);
      sayhiDialog.setTitle("向 " + mCurrentSayhiUser.getNickname() + " 打招呼");

      sayhiView
          .findViewById(R.id.tv_send_sayhi)
          .setOnClickListener(
              new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                  if (TextUtils.isEmpty(etContent.getText())) {
                    ToastFactory.getToast(mContext, "内容不能为空").show();
                    return;
                  }
                  sendSayhi(etContent.getText().toString());
                  sayhiDialog.dismiss();
                }
              });

      sayhiView
          .findViewById(R.id.tv_cancel_send_sayhi)
          .setOnClickListener(
              new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                  sayhiDialog.dismiss();
                }
              });

      sayhiDialog.show();

      ViewGroup.LayoutParams params =
          new ViewGroup.LayoutParams(
              ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
      sayhiDialog.addContentView(sayhiView, params);
    }
    if (!sayhiDialog.isShowing()) {

      sayhiDialog.setTitle("向 " + mCurrentSayhiUser.getNickname() + " 打招呼");

      sayhiDialog.show();
    }
  }
Exemple #8
0
 @SuppressLint("InflateParams")
 private void showLoadingDialog() {
   if (loadingDialog != null) {
     loadingDialog.show();
     return;
   }
   loadingDialog = new Dialog(mContext, R.style.dialog_loading);
   View view = LayoutInflater.from(mContext).inflate(R.layout.dialog_loading, null);
   loadingDialog.setContentView(
       view, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
   loadingDialog.setCancelable(false);
   loadingDialog.show();
 }
Exemple #9
0
 /** 显示范围选择dialog */
 @SuppressLint("InflateParams")
 private void showSelectDialog() {
   if (selectDialog != null) {
     selectDialog.show();
     return;
   }
   selectDialog = new Dialog(mContext, R.style.dialog);
   View view = LayoutInflater.from(mContext).inflate(R.layout.dialog_distance, null);
   selectDialog.setContentView(
       view, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
   selectDialog.setCanceledOnTouchOutside(true);
   selectDialog.show();
 }
 @Override
 public void onClick(View v) {
   switch (v.getId()) {
     case R.id.btnEndDate:
       dialogDate.show();
       break;
     case R.id.btnFav:
       if (cb.isFavorited()) {
         CouponBean favCoupon =
             RestClient.deleteFavCoupons(SessionUserBean.getId(), "" + cb.getId());
         if (favCoupon.getErrorId() == 0) {
           cb.setFavorited(false);
           imgFavOn.setVisibility(View.INVISIBLE);
           imgFavOff.setVisibility(View.VISIBLE);
         } else {
           Toast.makeText(
                   CouponActivity.this,
                   "Error!! " + favCoupon.getErrorMessage(),
                   Toast.LENGTH_LONG)
               .show();
         }
       } else {
         CouponBean favCoupon = RestClient.addMyFavorites(couponId, SessionUserBean.getId());
         if (favCoupon.getErrorId() == 0) {
           cb.setFavorited(true);
           imgFavOn.setVisibility(View.VISIBLE);
           imgFavOff.setVisibility(View.INVISIBLE);
         } else {
           Toast.makeText(
                   CouponActivity.this,
                   "Error!! " + favCoupon.getErrorMessage(),
                   Toast.LENGTH_LONG)
               .show();
         }
       }
       break;
     case R.id.btnLocation:
       dialogLocation.show();
       break;
     case R.id.btnUsage:
       dialogUsage.show();
       break;
     case R.id.btnInfo:
       dialogInfo.show();
       break;
     case R.id.btnTerms:
       dialogTerms.show();
       break;
   }
 }
  private void useTheme(final Context context) {
    SharedPreferences preferences =
        context.getSharedPreferences(Theme.PREFS_NAME_THEME_SETTING, Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = preferences.edit();
    editor.putString(Theme.PREFS_KEY_PACKAGE_NAME, entry.getPackageName());
    editor.putInt(Theme.PREFS_KEY_RESOURCE_TYPE, Theme.RESOURCES_FROM_APK);
    editor.putString(Theme.PREFS_KEY_THEME_NAME, entry.getName());
    editor.commit();

    Dialog dialog =
        new AlertDialog.Builder(context)
            .setTitle(R.string.title_dialog_alert)
            .setMessage("重启应用皮肤才能生效,确认要退出应用吗?")
            .setPositiveButton(
                R.string.btn_confirm,
                new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    exitApp(context);
                  }
                })
            .setNegativeButton(
                R.string.btn_cancel,
                new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                  }
                })
            .create();
    dialog.show();
  }
  private void dependToShowDialog() {
    if (!SomeUtil.hasSystemFeatureGPS(this)) {
      // 系统没有 GPS 模块就不弹出开启 GPS 的对话框
      return;
    }
    if (!SomeUtil.isGPSOn(this)) {
      mDialog = new Dialog(this, R.style.Dialog_style_dim2);
      View view = View.inflate(this, R.layout.dialog_my_vehicle_condition, null);
      TextView txt1 = (TextView) view.findViewById(R.id.txt_dialog_my_vehicle_condition_heading);
      TextView txt2 = (TextView) view.findViewById(R.id.txt_dialog_my_vehicle_condition_subheading);
      ImageView ivYes = (ImageView) view.findViewById(R.id.iv_dialog_my_vehicle_condition_yes);
      ImageView ivNo = (ImageView) view.findViewById(R.id.iv_dialog_my_vehicle_condition_no);

      txt1.setText(getResources().getString(R.string.myVehicleCondition_heading_no_gps));
      txt2.setText(getResources().getString(R.string.myVehicleCondition_subheading_no_gps));
      ivYes.setOnClickListener(mDialogOnClickListener);
      ivNo.setOnClickListener(mDialogOnClickListener);

      mDialog.setContentView(view);
      mDialog.setCanceledOnTouchOutside(true);
      mDialog.getWindow().setType((WindowManager.LayoutParams.TYPE_SYSTEM_ALERT));
      mDialog.show();
    } else {
      mLocationClient.start();
    }
  }
  public static void dlg_register_main(Activity actv) {
    /*----------------------------
    * Steps
    * 1. Get a dialog
    * 2. List view
    * 3. Set listener => list
    * 9. Show dialog
    ----------------------------*/

    Dialog dlg =
        dlg_template_cancel(
            actv,
            R.layout.dlg_register_main,
            R.string.generic_register,
            R.id.dlg_register_main_btn_cancel,
            Methods.DialogButtonTags.dlg_generic_dismiss);

    /*----------------------------
    * 2. List view
    * 		1. Get view
    * 		2. Prepare list data
    * 		3. Prepare adapter
    * 		4. Set adapter
    ----------------------------*/
    ListView lv = (ListView) dlg.findViewById(R.id.dlg_register_main_lv_list);

    /*----------------------------
    * 2.2. Prepare list data
    ----------------------------*/
    List<String> registerItems = new ArrayList<String>();

    registerItems.add(actv.getString(R.string.dlg_register_main_items));
    registerItems.add(actv.getString(R.string.dlg_register_main_stores));
    registerItems.add(actv.getString(R.string.dlg_register_main_genres));

    /** ******************************* 2.3. Prepare adapter ******************************* */
    ArrayAdapter<String> adp =
        new ArrayAdapter<String>(
            actv,
            android.R.layout.simple_list_item_1,
            //				R.layout.list_row_dlg_register_main,
            registerItems);

    /*----------------------------
    * 2.4. Set adapter
    ----------------------------*/
    lv.setAdapter(adp);

    lv.setTag(Methods.DialogItemTags.dlg_register_main);

    /*----------------------------
    * 3. Set listener => list
    ----------------------------*/
    lv.setOnItemClickListener(new DialogOnItemClickListener(actv, dlg));

    /*----------------------------
    * 9. Show dialog
    ----------------------------*/
    dlg.show();
  } // public static void dlg_register_main(Activity actv)
Exemple #14
0
 // 显示“视频下载安装”对话框
 protected void showApprovaDialog() {
   LayoutInflater inflater = LayoutInflater.from(activity);
   View layout = inflater.inflate(R.layout.approva_dialog, null);
   approvaDialog = new AlertDialog.Builder(activity).create();
   approvaDialog.setCancelable(false);
   approvaDialog.show();
   approvaDialog.getWindow().setContentView(layout);
   approvaDialog.setCancelable(true);
   TextView edit_approva = (TextView) layout.findViewById(R.id.edit_approva);
   ImageView close_btn = (ImageView) layout.findViewById(R.id.close_btn);
   // Button exit_cancel = (Button) layout.findViewById(R.id.exit_cancel);
   edit_approva.setOnClickListener(
       new OnClickListener() {
         @Override
         public void onClick(View arg0) {
           approvaDialog.dismiss();
         }
       });
   close_btn.setOnClickListener(
       new OnClickListener() {
         @Override
         public void onClick(View v) {
           approvaDialog.dismiss();
         }
       });
 }
  // 获取token
  private void getToken(final String imagePath) {
    loadingDialog = DialogUtils.creatLoadingDialog(this, "请稍后...");
    loadingDialog.show();
    RequestParams params = new RequestParams(GlobalContants.GET_TOKEN_URL);
    x.http()
        .post(
            params,
            new Callback.CommonCallback<String>() {
              @Override
              public void onSuccess(String result) {
                LogUtils.d("result_token", result);
                try {
                  JSONObject object = new JSONObject(result);
                  String token = object.getString("token");
                  if (!TextUtils.isEmpty(token)) {
                    upLoadFile(token, imagePath);
                  }

                } catch (JSONException e) {
                  e.printStackTrace();
                }
              }

              @Override
              public void onError(Throwable ex, boolean isOnCallback) {
                LogUtils.e("token_error", "获取token失败");
              }

              @Override
              public void onCancelled(CancelledException cex) {}

              @Override
              public void onFinished() {}
            });
  }
  @Override
  protected void onListItemClick(ListView l, View v, int position, long id) {
    if (isNetworkAvailable() == false) noInternetAccess();

    super.onListItemClick(l, v, position, id);
    ParseObject message = mMessages.get(position);
    String post = message.getString(ParseConstants.KEY_POST);
    String sendername = message.getString(ParseConstants.KEY_SENDER_NAME);

    final Dialog dialog = new Dialog(RumourActivity.this, R.style.Theme_Dialog);
    dialog.setContentView(R.layout.rumour_custom_alert);

    final TextView userInput3 = (TextView) dialog.findViewById(R.id.rumour_custom_et);
    final TextView sender = (TextView) dialog.findViewById(R.id.sender_custom_et);
    final Button ok = (Button) dialog.findViewById(R.id.btn_ok);

    sender.setText(sendername);
    userInput3.setText(post);
    dialog.show();
    ok.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            dialog.dismiss();
          }
        });
  }
  private void showLogoutTipDialog() {
    View.OnClickListener listener =
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            switch (view.getId()) {
              case R.id.dialog_base_with_button_cancel_btn:
                mDialog.dismiss();
                break;
              case R.id.dialog_base_with_button_commit_btn:
                mDialog.dismiss();
                PrefUtils.setBoolean(ProfileActivity.this, "login_flag", false);
                PrefUtils.setString(ProfileActivity.this, "loginUser", null);
                JMessageClient.logout();

                activityManager.popAllActivity();

                Intent intent6 = new Intent(ProfileActivity.this, ToLoginOrSingupActivity.class);
                startActivity(intent6);

                break;
            }
          }
        };
    mDialog = DialogUtils.createCommonDialog(this, listener, "您确定退出当前账户吗?", "否", "是");
    mDialog.show();
  }
  @Implementation
  public final boolean showDialog(int id, Bundle bundle) {
    Dialog dialog = null;
    this.lastShownDialogId = id;

    dialog = dialogForId.get(id);

    if (dialog == null) {
      final ActivityInvoker invoker = new ActivityInvoker();
      dialog = (Dialog) invoker.call("onCreateDialog", Integer.TYPE).with(id);

      if (bundle == null) {
        invoker.call("onPrepareDialog", Integer.TYPE, Dialog.class).with(id, dialog);
      } else {
        invoker
            .call("onPrepareDialog", Integer.TYPE, Dialog.class, Bundle.class)
            .with(id, dialog, bundle);
      }

      dialogForId.put(id, dialog);
    }

    dialog.show();

    return true;
  }
Exemple #19
0
 /** 修改图片 */
 private void showChangeIconDialog() {
   final Dialog dialog = new Dialog(getContext(), R.style.WhiteDialog);
   dialog.setContentView(R.layout.tpl_icon_select_dialog);
   dialog
       .findViewById(R.id.dialog_camera)
       .setOnClickListener(
           new OnClickListener() {
             @Override
             public void onClick(View v) {
               dialog.dismiss();
               openCamera();
             }
           });
   dialog
       .findViewById(R.id.dialog_picture)
       .setOnClickListener(
           new OnClickListener() {
             @Override
             public void onClick(View v) {
               dialog.dismiss();
               getPicture();
             }
           });
   dialog.show();
 }
  public boolean checkTestRunning(final Runnable runnable) {
    if (service == null || !service.isTestRunning()) return false;

    if (dialog == null || !dialog.isShowing()) {
      final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
      builder.setTitle(R.string.test_dialog_abort_title);
      builder.setMessage(R.string.test_dialog_abort_extended_text);
      builder.setPositiveButton(
          R.string.test_dialog_abort_yes,
          new DialogInterface.OnClickListener() {
            @Override
            public void onClick(final DialogInterface dialog, final int which) {
              if (extendedResultButtonCancel != null && extendedResultButtonCancel.isShown())
                extendedResultButtonCancel.setEnabled(false);

              if (service != null) service.stopTest();

              if (runnable != null) runnable.run();
            }
          });
      builder.setNegativeButton(R.string.test_dialog_abort_no, null);
      dialog = builder.create();
      dialog.show();
    }
    return true;
  }
Exemple #21
0
  private void dialog() {

    LayoutInflater inflater = LayoutInflater.from(activity);
    RelativeLayout layout = (RelativeLayout) inflater.inflate(R.layout.exit_dialog, null);

    dialog = new AlertDialog.Builder(activity).create();
    dialog.setCancelable(false);
    dialog.show();
    dialog.getWindow().setContentView(layout);

    Button exit_cancel = (Button) layout.findViewById(R.id.exit_cancel);
    Button drop_out = (Button) layout.findViewById(R.id.drop_out);

    drop_out.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            dialog.dismiss();
            activity.finish();
          }
        });
    exit_cancel.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            dialog.dismiss();
          }
        });
  }
Exemple #22
0
 public void showHelp(String topic) {
   final Dialog d = new Dialog(this, android.R.style.Theme);
   final WebView wv = new WebView(this);
   d.setOnKeyListener(
       new DialogInterface.OnKeyListener() {
         public boolean onKey(DialogInterface di, int key, KeyEvent evt) {
           if (evt.getAction() != KeyEvent.ACTION_DOWN || key != KeyEvent.KEYCODE_BACK)
             return false;
           if (wv.canGoBack()) wv.goBack();
           else d.cancel();
           return true;
         }
       });
   d.setContentView(wv);
   wv.setWebChromeClient(
       new WebChromeClient() {
         public void onReceivedTitle(WebView w, String title) {
           d.setTitle(title);
         }
         // onReceivedTitle doesn't happen on back button :-(
         public void onProgressChanged(WebView w, int progress) {
           if (progress == 100) d.setTitle(w.getTitle());
         }
       });
   wv.getSettings().setBuiltInZoomControls(true);
   wv.loadUrl(MessageFormat.format(getString(R.string.docs_url), new Object[] {topic}));
   d.show();
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //	Toast.makeText(this, "onCreate ", Toast.LENGTH_SHORT).show();
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    setContentView(R.layout.activity_map);
    // Show the Up button in the action bar.
    setupActionBar();

    // Getting Google Play availability status
    int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getBaseContext());

    // Showing status
    if (status != ConnectionResult.SUCCESS) { // Google Play Services are
      // not available

      int requestCode = 10;
      Dialog dialog = GooglePlayServicesUtil.getErrorDialog(status, this, requestCode);
      dialog.show();

    } else { // Google Play Services are available
      // Getting reference to the SupportMapFragment of activity_main.xml
      SupportMapFragment fm =
          (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);

      // Getting GoogleMap object from the fragment
      googleMap = fm.getMap();

      // Enabling MyLocation Layer of Google Map
      googleMap.setMyLocationEnabled(true);

      googleMap.setOnInfoWindowClickListener(this);
    }
  }
  public void openDialog() {
    final Dialog dialog = new Dialog(CreateChannelActivity.this);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.custom_dialog_for_upload_photo);

    TextView gallery, camera;

    gallery = (TextView) dialog.findViewById(R.id.gallery);
    camera = (TextView) dialog.findViewById(R.id.camera);

    gallery.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            chooseImage();
          }
        });
    camera.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            takePicture();
          }
        });

    dialog.show();
  }
Exemple #25
0
 /** 显示版本更新通知对话框 */
 private void showNoticeDialog() {
   AlertDialog.Builder builder = new Builder(mContext);
   builder.setTitle("软件版本更新");
   builder.setMessage(updateMsg);
   builder.setPositiveButton(
       "立即更新",
       new OnClickListener() {
         @Override
         public void onClick(DialogInterface dialog, int which) {
           dialog.dismiss();
           showDownloadDialog();
         }
       });
   builder.setNegativeButton(
       "以后再说",
       new OnClickListener() {
         @Override
         public void onClick(DialogInterface dialog, int which) {
           dialog.dismiss();
           stopSelf();
         }
       });
   noticeDialog = builder.create();
   noticeDialog.setCanceledOnTouchOutside(false);
   noticeDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
   noticeDialog.show();
 }
 @Override
 public void onClick(View v) {
   switch (v.getId()) {
     case R.id.color_button:
       colorDialog = new Dialog(this);
       colorDialog.setTitle(getString(R.string.select_color));
       colorDialog.setContentView(R.layout.color_dialog);
       colorDialog.findViewById(R.id.green_color_button).setOnClickListener(this);
       colorDialog.findViewById(R.id.yellow_color_button).setOnClickListener(this);
       colorDialog.findViewById(R.id.red_color_button).setOnClickListener(this);
       colorDialog.show();
       break;
     case R.id.green_color_button:
       currentColor = MainMenuActivity.COLOR_GREEN;
       ((ImageButton) findViewById(R.id.color_button))
           .setImageDrawable(getResources().getDrawable(R.drawable.greenstar));
       colorDialog.dismiss();
       break;
     case R.id.yellow_color_button:
       currentColor = MainMenuActivity.COLOR_YELLOW;
       ((ImageButton) findViewById(R.id.color_button))
           .setImageDrawable(getResources().getDrawable(R.drawable.yellowstar));
       colorDialog.dismiss();
       break;
     case R.id.red_color_button:
       currentColor = MainMenuActivity.COLOR_RED;
       ((ImageButton) findViewById(R.id.color_button))
           .setImageDrawable(getResources().getDrawable(R.drawable.redstar));
       colorDialog.dismiss();
       break;
     default:
       break;
   }
 }
Exemple #27
0
  /**
   * Ensures that the device has the correct version of the Google Play Services.
   *
   * @return true if the Google Play Services binary is valid
   */
  private boolean isGooglePlayServicesValid(boolean showErrorDialog) {
    // Check for the google play services is available
    final int playStatus = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getContext());
    final boolean isValid = playStatus == ConnectionResult.SUCCESS;

    if (!isValid && showErrorDialog) {
      final Dialog errorDialog =
          GooglePlayServicesUtil.getErrorDialog(
              playStatus,
              getActivity(),
              GOOGLE_PLAY_SERVICES_REQUEST_CODE,
              new DialogInterface.OnCancelListener() {
                @Override
                public void onCancel(DialogInterface dialog) {
                  if (isAdded()) {
                    getActivity().finish();
                  }
                }
              });

      if (errorDialog != null) errorDialog.show();
    }

    return isValid;
  }
  private void showUnitSpinner(final String[] data) {

    final Dialog a = new Dialog(this);
    Window w = a.getWindow();
    a.requestWindowFeature(Window.FEATURE_NO_TITLE);
    a.setContentView(R.layout.spinner);
    w.setBackgroundDrawableResource(android.R.color.transparent);

    TextView lblselect = (TextView) w.findViewById(R.id.dialogtitle);
    lblselect.setTypeface(Utils.getBold(getActivity()));
    lblselect.setText(R.string.unit_selection);

    ArrayAdapter<String> adapter =
        new ArrayAdapter<String>(getActivity(), R.layout.spinner_item, data);
    ListView lv = (ListView) w.findViewById(R.id.lvSpinner);
    lv.setAdapter(adapter);

    lv.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {

          @Override
          public void onItemClick(AdapterView<?> adapterview, View view, int position, long l) {

            a.dismiss();

            Utils.setPref(getActivity(), Constant.SELECTED_UNIT_STORAGE, data[position]);
            mAdapter.addAll(converter.getFavUnit());
            tvUnitSelVal.setText(data[position]);
          }
        });

    a.show();
  }
Exemple #29
0
  /** 显示下载对话框 */
  private void showDownloadDialog() {
    Builder builder = new Builder(mContext);
    builder.setTitle("正在下载新版本");

    final LayoutInflater inflater = LayoutInflater.from(mContext);
    View v = inflater.inflate(R.layout.update_progress, null);
    mProgress = (ProgressBar) v.findViewById(R.id.update_progress);
    mProgressText = (TextView) v.findViewById(R.id.update_progress_text);

    builder.setView(v);
    builder.setNegativeButton(
        "取消",
        new OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
            interceptFlag = true;
          }
        });
    builder.setOnCancelListener(
        new OnCancelListener() {
          @Override
          public void onCancel(DialogInterface dialog) {
            dialog.dismiss();
            interceptFlag = true;
          }
        });
    downloadDialog = builder.create();
    downloadDialog.setCanceledOnTouchOutside(false);
    downloadDialog.show();

    downloadApk();
  }
  public static void accessDialog(Context ctx) {
    final Context context = ctx;
    final Dialog dialog =
        new IntroduceDialog(context, R.layout.dialog_clear_history, R.style.Theme_dialog);
    dialog.setCanceledOnTouchOutside(true);
    dialog.show();
    TextView t1 = (TextView) dialog.findViewById(R.id.dialog_title);
    TextView t2 = (TextView) dialog.findViewById(R.id.dialog_content);
    t1.setText("È·ÈÏÍ˳ö");
    t2.setText("ÄúÕæµÄÒªÍ˳öËѹ·ÔĶÁÂð£¿");

    Button pButton = (Button) dialog.findViewById(R.id.dialog_ok);
    Button cButton = (Button) dialog.findViewById(R.id.dialog_cancer);
    pButton.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            dialog.dismiss();
            ((Activity) context).finish();
          }
        });

    cButton.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            dialog.dismiss();
          }
        });
  }