See also: https://github.com/vbauer/java-blogs
- Androcid http://www.androcid.com
- Androidized http://www.androidized.com
- Androinica http://androinica.com
import android.content.Context; | |
import android.content.res.TypedArray; | |
import android.graphics.Canvas; | |
import android.graphics.Rect; | |
import android.graphics.drawable.Drawable; | |
import android.support.v4.content.ContextCompat; | |
import android.support.v7.widget.LinearLayoutManager; | |
import android.support.v7.widget.RecyclerView; | |
import android.util.AttributeSet; | |
import android.view.View; |
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; | |
} |
<?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 |
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; |
// 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 { |
<?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> |
[ | |
{ | |
"name": "Afghanistan", | |
"dial_code": "+93", | |
"code": "AF" | |
}, | |
{ | |
"name": "Aland Islands", | |
"dial_code": "+358", | |
"code": "AX" |
See also: https://github.com/vbauer/java-blogs
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
/* | |
* @author Dipendra Sunar | |
*/ | |
public class DashedUnderlinedTextView extends AppCompatTextView { | |
private Rect mRect; | |
private Paint mPaint; | |
private float mStrokeWidth; | |
private int mUnderlinePadding; |