BVB Source Codes

Android-ItemTouchHelper-Demo Show RecyclerGridFragment.java Source code

Return Download Android-ItemTouchHelper-Demo: download RecyclerGridFragment.java Source code - Download Android-ItemTouchHelper-Demo Source code - Type:.java
  1. /*
  2.  * Copyright (C) 2015 Paul Burke
  3.  *
  4.  * Licensed under the Apache License, Version 2.0 (the "License");
  5.  * you may not use this file except in compliance with the License.
  6.  * You may obtain a copy of the License at
  7.  *
  8.  *      http://www.apache.org/licenses/LICENSE-2.0
  9.  *
  10.  * Unless required by applicable law or agreed to in writing, software
  11.  * distributed under the License is distributed on an "AS IS" BASIS,
  12.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13.  * See the License for the specific language governing permissions and
  14.  * limitations under the License.
  15.  */
  16.  
  17. package co.paulburke.android.itemtouchhelperdemo;
  18.  
  19. import android.os.Bundle;
  20. import android.support.annotation.Nullable;
  21. import android.support.v4.app.Fragment;
  22. import android.support.v7.widget.GridLayoutManager;
  23. import android.support.v7.widget.RecyclerView;
  24. import android.support.v7.widget.helper.ItemTouchHelper;
  25. import android.view.LayoutInflater;
  26. import android.view.View;
  27. import android.view.ViewGroup;
  28.  
  29. import co.paulburke.android.itemtouchhelperdemo.helper.OnStartDragListener;
  30. import co.paulburke.android.itemtouchhelperdemo.helper.SimpleItemTouchHelperCallback;
  31.  
  32. /**
  33.  * @author Paul Burke (ipaulpro)
  34.  */
  35. public class RecyclerGridFragment extends Fragment implements OnStartDragListener {
  36.  
  37.     private ItemTouchHelper mItemTouchHelper;
  38.  
  39.     public RecyclerGridFragment() {
  40.     }
  41.  
  42.     @Nullable
  43.     @Override
  44.     public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  45.         return new RecyclerView(container.getContext());
  46.     }
  47.  
  48.     @Override
  49.     public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
  50.         super.onViewCreated(view, savedInstanceState);
  51.  
  52.         final RecyclerListAdapter adapter = new RecyclerListAdapter(getActivity(), this);
  53.  
  54.         RecyclerView recyclerView = (RecyclerView) view;
  55.         recyclerView.setHasFixedSize(true);
  56.         recyclerView.setAdapter(adapter);
  57.  
  58.         final int spanCount = getResources().getInteger(R.integer.grid_columns);
  59.         final GridLayoutManager layoutManager = new GridLayoutManager(getActivity(), spanCount);
  60.         recyclerView.setLayoutManager(layoutManager);
  61.  
  62.         ItemTouchHelper.Callback callback = new SimpleItemTouchHelperCallback(adapter);
  63.         mItemTouchHelper = new ItemTouchHelper(callback);
  64.         mItemTouchHelper.attachToRecyclerView(recyclerView);
  65.     }
  66.  
  67.     @Override
  68.     public void onStartDrag(RecyclerView.ViewHolder viewHolder) {
  69.         mItemTouchHelper.startDrag(viewHolder);
  70.     }
  71. }
  72.  
downloadRecyclerGridFragment.java Source code - Download Android-ItemTouchHelper-Demo Source code
Related Source Codes/Software:
later - A javascript library for defining recurring schedu... 2017-04-16
x64dbg - An open-source x64/x32 debugger for windows. ... 2017-04-16
pencil - Multiplatform GUI Prototyping/Wireframing 2017-04-16
rainloop-webmail - Simple, modern & fast web-based email client ... 2017-04-16
qt - Qt binding for Go (Golang) which supports Windows ... 2017-04-16
onionshare - Securely and anonymously share a file of any size ... 2017-04-16
android-viewflow - A horizontal view scroller library for Android 2017-04-16
css-in-js - React: CSS in JS techniques comparison. 2017-04-16
st2 - StackStorm (aka IFTTT for Ops) is event-driven aut... 2017-04-16
WNXHuntForCity - City find By Objective - C 2017-04-16
viz.js - A hack to put Graphviz on the web. ... 2017-04-23
JKeyboardPanelSwitch - For resolve the layout conflict when keybord & amp... 2017-04-23
mama2 - Mother plan - all firewood high flame 2017-04-23
BlurEffectForAndroidDesign - Sample to show how to implement blur graphical tri... 2017-04-23
sphinx_rtd_theme - Sphinx theme for readthedocs.org 2017-04-23
rouge - A pure-ruby code highlighter that is compatible wi... 2017-04-23
spring-security-oauth - Support for adding OAuth1(a) and OAuth2 features (... 2017-04-23
Toucan - Fabulous Image Processing in Swift 2017-04-23
CoffeeScriptRedux - 2017-04-23
breakpoint - Really simple media queries in Sa 2017-04-23

 Back to top