解决循环获取platform的bug
This commit is contained in:
@ -65,6 +65,7 @@ import com.gh.gamecenter.manager.DataCollectionManager;
|
||||
import com.gh.gamecenter.manager.PackageManager;
|
||||
import com.tendcloud.tenddata.TCAgent;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@ -207,6 +208,8 @@ public class DownloadDialog {
|
||||
.findViewById(R.id.dialog_ll_hint);
|
||||
viewPager = (ViewPager) contentView.findViewById(R.id.dialog_viewPager);
|
||||
|
||||
isLoadPlatform = false;
|
||||
|
||||
init(new ArrayList<ApkEntity>(gameApk));
|
||||
|
||||
viewPager.addOnPageChangeListener(new OnPageChangeListener() {
|
||||
@ -295,6 +298,8 @@ public class DownloadDialog {
|
||||
DownloadManager.getInstance(context).addObserver(dataWatcher);
|
||||
}
|
||||
|
||||
private boolean isLoadPlatform;
|
||||
|
||||
private void init(List<ApkEntity> apkList) {
|
||||
for (int i = 0; i < apkList.size(); i++) {
|
||||
String platformName = PlatformUtils.getInstance(context)
|
||||
@ -302,6 +307,11 @@ public class DownloadDialog {
|
||||
if (platformName == null) {
|
||||
apkList.remove(i);
|
||||
i--;
|
||||
if (!isLoadPlatform) {
|
||||
Utils.log("load platform");
|
||||
PlatformUtils.getInstance(context).getPlatform();
|
||||
isLoadPlatform = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -334,7 +344,13 @@ public class DownloadDialog {
|
||||
}
|
||||
}
|
||||
|
||||
int currentItem = 0;
|
||||
if (viewPager != null) {
|
||||
currentItem = viewPager.getCurrentItem();
|
||||
}
|
||||
Utils.log("currentItem = " + currentItem);
|
||||
viewPager.setAdapter(new PlatformAdapter(apkList));
|
||||
viewPager.setCurrentItem(currentItem);
|
||||
}
|
||||
|
||||
private ArrayList<ApkEntity> sortApk(String gameId, List<ApkEntity> apkList) {
|
||||
@ -423,7 +439,6 @@ public class DownloadDialog {
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
|
||||
return (int) Math.ceil(platforms.size() / (double) (row * column));
|
||||
}
|
||||
|
||||
@ -465,7 +480,6 @@ public class DownloadDialog {
|
||||
|
||||
@Override
|
||||
public void destroyItem(ViewGroup container, int position, Object object) {
|
||||
|
||||
container.removeView((View) object);
|
||||
object = null;
|
||||
}
|
||||
@ -1070,7 +1084,7 @@ public class DownloadDialog {
|
||||
} else {
|
||||
String path = PlatformUtils.getInstance(context)
|
||||
.getPlatformPicPath(apkEntity.getPlatform());
|
||||
if (path != null) {
|
||||
if (path != null && new File(path).exists()) {
|
||||
viewHolder.download_item_iv_pic
|
||||
.setVisibility(View.VISIBLE);
|
||||
ImageUtils.getInstance(context).display(
|
||||
|
||||
Reference in New Issue
Block a user