1、统一了entrance

2、统一了部分跳转intent,传参返回intent
3、修改出dialogfragment
4、clipboardmanager等处理
This commit is contained in:
CsHeng
2017-05-17 18:18:46 +08:00
parent 6d4de6795e
commit 4c762a1aa8
108 changed files with 1470 additions and 1099 deletions

View File

@ -4,45 +4,24 @@ import android.content.Context;
import android.content.SharedPreferences;
import android.support.v4.view.ViewPager;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.View;
import android.view.*;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.*;
import android.widget.LinearLayout.LayoutParams;
import android.widget.PopupWindow;
import android.widget.TextView;
import com.gh.common.constant.Config;
import com.gh.common.util.DisplayUtils;
import com.gh.common.util.PackageUtils;
import com.gh.common.util.PlatformUtils;
import com.gh.common.util.Utils;
import com.gh.download.DataWatcher;
import com.gh.download.DownloadEntity;
import com.gh.download.DownloadManager;
import com.gh.download.DownloadStatus;
import com.gh.common.util.*;
import com.gh.download.*;
import com.gh.gamecenter.R;
import com.gh.gamecenter.adapter.PlatformPagerAdapter;
import com.gh.gamecenter.entity.ApkEntity;
import com.gh.gamecenter.entity.GameCollectionEntity;
import com.gh.gamecenter.entity.GameEntity;
import com.gh.gamecenter.eventbus.EBDownloadStatus;
import com.gh.gamecenter.eventbus.EBPackage;
import com.gh.gamecenter.eventbus.EBReuse;
import com.gh.gamecenter.entity.*;
import com.gh.gamecenter.eventbus.*;
import com.gh.gamecenter.listener.OnCollectionCallBackListener;
import com.gh.gamecenter.manager.PackageManager;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import de.greenrobot.event.EventBus;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
/**
* @author 温冠超
* @email 294299195@qq.com
@ -54,7 +33,7 @@ public class DownloadDialog implements OnCollectionCallBackListener {
private static DownloadDialog instance;
private Context context;
private Context mContext;
private boolean isShow;
private PopupWindow popupWindow;
@ -70,7 +49,7 @@ public class DownloadDialog implements OnCollectionCallBackListener {
@Override
public void onDataChanged(DownloadEntity downloadEntity) {
if (downloadEntity.getName().equals(gameEntity.getName())
&& !"delete".equals(DownloadManager.getInstance(context).getStatus(downloadEntity.getUrl()))) {
&& !"delete".equals(DownloadManager.getInstance(mContext).getStatus(downloadEntity.getUrl()))) {
adapter.putDownloadEntity(downloadEntity);
@ -88,14 +67,17 @@ public class DownloadDialog implements OnCollectionCallBackListener {
private boolean isLoadPlatform;
private DownloadDialog() {
}
private DownloadDialog(Context context) {
mContext = context;
isShow = false;
}
public static DownloadDialog getInstance(Context context) {
if (instance == null) {
instance = new DownloadDialog();
instance = new DownloadDialog(context);
}
instance.context = context;
return instance;
}
@ -113,7 +95,7 @@ public class DownloadDialog implements OnCollectionCallBackListener {
this.entrance = entrance;
this.location = location;
SharedPreferences sp = context.getSharedPreferences(Config.PREFERENCE, Context.MODE_PRIVATE);
SharedPreferences sp = mContext.getSharedPreferences(Config.PREFERENCE, Context.MODE_PRIVATE);
row = sp.getInt("download_box_row", 3);
column = sp.getInt("download_box_column", 3);
@ -124,7 +106,7 @@ public class DownloadDialog implements OnCollectionCallBackListener {
}
// 一个自定义的布局,作为显示的内容
View contentView = View.inflate(context, R.layout.game_download_dialog, null);
View contentView = View.inflate(mContext, R.layout.game_download_dialog, null);
TextView title = (TextView) contentView.findViewById(R.id.dialog_title);
title.setText(gameEntity.getName());
@ -168,7 +150,7 @@ public class DownloadDialog implements OnCollectionCallBackListener {
public void onDismiss() {
isShow = false;
EventBus.getDefault().unregister(DownloadDialog.this);
DownloadManager.getInstance(context).removeObserver(dataWatcher);
DownloadManager.getInstance(mContext).removeObserver(dataWatcher);
}
});
@ -185,7 +167,7 @@ public class DownloadDialog implements OnCollectionCallBackListener {
EventBus.getDefault().register(DownloadDialog.this);
}
DownloadManager.getInstance(context).addObserver(dataWatcher);
DownloadManager.getInstance(mContext).addObserver(dataWatcher);
}
// 合并ApkCollection
@ -230,13 +212,13 @@ public class DownloadDialog implements OnCollectionCallBackListener {
private void init(List<ApkEntity> apkList) {
for (int i = 0; i < apkList.size(); i++) {
String platformName = PlatformUtils.getInstance(context)
String platformName = PlatformUtils.getInstance(mContext)
.getPlatformName(apkList.get(i).getPlatform());
if (platformName == null) {
apkList.remove(i);
i--;
if (!isLoadPlatform) {
PlatformUtils.getInstance(context).getPlatform();
PlatformUtils.getInstance(mContext).getPlatform();
isLoadPlatform = true;
}
}
@ -260,7 +242,7 @@ public class DownloadDialog implements OnCollectionCallBackListener {
vpHeight = 208;
}
ViewGroup.LayoutParams layoutParams = viewPager.getLayoutParams();
layoutParams.height = DisplayUtils.dip2px(context, vpHeight);
layoutParams.height = DisplayUtils.dip2px(mContext, vpHeight);
viewPager.setLayoutParams(layoutParams);
int currentItem = 0;
@ -268,7 +250,7 @@ public class DownloadDialog implements OnCollectionCallBackListener {
currentItem = viewPager.getCurrentItem();
}
Utils.log("currentItem = " + currentItem);
adapter = new PlatformPagerAdapter(context, this, gameEntity, apkList, entrance, location);
adapter = new PlatformPagerAdapter(mContext, this, gameEntity, apkList, entrance, location);
viewPager.setAdapter(adapter);
viewPager.setCurrentItem(currentItem);
}
@ -292,13 +274,13 @@ public class DownloadDialog implements OnCollectionCallBackListener {
String packageName;
Object gh_id;
for (ApkEntity apkEntity : apkList) {
downloadEntity = DownloadManager.getInstance(context).get(apkEntity.getUrl());
downloadEntity = DownloadManager.getInstance(mContext).get(apkEntity.getUrl());
if (downloadEntity == null) {
packageName = apkEntity.getPackageName();
if (PackageManager.isInstalled(packageName)) {
gh_id = PackageUtils.getMetaData(context, packageName, "gh_id");
gh_id = PackageUtils.getMetaData(mContext, packageName, "gh_id");
if (gh_id == null || gh_id.equals(gameEntity.getId())) {
if (!PackageUtils.isSignature(context, packageName)) {
if (!PackageUtils.isSignature(mContext, packageName)) {
apkEntity.setOrder(8);
} else if (PackageManager.isCanUpdate(gameEntity.getId(), packageName)) {
apkEntity.setOrder(5);
@ -311,9 +293,9 @@ public class DownloadDialog implements OnCollectionCallBackListener {
apkEntity.setOrder(1);
String platform = apkEntity.getPlatform();
int id = PlatformUtils.getInstance(context).getPlatformPic(platform);
int id = PlatformUtils.getInstance(mContext).getPlatformPic(platform);
if (id == 0) {
String path = PlatformUtils.getInstance(context).getPlatformPicPath(platform);
String path = PlatformUtils.getInstance(mContext).getPlatformPicPath(platform);
if (path == null) {
apkEntity.setOrder(0);
}
@ -371,16 +353,16 @@ public class DownloadDialog implements OnCollectionCallBackListener {
if (collectionAdapter != null) {
collectionAdapter.removeDownloadEntityByUrl(url);
}
DownloadManager.getInstance(context).putStatus(url, "delete");
DownloadManager.getInstance(mContext).putStatus(url, "delete");
}
}
// 接收platform数据改变消息更新界面
public void onEvent(EBReuse reuse) {
if ("PlatformChanged".equals(reuse.getType())) {
DownloadManager.getInstance(context).removeObserver(dataWatcher);
DownloadManager.getInstance(mContext).removeObserver(dataWatcher);
init(new ArrayList<>(gameApk));
DownloadManager.getInstance(context).addObserver(dataWatcher);
DownloadManager.getInstance(mContext).addObserver(dataWatcher);
}
}
@ -389,14 +371,14 @@ public class DownloadDialog implements OnCollectionCallBackListener {
return;
}
for (int i = 0; i < size; i++) {
ImageView imageView = new ImageView(context);
ImageView imageView = new ImageView(mContext);
LayoutParams lparams = new LayoutParams(
DisplayUtils.dip2px(context, 6), DisplayUtils.dip2px(context, 6));
DisplayUtils.dip2px(mContext, 6), DisplayUtils.dip2px(mContext, 6));
if (i == 0) {
lparams.leftMargin = 0;
imageView.setImageResource(R.drawable.oval_hint_up);
} else {
lparams.leftMargin = DisplayUtils.dip2px(context, 9);
lparams.leftMargin = DisplayUtils.dip2px(mContext, 9);
imageView.setImageResource(R.drawable.oval_hint_gray_bg);
}
imageView.setLayoutParams(lparams);
@ -420,7 +402,7 @@ public class DownloadDialog implements OnCollectionCallBackListener {
}
ViewGroup.LayoutParams layoutParams = collectionViewPager.getLayoutParams();
layoutParams.height = DisplayUtils.dip2px(context, vpHeight);
layoutParams.height = DisplayUtils.dip2px(mContext, vpHeight);
collectionViewPager.setLayoutParams(layoutParams);
dialog_ll_collection_hint.removeAllViews();
@ -428,7 +410,7 @@ public class DownloadDialog implements OnCollectionCallBackListener {
addHintPoint(dialog_ll_collection_hint, size);
collectionAdapter = new PlatformPagerAdapter(
context, this, gameEntity, gameCollectionEntity.getSaveApkEntity(), entrance, location);
mContext, this, gameEntity, gameCollectionEntity.getSaveApkEntity(), entrance, location);
collectionViewPager.setAdapter(collectionAdapter);
collectionViewPager.addOnPageChangeListener(new MyPageChangeListener(dialog_ll_collection_hint));