public boolean savePlotInfo(View v) { Log.d("TEST", "OOH SAVEPLOTINFO OOH"); plot.plotName = ((EditText) plotEditPopoverView.findViewById(R.id.plot_name_field)).getText().toString(); Log.d("TEST", "PLOTNAME IS " + plot.plotName); // get values from radio selectors int cropRadioId = ((RadioGroup) findViewById(R.id.crop_radio_group)).getCheckedRadioButtonId(); int fertilizerRadioId = ((RadioGroup) findViewById(R.id.fertilizer_radio_group)).getCheckedRadioButtonId(); String cropChoice = ((RadioButton) (findViewById(cropRadioId))).getText().toString(); String fertilizerChoice = ((RadioButton) (findViewById(fertilizerRadioId))).getText().toString(); plot.crop = cropChoice; plot.fertilizerType = fertilizerChoice; // dismiss the old popWindow popWindow.dismiss(); // DO CALCULATIONS & show the view plot stats winder' LayoutInflater layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); View inflatedView = layoutInflater.inflate(R.layout.view_plot_stats, null, false); Display display = getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size); popWindow = new PopupWindow(inflatedView, size.x - 50, size.y - 500, true); popWindow.setFocusable(true); popWindow.setOutsideTouchable(true); popWindow.setBackgroundDrawable( new ColorDrawable( Color .LTGRAY)); // popWindow.setAnimationStyle(android.R.anim.an); // call this before // showing the popup // ((TextView)findViewById(R.id.plot_name_display)).setText(plot.plotName); Crop crop; switch (plot.crop) { case "Corn": crop = Crop.CORN; break; case "Grain": crop = Crop.GRAIN; break; case "Soybean": crop = Crop.SOYBEAN; break; case "Rice": crop = Crop.RICE; break; default: crop = Crop.SOYBEAN; break; } Fertilizer fertilizer; switch (plot.fertilizerType) { case "Urea": fertilizer = Fertilizer.UREA; break; case "Swine": fertilizer = Fertilizer.SWINE; break; case "Chicken": fertilizer = Fertilizer.CHICKEN; break; case "Cow": fertilizer = Fertilizer.COW; break; case "Sheep": fertilizer = Fertilizer.SHEEP; break; default: fertilizer = Fertilizer.CHICKEN; break; } // run the calculator OptimalValuesCalculator calculator = new OptimalValuesCalculator(plot.plotArea, crop, fertilizer); // set all of the views to display the output Log.d( "TAGGGGGGG", (((Double) calculator.getSeedAmount()).toString()) + "SEED FERT" + (((Double) calculator.getFertilizerAmount()).toString())); ((TextView) findViewById(R.id.seed_amount_display)) .setText(((Double) calculator.getSeedAmount()).toString()); ((TextView) findViewById(R.id.fertilizer_amount_display)) .setText(((Double) calculator.getFertilizerAmount()).toString()); ((TextView) findViewById(R.id.water_amount_display)) .setText(((Double) calculator.getWaterAmount()).toString()); ((TextView) findViewById(R.id.land_area_display)).setText(((Float) plot.plotArea).toString()); ((TextView) findViewById(R.id.crop_type_display)).setText(cropChoice); ((TextView) findViewById(R.id.fertilizer_type_display)).setText(fertilizerChoice); ((TextView) findViewById(R.id.plot_recommendations_field)) .setText("Recommendations for " + plot.plotName); popWindow.showAtLocation( findViewById(R.id.main_bar_view), Gravity.BOTTOM, 0, 150); // 0 - X postion and 150 - Y position // PlotDbHelper dbHelper = new PlotDbHelper(getApplicationContext()); // dbHelper.editPlot(plot); return true; }
// implement action handlers into fragments public boolean donePlotting(MenuItem v) { plot.coordinates = mapFragment.onSaveInstanceState(); plot.plotArea = (float) mapFragment.getPlotArea(); LayoutInflater layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); plotEditPopoverView = layoutInflater.inflate(R.layout.plot_edit_popover, null); Display display = getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size); popWindow = new PopupWindow(plotEditPopoverView, size.x - 50, size.y - 500, true); popWindow.setFocusable(true); popWindow.setOutsideTouchable(true); popWindow.setBackgroundDrawable( new ColorDrawable( Color .LTGRAY)); // popWindow.setAnimationStyle(android.R.anim.an); // call this before // showing the popup popWindow.showAtLocation( findViewById(R.id.main_bar_view), Gravity.BOTTOM, 0, 150); // 0 - X postion and 150 - Y position /*//set up fertilizerSpinner Spinner fertilizerSpinner; try{ fertilizerSpinner = (Spinner)findViewById(R.id.fertilizer_spinner); // Spinner Drop down elements List<String> categories = new ArrayList<String>(); categories.add("Cow"); categories.add("Chicken"); categories.add("Sheep"); categories.add("Swine"); categories.add("Urea"); // Creating adapter for spinner ArrayAdapter<String> fertilizerAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, categories); fertilizerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); // Specify the layout to use when the list of choices appears fertilizerSpinner.setAdapter(fertilizerAdapter); // Apply the adapter to the spinner } catch (Exception e){ Log.d("TT","ERROOURURURU : "+e.getLocalizedMessage()); } //set up cropSpinner Spinner cropSpinner; try{ cropSpinner = (Spinner)findViewById(R.id.crop_spinner); // Spinner Drop down elements List<String> categories2 = new ArrayList<String>(); categories2.add("Corn"); categories2.add("Rice"); categories2.add("Grain"); categories2.add("Soybean"); // Creating adapter for spinner ArrayAdapter<String> cropAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, categories2); cropAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); // Specify the layout to use when the list of choices appears cropSpinner.setAdapter(cropAdapter); // Apply the adapter to the spinner } catch (Exception e){ Log.d("TT","ERROOURURURU2222222 : "+e.getLocalizedMessage()); } */ return true; }