use of androidx.recyclerview.widget.LinearLayoutManager 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.LinearLayoutManager in project ahbottomnavigation by aurelhubert.
the class DemoFragment method initDemoList.
/**
* Init the fragment
*/
private void initDemoList(View view) {
fragmentContainer = view.findViewById(R.id.fragment_container);
recyclerView = view.findViewById(R.id.fragment_demo_recycler_view);
recyclerView.setHasFixedSize(true);
layoutManager = new LinearLayoutManager(getActivity());
recyclerView.setLayoutManager(layoutManager);
ArrayList<String> itemsData = new ArrayList<>();
for (int i = 0; i < 50; i++) {
itemsData.add("Fragment " + getArguments().getInt("index", -1) + " / Item " + i);
}
DemoAdapter adapter = new DemoAdapter(itemsData);
recyclerView.setAdapter(adapter);
}
use of androidx.recyclerview.widget.LinearLayoutManager in project storio by pushtorefresh.
the class MainActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
storIOSQLite = DefaultStorIOSQLite.builder().sqliteOpenHelper(new DbOpenHelper(this)).addTypeMapping(Tweet.class, new TweetSQLiteTypeMapping()).build();
tweetsAdapter = new TweetsAdapter();
recyclerView = (RecyclerView) findViewById(R.id.tweets_recycler_view);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.setAdapter(tweetsAdapter);
addTweets();
}
use of androidx.recyclerview.widget.LinearLayoutManager 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;
}
use of androidx.recyclerview.widget.LinearLayoutManager in project AntennaPod by AntennaPod.
the class DownloadStatisticsFragment method onCreateView.
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View root = inflater.inflate(R.layout.statistics_activity, container, false);
downloadStatisticsList = root.findViewById(R.id.statistics_list);
progressBar = root.findViewById(R.id.progressBar);
listAdapter = new DownloadStatisticsListAdapter(getContext());
downloadStatisticsList.setLayoutManager(new LinearLayoutManager(getContext()));
downloadStatisticsList.setAdapter(listAdapter);
return root;
}
Aggregations