コード例 #1
0
 @Override
 public void onStart() {
   super
       .onStart(); // super.onStart() is where dialog.show() is actually called on the underlying
                   // dialog, so we have to do it after this point
   final AlertDialog d = (AlertDialog) getDialog();
   if (d != null) {
     TextView spotET = (TextView) getDialog().findViewById(R.id.spot_to_add);
     spotET.setText("Plaça " + mSpot);
     EditText inputCar = (EditText) getDialog().findViewById(R.id.licensePlateEditText);
     inputCar.setFilters(new InputFilter[] {new InputFilter.AllCaps()});
     Button positiveButton = d.getButton(Dialog.BUTTON_POSITIVE);
     positiveButton.setOnClickListener(
         new View.OnClickListener() {
           @Override
           public void onClick(View v) {
             // Send the positive button event back to the host activity
             EditText inputCar = (EditText) getDialog().findViewById(R.id.licensePlateEditText);
             String licensePlate = inputCar.getText().toString();
             Log.d("Dialog", "Input: " + licensePlate);
             if (!licensePlate.equals("")) {
               mListener.onDialogPositiveClick(AddCarDialogFragment.this, mSpot, licensePlate);
               d.dismiss();
             } else {
               Toast.makeText(
                       getActivity().getApplicationContext(),
                       "Escriu la matrícula del vehicle",
                       Toast.LENGTH_SHORT)
                   .show();
             }
           }
         });
   }
 }
コード例 #2
0
 @Override
 public void onStart() {
   super.onStart();
   getDialog()
       .getWindow()
       .setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
 }
コード例 #3
0
  @Override
  public void onStart() {
    super.onStart();

    AlertDialog alertDialog = (AlertDialog) getDialog();
    final Button buttonNeutral = alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL);
    buttonNeutral.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            if (isRunning) {
              dataFileWriter.writeToFile(
                  "Magnetic_Field_Uncalibrated",
                  "Calculated_bias: " + Arrays.toString(magneticFieldBias.getBias()));
              dismissDialog();
            } else {
              sensorManager.registerListener(
                  MagCalibrationDialogFragment.this,
                  sensorMagneticField,
                  SensorManager.SENSOR_DELAY_FASTEST);

              isRunning = true;
              buttonNeutral.setText("Stop Calibration");
            }
          }
        });
  }
コード例 #4
0
  @Override
  public void onStart() {
    super.onStart();
    if (getDialog() == null) return;

    // Dialog Fragments are automatically set to wrap_content, so we need to force the width to fit
    // our view
    int dialogWidth = (int) (getResources().getDisplayMetrics().widthPixels * .85);
    getDialog().getWindow().setLayout(dialogWidth, getDialog().getWindow().getAttributes().height);
  }
コード例 #5
0
 @Override
 public void onStart() {
   super.onStart();
   Dialog dialog = getDialog();
   if (dialog != null) {
     dialog
         .getWindow()
         .setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
     dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
   }
 }
コード例 #6
0
  @Override
  public void onStart() {
    super.onStart();

    Dialog d = getDialog();
    if (d != null) {
      int width = ViewGroup.LayoutParams.WRAP_CONTENT;
      int height = ViewGroup.LayoutParams.WRAP_CONTENT;
      d.getWindow().setLayout(width, height);
    }
  }
コード例 #7
0
  @Override
  public void onStart() {
    super.onStart();

    final AlertDialog dialog = (AlertDialog) getDialog();

    if (dialog != null) {
      okay = dialog.getButton(Dialog.BUTTON_POSITIVE);
      okay.setOnClickListener(this);
      okay.setEnabled(false);
    }
  }
コード例 #8
0
  @Override
  public void onStart() {
    super.onStart();

    // Prepare canvas as full screen
    wWindow = getDialog().getWindow();
    wWindow.setLayout(
        ScreenUtils.getScreenWidth(getActivity()),
        ScreenUtils.getScreenHeight(getActivity()) - ScreenUtils.getStatusHeight(getActivity()));
    wWindow.setGravity(Gravity.CENTER);

    // Prepare animation
    if (!mAnimationView.isAnimationPrepared()) {
      mAnimationView.setInteractionListener(mInteractionListener).prepareAnimation();
    }
  }
  @Override
  public void onStart() {
    if (getDialog() != null) {
      getDialog().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, R.drawable.ic_cloud);
    }

    initForm();

    if (retrieveFormValues()) {
      signup.setEnabled(true);
    } else {
      signup.setEnabled(false);
    }

    super.onStart();
  }
コード例 #10
0
 @Override
 public void onStart() {
   super.onStart();
   // updateUserInfo();
 }
コード例 #11
0
  @Override
  public void onStart() {
    super.onStart();
    AlertDialog dialog = (AlertDialog) getDialog();

    final EditText et = (EditText) dialog.findViewById(R.id.sa_edittext);
    final Spinner spinner = (Spinner) dialog.findViewById(R.id.sa_spinner);
    final ListView recentList = (ListView) dialog.findViewById(R.id.sa_recent_list);
    final ProgressBar pb = (ProgressBar) dialog.findViewById(R.id.sa_progressBar);
    final ListView lv = (ListView) dialog.findViewById(R.id.sa_result_list);
    final TextView aerror = (TextView) dialog.findViewById(R.id.sa_error_text);
    final Button abutton = (Button) dialog.findViewById(R.id.sa_nores_button);
    final TextView infotv = (TextView) dialog.findViewById(R.id.sa_info_text);
    final Button neutButton = dialog.getButton(Dialog.BUTTON_NEUTRAL);
    final ImageButton clearbtn = (ImageButton) dialog.findViewById(R.id.sa_recent_btn);
    final LinearLayout recentcontainer =
        (LinearLayout) dialog.findViewById(R.id.sa_recent_title_container);

    if (!datasource.isOpen()) {
      try {
        datasource.open();
      } catch (SQLException e) {
        e.printStackTrace();
      }
    }

    final Cursor cursor = datasource.getRecentCursor();
    final Cursor listCursor = datasource.getRecentCursor();

    if (recent && !searching) {
      recentList.setVisibility(View.VISIBLE);
      recentcontainer.setVisibility(View.VISIBLE);
      String[] col = {DBHelper.COLUMN_NAME};
      int[] bind = {android.R.id.text1};
      adapter =
          new SimpleCursorAdapter(
              getActivity(), android.R.layout.simple_list_item_1, listCursor, col, bind, 0);
      recentList.setAdapter(adapter);
    }

    // Onclicklistener to truncate recent list
    clearbtn.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            if (!datasource.isOpen()) {
              try {
                datasource.open();
              } catch (SQLException e) {
                e.printStackTrace();
              }
            }
            adapter.notifyDataSetInvalidated();
            datasource.truncate();
            recentList.setVisibility(View.GONE);
            recentcontainer.setVisibility(View.GONE);
          }
        });

    clearbtn.setOnLongClickListener(
        new View.OnLongClickListener() {
          @Override
          public boolean onLongClick(View view) {
            Toast.makeText(getActivity(), clearbtn.getContentDescription(), Toast.LENGTH_SHORT)
                .show();
            return false;
          }
        });

    recentList.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            cursor.moveToPosition(i);
            datasource.addRecent(
                cursor.getString(cursor.getColumnIndex(DBHelper.COLUMN_CLASS_ID)),
                cursor.getString(cursor.getColumnIndex(DBHelper.COLUMN_NAME)));
            listener.openTimeTable(
                cursor.getString(cursor.getColumnIndex(DBHelper.COLUMN_NAME)),
                cursor.getString(cursor.getColumnIndex(DBHelper.COLUMN_CLASS_ID)));
            dismiss();
          }
        });

    et.setOnEditorActionListener(
        new TextView.OnEditorActionListener() {
          @Override
          public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
            if (i == EditorInfo.IME_ACTION_DONE) {
              neutButton.performClick();
              return true;
            }
            return false;
          }
        });

    assert neutButton != null;

    // Set onClick Listener for dialog button
    neutButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            if (et.getText().length() > 0) {
              if (!et.getText().toString().matches("[^a-zA-Z0-9\\s-]")) {
                // Bool to prevent recentlist to reappear
                searching = true;

                // Manager to close keyboard after searching
                InputMethodManager imgr =
                    (InputMethodManager)
                        getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
                imgr.hideSoftInputFromWindow(et.getWindowToken(), 0);

                // Hide old shit, show progressbar, disable search button
                spinner.setVisibility(View.GONE);
                et.setVisibility(View.GONE);
                infotv.setVisibility(View.GONE);
                recentList.setVisibility(View.GONE);
                recentcontainer.setVisibility(View.GONE);
                pb.setVisibility(View.VISIBLE);
                neutButton.setEnabled(false);

                // Get string from search field
                final String term = et.getText().toString();

                // Send to network class
                Network.search(
                    term,
                    spinner.getSelectedItem().toString(),
                    getResources().getStringArray(R.array.sa_search_array),
                    new AsyncHttpResponseHandler() {
                      @Override
                      public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
                        String response = new String(responseBody);
                        Log.d("DIALOG", "onSuccess starting");

                        // Get parsed results from parser
                        final String[][] results = TimeParser.search(response, term);
                        String[] names = new String[results.length];

                        // Create separate (1D) array of names of classes/courses
                        for (int i = 0; i < results.length; i++) {
                          names[i] = results[i][1];
                        }

                        pb.setVisibility(View.GONE);

                        // Arrayadapter for populating the listview
                        final ArrayAdapter adapter =
                            new ArrayAdapter(
                                getActivity(),
                                android.R.layout.simple_expandable_list_item_1,
                                names);
                        lv.setAdapter(adapter);
                        lv.setVisibility(View.VISIBLE);

                        // onClick Listener for listview
                        lv.setOnItemClickListener(
                            new AdapterView.OnItemClickListener() {
                              @Override
                              public void onItemClick(
                                  AdapterView<?> parent, View view, int position, long id) {
                                // Add choice to list of recent choices
                                datasource.addRecent(results[position][0], results[position][1]);
                                // Call listener to open timetable with selected timetable
                                listener.openTimeTable(results[position][1], results[position][0]);
                                // Dismiss current dialog
                                dismiss();
                              }
                            });

                        // This block checks number of items in the listview, if empty show error,
                        // if one item, choose that automatically.
                        if (lv.getCount() == 0) {
                          aerror.setVisibility(View.VISIBLE);
                          abutton.setVisibility(View.VISIBLE);
                        } else if (lv.getCount() == 1) {
                          datasource.addRecent(results[0][0], results[0][1]);
                          listener.openTimeTable(results[0][1], results[0][0]);
                          Toast.makeText(
                                  getActivity(),
                                  getResources().getString(R.string.sa_auto_pick) + results[0][1],
                                  Toast.LENGTH_SHORT)
                              .show();
                          dismiss();
                        }
                      }

                      @Override
                      public void onFailure(
                          int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
                        Toast.makeText(
                                getActivity(),
                                getResources().getString(R.string.add_net_failure),
                                Toast.LENGTH_LONG)
                            .show();
                        Log.d("NET", error.toString());
                      }
                    });
              } else {
                // If search string contains illegal characters, this will show up
                Toast.makeText(
                        getActivity(),
                        getResources().getString(R.string.add_field_illegal),
                        Toast.LENGTH_SHORT)
                    .show();
              }
            } else {
              // If nothing is written in search field, this will show up
              Toast.makeText(
                      getActivity(),
                      getResources().getString(R.string.add_field_empty),
                      Toast.LENGTH_SHORT)
                  .show();
            }
          }
        });
  }
コード例 #12
0
 @Override
 @SuppressLint("NewApi")
 public void onStart() {
   super.onStart();
   mDelegate.onStart();
 }
コード例 #13
0
ファイル: WinFragment.java プロジェクト: hanola/Sintavillie
 @Override
 public void onStart() {
   super.onStart();
   updateUi();
 }