Skip to content

Instantly share code, notes, and snippets.

View shaon2016's full-sized avatar

Ashiqul Islam Shaon shaon2016

View GitHub Profile
package com.lastblade.common.restclient
import android.content.Context
import com.durbinlabs.duplate.common.utils.U
import com.osellers.common.BuildConfig
import com.lastblade.common.utils.C
import com.lastblade.common.utils.D
import com.lastblade.common.utils.Lg
import io.reactivex.Observable
import io.reactivex.Observer
@shaon2016
shaon2016 / Rester
Last active November 29, 2018 11:40
This is customized retrofit rest api client for android
package com.osellers.common.restclient
import android.content.Context
import com.durbinlabs.duplate.common.utils.U
import com.osellers.common.BuildConfig
import com.osellers.common.utils.C
import com.osellers.common.utils.D
import com.osellers.common.utils.Lg
import io.reactivex.Observable
import io.reactivex.Observer
@shaon2016
shaon2016 / TabLayout with view pager
Last active July 1, 2018 06:59
This gist shows an example of how to implement tablayout with viewpager
Layout
````
<android.support.design.widget.TabLayout
android:id="@+id/tabOrderStatus"
android:layout_width="match_parent"
android:layout_height="56dp"
android:background="@color/colorPrimary"
app:tabGravity="fill"
app:tabIndicatorColor="@color/colorAccent"
@shaon2016
shaon2016 / gist:7c840a62f26d256386fac2bed1edb51c
Created June 27, 2018 05:11
This will calculate the height or width at runtime
private fun measureFoodImageLayoutAtRuntime() {
// here adfAppBar is the root layout
val layoutParam = afdAppBar?.layoutParams as CoordinatorLayout.LayoutParams
layoutParam.height = U.getScreenHeight(this) / 3
afdAppBar?.layoutParams = layoutParam
afdAppBar?.requestLayout()
}
@shaon2016
shaon2016 / reverse geocoding
Created May 29, 2018 16:06
Get the address using lat lng
private void gettingAddressUsingLatLng(double latitude, double longitude) {
Geocoder geocoder = new Geocoder(this, Locale.getDefault());
List<Address> addresses = null;
try {
addresses = geocoder.getFromLocation(
latitude,
longitude,
1);
}catch (IOException e) {
e.printStackTrace();
package com.durbinlabs.duplate.fragments;
import android.location.Address;
import android.location.Geocoder;
import android.support.v4.app.Fragment;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@shaon2016
shaon2016 / adding new data to rv checking duplicate
Created January 28, 2018 04:34
This code ensures that duplicate data will not be in rv list.
public void addAll(ArrayList<Inventory> newList) {
// Lg.i(TAG, "Adding all: Current count=" + c + ", \nNew count=" + newList.size());
//Previous List of Recycler View
List<Inventory> itemList = this.itemList;
for (Inventory iv : newList) {
boolean exists = false;
// id of new list
int id = iv.getId();
for (Inventory ivOld : itemList)
// checking new id with old id
private int imageHeight, imageWidth, w;
private ImageView imageSingleFoodItem;
onCreate() {
// w = (int) (getScreenWidth(this) * 0.80);
w = (int) (getScreenWidth(this));
//drawable image and you want that size you can get like this way
BitmapFactory.Options options = new BitmapFactory.Options();
package com.durbinlabs.duplate.common.utils;
import android.content.Context;
import android.content.res.TypedArray;
import android.support.design.widget.CoordinatorLayout;
import android.support.v7.widget.Toolbar;
import android.util.AttributeSet;
import android.view.View;