Commit ee69b3ab authored by fallenstardust's avatar fallenstardust

添加点赞淡出动画

parent c01a66c5
...@@ -79,6 +79,7 @@ import cn.garymb.ygomobile.core.IrrlichtBridge; ...@@ -79,6 +79,7 @@ import cn.garymb.ygomobile.core.IrrlichtBridge;
import cn.garymb.ygomobile.deck_square.DeckManageDialog; import cn.garymb.ygomobile.deck_square.DeckManageDialog;
import cn.garymb.ygomobile.deck_square.DeckSquareApiUtil; import cn.garymb.ygomobile.deck_square.DeckSquareApiUtil;
import cn.garymb.ygomobile.deck_square.DeckSquareFileUtil; import cn.garymb.ygomobile.deck_square.DeckSquareFileUtil;
import cn.garymb.ygomobile.deck_square.api_response.BasicResponse;
import cn.garymb.ygomobile.deck_square.api_response.DownloadDeckResponse; import cn.garymb.ygomobile.deck_square.api_response.DownloadDeckResponse;
import cn.garymb.ygomobile.lite.R; import cn.garymb.ygomobile.lite.R;
import cn.garymb.ygomobile.loader.CardLoader; import cn.garymb.ygomobile.loader.CardLoader;
...@@ -133,6 +134,7 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte ...@@ -133,6 +134,7 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
private HomeActivity activity; private HomeActivity activity;
private String mDeckId; private String mDeckId;
private LinearLayout ll_click_like; private LinearLayout ll_click_like;
private TextView tv_add_1;
protected int screenWidth; protected int screenWidth;
...@@ -210,9 +212,28 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte ...@@ -210,9 +212,28 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
initBoomMenuButton(layoutView.findViewById(R.id.bmb)); initBoomMenuButton(layoutView.findViewById(R.id.bmb));
layoutView.findViewById(R.id.btn_nav_search).setOnClickListener((v) -> doMenu(R.id.action_search)); layoutView.findViewById(R.id.btn_nav_search).setOnClickListener((v) -> doMenu(R.id.action_search));
layoutView.findViewById(R.id.btn_nav_list).setOnClickListener((v) -> doMenu(R.id.action_card_list)); layoutView.findViewById(R.id.btn_nav_list).setOnClickListener((v) -> doMenu(R.id.action_card_list));
//只有当加载的是具有id的deck时才显示点赞按钮
tv_add_1 = layoutView.findViewById(R.id.tv_add_1);
ll_click_like = layoutView.findViewById(R.id.ll_click_like); ll_click_like = layoutView.findViewById(R.id.ll_click_like);
ll_click_like.setOnClickListener(v -> { ll_click_like.setOnClickListener(v -> {
if (mDeckId != null) {
VUiKit.defer().when(() -> {
BasicResponse result = DeckSquareApiUtil.likeDeck(mDeckId);
return result;
}).fail(e -> {
LogUtil.i(TAG, "Like deck fail" + e.getMessage());
YGOUtil.showTextToast("点赞失败");
}).done(data -> {
if (data != null && data.getMessage() != null && data.getMessage().equals("true")) {
// 显示点赞动画
tv_add_1.setText("+1");
ll_click_like.startAnimation(AnimationUtils.loadAnimation(getContext(), R.anim.fade_out));
ll_click_like.setVisibility(View.GONE); ll_click_like.setVisibility(View.GONE);
} else {
YGOUtil.showTextToast(data != null ? data.getMessage() : "点赞失败");
}
});
}
}); });
tv_deck.setOnClickListener(v -> { tv_deck.setOnClickListener(v -> {
new DeckManageDialog(this).show( new DeckManageDialog(this).show(
...@@ -1275,10 +1296,8 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte ...@@ -1275,10 +1296,8 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
if (deckData != null) { if (deckData != null) {
mDeckId = deckData.getDeckId(); mDeckId = deckData.getDeckId();
Log.w("seesee mDeckId", mDeckId); Log.w("seesee mDeckId", mDeckId);
if(mDeckId != null ) ll_click_like.setVisibility(View.VISIBLE);
deckData.getDeckYdk(); deckData.getDeckYdk();
String fileFullName = deckData.getDeckName() + ".ydk"; String fileFullName = deckData.getDeckName() + ".ydk";
// String path = AppsSettings.get().getDeckDir();
File dir = new File(getActivity().getApplicationInfo().dataDir, "cache"); File dir = new File(getActivity().getApplicationInfo().dataDir, "cache");
//将卡组存到cache缓存目录中 //将卡组存到cache缓存目录中
boolean result = DeckSquareFileUtil.saveFileToPath(dir.getPath(), fileFullName, deckData.getDeckYdk()); boolean result = DeckSquareFileUtil.saveFileToPath(dir.getPath(), fileFullName, deckData.getDeckYdk());
...@@ -1286,8 +1305,9 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte ...@@ -1286,8 +1305,9 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
LogUtil.i(TAG, "square deck detail done"); LogUtil.i(TAG, "square deck detail done");
//File file = new File(dir, fileFullName); //File file = new File(dir, fileFullName);
preLoadFile(dir.getPath() + "/" + fileFullName); preLoadFile(dir.getPath() + "/" + fileFullName);
tv_add_1.setText(R.string.like_deck_thumb);
ll_click_like.setVisibility(View.VISIBLE);
} }
} }
}); });
......
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="false">
<!-- 位移动画:从当前位置向上移动150dp -->
<translate
android:duration="1000"
android:fromYDelta="0"
android:toYDelta="-150dp"
android:interpolator="@android:anim/decelerate_interpolator" />
<!-- 透明度动画:从完全可见到完全透明 -->
<alpha
android:duration="1000"
android:fromAlpha="1.0"
android:toAlpha="0.0"
android:interpolator="@android:anim/accelerate_interpolator" />
<!-- 缩放动画:稍微缩小一点 -->
<scale
android:duration="1000"
android:fromXScale="1.0"
android:fromYScale="1.0"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="0.8"
android:toYScale="0.8"
android:interpolator="@android:anim/decelerate_interpolator" />
</set>
\ No newline at end of file
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="70dp" android:layout_height="wrap_content"
android:layout_gravity="bottom" android:layout_gravity="bottom"
android:layout_marginLeft="10dp" android:layout_marginLeft="10dp"
android:orientation="horizontal" android:orientation="horizontal"
...@@ -32,8 +32,9 @@ ...@@ -32,8 +32,9 @@
<LinearLayout <LinearLayout
android:id="@+id/tv_deckmanger" android:id="@+id/tv_deckmanger"
android:layout_width="0dp" android:layout_width="match_parent"
android:layout_height="@dimen/item_and_text_height" android:layout_height="wrap_content"
android:background="@drawable/dialogshort"
android:layout_weight="1" android:layout_weight="1"
android:gravity="center_vertical" android:gravity="center_vertical"
android:orientation="vertical" android:orientation="vertical"
...@@ -57,9 +58,9 @@ ...@@ -57,9 +58,9 @@
<LinearLayout <LinearLayout
android:id="@+id/ll_click_like" android:id="@+id/ll_click_like"
android:layout_width="match_parent" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@drawable/button_radius_red" android:background="@drawable/veil2"
android:visibility="gone" android:visibility="gone"
android:orientation="horizontal"> android:orientation="horizontal">
...@@ -67,11 +68,17 @@ ...@@ -67,11 +68,17 @@
android:layout_width="20dp" android:layout_width="20dp"
android:layout_height="20dp" android:layout_height="20dp"
android:layout_marginStart="5dp" android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
android:src="@drawable/baseline_thumb_up_24"/> android:src="@drawable/baseline_thumb_up_24"/>
<TextView <TextView
android:layout_width="match_parent" android:id="@+id/tv_add_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:layout_weight="1"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp" android:layout_marginEnd="5dp"
android:textColor="@color/white" android:textColor="@color/white"
android:text="@string/like_deck_thumb"/> android:text="@string/like_deck_thumb"/>
...@@ -84,13 +91,13 @@ ...@@ -84,13 +91,13 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginTop="2dp" android:layout_marginTop="2dp"
android:background="@drawable/button_radius_black_transparents"
android:ellipsize="end" android:ellipsize="end"
android:gravity="center|left" android:gravity="center|left"
android:maxLines="1" android:maxLines="1"
android:paddingStart="5dp" android:paddingStart="5dp"
android:paddingEnd="5dp" android:paddingEnd="5dp"
android:shadowColor="@color/black" android:shadowColor="@color/black"
android:background="@drawable/button_radius_black_transparents"
android:shadowDx="1" android:shadowDx="1"
android:shadowDy="1" android:shadowDy="1"
android:shadowRadius="2" android:shadowRadius="2"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment