use of android.support.v7.widget.helper.ItemTouchHelper in project sbt-android by scala-android.
the class HomeActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
ButterKnife.bind(this);
drawer.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
// toolbar.inflateMenu(R.menu.main);
setActionBar(toolbar);
if (savedInstanceState == null) {
animateToolbar();
}
dribbblePrefs = DribbblePrefs.get(this);
designerNewsPrefs = DesignerNewsPrefs.get(this);
filtersAdapter = new FilterAdapter(this, SourceManager.getSources(this), new FilterAdapter.FilterAuthoriser() {
@Override
public void requestDribbbleAuthorisation(View sharedElemeent, Source forSource) {
Intent login = new Intent(HomeActivity.this, DribbbleLogin.class);
login.putExtra(FabDialogMorphSetup.EXTRA_SHARED_ELEMENT_START_COLOR, ContextCompat.getColor(HomeActivity.this, R.color.background_dark));
ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(HomeActivity.this, sharedElemeent, getString(R.string.transition_dribbble_login));
startActivityForResult(login, getAuthSourceRequestCode(forSource), options.toBundle());
}
});
dataManager = new DataManager(this, filtersAdapter) {
@Override
public void onDataLoaded(List<? extends PlaidItem> data) {
adapter.addAndResort(data);
checkEmptyState();
}
};
adapter = new FeedAdapter(this, dataManager, columns, PocketUtils.isPocketInstalled(this));
grid.setAdapter(adapter);
layoutManager = new GridLayoutManager(this, columns);
layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
return adapter.getItemColumnSpan(position);
}
});
grid.setLayoutManager(layoutManager);
grid.addOnScrollListener(gridScroll);
grid.addOnScrollListener(new InfiniteScrollListener(layoutManager, dataManager) {
@Override
public void onLoadMore() {
dataManager.loadAllDataSources();
}
});
grid.setHasFixedSize(true);
// drawer layout treats fitsSystemWindows specially so we have to handle insets ourselves
drawer.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
@Override
public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
// inset the toolbar down by the status bar height
ViewGroup.MarginLayoutParams lpToolbar = (ViewGroup.MarginLayoutParams) toolbar.getLayoutParams();
lpToolbar.topMargin += insets.getSystemWindowInsetTop();
lpToolbar.rightMargin += insets.getSystemWindowInsetRight();
toolbar.setLayoutParams(lpToolbar);
// inset the grid top by statusbar+toolbar & the bottom by the navbar (don't clip)
grid.setPadding(grid.getPaddingLeft(), insets.getSystemWindowInsetTop() + ViewUtils.getActionBarSize(HomeActivity.this), // landscape
grid.getPaddingRight() + insets.getSystemWindowInsetRight(), grid.getPaddingBottom());
// inset the fab for the navbar
ViewGroup.MarginLayoutParams lpFab = (ViewGroup.MarginLayoutParams) fab.getLayoutParams();
// portrait
lpFab.bottomMargin += insets.getSystemWindowInsetBottom();
// landscape
lpFab.rightMargin += insets.getSystemWindowInsetRight();
fab.setLayoutParams(lpFab);
// we place a background behind the status bar to combine with it's semi-transparent
// color to get the desired appearance. Set it's height to the status bar height
View statusBarBackground = findViewById(R.id.status_bar_background);
FrameLayout.LayoutParams lpStatus = (FrameLayout.LayoutParams) statusBarBackground.getLayoutParams();
lpStatus.height = insets.getSystemWindowInsetTop();
statusBarBackground.setLayoutParams(lpStatus);
// inset the filters list for the status bar / navbar
// need to set the padding end for landscape case
final boolean ltr = filtersList.getLayoutDirection() == View.LAYOUT_DIRECTION_LTR;
filtersList.setPaddingRelative(filtersList.getPaddingStart(), filtersList.getPaddingTop() + insets.getSystemWindowInsetTop(), filtersList.getPaddingEnd() + (ltr ? insets.getSystemWindowInsetRight() : 0), filtersList.getPaddingBottom() + insets.getSystemWindowInsetBottom());
// clear this listener so insets aren't re-applied
drawer.setOnApplyWindowInsetsListener(null);
return insets.consumeSystemWindowInsets();
}
});
setupTaskDescription();
filtersList.setAdapter(filtersAdapter);
filtersAdapter.addFilterChangedListener(filtersChangedListener);
filtersAdapter.addFilterChangedListener(dataManager);
dataManager.loadAllDataSources();
ItemTouchHelper.Callback callback = new FilterTouchHelperCallback(filtersAdapter);
ItemTouchHelper itemTouchHelper = new ItemTouchHelper(callback);
itemTouchHelper.attachToRecyclerView(filtersList);
checkEmptyState();
checkConnectivity();
}
use of android.support.v7.widget.helper.ItemTouchHelper in project android_packages_apps_Settings by DirtyUnicorns.
the class ConditionAdapter method addDismissHandling.
public void addDismissHandling(final RecyclerView recyclerView) {
final ItemTouchHelper itemTouchHelper = new ItemTouchHelper(mSwipeCallback);
itemTouchHelper.attachToRecyclerView(recyclerView);
}
use of android.support.v7.widget.helper.ItemTouchHelper in project xRecyclerViewF by Dsiner.
the class ItemTouchActivity method init.
private void init() {
// step9-1:获取引用-!!!!!!!!!!不要使用XRecyclerView
rvList = (RecyclerView) this.findViewById(R.id.rv_list);
rvList.setHasFixedSize(true);
// step9-2:为RecyclerView指定布局管理对象
setLayoutManager(isLinear);
// step9-3:setAdapter
adapter = new ItemTouchAdapter(this, Factory.createDatas(15), R.layout.item_touch);
adapter.toggle(isLinear);
adapter.setOnStartDragListener(this);
rvList.setAdapter(adapter);
// step9-4:关联ItemTouchHelper
ItemTouchHelper.Callback callback = new SimpleItemTouchHelperCallback(adapter);
itemTouchHelper = new ItemTouchHelper(callback);
// !!!!!!!!!!不要使用XRecyclerView-重要的事情说三遍
itemTouchHelper.attachToRecyclerView(rvList);
}
use of android.support.v7.widget.helper.ItemTouchHelper in project PhoneProfiles 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 osm-contributor by jawg.
the class TypeListActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_type_list);
ButterKnife.bind(this);
((OsmTemplateApplication) getApplication()).getOsmTemplateComponent().inject(this);
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
}
presenter = new TypeListActivityPresenter(this, savedInstanceState);
typesAdapter = new PoiTypeAdapter(new ArrayList<PoiType>(), bitmapHandler);
typesAdapter.setPoiTypeAdapterListener(presenter.getPoiTypeAdapterListener());
recyclerTypes.setAdapter(typesAdapter);
recyclerTypes.setLayoutManager(new LinearLayoutManager(this));
ItemTouchHelper.Callback callback = new SwipeItemTouchHelperCallback(typesAdapter);
ItemTouchHelper swipeItemTouchHelper = new ItemTouchHelper(callback);
swipeItemTouchHelper.attachToRecyclerView(recyclerTypes);
tagsAdapter = new PoiTypeTagAdapter(new ArrayList<PoiTypeTag>());
tagsAdapter.setPoiTypeTagAdapterListener(presenter.getPoiTypeTagAdapterListener());
tagsAdapter.setOnStartDragListener(this);
recyclerTags.setAdapter(tagsAdapter);
recyclerTags.setLayoutManager(new LinearLayoutManager(this));
ItemTouchHelper.Callback dragSwipeCallback = new DragSwipeItemTouchHelperCallback(tagsAdapter);
dragSwipeItemTouchHelper = new ItemTouchHelper(dragSwipeCallback);
dragSwipeItemTouchHelper.attachToRecyclerView(recyclerTags);
listSwitcher.prepareViews(showingTypes);
if (savedInstanceState != null) {
filterConstraint = savedInstanceState.getString(FILTER_CONSTRAINT);
}
}
Aggregations