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();
}
}
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();
}
}
}
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();
}
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();
}
});
}
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;
}
Aggregations