Skip to content

Instantly share code, notes, and snippets.

View iamdeveloper-lopez's full-sized avatar
👨‍💻
Focusing

Lester Lopez iamdeveloper-lopez

👨‍💻
Focusing
View GitHub Profile
abstract class BaseBottomSheetDialogFragment : BottomSheetDialogFragment() {
@LayoutRes
protected abstract fun layoutRes(): Int
protected abstract fun onViewCreated()
private var sheetBehavior: BottomSheetBehavior<*>? = null
private var peekHeight = 0
private var expandedOffset = 0
@iamdeveloper-lopez
iamdeveloper-lopez / GitCommands
Created January 15, 2020 09:41
Important git commands
# rm all files
git rm -r --cached .
# add all files as per new .gitignore
git add .
# now, commit for new .gitignore to apply
git commit -m ".gitignore is now working"
Delete uncommited items in branch
git reset --hard
@iamdeveloper-lopez
iamdeveloper-lopez / SpacingItemDecoration.java
Created November 14, 2019 07:38
Equally spacing recyclerView items with the provided space.
public class SpacingItemDecoration extends RecyclerView.ItemDecoration {
private static final String TAG = "SPACE";
private int spacing;
public SpacingItemDecoration(int spacing) {
this.spacing = spacing;
}
public abstract class SimpleCollapsingToolbarCallback implements AppBarLayout.OnOffsetChangedListener {
public enum State {
EXPANDED,
COLLAPSED
}
@iamdeveloper-lopez
iamdeveloper-lopez / IPFinderTask.java
Created March 19, 2019 04:26
Getting IP address in simple way.
import android.os.AsyncTask;
import android.util.Log;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
public class IPFinderTask extends AsyncTask<Void, Void, String> {
@iamdeveloper-lopez
iamdeveloper-lopez / DynamicHeightImageView.java
Created March 18, 2019 06:52
An ImageView layout that maintains a consistent width to height aspect ratio.
public class DynamicHeightImageView extends ImageView {
private double mHeightRatio;
public DynamicHeightImageView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public DynamicHeightImageView(Context context) {
super(context);
@iamdeveloper-lopez
iamdeveloper-lopez / README.md
Created October 26, 2018 02:53
UnzipTask is an extension for AsyncTask which focus on Unzipping file and extract it to the one you've provided.

UnzipTask

UnzipTask is an extension for AsyncTask which focus on Unzipping file and extract it to the one you've provided.

Implementation

Using Builder

UnzipTask.Builder builder = new UnzipTask.Builder();
builder.setZipFile(zipFile);
@iamdeveloper-lopez
iamdeveloper-lopez / PercentViewPager.java
Created August 28, 2018 02:44
PercentViewPager is an extension for ViewPager that can control W & H by percentage.
public class PercentViewPager extends ViewPager {
private int WIDTH_PERCENT = Integer.MIN_VALUE;
private int HEIGHT_PERCENT = Integer.MIN_VALUE;
public PercentViewPager(@NonNull Context context) {
super(context);
init(context, null);
}
@iamdeveloper-lopez
iamdeveloper-lopez / PercentImageView.java
Last active August 28, 2018 02:43
PercentImageView is an extension for ImageView that can control W & H by percentage.
public class PercentImageView extends AppCompatImageView {
private int WIDTH_PERCENT = Integer.MIN_VALUE;
private int HEIGHT_PERCENT = Integer.MIN_VALUE;
public PercentImageView(Context context) {
super(context);
init(context, null);
}
@iamdeveloper-lopez
iamdeveloper-lopez / README.md
Last active October 25, 2018 04:00
Alternative to Rx request using Retrofit

RetrofitTask

To implement it with custom callback just call

Call<GitHubUser> call = githubService.getUser(userId);

RetrofitTask task = new RetrofitTask<GitHubUser>(call, new RetrofitTask.RetrofitTaskCllback<GitHubUser>(){
    @Override
 public void onSuccess(GitHubUser response) {