Skip to content

Instantly share code, notes, and snippets.

yes you can
AppBarLayout appBar;
appBar.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
if(verticalOffset > -300) {
collapsedAppBar.setTitleEnabled(false);
}
else {
@danielmai
danielmai / ForecastListToDetailTest.java
Created December 18, 2015 23:22
Espresso test for Sunshine. Demo for the Android Testing webcast in the Android Developer Nanodegree.
package com.example.android.sunshine.app.ui;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.LargeTest;
import com.example.android.sunshine.app.MainActivity;
import com.example.android.sunshine.app.R;
import org.junit.Rule;
@keyboardsurfer
keyboardsurfer / studio64.vmoptions
Created January 26, 2015 10:02
My vmoptions for android studio
-Xms1G
-Xmx8G
-XX:MaxPermSize=4G
-XX:ReservedCodeCacheSize=512m
-ea
-Dsun.io.useCanonCaches=false
-Djava.net.preferIPv4Stack=true
-Djna.nosys=true
-Djna.boot.library.path=
package ru.mobileup.grushasdk.utils;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.Network;
import android.net.NetworkInfo;
import android.net.wifi.WifiManager;
/**
* @author Vasili Chyrvon (vasili.chyrvon@gmail.com)
@geniushkg
geniushkg / filter category in result retrofit list
Created September 27, 2016 05:03
sample gist to filter content from retrofit response
// this is retrofit response
Eventlist eventlist = response.body();
List<Website> websites = eventlist.getWebsites(); // website is POJO class for even as per api
List<Website> filteredWebsite = new ArrayList<Website>(); // empty list new
for(Website temp:websites){
if(temp.getCategory().equalsIgnoreCase(sortType.name())){
filteredWebsite.add(temp); // sortType.name() is BOT or Competitive or whichever selected
}
}
public class DelayAutoCompleteTextView extends AutoCompleteTextView {
private static final int MESSAGE_TEXT_CHANGED = 100;
private static final int DEFAULT_AUTOCOMPLETE_DELAY = 1000;
private int mAutoCompleteDelay = DEFAULT_AUTOCOMPLETE_DELAY;
private static class AvoidingMemoryLeakHandler extends Handler {
private final WeakReference<DelayAutoCompleteTextView> delayAutoCompleteTextViewWeakReference;
anonymous
anonymous / TestDb.java
Created August 21, 2014 07:40
// Use this in your testLocationTable() method
// Test data we're going to insert into the DB to see if it works.
String testLocationSetting = "99705";
String testCityName = "North Pole";
double testLatitude = 64.7488;
double testLongitude = -147.353;
@M-Medhat
M-Medhat / RegExReplace.swift
Created February 2, 2015 09:33
Regular Expressions: How to replace patterns in Swift
// You need to import Foundation to use NSRegularExpression, NSError and NSString
import Foundation
/// This function takes three parameters
/// text: a string that we search in
/// pattern: a reqular expression pattern to use in the search
/// withTemplate: the string that we use instead of the occurrances we find in text
///
/// The method returns (text) with occurrance found using (pattern) replaced with (withTemplate)
func regexReplace(text:String, pattern:String, withTemplate:String) -> String {
@cyrilmottier
cyrilmottier / _app_avelibRelease_res_values_config.xml
Last active November 20, 2020 11:27
Using the new Gradle-based Android build system: an example
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="config_app_name">AVélib</string>
<string name="config_authority">com.cyrilmottier.android.avelib.citybikes</string>
<string name="config_com.google.android.maps.v2.api_key">XXX</string>
</resources>
@tarrsalah
tarrsalah / SimpleListView.java
Last active August 15, 2021 17:05
Simple Editable javafx ListView.
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.ListView;