Commit 00cc6945 authored by fallenstardust's avatar fallenstardust

分段处理,onCreate预加载好卡片信息数组

parent 10b62798
...@@ -161,12 +161,12 @@ public class YGOStarter { ...@@ -161,12 +161,12 @@ public class YGOStarter {
//显示加载背景 //显示加载背景
showLoadingBg(activity); showLoadingBg(activity);
Log.e("YGOStarter", "设置背景后" + System.currentTimeMillis()); Log.e("YGOStarter", "设置背景后" + System.currentTimeMillis());
if (!ComponentUtils.isActivityRunning(activity, new ComponentName(activity, YGOMobileActivity.class))) { /* if (!ComponentUtils.isActivityRunning(activity, new ComponentName(activity, YGOMobileActivity.class))) {
String[] tipsList = activity.getResources().getStringArray(R.array.tips); String[] tipsList = activity.getResources().getStringArray(R.array.tips);
int x = (int) (Math.random() * tipsList.length); int x = (int) (Math.random() * tipsList.length);
String tips = tipsList[x]; String tips = tipsList[x];
Toast.makeText(activity, tips, Toast.LENGTH_LONG).show(); Toast.makeText(activity, tips, Toast.LENGTH_LONG).show();
} }*/
} }
Intent intent = new Intent(activity, YGOMobileActivity.class); Intent intent = new Intent(activity, YGOMobileActivity.class);
if (options != null) { if (options != null) {
......
...@@ -264,13 +264,13 @@ public class ImageLoader implements Closeable { ...@@ -264,13 +264,13 @@ public class ImageLoader implements Closeable {
} }
} }
} }
} }/*
if (!bind) { if (!bind) {
if (Constants.NETWORK_IMAGE && NetUtils.isWifiConnected(imageview.getContext())) { if (Constants.NETWORK_IMAGE && NetUtils.isWifiConnected(imageview.getContext())) {
bind(String.format(Constants.IMAGE_URL, "" + code), imageview, code, pre, isBig); bind(String.format(Constants.IMAGE_URL, "" + code), imageview, code, pre, isBig);
} else { } else {
imageview.setImageResource(R.drawable.unknown); imageview.setImageResource(R.drawable.unknown);
} }
} }*/
} }
} }
...@@ -24,6 +24,7 @@ import ocgcore.enums.CardType; ...@@ -24,6 +24,7 @@ import ocgcore.enums.CardType;
import static android.view.View.inflate; import static android.view.View.inflate;
public class CardDetailRandom { public class CardDetailRandom {
private static ThreeDLayoutUtil viewCardDetail;
private static ImageView cardImage; private static ImageView cardImage;
private static TextView name; private static TextView name;
private static TextView desc; private static TextView desc;
...@@ -33,23 +34,18 @@ public class CardDetailRandom { ...@@ -33,23 +34,18 @@ public class CardDetailRandom {
private static TextView cardAtk; private static TextView cardAtk;
private static TextView cardDef; private static TextView cardDef;
private static TextView attrView; private static TextView attrView;
private static View linkArrow;
private static View monsterlayout; private static View monsterlayout;
private static View layout_detail_p_scale;
private static View atkdefView; private static View atkdefView;
private static TextView detail_cardscale;
private static CardManager mCardManager;
private static ImageLoader imageLoader; private static ImageLoader imageLoader;
private static StringManager mStringManager; private static StringManager mStringManager;
private static SparseArray<Card> cards;
private static View view;
public static void RandomCardDetail(BaseActivity context, Card cardInfo) { public static void RandomCardDetail(Context context, Card cardInfo) {
ThreeDLayoutUtil viewCardDetail = (ThreeDLayoutUtil) inflate(context, R.layout.dialog_cardinfo_small, null); imageLoader = ImageLoader.get(context);
viewCardDetail = (ThreeDLayoutUtil) inflate(context, R.layout.dialog_cardinfo_small, null);
cardImage = viewCardDetail.findViewById(R.id.card_image_toast); cardImage = viewCardDetail.findViewById(R.id.card_image_toast);
name = viewCardDetail.findViewById(R.id.card_name_toast); name = viewCardDetail.findViewById(R.id.card_name_toast);
monsterlayout = viewCardDetail.findViewById(R.id.star_attr_race_toast);
level = viewCardDetail.findViewById(R.id.card_level_toast); level = viewCardDetail.findViewById(R.id.card_level_toast);
linkArrow = viewCardDetail.findViewById(R.id.link_arrows_toast);
race = viewCardDetail.findViewById(R.id.card_race_toast); race = viewCardDetail.findViewById(R.id.card_race_toast);
attrView = viewCardDetail.findViewById(R.id.card_attr_toast); attrView = viewCardDetail.findViewById(R.id.card_attr_toast);
type = viewCardDetail.findViewById(R.id.card_type_toast); type = viewCardDetail.findViewById(R.id.card_type_toast);
...@@ -58,13 +54,9 @@ public class CardDetailRandom { ...@@ -58,13 +54,9 @@ public class CardDetailRandom {
atkdefView = viewCardDetail.findViewById(R.id.layout_atkdef2_toast); atkdefView = viewCardDetail.findViewById(R.id.layout_atkdef2_toast);
desc = viewCardDetail.findViewById(R.id.text_desc_toast); desc = viewCardDetail.findViewById(R.id.text_desc_toast);
layout_detail_p_scale = viewCardDetail.findViewById(R.id.detail_p_scale);
detail_cardscale = viewCardDetail.findViewById(R.id.detail_cardscale);
if (cardInfo == null) return; if (cardInfo == null) return;
mStringManager = DataManager.get().getStringManager(); mStringManager = DataManager.get().getStringManager();
imageLoader = ImageLoader.get(context); imageLoader.bindImage(cardImage, cardInfo.Code);
imageLoader.bindImage(cardImage, cardInfo.Code, null, true);
name.setText(cardInfo.Name); name.setText(cardInfo.Name);
type.setText(CardUtils.getAllTypeString(cardInfo, mStringManager).replace("/", "|")); type.setText(CardUtils.getAllTypeString(cardInfo, mStringManager).replace("/", "|"));
attrView.setText(mStringManager.getAttributeString(cardInfo.Attribute)); attrView.setText(mStringManager.getAttributeString(cardInfo.Attribute));
...@@ -86,21 +78,19 @@ public class CardDetailRandom { ...@@ -86,21 +78,19 @@ public class CardDetailRandom {
//连接怪兽设置 //连接怪兽设置
if (cardInfo.isType(CardType.Link)) { if (cardInfo.isType(CardType.Link)) {
level.setVisibility(View.GONE); level.setVisibility(View.GONE);
linkArrow.setVisibility(View.VISIBLE);
cardDef.setText((cardInfo.getStar() < 0 ? "?" : "LINK-" + String.valueOf(cardInfo.getStar()))); cardDef.setText((cardInfo.getStar() < 0 ? "?" : "LINK-" + String.valueOf(cardInfo.getStar())));
BaseActivity.showLinkArrows(cardInfo, view);
} else { } else {
level.setVisibility(View.VISIBLE); level.setVisibility(View.VISIBLE);
linkArrow.setVisibility(View.GONE);
cardDef.setText((cardInfo.Defense < 0 ? "?" : String.valueOf(cardInfo.Defense))); cardDef.setText((cardInfo.Defense < 0 ? "?" : String.valueOf(cardInfo.Defense)));
} }
race.setText(mStringManager.getRaceString(cardInfo.Race)); race.setText(mStringManager.getRaceString(cardInfo.Race));
} else { } else {
atkdefView.setVisibility(View.GONE); atkdefView.setVisibility(View.GONE);
race.setVisibility(View.GONE); monsterlayout.setVisibility(View.GONE);
level.setVisibility(View.GONE);
linkArrow.setVisibility(View.GONE);
} }
}
public static void showRandromCardDetailToast(Context context) {
Toast toast = new Toast(context); Toast toast = new Toast(context);
toast.setView(viewCardDetail); toast.setView(viewCardDetail);
toast.setDuration(Toast.LENGTH_LONG); toast.setDuration(Toast.LENGTH_LONG);
......
...@@ -80,7 +80,6 @@ import cn.garymb.ygomobile.utils.PayUtils; ...@@ -80,7 +80,6 @@ import cn.garymb.ygomobile.utils.PayUtils;
import cn.garymb.ygomobile.utils.ScreenUtil; import cn.garymb.ygomobile.utils.ScreenUtil;
import cn.garymb.ygomobile.utils.YGOUtil; import cn.garymb.ygomobile.utils.YGOUtil;
import ocgcore.CardManager; import ocgcore.CardManager;
import ocgcore.DataManager;
import ocgcore.data.Card; import ocgcore.data.Card;
import static cn.garymb.ygomobile.Constants.ASSET_SERVER_LIST; import static cn.garymb.ygomobile.Constants.ASSET_SERVER_LIST;
...@@ -104,6 +103,7 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie ...@@ -104,6 +103,7 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home); setContentView(R.layout.activity_home);
setExitAnimEnable(false); setExitAnimEnable(false);
mCardManager = new CardManager(AppsSettings.get().getDataBaseFile().getAbsolutePath(), null);
mServerList = $(R.id.list_server); mServerList = $(R.id.list_server);
mServerListAdapter = new ServerListAdapter(this); mServerListAdapter = new ServerListAdapter(this);
//server list //server list
...@@ -122,6 +122,7 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie ...@@ -122,6 +122,7 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie
AnimationShake(); AnimationShake();
tv = (ShimmerTextView) findViewById(R.id.shimmer_tv); tv = (ShimmerTextView) findViewById(R.id.shimmer_tv);
toggleAnimation(tv); toggleAnimation(tv);
setRandomCardDetail();
QbSdk.PreInitCallback cb = new QbSdk.PreInitCallback() { QbSdk.PreInitCallback cb = new QbSdk.PreInitCallback() {
@Override @Override
...@@ -154,6 +155,7 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie ...@@ -154,6 +155,7 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie
@Override @Override
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
setRandomCardDetail();
BacktoDuel(); BacktoDuel();
} }
...@@ -314,6 +316,7 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie ...@@ -314,6 +316,7 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie
} }
break; break;
case R.id.action_game: case R.id.action_game:
CardDetailRandom.showRandromCardDetailToast(this);
openGame(); openGame();
break; break;
case R.id.action_settings: { case R.id.action_settings: {
...@@ -656,10 +659,15 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie ...@@ -656,10 +659,15 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie
} }
public void setRandomCardDetail() { public void setRandomCardDetail() {
mCardManager = DataManager.get().getCardManager(); //加载数据库中所有卡片卡片
mCardManager.loadCards();
//mCardManager = DataManager.get().getCardManager();
cards = mCardManager.getAllCards(); cards = mCardManager.getAllCards();
int y = (int) (Math.random() * cards.size()); int y = (int) (Math.random() * cards.size());
Card cardinfo = cards.valueAt(y); Card cardInfo = cards.valueAt(y);
CardDetailRandom.RandomCardDetail(this, cardinfo); if (cardInfo == null) {
Toast.makeText(this, "code为空", Toast.LENGTH_LONG).show();
}
CardDetailRandom.RandomCardDetail(this, cardInfo);
} }
} }
...@@ -42,7 +42,6 @@ import static cn.garymb.ygomobile.Constants.NETWORK_IMAGE; ...@@ -42,7 +42,6 @@ import static cn.garymb.ygomobile.Constants.NETWORK_IMAGE;
import static cn.garymb.ygomobile.Constants.ORI_DECK; import static cn.garymb.ygomobile.Constants.ORI_DECK;
import static cn.garymb.ygomobile.Constants.ORI_PICS; import static cn.garymb.ygomobile.Constants.ORI_PICS;
import static cn.garymb.ygomobile.Constants.ORI_REPLAY; import static cn.garymb.ygomobile.Constants.ORI_REPLAY;
import static cn.garymb.ygomobile.Constants.ORI_TEXTURES;
import static cn.garymb.ygomobile.ui.home.ResCheckTask.ResCheckListener; import static cn.garymb.ygomobile.ui.home.ResCheckTask.ResCheckListener;
import static cn.garymb.ygomobile.ui.home.ResCheckTask.getDatapath; import static cn.garymb.ygomobile.ui.home.ResCheckTask.getDatapath;
......
...@@ -26,8 +26,7 @@ ...@@ -26,8 +26,7 @@
android:layout_centerHorizontal="true" android:layout_centerHorizontal="true"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:scaleType="fitXY" android:scaleType="fitXY"/>
tools:src="@drawable/unknown" />
</RelativeLayout> </RelativeLayout>
<LinearLayout <LinearLayout
...@@ -116,17 +115,12 @@ ...@@ -116,17 +115,12 @@
tools:text="Card Name" /> tools:text="Card Name" />
<LinearLayout <LinearLayout
android:id="@+id/star_attr_race_scale_toast" android:id="@+id/star_attr_race_toast"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:gravity="center_horizontal" android:gravity="center_horizontal"
android:orientation="horizontal"> android:orientation="horizontal">
<include
android:id="@+id/link_arrows_toast"
layout="@layout/item_linkmaker_small"
android:visibility="gone" />
<TextView <TextView
android:id="@+id/card_level_toast" android:id="@+id/card_level_toast"
android:layout_width="wrap_content" android:layout_width="wrap_content"
......
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