Skip to content

Instantly share code, notes, and snippets.

@Override
public void onClick(View v) {
Field f;
int rid;
String name = "unknown View";
try {
f = R.id.class.getDeclaredField(Integer.toString(v.getId()));
rid = f.getInt(f);
name = MainActivity.this.getString(rid);
} catch (Exception e) {
@robbiemu
robbiemu / Angularjs - Selected value row.md
Last active March 30, 2016 01:54
Angularjs - Selected value row

If you don't move the button into the ng-repeat element, there will only be one button for the entire form. Therefore, the user will not be selecting any column or row at the moment they press the button.

One could get around that by changing the prescribed user behavior:

  • First: the user clicks the row/column as per normal
  • Second: the user then clicks the button, which shows the alert.

The button would be:

click

@robbiemu
robbiemu / WindView.java
Created March 24, 2016 18:42
need to refactor this bad boy
package com.example.android.sunshine.app;
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.Typeface;
@robbiemu
robbiemu / WindView.java
Last active April 27, 2016 14:29
a custom view that indicates wind speed and direction
package com.example.android.sunshine.app;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
public static class OldFavoritesEntry {
public static final Uri CONTENT_URI =
BASE_CONTENT_URI.buildUpon().appendPath(PATH_FAVORITES).build();
public static final String CONTENT_TYPE =
ContentResolver.CURSOR_DIR_BASE_TYPE + "/" + CONTENT_AUTHORITY + "/" + PATH_FAVORITES;
public static final String CONTENT_ITEM_TYPE =
ContentResolver.CURSOR_ITEM_BASE_TYPE + "/" + CONTENT_AUTHORITY + "/" + PATH_FAVORITES;
// Table name
FavoritesContract.FavoritesEntry.ContentUris.CONTENT_URI,
new String[] {FavoritesContract.FavoritesEntry.COL_THEMOVIEDBKEY,
FavoritesContract.FavoritesEntry.COL_TITLE,
FavoritesContract.FavoritesEntry.COL_RELEASE_DATE,
FavoritesContract.FavoritesEntry.COL_VOTE_AVERAGE,
FavoritesContract.FavoritesEntry.COL_POSTER_PATH,
FavoritesContract.FavoritesEntry.COL_POSTER_TYPE,
FavoritesContract.FavoritesEntry.COL_BACKDROP_PATH,
FavoritesContract.FavoritesEntry.COL_OVERVIEW },
FavoritesContract.FavoritesEntry.COL_THEMOVIEDBKEY + " = ?",
@Override
public void onResume() {
super.onResume();
PreferenceManager.getDefaultSharedPreferences(getContext())
.registerOnSharedPreferenceChangeListener(this);
}
@Override public void onPause() {
super.onPause();
package xyz.selfenrichment.robertotomas.popularmovies.SQLite;
// Created by RobertoTomás on 0002, 2, 4, 2016.
import android.content.ContentProvider;
import android.content.ContentUris;
import android.content.ContentValues;
import android.content.UriMatcher;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteConstraintException;
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace Solution
{
class Solution
{
static void Main(String[] args)
{