-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Atroshchenko Sergey - @SerG3z #8
Open
SerG3z
wants to merge
9
commits into
yamblz-native:master
Choose a base branch
from
SerG3z:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
586db6e
add swipe right - remove, move item, create columns and remove column…
SerG3z bafaa7c
fix edit color swipe delete
SerG3z 68af297
color change click
SerG3z 5558a40
add animation edit columns and edit style item with frame and not frame
SerG3z 3867378
draw crown two last moved item
SerG3z 583511b
added all the rest
SerG3z 03808a6
add 2 button in toolbar
SerG3z 9d58ca7
scrolling does not brake
SerG3z fad0430
bug fix
SerG3z File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
10 changes: 10 additions & 0 deletions
10
app/src/main/java/ru/yandex/yamblz/ui/adapters/ItemTouchHelperAdapter.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,10 @@ | ||
package ru.yandex.yamblz.ui.adapters; | ||
|
||
/** | ||
* Created by user on 28.07.16. | ||
*/ | ||
|
||
public interface ItemTouchHelperAdapter { | ||
boolean onItemMove(int startPosition, int endPosition); | ||
void onItemDismiss(int position); | ||
} |
96 changes: 96 additions & 0 deletions
96
app/src/main/java/ru/yandex/yamblz/ui/adapters/SimpleItemTouchCallback.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,96 @@ | ||
package ru.yandex.yamblz.ui.adapters; | ||
|
||
import android.content.Context; | ||
import android.graphics.Canvas; | ||
import android.graphics.Color; | ||
import android.graphics.Paint; | ||
import android.graphics.drawable.Drawable; | ||
import android.support.v4.content.ContextCompat; | ||
import android.support.v7.widget.RecyclerView; | ||
import android.support.v7.widget.helper.ItemTouchHelper; | ||
import android.view.View; | ||
|
||
import ru.yandex.yamblz.R; | ||
import ru.yandex.yamblz.ui.fragments.FrameItemDecoration; | ||
|
||
/** | ||
* Created by user on 28.07.16. | ||
*/ | ||
|
||
public class SimpleItemTouchCallback extends ItemTouchHelper.Callback { | ||
|
||
private final ItemTouchHelperAdapter touchHelperAdapter; | ||
private final FrameItemDecoration frameItemDecoration; | ||
private Paint paint; | ||
private Context context; | ||
|
||
public SimpleItemTouchCallback(ItemTouchHelperAdapter touchHelperAdapter, FrameItemDecoration frameItemDecoration, Context context) { | ||
this.touchHelperAdapter = touchHelperAdapter; | ||
this.frameItemDecoration = frameItemDecoration; | ||
this.context = context; | ||
paint = new Paint(); | ||
paint.setColor(Color.RED); | ||
} | ||
|
||
@Override | ||
public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { | ||
final int dragFlag = ItemTouchHelper.UP | ItemTouchHelper.DOWN | ItemTouchHelper.LEFT | | ||
ItemTouchHelper.RIGHT; | ||
final int swipeFlag = ItemTouchHelper.END; | ||
return makeMovementFlags(dragFlag, swipeFlag); | ||
} | ||
|
||
@Override | ||
public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) { | ||
frameItemDecoration.setIndexSelectedItem(viewHolder.getAdapterPosition(), target.getAdapterPosition()); | ||
touchHelperAdapter.onItemMove(viewHolder.getAdapterPosition(), target.getAdapterPosition()); | ||
return true; | ||
} | ||
|
||
@Override | ||
public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) { | ||
touchHelperAdapter.onItemDismiss(viewHolder.getAdapterPosition()); | ||
} | ||
|
||
@Override | ||
public void onChildDraw(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, | ||
float dX, float dY, int actionState, boolean isCurrentlyActive) { | ||
if (actionState == ItemTouchHelper.ACTION_STATE_SWIPE) { | ||
Drawable drawable = ContextCompat.getDrawable(context, R.drawable.delete_icon); | ||
View itemView = viewHolder.itemView; | ||
float alpha = Math.abs(dX) / itemView.getWidth(); | ||
itemView.setTranslationX(dX); | ||
if (dX >= itemView.getWidth()) { | ||
paint.setAlpha(255); | ||
drawable.setAlpha(255); | ||
} else { | ||
paint.setAlpha((int) (255 * alpha)); | ||
drawable.setAlpha((int) (255 * alpha)); | ||
} | ||
c.drawRect(itemView.getLeft(), itemView.getTop(), itemView.getRight(), | ||
itemView.getBottom(), paint); | ||
|
||
final RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager(); | ||
int left = layoutManager.getDecoratedLeft(itemView); | ||
int top = layoutManager.getDecoratedTop(itemView) + drawable.getMinimumHeight(); | ||
int bottom = layoutManager.getDecoratedBottom(itemView) - drawable.getMinimumHeight(); | ||
int right = layoutManager.getDecoratedLeft(itemView) + bottom - top; | ||
drawable.setBounds(left, top, right, bottom); | ||
drawable.draw(c); | ||
} else { | ||
super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive); | ||
} | ||
} | ||
|
||
@Override | ||
public boolean isLongPressDragEnabled() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean isItemViewSwipeEnabled() { | ||
return true; | ||
} | ||
|
||
|
||
} |
20 changes: 20 additions & 0 deletions
20
app/src/main/java/ru/yandex/yamblz/ui/fragments/Animation.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,20 @@ | ||
package ru.yandex.yamblz.ui.fragments; | ||
|
||
import android.animation.ObjectAnimator; | ||
import android.support.v7.widget.RecyclerView; | ||
import android.view.View; | ||
|
||
/** | ||
* Created by SerG3z on 06.08.16. | ||
*/ | ||
|
||
public class Animation { | ||
|
||
public static void animationAppearence(RecyclerView.ViewHolder holder) { | ||
ObjectAnimator.ofFloat( | ||
holder.itemView, | ||
View.ROTATION_X, 0, 360) | ||
.setDuration(1000) | ||
.start(); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
app/src/main/java/ru/yandex/yamblz/ui/fragments/AnimationAppearanceLayoutManager.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,42 @@ | ||
package ru.yandex.yamblz.ui.fragments; | ||
|
||
import android.content.Context; | ||
import android.support.v7.widget.GridLayoutManager; | ||
import android.support.v7.widget.RecyclerView; | ||
import android.util.AttributeSet; | ||
import android.view.View; | ||
|
||
/** | ||
* Created by SerG3z on 06.08.16. | ||
*/ | ||
|
||
public class AnimationAppearanceLayoutManager extends GridLayoutManager { | ||
|
||
public AnimationAppearanceLayoutManager(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { | ||
super(context, attrs, defStyleAttr, defStyleRes); | ||
} | ||
|
||
public AnimationAppearanceLayoutManager(Context context, int spanCount) { | ||
super(context, spanCount); | ||
} | ||
|
||
public AnimationAppearanceLayoutManager(Context context, int spanCount, int orientation, boolean reverseLayout) { | ||
super(context, spanCount, orientation, reverseLayout); | ||
} | ||
|
||
@Override | ||
public int scrollVerticallyBy(int dy, RecyclerView.Recycler recycler, RecyclerView.State state) { | ||
return super.scrollVerticallyBy(dy, recycler, state); | ||
|
||
} | ||
|
||
@Override | ||
public void removeAndRecycleView(View child, RecyclerView.Recycler recycler) { | ||
super.removeAndRecycleView(child, recycler); | ||
} | ||
|
||
@Override | ||
public void removeAndRecycleViewAt(int index, RecyclerView.Recycler recycler) { | ||
super.removeAndRecycleViewAt(index, recycler); | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
app/src/main/java/ru/yandex/yamblz/ui/fragments/AnimationAppearanceScrollListener.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,48 @@ | ||
package ru.yandex.yamblz.ui.fragments; | ||
|
||
import android.animation.ObjectAnimator; | ||
import android.support.v7.widget.GridLayoutManager; | ||
import android.support.v7.widget.RecyclerView; | ||
import android.view.View; | ||
|
||
/** | ||
* Created by user on 28.07.16. | ||
*/ | ||
|
||
class AnimationAppearanceScrollListener extends RecyclerView.OnScrollListener { | ||
|
||
private static final int DURATION = 1000; | ||
private static final int ROTATION = 360; | ||
|
||
private int tempFirstItemPosition; | ||
private int tempLastItemPosition; | ||
|
||
@Override | ||
public void onScrolled(RecyclerView recyclerView, int dx, int dy) { | ||
GridLayoutManager layoutManager = (GridLayoutManager) recyclerView.getLayoutManager(); | ||
int firstVisibleItemPosition = layoutManager.findFirstVisibleItemPosition(); | ||
int lastVisibleItemPosition = layoutManager.findLastVisibleItemPosition(); | ||
|
||
if (dy < 0 && tempFirstItemPosition != firstVisibleItemPosition) { | ||
onDrawAnimation(recyclerView, firstVisibleItemPosition, | ||
firstVisibleItemPosition + layoutManager.getSpanCount()); | ||
} | ||
if (dy > 0 && tempLastItemPosition != lastVisibleItemPosition) { | ||
onDrawAnimation(recyclerView, lastVisibleItemPosition - layoutManager.getSpanCount() + 1, | ||
lastVisibleItemPosition + 1); | ||
} | ||
|
||
tempFirstItemPosition = layoutManager.findFirstVisibleItemPosition(); | ||
tempLastItemPosition = layoutManager.findLastVisibleItemPosition(); | ||
} | ||
|
||
private void onDrawAnimation(RecyclerView recyclerView, int startPos, int endPos) { | ||
for (int i = startPos; i < endPos; i++) { | ||
ObjectAnimator.ofFloat( | ||
recyclerView.findViewHolderForAdapterPosition(i).itemView, | ||
View.ROTATION_X, 0, ROTATION) | ||
.setDuration(DURATION) | ||
.start(); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
а останавливать эту анимацию когда будешь?