Search in sources :

Example 1 with NumberPicker

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);
}
Also used : NumberPicker(android.widget.NumberPicker) EphemeralExpiration(com.waz.api.EphemeralExpiration) View(android.view.View) Field(java.lang.reflect.Field) ContextThemeWrapper(android.support.v7.view.ContextThemeWrapper)

Example 2 with 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();
}
Also used : ContentProviderOperation(android.content.ContentProviderOperation) R(com.simplecity.amp_library.R) GridLayoutManager(android.support.v7.widget.GridLayoutManager) ProgressBar(android.widget.ProgressBar) AndroidSchedulers(rx.android.schedulers.AndroidSchedulers) PlayCountTable(com.simplecity.amp_library.sql.providers.PlayCountTable) Drawable(android.graphics.drawable.Drawable) FileProvider(android.support.v4.content.FileProvider) Song(com.simplecity.amp_library.model.Song) FileObject(com.simplecity.amp_library.model.FileObject) Schedulers(rx.schedulers.Schedulers) View(android.view.View) BlacklistView(com.simplecity.amp_library.ui.modelviews.BlacklistView) BlacklistAdapter(com.simplecity.amp_library.ui.adapters.BlacklistAdapter) SimpleTarget(com.bumptech.glide.request.target.SimpleTarget) WhitelistAdapter(com.simplecity.amp_library.ui.adapters.WhitelistAdapter) R.id.album(com.simplecity.amp_library.R.id.album) MainActivity(com.simplecity.amp_library.ui.activities.MainActivity) ColorView(com.simplecity.amp_library.ui.modelviews.ColorView) R.id.artist(com.simplecity.amp_library.R.id.artist) WhitelistHelper(com.simplecity.amp_library.sql.databases.WhitelistHelper) FileNotFoundException(java.io.FileNotFoundException) CustomColorPicker(com.simplecity.amp_library.ui.views.CustomColorPicker) List(java.util.List) TextView(android.widget.TextView) ColorAdapter(com.simplecity.amp_library.ui.adapters.ColorAdapter) Html(android.text.Html) LastFmArtist(com.simplecity.amp_library.lastfm.LastFmArtist) ListView(android.widget.ListView) AdaptableItem(com.simplecity.amp_library.model.AdaptableItem) Snackbar(android.support.design.widget.Snackbar) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) Call(retrofit2.Call) Subscription(rx.Subscription) NumberPicker(android.widget.NumberPicker) SettingsActivity(com.simplecity.amp_library.ui.activities.SettingsActivity) Context(android.content.Context) LastFmAlbum(com.simplecity.amp_library.lastfm.LastFmAlbum) Stream(com.annimon.stream.Stream) EmptyView(com.simplecity.amp_library.ui.modelviews.EmptyView) HttpClient(com.simplecity.amp_library.http.HttpClient) Dialog(android.app.Dialog) Intent(android.content.Intent) RemoteException(android.os.RemoteException) StringRes(android.support.annotation.StringRes) Response(retrofit2.Response) SettingsFragment(com.simplecity.amp_library.ui.fragments.SettingsFragment) ArrayList(java.util.ArrayList) Observable(rx.Observable) GlideAnimation(com.bumptech.glide.request.animation.GlideAnimation) WhitelistView(com.simplecity.amp_library.ui.modelviews.WhitelistView) Toast(android.widget.Toast) DiskCacheStrategy(com.bumptech.glide.load.engine.DiskCacheStrategy) BlacklistedSong(com.simplecity.amp_library.model.BlacklistedSong) SqlBriteUtils(com.simplecity.amp_library.sql.sqlbrite.SqlBriteUtils) Collectors(com.annimon.stream.Collectors) ComponentName(android.content.ComponentName) LayoutInflater(android.view.LayoutInflater) IntentCompat(android.support.v4.content.IntentCompat) FileOutputStream(java.io.FileOutputStream) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) IOException(java.io.IOException) File(java.io.File) OperationApplicationException(android.content.OperationApplicationException) Color(android.graphics.Color) RecyclerView(android.support.v7.widget.RecyclerView) ArrayAdapter(android.widget.ArrayAdapter) ShuttleApplication(com.simplecity.amp_library.ShuttleApplication) BlacklistHelper(com.simplecity.amp_library.sql.databases.BlacklistHelper) Glide(com.bumptech.glide.Glide) Callback(retrofit2.Callback) ScrollView(android.widget.ScrollView) Bitmap(android.graphics.Bitmap) Activity(android.app.Activity) NumberPicker(android.widget.NumberPicker) View(android.view.View) BlacklistView(com.simplecity.amp_library.ui.modelviews.BlacklistView) ColorView(com.simplecity.amp_library.ui.modelviews.ColorView) TextView(android.widget.TextView) ListView(android.widget.ListView) EmptyView(com.simplecity.amp_library.ui.modelviews.EmptyView) WhitelistView(com.simplecity.amp_library.ui.modelviews.WhitelistView) RecyclerView(android.support.v7.widget.RecyclerView) ScrollView(android.widget.ScrollView)

Example 3 with NumberPicker

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);
    }
}
Also used : Rating(tr.bcxip.hummingbird.api.objects.Rating) NumberPicker(android.widget.NumberPicker) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) ImageView(android.widget.ImageView) ObservableScrollView(tr.bcxip.hummingbird.widget.ObservableScrollView) View(android.view.View) AdapterView(android.widget.AdapterView) SimpleRatingView(tr.xip.widget.simpleratingview.SimpleRatingView) TextView(android.widget.TextView) RatingBar(android.widget.RatingBar) AdapterView(android.widget.AdapterView) CompoundButton(android.widget.CompoundButton) SimpleRatingView(tr.xip.widget.simpleratingview.SimpleRatingView)

Example 4 with NumberPicker

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);
        }
    });
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) NumberPicker(android.widget.NumberPicker) DatabaseError(com.google.firebase.database.DatabaseError) TextView(android.widget.TextView) Shelter(com.example.peter.homelessapp.model.Shelter) ValueEventListener(com.google.firebase.database.ValueEventListener) DataSnapshot(com.google.firebase.database.DataSnapshot)

Example 5 with NumberPicker

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();
}
Also used : R(com.simplecity.amp_library.R) Context(android.content.Context) BaseTransientBottomBar(android.support.design.widget.BaseTransientBottomBar) LayoutInflater(android.view.LayoutInflater) Color(android.graphics.Color) ShuttleApplication(com.simplecity.amp_library.ShuttleApplication) SuppressLint(android.annotation.SuppressLint) TextView(android.widget.TextView) View(android.view.View) Snackbar(android.support.design.widget.Snackbar) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) Activity(android.app.Activity) NumberPicker(android.widget.NumberPicker) NumberPicker(android.widget.NumberPicker) SuppressLint(android.annotation.SuppressLint) TextView(android.widget.TextView) View(android.view.View)

Aggregations

NumberPicker (android.widget.NumberPicker)29 View (android.view.View)16 DialogInterface (android.content.DialogInterface)12 TextView (android.widget.TextView)12 AlertDialog (android.app.AlertDialog)9 Dialog (android.app.Dialog)8 Button (android.widget.Button)7 AlertDialog (android.support.v7.app.AlertDialog)6 LayoutInflater (android.view.LayoutInflater)6 Paint (android.graphics.Paint)5 NonNull (android.support.annotation.NonNull)5 CompoundButton (android.widget.CompoundButton)5 FrameLayout (android.widget.FrameLayout)5 OnClick (butterknife.OnClick)5 TimePickerDialog (android.app.TimePickerDialog)4 Activity (android.app.Activity)3 Intent (android.content.Intent)3 ImageView (android.widget.ImageView)3 ListView (android.widget.ListView)3 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)3