-
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
@dSukmanova Сукманова Дарья #9
Open
dmikheeva
wants to merge
10
commits into
yamblz-native:master
Choose a base branch
from
dmikheeva: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
10 commits
Select commit
Hold shift + click to select a range
cd1ecb5
change gradle version
dmikheeva c7216e3
simple swipe to dismiss
dmikheeva 4b5d661
simple move event
dmikheeva 8815402
change background color from white to red
dmikheeva bde78fb
add menu
dmikheeva fa13dbe
add borders on/off mode
dmikheeva dc63d3a
refactoring + fix borders mode on configuration change
dmikheeva 88c951f
add green circles on two last swaped items
dmikheeva dcd0da6
add columns number change
dmikheeva 2a091e2
save columns number for configuration change
dmikheeva 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
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
56 changes: 56 additions & 0 deletions
56
app/src/main/java/ru/yandex/yamblz/ui/fragments/ItemsChangedDecorator.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,56 @@ | ||
package ru.yandex.yamblz.ui.fragments; | ||
|
||
import android.graphics.Canvas; | ||
import android.graphics.Color; | ||
import android.graphics.Paint; | ||
import android.support.v7.widget.RecyclerView; | ||
import android.view.View; | ||
|
||
/** | ||
* Created by dsukmanova on 31.07.16. | ||
*/ | ||
|
||
public class ItemsChangedDecorator extends RecyclerView.ItemDecoration { | ||
private int fromPos = -1; | ||
private int toPos = -1; | ||
private int CIRCLE_RADIUS = 15; | ||
private int CIRCLE_OFFSET = 30; | ||
|
||
private Paint paint; | ||
|
||
ItemsChangedDecorator() { | ||
paint = new Paint(); | ||
paint.setColor(Color.GREEN); | ||
paint.setStyle(Paint.Style.STROKE); | ||
paint.setStrokeWidth(6); | ||
} | ||
|
||
public void setFromPos(int fromPos) { | ||
this.fromPos = fromPos; | ||
} | ||
|
||
public void setToPos(int toPos) { | ||
this.toPos = toPos; | ||
} | ||
|
||
@Override | ||
public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) { | ||
if (fromPos > -1) { | ||
RecyclerView.LayoutManager layoutManager = parent.getLayoutManager(); | ||
|
||
View child = layoutManager.findViewByPosition(fromPos); | ||
if (child != null) { | ||
drawCircle(c, layoutManager, child); | ||
} | ||
child = layoutManager.findViewByPosition(toPos); | ||
if (child != null) { | ||
drawCircle(c, layoutManager, child); | ||
} | ||
} | ||
} | ||
|
||
private void drawCircle(Canvas c, RecyclerView.LayoutManager lm, View child) { | ||
int heigth = Math.abs(lm.getDecoratedTop(child) - lm.getDecoratedBottom(child)); | ||
c.drawCircle(lm.getDecoratedRight(child) - CIRCLE_OFFSET, lm.getDecoratedTop(child) + heigth / 2, CIRCLE_RADIUS, paint); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
app/src/main/java/ru/yandex/yamblz/ui/fragments/MyItemDecoration.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.graphics.Canvas; | ||
import android.graphics.Color; | ||
import android.graphics.Paint; | ||
import android.support.v7.widget.RecyclerView; | ||
import android.view.View; | ||
|
||
/** | ||
* Created by dsukmanova on 31.07.16. | ||
*/ | ||
|
||
public class MyItemDecoration extends RecyclerView.ItemDecoration { | ||
private int offset; | ||
Paint paint; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. =( |
||
|
||
MyItemDecoration(int offset) { | ||
this.offset = offset; | ||
this.paint = new Paint(); | ||
this.paint.setColor(Color.WHITE); | ||
paint.setStyle(Paint.Style.STROKE); | ||
paint.setStrokeWidth(2 * offset); | ||
} | ||
|
||
@Override | ||
public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) { | ||
int count = parent.getChildCount(); | ||
RecyclerView.LayoutManager layoutManager = parent.getLayoutManager(); | ||
for (int i = 0; i < count; i++) { | ||
View child = parent.getChildAt(i); | ||
int position = parent.getChildAdapterPosition(child); | ||
if (position % 2 == 0) { | ||
c.drawRect(layoutManager.getDecoratedLeft(child) + offset, | ||
layoutManager.getDecoratedTop(child) + offset, | ||
layoutManager.getDecoratedRight(child) - offset, | ||
layoutManager.getDecoratedBottom(child) - offset, | ||
paint | ||
); | ||
} | ||
} | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
app/src/main/java/ru/yandex/yamblz/ui/fragments/MyItemTochHelperCallback.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,71 @@ | ||
package ru.yandex.yamblz.ui.fragments; | ||
|
||
import android.graphics.Canvas; | ||
import android.graphics.Color; | ||
import android.graphics.Paint; | ||
import android.support.v7.widget.RecyclerView; | ||
import android.support.v7.widget.helper.ItemTouchHelper; | ||
import android.view.View; | ||
|
||
|
||
/** | ||
* Created by dsukmanova on 31.07.16. | ||
*/ | ||
|
||
public class MyItemTochHelperCallback extends ItemTouchHelper.Callback { | ||
MyItemTouchHelperAdapter myItemTouchHelperAdapter; | ||
ItemsChangedDecorator itemsChangedDecorator; | ||
|
||
MyItemTochHelperCallback(MyItemTouchHelperAdapter myItemTouchHelperAdapter) { | ||
this.myItemTouchHelperAdapter = myItemTouchHelperAdapter; | ||
} | ||
|
||
MyItemTochHelperCallback(MyItemTouchHelperAdapter myItemTouchHelperAdapter,ItemsChangedDecorator decorator) { | ||
this.myItemTouchHelperAdapter = myItemTouchHelperAdapter; | ||
this.itemsChangedDecorator = decorator; | ||
} | ||
|
||
@Override | ||
public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { | ||
int moveFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN; | ||
int swipeFlags = ItemTouchHelper.RIGHT; | ||
return makeMovementFlags(moveFlags, swipeFlags); | ||
} | ||
|
||
@Override | ||
public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) { | ||
myItemTouchHelperAdapter.onItemMove(viewHolder.getAdapterPosition(), target.getAdapterPosition()); | ||
return true; | ||
} | ||
|
||
@Override | ||
public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) { | ||
int position = viewHolder.getAdapterPosition(); | ||
myItemTouchHelperAdapter.onItemDissmiss(position); | ||
} | ||
|
||
@Override | ||
public void onChildDraw(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) { | ||
super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive); | ||
if (actionState == ItemTouchHelper.ACTION_STATE_SWIPE) { | ||
View itemView = viewHolder.itemView; | ||
int itemViewWidth = itemView.getWidth(); | ||
Paint paint = new Paint(); | ||
paint.setColor(Color.RED); | ||
int maxAlpha = 255; | ||
double kAlpha = 0.75; | ||
paint.setAlpha(Math.min(maxAlpha, (int) (kAlpha * maxAlpha * Math.abs(dX) / itemViewWidth))); | ||
float rectLeft = dX > 0 ? itemView.getLeft() : (itemView.getLeft() + dX); | ||
float rectRight = dX > 0 ? dX : itemView.getRight(); | ||
c.drawRect(rectLeft, itemView.getTop(), rectRight, itemView.getBottom(), paint); | ||
|
||
} | ||
} | ||
|
||
@Override | ||
public void onMoved(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, int fromPos, RecyclerView.ViewHolder target, int toPos, int x, int y) { | ||
super.onMoved(recyclerView, viewHolder, fromPos, target, toPos, x, y); | ||
itemsChangedDecorator.setFromPos(fromPos); | ||
itemsChangedDecorator.setToPos(toPos); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
app/src/main/java/ru/yandex/yamblz/ui/fragments/MyItemTouchHelperAdapter.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,11 @@ | ||
package ru.yandex.yamblz.ui.fragments; | ||
|
||
/** | ||
* Created by dsukmanova on 31.07.16. | ||
*/ | ||
|
||
public interface MyItemTouchHelperAdapter { | ||
void onItemDissmiss(int position); | ||
|
||
void onItemMove(int fromPosition, int toPosition); | ||
} |
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,9 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<menu xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<item android:title="Рамки вкл./выкл." | ||
android:id="@+id/borders"/> | ||
<item android:title="Колонки +1" | ||
android:id="@+id/plusColumns"/> | ||
<item android:title="Колонки -1" | ||
android:id="@+id/minusColumns"/> | ||
</menu> |
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
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.
значение в пикселях приводит к раку чешуи