Skip to content

Instantly share code, notes, and snippets.

View AdamMc331's full-sized avatar

Adam McNeilly AdamMc331

View GitHub Profile
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"/>
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Get the top text view
TextView top = (TextView) findViewById(R.id.top_text_view);
// Get the bottom text view
TextView bottom = (TextView) findViewById(R.id.bottom_text_view);
}
@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"