use of android.support.v7.widget.helper.ItemTouchHelper in project PhoneProfilesPlus by henrichg.
the class ApplicationsMultiSelectDialogPreference method showDialog.
protected void showDialog(Bundle state) {
PPApplication.logE("ApplicationsMultiSelectDialogPreference.showDialog", "xxx");
MaterialDialog.Builder mBuilder = new MaterialDialog.Builder(getContext()).title(getDialogTitle()).icon(getDialogIcon()).positiveText(getPositiveButtonText()).negativeText(getNegativeButtonText()).autoDismiss(false).onPositive(new MaterialDialog.SingleButtonCallback() {
@SuppressWarnings("StringConcatenationInLoop")
@Override
public void onClick(@NonNull MaterialDialog materialDialog, @NonNull DialogAction dialogAction) {
if (shouldPersist()) {
// fill with contact strings separated with |
value = "";
if (applicationList != null) {
for (Application application : applicationList) {
if (application.checked) {
if (!value.isEmpty())
value = value + "|";
if (application.shortcut)
value = value + "(s)";
value = value + application.packageName + "/" + application.activityName;
}
}
}
persistString(value);
setIcons();
setSummaryAMSDP();
mDialog.dismiss();
}
}
}).onNegative(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
mDialog.dismiss();
}
}).content(getDialogMessage()).customView(R.layout.activity_applications_multiselect_pref_dialog, false).dividerColor(0);
mBuilder.showListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(DialogInterface dialog) {
ApplicationsMultiSelectDialogPreference.this.onShow();
}
});
mDialog = mBuilder.build();
View layout = mDialog.getCustomView();
// noinspection ConstantConditions
linlaProgress = layout.findViewById(R.id.applications_multiselect_pref_dlg_linla_progress);
// noinspection ConstantConditions
rellaData = layout.findViewById(R.id.applications_multiselect_pref_dlg_rella_data);
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getContext());
// noinspection ConstantConditions
FastScrollRecyclerView listView = layout.findViewById(R.id.applications_multiselect_pref_dlg_listview);
listView.setLayoutManager(layoutManager);
listView.setHasFixedSize(true);
listAdapter = new ApplicationsMultiSelectPreferenceAdapter(_context, this, addShortcuts);
listView.setAdapter(listAdapter);
/*
// added touch helper for drag and drop items
ItemTouchHelper.Callback callback = new ItemTouchHelperCallback(listAdapter, false, false);
itemTouchHelper = new ItemTouchHelper(callback);
itemTouchHelper.attachToRecyclerView(listView);
*/
final Button unselectAllButton = layout.findViewById(R.id.applications_multiselect_pref_dlg_unselect_all);
unselectAllButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
value = "";
refreshListView(false);
}
});
GlobalGUIRoutines.registerOnActivityDestroyListener(this, this);
if (state != null)
mDialog.onRestoreInstanceState(state);
mDialog.setOnDismissListener(this);
mDialog.show();
}
use of android.support.v7.widget.helper.ItemTouchHelper in project haven by guardianproject.
the class EventActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_event);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
StrictMode.setVmPolicy(StrictMode.VmPolicy.LAX);
long eventId = getIntent().getLongExtra("eventid", -1);
if (eventId != -1) {
mEvent = Event.findById(Event.class, eventId);
mRecyclerView = findViewById(R.id.event_trigger_list);
setTitle(mEvent.getStartTime().toLocaleString());
mAdapter = new EventTriggerAdapter(this, mEvent.getEventTriggers());
LinearLayoutManager llm = new LinearLayoutManager(this);
mRecyclerView.setLayoutManager(llm);
mRecyclerView.setAdapter(mAdapter);
FloatingActionButton fab = findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
shareEvent();
}
});
// Handling swipe to delete
ItemTouchHelper.SimpleCallback simpleCallback = new ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT) {
@Override
public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
return false;
}
@Override
public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
// Remove swiped item from list and notify the RecyclerView
final int position = viewHolder.getAdapterPosition();
final EventTrigger eventTrigger = mEvent.getEventTriggers().get(viewHolder.getAdapterPosition());
deleteEventTrigger(eventTrigger, position);
}
};
ItemTouchHelper itemTouchHelper = new ItemTouchHelper(simpleCallback);
itemTouchHelper.attachToRecyclerView(mRecyclerView);
} else
finish();
}
use of android.support.v7.widget.helper.ItemTouchHelper in project Roblu by wdavies973.
the class TBAEventSelector method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_apievent_select);
teamNumber = new IO(getApplicationContext()).loadSettings().getTeamNumber();
/*
* Setup UI
*/
// Setup
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
if (getSupportActionBar() != null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setTitle("Select an event");
}
// Progress bar
bar = findViewById(R.id.progress_bar);
bar.setVisibility(View.GONE);
// Recycler view
rv = findViewById(R.id.events_recycler);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
rv.setLayoutManager(linearLayoutManager);
((SimpleItemAnimator) rv.getItemAnimator()).setSupportsChangeAnimations(false);
// Setup the tbaEventAdapter
tbaEventAdapter = new TBAEventAdapter(this, this);
rv.setAdapter(tbaEventAdapter);
// Setup the gesture listener
ItemTouchHelper.Callback callback = new TutorialsRecyclerTouchHelper();
ItemTouchHelper helper = new ItemTouchHelper(callback);
helper.attachToRecyclerView(rv);
/*
* Create the "My Events / All Events" chooser
*/
Spinner showTeam = findViewById(R.id.show_team);
ArrayAdapter<String> sAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, new String[] { "My events", "All events" });
sAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
showTeam.setAdapter(sAdapter);
showTeam.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long l) {
onlyShowMyEvents = parent.getItemAtPosition(position).toString().equals("My events");
rv.setVisibility(View.INVISIBLE);
bar.setVisibility(View.VISIBLE);
if (tbaEventAdapter.getEvents() != null)
tbaEventAdapter.getEvents().clear();
tbaEventAdapter.notifyDataSetChanged();
TBALoadEventsTask task = new TBALoadEventsTask(bar, rv, tbaEventAdapter, TBAEventSelector.this, teamNumber, selectedYear, onlyShowMyEvents);
task.execute();
}
@Override
public void onNothingSelected(AdapterView<?> adapterView) {
}
});
// If no team number is found, default to "All events"
if (new IO(getApplicationContext()).loadSettings().getTeamNumber() == 0)
showTeam.setSelection(1);
/*
* Setup the years spinner
*/
Spinner yearsSpinner = findViewById(R.id.spinner);
selectedYear = Calendar.getInstance().get(Calendar.YEAR);
String[] years = new String[selectedYear - 1991];
for (int i = years.length - 1; i >= 0; i--) years[Math.abs(i - years.length + 1)] = String.valueOf(1992 + i);
final ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, years);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
yearsSpinner.setAdapter(adapter);
yearsSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
selectedYear = Integer.parseInt(adapterView.getItemAtPosition(i).toString());
rv.setVisibility(View.INVISIBLE);
bar.setVisibility(View.VISIBLE);
if (tbaEventAdapter.getEvents() != null)
tbaEventAdapter.getEvents().clear();
tbaEventAdapter.notifyDataSetChanged();
TBALoadEventsTask task = new TBALoadEventsTask(bar, rv, tbaEventAdapter, TBAEventSelector.this, teamNumber, selectedYear, onlyShowMyEvents);
task.execute();
}
@Override
public void onNothingSelected(AdapterView<?> adapterView) {
}
});
/*
* Setup the search view
*/
searchView = findViewById(R.id.search_view);
searchView.setHintTextColor(Color.BLACK);
searchView.setHint("Search events");
searchView.setOnSearchViewListener(new MaterialSearchView.SearchViewListener() {
@Override
public void onSearchViewShown() {
}
@Override
public void onSearchViewClosed() {
TBALoadEventsTask task = new TBALoadEventsTask(bar, rv, tbaEventAdapter, TBAEventSelector.this, teamNumber, selectedYear, onlyShowMyEvents);
task.setEvents(events);
task.execute();
}
});
searchView.setOnQueryTextListener(new MaterialSearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
searchView.closeSearch();
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
TBALoadEventsTask task = new TBALoadEventsTask(bar, rv, tbaEventAdapter, TBAEventSelector.this, teamNumber, selectedYear, onlyShowMyEvents);
task.setEvents(events);
task.setQuery(newText);
task.execute();
return true;
}
});
// Sync UI with user preferences
new UIHandler(this, toolbar).update();
}
use of android.support.v7.widget.helper.ItemTouchHelper in project Roblu by wdavies973.
the class Tutorial method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tutorial);
/*
* Setup UI
*/
// Toolbar
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
if (getSupportActionBar() != null) {
getSupportActionBar().setTitle("Tutorials");
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
// List of tutorials
tutorials = new ArrayList<>();
tutorials.add(new RTutorial("Text based", "View the Roblu text based tutorial", "https://docs.google.com/document/d/1DqpgKPdtfZDUc7Zu3MqdJHL59aB-ht8H1ZwllYlzMuc/edit?usp=sharing"));
tutorials.add(new RTutorial("The basics", "Roblu's mission, description of platforms, terms, etc.", "9j6ysvJJyQg"));
tutorials.add(new RTutorial("Events", "Learn how to create, manage, backup, organize, and export events", "6BLlLxltppk"));
tutorials.add(new RTutorial("Forms", "Learn how to create, manage, edit, organize, master form", "xLLbPyhW9fg"));
tutorials.add(new RTutorial("Roblu Cloud (Network syncing)", "Learn how to setup and sync scouting data across unlimited devices over a data connection.", "z9tIGaaV1jQ"));
tutorials.add(new RTutorial("Bluetooth Syncing", "Learn how to setup and sync with Bluetooth syncing.", "Adjp3rjt2_4"));
tutorials.add(new RTutorial("QR Codes", "Learn how to use QR code syncing", "pS_5bvp1D_c"));
tutorials.add(new RTutorial("Manual Schedule Importer", "Learn how to use the manual schedule importer if the FIRST API is down.", "https://github.com/wdavies973/Roblu/wiki/Manually-Importing-a-Match-Schedule"));
tutorials.add(new RTutorial("Scouting / Odds and Ends", "Learn about those features that weren't in any of the other tutorial videos", "JL_lSaB0gsk"));
tutorials.add(new RTutorial("How to get Roblu Cloud for free", "Get Roblu Cloud for free", "dQw4w9WgXcQ"));
tutorials.add(new RTutorial("Roblu Devlogs", "For those interested in watching the development process", ""));
/*
* Add the tutorials to the recycler view
*/
rv = findViewById(R.id.teams_recycler);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
rv.setLayoutManager(linearLayoutManager);
((SimpleItemAnimator) rv.getItemAnimator()).setSupportsChangeAnimations(false);
TutorialsRecyclerAdapter adapter = new TutorialsRecyclerAdapter(this, this, tutorials);
rv.setAdapter(adapter);
// Gesture listener
ItemTouchHelper.Callback callback = new TutorialsRecyclerTouchHelper();
ItemTouchHelper helper = new ItemTouchHelper(callback);
helper.attachToRecyclerView(rv);
// Sync UI with settings
new UIHandler(this, toolbar).update();
}
use of android.support.v7.widget.helper.ItemTouchHelper in project Roblu by wdavies973.
the class MetricSortFragment method onCreateView.
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.metric_tab, container, false);
/*
* Receive parameters
*/
Bundle bundle = this.getArguments();
metrics = (ArrayList<RMetric>) bundle.getSerializable("metrics");
processMethod = bundle.getInt("processMethod");
eventID = bundle.getInt("eventID");
/*
* Attach metrics to the RecyclerView
*/
rv = view.findViewById(R.id.metric_recycler);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(view.getContext());
linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
rv.setLayoutManager(linearLayoutManager);
((SimpleItemAnimator) rv.getItemAnimator()).setSupportsChangeAnimations(false);
FormRecyclerAdapter adapter = new FormRecyclerAdapter(view.getContext(), this);
rv.setAdapter(adapter);
// setup gesture listener
ItemTouchHelper.Callback callback = new FormRecyclerTouchHelper(adapter, true);
ItemTouchHelper helper = new ItemTouchHelper(callback);
helper.attachToRecyclerView(rv);
adapter.setMetrics(metrics);
return view;
}
Aggregations