Skip to content

Instantly share code, notes, and snippets.

View amannepid's full-sized avatar

Dipendra Sunar amannepid

View GitHub Profile
@amannepid
amannepid / Dagger2SimpleExample.java
Created February 12, 2018 21:57 — forked from vestrel00/Dagger2SimpleExample.java
A: Dagger.android 2.11 simple example with support for Singleton, PerActivity, PerFragment, and PerChildFragment scopes
// This is a super simplified example of how to use the new dagger.android framework
// introduced in Dagger 2.10. For a more complete, in-depth guide to dagger.android
// read https://proandroiddev.com/how-to-android-dagger-2-10-2-11-butterknife-mvp-part-1-eb0f6b970fd
// For a complete codebase using dagger.android 2.11/2.12/2.13/2.14, butterknife 8.7/8.8, and MVP,
// see https://github.com/vestrel00/android-dagger-butterknife-mvp
// This example works with Dagger 2.11/2.12/2.13/2.14. Starting with Dagger 2.11,
// @ContributesAndroidInjector was introduced removing the need to define @Subcomponent classes.
@amannepid
amannepid / DashedUnderlinedTextView.java
Last active November 29, 2017 13:52
Dashed Underlined TextView
/*
* @author Dipendra Sunar
*/
public class DashedUnderlinedTextView extends AppCompatTextView {
private Rect mRect;
private Paint mPaint;
private float mStrokeWidth;
private int mUnderlinePadding;
@amannepid
amannepid / android_architecture.md
Last active November 14, 2017 17:04
Android Archtecture

Architecture Guidelines

The architecture of our Android apps is based on the MVP (Model View Presenter) pattern.

  • View (UI layer): this is where Activities, Fragments and other standard Android components live. It's responsible for displaying the data received from the presenters to the user. It also handles user interactions and inputs (click listeners, etc) and triggers the right action in the Presenter if needed.

  • Presenter: presenters subscribe to RxJava Observables provided by the DataManager. They are in charge of handling the subscription lifecycle, analysing/modifying the data returned by the DataManager and calling the appropriate methods in the View in order to display the data.

  • Model (Data Layer): this is responsible for retrieving, saving, caching and massaging data. It can communicate with local databases and other data stores as well as with restful APIs or third party SDKs. It is divided in two parts

@amannepid
amannepid / readme.md
Last active March 15, 2018 23:34
Popular Android Blogs
@amannepid
amannepid / countries.json
Created January 16, 2017 03:49
Simple JSON list of countries and their code and dial codes. Can be helpful as a remote api for listing countries.
[
{
"name": "Afghanistan",
"dial_code": "+93",
"code": "AF"
},
{
"name": "Aland Islands",
"dial_code": "+358",
"code": "AX"
@amannepid
amannepid / anim_alpha.xml
Created January 3, 2017 04:03
Sample Animations Resources
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator">
<alpha
android:fromAlpha="1.0"
android:toAlpha="0.1"
android:duration="500"
android:repeatCount="1"
android:repeatMode="reverse" />
</set>
@amannepid
amannepid / apk_versioning.gradle
Created August 8, 2016 04:15
Generate APK with version names and date
// This gist is tested with gradle version 2.1.2
// Create a method outside android { .... }
// Built apk file naming: AppName-VersionName-Date-BuildType.apk
def getBuildFileName(versionName) {
def date = new Date().format('yyyy-MMM-dd')
def appName
if(project.hasProperty("applicationName")){
appName = applicationName
}else {
@amannepid
amannepid / EndlessRecyclerOnScrollListener.java
Created March 28, 2016 13:58 — forked from ssinss/EndlessRecyclerOnScrollListener.java
Endless RecyclerView OnScrollListener
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
public abstract class EndlessRecyclerOnScrollListener extends RecyclerView.OnScrollListener {
public static String TAG = EndlessRecyclerOnScrollListener.class.getSimpleName();
private int previousTotal = 0; // The total number of items in the dataset after the last load
private boolean loading = true; // True if we are still waiting for the last set of data to load.
private int visibleThreshold = 5; // The minimum amount of items to have below your current scroll position before loading more.
int firstVisibleItem, visibleItemCount, totalItemCount;
@amannepid
amannepid / 1_drawable_ic_hash_io16.xml
Created March 19, 2016 13:42 — forked from nickbutcher/1_drawable_ic_hash_io16.xml
Animated Stroke. The google I/O website this year (https://google.com/io) has some funky animated lettering. I especially liked the animated stroke around the letters and wondered how you might implement that on Android. Turns out that AnimatedVectorDrawable makes this very easy! Here's how it looks: https://twitter.com/crafty/status/71077957997…
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2016 Google Inc.
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
public class AuthInterceptor implements Interceptor {
private String mAccessToken;
private final Context mContext;
public AuthInterceptor(Context context) {
AccessToken accessToken = AccessToken.get(context);
mAccessToken = accessToken.accessToken;
mContext = context;
}