Skip to content

Commit 1bc3af8

Browse files
committed
1. Added a generic method for getting data from database directly into 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.
1 parent f670458 commit 1bc3af8

12 files changed

+424
-10
lines changed

.idea/caches/build_file_checksums.ser

0 Bytes
Binary file not shown.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ allprojects{
2222
```
2323
dependencies {
2424
...
25-
implementation 'com.github.amitjangid80:multiutillib:v1.3.61'
25+
implementation 'com.github.amitjangid80:multiutillib:v1.4.0'
2626
}
2727
```
2828

@@ -43,7 +43,7 @@ dependencies {
4343
<dependency>
4444
<groupId>com.github.amitjangid80</groupId>
4545
<artifactId>multiutillib</artifactId>
46-
<version>v1.3.61</version>
46+
<version>v1.4.0</version>
4747
<dependency>
4848
```
4949

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ android {
1111
minSdkVersion 19
1212
targetSdkVersion 28
1313
versionCode 36 // this indicates the number of releases of library
14-
versionName "1.3.62" // this indicates the current version of library
14+
versionName "1.4.0" // this indicates the current version of library
1515
}
1616

1717
buildTypes {

app/src/main/java/com/amit/db/DBHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ public <T> ArrayList<T> executeSelectQuery(String tableName,
518518
// if yes the conditional values should not be null
519519
if (hasConditions)
520520
{
521-
// check ig conditional values is passed
521+
// check if conditional values is passed
522522
// it should be of string builder type
523523
// where user has to pass values to be passed in where clause
524524
//

app/src/main/java/com/amit/ui/ToastMsg.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import com.amit.R;
2222

23+
@SuppressWarnings({"WeakerAccess", "unused"})
2324
@SuppressLint("InflateParams")
2425
public class ToastMsg
2526
{

app/src/main/java/com/amit/ui/ToastMsgUtils.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
import android.graphics.PorterDuff;
55
import android.graphics.drawable.Drawable;
66
import android.graphics.drawable.NinePatchDrawable;
7-
import android.os.Build;
87
import android.support.annotation.ColorInt;
98
import android.support.annotation.DrawableRes;
109
import android.support.annotation.NonNull;
10+
import android.support.v4.content.ContextCompat;
1111
import android.view.View;
1212

1313
import com.amit.R;
@@ -18,6 +18,7 @@
1818
*
1919
* Toast message utils class
2020
**/
21+
@SuppressWarnings({"WeakerAccess", "unused"})
2122
public class ToastMsgUtils
2223
{
2324
private ToastMsgUtils()
@@ -44,13 +45,15 @@ static void setBackground(@NonNull View view, Drawable drawable)
4445

4546
static Drawable getDrawable(@NonNull Context context, @DrawableRes int id)
4647
{
47-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
48+
return ContextCompat.getDrawable(context, id);
49+
50+
/*if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
4851
{
4952
return context.getDrawable(id);
5053
}
5154
else
5255
{
5356
return context.getResources().getDrawable(id, null);
54-
}
57+
}*/
5558
}
5659
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package com.amit.utilities;
2+
3+
import android.content.Context;
4+
import android.support.annotation.NonNull;
5+
import android.support.design.widget.CoordinatorLayout;
6+
import android.support.design.widget.Snackbar;
7+
import android.support.v4.view.ViewCompat;
8+
import android.util.AttributeSet;
9+
import android.view.Gravity;
10+
import android.view.View;
11+
12+
/**
13+
* Created by AMIT JANGID on 26-Nov-18.
14+
**/
15+
@SuppressWarnings({"unused", "unchecked"})
16+
public class BottomNavigationViewBehaviour extends CoordinatorLayout.Behavior
17+
{
18+
public BottomNavigationViewBehaviour()
19+
{
20+
21+
}
22+
23+
public BottomNavigationViewBehaviour(Context context, AttributeSet attrs)
24+
{
25+
super(context, attrs);
26+
}
27+
28+
@Override
29+
public boolean onStartNestedScroll(@NonNull CoordinatorLayout coordinatorLayout, @NonNull View child, @NonNull View directTargetChild, @NonNull View target, int axes, int type)
30+
{
31+
return axes == ViewCompat.SCROLL_AXIS_VERTICAL;
32+
}
33+
34+
@Override
35+
public void onNestedScroll(@NonNull CoordinatorLayout coordinatorLayout, @NonNull View child, @NonNull View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, int type)
36+
{
37+
super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed, type);
38+
child.setTranslationY(Math.max(0f, Math.min(Float.parseFloat(String.valueOf(child.getHeight())), child.getTranslationY() + dyConsumed)));
39+
}
40+
41+
@Override
42+
public boolean layoutDependsOn(@NonNull CoordinatorLayout parent, @NonNull View child, @NonNull View dependency)
43+
{
44+
if (dependency instanceof Snackbar.SnackbarLayout)
45+
{
46+
updateSnackBar(child, dependency);
47+
}
48+
49+
return super.layoutDependsOn(parent, child, dependency);
50+
}
51+
52+
private void updateSnackBar(View child, View dependency)
53+
{
54+
if (dependency.getLayoutParams() instanceof CoordinatorLayout.LayoutParams)
55+
{
56+
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) dependency.getLayoutParams();
57+
params.setAnchorId(child.getId());
58+
params.anchorGravity = Gravity.TOP;
59+
dependency.setLayoutParams(params);
60+
}
61+
}
62+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package com.amit.utilities;
2+
3+
import android.graphics.Color;
4+
import android.support.annotation.NonNull;
5+
import android.text.TextPaint;
6+
import android.text.style.ClickableSpan;
7+
import android.view.View;
8+
9+
/**
10+
* Created by AMIT JANGID on 26-Nov-18.
11+
**/
12+
public class MySpannable extends ClickableSpan
13+
{
14+
private final boolean isUnderLine;
15+
16+
MySpannable(boolean isUnderLine)
17+
{
18+
this.isUnderLine = isUnderLine;
19+
}
20+
21+
@Override
22+
public void updateDrawState(@NonNull TextPaint ds)
23+
{
24+
ds.setUnderlineText(isUnderLine);
25+
ds.setColor(Color.parseColor("#1b76d3"));
26+
}
27+
28+
@Override
29+
public void onClick(@NonNull View widget)
30+
{
31+
32+
}
33+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package com.amit.utilities;
2+
3+
import android.support.annotation.NonNull;
4+
import android.support.v7.widget.RecyclerView;
5+
6+
/**
7+
* Created by AMIT JANGID on 20-Oct-18.
8+
**/
9+
@SuppressWarnings({"unused", "WeakerAccess"})
10+
public abstract class RecyclerViewScroll extends RecyclerView.OnScrollListener
11+
{
12+
private static final float MINIMUM = 25;
13+
private boolean isVisible = true;
14+
private int scrollDist = 0;
15+
16+
@Override
17+
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy)
18+
{
19+
super.onScrolled(recyclerView, dx, dy);
20+
21+
if (isVisible && scrollDist > MINIMUM)
22+
{
23+
// calling hide fab button method
24+
hideFabButton();
25+
26+
scrollDist = 0;
27+
isVisible = false;
28+
}
29+
else if (!isVisible && scrollDist < -MINIMUM)
30+
{
31+
// calling show fab button method
32+
showFabButton();
33+
34+
scrollDist = 0;
35+
isVisible = true;
36+
}
37+
38+
if ((isVisible && dy > 0) || (!isVisible && dy < 0))
39+
{
40+
scrollDist += dy;
41+
}
42+
}
43+
44+
protected abstract void showFabButton();
45+
protected abstract void hideFabButton();
46+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package com.amit.utilities;
2+
3+
import android.content.Context;
4+
import android.content.res.TypedArray;
5+
import android.support.annotation.NonNull;
6+
import android.support.design.widget.AppBarLayout;
7+
import android.support.design.widget.CoordinatorLayout;
8+
import android.support.design.widget.FloatingActionButton;
9+
import android.util.AttributeSet;
10+
import android.view.View;
11+
12+
import com.amit.R;
13+
14+
/**
15+
* Created by AMIT JANGID on 22-Oct-18.
16+
**/
17+
@SuppressWarnings("unused")
18+
public class ScrollingFABBehavior extends CoordinatorLayout.Behavior<FloatingActionButton>
19+
{
20+
private final int toolbarHeight;
21+
22+
public ScrollingFABBehavior(Context context, AttributeSet attrs)
23+
{
24+
super(context, attrs);
25+
26+
final TypedArray styledAttributes = context.getTheme().obtainStyledAttributes(new int[]{R.attr.actionBarSize});
27+
this.toolbarHeight = (int) styledAttributes.getDimension(0, 0);
28+
styledAttributes.recycle();
29+
}
30+
31+
@Override
32+
public boolean layoutDependsOn(@NonNull CoordinatorLayout parent, @NonNull FloatingActionButton fab, @NonNull View dependency)
33+
{
34+
return dependency instanceof AppBarLayout;
35+
}
36+
37+
@Override
38+
public boolean onDependentViewChanged(@NonNull CoordinatorLayout parent, @NonNull FloatingActionButton fab, @NonNull View dependency)
39+
{
40+
if (dependency instanceof AppBarLayout)
41+
{
42+
CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) fab.getLayoutParams();
43+
44+
int fabBottomMargin = lp.bottomMargin;
45+
int distanceToScroll = fab.getHeight() + fabBottomMargin;
46+
47+
float ratio = dependency.getY() / (float) toolbarHeight;
48+
fab.setTranslationY(-distanceToScroll * ratio);
49+
}
50+
51+
return true;
52+
}
53+
}

0 commit comments

Comments
 (0)