Skip to content

Instantly share code, notes, and snippets.

@hector6872
hector6872 / build.gradle
Last active July 17, 2017 17:57
Semantic versioning
def appVersionMajor = 1
def appVersionMinor = 0
def appVersionPatch = 0
def appVersionBuild = 0
appVersionCode = appVersionMajor * 1000000 + appVersionMinor * 10000 + appVersionPatch * 100 + appVersionBuild
appVersionName = "${appVersionMajor}.${appVersionMinor}.${appVersionPatch}"
@hector6872
hector6872 / StateRecyclerView.java
Last active May 31, 2017 22:00
StateRecyclerView
public class StateRecyclerView extends RecyclerView {
private View emptyView;
private int emptyViewId;
public StateRecyclerView(Context context) {
this(context, null);
}
public StateRecyclerView(Context context, @Nullable AttributeSet attrs) {
this(context, attrs, 0);
@hector6872
hector6872 / DRMVPAppCompatActivity.java
Last active November 29, 2024 12:06
DRMVPAppCompatActivity example for DaRealMVP library - https://github.com/hector6872/DaRealMVP
@SuppressWarnings("unchecked") public abstract class DRMVPAppCompatActivity<P extends DRMVPPresenter<V>, V extends DRMVPView>
extends AppCompatActivity {
private P presenter;
@CallSuper @Override protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(getLayoutResId());
presenter = MVPUtils.getDeclaredPresenter(getClass());
presenter.bind((V) this);
}
@hector6872
hector6872 / DRMVPFragmentV4.java
Last active November 29, 2024 12:06
DRMVPFragmentV4 example for DaRealMVP library - https://github.com/hector6872/DaRealMVP
@SuppressWarnings("unchecked") public abstract class DRMVPFragmentV4<P extends DRMVPPresenter<V>, V extends DRMVPView> extends Fragment {
private P presenter;
@CallSuper @Nullable @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(getLayoutResId(), container, false);
}
@CallSuper @Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
presenter = MVPUtils.getDeclaredPresenter(getClass());
presenter.bind((V) this);
@hector6872
hector6872 / DRMVPFrameLayoutView.java
Last active November 29, 2024 12:05
DRMVPFrameLayoutView example for DaRealMVP library - https://github.com/hector6872/DaRealMVP
public abstract class DRMVPFrameLayoutView<P extends DRMVPPresenter<V>, V extends DRMVPView> extends FrameLayout {
private P presenter;
public DRMVPFrameLayoutView(Context context, @Nullable AttributeSet attrs) {
this(context, attrs, 0);
}
public DRMVPFrameLayoutView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init();
public class GifImageView extends ImageView {
private static final long DEFAULT_MOVIE_VIEW_DURATION = TimeUnit.SECONDS.toMillis(1);
private Movie movie;
private long movieStart;
private int movieCurrentAnimationTime;
private boolean running = false;
private boolean visible = true;
public final class Network {
private Network() {
}
public static @NonNull String doGetRequest(@NonNull String service, @NonNull String resource,
@NonNull List<Pair<String, String>> params, @NonNull List<Pair<String, String>> headers) throws IOException {
HttpURLConnection httpURLConnection = null;
try {
URL url = new URL(
service + "/" + Uri.encode(resource) + (params.isEmpty() ? "" : "&" + convertPairToParamString(params)));
@hector6872
hector6872 / UidUtils.java
Last active July 6, 2017 08:39
UidUtils
public enum UidUtils {
INSTANCE;
private final static String DEFAULT_ID = "anonymous";
private String androidId = DEFAULT_ID;
private String advertisingId = "";
private boolean limitAdTrackingEnabled = false;
@hector6872
hector6872 / DashedLineView.java
Last active July 5, 2017 16:06
DashedLineView
public class DashedLineView extends View {
private static final int DEFAULT_COLOR = Color.BLACK;
private static final float DEFAULT_DASH = 4f;
private static final float DEFAULT_GAP = 2f;
private static final float DEFAULT_PHASE = 0f;
private final Paint paint = new Paint();
private final Path path = new Path();
private float dash;
@hector6872
hector6872 / demo-mode.sh
Last active January 31, 2023 16:34
Demo Mode for the Android System UI - screenshots - bash script
#!/usr/bin/env sh
# export PATH=$PATH:~/Library/Android/sdk/platform-tools/
case $1 in
"enter")
adb shell settings put global sysui_demo_allowed 1
# display time 12:00
adb shell am broadcast -a com.android.systemui.demo -e command clock -e hhmm 1200
# display full mobile data without type
adb shell am broadcast -a com.android.systemui.demo -e command network -e mobile show -e level 4 -e datatype false