-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. Added a generic method for getting data from database directly int…
…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
1 parent
f670458
commit 1bc3af8
Showing
12 changed files
with
424 additions
and
10 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
app/src/main/java/com/amit/utilities/BottomNavigationViewBehaviour.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
46
app/src/main/java/com/amit/utilities/RecyclerViewScroll.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
53
app/src/main/java/com/amit/utilities/ScrollingFABBehavior.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
Oops, something went wrong.