去掉MainActivity的entryMap、uninstallMap,使用下载是添加packageNam来进行获取DownloadEntity
This commit is contained in:
@ -24,7 +24,6 @@ import com.gh.common.util.RunningUtils;
|
||||
import com.gh.common.util.ShareUtils;
|
||||
import com.gh.common.util.Utils;
|
||||
import com.gh.download.DownloadManager;
|
||||
import com.gh.gamecenter.MainActivity;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.eventbus.EBShowDialog;
|
||||
import com.gh.gamecenter.listener.OnCallBackListener;
|
||||
@ -175,8 +174,6 @@ public class BaseActivity extends Activity implements OnCallBackListener {
|
||||
DialogUtils.showUninstallDialog(this, new DialogUtils.ConfiremListener() {
|
||||
@Override
|
||||
public void onConfirem() {
|
||||
MainActivity.uninstallMap.put(
|
||||
PackageUtils.getPackageNameByPath(BaseActivity.this, showDialog.getPath()), showDialog.getPath());
|
||||
startActivity(PackageUtils.getUninstallIntent(BaseActivity.this, showDialog.getPath()));
|
||||
}
|
||||
});
|
||||
@ -185,8 +182,6 @@ public class BaseActivity extends Activity implements OnCallBackListener {
|
||||
|
||||
@Override
|
||||
public void onConfirem() {
|
||||
MainActivity.uninstallMap.put(
|
||||
PackageUtils.getPackageNameByPath(BaseActivity.this, showDialog.getPath()), showDialog.getPath());
|
||||
startActivity(PackageUtils.getUninstallIntent(BaseActivity.this, showDialog.getPath()));
|
||||
}
|
||||
});
|
||||
|
||||
@ -24,7 +24,6 @@ import com.gh.common.util.RunningUtils;
|
||||
import com.gh.common.util.ShareUtils;
|
||||
import com.gh.common.util.Utils;
|
||||
import com.gh.download.DownloadManager;
|
||||
import com.gh.gamecenter.MainActivity;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.eventbus.EBShowDialog;
|
||||
import com.gh.gamecenter.manager.SystemBarTintManager;
|
||||
@ -163,8 +162,6 @@ public class BaseFragmentActivity extends FragmentActivity {
|
||||
DialogUtils.showUninstallDialog(this, new DialogUtils.ConfiremListener() {
|
||||
@Override
|
||||
public void onConfirem() {
|
||||
MainActivity.uninstallMap.put(
|
||||
PackageUtils.getPackageNameByPath(BaseFragmentActivity.this, showDialog.getPath()), showDialog.getPath());
|
||||
startActivity(PackageUtils.getUninstallIntent(BaseFragmentActivity.this, showDialog.getPath()));
|
||||
}
|
||||
});
|
||||
@ -173,8 +170,6 @@ public class BaseFragmentActivity extends FragmentActivity {
|
||||
|
||||
@Override
|
||||
public void onConfirem() {
|
||||
MainActivity.uninstallMap.put(
|
||||
PackageUtils.getPackageNameByPath(BaseFragmentActivity.this, showDialog.getPath()), showDialog.getPath());
|
||||
startActivity(PackageUtils.getUninstallIntent(BaseFragmentActivity.this, showDialog.getPath()));
|
||||
}
|
||||
});
|
||||
|
||||
@ -27,13 +27,11 @@ import com.gh.download.DataWatcher;
|
||||
import com.gh.download.DownloadEntity;
|
||||
import com.gh.download.DownloadManager;
|
||||
import com.gh.gamecenter.DownloadManagerActivity;
|
||||
import com.gh.gamecenter.MainActivity;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.entity.ApkEntity;
|
||||
import com.gh.gamecenter.entity.GameEntity;
|
||||
import com.gh.gamecenter.eventbus.EBDownloadStatus;
|
||||
import com.gh.gamecenter.eventbus.EBPackage;
|
||||
import com.gh.gamecenter.eventbus.EBPutUrl;
|
||||
import com.gh.gamecenter.manager.DataCollectionManager;
|
||||
import com.gh.gamecenter.manager.PackageManager;
|
||||
import com.tencent.tauth.Tencent;
|
||||
@ -42,8 +40,6 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import de.greenrobot.event.EventBus;
|
||||
|
||||
/**
|
||||
* Created by Administrator on 2016/9/19.
|
||||
*/
|
||||
@ -272,8 +268,6 @@ public abstract class DetailActivity extends BaseActivity implements View.OnClic
|
||||
detail_tv_per.setText("下载中");
|
||||
break;
|
||||
case done:
|
||||
EventBus.getDefault().post(new EBPutUrl(
|
||||
gameEntity.getApk().get(0).getPackageName(), mDownloadEntity.getUrl()));
|
||||
detail_tv_per.setText("安装");
|
||||
break;
|
||||
case cancel:
|
||||
@ -340,16 +334,11 @@ public abstract class DetailActivity extends BaseActivity implements View.OnClic
|
||||
final String path = mDownloadEntity.getPath();
|
||||
PackageManager manager = new PackageManager(getApplicationContext());
|
||||
if (manager.launchSetup(path)) {
|
||||
EventBus.getDefault().post(new EBPutUrl(
|
||||
mDownloadEntity.getPackageName(), mDownloadEntity.getUrl()));
|
||||
startActivity(PackageUtils.getInstallIntent(path));
|
||||
} else {
|
||||
DialogUtils.showPluginDialog(this, new DialogUtils.ConfiremListener() {
|
||||
@Override
|
||||
public void onConfirem() {
|
||||
MainActivity.uninstallMap.put(
|
||||
PackageUtils.getPackageNameByPath(
|
||||
DetailActivity.this, path), path);
|
||||
startActivity(PackageUtils.getUninstallIntent(
|
||||
DetailActivity.this, path));
|
||||
}
|
||||
@ -410,6 +399,7 @@ public abstract class DetailActivity extends BaseActivity implements View.OnClic
|
||||
downloadEntity.setETag(apkEntity.getEtag());
|
||||
downloadEntity.setIcon(gameEntity.getIcon());
|
||||
downloadEntity.setPlatform(apkEntity.getPlatform());
|
||||
downloadEntity.setPackageName(apkEntity.getPackageName());
|
||||
downloadEntity.setGameId(gameEntity.getId());
|
||||
downloadEntity.setEntrance(entrance);
|
||||
downloadEntity.setLocation(name + ":" + title);
|
||||
|
||||
@ -20,11 +20,9 @@ import com.gh.download.DownloadEntity;
|
||||
import com.gh.download.DownloadManager;
|
||||
import com.gh.download.DownloadStatus;
|
||||
import com.gh.gamecenter.DownloadManagerActivity;
|
||||
import com.gh.gamecenter.MainActivity;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.entity.ApkEntity;
|
||||
import com.gh.gamecenter.entity.GameEntity;
|
||||
import com.gh.gamecenter.eventbus.EBPutUrl;
|
||||
import com.gh.gamecenter.manager.DataCollectionManager;
|
||||
import com.gh.gamecenter.manager.PackageManager;
|
||||
|
||||
@ -33,8 +31,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
||||
import de.greenrobot.event.EventBus;
|
||||
|
||||
public class DownloadItemUtils {
|
||||
|
||||
// 初始化gameMap
|
||||
@ -484,6 +480,7 @@ public class DownloadItemUtils {
|
||||
MD5Utils.getContentMD5(
|
||||
gameEntity.getName() + "_" + System.currentTimeMillis()) + ".apk"));
|
||||
downloadEntity.setPlatform(apkEntity.getPlatform());
|
||||
downloadEntity.setPackageName(apkEntity.getPackageName());
|
||||
downloadEntity.setIcon(gameEntity.getIcon());
|
||||
downloadEntity.setUpdate(true);
|
||||
downloadEntity.setETag(apkEntity.getEtag());
|
||||
@ -631,14 +628,11 @@ public class DownloadItemUtils {
|
||||
} else {
|
||||
PackageManager manager = new PackageManager(context);
|
||||
if (manager.launchSetup(path)) {
|
||||
EventBus.getDefault().post(new EBPutUrl(downloadEntity.getPackageName(), downloadEntity.getUrl()));
|
||||
context.startActivity(PackageUtils.getInstallIntent(path));
|
||||
} else {
|
||||
DialogUtils.showPluginDialog(context, new DialogUtils.ConfiremListener() {
|
||||
@Override
|
||||
public void onConfirem() {
|
||||
MainActivity.uninstallMap.put(
|
||||
PackageUtils.getPackageNameByPath(context, path), path);
|
||||
context.startActivity(PackageUtils.getUninstallIntent(context, path));
|
||||
}
|
||||
});
|
||||
@ -661,6 +655,7 @@ public class DownloadItemUtils {
|
||||
downloadEntity.setIcon(gameEntity.getIcon());
|
||||
downloadEntity.setETag(apkEntity.getEtag());
|
||||
downloadEntity.setPlatform(apkEntity.getPlatform());
|
||||
downloadEntity.setPackageName(apkEntity.getPackageName());
|
||||
downloadEntity.setGameId(gameEntity.getId());
|
||||
downloadEntity.setPluggable(gameEntity.isPluggable());
|
||||
downloadEntity.setEntrance(entrance);
|
||||
|
||||
@ -47,7 +47,6 @@ import com.gh.download.DownloadEntity;
|
||||
import com.gh.download.DownloadManager;
|
||||
import com.gh.download.DownloadStatus;
|
||||
import com.gh.gamecenter.DownloadManagerActivity;
|
||||
import com.gh.gamecenter.MainActivity;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.entity.ApkEntity;
|
||||
import com.gh.gamecenter.entity.GameCollectionEntity;
|
||||
@ -55,7 +54,6 @@ import com.gh.gamecenter.entity.GameEntity;
|
||||
import com.gh.gamecenter.entity.GameUpdateEntity;
|
||||
import com.gh.gamecenter.eventbus.EBDownloadStatus;
|
||||
import com.gh.gamecenter.eventbus.EBPackage;
|
||||
import com.gh.gamecenter.eventbus.EBPutUrl;
|
||||
import com.gh.gamecenter.eventbus.EBReuse;
|
||||
import com.gh.gamecenter.manager.DataCollectionManager;
|
||||
import com.gh.gamecenter.manager.PackageManager;
|
||||
@ -653,7 +651,6 @@ public class DownloadDialog {
|
||||
DownloadManager.getInstance(context).cancel(apkEntity.getUrl());
|
||||
adapter.notifyItemChanged(location);
|
||||
} else {
|
||||
MainActivity.uninstallMap.put(PackageUtils.getPackageNameByPath(context, path), path);
|
||||
context.startActivity(PackageUtils.getUninstallIntent(context, path));
|
||||
}
|
||||
}
|
||||
@ -865,8 +862,6 @@ public class DownloadDialog {
|
||||
|| status.equals(DownloadStatus.waiting)) {
|
||||
viewHolder.download_item_tv_status.setText("下载中");
|
||||
} else if (status.equals(DownloadStatus.done)) {
|
||||
EventBus.getDefault().post(new EBPutUrl(PackageUtils.getPackageNameByPath(
|
||||
context, downloadEntity.getPath()), downloadEntity.getUrl()));
|
||||
viewHolder.download_item_tv_status.setText("安装");
|
||||
} else if (status.equals(DownloadStatus.cancel)
|
||||
|| status.equals(DownloadStatus.hijack)) {
|
||||
@ -975,14 +970,11 @@ public class DownloadDialog {
|
||||
} else {
|
||||
PackageManager manager = new PackageManager(context);
|
||||
if (manager.launchSetup(path)) {
|
||||
EventBus.getDefault().post(new EBPutUrl(apkEntity.getPackageName(), apkEntity.getUrl()));
|
||||
context.startActivity(PackageUtils.getInstallIntent(path));
|
||||
} else {
|
||||
DialogUtils.showPluginDialog(context, new DialogUtils.ConfiremListener() {
|
||||
@Override
|
||||
public void onConfirem() {
|
||||
MainActivity.uninstallMap.put(
|
||||
PackageUtils.getPackageNameByPath(context, path), path);
|
||||
context.startActivity(PackageUtils.getUninstallIntent(context, path));
|
||||
}
|
||||
});
|
||||
@ -1006,6 +998,7 @@ public class DownloadDialog {
|
||||
downloadEntity.setETag(apkEntity.getEtag());
|
||||
downloadEntity.setIcon(gameIcon);
|
||||
downloadEntity.setPlatform(apkEntity.getPlatform());
|
||||
downloadEntity.setPackageName(apkEntity.getPackageName());
|
||||
downloadEntity.setUpdate(true);
|
||||
DownloadManager.getInstance(context).add(downloadEntity);
|
||||
}
|
||||
@ -1165,6 +1158,7 @@ public class DownloadDialog {
|
||||
downloadEntity.setETag(apkEntity.getEtag());
|
||||
downloadEntity.setIcon(gameIcon);
|
||||
downloadEntity.setPlatform(apkEntity.getPlatform());
|
||||
downloadEntity.setPackageName(apkEntity.getPackageName());
|
||||
downloadEntity.setGameId(gameId);
|
||||
HashMap<String, String> meta = new HashMap<>();
|
||||
meta.put("entrance", entrance);
|
||||
|
||||
@ -120,6 +120,10 @@ public class ConcernActivity extends BaseActivity implements OnClickListener {
|
||||
concernInfo.setId(gameEntity.getId());
|
||||
concernAdapter.getConcernList().add(concernInfo);
|
||||
concernAdapter.getConcernGameList().add(gameEntity);
|
||||
if (reuse_none_data.getVisibility() == View.VISIBLE) {
|
||||
reuse_none_data.setVisibility(View.GONE);
|
||||
concern_rv_show.setVisibility(View.VISIBLE);
|
||||
}
|
||||
concernAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
@ -127,6 +131,18 @@ public class ConcernActivity extends BaseActivity implements OnClickListener {
|
||||
if (changed.getGameId().equals(concernRecommendAdapter.getRecommendGameList().get(i).getId())) {
|
||||
concernRecommendAdapter.getRecommendGameList().remove(i);
|
||||
concernRecommendAdapter.notifyDataSetChanged();
|
||||
if (concernRecommendAdapter.getRecommendGameList().isEmpty()) {
|
||||
concern_rl_title.setVisibility(View.GONE);
|
||||
concern_rv_recommend.setVisibility(View.GONE);
|
||||
}
|
||||
if (concernRecommendAdapter.getRecommendGameList().size() < 4) {
|
||||
concern_rv_recommend.setLayoutManager(new GridLayoutManager(
|
||||
ConcernActivity.this, concernRecommendAdapter.getRecommendGameList().size()));
|
||||
} else {
|
||||
concern_rv_recommend.setLayoutManager(new GridLayoutManager(
|
||||
ConcernActivity.this, 4));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -137,6 +153,20 @@ public class ConcernActivity extends BaseActivity implements OnClickListener {
|
||||
}
|
||||
}
|
||||
concernRecommendAdapter.notifyDataSetChanged();
|
||||
if (concernRecommendAdapter.getRecommendGameList().isEmpty()) {
|
||||
concern_rl_title.setVisibility(View.GONE);
|
||||
concern_rv_recommend.setVisibility(View.GONE);
|
||||
} else {
|
||||
concern_rl_title.setVisibility(View.VISIBLE);
|
||||
concern_rv_recommend.setVisibility(View.VISIBLE);
|
||||
}
|
||||
if (concernRecommendAdapter.getRecommendGameList().size() < 4) {
|
||||
concern_rv_recommend.setLayoutManager(new GridLayoutManager(
|
||||
ConcernActivity.this, concernRecommendAdapter.getRecommendGameList().size()));
|
||||
} else {
|
||||
concern_rv_recommend.setLayoutManager(new GridLayoutManager(
|
||||
ConcernActivity.this, 4));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -17,7 +17,6 @@ import android.provider.Settings;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
import android.support.v4.util.ArrayMap;
|
||||
import android.text.Html;
|
||||
import android.text.Spanned;
|
||||
import android.text.TextUtils;
|
||||
@ -68,7 +67,6 @@ import com.gh.gamecenter.entity.GameEntity;
|
||||
import com.gh.gamecenter.entity.GameUpdateEntity;
|
||||
import com.gh.gamecenter.eventbus.EBDownloadStatus;
|
||||
import com.gh.gamecenter.eventbus.EBPackage;
|
||||
import com.gh.gamecenter.eventbus.EBPutUrl;
|
||||
import com.gh.gamecenter.eventbus.EBShowDialog;
|
||||
import com.gh.gamecenter.eventbus.EBSkip;
|
||||
import com.gh.gamecenter.eventbus.EBTopStatus;
|
||||
@ -121,7 +119,6 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
|
||||
|
||||
public static final String TAG = MainActivity.class.getSimpleName();
|
||||
|
||||
public static ArrayMap<String, String> uninstallMap;
|
||||
public static String searchHint;
|
||||
|
||||
private GameFragment gameFragment;
|
||||
@ -134,8 +131,6 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
|
||||
private SharedPreferences sp;
|
||||
private ConcernManager concernManager;
|
||||
|
||||
private ArrayMap<String, String> entryMap;
|
||||
|
||||
private int currentTab;
|
||||
|
||||
private boolean isDestroy = false;
|
||||
@ -166,7 +161,6 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
|
||||
if (DownloadStatus.done.equals(downloadEntity.getStatus())) {
|
||||
if (downloadEntity.getName().contains("光环助手")) {
|
||||
DataUtils.onEvent(MainActivity.this, "软件更新", "下载完成");
|
||||
entryMap.put(downloadEntity.getPackageName(), downloadEntity.getUrl());
|
||||
startActivity(PackageUtils.getInstallIntent(downloadEntity.getPath()));
|
||||
if (appEntity != null && appEntity.isIs_force()) {
|
||||
finish();
|
||||
@ -216,11 +210,6 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
|
||||
map.put("network", NetworkUtils.getConnectedType(MainActivity.this));
|
||||
DataCollectionManager.onEvent(MainActivity.this, "download", map);
|
||||
|
||||
entryMap.put(PackageUtils.getPackageNameByPath(
|
||||
getApplicationContext(),
|
||||
downloadEntity.getPath()), downloadEntity
|
||||
.getUrl());
|
||||
|
||||
if (RunningUtils.isApplicationBroughtToBackground(getApplicationContext())) {
|
||||
if (downloadEntity.isPluggable()) {
|
||||
NotificationManager nManager = (NotificationManager) getSystemService(
|
||||
@ -253,9 +242,6 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
|
||||
nManager.notify(
|
||||
((int) System.currentTimeMillis() / 1000),
|
||||
notification);
|
||||
|
||||
uninstallMap.put(PackageUtils.getPackageNameByPath(
|
||||
getApplicationContext(), path), path);
|
||||
}
|
||||
} else {
|
||||
String platform = PlatformUtils.getInstance(
|
||||
@ -283,7 +269,6 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
|
||||
PackageManager manager = new PackageManager(
|
||||
getApplicationContext());
|
||||
if (manager.launchSetup(downloadEntity.getPath())) {
|
||||
entryMap.put(downloadEntity.getPackageName(), downloadEntity.getUrl());
|
||||
startActivity(PackageUtils.getInstallIntent(downloadEntity.getPath()));
|
||||
} else {
|
||||
// 记录自动弹出卸载框
|
||||
@ -300,10 +285,6 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
|
||||
// 统计下载完成
|
||||
uploadData(downloadEntity.getGameId(), downloadEntity.getPlatform());
|
||||
}
|
||||
} else {
|
||||
Utils.log("It is already done!");
|
||||
DataUtils.onEvent(MainActivity.this, "多次弹框数据",
|
||||
downloadEntity.getName() + "-" + downloadEntity.getPlatform());
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -415,9 +396,6 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
|
||||
initViews();
|
||||
setTabSelection(currentTab);
|
||||
|
||||
uninstallMap = new ArrayMap<>();
|
||||
entryMap = new ArrayMap<>();
|
||||
|
||||
getSearchHints();
|
||||
|
||||
sp = getSharedPreferences(Config.PREFERENCE, Context.MODE_PRIVATE);
|
||||
@ -1280,6 +1258,7 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
|
||||
downloadEntity.setName("光环助手V" + appEntity.getVersion());
|
||||
downloadEntity.setPath(path);
|
||||
downloadEntity.setPlatform("官方版");
|
||||
downloadEntity.setPackageName(getPackageName());
|
||||
|
||||
DownloadManager.getInstance(getApplicationContext()).cancel(
|
||||
downloadEntity.getUrl(), false);
|
||||
@ -1491,12 +1470,7 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
|
||||
}
|
||||
}
|
||||
|
||||
public void onEventMainThread(EBPutUrl url) {
|
||||
entryMap.put(url.getPackageName(), url.getUrl());
|
||||
}
|
||||
|
||||
public void onEventMainThread(EBPackage busFour) {
|
||||
|
||||
String packageName = busFour.getPackageName();
|
||||
// 添加进已安装map中
|
||||
if ("安装".equals(busFour.getType())) {
|
||||
@ -1504,45 +1478,31 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
|
||||
} else if ("卸载".equals(busFour.getType())) {
|
||||
PackageManager.removeInstalled(packageName);
|
||||
}
|
||||
if ("安装".equals(busFour.getType())) {
|
||||
String url = entryMap.get(packageName);
|
||||
if (url != null) {
|
||||
entryMap.remove(packageName);
|
||||
|
||||
DownloadEntity downloadEntity = DownloadManager.getInstance(
|
||||
getApplicationContext()).get(url);
|
||||
if (downloadEntity != null && downloadEntity.isPluggable()) {
|
||||
DownloadEntity mDownloadEntity = null;
|
||||
for (DownloadEntity downloadEntity : DownloadManager.getInstance(
|
||||
getApplicationContext()).getAll()) {
|
||||
if (packageName.equals(downloadEntity.getPackageName())) {
|
||||
mDownloadEntity = downloadEntity;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (mDownloadEntity != null) {
|
||||
if ("安装".equals(busFour.getType())) {
|
||||
if (mDownloadEntity.isPluggable()) {
|
||||
Map<String, Object> kv6 = new HashMap<>();
|
||||
kv6.put("安装或卸载", "安装完成");
|
||||
DataUtils.onEvent(this, "插件化", downloadEntity.getName(), kv6);
|
||||
DataUtils.onEvent(this, "插件化", mDownloadEntity.getName(), kv6);
|
||||
}
|
||||
|
||||
// 删除数据库和文件
|
||||
DownloadManager.getInstance(getApplicationContext()).cancel(
|
||||
url, sp.getBoolean("autodelete", true));
|
||||
}
|
||||
} else if ("卸载".equals(busFour.getType())) {
|
||||
try {
|
||||
for (DownloadEntity downloadEntity : DownloadManager.getInstance(
|
||||
getApplicationContext()).getAll()) {
|
||||
if (downloadEntity.isPluggable()
|
||||
&& packageName.equals(downloadEntity.getPackageName())) {
|
||||
Map<String, Object> kv6 = new HashMap<>();
|
||||
kv6.put("安装或卸载", "卸载完成");
|
||||
DataUtils.onEvent(this, "插件化", downloadEntity.getName(), kv6);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
mDownloadEntity.getUrl(), sp.getBoolean("autodelete", true));
|
||||
} else if ("卸载".equals(busFour.getType())) {
|
||||
Map<String, Object> kv6 = new HashMap<>();
|
||||
kv6.put("安装或卸载", "卸载完成");
|
||||
DataUtils.onEvent(this, "插件化", mDownloadEntity.getName(), kv6);
|
||||
|
||||
String path = uninstallMap.get(packageName);
|
||||
|
||||
if (path != null) {
|
||||
uninstallMap.remove(packageName);
|
||||
|
||||
startActivity(PackageUtils.getInstallIntent(path));
|
||||
startActivity(PackageUtils.getInstallIntent(mDownloadEntity.getPath()));
|
||||
}
|
||||
}
|
||||
if ("安装".equals(busFour.getType())) {
|
||||
@ -1655,7 +1615,6 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
|
||||
home2Title = null;
|
||||
home3Title = null;
|
||||
sp = null;
|
||||
entryMap = null;
|
||||
dialog = null;
|
||||
app_pb_progress = null;
|
||||
app_tv_speed = null;
|
||||
|
||||
@ -536,6 +536,7 @@ public class SettingActivity extends BaseActivity implements OnClickListener {
|
||||
downloadEntity.setName("光环助手V" + appEntity.getVersion());
|
||||
downloadEntity.setPath(path);
|
||||
downloadEntity.setPlatform("官方版");
|
||||
downloadEntity.setPackageName(getPackageName());
|
||||
|
||||
DownloadManager.getInstance(getApplicationContext()).cancel(
|
||||
downloadEntity.getUrl(), false);
|
||||
|
||||
@ -208,10 +208,16 @@ public class ConcernAdapter extends RecyclerView.Adapter<ConcernViewHolder> {
|
||||
}
|
||||
|
||||
public List<GameEntity> getConcernGameList() {
|
||||
if (concernGameList == null) {
|
||||
concernGameList = new ArrayList<>();
|
||||
}
|
||||
return concernGameList;
|
||||
}
|
||||
|
||||
public List<ConcernInfo> getConcernList() {
|
||||
if (concernList == null) {
|
||||
concernList = new ArrayList<>();
|
||||
}
|
||||
return concernList;
|
||||
}
|
||||
}
|
||||
|
||||
@ -118,7 +118,8 @@ public class ConcernRecommendAdapter extends RecyclerView.Adapter<ConcernViewHol
|
||||
|
||||
holder.concern_item_concern.setClickable(false);
|
||||
holder.itemView.setClickable(false);
|
||||
notifyItemRemoved(holder.getPosition());
|
||||
// notifyItemRemoved(holder.getPosition());
|
||||
notifyDataSetChanged();
|
||||
|
||||
Toast.makeText(context, "关注成功", Toast.LENGTH_SHORT).show();
|
||||
|
||||
@ -160,6 +161,9 @@ public class ConcernRecommendAdapter extends RecyclerView.Adapter<ConcernViewHol
|
||||
}
|
||||
|
||||
public List<GameEntity> getRecommendGameList() {
|
||||
if (recommendGameList == null) {
|
||||
recommendGameList = new ArrayList<>();
|
||||
}
|
||||
return recommendGameList;
|
||||
}
|
||||
|
||||
|
||||
@ -327,6 +327,8 @@ public class GameDownLoadFragment extends Fragment implements View.OnClickListen
|
||||
|
||||
if (adapter.getDownloadingList().isEmpty() && adapter.getDoneList().isEmpty()) {
|
||||
reuse_nodata_skip.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
reuse_nodata_skip.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -28,10 +28,8 @@ import com.gh.common.view.CardRelativeLayout;
|
||||
import com.gh.download.DownloadEntity;
|
||||
import com.gh.download.DownloadManager;
|
||||
import com.gh.download.DownloadStatus;
|
||||
import com.gh.gamecenter.MainActivity;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.eventbus.EBDownloadChanged;
|
||||
import com.gh.gamecenter.eventbus.EBPutUrl;
|
||||
import com.gh.gamecenter.manager.PackageManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -300,18 +298,15 @@ public class GameDownloadAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||
removeDownload(entry, viewHolder.getPosition());
|
||||
} else {
|
||||
if (entry.getName().contains("光环助手")) {
|
||||
EventBus.getDefault().post(new EBPutUrl(entry.getPackageName(), entry.getUrl()));
|
||||
context.startActivity(PackageUtils.getInstallIntent(path));
|
||||
} else {
|
||||
PackageManager manager = new PackageManager(context);
|
||||
if (manager.launchSetup(path)) {
|
||||
EventBus.getDefault().post(new EBPutUrl(entry.getPackageName(), entry.getUrl()));
|
||||
context.startActivity(PackageUtils.getInstallIntent(path));
|
||||
} else {
|
||||
DialogUtils.showPluginDialog(context, new DialogUtils.ConfiremListener() {
|
||||
@Override
|
||||
public void onConfirem() {
|
||||
MainActivity.uninstallMap.put(PackageUtils.getPackageNameByPath(context, path), path);
|
||||
context.startActivity(PackageUtils.getUninstallIntent(context, path));
|
||||
}
|
||||
});
|
||||
@ -531,7 +526,6 @@ public class GameDownloadAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||
if (FileUtils.isEmptyFile(path)) {
|
||||
Toast.makeText(context, "解析包出错(可能被误删了),请重新下载", Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
MainActivity.uninstallMap.put(PackageUtils.getPackageNameByPath(context, path), path);
|
||||
context.startActivity(PackageUtils.getUninstallIntent(context, path));
|
||||
}
|
||||
}
|
||||
|
||||
@ -606,6 +606,7 @@ public class GameUpdateAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
downloadEntity.setETag(updateEntity.getEtag());
|
||||
downloadEntity.setIcon(updateEntity.getIcon());
|
||||
downloadEntity.setPlatform(updateEntity.getPlatform());
|
||||
downloadEntity.setPackageName(updateEntity.getPackageName());
|
||||
if (updateEntity.isPluggable()) {
|
||||
downloadEntity.setPluggable(true);
|
||||
} else {
|
||||
|
||||
@ -1,30 +0,0 @@
|
||||
package com.gh.gamecenter.eventbus;
|
||||
|
||||
public class EBPutUrl {
|
||||
|
||||
private String packageName;
|
||||
private String url;
|
||||
|
||||
public EBPutUrl(String packageName, String url) {
|
||||
super();
|
||||
this.packageName = packageName;
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String getPackageName() {
|
||||
return packageName;
|
||||
}
|
||||
|
||||
public void setPackageName(String packageName) {
|
||||
this.packageName = packageName;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
}
|
||||
@ -75,6 +75,7 @@ public class GameDetailAdapter extends RecyclerView.Adapter {
|
||||
private String gameId;
|
||||
private String entrance;
|
||||
|
||||
private int position_top = -1;
|
||||
private int position_newsserver = -1;
|
||||
private int position_plugin = -1;
|
||||
private int position_news = -1;
|
||||
@ -107,11 +108,8 @@ public class GameDetailAdapter extends RecyclerView.Adapter {
|
||||
new Response.Listener<JSONObject>() {
|
||||
@Override
|
||||
public void onResponse(JSONObject response) {
|
||||
|
||||
Gson gson = new Gson();
|
||||
gameDetailEntity = gson.fromJson(response.toString(), GameDetailEntity.class);
|
||||
initPosition();
|
||||
notifyItemRangeInserted(0, getItemCount());
|
||||
|
||||
getGameNews();
|
||||
|
||||
@ -144,10 +142,7 @@ public class GameDetailAdapter extends RecyclerView.Adapter {
|
||||
listener.loadDone();
|
||||
}
|
||||
initPosition();
|
||||
if (position_news != -1) {
|
||||
// notifyItemInserted(position_news);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}, new Response.ErrorListener() {
|
||||
@Override
|
||||
@ -155,6 +150,8 @@ public class GameDetailAdapter extends RecyclerView.Adapter {
|
||||
if (listener != null) {
|
||||
listener.loadDone();
|
||||
}
|
||||
initPosition();
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
AppController.addToRequestQueue(request, GameDetailActivity.TAG);
|
||||
@ -167,80 +164,79 @@ public class GameDetailAdapter extends RecyclerView.Adapter {
|
||||
new Response.Listener<JSONArray>() {
|
||||
@Override
|
||||
public void onResponse(JSONArray response) {
|
||||
try {
|
||||
ArrayList<ServerEntity> serverInfo = new ArrayList<>();
|
||||
SimpleDateFormat format = new SimpleDateFormat(
|
||||
"Mdd", Locale.getDefault());
|
||||
int today = Integer.valueOf(format.format(new Date()));
|
||||
for (int j = 0, sizej = response.length(); j < sizej; j++) {
|
||||
ServerEntity entity = new ServerEntity();
|
||||
JSONObject jsonObject2;
|
||||
jsonObject2 = response.getJSONObject(j);
|
||||
String server = jsonObject2.getString("server");
|
||||
if (server.length() > 4) {
|
||||
server = server.substring(0, 4);
|
||||
if (response.length() != 0) {
|
||||
try {
|
||||
ArrayList<ServerEntity> serverInfo = new ArrayList<>();
|
||||
SimpleDateFormat format = new SimpleDateFormat(
|
||||
"Mdd", Locale.getDefault());
|
||||
int today = Integer.valueOf(format.format(new Date()));
|
||||
for (int j = 0, sizej = response.length(); j < sizej; j++) {
|
||||
ServerEntity entity = new ServerEntity();
|
||||
JSONObject jsonObject2;
|
||||
jsonObject2 = response.getJSONObject(j);
|
||||
String server = jsonObject2.getString("server");
|
||||
if (server.length() > 4) {
|
||||
server = server.substring(0, 4);
|
||||
}
|
||||
entity.setServer(server);
|
||||
entity.setTime(Long.valueOf(jsonObject2.getString("time") + "000"));
|
||||
int day = Integer.valueOf(format.format(new Date(entity.getTime())));
|
||||
if (day == today + 1) {
|
||||
entity.setTag("明天");
|
||||
serverInfo.add(entity);
|
||||
} else if (day == today - 1) {
|
||||
entity.setTag("昨天");
|
||||
serverInfo.add(entity);
|
||||
} else if (day == today) {
|
||||
entity.setTag("今天");
|
||||
serverInfo.add(entity);
|
||||
}
|
||||
}
|
||||
entity.setServer(server);
|
||||
entity.setTime(Long.valueOf(jsonObject2.getString("time") + "000"));
|
||||
int day = Integer.valueOf(format.format(new Date(entity.getTime())));
|
||||
if (day == today + 1) {
|
||||
entity.setTag("明天");
|
||||
serverInfo.add(entity);
|
||||
} else if (day == today - 1) {
|
||||
entity.setTag("昨天");
|
||||
serverInfo.add(entity);
|
||||
} else if (day == today) {
|
||||
entity.setTag("今天");
|
||||
serverInfo.add(entity);
|
||||
|
||||
Comparator<ServerEntity> comparator = new Comparator<ServerEntity>() {
|
||||
@Override
|
||||
public int compare(ServerEntity lhs, ServerEntity rhs) {
|
||||
return (int) (lhs.getTime() - rhs.getTime());
|
||||
}
|
||||
};
|
||||
Collections.sort(serverInfo, comparator);
|
||||
|
||||
gameDetailEntity.setServerInfo(serverInfo);
|
||||
initPosition();
|
||||
if (position_newsserver != -1) {
|
||||
notifyItemInserted(position_newsserver);
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Comparator<ServerEntity> comparator = new Comparator<ServerEntity>() {
|
||||
@Override
|
||||
public int compare(ServerEntity lhs, ServerEntity rhs) {
|
||||
return (int) (lhs.getTime() - rhs.getTime());
|
||||
}
|
||||
};
|
||||
Collections.sort(serverInfo, comparator);
|
||||
|
||||
gameDetailEntity.setServerInfo(serverInfo);
|
||||
initPosition();
|
||||
notifyDataSetChanged();
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}, new Response.ErrorListener() {
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
|
||||
}
|
||||
});
|
||||
}, null);
|
||||
AppController.addToRequestQueue(request, GameDetailActivity.TAG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
if (viewType == 0) {
|
||||
if (viewType == 1) {
|
||||
View view = LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.gamedetail_item_top, parent, false);
|
||||
return new GameDetailTopViewHolder(view);
|
||||
} else if (viewType == 1) {
|
||||
View view = LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.gamedetail_item_plugin, parent, false);
|
||||
return new GameDetailPluginViewHolder(view);
|
||||
} else if (viewType == 2) {
|
||||
View view = LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.gamedetail_item_news, parent, false);
|
||||
return new GameDetailNewsViewHolder(view);
|
||||
} else if (viewType == 3) {
|
||||
View view = LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.gamedetail_item_intro,parent,false);
|
||||
return new GameDetailIntroViewHolder(view);
|
||||
} else if (viewType == 4) {
|
||||
View view = LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.gamedetail_item_newsserver,parent,false);
|
||||
return new GameDetailNewsServerViewHolder(view);
|
||||
} else if (viewType == 3) {
|
||||
View view = LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.gamedetail_item_plugin, parent, false);
|
||||
return new GameDetailPluginViewHolder(view);
|
||||
} else if (viewType == 4) {
|
||||
View view = LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.gamedetail_item_news, parent, false);
|
||||
return new GameDetailNewsViewHolder(view);
|
||||
} else if (viewType == 5) {
|
||||
View view = LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.gamedetail_item_intro,parent,false);
|
||||
return new GameDetailIntroViewHolder(view);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -677,12 +673,15 @@ public class GameDetailAdapter extends RecyclerView.Adapter {
|
||||
}
|
||||
|
||||
private void initPosition() {
|
||||
if (gameDetailEntity != null) {
|
||||
position_top = 0;
|
||||
}
|
||||
if (gameDetailEntity.getServerInfo() != null
|
||||
&& gameDetailEntity.getServerInfo().size() != 0) {
|
||||
position_newsserver = 1;
|
||||
}
|
||||
if (gameDetailEntity.getTag() != null
|
||||
&& gameDetailEntity.getTag().size() > 0) {
|
||||
&& gameDetailEntity.getTag().size() != 0) {
|
||||
if (position_newsserver == -1) {
|
||||
position_plugin = 1;
|
||||
} else {
|
||||
@ -690,7 +689,7 @@ public class GameDetailAdapter extends RecyclerView.Adapter {
|
||||
}
|
||||
}
|
||||
if (gameDetailEntity.getNews() != null
|
||||
&& gameDetailEntity.getNews().size() > 0) {
|
||||
&& gameDetailEntity.getNews().size() != 0) {
|
||||
if (position_newsserver == -1 && position_plugin == -1) {
|
||||
position_news = 1;
|
||||
} else if (position_plugin != -1) {
|
||||
@ -702,7 +701,7 @@ public class GameDetailAdapter extends RecyclerView.Adapter {
|
||||
}
|
||||
}
|
||||
if (gameDetailEntity.getGallery() != null
|
||||
&& gameDetailEntity.getGallery().size() > 0) {
|
||||
&& gameDetailEntity.getGallery().size() != 0) {
|
||||
if (position_newsserver == -1 && position_plugin == -1 && position_news == -1) {
|
||||
position_intro = 1;
|
||||
} else if (position_news != -1) {
|
||||
@ -722,21 +721,20 @@ public class GameDetailAdapter extends RecyclerView.Adapter {
|
||||
if (gameDetailEntity == null) {
|
||||
return 0;
|
||||
} else {
|
||||
int index = 1;
|
||||
if (gameDetailEntity.getServerInfo() != null
|
||||
&& gameDetailEntity.getServerInfo().size() != 0) {
|
||||
int index = 0;
|
||||
if (position_top != -1) {
|
||||
index++;
|
||||
}
|
||||
if (gameDetailEntity.getTag() != null
|
||||
&& gameDetailEntity.getTag().size() > 0) {
|
||||
if (position_newsserver != -1) {
|
||||
index++;
|
||||
}
|
||||
if (gameDetailEntity.getNews() != null
|
||||
&& gameDetailEntity.getNews().size() > 0) {
|
||||
if (position_plugin != -1) {
|
||||
index++;
|
||||
}
|
||||
if (gameDetailEntity.getGallery() != null
|
||||
&& gameDetailEntity.getGallery().size() > 0) {
|
||||
if (position_news != -1) {
|
||||
index++;
|
||||
}
|
||||
if (position_intro != -1) {
|
||||
index++;
|
||||
}
|
||||
return index;
|
||||
@ -745,18 +743,21 @@ public class GameDetailAdapter extends RecyclerView.Adapter {
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
if (position_newsserver != -1 && position == position_newsserver) {
|
||||
return 4;
|
||||
}
|
||||
if (position_plugin != -1 && position == position_plugin) {
|
||||
if (position_top != -1 && position == position_top) {
|
||||
return 1;
|
||||
}
|
||||
if (position_news != -1 && position == position_news) {
|
||||
if (position_newsserver != -1 && position == position_newsserver) {
|
||||
return 2;
|
||||
}
|
||||
if (position_intro != -1 && position == position_intro) {
|
||||
if (position_plugin != -1 && position == position_plugin) {
|
||||
return 3;
|
||||
}
|
||||
if (position_news != -1 && position == position_news) {
|
||||
return 4;
|
||||
}
|
||||
if (position_intro != -1 && position == position_intro) {
|
||||
return 5;
|
||||
}
|
||||
return position;
|
||||
}
|
||||
|
||||
|
||||
@ -26,7 +26,6 @@ public class ConcernFragment extends BaseFragment {
|
||||
public static final String TAG = ConcernFragment.class.getSimpleName();
|
||||
|
||||
private RecyclerView fm_concern_rv_show;
|
||||
private LinearLayoutManager linearLayoutManager;
|
||||
private ConcernFragmentAdapter adapter;
|
||||
|
||||
private boolean isEverpause;
|
||||
@ -54,8 +53,7 @@ public class ConcernFragment extends BaseFragment {
|
||||
init(R.layout.fm_concern);
|
||||
|
||||
fm_concern_rv_show.setHasFixedSize(true);
|
||||
linearLayoutManager = new LinearLayoutManager(getActivity());
|
||||
fm_concern_rv_show.setLayoutManager(linearLayoutManager);
|
||||
fm_concern_rv_show.setLayoutManager(new LinearLayoutManager(getActivity()));
|
||||
adapter = new ConcernFragmentAdapter(getActivity(), fm_concern_rv_show);
|
||||
fm_concern_rv_show.setAdapter(adapter);
|
||||
}
|
||||
|
||||
@ -3,12 +3,10 @@ package com.gh.gamecenter.personal;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.support.v4.util.ArrayMap;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import com.android.volley.Response;
|
||||
import com.android.volley.VolleyError;
|
||||
@ -21,7 +19,6 @@ import com.gh.common.util.DownloadItemUtils;
|
||||
import com.gh.common.util.GameViewUtils;
|
||||
import com.gh.common.util.ImageUtils;
|
||||
import com.gh.common.util.TimestampUtils;
|
||||
import com.gh.common.util.Utils;
|
||||
import com.gh.common.view.CardLinearLayout;
|
||||
import com.gh.download.DownloadManager;
|
||||
import com.gh.gamecenter.GameDetailActivity;
|
||||
@ -29,7 +26,6 @@ import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.adapter.viewholder.FooterViewHolder;
|
||||
import com.gh.gamecenter.adapter.viewholder.GameNormalViewHolder;
|
||||
import com.gh.gamecenter.adapter.viewholder.NoDataSkipViewHolder;
|
||||
import com.gh.gamecenter.adapter.viewholder.ReuseViewHolder;
|
||||
import com.gh.gamecenter.db.info.ConcernInfo;
|
||||
import com.gh.gamecenter.entity.ApkEntity;
|
||||
import com.gh.gamecenter.entity.GameEntity;
|
||||
@ -151,9 +147,8 @@ public class ConcernFragmentAdapter extends RecyclerView.Adapter<RecyclerView.Vi
|
||||
manager.addOrUpdate(gEntity.getApk(), gEntity.getId(), gEntity.getName());
|
||||
}
|
||||
|
||||
notifyItemRangeInserted(0, gameList.size());
|
||||
isRemove = true;
|
||||
notifyItemRemoved(getItemCount());
|
||||
notifyDataSetChanged();
|
||||
|
||||
initLocationMap();
|
||||
}
|
||||
@ -171,7 +166,7 @@ public class ConcernFragmentAdapter extends RecyclerView.Adapter<RecyclerView.Vi
|
||||
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
if (gameList.size() > 0 && viewType >= 0 && viewType < gameList.size()) {
|
||||
if (viewType == 1) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(
|
||||
R.layout.game_normal_item, parent, false);
|
||||
return new GameNormalViewHolder(view);
|
||||
@ -179,12 +174,6 @@ public class ConcernFragmentAdapter extends RecyclerView.Adapter<RecyclerView.Vi
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(
|
||||
R.layout.reuse_nodata_skip, parent, false);
|
||||
return new NoDataSkipViewHolder(view);
|
||||
} else if (isRemove) {
|
||||
RelativeLayout relativeLayout = new RelativeLayout(context);
|
||||
ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT, 0);
|
||||
relativeLayout.setLayoutParams(params);
|
||||
return new ReuseViewHolder(relativeLayout);
|
||||
} else {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(
|
||||
R.layout.refresh_footerview, parent, false);
|
||||
@ -196,47 +185,9 @@ public class ConcernFragmentAdapter extends RecyclerView.Adapter<RecyclerView.Vi
|
||||
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
|
||||
if (holder instanceof GameNormalViewHolder && gameList.size() > position) {
|
||||
initGameNormal((GameNormalViewHolder) holder, gameList.get(position), position);
|
||||
} else if (holder instanceof ReuseViewHolder && position == getItemCount() - 1) {
|
||||
// ReuseViewHolder viewHolder = (ReuseViewHolder) holder;
|
||||
//
|
||||
// int height = 0;
|
||||
// LinearLayoutManager linearLayoutManager = (LinearLayoutManager) fm_concern_rv_show.getLayoutManager();
|
||||
// if (linearLayoutManager.findFirstVisibleItemPosition() < 1) {
|
||||
// for (int i = 0, size = fm_concern_rv_show.getChildCount(); i < size; i++) {
|
||||
// height += fm_concern_rv_show.getChildAt(i).getMeasuredHeight();
|
||||
// }
|
||||
// height = fm_concern_rv_show.getHeight() + DisplayUtils.dip2px(context, 229)
|
||||
// - DisplayUtils.getInternalDimensionSize(context.getResources(), "status_bar_height") - height;
|
||||
// if (height < 0) {
|
||||
// height = 0;
|
||||
// }
|
||||
// Utils.log("height = " + height);
|
||||
// }
|
||||
//
|
||||
// ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(
|
||||
// ViewGroup.LayoutParams.MATCH_PARENT, height);
|
||||
// viewHolder.itemView.setLayoutParams(params);
|
||||
} else if (holder instanceof NoDataSkipViewHolder) {
|
||||
NoDataSkipViewHolder viewHolder = (NoDataSkipViewHolder) holder;
|
||||
|
||||
int height = 0;
|
||||
LinearLayoutManager linearLayoutManager = (LinearLayoutManager) fm_concern_rv_show.getLayoutManager();
|
||||
if (linearLayoutManager.findFirstVisibleItemPosition() < 1) {
|
||||
for (int i = 0, size = fm_concern_rv_show.getChildCount(); i < size; i++) {
|
||||
height += fm_concern_rv_show.getChildAt(i).getMeasuredHeight();
|
||||
}
|
||||
height = fm_concern_rv_show.getHeight()
|
||||
- DisplayUtils.getInternalDimensionSize(context.getResources(), "status_bar_height") - height;
|
||||
if (height < 0) {
|
||||
height = 0;
|
||||
}
|
||||
Utils.log("height = " + height);
|
||||
}
|
||||
|
||||
ViewGroup.LayoutParams params = viewHolder.itemView.getLayoutParams();
|
||||
params.height = height;
|
||||
viewHolder.itemView.setLayoutParams(params);
|
||||
|
||||
viewHolder.reuse_nodata_skip_tv_hint.setText("暂无关注");
|
||||
viewHolder.reuse_nodata_skip_tv_btn.setText("查看精品推荐");
|
||||
viewHolder.reuse_nodata_skip_tv_btn.setOnClickListener(new View.OnClickListener() {
|
||||
@ -250,12 +201,21 @@ public class ConcernFragmentAdapter extends RecyclerView.Adapter<RecyclerView.Vi
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
if (gameList.isEmpty() && (isEmpty || !isRemove)) {
|
||||
return 1;
|
||||
}
|
||||
if (isRemove) {
|
||||
return gameList.size();
|
||||
}
|
||||
return gameList.size() + 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
return position;
|
||||
if (gameList.size() != 0 && position >= 0 && position < gameList.size()) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private void initGameNormal(final GameNormalViewHolder holder, final GameEntity gameEntity, int i) {
|
||||
|
||||
@ -25,7 +25,6 @@ public class InstallFragment extends BaseFragment {
|
||||
public static final String TAG = InstallFragment.class.getSimpleName();
|
||||
|
||||
private RecyclerView fm_install_rv_show;
|
||||
private LinearLayoutManager linearLayoutManager;
|
||||
private InstallFragmentAdapter adapter;
|
||||
|
||||
private boolean isEverpause;
|
||||
@ -55,8 +54,7 @@ public class InstallFragment extends BaseFragment {
|
||||
init(R.layout.fm_install);
|
||||
|
||||
fm_install_rv_show.setHasFixedSize(true);
|
||||
linearLayoutManager = new LinearLayoutManager(getActivity());
|
||||
fm_install_rv_show.setLayoutManager(linearLayoutManager);
|
||||
fm_install_rv_show.setLayoutManager(new LinearLayoutManager(getActivity()));
|
||||
adapter = new InstallFragmentAdapter(getActivity(), fm_install_rv_show);
|
||||
fm_install_rv_show.setAdapter(adapter);
|
||||
}
|
||||
|
||||
@ -3,12 +3,10 @@ package com.gh.gamecenter.personal;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.support.v4.util.ArrayMap;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import com.android.volley.Response;
|
||||
import com.android.volley.VolleyError;
|
||||
@ -23,7 +21,6 @@ import com.gh.common.util.ImageUtils;
|
||||
import com.gh.common.util.PlatformUtils;
|
||||
import com.gh.common.util.TimestampUtils;
|
||||
import com.gh.common.util.TrafficUtils;
|
||||
import com.gh.common.util.Utils;
|
||||
import com.gh.common.view.CardLinearLayout;
|
||||
import com.gh.download.DownloadManager;
|
||||
import com.gh.gamecenter.GameDetailActivity;
|
||||
@ -31,7 +28,6 @@ import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.adapter.viewholder.FooterViewHolder;
|
||||
import com.gh.gamecenter.adapter.viewholder.GameNormalViewHolder;
|
||||
import com.gh.gamecenter.adapter.viewholder.NoDataSkipViewHolder;
|
||||
import com.gh.gamecenter.adapter.viewholder.ReuseViewHolder;
|
||||
import com.gh.gamecenter.db.info.ConcernInfo;
|
||||
import com.gh.gamecenter.entity.ApkEntity;
|
||||
import com.gh.gamecenter.entity.GameEntity;
|
||||
@ -195,8 +191,6 @@ public class InstallFragmentAdapter extends RecyclerView.Adapter<RecyclerView.Vi
|
||||
sortedList.addAll(noopenList);
|
||||
sortedList.addAll(oftenuseList);
|
||||
sortedList.addAll(unsignatureList);
|
||||
|
||||
Utils.log("sortedList size = " + sortedList.size());
|
||||
}
|
||||
|
||||
private int count;
|
||||
@ -291,9 +285,8 @@ public class InstallFragmentAdapter extends RecyclerView.Adapter<RecyclerView.Vi
|
||||
list.addAll(map.get(key));
|
||||
}
|
||||
this.gameList = list;
|
||||
notifyItemRangeInserted(0, this.gameList.size());
|
||||
isRemove = true;
|
||||
notifyItemRemoved(getItemCount());
|
||||
notifyDataSetChanged();
|
||||
|
||||
initLocationMap();
|
||||
}
|
||||
@ -311,7 +304,7 @@ public class InstallFragmentAdapter extends RecyclerView.Adapter<RecyclerView.Vi
|
||||
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
if (gameList.size() > 0 && viewType >= 0 && viewType < gameList.size()) {
|
||||
if (viewType == 1) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(
|
||||
R.layout.game_normal_item, parent, false);
|
||||
return new GameNormalViewHolder(view);
|
||||
@ -319,12 +312,6 @@ public class InstallFragmentAdapter extends RecyclerView.Adapter<RecyclerView.Vi
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(
|
||||
R.layout.reuse_nodata_skip, parent, false);
|
||||
return new NoDataSkipViewHolder(view);
|
||||
} else if (isRemove) {
|
||||
RelativeLayout relativeLayout = new RelativeLayout(context);
|
||||
ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT, 0);
|
||||
relativeLayout.setLayoutParams(params);
|
||||
return new ReuseViewHolder(relativeLayout);
|
||||
} else {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(
|
||||
R.layout.refresh_footerview, parent, false);
|
||||
@ -336,47 +323,9 @@ public class InstallFragmentAdapter extends RecyclerView.Adapter<RecyclerView.Vi
|
||||
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
|
||||
if (holder instanceof GameNormalViewHolder) {
|
||||
initGameNormal((GameNormalViewHolder) holder, gameList.get(position), position);
|
||||
} else if (holder instanceof ReuseViewHolder && position == getItemCount() - 1) {
|
||||
// ReuseViewHolder viewHolder = (ReuseViewHolder) holder;
|
||||
//
|
||||
// int height = 0;
|
||||
// LinearLayoutManager linearLayoutManager = (LinearLayoutManager) fm_install_rv_show.getLayoutManager();
|
||||
// if (linearLayoutManager.findFirstVisibleItemPosition() < 1) {
|
||||
// for (int i = 0, size = fm_install_rv_show.getChildCount(); i < size; i++) {
|
||||
// height += fm_install_rv_show.getChildAt(i).getMeasuredHeight();
|
||||
// }
|
||||
// height = fm_install_rv_show.getHeight() + DisplayUtils.dip2px(context, 229)
|
||||
// - DisplayUtils.getInternalDimensionSize(context.getResources(), "status_bar_height") - height;
|
||||
// if (height < 0) {
|
||||
// height = 0;
|
||||
// }
|
||||
// Utils.log("height = " + height);
|
||||
// }
|
||||
//
|
||||
// ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(
|
||||
// ViewGroup.LayoutParams.MATCH_PARENT, height);
|
||||
// viewHolder.itemView.setLayoutParams(params);
|
||||
} else if (holder instanceof NoDataSkipViewHolder) {
|
||||
NoDataSkipViewHolder viewHolder = (NoDataSkipViewHolder) holder;
|
||||
|
||||
int height = 0;
|
||||
LinearLayoutManager linearLayoutManager = (LinearLayoutManager) fm_install_rv_show.getLayoutManager();
|
||||
if (linearLayoutManager.findFirstVisibleItemPosition() < 1) {
|
||||
for (int i = 0, size = fm_install_rv_show.getChildCount(); i < size; i++) {
|
||||
height += fm_install_rv_show.getChildAt(i).getMeasuredHeight();
|
||||
}
|
||||
height = fm_install_rv_show.getHeight()
|
||||
- DisplayUtils.getInternalDimensionSize(context.getResources(), "status_bar_height") - height;
|
||||
if (height < 0) {
|
||||
height = 0;
|
||||
}
|
||||
Utils.log("height = " + height);
|
||||
}
|
||||
|
||||
ViewGroup.LayoutParams params = viewHolder.itemView.getLayoutParams();
|
||||
params.height = height;
|
||||
viewHolder.itemView.setLayoutParams(params);
|
||||
|
||||
viewHolder.reuse_nodata_skip_tv_hint.setText("暂无游戏");
|
||||
viewHolder.reuse_nodata_skip_tv_btn.setText("查看精品推荐");
|
||||
viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@ -390,12 +339,21 @@ public class InstallFragmentAdapter extends RecyclerView.Adapter<RecyclerView.Vi
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
if (gameList.isEmpty() && (isEmpty || !isRemove)) {
|
||||
return 1;
|
||||
}
|
||||
if (isRemove) {
|
||||
return gameList.size();
|
||||
}
|
||||
return gameList.size() + 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
return position;
|
||||
if (gameList.size() != 0 && position >= 0 && position < gameList.size()) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private void initGameNormal(final GameNormalViewHolder holder, final GameEntity gameEntity, int i) {
|
||||
|
||||
Reference in New Issue
Block a user