예제 #1
0
  private void init() {

    searchField = (EditText) findViewById(R.id.search);
    clear = (ImageButton) findViewById(R.id.clear);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    genreSpinner = (AppCompatSpinner) findViewById(R.id.genre);
    sortSpinner = (AppCompatSpinner) findViewById(R.id.sort);
    ratingSpinner = (AppCompatSpinner) findViewById(R.id.rating);
    searchButton = (FloatingActionButton) findViewById(R.id.search_button);
    qualityRG = (RadioGroup) findViewById(R.id.quality_rg);
    orderRG = (RadioGroup) findViewById(R.id.order_rg);

    setSupportActionBar(toolbar);
    //noinspection ConstantConditions
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_HOME_AS_UP);

    ArrayAdapter<CharSequence> genreAdapter =
        ArrayAdapter.createFromResource(this, R.array.genre_name, R.layout.dropdown_display);
    genreAdapter.setDropDownViewResource(R.layout.dropdown_item);
    genreSpinner.setAdapter(genreAdapter);

    ArrayAdapter<CharSequence> sortAdapter =
        ArrayAdapter.createFromResource(this, R.array.sort_name, R.layout.dropdown_display);
    sortAdapter.setDropDownViewResource(R.layout.dropdown_item);
    sortSpinner.setAdapter(sortAdapter);

    ArrayAdapter<CharSequence> ratingAdapter =
        ArrayAdapter.createFromResource(this, R.array.rating_name, R.layout.dropdown_display);
    ratingAdapter.setDropDownViewResource(R.layout.dropdown_item);
    ratingSpinner.setAdapter(ratingAdapter);

    imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_partitionitem_list, container, false);

    //  get views
    mSpinnerPartitionScheme = (AppCompatSpinner) view.findViewById(R.id.spinner_partition_scheme);
    View schemeContainer = view.findViewById(R.id.scheme_container);

    if (mOperatingSystem.isCreationMode()) {
      // partition scheme
      mSpinnerPartitionScheme.setOnItemSelectedListener(
          new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
              PartitionScheme scheme = mSpinnerSchemes.get(position);
              scheme.mCallback.onSetDefaults();
              mOperatingSystem.notifyChange();
            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {}
          });
      onOperatingSystemChanged();
    } else {
      schemeContainer.setVisibility(View.GONE);
    }

    // Set the adapter
    Context context = view.getContext();
    RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.list);
    recyclerView.setLayoutManager(new LinearLayoutManager(context));
    recyclerView.setAdapter(new PartitionItemRecyclerViewAdapter(mOperatingSystem, mListener));
    return view;
  }
  @Override
  public void onOperatingSystemChanged() {
    if (mSpinnerPartitionScheme == null || !mOperatingSystem.isCreationMode()) return;

    OperatingSystemEditActivity.MultibootDir location = mOperatingSystem.getLocation();
    String osType = mOperatingSystem.getOperatingSystemType();

    // check if sth. has changed
    if (mPreviousOSType != null && mPreviousLocation != null) {
      if (mPreviousOSType.equals(osType) && mPreviousLocation == location) return;
    }

    // spinner schemes
    mSpinnerSchemes.clear();
    if (location != null) {
      boolean bindSupported =
          OperatingSystem.isBindAllowed(mOperatingSystem.getLocation().mountEntry.getFsType());

      if (bindSupported) mSpinnerSchemes.add(SCHEMES.get(SCHEMEID_ANDROID_DYNSYS_BINDOTHER));
      if (bindSupported) mSpinnerSchemes.add(SCHEMES.get(SCHEMEID_ANDROID_BINDALL));
      mSpinnerSchemes.add(SCHEMES.get(SCHEMEID_ANDROID_DYNSYS_LOOPOTHER));
      mSpinnerSchemes.add(SCHEMES.get(SCHEMEID_ANDROID_LOOPALL));
    }
    mSpinnerPartitionScheme.setAdapter(
        new ArrayAdapter<>(
            getContext(), R.layout.support_simple_spinner_dropdown_item, mSpinnerSchemes));

    // update previous data
    mPreviousOSType = osType;
    mPreviousLocation = location;
  }
 private void generateNumberTimePerDay() {
   ReminderItem remind = ReminderList.getInstance().getCurrentReminder();
   if (remind == null) {
     return;
   }
   int diffMinutes =
       (remind.getEndTime().hour * 60 + remind.getEndTime().minute)
           - (remind.getStartTime().hour * 60 + remind.getStartTime().minute);
   int max = Math.max(diffMinutes / 10, 1);
   remind.setNumberPerDay(Math.min(remind.getNumberPerDay(), max));
   List<String> perDayList = new ArrayList<>();
   for (int i = 0; i < max; i++) {
     perDayList.add(Integer.toString(i + 1));
   }
   ArrayAdapter<String> spinnerArrayAdapter =
       new ArrayAdapter<>(
           parent.getContext(), R.layout.support_simple_spinner_dropdown_item, perDayList);
   spinnerArrayAdapter.setDropDownViewResource(R.layout.simple_drop_down_item);
   timeSpinner.setAdapter(spinnerArrayAdapter);
   timeSpinner.setSelection(remind.getNumberPerDay() - 1);
 }
예제 #5
0
  public static void setupServiceSelector() {
    AppCompatSpinner serviceSelector =
        (AppCompatSpinner) toolbar.findViewById(R.id.toolbar_service_selector);
    ArrayAdapter<String> spinnerAdapter =
        new ArrayAdapter<String>(
            mainActivity,
            android.R.layout.simple_spinner_dropdown_item,
            new String[] {"m5", "Arion", "Landsbanki", "Arion - Visa"});
    serviceSelector.setAdapter(spinnerAdapter);
    serviceSelector.setOnItemSelectedListener(
        new AdapterView.OnItemSelectedListener() {
          @Override
          public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            switch (position) {
              case 0:
                ISKCurrency.setUrl("http://apis.is");
                selectedBank = "m5";
                break;
              case 1:
                ISKCurrency.setUrl("http://apis.is");
                selectedBank = "arion";
                break;
              case 2:
                ISKCurrency.setUrl("http://apis.is");
                selectedBank = "lb";
                break;
              case 3:
                ISKCurrency.setUrl("http://arionbanki.is");
                break;
            }
            serviceAdapter = new ServiceAdapter(ISKCurrency.getServerInfo());
            reloadFragment();
          }

          @Override
          public void onNothingSelected(AdapterView<?> parent) {}
        });
  }
예제 #6
0
  @Override
  protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.be_creator_menu);

    /** *** CONFIGURE THE ACTIONBAR **** */
    configAB();

    /** *** CAST THE LAYOUT ELEMENTS **** */
    castLayoutElements();

    /** *** FETCH THE MENU CATEGORIES **** */
    new fetchMenuCategories().execute();

    /** *** SELECT A MENU CATEGORY FOR THE DISH TO GO IN **** */
    spnMenuCategory.setOnItemSelectedListener(selectCategory);
  }
  public final void bindItem(EditReminderItem item) {
    ReminderItem remind = ReminderList.getInstance().getCurrentReminder();
    if (remind == null) {
      return;
    }
    updateTimingType();
    updateStartTime();
    updateEndTime();
    generateNumberTimePerDay();

    timingContainer.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            String title = AppUtil.getContext().getString(R.string.timing_type);
            String[] items =
                new String[] {
                  AppUtil.getContext().getString(R.string.range),
                  AppUtil.getContext().getString(R.string.specific)
                };
            Bus.postObject(
                new SingleChoiceRequest(
                    title,
                    items,
                    new DialogInterface.OnClickListener() {
                      @Override
                      public void onClick(DialogInterface dialog, int which) {
                        ReminderItem remind = ReminderList.getInstance().getCurrentReminder();
                        if (remind == null) {
                          return;
                        }
                        if (which == 0) {
                          remind.setRangeTiming(true);
                        } else {
                          remind.setRangeTiming(false);
                        }
                        updateTimingType();
                      }
                    },
                    new DialogInterface.OnClickListener() {
                      @Override
                      public void onClick(DialogInterface dialog, int which) {
                        // On Negative. Unused
                      }
                    }));
          }
        });
    timesContainer.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            ReminderItem remind = ReminderList.getInstance().getCurrentReminder();
            if (remind == null) {
              return;
            }
            Bus.postObject(
                new EditTimesRequest(
                    remind.getSpecificTimeList(),
                    new EditTimesDialog.EditTimesListener() {
                      @Override
                      public void onPositive(ArrayList<TimeItem> times) {
                        ReminderItem remind = ReminderList.getInstance().getCurrentReminder();
                        if (remind == null) {
                          return;
                        }
                        remind.setSpecificTimeList(times);
                      }
                    },
                    new View.OnClickListener() {
                      @Override
                      public void onClick(View v) {}
                    },
                    true));
          }
        });
    final TimePickerDialog.OnTimeSetListener timeStartListener =
        new TimePickerDialog.OnTimeSetListener() {
          @Override
          public void onTimeSet(
              @NonNull RadialPickerLayout radialPickerLayout, int hourOfDay, int minute) {
            ReminderItem remind = ReminderList.getInstance().getCurrentReminder();
            if (remind == null) {
              return;
            }
            int diffMinutes =
                (remind.getEndTime().hour * 60 + remind.getEndTime().minute)
                    - (hourOfDay * 60 + minute);
            if (diffMinutes >= 0) {
              remind.updateStartTime().hour = hourOfDay;
              remind.updateStartTime().minute = minute;
              UtilsTime.setTime(startHour, startMinute, startAM, startPM, remind.getStartTime());
              generateNumberTimePerDay();
            } else {
              Utils.toastShort(
                  AppUtil.getContext().getResources().getString(R.string.error_time_difference));
            }
          }
        };
    startTimeContainer.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(@NonNull View v) {
            ReminderItem currentReminder = ReminderList.getInstance().getCurrentReminder();
            if (currentReminder == null) {
              return;
            }
            Bus.postObject(
                new TimePickerRequest(
                    timeStartListener,
                    currentReminder.getStartTime().hour,
                    currentReminder.getStartTime().minute,
                    currentReminder.getStartTime().is24Hour()));
          }
        });
    final TimePickerDialog.OnTimeSetListener timeEndListener =
        new TimePickerDialog.OnTimeSetListener() {
          @Override
          public void onTimeSet(
              @NonNull RadialPickerLayout radialPickerLayout, int hourOfDay, int minute) {
            ReminderItem remind = ReminderList.getInstance().getCurrentReminder();
            if (remind == null) {
              return;
            }
            int diffMinutes =
                (hourOfDay * 60 + minute)
                    - (remind.getStartTime().hour * 60 + remind.getStartTime().minute);
            if (diffMinutes >= 0) {
              remind.updateEndTime().hour = hourOfDay;
              remind.updateEndTime().minute = minute;
              UtilsTime.setTime(endHour, endMinute, endAM, endPM, remind.getEndTime());
              generateNumberTimePerDay();
            } else {
              Utils.toastShort(
                  AppUtil.getContext().getResources().getString(R.string.error_time_difference));
            }
          }
        };
    endTimeContainer.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(@NonNull View v) {
            ReminderItem currentReminder = ReminderList.getInstance().getCurrentReminder();
            if (currentReminder == null) {
              return;
            }
            Bus.postObject(
                new TimePickerRequest(
                    timeEndListener,
                    currentReminder.getEndTime().hour,
                    currentReminder.getEndTime().minute,
                    currentReminder.getEndTime().is24Hour()));
          }
        });
    timeSpinner.setOnItemSelectedListener(
        new AdapterView.OnItemSelectedListener() {
          @Override
          public void onItemSelected(
              @NonNull AdapterView<?> parent, @NonNull View view, int position, long id) {
            ReminderItem currentReminder = ReminderList.getInstance().getCurrentReminder();
            if (currentReminder == null) {
              return;
            }
            currentReminder.setNumberPerDay(position + 1);
          }

          @Override
          public void onNothingSelected(AdapterView<?> parent) {}
        });
    numTimesContainer.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            timeSpinner.performClick();
          }
        });
  }
예제 #8
0
  /** *** CAST THE LAYOUT ELEMENTS **** */
  private void castLayoutElements() {

    /* CATEGORY SELECTOR */
    spnMenuCategory = (AppCompatSpinner) findViewById(R.id.spnMenuCategory);
    AppCompatTextView txtAddNewCategory = (AppCompatTextView) findViewById(R.id.txtAddNewCategory);

    /* MENU / DISH DETAILS */
    inputDishName = (TextInputLayout) findViewById(R.id.inputDishName);
    edtDishName = (AppCompatEditText) findViewById(R.id.edtDishName);
    inputDishDescription = (TextInputLayout) findViewById(R.id.inputDishDescription);
    edtDishDescription = (AppCompatEditText) findViewById(R.id.edtDishDescription);
    inputDishPrice = (TextInputLayout) findViewById(R.id.inputDishPrice);
    edtDishPrice = (AppCompatEditText) findViewById(R.id.edtDishPrice);
    RadioGroup rdgDishType = (RadioGroup) findViewById(R.id.rdgDishType);
    spnServes = (AppCompatSpinner) findViewById(R.id.spnServes);
    imgvwAddPhoto = (AppCompatImageView) findViewById(R.id.imgvwAddPhoto);

    /** CHANGE THE MEAL TYPE * */
    rdgDishType.setOnCheckedChangeListener(
        new RadioGroup.OnCheckedChangeListener() {
          @Override
          public void onCheckedChanged(RadioGroup radioGroup, int checkedId) {

            switch (checkedId) {
              case R.id.rdbtnVeg:
                /** SET THE DISH TYPE TO "VEG" * */
                MEAL_TYPE = "Veg";
                break;
              case R.id.rdbtnNonVeg:
                /** SET THE DISH TYPE TO "NON-VEG" * */
                MEAL_TYPE = "Non-veg";
                break;
              default:
                break;
            }
          }
        });

    /** *** CREATE A NEW CATEGORY **** */
    txtAddNewCategory.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            Intent newCategory = new Intent(MenuCreator.this, CategoryCreator.class);
            startActivityForResult(newCategory, ACTION_REQUEST_NEW_CATEGORY);
          }
        });

    /** *** SELECT A PHOTO FOR THE DISH **** */
    imgvwAddPhoto.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            EasyImage.openChooser(MenuCreator.this, "Pick Image Source", true);
          }
        });

    /** POPULATE THE SPINNER * */
    String[] strServes = getResources().getStringArray(R.array.menuServes);
    final List<String> arrServes;
    arrServes = Arrays.asList(strServes);
    spnServes.setAdapter(
        new MenuServesAdapter(MenuCreator.this, R.layout.custom_spinner_row, arrServes));

    /** CHANGE THE MENU SERVES NUMBER * */
    spnServes.setOnItemSelectedListener(
        new AdapterView.OnItemSelectedListener() {
          @Override
          public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            //                Toast.makeText(getApplication(), arrServes.get(position),
            // Toast.LENGTH_SHORT).show();
            MEAL_SERVES = arrServes.get(position);
          }

          @Override
          public void onNothingSelected(AdapterView<?> parent) {}
        });
  }