Skip to content

Commit

Permalink
1. Added a generic method for getting data from database directly int…
Browse files Browse the repository at this point in the history
…o custom array list.

2. Added a method in Utils to make a view perform shared transition element.
3. Added Expandable Recycler view, which can be used inside scroll view for showing data.
4. Added Recycler view scroll class for adding hide and show animation on fab button.
5. Resolved bugs with ToastMsg and added support for older API levels.
  • Loading branch information
amitjangid80 committed Nov 29, 2018
1 parent f670458 commit 1bc3af8
Show file tree
Hide file tree
Showing 12 changed files with 424 additions and 10 deletions.
Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ allprojects{
```
dependencies {
...
implementation 'com.github.amitjangid80:multiutillib:v1.3.61'
implementation 'com.github.amitjangid80:multiutillib:v1.4.0'
}
```

Expand All @@ -43,7 +43,7 @@ dependencies {
<dependency>
<groupId>com.github.amitjangid80</groupId>
<artifactId>multiutillib</artifactId>
<version>v1.3.61</version>
<version>v1.4.0</version>
<dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ android {
minSdkVersion 19
targetSdkVersion 28
versionCode 36 // this indicates the number of releases of library
versionName "1.3.62" // this indicates the current version of library
versionName "1.4.0" // this indicates the current version of library
}

buildTypes {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/amit/db/DBHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ public <T> ArrayList<T> executeSelectQuery(String tableName,
// if yes the conditional values should not be null
if (hasConditions)
{
// check ig conditional values is passed
// check if conditional values is passed
// it should be of string builder type
// where user has to pass values to be passed in where clause
//
Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/com/amit/ui/ToastMsg.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import com.amit.R;

@SuppressWarnings({"WeakerAccess", "unused"})
@SuppressLint("InflateParams")
public class ToastMsg
{
Expand Down
9 changes: 6 additions & 3 deletions app/src/main/java/com/amit/ui/ToastMsgUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.NinePatchDrawable;
import android.os.Build;
import android.support.annotation.ColorInt;
import android.support.annotation.DrawableRes;
import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat;
import android.view.View;

import com.amit.R;
Expand All @@ -18,6 +18,7 @@
*
* Toast message utils class
**/
@SuppressWarnings({"WeakerAccess", "unused"})
public class ToastMsgUtils
{
private ToastMsgUtils()
Expand All @@ -44,13 +45,15 @@ static void setBackground(@NonNull View view, Drawable drawable)

static Drawable getDrawable(@NonNull Context context, @DrawableRes int id)
{
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
return ContextCompat.getDrawable(context, id);

/*if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
{
return context.getDrawable(id);
}
else
{
return context.getResources().getDrawable(id, null);
}
}*/
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package com.amit.utilities;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.design.widget.CoordinatorLayout;
import android.support.design.widget.Snackbar;
import android.support.v4.view.ViewCompat;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.View;

/**
* Created by AMIT JANGID on 26-Nov-18.
**/
@SuppressWarnings({"unused", "unchecked"})
public class BottomNavigationViewBehaviour extends CoordinatorLayout.Behavior
{
public BottomNavigationViewBehaviour()
{

}

public BottomNavigationViewBehaviour(Context context, AttributeSet attrs)
{
super(context, attrs);
}

@Override
public boolean onStartNestedScroll(@NonNull CoordinatorLayout coordinatorLayout, @NonNull View child, @NonNull View directTargetChild, @NonNull View target, int axes, int type)
{
return axes == ViewCompat.SCROLL_AXIS_VERTICAL;
}

@Override
public void onNestedScroll(@NonNull CoordinatorLayout coordinatorLayout, @NonNull View child, @NonNull View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, int type)
{
super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed, type);
child.setTranslationY(Math.max(0f, Math.min(Float.parseFloat(String.valueOf(child.getHeight())), child.getTranslationY() + dyConsumed)));
}

@Override
public boolean layoutDependsOn(@NonNull CoordinatorLayout parent, @NonNull View child, @NonNull View dependency)
{
if (dependency instanceof Snackbar.SnackbarLayout)
{
updateSnackBar(child, dependency);
}

return super.layoutDependsOn(parent, child, dependency);
}

private void updateSnackBar(View child, View dependency)
{
if (dependency.getLayoutParams() instanceof CoordinatorLayout.LayoutParams)
{
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) dependency.getLayoutParams();
params.setAnchorId(child.getId());
params.anchorGravity = Gravity.TOP;
dependency.setLayoutParams(params);
}
}
}
33 changes: 33 additions & 0 deletions app/src/main/java/com/amit/utilities/MySpannable.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.amit.utilities;

import android.graphics.Color;
import android.support.annotation.NonNull;
import android.text.TextPaint;
import android.text.style.ClickableSpan;
import android.view.View;

/**
* Created by AMIT JANGID on 26-Nov-18.
**/
public class MySpannable extends ClickableSpan
{
private final boolean isUnderLine;

MySpannable(boolean isUnderLine)
{
this.isUnderLine = isUnderLine;
}

@Override
public void updateDrawState(@NonNull TextPaint ds)
{
ds.setUnderlineText(isUnderLine);
ds.setColor(Color.parseColor("#1b76d3"));
}

@Override
public void onClick(@NonNull View widget)
{

}
}
46 changes: 46 additions & 0 deletions app/src/main/java/com/amit/utilities/RecyclerViewScroll.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.amit.utilities;

import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;

/**
* Created by AMIT JANGID on 20-Oct-18.
**/
@SuppressWarnings({"unused", "WeakerAccess"})
public abstract class RecyclerViewScroll extends RecyclerView.OnScrollListener
{
private static final float MINIMUM = 25;
private boolean isVisible = true;
private int scrollDist = 0;

@Override
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy)
{
super.onScrolled(recyclerView, dx, dy);

if (isVisible && scrollDist > MINIMUM)
{
// calling hide fab button method
hideFabButton();

scrollDist = 0;
isVisible = false;
}
else if (!isVisible && scrollDist < -MINIMUM)
{
// calling show fab button method
showFabButton();

scrollDist = 0;
isVisible = true;
}

if ((isVisible && dy > 0) || (!isVisible && dy < 0))
{
scrollDist += dy;
}
}

protected abstract void showFabButton();
protected abstract void hideFabButton();
}
53 changes: 53 additions & 0 deletions app/src/main/java/com/amit/utilities/ScrollingFABBehavior.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package com.amit.utilities;

import android.content.Context;
import android.content.res.TypedArray;
import android.support.annotation.NonNull;
import android.support.design.widget.AppBarLayout;
import android.support.design.widget.CoordinatorLayout;
import android.support.design.widget.FloatingActionButton;
import android.util.AttributeSet;
import android.view.View;

import com.amit.R;

/**
* Created by AMIT JANGID on 22-Oct-18.
**/
@SuppressWarnings("unused")
public class ScrollingFABBehavior extends CoordinatorLayout.Behavior<FloatingActionButton>
{
private final int toolbarHeight;

public ScrollingFABBehavior(Context context, AttributeSet attrs)
{
super(context, attrs);

final TypedArray styledAttributes = context.getTheme().obtainStyledAttributes(new int[]{R.attr.actionBarSize});
this.toolbarHeight = (int) styledAttributes.getDimension(0, 0);
styledAttributes.recycle();
}

@Override
public boolean layoutDependsOn(@NonNull CoordinatorLayout parent, @NonNull FloatingActionButton fab, @NonNull View dependency)
{
return dependency instanceof AppBarLayout;
}

@Override
public boolean onDependentViewChanged(@NonNull CoordinatorLayout parent, @NonNull FloatingActionButton fab, @NonNull View dependency)
{
if (dependency instanceof AppBarLayout)
{
CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) fab.getLayoutParams();

int fabBottomMargin = lp.bottomMargin;
int distanceToScroll = fab.getHeight() + fabBottomMargin;

float ratio = dependency.getY() / (float) toolbarHeight;
fab.setTranslationY(-distanceToScroll * ratio);
}

return true;
}
}
Loading

0 comments on commit 1bc3af8

Please sign in to comment.