Skip to content

Instantly share code, notes, and snippets.

View chrisbanes's full-sized avatar

Chris Banes chrisbanes

View GitHub Profile
@chrisbanes
chrisbanes / PullToRefreshListFragment.java
Created May 15, 2012 14:32
PullToRefreshListFragment
import com.handmark.pulltorefresh.library.PullToRefreshListView;
import android.os.Bundle;
import android.support.v4.app.ListFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
public class PullToRefreshListFragment extends ListFragment {
@chrisbanes
chrisbanes / gist:3834527
Created October 4, 2012 15:49
Fail-safe way of getting first visible child
final int listViewTopPadding = mListView.getPaddingTop();
for (int i = 0, z = mListView.getChildCount(); i < z; i++) {
View child = mListView.getChildAt(i);
if (child.getTop() > (listViewTopPadding - child.getHeight()) && child.getTop() <= listViewTopPadding) {
// Bingo, we have our first visible child...
}
}
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
import android.util.AttributeSet;
import android.widget.ImageView;
public class OptimisedImageView extends ImageView {
private boolean mIgnoreNextRequestLayout = false;
@chrisbanes
chrisbanes / gist:5004907
Last active January 24, 2021 01:13
Blocking ListView
import android.content.Context;
import android.util.AttributeSet;
import android.widget.ListView;
public class BlockingListView extends ListView {
private boolean mBlockLayoutChildren;
public BlockingListView(Context context) {
super(context);
package com.example.checkableviews;
/*******************************************************************************
* Copyright 2013 Chris Banes.
*
* 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
DecorChildLayout(Context context, ViewGroup systemDecorView, View headerView) {
super(context);
// Move all children from decor view to here
for (int i = 0, z = systemDecorView.getChildCount() ; i < z ; i++) {
View child = systemDecorView.getChildAt(i);
systemDecorView.removeView(child);
addView(child);
}
STORE_FILE=/path/to/your.keystore
STORE_PASSWORD=yourkeystorepass
KEY_ALIAS=projectkeyalias
KEY_PASSWORD=keyaliaspassword
@chrisbanes
chrisbanes / ForegroundLinearLayout.java
Created February 19, 2014 13:16
ForegroundLinearLayout
/*
* Copyright (C) 2006 The Android Open Source Project
*
* 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
@chrisbanes
chrisbanes / FloatLabelLayout.java
Last active March 15, 2024 06:39
FloatLabelLayout
/*
* Copyright 2014 Chris Banes
*
* 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
@chrisbanes
chrisbanes / SystemUiHelper.java
Last active March 2, 2024 18:57
SystemUiHelper
/*
* Copyright (C) 2014 The Android Open Source Project
*
* 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