inspired by https://www.intercom.com/
tried to add a floating chat button for support
A Pen by neil kalman on CodePen.
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| import android.support.v7.widget.RecyclerView; | |
| public class RecyclerViewSwipeListener extends RecyclerView.OnFlingListener { | |
| private static final int SWIPE_VELOCITY_THRESHOLD = 2000; | |
| boolean mIsScrollingVertically; | |
| // change swipe listener depending on whether we are scanning items horizontally or vertically | |
| RecyclerViewSwipeListener(boolean vertical) { |
| /* | |
| * Copyright 2016 Google Inc. | |
| * | |
| * Licensed under the Apache License, Version 2.0 (the "License"); | |
| * you may not use this file except in compliance with the License. | |
| * You may obtain a copy of the License at | |
| * | |
| * http://www.apache.org/licenses/LICENSE-2.0 | |
| * | |
| * Unless required by applicable law or agreed to in writing, software |
| import rx.Observable; | |
| import rx.Subscriber; | |
| import rx.Subscription; | |
| import rx.functions.Action0; | |
| import rx.subjects.PublishSubject; | |
| import rx.subjects.SerializedSubject; | |
| /** | |
| * An object reference of EventBus |
| /** | |
| * Check if the application is in the foreground or background. | |
| * * | |
| * Register this callbacks for an application | |
| * Application application = (Application) context.getApplicationContext(); | |
| * application.registerActivityLifecycleCallbacks(new BaseLifeCycleCallbacks()); | |
| * * | |
| * Note: These callbacks can be registered at any level of the application lifecycle. | |
| * Previous methods to get the application lifecycle forced the lifecycle callbacks to be registered |
| /** | |
| * Custom Scroll listener for RecyclerView. | |
| * Based on implementation https://gist.github.com/ssinss/e06f12ef66c51252563e | |
| */ | |
| public abstract class EndlessRecyclerOnScrollListener extends RecyclerView.OnScrollListener { | |
| public static String TAG = "EndlessScrollListener"; | |
| private int previousTotal = 0; // The total number of items in the dataset after the last load | |
| private boolean loading = true; // True if we are still waiting for the last set of data to load. | |
| private int visibleThreshold = 5; // The minimum amount of items to have below your current scroll position before loading more. |
| private String getWifiIp() throws SocketException { | |
| for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); | |
| en.hasMoreElements(); ) { | |
| NetworkInterface intf = en.nextElement(); | |
| if (intf.isLoopback()) { | |
| continue; | |
| } | |
| if (intf.isVirtual()) { | |
| continue; | |
| } |
| /** | |
| * Uses a combination of a PageTransformer and swapping X & Y coordinates | |
| * of touch events to create the illusion of a vertically scrolling ViewPager. | |
| * | |
| * Requires API 11+ | |
| * | |
| */ | |
| public class VerticalViewPager extends ViewPager { | |
| public VerticalViewPager(Context context) { |
| // 웹페이지 띄우기 | |
| Uri uri = Uri.parse("http://www.google.com"); | |
| Intent it = new Intent(Intent.ACTION_VIEW,uri); | |
| startActivity(it); | |
| // 구글맵 띄우기 | |
| Uri uri = Uri.parse("geo:38.899533,-77.036476"); | |
| Intent it = new Intent(Intent.Action_VIEW,uri); | |
| startActivity(it); |