This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.Context | |
import java.io.File | |
import java.io.FileOutputStream | |
import java.io.PrintWriter | |
import java.io.StringWriter | |
fun Context.logToFile(str: String, filename: String = "LOG.txt") { | |
val file = File("$filesDir${File.separator}$filename") | |
if (!file.exists()) file.createNewFile() | |
FileOutputStream(file, true).bufferedWriter().use { out -> out.appendLine(str) } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Выводит в лог удобочитаемое представление AttributeSet'а | |
*/ | |
fun AttributeSet.dump(ctx: Context) { | |
Log.i("AttributeSetDump", "For element at $positionDescription") | |
for (i in 0 until attributeCount) { | |
val attrName = this.getAttributeName(i) ?: "null" | |
var attrValue = this.getAttributeValue(i) ?: "null" | |
if (attrValue.startsWith("@")) { | |
attrValue = ctx.resources.getResourceEntryName(attrValue.substring(1).toInt()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class AndroidFieldNamingPolicy implements FieldNamingStrategy { | |
private static final String JSON_WORD_DELIMITER = "_"; | |
@Override | |
public String translateName(final Field f) { | |
if (f.getName().startsWith("m")) { | |
return handleWords(f.getName().substring(1)); | |
} | |
else { | |
throw new IllegalArgumentException("Don't know how to handle field not starting with m prefix: " + f.getName()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ru.rarescrap.simpleweightsystem; | |
import cpw.mods.fml.common.eventhandler.SubscribeEvent; | |
import net.minecraft.entity.Entity; | |
import net.minecraft.entity.item.EntityItem; | |
import net.minecraft.entity.player.EntityPlayer; | |
import net.minecraft.entity.player.EntityPlayerMP; | |
import net.minecraft.inventory.*; | |
import net.minecraft.item.Item; | |
import net.minecraft.world.World; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package javaapplication16; | |
import java.util.ArrayList; | |
import java.util.Arrays; | |
import java.util.Collections; | |
import java.util.Iterator; | |
import java.util.List; | |
import javafx.print.Collation; | |
/** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright (C) 2014 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 | |
* | |
* Unless required by applicable law or agreed to in writing, software |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Отвечает за скорость "задвигания" элеметов, закрывающих пустоту после удаления элемета из середины | |
// recyclerView.getItemAnimator().setMoveDuration(6000); | |
// int d = recyclerView.getItemAnimator().getMoveDuration(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.webtrust.tennosushi.adapters; | |
import android.graphics.Bitmap; | |
import android.graphics.BitmapFactory; | |
import android.os.AsyncTask; | |
import android.support.v7.widget.RecyclerView; | |
import android.view.LayoutInflater; | |
import android.view.View; | |
import android.view.ViewGroup; | |
import android.widget.ImageView; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:tools="http://schemas.android.com/tools" | |
xmlns:myapp="http://schemas.android.com/apk/res-auto" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:orientation="vertical" | |
tools:context=".MainActivity"> | |
<fragment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Клавиатура закрывается при касании кнопки FAB | |
private void dismissKeyboard(View view) { | |
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); | |
imm.hideSoftInputFromWindow(view.getWindowToken(), 0); | |
} |
NewerOlder