Commit a3d9d3fa authored by fallenstardust's avatar fallenstardust

完善和实现连接标记显示

fix箭头上下颠倒
parent 486be731
...@@ -93,6 +93,40 @@ public class CardDetail extends BaseAdapterPlus.BaseViewHolder { ...@@ -93,6 +93,40 @@ public class CardDetail extends BaseAdapterPlus.BaseViewHolder {
private boolean isDownloadCardImage = true; private boolean isDownloadCardImage = true;
private CallBack mCallBack; private CallBack mCallBack;
public static int[] enImgs = new int[]{
R.drawable.left_top_1,
R.drawable.top_1,
R.drawable.right_top_1,
R.drawable.left_1,
0,
R.drawable.right_1,
R.drawable.left_bottom_1,
R.drawable.bottom_1,
R.drawable.right_bottom_1,
};
public static int[] disImgs = new int[]{
R.drawable.left_top_0,
R.drawable.top_0,
R.drawable.right_top_0,
R.drawable.left_0,
0,
R.drawable.right_0,
R.drawable.left_bottom_0,
R.drawable.bottom_0,
R.drawable.right_bottom_0,
};
public static int[] ids = new int[]{
R.id.iv_7,
R.id.iv_8,
R.id.iv_9,
R.id.iv_4,
0,
R.id.iv_6,
R.id.iv_1,
R.id.iv_2,
R.id.iv_3,
};
public interface CallBack { public interface CallBack {
void onSearchStart(); void onSearchStart();
...@@ -266,7 +300,7 @@ public class CardDetail extends BaseAdapterPlus.BaseViewHolder { ...@@ -266,7 +300,7 @@ public class CardDetail extends BaseAdapterPlus.BaseViewHolder {
curPosition = position; curPosition = position;
mProvider = provider; mProvider = provider;
if (cardInfo != null) { if (cardInfo != null) {
setCardInfo(cardInfo); setCardInfo(cardInfo, view);
} }
} }
...@@ -282,41 +316,9 @@ public class CardDetail extends BaseAdapterPlus.BaseViewHolder { ...@@ -282,41 +316,9 @@ public class CardDetail extends BaseAdapterPlus.BaseViewHolder {
return mCardInfo; return mCardInfo;
} }
private void setCardInfo(Card cardInfo) { private void setCardInfo(Card cardInfo, View view) {
if (cardInfo == null) return; if (cardInfo == null) return;
int[] enImgs = new int[]{
R.drawable.left_bottom_1,
R.drawable.bottom_1,
R.drawable.right_bottom_1,
R.drawable.left_1,
0,
R.drawable.right_1,
R.drawable.left_top_1,
R.drawable.top_1,
R.drawable.right_top_1,
};
int[] disImgs = new int[]{
R.drawable.left_bottom_0,
R.drawable.bottom_0,
R.drawable.right_bottom_0,
R.drawable.left_0,
0,
R.drawable.right_0,
R.drawable.left_top_0,
R.drawable.top_0,
R.drawable.right_top_0,
};
int[] ids = new int[]{
R.id.iv_1,
R.id.iv_2,
R.id.iv_3,
R.id.iv_4,
R.id.iv_6,
R.id.iv_7,
R.id.iv_8,
R.id.iv_9,
};
View linkarrow = new View(mContext);
mCardInfo = cardInfo; mCardInfo = cardInfo;
imageLoader.bindImage(cardImage, cardInfo.Code, null, true); imageLoader.bindImage(cardImage, cardInfo.Code, null, true);
dialog = DialogUtils.getdx(context); dialog = DialogUtils.getdx(context);
...@@ -382,17 +384,10 @@ public class CardDetail extends BaseAdapterPlus.BaseViewHolder { ...@@ -382,17 +384,10 @@ public class CardDetail extends BaseAdapterPlus.BaseViewHolder {
level.setTextColor(context.getResources().getColor(R.color.star)); level.setTextColor(context.getResources().getColor(R.color.star));
} }
cardAtk.setText((cardInfo.Attack < 0 ? "?" : String.valueOf(cardInfo.Attack))); cardAtk.setText((cardInfo.Attack < 0 ? "?" : String.valueOf(cardInfo.Attack)));
//连接怪兽设置
if (cardInfo.isType(CardType.Link)) { if (cardInfo.isType(CardType.Link)) {
cardDef.setText((cardInfo.getStar() < 0 ? "?" : "LINK-" + String.valueOf(cardInfo.getStar()))); cardDef.setText((cardInfo.getStar() < 0 ? "?" : "LINK-" + String.valueOf(cardInfo.getStar())));
String LineKey = String.valueOf(cardInfo.Defense); showLinkArrows(cardInfo, view);
for (int i = 0; i < 9; i++) {
String arrow = String.valueOf(LineKey.indexOf(i));
if (arrow.equals("1")) {
linkarrow.findViewById(ids[i]).setBackgroundResource(enImgs[i]);
} else {
linkarrow.findViewById(ids[i]).setBackgroundResource(disImgs[i]);
}
}
} else { } else {
cardDef.setText((cardInfo.Defense < 0 ? "?" : String.valueOf(cardInfo.Defense))); cardDef.setText((cardInfo.Defense < 0 ? "?" : String.valueOf(cardInfo.Defense)));
} }
...@@ -402,6 +397,22 @@ public class CardDetail extends BaseAdapterPlus.BaseViewHolder { ...@@ -402,6 +397,22 @@ public class CardDetail extends BaseAdapterPlus.BaseViewHolder {
race.setVisibility(View.GONE); race.setVisibility(View.GONE);
monsterlayout.setVisibility(View.GONE); monsterlayout.setVisibility(View.GONE);
level.setVisibility(View.GONE); level.setVisibility(View.GONE);
linkArrow.setVisibility(View.GONE);
}
}
public void showLinkArrows(Card cardInfo, View view){
String lk = Integer.toBinaryString(cardInfo.Defense);
String Linekey = String.format("%09d", Integer.parseInt(lk));
for (int i = 0; i < ids.length; i++) {
String arrow = Linekey.substring(i, i + 1);
if (i != 4) {
if ("1".equals(arrow)) {
view.findViewById(ids[i]).setBackgroundResource(enImgs[i]);
} else {
view.findViewById(ids[i]).setBackgroundResource(disImgs[i]);
}
}
} }
} }
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="26dp"
android:layout_height="26dp"
android:gravity="center_vertical"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/iv_7"
android:layout_width="7dp"
android:layout_height="7dp"
android:background="@drawable/left_top_0"
android:visibility="visible" />
<ImageView
android:id="@+id/iv_8"
android:layout_width="12dp"
android:layout_height="5dp"
android:background="@drawable/top_0"
android:visibility="visible" />
<ImageView
android:id="@+id/iv_9"
android:layout_width="7dp"
android:layout_height="7dp"
android:background="@drawable/right_top_0"
android:visibility="visible" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="horizontal">
<ImageView
android:id="@+id/iv_4"
android:layout_width="5dp"
android:layout_height="12dp"
android:background="@drawable/left_0"
android:visibility="visible" />
<View
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_weight="1" />
<ImageView
android:id="@+id/iv_6"
android:layout_width="5dp"
android:layout_height="12dp"
android:background="@drawable/right_0"
android:visibility="visible" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/iv_1"
android:layout_width="7dp"
android:layout_height="7dp"
android:background="@drawable/left_bottom_0"
android:visibility="visible" />
<ImageView
android:id="@+id/iv_2"
android:layout_width="12dp"
android:layout_height="5dp"
android:layout_gravity="bottom"
android:background="@drawable/bottom_0"
android:visibility="visible" />
<ImageView
android:id="@+id/iv_3"
android:layout_width="7dp"
android:layout_height="7dp"
android:background="@drawable/right_bottom_0" />
</LinearLayout>
</LinearLayout>
\ No newline at end of file
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