use of android.support.v7.widget.helper.ItemTouchHelper.DOWN in project Riksdagskollen by OAndell.
the class CurrentNewsListFragment method onCreateView.
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_party_list, null);
currentNewsListAdapter = new CurrentNewsListAdapter(newsList);
recyclerView = view.findViewById(R.id.recycler_view);
recyclerView.setAdapter(currentNewsListAdapter);
recyclerView.setNestedScrollingEnabled(true);
final LinearLayoutManager mLayoutManager = new LinearLayoutManager(getContext());
recyclerView.setLayoutManager(mLayoutManager);
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
if (// check for scroll down
dy > 0) {
int visibleItemCount = mLayoutManager.getChildCount();
int totalItemCount = mLayoutManager.getItemCount();
pastVisiblesItems = mLayoutManager.findFirstVisibleItemPosition();
if ((visibleItemCount + pastVisiblesItems) >= totalItemCount) {
if (!loading)
loadNextPage();
}
}
}
});
loadingView = view.findViewById(R.id.loading_view);
loadNextPage();
return view;
}
use of android.support.v7.widget.helper.ItemTouchHelper.DOWN in project afwall by ukanth.
the class AppDetailActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTitle(getString(R.string.traffic_detail_title));
setContentView(R.layout.app_detail);
int appid = getIntent().getIntExtra("appid", -1);
String packageName = getIntent().getStringExtra("package");
try {
CheckBox logOption = (CheckBox) findViewById(R.id.notification_p);
LogPreference logPreference = SQLite.select().from(LogPreference.class).where(LogPreference_Table.uid.eq(appid)).querySingle();
if (logPreference != null) {
logOption.setChecked(logPreference.isDisable());
}
logOption.setOnCheckedChangeListener((buttonView, isChecked) -> {
// only use when triggered by user
if (buttonView.isPressed()) {
// write the logic here
G.updateLogNotification(appid, isChecked);
}
});
} catch (Exception e) {
}
Toolbar toolbar = (Toolbar) findViewById(R.id.app_toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
final Context ctx = getApplicationContext();
ImageView image = (ImageView) findViewById(R.id.app_icon);
TextView textView = (TextView) findViewById(R.id.app_title);
TextView textView2 = (TextView) findViewById(R.id.app_package);
TextView up = (TextView) findViewById(R.id.up);
TextView down = (TextView) findViewById(R.id.down);
/**/
final PackageManager packageManager = getApplicationContext().getPackageManager();
final String[] packageNameList = ctx.getPackageManager().getPackagesForUid(appid);
final String pName = packageName;
Button button = findViewById(R.id.app_settings);
button.setOnClickListener(v -> Api.showInstalledAppDetails(getApplicationContext(), pName));
ApplicationInfo applicationInfo;
try {
if (!packageName.startsWith("dev.afwall.special.")) {
applicationInfo = packageManager.getApplicationInfo(packageName, PackageManager.GET_META_DATA);
if (applicationInfo != null) {
image.setImageDrawable(applicationInfo.loadIcon(packageManager));
String name = packageManager.getApplicationLabel(applicationInfo).toString();
textView.setText(name);
setTotalBytesManual(down, up, applicationInfo.uid);
}
} else {
image.setImageDrawable(getApplicationContext().getResources().getDrawable(R.drawable.ic_android_white_24dp));
if (appid >= 0) {
textView.setText(Api.getSpecialDescription(getApplicationContext(), packageName.replace("dev.afwall.special.", "")));
} else {
textView.setText(Api.getSpecialDescriptionSystem(getApplicationContext(), packageName.replace("dev.afwall.special.", "")));
}
down.setText(" : " + humanReadableByteCount(0, false));
up.setText(" : " + humanReadableByteCount(0, false));
button.setEnabled(false);
}
if (packageNameList != null && packageNameList.length > 1) {
textView2.setText(Arrays.toString(packageNameList));
button.setEnabled(false);
} else {
textView2.setText(packageName);
}
} catch (final NameNotFoundException e) {
down.setText(" : " + humanReadableByteCount(0, false));
up.setText(" : " + humanReadableByteCount(0, false));
button.setEnabled(false);
}
}
use of android.support.v7.widget.helper.ItemTouchHelper.DOWN in project SimpleBucketList-material by thevarunshah.
the class BucketItemListView method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.bucket_item_listview);
// fetch toolbar and set it as the action bar
Toolbar toolbar = findViewById(R.id.toolbar);
toolbar.setContentInsetsRelative(72, 72);
setSupportActionBar(toolbar);
// check if tablet view is being used
boolean tablet = (findViewById(R.id.coordLayout_tablet) != null);
// obtain list view and create new bucket list custom adapter
recyclerView = findViewById(R.id.recycler_view);
recyclerAdapter = new BucketItemListAdapter(this, Utility.getBucketList(), tablet, this);
// attach adapter to list view
recyclerView.setAdapter(recyclerAdapter);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
ItemTouchHelper.Callback callback = new SimpleItemTouchHelperCallback(recyclerAdapter);
itemTouchHelper = new ItemTouchHelper(callback);
itemTouchHelper.attachToRecyclerView(recyclerView);
// obtain add button and attach a on-tap listener to it
final FloatingActionButton addButton = findViewById(R.id.add_item);
addButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// inflate layout with customized alert dialog view
LayoutInflater layoutInflater = LayoutInflater.from(BucketItemListView.this);
final View dialog = layoutInflater.inflate(R.layout.input_dialog, null);
final AlertDialog.Builder newItemDialogBuilder = new AlertDialog.Builder(BucketItemListView.this, R.style.AppCompatAlertDialogStyle);
// customize alert dialog and set its view
newItemDialogBuilder.setTitle("New Item");
newItemDialogBuilder.setIcon(R.drawable.ic_launcher);
newItemDialogBuilder.setView(dialog);
// fetch and set up edittext
final EditText input = dialog.findViewById(R.id.input_dialog_text);
input.setHint("Enter Details");
input.setFocusableInTouchMode(true);
input.requestFocus();
// set up actions for dialog buttons
newItemDialogBuilder.setPositiveButton("ADD", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialogInterface, int whichButton) {
// create new item
String itemText = input.getText().toString();
Item item = new Item(itemText);
// add item to main list and update view
Utility.getBucketList().add(item);
recyclerAdapter.notifyDataSetChanged();
// backup data
Utility.writeData(getApplicationContext());
}
});
newItemDialogBuilder.setNegativeButton("CANCEL", null);
// create and show the dialog
AlertDialog newItemDialog = newItemDialogBuilder.create();
newItemDialog.show();
// show keyboard
newItemDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
}
});
// add specific listeners only if tablet is not being used
if (!tablet) {
// moving fab out of the way when scrolling listview
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
if (dy > 0) {
// scrolling down
addButton.animate().translationY(addButton.getHeight() * 2);
} else {
// scrolling up
addButton.animate().translationY(0);
}
}
});
}
}
use of android.support.v7.widget.helper.ItemTouchHelper.DOWN 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.DOWN in project QuickReturn by lawloretienne.
the class SpeedyQuickReturnRecyclerViewOnScrollListener method onScrolled.
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
// apply extra on scroll listener
for (RecyclerView.OnScrollListener listener : mExtraOnScrollListeners) {
listener.onScrolled(recyclerView, dx, dy);
}
int scrollY = QuickReturnUtils.getScrollY(recyclerView, mColumnCount);
int diff = mPrevScrollY - scrollY;
if (diff > 0) {
// scrolling up
switch(mQuickReturnViewType) {
case HEADER:
if (mHeader.getVisibility() == View.GONE) {
mHeader.setVisibility(View.VISIBLE);
mHeader.startAnimation(mSlideHeaderDownAnimation);
}
break;
case FOOTER:
if (mFooter.getVisibility() == View.GONE) {
mFooter.setVisibility(View.VISIBLE);
mFooter.startAnimation(mSlideFooterUpAnimation);
}
break;
case BOTH:
if (mHeader.getVisibility() == View.GONE) {
mHeader.setVisibility(View.VISIBLE);
mHeader.startAnimation(mSlideHeaderDownAnimation);
}
if (mFooter.getVisibility() == View.GONE) {
mFooter.setVisibility(View.VISIBLE);
mFooter.startAnimation(mSlideFooterUpAnimation);
}
break;
case GOOGLE_PLUS:
if (mHeaderViews != null) {
for (View view : mHeaderViews) {
if (view.getVisibility() == View.GONE) {
view.setVisibility(View.VISIBLE);
view.startAnimation(mSlideHeaderDownAnimation);
}
}
}
if (mFooterViews != null) {
for (View view : mFooterViews) {
int scrollThreshold = (Integer) view.getTag(R.id.scroll_threshold_key);
if (diff > scrollThreshold) {
if (view.getVisibility() == View.GONE) {
view.setVisibility(View.VISIBLE);
view.startAnimation(mSlideFooterUpAnimation);
}
}
}
}
break;
}
} else if (diff < 0) {
// scrolling down
switch(mQuickReturnViewType) {
case HEADER:
if (mHeader.getVisibility() == View.VISIBLE) {
mHeader.setVisibility(View.GONE);
mHeader.startAnimation(mSlideHeaderUpAnimation);
}
break;
case FOOTER:
if (mFooter.getVisibility() == View.VISIBLE) {
mFooter.setVisibility(View.GONE);
mFooter.startAnimation(mSlideFooterDownAnimation);
}
break;
case BOTH:
if (mHeader.getVisibility() == View.VISIBLE) {
mHeader.setVisibility(View.GONE);
mHeader.startAnimation(mSlideHeaderUpAnimation);
}
if (mFooter.getVisibility() == View.VISIBLE) {
mFooter.setVisibility(View.GONE);
mFooter.startAnimation(mSlideFooterDownAnimation);
}
break;
case GOOGLE_PLUS:
if (mHeaderViews != null) {
for (View view : mHeaderViews) {
if (view.getVisibility() == View.VISIBLE) {
view.setVisibility(View.GONE);
view.startAnimation(mSlideHeaderUpAnimation);
}
}
}
if (mFooterViews != null) {
for (View view : mFooterViews) {
int scrollThreshold = (Integer) view.getTag(R.id.scroll_threshold_key);
if (diff < -scrollThreshold) {
if (view.getVisibility() == View.VISIBLE) {
view.setVisibility(View.GONE);
view.startAnimation(mSlideFooterDownAnimation);
}
}
}
}
break;
}
}
mPrevScrollY = scrollY;
}
Aggregations