Skip to content

Instantly share code, notes, and snippets.

View adennie's full-sized avatar

Andy Dennie adennie

View GitHub Profile
@adennie
adennie / ContextHoldingModules2.java
Created March 19, 2013 19:47
inherited qualified provider not found when checking for completeness of bindings
package com.fizzbuzz.daggerexperiments;
import dagger.Module;
import dagger.Provides;
import javax.inject.Inject;
import javax.inject.Qualifier;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
@adennie
adennie / EllipsizingTextView.java
Created October 11, 2013 15:14
EllipsizingTextView
/*
* Copyright (C) 2011 Micah Hainline
* Copyright (C) 2012 Triposo
* 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
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@adennie
adennie / BaseApplication.java
Created October 22, 2013 20:30
detect first run after install/upgrade
protected void handleNewInstallsAndUpgrades() {
int savedVersion = readVersionCodeFromPref(PREF_TAG_CURRENT_APP_VERSION);
if (savedVersion == -1)
processNewInstall(getVersionCode());
else if (savedVersion != getVersionCode())
processUpgrade(getVersionCode(), readVersionCodeFromPref(PREF_TAG_PREVIOUS_APP_VERSION));
}
protected void processNewInstall(final int newVersionCode) {
updateSavedVersionCodes();
#include "BoundingBox.h"
BoundingBox::BoundingBox(vector<Point> points) :
top_left(points[(0)]), bottom_right(points[1]) {
if (top_left.x > bottom_right.x || top_left.y > bottom_right.y) {
string msg("Invalid points for BoundingBox. Bottom right must have (x,y) >= top right point.");
cerr << msg.c_str() << endl;
throw runtime_error(msg);
}
}