Skip to content

Instantly share code, notes, and snippets.

View ssaurel's full-sized avatar

Sylvain Saurel ssaurel

View GitHub Profile
@ssaurel
ssaurel / activity_main.xml
Created April 30, 2017 15:51
Main Activity of the Audio Streaming Tutorial for the SSaurel's Channel
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
@ssaurel
ssaurel / MainActivity.java
Created April 30, 2017 15:52
Main Activity of the Audio Streaming Tutorial for the SSaurel's Channel
package com.ssaurel.audiostreaming;
import android.app.ProgressDialog;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
@ssaurel
ssaurel / RotaryDialerView.java
Created May 11, 2017 07:32
Rotary Dialer View for a tutorial on the SSaurel's Blog
public class RotaryDialerView extends View {
private final Drawable rotorDrawable;
public RotaryDialerView(Context context) {
this(context, null);
}
public RotaryDialerView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
@ssaurel
ssaurel / main.xml
Created May 11, 2017 07:33
Layout for the Rotary Dialer tutorial on the SSaurel's Blog
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<View
@ssaurel
ssaurel / RotaryDialerView.java
Created May 11, 2017 07:38
RotaryDialerView with animation for a tutorial on the SSaurel's Blog
public class RotaryDialerView extends View {
private float rotorAngle;
private final Drawable rotorDrawable;
private final int r1 = 50;
private final int r2 = 160;
private double lastFi;
public RotaryDialerView(Context context) {
this(context, null);
}
@ssaurel
ssaurel / main.xml
Created May 11, 2017 07:40
Main layout for the Rotary Dialer App Tutorial on the SSaurel's Blog
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<LinearLayout
@ssaurel
ssaurel / DialListener.java
Created May 11, 2017 07:42
DialListener to add to RotaryDialerView for a tutorial on the SSaurel's Blog
public interface DialListener {
void onDial(int number);
}
private final List<DialListener> dialListeners = new ArrayList<DialListener>();
// ...
public void addDialListener(DialListener listener) {
dialListeners.add(listener);
}
@ssaurel
ssaurel / RotaryDialer.java
Created May 11, 2017 07:47
Main Activity of the Rotary Dialer App tutorial on the SSaurel's Blog
public class RotaryDialer extends Activity {
private EditText digits;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
RotaryDialerView rotaryDialerView = (RotaryDialerView) findViewById(R.id.rotary_dialer);
digits = (EditText) findViewById(R.id.digits);
@ssaurel
ssaurel / Thermometer.java
Created May 18, 2017 10:42
Thermometer view implementation for a tutorial on the SSaurel's Channel
package com.ssaurel.mythermometer;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.RectF;
import android.util.AttributeSet;
@ssaurel
ssaurel / attrs.xml
Created May 18, 2017 10:50
Specific Attributes for the Thermometer View
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="Thermometer">
<attr name="radius" format="dimension" />
<attr name="outerColor" format="color" />
<attr name="middleColor" format="color" />
<attr name="innerColor" format="color" />
</declare-styleable>