Search in sources :

Example 16 with RecyclerView

use of androidx.recyclerview.widget.RecyclerView in project materialistic by hidroh.

the class UserActivity method onCreate.

@SuppressWarnings("ConstantConditions")
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mUsername = getIntent().getStringExtra(EXTRA_USERNAME);
    if (TextUtils.isEmpty(mUsername)) {
        mUsername = AppUtils.getDataUriId(getIntent(), PARAM_ID);
    }
    if (TextUtils.isEmpty(mUsername)) {
        finish();
        return;
    }
    setTaskTitle(mUsername);
    AppUtils.setStatusBarDim(getWindow(), true);
    setContentView(R.layout.activity_user);
    findViewById(R.id.touch_outside).setOnClickListener(v -> finish());
    mBottomSheetBehavior = BottomSheetBehavior.from(findViewById(R.id.bottom_sheet));
    mBottomSheetBehavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {

        @Override
        public void onStateChanged(@NonNull View bottomSheet, int newState) {
            switch(newState) {
                case BottomSheetBehavior.STATE_HIDDEN:
                    finish();
                    break;
                case BottomSheetBehavior.STATE_EXPANDED:
                    AppUtils.setStatusBarDim(getWindow(), false);
                    mRecyclerView.setLayoutFrozen(false);
                    break;
                case BottomSheetBehavior.STATE_COLLAPSED:
                case BottomSheetBehavior.STATE_DRAGGING:
                case BottomSheetBehavior.STATE_HALF_EXPANDED:
                case BottomSheetBehavior.STATE_SETTLING:
                default:
                    AppUtils.setStatusBarDim(getWindow(), true);
                    break;
            }
        }

        @Override
        public void onSlide(@NonNull View bottomSheet, float slideOffset) {
        // no op
        }
    });
    mTitle = (TextView) findViewById(R.id.title);
    mTitle.setText(mUsername);
    mInfo = (TextView) findViewById(R.id.user_info);
    mAbout = (TextView) findViewById(R.id.about);
    mEmpty = findViewById(R.id.empty);
    mTabLayout = (TabLayout) findViewById(R.id.tab_layout);
    mTabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {

        @Override
        public void onTabSelected(TabLayout.Tab tab) {
        // no op
        }

        @Override
        public void onTabUnselected(TabLayout.Tab tab) {
        // no op
        }

        @Override
        public void onTabReselected(TabLayout.Tab tab) {
            scrollToTop();
        }
    });
    mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view);
    mRecyclerView.setLayoutManager(new SnappyLinearLayoutManager(this, true));
    mRecyclerView.addItemDecoration(new CommentItemDecoration(this));
    mScrollableHelper = new KeyDelegate.RecyclerViewHelper(mRecyclerView, KeyDelegate.RecyclerViewHelper.SCROLL_ITEM);
    if (savedInstanceState != null) {
        mUser = savedInstanceState.getParcelable(STATE_USER);
    }
    if (mUser == null) {
        load();
    } else {
        bind();
    }
    if (!AppUtils.hasConnection(this)) {
        Snackbar.make(findViewById(R.id.content_frame), R.string.offline_notice, Snackbar.LENGTH_LONG).show();
    }
}
Also used : CommentItemDecoration(io.github.hidroh.materialistic.widget.CommentItemDecoration) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) BottomSheetBehavior(com.google.android.material.bottomsheet.BottomSheetBehavior) TabLayout(com.google.android.material.tabs.TabLayout) SnappyLinearLayoutManager(io.github.hidroh.materialistic.widget.SnappyLinearLayoutManager)

Example 17 with RecyclerView

use of androidx.recyclerview.widget.RecyclerView in project xLog by elvishew.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    tagView = (TextView) findViewById(R.id.tag);
    tagView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            showChangeTagDialog();
        }
    });
    levelView = (Spinner) findViewById(R.id.level);
    threadInfo = (CheckedTextView) findViewById(R.id.thread_info);
    threadInfo.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            threadInfo.toggle();
        }
    });
    stackTraceInfo = (CheckedTextView) findViewById(R.id.stack_trace_info);
    stackTraceInfo.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            stackTraceInfo.toggle();
            setEnabledStateOnViews(stackTraceDepthContainer, stackTraceInfo.isChecked());
        }
    });
    stackTraceDepthContainer = findViewById(R.id.stack_trace_depth_container);
    setEnabledStateOnViews(stackTraceDepthContainer, false);
    stackTraceDepth = (Spinner) stackTraceDepthContainer.findViewById(R.id.stack_trace_depth);
    border = (CheckedTextView) findViewById(R.id.border);
    border.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            border.toggle();
        }
    });
    // Setup print button.
    findViewById(R.id.print).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            printLog();
        }
    });
    // Setup view printer.
    RecyclerView logContainer = (RecyclerView) findViewById(R.id.log_container);
    viewPrinter = new RecyclerViewPrinter(logContainer);
    // Print welcome message.
    XLog.printers(viewPrinter).i("XLog is ready.\nPrint your log now!");
    // Check permission.
    hasPermission = hasPermission();
    if (!hasPermission) {
        if (shouldShowRequestPermissionRationale()) {
            showPermissionRequestDialog(false);
        } else {
            requestPermission();
        }
    }
}
Also used : RecyclerView(androidx.recyclerview.widget.RecyclerView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) CheckedTextView(android.widget.CheckedTextView) Toolbar(androidx.appcompat.widget.Toolbar)

Example 18 with RecyclerView

use of androidx.recyclerview.widget.RecyclerView in project OneSignal-Android-SDK by OneSignal.

the class Dialog method createSendOutcomeAlertDialog.

public void createSendOutcomeAlertDialog(final String content) {
    final View sendOutcomeAlertDialogView = layoutInflater.inflate(R.layout.send_outcome_alert_dialog_layout, null, false);
    final CardView sendOutcomeDialogTitleCardView = sendOutcomeAlertDialogView.findViewById(R.id.send_outcome_alert_dialog_selection_card_view);
    final RelativeLayout sendOutcomeDialogTitleRelativeLayout = sendOutcomeAlertDialogView.findViewById(R.id.send_outcome_alert_dialog_selection_relative_layout);
    final TextView sendOutcomeDialogTitleTextView = sendOutcomeAlertDialogView.findViewById(R.id.send_outcome_alert_dialog_selection_text_view);
    final ImageView sendOutcomeDialogTitleArrowImageView = sendOutcomeAlertDialogView.findViewById(R.id.send_outcome_alert_dialog_selection_arrow_image_view);
    final RecyclerView sendOutcomeDialogSelectionRecyclerView = sendOutcomeAlertDialogView.findViewById(R.id.send_outcome_alert_dialog_selection_recycler_view);
    final LinearLayout sendOutcomeDialogSelectionContentLinearLayout = sendOutcomeAlertDialogView.findViewById(R.id.send_outcome_alert_dialog_content_linear_layout);
    final TextInputLayout sendOutcomeDialogNameTextInputLayout = sendOutcomeAlertDialogView.findViewById(R.id.send_outcome_alert_dialog_name_text_input_layout);
    final EditText sendOutcomeDialogNameEditText = sendOutcomeAlertDialogView.findViewById(R.id.send_outcome_alert_dialog_name_edit_text);
    final TextInputLayout sendOutcomeDialogValueTextInputLayout = sendOutcomeAlertDialogView.findViewById(R.id.send_outcome_alert_dialog_value_text_input_layout);
    final EditText sendOutcomeDialogValueEditText = sendOutcomeAlertDialogView.findViewById(R.id.send_outcome_alert_dialog_value_edit_text);
    final ProgressBar sendOutcomeDialogProgressBar = sendOutcomeAlertDialogView.findViewById(R.id.send_outcome_alert_dialog_progress_bar);
    sendOutcomeDialogNameTextInputLayout.setHint("Name");
    sendOutcomeDialogValueTextInputLayout.setHint("Value");
    sendOutcomeDialogTitleTextView.setText(content);
    font.applyFont(sendOutcomeDialogTitleTextView, font.saralaBold);
    font.applyFont(sendOutcomeDialogNameTextInputLayout, font.saralaBold);
    font.applyFont(sendOutcomeDialogValueTextInputLayout, font.saralaBold);
    sendOutcomeDialogTitleCardView.setCardElevation(8f);
    recyclerViewBuilder.setupRecyclerView(sendOutcomeDialogSelectionRecyclerView, 3, false, true);
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context);
    sendOutcomeDialogSelectionRecyclerView.setLayoutManager(linearLayoutManager);
    EnumSelectionRecyclerViewAdapter enumSelectionRecyclerViewAdapter = new EnumSelectionRecyclerViewAdapter(context, OutcomeEvent.values(), new EnumSelectionCallback() {

        @Override
        public void onSelection(String title) {
            int nameVisibility = View.GONE;
            int valueVisibility = View.GONE;
            OutcomeEvent outcomeEvent = OutcomeEvent.enumFromTitleString(title);
            if (outcomeEvent == null) {
                Drawable arrow = context.getResources().getDrawable(R.drawable.ic_chevron_down_white_48dp);
                sendOutcomeDialogTitleArrowImageView.setImageDrawable(arrow);
                sendOutcomeDialogTitleCardView.setCardElevation(0f);
                sendOutcomeDialogSelectionRecyclerView.setVisibility(View.GONE);
                sendOutcomeDialogSelectionContentLinearLayout.setVisibility(View.GONE);
                sendOutcomeDialogNameEditText.setVisibility(nameVisibility);
                sendOutcomeDialogValueTextInputLayout.setVisibility(valueVisibility);
                return;
            }
            switch(outcomeEvent) {
                case OUTCOME:
                case UNIQUE_OUTCOME:
                    nameVisibility = View.VISIBLE;
                    break;
                case OUTCOME_WITH_VALUE:
                    nameVisibility = View.VISIBLE;
                    valueVisibility = View.VISIBLE;
                    break;
            }
            sendOutcomeDialogTitleTextView.setText(outcomeEvent.getTitle());
            Drawable arrow = context.getResources().getDrawable(R.drawable.ic_chevron_down_white_48dp);
            sendOutcomeDialogTitleArrowImageView.setImageDrawable(arrow);
            sendOutcomeDialogTitleCardView.setCardElevation(0f);
            sendOutcomeDialogSelectionRecyclerView.setVisibility(View.GONE);
            sendOutcomeDialogSelectionContentLinearLayout.setVisibility(View.VISIBLE);
            sendOutcomeDialogNameTextInputLayout.setVisibility(nameVisibility);
            sendOutcomeDialogNameEditText.setVisibility(nameVisibility);
            sendOutcomeDialogValueTextInputLayout.setVisibility(valueVisibility);
            sendOutcomeDialogValueEditText.setVisibility(valueVisibility);
        }
    });
    sendOutcomeDialogSelectionRecyclerView.setAdapter(enumSelectionRecyclerViewAdapter);
    sendOutcomeDialogTitleRelativeLayout.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean showMenu = sendOutcomeDialogSelectionRecyclerView.getVisibility() == View.GONE;
            Drawable arrow = context.getResources().getDrawable(showMenu ? R.drawable.ic_chevron_up_white_48dp : R.drawable.ic_chevron_down_white_48dp);
            int menuVisibility = showMenu ? View.VISIBLE : View.GONE;
            int contentVisibility = showMenu ? View.GONE : View.VISIBLE;
            float shadow = showMenu ? 8f : 0f;
            sendOutcomeDialogTitleArrowImageView.setImageDrawable(arrow);
            sendOutcomeDialogTitleCardView.setCardElevation(shadow);
            sendOutcomeDialogSelectionRecyclerView.setVisibility(menuVisibility);
            sendOutcomeDialogSelectionContentLinearLayout.setVisibility(contentVisibility);
            int nameVisibility = View.GONE;
            int valueVisibility = View.GONE;
            String selectedTitle = sendOutcomeDialogTitleTextView.getText().toString();
            OutcomeEvent outcomeEvent = OutcomeEvent.enumFromTitleString(selectedTitle);
            if (outcomeEvent == null) {
                sendOutcomeDialogSelectionContentLinearLayout.setVisibility(View.GONE);
                return;
            }
            if (!showMenu) {
                switch(outcomeEvent) {
                    case OUTCOME:
                    case UNIQUE_OUTCOME:
                        nameVisibility = View.VISIBLE;
                        break;
                    case OUTCOME_WITH_VALUE:
                        nameVisibility = View.VISIBLE;
                        valueVisibility = View.VISIBLE;
                        break;
                }
            }
            sendOutcomeDialogSelectionContentLinearLayout.setVisibility(nameVisibility);
            sendOutcomeDialogNameEditText.setVisibility(nameVisibility);
            sendOutcomeDialogValueTextInputLayout.setVisibility(valueVisibility);
            sendOutcomeDialogValueEditText.setVisibility(valueVisibility);
        }
    });
    final CustomAlertDialogBuilder sendOutcomeAlertDialog = new CustomAlertDialogBuilder(context, sendOutcomeAlertDialogView);
    sendOutcomeAlertDialog.setView(sendOutcomeAlertDialogView);
    sendOutcomeAlertDialog.setIsCancelable(true);
    sendOutcomeAlertDialog.setCanceledOnTouchOutside(false);
    sendOutcomeAlertDialog.setPositiveButton(Text.BUTTON_SEND, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(final DialogInterface dialog, int which) {
            toggleUpdateAlertDialogAttributes(true);
            String selectedTitle = sendOutcomeDialogTitleTextView.getText().toString();
            OutcomeEvent outcomeEvent = OutcomeEvent.enumFromTitleString(selectedTitle);
            if (outcomeEvent == null) {
                toaster.makeCustomViewToast("Please select an outcome type!", ToastType.ERROR);
                toggleUpdateAlertDialogAttributes(false);
                return;
            }
            String name = sendOutcomeDialogNameEditText.getText().toString().trim();
            String value = sendOutcomeDialogValueEditText.getText().toString().trim();
            if (name.isEmpty()) {
                toaster.makeCustomViewToast("Please enter an outcome name!", ToastType.ERROR);
                toggleUpdateAlertDialogAttributes(false);
                return;
            }
            switch(outcomeEvent) {
                case OUTCOME:
                    OneSignal.sendOutcome(name, new OneSignal.OutcomeCallback() {

                        @Override
                        public void onSuccess(@Nullable OSOutcomeEvent outcomeEvent) {
                            ((Activity) context).runOnUiThread(new Runnable() {

                                @Override
                                public void run() {
                                    toggleUpdateAlertDialogAttributes(false);
                                    dialog.dismiss();
                                }
                            });
                        }
                    });
                    break;
                case UNIQUE_OUTCOME:
                    OneSignal.sendUniqueOutcome(name, new OneSignal.OutcomeCallback() {

                        @Override
                        public void onSuccess(@Nullable OSOutcomeEvent outcomeEvent) {
                            ((Activity) context).runOnUiThread(new Runnable() {

                                @Override
                                public void run() {
                                    toggleUpdateAlertDialogAttributes(false);
                                    dialog.dismiss();
                                }
                            });
                        }
                    });
                    break;
                case OUTCOME_WITH_VALUE:
                    if (value.isEmpty()) {
                        toaster.makeCustomViewToast("Please enter an outcome value!", ToastType.ERROR);
                        toggleUpdateAlertDialogAttributes(false);
                        return;
                    }
                    OneSignal.sendOutcomeWithValue(name, Float.parseFloat(value), new OneSignal.OutcomeCallback() {

                        @Override
                        public void onSuccess(@Nullable OSOutcomeEvent outcomeEvent) {
                            ((Activity) context).runOnUiThread(new Runnable() {

                                @Override
                                public void run() {
                                    toggleUpdateAlertDialogAttributes(false);
                                    dialog.dismiss();
                                }
                            });
                        }
                    });
                    break;
            }
            InterfaceUtil.hideKeyboardFrom(context, sendOutcomeAlertDialogView);
        }

        private void toggleUpdateAlertDialogAttributes(boolean disableAttributes) {
            int progressVisibility = disableAttributes ? View.VISIBLE : View.GONE;
            sendOutcomeDialogProgressBar.setVisibility(progressVisibility);
            int buttonVisibility = disableAttributes ? View.GONE : View.VISIBLE;
            sendOutcomeAlertDialog.getPositiveButtonElement().setVisibility(buttonVisibility);
            sendOutcomeAlertDialog.getNegativeButtonElement().setVisibility(buttonVisibility);
            sendOutcomeAlertDialog.getPositiveButtonElement().setEnabled(!disableAttributes);
            sendOutcomeAlertDialog.getNegativeButtonElement().setEnabled(!disableAttributes);
            sendOutcomeAlertDialog.setIsCancelable(!disableAttributes);
        }
    }).setNegativeButton(Text.BUTTON_CANCEL, null);
    sendOutcomeAlertDialog.show();
}
Also used : OneSignal(com.onesignal.OneSignal) DialogInterface(android.content.DialogInterface) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) OutcomeEvent(com.onesignal.sdktest.type.OutcomeEvent) OSOutcomeEvent(com.onesignal.OSOutcomeEvent) TextView(android.widget.TextView) CustomAlertDialogBuilder(com.onesignal.sdktest.ui.CustomAlertDialogBuilder) ImageView(android.widget.ImageView) TextInputLayout(com.google.android.material.textfield.TextInputLayout) ProgressBar(android.widget.ProgressBar) EditText(android.widget.EditText) OSOutcomeEvent(com.onesignal.OSOutcomeEvent) CardView(androidx.cardview.widget.CardView) Drawable(android.graphics.drawable.Drawable) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) CardView(androidx.cardview.widget.CardView) TextView(android.widget.TextView) EnumSelectionCallback(com.onesignal.sdktest.callback.EnumSelectionCallback) RelativeLayout(android.widget.RelativeLayout) RecyclerView(androidx.recyclerview.widget.RecyclerView) LinearLayout(android.widget.LinearLayout) EnumSelectionRecyclerViewAdapter(com.onesignal.sdktest.adapter.EnumSelectionRecyclerViewAdapter)

Example 19 with RecyclerView

use of androidx.recyclerview.widget.RecyclerView in project greedo-layout-for-android by 500px.

the class SampleActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sample);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    }
    PhotosAdapter photosAdapter = new PhotosAdapter(this);
    final GreedoLayoutManager layoutManager = new GreedoLayoutManager(photosAdapter);
    layoutManager.setMaxRowHeight(MeasUtils.dpToPx(150, this));
    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setAdapter(photosAdapter);
    int spacing = MeasUtils.dpToPx(4, this);
    recyclerView.addItemDecoration(new GreedoSpacingItemDecoration(spacing));
    findViewById(R.id.toggle_fixed_height).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            layoutManager.setFixedHeight(((ToggleButton) view).isChecked());
            layoutManager.requestLayout();
        }
    });
}
Also used : GreedoLayoutManager(com.fivehundredpx.greedolayout.GreedoLayoutManager) ToggleButton(android.widget.ToggleButton) RecyclerView(androidx.recyclerview.widget.RecyclerView) GreedoSpacingItemDecoration(com.fivehundredpx.greedolayout.GreedoSpacingItemDecoration) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView)

Example 20 with RecyclerView

use of androidx.recyclerview.widget.RecyclerView in project AntennaPod by AntennaPod.

the class NavDrawerFragment method onCreateView.

@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    View root = inflater.inflate(R.layout.nav_list, container, false);
    SharedPreferences preferences = getContext().getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
    // Must not modify
    openFolders = new HashSet<>(preferences.getStringSet(PREF_OPEN_FOLDERS, new HashSet<>()));
    progressBar = root.findViewById(R.id.progressBar);
    RecyclerView navList = root.findViewById(R.id.nav_list);
    navAdapter = new NavListAdapter(itemAccess, getActivity());
    navAdapter.setHasStableIds(true);
    navList.setAdapter(navAdapter);
    navList.setLayoutManager(new LinearLayoutManager(getContext()));
    root.findViewById(R.id.nav_settings).setOnClickListener(v -> startActivity(new Intent(getActivity(), PreferenceActivity.class)));
    preferences.registerOnSharedPreferenceChangeListener(this);
    return root;
}
Also used : SharedPreferences(android.content.SharedPreferences) NavListAdapter(de.danoeh.antennapod.adapter.NavListAdapter) RecyclerView(androidx.recyclerview.widget.RecyclerView) Intent(android.content.Intent) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView)

Aggregations

RecyclerView (androidx.recyclerview.widget.RecyclerView)352 View (android.view.View)232 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)156 TextView (android.widget.TextView)51 GridLayoutManager (androidx.recyclerview.widget.GridLayoutManager)39 ImageView (android.widget.ImageView)29 Nullable (androidx.annotation.Nullable)29 Toolbar (androidx.appcompat.widget.Toolbar)25 Test (org.junit.Test)24 ArrayList (java.util.ArrayList)20 Intent (android.content.Intent)19 NonNull (androidx.annotation.NonNull)19 StaggeredGridLayoutManager (androidx.recyclerview.widget.StaggeredGridLayoutManager)19 Bundle (android.os.Bundle)18 ViewGroup (android.view.ViewGroup)16 SwipeRefreshLayout (androidx.swiperefreshlayout.widget.SwipeRefreshLayout)16 Context (android.content.Context)15 Rect (android.graphics.Rect)15 SuppressLint (android.annotation.SuppressLint)12 LayoutInflater (android.view.LayoutInflater)11