Skip to content

Instantly share code, notes, and snippets.

View AdamMc331's full-sized avatar

Adam McNeilly AdamMc331

View GitHub Profile
@AdamMc331
AdamMc331 / manifest.xml
Created August 26, 2015 02:09
Security Denied
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.app" >
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
package com.adam.cashcaretaker.fragments;
import android.database.Cursor;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.LoaderManager;
import android.support.v4.content.CursorLoader;
import android.support.v4.content.Loader;
import android.view.LayoutInflater;
private void validateCursor(Cursor valueCursor, ContentValues expectedValues){
assertTrue(valueCursor.moveToFirst());
Set<Map.Entry<String, Object>> valueSet = expectedValues.valueSet();
for(Map.Entry<String, Object> entry : valueSet){
String columnName = entry.getKey();
int idx = valueCursor.getColumnIndex(columnName);
assertFalse(idx == -1);
switch(columnName){
// onCreateLoader:
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
switch(id){
case ACCOUNT_LOADER:
return new CursorLoader(
getActivity(),
AccountEntry.buildAccountUri(mAccountID),
new String[]{
AccountEntry.TABLE_NAME + "." + AccountEntry._ID,
public void test_getFormattedCurrency(){
// Test double without decimal points
assertEquals("$100.00", Utility.getFormattedCurrency(100));
// Test with one decimal point
assertEquals("$100.00", Utility.getFormattedCurrency(100.0));
// Test with two decimal points
assertEquals("$100.00", Utility.getFormattedCurrency(100.00));
public static String getUIDateString(LocalDate d){
// Do not allow dates with negative years
if(d.getYear() < 0){
throw new UnsupportedOperationException("LocalDate has negative year value.");
} else {
DateTimeFormatter dtf = DateTimeFormat.forPattern(UI_DATE_FORMAT);
return dtf.print(d);
}
}
public class HttpExampleActivity extends Activity {
private static final String DEBUG_TAG = "HttpExample";
private EditText urlText;
private TextView textView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout_main);
urlText = (EditText) findViewById(R.id.myUrl);
public class HttpExampleActivity extends Activity {
private static final String DEBUG_TAG = "HttpExample";
private EditText urlText;
private TextView textView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout_main);
urlText = (EditText) findViewById(R.id.myUrl);
final ListView mTransactionListView = (ListView) view.findViewById(R.id.transactionListView);
// Set header view
mAccountBalanceHeader = (TextView) inflater.inflate(R.layout.account_balance_header, container, false);
mTransactionListView.setHeaderDividersEnabled(true);
mTransactionListView.addHeaderView(mAccountBalanceHeader);
// Set adapter
mTransactionListView.setAdapter(mTransactionAdapter);
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<Button
android:id="@+id/wide_button"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>