This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ClassPropertyDescriptor(object): | |
def __init__(self, fget, fset=None): | |
self.fget = fget | |
self.fset = fset | |
def __get__(self, obj, klass=None): | |
if klass is None: | |
klass = type(obj) | |
return self.fget.__get__(obj, klass)() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DataViewController: UITableViewController, UISearchResultsUpdating { | |
var data = [Data]() | |
var filteredData = [Data]() | |
@available(iOS 8.0, *) | |
public func updateSearchResults(for searchController: UISearchController) { | |
let query = searchController.searchBar.text! | |
filteredData = data.filter { element in |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DateTimeAwareJSONEncoder(json.JSONEncoder): | |
""" | |
A JSONEncoder subclass for handling objects of types `timedelta`, `datetime` and `date` | |
""" | |
def default(self, obj): | |
if isinstance(obj, datetime): | |
return { | |
'__type__': 'datetime', | |
'year': obj.year, | |
'month': obj.month, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package vmax.myway; | |
import android.animation.LayoutTransition; | |
import android.util.Log; | |
import android.view.View; | |
import android.view.ViewGroup; | |
public class LayoutTransitionLogger implements LayoutTransition.TransitionListener { | |
private String logTAG; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.HashMap; | |
import android.graphics.Color; | |
import android.support.annotation.ColorInt; | |
/** | |
* Class that helps converting Moscow Subway line names (in Russian) to their colors | |
* Based on https://en.wikipedia.org/wiki/Moscow_Metro#Lines | |
*/ | |
public class MoscowSubwayLineUtil { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.Context; | |
import android.support.v7.widget.RecyclerView; | |
import android.util.AttributeSet; | |
import android.view.View; | |
public class EmptyRecyclerView extends RecyclerView { | |
private View emptyView, nonEmptyView; | |
final private AdapterDataObserver observer = new AdapterDataObserver() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.Context; | |
import android.os.Handler; | |
import android.os.Message; | |
import android.util.AttributeSet; | |
import android.view.View; | |
import android.widget.AutoCompleteTextView; | |
import android.widget.ProgressBar; | |
public class DelayAutoCompleteTextView extends AutoCompleteTextView { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ViewWeightAnimationWrapper { | |
private View view; | |
public ViewWeightAnimationWrapper(View view) { | |
if (view.getLayoutParams() instanceof LinearLayout.LayoutParams) { | |
this.view = view; | |
} else { | |
throw new IllegalArgumentException("The view should have LinearLayout as parent"); | |
} | |
} |