use of android.widget.NumberPicker in project wire-android by wireapp.
the class EphemeralLayout method onFinishInflate.
@Override
protected void onFinishInflate() {
super.onFinishInflate();
ContextThemeWrapper cw = new ContextThemeWrapper(getContext(), com.waz.zclient.ui.R.style.NumberPickerText);
numberPicker = new NumberPicker(cw);
numberPicker.setMinValue(0);
final EphemeralExpiration[] ephemeralExpirationsValues = getAvailableEphemeralExpirations();
numberPicker.setMaxValue(ephemeralExpirationsValues.length - 1);
String[] values = new String[ephemeralExpirationsValues.length];
for (int i = 0; i < values.length; i++) {
values[i] = getDisplayName(ephemeralExpirationsValues[i]);
}
numberPicker.setDisplayedValues(values);
numberPicker.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (callback != null) {
callback.onEphemeralExpirationSelected(ephemeralExpirationsValues[numberPicker.getValue()], true);
}
}
});
numberPicker.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() {
@Override
public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
if (callback != null) {
callback.onEphemeralExpirationSelected(ephemeralExpirationsValues[numberPicker.getValue()], false);
}
}
});
try {
//NoSuchFieldException
Field f = numberPicker.getClass().getDeclaredField("mSelectionDivider");
f.setAccessible(true);
f.set(numberPicker, getResources().getDrawable(com.waz.zclient.ui.R.drawable.number_picker_divider));
} catch (Throwable t) {
Timber.e(t, "Something went wrong");
}
addView(numberPicker);
}
use of android.widget.NumberPicker in project Shuttle by timusus.
the class DialogUtils method showWeekSelectorDialog.
public static void showWeekSelectorDialog(final Context context, final MaterialDialog.SingleButtonCallback listener) {
View view = LayoutInflater.from(context).inflate(R.layout.weekpicker, null);
final NumberPicker numberPicker;
numberPicker = (NumberPicker) view.findViewById(R.id.weeks);
numberPicker.setMaxValue(12);
numberPicker.setMinValue(1);
numberPicker.setValue(MusicUtils.getIntPref(context, "numweeks", 2));
getBuilder(context).title(R.string.week_selector).customView(view, false).negativeText(R.string.cancel).positiveText(R.string.picker_set).onPositive((materialDialog, dialogAction) -> {
int numweeks;
numweeks = numberPicker.getValue();
MusicUtils.setIntPref(context, "numweeks", numweeks);
if (listener != null) {
listener.onClick(materialDialog, dialogAction);
}
}).show();
}
use of android.widget.NumberPicker in project Hummingbird-for-Android by xiprox.
the class AnimeDetailsActivity method displayLibraryElements.
/* If Anime exist in user library, show library related elements... */
public void displayLibraryElements() {
if (libraryEntry != null) {
if (mRemove != null)
mRemove.setVisible(true);
final String animeEpisodeCount = anime.getEpisodeCount() != 0 ? anime.getEpisodeCount() + "" : "?";
mEpisodes.setText(libraryEntry.getEpisodesWatched() + "/" + animeEpisodeCount);
mRewatching.setChecked(libraryEntry.isRewatching());
mRewatchedTimes.setText(libraryEntry.getNumberOfRewatches() + "");
mPrivate.setChecked(libraryEntry.isPrivate());
Rating rating = libraryEntry.getRating();
if (rating.isAdvanced()) {
if (rating.getAdvancedRating() != null)
mRatingBar.setRating(Float.parseFloat(rating.getAdvancedRating()));
else
mRatingBar.setRating(0);
mRatingBar.setVisibility(View.VISIBLE);
mSimpleRatingView.setVisibility(View.GONE);
} else {
if (rating.getSimpleRating() != null)
mSimpleRatingView.setSelectedRating(Utils.getRatingFromString(rating.getSimpleRating()));
else
mSimpleRatingView.setSelectedRating(SimpleRatingView.Rating.NEUTRAL);
mRatingBar.setVisibility(View.GONE);
mSimpleRatingView.setVisibility(View.VISIBLE);
}
newWatchStatus = libraryEntry.getStatus();
newEpisodesWatched = libraryEntry.getEpisodesWatched();
newIsRewatching = libraryEntry.isRewatching();
newRewatchedTimes = libraryEntry.getNumberOfRewatches();
newPrivate = libraryEntry.isPrivate();
newRating = libraryEntry.getRating().getAdvancedRating() != null ? libraryEntry.getRating().getAdvancedRating() : "0";
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(AnimeDetailsActivity.this, R.array.library_watch_status_items, R.layout.item_spinner_library_status);
adapter.setDropDownViewResource(R.layout.item_spinner_item_library_status);
mStatusSpinner.setAdapter(adapter);
String watchStatus = libraryEntry.getStatus();
if (watchStatus.equals("currently-watching"))
mStatusSpinner.setSelection(0);
if (watchStatus.equals("plan-to-watch"))
mStatusSpinner.setSelection(1);
if (watchStatus.equals("completed"))
mStatusSpinner.setSelection(2);
if (watchStatus.equals("on-hold"))
mStatusSpinner.setSelection(3);
if (watchStatus.equals("dropped"))
mStatusSpinner.setSelection(4);
mEpisodesHolder.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
View dialogView = getLayoutInflater().inflate(R.layout.number_picker, null);
final NumberPicker mNumberPicker = (NumberPicker) dialogView.findViewById(R.id.number_picker);
mNumberPicker.setMaxValue(anime.getEpisodeCount() != 0 ? anime.getEpisodeCount() : 1000);
mNumberPicker.setValue(newEpisodesWatched);
mNumberPicker.setWrapSelectorWheel(false);
new MaterialDialog.Builder(AnimeDetailsActivity.this).title(R.string.content_episodes).positiveText(R.string.ok).negativeText(R.string.cancel).positiveColor(vibrantColor).negativeColorRes(R.color.text_dialog_action).customView(dialogView, true).callback(new MaterialDialog.ButtonCallback() {
@Override
public void onPositive(MaterialDialog materialDialog) {
newEpisodesWatched = mNumberPicker.getValue();
mEpisodes.setText(newEpisodesWatched + "/" + animeEpisodeCount);
if ((newEpisodesWatched + "").equals(animeEpisodeCount))
// (completed)
mStatusSpinner.setSelection(2);
updateUpdateButtonStatus(libraryEntry);
}
}).show();
}
});
mRewatching.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
newIsRewatching = isChecked;
updateUpdateButtonStatus(libraryEntry);
}
});
mRewatchedTimesHolder.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
View dialogView = getLayoutInflater().inflate(R.layout.number_picker, null);
final NumberPicker mNumberPicker = (NumberPicker) dialogView.findViewById(R.id.number_picker);
mNumberPicker.setMaxValue(200);
mNumberPicker.setValue(newRewatchedTimes);
mNumberPicker.setWrapSelectorWheel(false);
new MaterialDialog.Builder(AnimeDetailsActivity.this).title(R.string.content_rewatched).positiveText(R.string.ok).negativeText(R.string.cancel).positiveColor(vibrantColor).negativeColorRes(R.color.text_dialog_action).customView(dialogView, true).callback(new MaterialDialog.ButtonCallback() {
@Override
public void onPositive(MaterialDialog materialDialog) {
newRewatchedTimes = mNumberPicker.getValue();
mRewatchedTimes.setText(newRewatchedTimes + "");
updateUpdateButtonStatus(libraryEntry);
}
}).show();
}
});
mPrivate.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
newPrivate = isChecked;
updateUpdateButtonStatus(libraryEntry);
}
});
mStatusSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int position, long l) {
switch(position) {
case 0:
newWatchStatus = "currently-watching";
break;
case 1:
newWatchStatus = "plan-to-watch";
break;
case 2:
newWatchStatus = "completed";
break;
case 3:
newWatchStatus = "on-hold";
break;
case 4:
newWatchStatus = "dropped";
break;
}
updateUpdateButtonStatus(libraryEntry);
}
@Override
public void onNothingSelected(AdapterView<?> adapterView) {
}
});
mRatingBar.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() {
@Override
public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
newRating = rating + "";
updateUpdateButtonStatus(libraryEntry);
}
});
mSimpleRatingView.setOnRatingChangedListener(new SimpleRatingView.OnRatingChangeListener() {
@Override
public void onRatingChanged(SimpleRatingView.Rating rating) {
switch(rating) {
case POSITIVE:
newRating = "1";
break;
case NEUTRAL:
newRating = "3";
break;
case NEGATIVE:
newRating = "5";
break;
}
updateUpdateButtonStatus(libraryEntry);
}
});
mActionButton.setImageResource(R.drawable.ic_upload_white_24dp);
mActionButton.setOnClickListener(new OnLibraryUpdateClickListener());
mLibraryProgressBar.setVisibility(View.GONE);
mLibraryInfoHolder.setVisibility(View.VISIBLE);
} else {
enableFAB();
mRemove.setVisible(false);
mLibraryProgressBar.setVisibility(View.GONE);
mLibraryInfoHolder.setVisibility(View.GONE);
}
}
use of android.widget.NumberPicker in project FindMyHome by DjangoBlockchained.
the class ClaimScreenActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_claim_screen);
final TextView tv = (TextView) findViewById(R.id.tv);
NumberPicker np = (NumberPicker) findViewById(R.id.np);
np.setMinValue(1);
np.setMaxValue(10);
// User user = getIntent().getParcelableExtra("user");
username = getIntent().getStringExtra("username");
userRef = FirebaseDatabase.getInstance().getReference().child("users").child(username);
userRef.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
currentUser = dataSnapshot.getValue(HomelessUser.class);
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
String name = getIntent().getStringExtra("Shelter Name");
// .getParent();
shelterRef = FirebaseDatabase.getInstance().getReference().child("shelters").child(name);
shelterRef.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
shelter = dataSnapshot.getValue(Shelter.class);
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
// bedsPicker = (EditText) findViewById(R.id.claimnum);
claimButton = (Button) findViewById(R.id.claim);
claimButton.setOnClickListener((view) -> {
int beds = np.getValue();
if (!shelter.hasVacancy(beds)) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Not Enough Beds Available.");
builder.setMessage("This shelter has " + shelter.getNumberOfVacancies() + " beds available.");
builder.setPositiveButton("OK", (dialog, id) -> {
dialog.dismiss();
});
builder.create().show();
return;
}
if (currentUser.getCurrentShelter() != null) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Already Checked In");
builder.setMessage("You are already checked in to the shelter '" + currentUser.getCurrentShelter() + "'. Would you like to check out and check in to the new shelter?");
builder.setPositiveButton("Check Out", (dialog, id) -> {
String sheltername = currentUser.getCurrentShelter();
// .getParent();
shelterRef = FirebaseDatabase.getInstance().getReference().child("shelters").child(sheltername);
shelterRef.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
Shelter currShelter = dataSnapshot.getValue(Shelter.class);
if (currShelter.getName().equals(shelter.getName())) {
shelter.checkOut(currentUser);
} else {
currShelter.checkOut(currentUser);
}
checkIn(beds);
dialog.dismiss();
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
});
builder.setNegativeButton("Cancel", (dialog, id) -> {
dialog.dismiss();
});
builder.create().show();
return;
} else {
checkIn(beds);
}
});
}
use of android.widget.NumberPicker in project Shuttle by timusus.
the class DialogUtils method showWeekSelectorDialog.
public static void showWeekSelectorDialog(final Context context) {
@SuppressLint("InflateParams") View view = LayoutInflater.from(context).inflate(R.layout.weekpicker, null);
final NumberPicker numberPicker;
numberPicker = view.findViewById(R.id.weeks);
numberPicker.setMaxValue(12);
numberPicker.setMinValue(1);
numberPicker.setValue(MusicUtils.getIntPref(context, "numweeks", 2));
getBuilder(context).title(R.string.week_selector).customView(view, false).negativeText(R.string.cancel).positiveText(R.string.button_ok).onPositive((materialDialog, dialogAction) -> {
int numweeks;
numweeks = numberPicker.getValue();
MusicUtils.setIntPref(context, "numweeks", numweeks);
}).show();
}
Aggregations