Skip to content

Instantly share code, notes, and snippets.

View VladSumtsov's full-sized avatar

Vladyslav Sumtsov VladSumtsov

View GitHub Profile
@VladSumtsov
VladSumtsov / ScreenPagerStateAdapter.java
Created July 20, 2016 19:06
Flow mortar ViewPager Adapter with save state. Logic of saving state took from FragmentStatePagerAdapter.
package com.ghm.ui.adapter;
import android.content.Context;
import android.os.Bundle;
import android.os.Parcelable;
import android.support.v4.view.PagerAdapter;
import android.util.SparseArray;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@VladSumtsov
VladSumtsov / ColorChangeEvaluatorListener.java
Last active April 20, 2017 13:43
ViewPager listener to change colors on swiping
package com.corewillsoft.loansdeposits.ui.utils;
import android.animation.ArgbEvaluator;
import android.os.Handler;
import android.support.v4.view.ViewPager;
import static android.support.v4.view.ViewPager.SCROLL_STATE_IDLE;
import static com.corewillsoft.loansdeposits.ui.utils.SwipeDirectionDetector.Direction.LEFT;
import static com.corewillsoft.loansdeposits.ui.utils.SwipeDirectionDetector.Direction.RIGHT;
@VladSumtsov
VladSumtsov / ColorChangeEvaluatorListener.java
Created June 7, 2016 08:44
ViewPager listener to change colors on swiping
package com.corewillsoft.loansdeposits.ui.utils;
import android.animation.ArgbEvaluator;
import android.os.Handler;
import android.support.v4.view.ViewPager;
import static android.support.v4.view.ViewPager.SCROLL_STATE_IDLE;
import static com.corewillsoft.loansdeposits.ui.utils.SwipeDirectionDetector.Direction.LEFT;
import static com.corewillsoft.loansdeposits.ui.utils.SwipeDirectionDetector.Direction.RIGHT;
@VladSumtsov
VladSumtsov / build.gradle
Last active May 5, 2016 08:17
Android. Gradle. Change the package of the classes. Manifest, customviews, custom prefereces - all these xmls will be changed too. Only thing you have todo, enable your proguard and add "-applymapping ./build/mapping.txt" to your proguard. Also change "somepackage" and "targetpackage" to yours
android.applicationVariants.all { variant ->
File mappingFile = file("${buildDir}/mapping.txt")
if (variant.getBuildType().isMinifyEnabled()) {
variant.mergeResources.doLast {
if (!mappingFile.exists()) mappingFile.createNewFile()
println "minify replacePackageInResources"
replaceResources(variant, "com.somepackage", "com.targetpackage")
replaceResources(variant, "com.somepackage2", "com.targetpackage2")
}
@VladSumtsov
VladSumtsov / RecoderVideoSource.java
Created February 25, 2016 10:08
Fix for android 6
package com.ksy.recordlib.service.recoder;
import android.content.Context;
import android.hardware.Camera;
import android.media.MediaRecorder;
import android.os.Environment;
import android.util.Base64;
import android.util.Log;
import com.ksy.recordlib.service.core.CameraHelper;
@VladSumtsov
VladSumtsov / Good IOS RTSP Player.md
Created January 4, 2016 15:28 — forked from oc2pcoj/Good IOS RTSP Player.md
iOS RTSP player for IP video cameras
@VladSumtsov
VladSumtsov / CenterImageView.java
Last active September 17, 2015 08:06
Center image in the ImageView using matrix scheme.
package com.aliens.ui.widget;
import android.content.Context;
import android.graphics.Matrix;
import android.graphics.drawable.PictureDrawable;
import android.util.AttributeSet;
import android.widget.ImageView;
public class CenterImageView extends ImageView {
@VladSumtsov
VladSumtsov / OnDrawableClickListener.java
Created September 2, 2015 16:11
compound drawables click listener
package com.aliens.utils;
import android.view.MotionEvent;
import android.view.View;
import android.widget.TextView;
public class OnDrawableClickListener implements View.OnTouchListener {
private static final int LEFT_DRAWABLE = 0;
private static final int TOP_DRAWABLE = 1;
@VladSumtsov
VladSumtsov / EndlessScrollListener.java
Created August 27, 2015 08:11
Progress load for list view on scroll
package com.naughtystick.utils;
import android.view.View;
import android.widget.AbsListView;
import android.widget.AdapterView;
/**
* Created by dirong on 26.06.13.
*/
public abstract class EndlessScrollListener implements AbsListView.OnScrollListener, AbsListView.OnItemSelectedListener {
@VladSumtsov
VladSumtsov / Example
Last active August 29, 2015 14:25
Parse regular string to spannable with specified icons. Icons in string. String with icons. Android.
TextView instruction;
Spannable span = new StringToSpannable(context, "Push the icon {R.drawable.icon_menu}")
.setTextColor(context.getResources().getColor(R.color.holo_blue))
.setTextStyle(Typeface.BOLD)
.toSpannable();
instruction.setText(span);