Skip to content

Instantly share code, notes, and snippets.

View Frederikos's full-sized avatar

Glebov Sergey Frederikos

View GitHub Profile
@Frederikos
Frederikos / BitmapFromViewHelper.java
Last active January 10, 2023 10:58
Get Bitmap from Layout view
public class BitmapFromViewHelper {
public static Bitmap getImageFromLayout(Context context, @LayoutRes int viewLayout, int width, int height) {
View layoutTemplate = LayoutInflater.from(context).inflate(viewLayout, null);
int widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(width, View.MeasureSpec.EXACTLY);
int heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(height, View.MeasureSpec.EXACTLY);
return getBitmapFromView(layoutTemplate, widthMeasureSpec, heightMeasureSpec);
}
@Frederikos
Frederikos / SquareImageView.java
Created March 12, 2016 15:24 — forked from blork/SquareImageView.java
Android imageview subclass which maintains a square aspect ratio.
import android.content.Context;
import android.util.AttributeSet;
import android.widget.ImageView;
public class SquareImageView extends ImageView {
public SquareImageView(Context context) {
super(context);
}
public class AppRater {
private static final String PREF_NAME = "AppRater";
private static final String KEY_SHOW_APP_RATE = "show_app_rate";
private static final String KEY_SHOW_LATER_COUNTER = "show_later_counter";
private static final long SHOW_APP_RATE_INTERVAL = 1000 * 60 * 60 * 24 * 2;
public static void appLaunched(Context context) {
public abstract class Callback<T> implements retrofit2.Callback<T> {
private WeakReference<Activity> activityReference;
private ObservableField<Boolean> isDataLoading;
public Callback(Activity activity, ObservableField<Boolean> isDataLoading) {
this.activityReference = new WeakReference<>(activity);
this.isDataLoading = isDataLoading;
if (isDataLoading != null) {
isDataLoading.set(true);
[
{
"QuestionId": "WhatDoYouLikeSending",
"SequenceType": "Question",
"Label": [
{
"en": "What do you like sending?"
},
{
"fr": "Qu'aimez-vous envoyer ?"
@Frederikos
Frederikos / triggers.json
Last active February 28, 2017 12:42
triggers
[
{
"EventId": "MorningMessage",
"Action": "ShowAskHuggyMorningMessage",
"TriggersRule": "AllTriggersPassed",
"Triggers": [
{
"TriggerId": "TriggerByTimePeriod",
"TriggerType": "TimePeriod",
"TimeFrom": 8,
[
{
"CommandId": "MessagesForSweetheart",
"Action": "MessagesByRecipient",
"TargetType": "9E2D23",
"TargetId": "SweetheartF",
"ImageName": "iStock_000008350300_Medium.jpg",
"Label": [
{
"en": "Messages my sweetheart"
[
{
"QuestionId": "IsOftenLate",
"Label": [
{
"en": "Are you often late?"
},
{
"fr": "Es-tu souvent en retard?"
},
android {
dataBinding {
enabled = true
}
}
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<!-- Variables and imports goes here -->
</data>
<!-- Your layout goes here -->
</layout>