It is a simple gist to realize the UI ANIMATION IN PHOTOSHOP – TUTORIAL #1 provided by Taylor Ling .
Due to shadow and Z-animation, this code can work only on L-devices.
| import android.support.v7.widget.LinearLayoutManager; | |
| import android.support.v7.widget.RecyclerView; | |
| public abstract class EndlessRecyclerOnScrollListener extends RecyclerView.OnScrollListener { | |
| public static String TAG = EndlessRecyclerOnScrollListener.class.getSimpleName(); | |
| 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. | |
| int firstVisibleItem, visibleItemCount, totalItemCount; |
| func timeAgoSinceDate(date:NSDate, numericDates:Bool) -> String { | |
| let calendar = NSCalendar.currentCalendar() | |
| let unitFlags = NSCalendarUnit.CalendarUnitMinute | NSCalendarUnit.CalendarUnitHour | NSCalendarUnit.CalendarUnitDay | NSCalendarUnit.CalendarUnitWeekOfYear | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitYear | NSCalendarUnit.CalendarUnitSecond | |
| let now = NSDate() | |
| let earliest = now.earlierDate(date) | |
| let latest = (earliest == now) ? date : now | |
| let components:NSDateComponents = calendar.components(unitFlags, fromDate: earliest, toDate: latest, options: nil) | |
| if (components.year >= 2) { | |
| return "\(components.year) years ago" |
| dependencies { | |
| compile 'com.android.support:appcompat-v7:21.+' | |
| compile 'com.wrapp.floatlabelededittext:library:0.0.5' | |
| } |
| ImageView imageView = (ImageView) findViewById(R.id.card_thumbnail_image); | |
| Bitmap mBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.rose); | |
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){ | |
| //Default | |
| imageView.setBackgroundResource(R.drawable.rose); | |
| } else { | |
| //RoundCorners | |
| RoundCornersDrawable round = new RoundCornersDrawable(mBitmap, | |
| getResources().getDimension(R.dimen.cardview_default_radius), 0); //or your custom radius |
| public class HelperUtil { | |
| private final HelperUtilImpl mImpl; | |
| public HelperUtil (Context context) { | |
| if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) { | |
| mImpl = new HelperUtilImplL(context); | |
| } else if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) { | |
| mImpl = new HelperUtilImplKK(context); |
| public class HelperUtil { | |
| public static HelperUtilBase getInstance(Context context) { | |
| if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) { | |
| return new HelperUtilL(context); | |
| } else if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) { | |
| return new HelperUtilKK(context); | |
| } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { | |
| return new HelperUtilJB(context); |
It is a simple gist to realize the UI ANIMATION IN PHOTOSHOP – TUTORIAL #1 provided by Taylor Ling .
Due to shadow and Z-animation, this code can work only on L-devices.
You can use this class to realize a simple sectioned RecyclerView.Adapter without changing your code.
The RecyclerView should use a LinearLayoutManager.
You can use this code also with the TwoWayView with the ListLayoutManager (https://github.com/lucasr/twoway-view)
This is a porting of the class SimpleSectionedListAdapter provided by Google
Example:
| ItemClickSupport itemClick = ItemClickSupport.addTo(recyclerView); | |
| itemclick.setOnItemClickListener(new OnItemClickListener() { | |
| @Override | |
| public void onItemClick(RecyclerView p, View c, int pos, long id) { | |
| ... | |
| } | |
| }); | |
| itemClick.setOnItemLongClickListener(new OnItemLongClickListener() { |
| import android.content.Context; | |
| import android.content.res.TypedArray; | |
| import android.graphics.Canvas; | |
| import android.graphics.drawable.Drawable; | |
| import android.util.AttributeSet; | |
| import android.widget.ImageView; | |
| public class ForegroundImageView extends ImageView { | |
| private Drawable foreground; |