Skip to content

Instantly share code, notes, and snippets.

View prashantwosti's full-sized avatar
🏠
WFH

Prashant Wosti prashantwosti

🏠
WFH
View GitHub Profile
@ckurtm
ckurtm / TintActivity.java
Created October 29, 2015 08:20
Dynamically change color of a drawable using TintDrawables
package com.peirra.tint;
import android.graphics.Color;
import android.support.v4.graphics.drawable.DrawableCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import java.util.Random;
@bacbos
bacbos / _worldcup2014.md
Last active January 2, 2016 00:48
FIFA Worldcup 2014 Brazil mySQL and JSON dumps, includes data for all participating teams, venues and matches

FIFA Worldcup 2014 Brazil mySQL and JSON dumps, includes data for all participating teams, venues and matches.

Note that match contains a parameter stage:

0 => Group games

8 => Round of 16

4 => Quarter-Finals

public class MyFragment {
boolean loaded;
private void maybeLoad() {
if (!loaded && getUserVisibleHint()) {
loaded = true;
loadMyData();
}
}
@Override
@rock3r
rock3r / prepareassets.sh
Last active April 28, 2017 23:43
Move/rename *-{m|h|xh|xxh|xxxh}dpi.png" assets into proper folder structure, ready for copypasta
#!/bin/bash
# License for any modification to the original (linked below):
# ----------------------------------------------------------------------------
# "THE BEER-WARE LICENSE" (Revision 42):
# Sebastiano Poggi wrote this file. As long as you retain this notice you
# can do whatever you want with this stuff. If we meet some day, and you think
# this stuff is worth it, you can buy me a beer in return.
# ----------------------------------------------------------------------------
prefix=${1-"drawable"}
buckets=( mdpi hdpi xhdpi xxhdpi xxxhdpi )
@pcqpcq
pcqpcq / shadow.xml
Created August 23, 2016 07:12 — forked from lecho/shadow.xml
Android shadow drawable xml.
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- Drop Shadow Stack -->
<item>
<shape>
<padding
android:bottom="1dp"
android:left="1dp"
android:right="1dp"
@li2
li2 / CenteredImageSpan.java
Last active March 20, 2018 06:46
使 ImageSpan 和 text 居中对齐 & 高度一致。ImageSpan 有一个构造器接收 drawable,所以可以根据 TextView 高度,设置 drawable.setBounds(0, 0, height, height),因此 CenteredImageSpan 也就没必要了。 #tags: android-view
// From http://stackoverflow.com/questions/25628258/align-text-around-imagespan-center-vertical
public class CenteredImageSpan extends ImageSpan {
// Extra variables used to redefine the Font Metrics when an ImageSpan is added
private int initialDescent = 0;
private int extraSpace = 0;
public CenteredImageSpan(final Drawable drawable) {
this(drawable, entry, DynamicDrawableSpan.ALIGN_BOTTOM);
@alapshin
alapshin / ProxyBottomSheetBehavior.java
Created March 18, 2017 15:00
BottomSheetBehavior with support for multiple callbacks
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.design.widget.BottomSheetBehavior;
import android.util.AttributeSet;
import android.view.View;
import java.util.ArrayList;
/**
* Wrapper around {@link BottomSheetBehavior} with support for multiple callbacks.
@Dantali0n
Dantali0n / Android ScanResult frequency to channel converter
Created October 20, 2015 23:41
Converts android wireless frequency numbers to their appriopiate wifi channel number, works for 2.4ghz and 5ghz channels
String frequencyToChannel(String frequency) {
switch(frequency) {
case "2412" :
return "ch 1 - 2.4ghz";
case "2417" :
return "ch 2 - 2.4ghz";
case "2422" :
return "ch 3 - 2.4ghz";
case "2427" :
return "ch 4 - 2.4ghz";
@niqdev
niqdev / rename-branch-github.txt
Last active January 15, 2020 18:17
Rename local and remote branch on GitHub
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
open class BaseRepository{
suspend fun <T : Any> safeApiCall(call: suspend () -> Response<T>, errorMessage: String): T? {
val result : Result<T> = safeApiResult(call,errorMessage)
var data : T? = null
when(result) {
is Result.Success ->
data = result.data