Skip to content

Instantly share code, notes, and snippets.

Intent galleryIntent = new Intent(Intent.ACTION_GET_CONTENT,null);
galleryIntent.setType("image/*");
galleryIntent.addCategory(Intent.CATEGORY_OPENABLE);
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
Intent chooser = new Intent(Intent.ACTION_CHOOSER);
chooser.putExtra(Intent.EXTRA_INTENT, galleryIntent);
chooser.putExtra(Intent.EXTRA_TITLE, "title");
@gordinmitya
gordinmitya / FontTabLayout.java
Created May 24, 2017 12:08 — forked from tmtrademarked/FontTabLayout.java
SImple wrapper class to support fonts in TabLayout
public class FontTabLayout extends TabLayout {
private Typeface typeface;
public FontTabLayout(Context context) {
super(context);
init(context, null);
}
public FontTabLayout(Context context, AttributeSet attrs) {
LayoutInflater factory = LayoutInflater.from(this); // this это context
// final - для того чтобы использовать его в OnClickListener()
final View alertView = factory.inflate(R.layout.layout_add_note, null);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setView(alertView);
builder.setTitle(R.string.alert_title_add);
builder.setNegativeButton(R.string.alert_cancel, null);
builder.setPositiveButton(R.string.menu_add, new DialogInterface.OnClickListener() {
@Override
@gordinmitya
gordinmitya / MainActivity.java
Last active February 3, 2017 09:02
Пример безопасной работы с потоками
// GameManager.java
public class GameManager {
private GameManager() {}
public static create(){
GameManager gm = new GameManager();
gm. // инициализируем созданием нового
return gm;
}
public static createFromStream(InputStream stream){
GameManager gm = new GameManager();
@gordinmitya
gordinmitya / EndlessList.kt
Created January 30, 2017 14:54
Бесконечный скролл RxKotlin Android
class EndlessList {
companion object {
fun <T> get(recyclerView: RecyclerView, next: (Int) -> Observable<Response<T>>): Observable<Response<T>> {
var loading = false
var hasNextPage = true
return Observable.create<Int> {
val lm = recyclerView.layoutManager
val getLastVisible = if (lm is LinearLayoutManager) {
fun() = lm.findLastVisibleItemPosition()
} else if (lm is GridLayoutManager) {
@gordinmitya
gordinmitya / wtf.js
Last active December 11, 2016 17:19
<!DOCTYPE html>
<html>
<head></head>
<body>
<div id="task1">
<input id="t0" type="number" value="18.5"/>
</div>
<div id="task2">
<input id="t0" type="number" value="18.5"/>
</div>
import random
import math
from datetime import datetime
def eco_pov(a, d, p):
res = a % p
d -= 1
while d > 0:
res *= a
res %= p
<?php
namespace Models\v2;
abstract class EventSubject extends \Models\EventSubject {
public static function schedule($id) {
$res = parent::schedule($id);
for ($w=0; $w<count($res); ++$w) {
for ($d=0; $d<count($res[$w]['days']); ++$d) {
for ($e=0; $e<count($res[$w]['days'][$d]['events']); ++$e) {
<?php
namespace Models;
class Group extends EventSubject
{
public static function subjectName() {
return 'group';
}
public static function reverseName() {
<?php
namespace Models;
abstract class EventSubject {
public static abstract function subjectName();
public static function reverseName(){}
/*public static function subjectId() {