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
@iamdeveloper-lopez
iamdeveloper-lopez / CustomRecyclerView.java
Created April 19, 2018 06:08
Easy implementation of RecyclerView and EmptyView
import android.content.Context;
import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import java.util.Objects;
@iamdeveloper-lopez
iamdeveloper-lopez / VetAdapter.java
Created June 18, 2018 08:09
VetAdapter - sample recyclerView adapter implementation
public class VetAdapter extends RecyclerView.Adapter<VetAdapter.ViewHolder> {
private List<VetArray> vetArrays = new ArrayList<>();
public VetAdapter() {
}
public VetAdapter(List<VetArray> vetArrays) {
this.vetArrays = vetArrays;
}
public class StatusBar extends View {
private int statusBarColor = Integer.MIN_VALUE;
public StatusBar(Context context) {
super(context);
}
public StatusBar(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
@iamdeveloper-lopez
iamdeveloper-lopez / PopBackStack
Created August 10, 2018 08:54
PopBackStack on Nested Child Fragments
@Override
public void onBackPressed() {
for (Fragment fragment : fragmentManager.getFragments()) {
if (fragment.isVisible() && hasBackStack(fragment)) {
if (popFragment(fragment))
return;
}
}
super.onBackPressed();
}
@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 / 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 / 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) {
@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 / 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 / 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> {