Search in sources :

Example 1 with ItemOffsetDecoration

use of de.danoeh.antennapod.view.ItemOffsetDecoration in project AntennaPod by AntennaPod.

the class TagSettingsDialog method onCreateDialog.

@NonNull
@Override
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
    ArrayList<FeedPreferences> feedPreferencesList = (ArrayList<FeedPreferences>) getArguments().getSerializable(ARG_FEED_PREFERENCES);
    Set<String> commonTags = new HashSet<>(feedPreferencesList.get(0).getTags());
    for (FeedPreferences preference : feedPreferencesList) {
        commonTags.retainAll(preference.getTags());
    }
    displayedTags = new ArrayList<>(commonTags);
    displayedTags.remove(FeedPreferences.TAG_ROOT);
    viewBinding = EditTagsDialogBinding.inflate(getLayoutInflater());
    viewBinding.tagsRecycler.setLayoutManager(new GridLayoutManager(getContext(), 2));
    viewBinding.tagsRecycler.addItemDecoration(new ItemOffsetDecoration(getContext(), 4));
    adapter = new TagSelectionAdapter();
    adapter.setHasStableIds(true);
    viewBinding.tagsRecycler.setAdapter(adapter);
    viewBinding.rootFolderCheckbox.setChecked(commonTags.contains(FeedPreferences.TAG_ROOT));
    viewBinding.newTagButton.setOnClickListener(v -> addTag(viewBinding.newTagEditText.getText().toString().trim()));
    loadTags();
    viewBinding.newTagEditText.setThreshold(1);
    viewBinding.newTagEditText.setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            viewBinding.newTagEditText.showDropDown();
            viewBinding.newTagEditText.requestFocus();
            return false;
        }
    });
    if (feedPreferencesList.size() > 1) {
        viewBinding.commonTagsInfo.setVisibility(View.VISIBLE);
    }
    AlertDialog.Builder dialog = new AlertDialog.Builder(getContext());
    dialog.setView(viewBinding.getRoot());
    dialog.setTitle(R.string.feed_tags_label);
    dialog.setPositiveButton(android.R.string.ok, (d, input) -> {
        addTag(viewBinding.newTagEditText.getText().toString().trim());
        updatePreferencesTags(feedPreferencesList, commonTags);
    });
    dialog.setNegativeButton(R.string.cancel_label, null);
    return dialog.create();
}
Also used : FeedPreferences(de.danoeh.antennapod.model.feed.FeedPreferences) AlertDialog(androidx.appcompat.app.AlertDialog) ArrayList(java.util.ArrayList) ItemOffsetDecoration(de.danoeh.antennapod.view.ItemOffsetDecoration) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) MotionEvent(android.view.MotionEvent) GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) HashSet(java.util.HashSet) NonNull(androidx.annotation.NonNull)

Example 2 with ItemOffsetDecoration

use of de.danoeh.antennapod.view.ItemOffsetDecoration in project AntennaPod by AntennaPod.

the class VariableSpeedDialog method onCreateView.

@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View root = View.inflate(getContext(), R.layout.speed_select_dialog, null);
    speedSeekBar = root.findViewById(R.id.speed_seek_bar);
    speedSeekBar.setProgressChangedListener(multiplier -> {
        if (controller != null) {
            controller.setPlaybackSpeed(multiplier);
        }
    });
    RecyclerView selectedSpeedsGrid = root.findViewById(R.id.selected_speeds_grid);
    selectedSpeedsGrid.setLayoutManager(new GridLayoutManager(getContext(), 3));
    selectedSpeedsGrid.addItemDecoration(new ItemOffsetDecoration(getContext(), 4));
    adapter = new SpeedSelectionAdapter();
    adapter.setHasStableIds(true);
    selectedSpeedsGrid.setAdapter(adapter);
    addCurrentSpeedChip = root.findViewById(R.id.add_current_speed_chip);
    addCurrentSpeedChip.setCloseIconVisible(true);
    addCurrentSpeedChip.setCloseIconResource(R.drawable.ic_add);
    addCurrentSpeedChip.setOnCloseIconClickListener(v -> addCurrentSpeed());
    addCurrentSpeedChip.setOnClickListener(v -> addCurrentSpeed());
    return root;
}
Also used : GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) RecyclerView(androidx.recyclerview.widget.RecyclerView) ItemOffsetDecoration(de.danoeh.antennapod.view.ItemOffsetDecoration) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) Nullable(androidx.annotation.Nullable)

Aggregations

View (android.view.View)2 GridLayoutManager (androidx.recyclerview.widget.GridLayoutManager)2 RecyclerView (androidx.recyclerview.widget.RecyclerView)2 ItemOffsetDecoration (de.danoeh.antennapod.view.ItemOffsetDecoration)2 MotionEvent (android.view.MotionEvent)1 NonNull (androidx.annotation.NonNull)1 Nullable (androidx.annotation.Nullable)1 AlertDialog (androidx.appcompat.app.AlertDialog)1 FeedPreferences (de.danoeh.antennapod.model.feed.FeedPreferences)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1