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 com.jakewharton.utilities; | |
import android.content.Context; | |
import android.graphics.drawable.Drawable; | |
import android.preference.CheckBoxPreference; | |
import android.util.AttributeSet; | |
import android.view.View; | |
import android.widget.ImageView; | |
import com.jakewharton.wakkawallpaper.R; |
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 TweetAdapter extends BaseAdapter { | |
// ... | |
public View getView(int position, View convertView, ViewGroup parent) { | |
TweetViewHolder vh = TweetViewHolder.get(convertView, parent); | |
Tweet item = getItem(position); | |
vh.user.setText(item.user); | |
vh.tweet.setText(item.tweet); |
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
/* Base fragment to ensure the parent activity implements a contract interface. */ | |
public abstract class ContractFragment<T> extends Fragment { | |
private T mContract; | |
@Override | |
public void onAttach(Activity activity) { | |
try { | |
mContract = (T)activity; | |
} catch (ClassCastException e) { | |
throw new IllegalStateException(activity.getClass().getSimpleName() |
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 CheckableFrameLayout extends FrameLayout implements Checkable { | |
private static final int[] CHECKED_STATE_SET = { | |
android.R.attr.state_activated, | |
android.R.attr.state_checked, | |
}; | |
private boolean mChecked; | |
public CheckableFrameLayout(Context context) { | |
super(context); |
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
// Copyright 2012 Square, Inc. | |
package com.squareup.widgets; | |
import android.content.Context; | |
import android.content.res.TypedArray; | |
import android.util.AttributeSet; | |
import android.widget.ImageView; | |
/** Maintains an aspect ratio based on either width or height. Disabled by default. */ | |
public class AspectRatioImageView extends ImageView { |
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 com.squareup.widgets; | |
import android.content.Context; | |
import android.util.AttributeSet; | |
import android.view.View; | |
import android.widget.ViewAnimator; | |
/** ViewAnimator helper which allows setting the selected child by ID rather than index. */ | |
public class SquareViewAnimator extends ViewAnimator { | |
public SquareViewAnimator(Context context) { |
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
/** | |
* Execute an {@link AsyncTask} on a thread pool. | |
* | |
* @param task Task to execute. | |
* @param args Optional arguments to pass to {@link AsyncTask#execute(Object[])}. | |
* @param <T> Task argument type. | |
*/ | |
public static <T> void execute(AsyncTask<T, ?, ?> task, T... args) { | |
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.DONUT) { | |
throw new UnsupportedOperationException("This class can only be used on API 4 and newer."); |
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
// Apache 2.0 licensed. | |
import android.content.Context; | |
import android.view.LayoutInflater; | |
import android.view.View; | |
import android.view.ViewGroup; | |
import android.widget.BaseAdapter; | |
/** An implementation of {@link BaseAdapter} which uses the new/bind pattern for its views. */ | |
public abstract class BindableAdapter<T> extends BaseAdapter { |
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.view.View; | |
import android.view.ViewGroup; | |
/** | |
* A {@link ViewGroup.OnHierarchyChangeListener hierarchy change listener} which recursively | |
* monitors an entire tree of views. | |
*/ | |
public final class HierarchyTreeChangeListener implements ViewGroup.OnHierarchyChangeListener { | |
/** | |
* Wrap a regular {@link ViewGroup.OnHierarchyChangeListener hierarchy change listener} with one |
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
/* | |
* Copyright 2014 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 |
OlderNewer