Skip to content

Instantly share code, notes, and snippets.

View swanhtet1992's full-sized avatar
🪶
Studying programming again!

Swan Htet Aung swanhtet1992

🪶
Studying programming again!
View GitHub Profile
@swanhtet1992
swanhtet1992 / SimpleUiTest.java
Last active August 29, 2015 14:20
Simple UI test class to demonstrate screenshot automation
public class SimpleUiTest extends InstrumentationTestCase {
private UiDevice mDevice;
private String PACKAGE_NAME = "co.example.uitest";
public void setUp() {
// Initialize UiDevice instance
mDevice = UiDevice.getInstance(getInstrumentation());
// Let's start from Home
mDevice.pressHome();
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 The Android Open Source Project
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

You can use this class to realize a simple sectioned RecyclerView.Adapter without changing your code.

The RecyclerView should use a LinearLayoutManager. You can use this code also with the TwoWayView with the ListLayoutManager (https://github.com/lucasr/twoway-view)

This is a porting of the class SimpleSectionedListAdapter provided by Google

Screen

Example:

You can use this class to realize a simple sectioned grid RecyclerView.Adapter without changing your code.

Screen

The RecyclerView has to use a GridLayoutManager.

This is a porting of the class SimpleSectionedListAdapter provided by Google

If you are looking for a sectioned list RecyclerView.Adapter you can take a look here

/*
* Copyright 2014 Chris Banes
*
* 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
@swanhtet1992
swanhtet1992 / quiz.scala
Last active August 29, 2015 14:11
Solution for λ Talks in Yangon registration quiz
def multiply(x: Double, n: Double): Double = {
if (n == 0) 0 else x + multiply(x, n - 1)
}
def power(b: Int, e: Int): Double = {
if (e > 0) multiply(b.toDouble, power(b, e - 1))
else if (e < 0) 1/power(b, -e) // let me use / for negative e :P
else 1.0
}
dependencies {
compile 'com.android.support:appcompat-v7:21.+'
compile 'com.wrapp.floatlabelededittext:library:0.0.5'
}
#! /usr/bin/env python2
import cv2
import numpy as np
from collections import deque
orig_image = None
gray_image = None
threshold_image = None
edge_image = None
/* The date/time conversion code is going to be moved outside the asynctask later,
* so for convenience we're breaking it out into its own method now.
*/
private String getReadableDateString(long time){
// Because the API returns a unix timestamp (measured in seconds),
// it must be converted to milliseconds in order to be converted to valid date.
Date date = new Date(time * 1000);
SimpleDateFormat format = new SimpleDateFormat("E, MMM d");
return format.format(date).toString();
}
// 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 {