Compare commits
26 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fc1dc858e2 | |||
| e656acec1d | |||
| 6fa4994e04 | |||
| a929706219 | |||
| 62effd1cc1 | |||
| 417b597d1d | |||
| 2fabb9013a | |||
| 835dcc6446 | |||
| fba0a6ec71 | |||
| 9a2f4c984c | |||
| d870e68001 | |||
| 8e7fcfb746 | |||
| a995e132f3 | |||
| 6b9921c5a7 | |||
| 75695812ee | |||
| eae0414cb4 | |||
| 7b203bedfc | |||
| da20b817d2 | |||
| ef1f2251b5 | |||
| c907835ce7 | |||
| 3be623dd63 | |||
| 045c1e0305 | |||
| c292e79d94 | |||
| cb54d87daf | |||
| a29c0bd466 | |||
| 575ba33e43 |
@ -4,15 +4,24 @@ android {
|
||||
compileSdkVersion 21
|
||||
buildToolsVersion "23.0.3"
|
||||
|
||||
dexOptions {
|
||||
jumboMode = true
|
||||
}
|
||||
|
||||
/**
|
||||
* 定位编译出错的图片
|
||||
*/
|
||||
aaptOptions.cruncherEnabled = false
|
||||
aaptOptions.useNewCruncher = false
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.gh.gamecenter"
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 21
|
||||
versionCode 18
|
||||
versionName "2.3"
|
||||
versionCode 19
|
||||
versionName "2.4"
|
||||
|
||||
// 默认的渠道
|
||||
// manifestPlaceholders = [CHANNEL_VALUE: "GH_TEST"]
|
||||
// multiDexEnabled true
|
||||
}
|
||||
|
||||
/**
|
||||
@ -39,6 +48,12 @@ android {
|
||||
}
|
||||
}
|
||||
|
||||
// sourceSets {
|
||||
// main {
|
||||
// jniLibs.srcDirs = ['libs']
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* 多渠道打包
|
||||
*/
|
||||
@ -129,4 +144,10 @@ dependencies {
|
||||
// zxing 二维码扫描以及生成
|
||||
compile 'com.google.zxing:core:3.2.1'
|
||||
compile 'com.google.zxing:android-core:3.2.1'
|
||||
}
|
||||
//tinker
|
||||
// compile("com.tencent.tinker:tinker-android-lib:${TINKER_VERSION}") { changing = true }
|
||||
// compile "com.android.support:multidex:1.0.1"
|
||||
}
|
||||
|
||||
// 依赖插件脚本
|
||||
//apply from: 'tinker-support.gradle'
|
||||
@ -38,6 +38,8 @@
|
||||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
|
||||
<!-- 小米推送需要的权限 -->
|
||||
<uses-permission android:name="com.gh.gamecenter.permission.MIPUSH_RECEIVE" />
|
||||
<!-- 修改系统设置的权限 -->
|
||||
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
|
||||
|
||||
<permission
|
||||
android:name="com.gh.gamecenter.permission.MIPUSH_RECEIVE"
|
||||
@ -162,6 +164,36 @@
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.LibaoDetailActivity"
|
||||
android:screenOrientation="portrait"/>
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.ShareGhWfifActivity"
|
||||
android:screenOrientation="portrait"/>
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.ShareGhActivity"
|
||||
android:screenOrientation="portrait"/>
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.CleanApkActivity"
|
||||
android:screenOrientation="portrait"/>
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.KcSelectGameActivity"
|
||||
android:screenOrientation="portrait"/>
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.ChooseReceiverActivity"
|
||||
android:screenOrientation="portrait"/>
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.ReceiverWaitingActivity"
|
||||
android:screenOrientation="portrait"/>
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.FileSenderActivity"
|
||||
android:screenOrientation="portrait"/>
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.FileReceiverActivity"
|
||||
android:screenOrientation="portrait"/>
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.SelectUserIconActivity"
|
||||
android:screenOrientation="portrait"/>
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.AboutActivity"
|
||||
android:screenOrientation="portrait"/>
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.SkipActivity"
|
||||
android:theme="@android:style/Theme.Translucent">
|
||||
@ -299,8 +331,12 @@
|
||||
<service
|
||||
android:name="com.gh.download.DownloadService" />
|
||||
|
||||
<!--<service-->
|
||||
<!--android:name="com.gh.base.AppTinkerResultService"-->
|
||||
<!--android:exported="false" />-->
|
||||
|
||||
<service
|
||||
android:name=".statistics.AppStaticService" />
|
||||
android:name="com.gh.gamecenter.statistics.AppStaticService" />
|
||||
|
||||
<service
|
||||
android:name="com.xiaomi.push.service.XMJobService"
|
||||
|
||||
67
app/src/main/assets/Home.html
Normal file
67
app/src/main/assets/Home.html
Normal file
@ -0,0 +1,67 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/html">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>光环助手</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<style>
|
||||
body {
|
||||
font: 100%/1.0 'Microsoft YaHei','Helvetica Neue',Helvetica,Arial,sans-serif;
|
||||
background-color: #fff;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
header {
|
||||
}
|
||||
|
||||
article {
|
||||
width:100%;
|
||||
max-width:720px;
|
||||
clear: both;
|
||||
margin: 0 auto;
|
||||
margin-top: 20%;
|
||||
text-align: center;
|
||||
margin-bottom:20%;
|
||||
}
|
||||
.title{margin-top: 4%;font-size:1.7em;color:#191919;text-align:center;}
|
||||
.info{margin-top: 18%;font-size:1.0em;color:#191919;line-height:1.3em;}
|
||||
.download {text-align: center;}
|
||||
.download a{font-size:1.8em;padding:0.2em; text-align:center;color:#ffffff;margin: 0 auto;width:56%;background-color:#2999f9;border-radius:8px; text-decoration:none;display:block;line-height:1.8em;}
|
||||
|
||||
@media only screen and (min-width: 1080px) {
|
||||
article {
|
||||
width:100%;
|
||||
max-width:720px;
|
||||
clear: both;
|
||||
margin: 0 auto;
|
||||
margin-top: 5%;
|
||||
text-align: center;
|
||||
margin-bottom:20%;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<header>
|
||||
</header>
|
||||
|
||||
<article>
|
||||
<img src="http://192.168.43.1:3100/image/gh_icon.png" width="28%">
|
||||
<p class="title">光环助手</p>
|
||||
<br class="info">乐于分享的人是最帅的^_^ </p>
|
||||
<div class="download">
|
||||
<a href="http://192.168.43.1:3100/download/ghzs.apk">免流量下载</a>
|
||||
</div>
|
||||
<p class="title"><font color="#9A9A9A" size="3em">仅限安卓系统 </font></p>
|
||||
</article>
|
||||
</body>
|
||||
</html>
|
||||
File diff suppressed because it is too large
Load Diff
@ -23,8 +23,11 @@ import com.xiaomi.mipush.sdk.MiPushClient;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
public class AppController extends Application {
|
||||
//public class AppController extends TinkerApplication {
|
||||
|
||||
public static final String TAG = AppController.class.getSimpleName();
|
||||
// xiaomi push appid
|
||||
@ -39,6 +42,17 @@ public class AppController extends Application {
|
||||
|
||||
private boolean isFinish = false;
|
||||
|
||||
//快传文件发送单线程
|
||||
public static Executor FILE_SENDER_EXECUTOR = Executors.newSingleThreadExecutor();
|
||||
|
||||
//快传文件发送主要的线程池
|
||||
public static Executor MAIN_EXECUTOR = Executors.newFixedThreadPool(5);
|
||||
|
||||
// public AppController() {
|
||||
// super(ShareConstants.TINKER_ENABLE_ALL, "com.gh.base.AppControllerLike",
|
||||
// "com.tencent.tinker.loader.TinkerLoader", false);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
|
||||
51
app/src/main/java/com/gh/base/AppControllerLike.java
Normal file
51
app/src/main/java/com/gh/base/AppControllerLike.java
Normal file
@ -0,0 +1,51 @@
|
||||
//package com.gh.base;
|
||||
//
|
||||
//
|
||||
//import android.annotation.TargetApi;
|
||||
//import android.app.Application;
|
||||
//import android.content.Context;
|
||||
//import android.content.Intent;
|
||||
//import android.os.Build;
|
||||
//import android.support.multidex.MultiDex;
|
||||
//
|
||||
//import com.tencent.tinker.lib.listener.DefaultPatchListener;
|
||||
//import com.tencent.tinker.lib.listener.PatchListener;
|
||||
//import com.tencent.tinker.lib.patch.AbstractPatch;
|
||||
//import com.tencent.tinker.lib.patch.UpgradePatch;
|
||||
//import com.tencent.tinker.lib.reporter.DefaultLoadReporter;
|
||||
//import com.tencent.tinker.lib.reporter.DefaultPatchReporter;
|
||||
//import com.tencent.tinker.lib.reporter.LoadReporter;
|
||||
//import com.tencent.tinker.lib.reporter.PatchReporter;
|
||||
//import com.tencent.tinker.lib.tinker.TinkerInstaller;
|
||||
//import com.tencent.tinker.loader.app.DefaultApplicationLike;
|
||||
//
|
||||
//public class AppControllerLike extends DefaultApplicationLike {
|
||||
//
|
||||
// public AppControllerLike(Application application, int tinkerFlags, boolean tinkerLoadVerifyFlag,
|
||||
// long applicationStartElapsedTime, long applicationStartMillisTime,
|
||||
// Intent tinkerResultIntent) {
|
||||
// super(application, tinkerFlags, tinkerLoadVerifyFlag, applicationStartElapsedTime,
|
||||
// applicationStartMillisTime, tinkerResultIntent);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onBaseContextAttached(Context base) {
|
||||
// super.onBaseContextAttached(base);
|
||||
// MultiDex.install(base);
|
||||
//
|
||||
// LoadReporter loadReporter = new DefaultLoadReporter(getApplication());
|
||||
// PatchReporter patchReporter = new DefaultPatchReporter(getApplication());
|
||||
// PatchListener patchListener = new DefaultPatchListener(getApplication());
|
||||
// AbstractPatch upgradePatchProcessor = new UpgradePatch();
|
||||
//
|
||||
// TinkerInstaller.install(this, loadReporter, patchReporter, patchListener,
|
||||
// AppTinkerResultService.class, upgradePatchProcessor);
|
||||
//// TinkerInstaller.install(this);
|
||||
// }
|
||||
//
|
||||
// @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
|
||||
// public void registerActivityLifecycleCallbacks(Application.ActivityLifecycleCallbacks callback) {
|
||||
// getApplication().registerActivityLifecycleCallbacks(callback);
|
||||
// }
|
||||
//
|
||||
//}
|
||||
29
app/src/main/java/com/gh/base/AppTinkerResultService.java
Normal file
29
app/src/main/java/com/gh/base/AppTinkerResultService.java
Normal file
@ -0,0 +1,29 @@
|
||||
//package com.gh.base;
|
||||
//
|
||||
//import com.gh.common.util.Utils;
|
||||
//import com.tencent.tinker.lib.service.DefaultTinkerResultService;
|
||||
//import com.tencent.tinker.lib.service.PatchResult;
|
||||
//import com.tencent.tinker.lib.util.TinkerServiceInternals;
|
||||
//
|
||||
//import java.io.File;
|
||||
//
|
||||
//
|
||||
//public class AppTinkerResultService extends DefaultTinkerResultService {
|
||||
//
|
||||
// @Override
|
||||
// public void onPatchResult(PatchResult result) {
|
||||
// if (result == null) {
|
||||
// return;
|
||||
// }
|
||||
// Utils.log(result);
|
||||
//
|
||||
// //first, we want to kill the recover process
|
||||
// TinkerServiceInternals.killTinkerPatchServiceProcess(getApplicationContext());
|
||||
//
|
||||
// if (result.isSuccess) {
|
||||
// Utils.log("Tinkder Success");
|
||||
// deleteRawPatchFile(new File(result.rawPatchFilePath));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//}
|
||||
@ -140,7 +140,7 @@ public class BaseActivity extends Activity implements OnCallBackListener {
|
||||
}
|
||||
}
|
||||
|
||||
ShareUtils.getInstance(this).showShareWindows(new View(this), url, gameName, icon, newsTitle, isPlugin);
|
||||
ShareUtils.getInstance(this).showShareWindows(new View(this), url, gameName, icon, newsTitle, isPlugin, true);
|
||||
|
||||
if (newsTitle == null) {
|
||||
DataUtils.onEvent(this, "内容分享", gameName);
|
||||
|
||||
@ -344,6 +344,7 @@ public abstract class BaseDetailActivity extends BaseActivity implements View.On
|
||||
String str = detail_tv_per.getText().toString();
|
||||
if ("下载中".equals(str)) {
|
||||
Intent intent = new Intent(this, DownloadManagerActivity.class);
|
||||
intent.putExtra("currentItem", 1);
|
||||
intent.putExtra("url", gameEntity.getApk().get(0).getUrl());
|
||||
intent.putExtra("entrance", entrance + "+(" + name + "[" + title + "])");
|
||||
startActivity(intent);
|
||||
|
||||
@ -133,7 +133,7 @@ public class BaseFragmentActivity extends FragmentActivity {
|
||||
}
|
||||
}
|
||||
|
||||
ShareUtils.getInstance(this).showShareWindows(new View(this), url, gameName, icon, newsTitle, isPlugin);
|
||||
ShareUtils.getInstance(this).showShareWindows(new View(this), url, gameName, icon, newsTitle, isPlugin, true);
|
||||
|
||||
if (newsTitle == null){
|
||||
DataUtils.onEvent(this, "内容分享", gameName);
|
||||
|
||||
@ -132,6 +132,7 @@ public class HomeFragment extends Fragment implements View.OnClickListener {
|
||||
|
||||
Intent intent = new Intent(getActivity(), DownloadManagerActivity.class);
|
||||
intent.putExtra("entrance", "(工具栏)");
|
||||
intent.putExtra("currentItem", 0);
|
||||
startActivity(intent);
|
||||
} else if (id == R.id.actionbar_iv_search) {
|
||||
DataUtils.onEvent(getActivity(), "主页", "搜索图标");
|
||||
|
||||
@ -6,11 +6,11 @@ import android.content.SharedPreferences;
|
||||
|
||||
public class Config {
|
||||
|
||||
public static final String HOST = "http://api.ghzhushou.com/v2d3/";
|
||||
public static final String USER_HOST = "http://user.ghzhushou.com/v1d1/";
|
||||
public static final String HOST = "http://api.ghzhushou.com/v2d4/";
|
||||
public static final String USER_HOST = "http://user.ghzhushou.com/v1d2/";
|
||||
public static final String COMMENT_HOST = "http://comment.ghzhushou.com/v1d1/";
|
||||
public static final String DATA_HOST = "http://data.ghzhushou.com/";
|
||||
public static final String LIBAO_HOST = "http://libao.ghzhushou.com/v1d0/";
|
||||
public static final String LIBAO_HOST = "http://libao.ghzhushou.com/v1d1/";
|
||||
public static final String PREFERENCE = "ghzhushou";
|
||||
|
||||
public static boolean isShow(Context context) {
|
||||
|
||||
@ -22,5 +22,6 @@ public class ItemViewType {
|
||||
public static final int LOADING = 14; // 加载布局
|
||||
public static final int LIBAO_NORMAL = 15; // 礼包正常布局
|
||||
public static final int LIBAO_SKIP_CONCERN = 16; // 跳转关注管理页面布局
|
||||
public static final int KC_HINT = 16;
|
||||
|
||||
}
|
||||
|
||||
@ -2,7 +2,10 @@ package com.gh.common.util;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.media.ExifInterface;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -84,4 +87,30 @@ public class BitmapUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Drawable转Bitmap
|
||||
*
|
||||
*/
|
||||
public static Bitmap drawableToBitmap(Drawable drawable){
|
||||
if(drawable == null){
|
||||
return null;
|
||||
}
|
||||
|
||||
// 取 drawable 的长宽
|
||||
int w = drawable.getIntrinsicWidth();
|
||||
int h = drawable.getIntrinsicHeight();
|
||||
// 取 drawable 的颜色格式
|
||||
Bitmap.Config config = drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888
|
||||
: Bitmap.Config.RGB_565;
|
||||
//建立对应的Bitmap
|
||||
Bitmap bitmap = Bitmap.createBitmap(w, h, config);
|
||||
// 建立对应 bitmap 的画布
|
||||
Canvas canvas = new Canvas(bitmap);
|
||||
drawable.setBounds(0, 0, w, h);
|
||||
// 把 drawable 内容画到画布中
|
||||
drawable.draw(canvas);
|
||||
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -2,14 +2,17 @@ package com.gh.common.util;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.gh.gamecenter.eventbus.EBReuse;
|
||||
import com.gh.gamecenter.retrofit.Response;
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager;
|
||||
|
||||
import org.json.JSONArray;
|
||||
|
||||
import de.greenrobot.event.EventBus;
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.RequestBody;
|
||||
import okhttp3.ResponseBody;
|
||||
import retrofit2.adapter.rxjava.HttpException;
|
||||
import rx.Observable;
|
||||
import rx.functions.Func1;
|
||||
import rx.schedulers.Schedulers;
|
||||
@ -59,7 +62,19 @@ public class ConcernUtils {
|
||||
})
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe(new Response<ResponseBody>());
|
||||
.subscribe(new Response<ResponseBody>(){
|
||||
@Override
|
||||
public void onResponse(ResponseBody response) {
|
||||
super.onResponse(response);
|
||||
EventBus.getDefault().post(new EBReuse("UpdateConcernSuccess"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(HttpException e) {
|
||||
super.onFailure(e);
|
||||
EventBus.getDefault().post(new EBReuse("UpdateConcernFailure"));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,20 +1,38 @@
|
||||
package com.gh.common.util;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.graphics.Bitmap;
|
||||
import android.net.Uri;
|
||||
import android.os.Handler;
|
||||
import android.text.Html;
|
||||
import android.text.Spanned;
|
||||
import android.view.Display;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gh.base.AppController;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.kuaichuan.WifiMgr;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
public class DialogUtils {
|
||||
|
||||
@ -32,6 +50,168 @@ public class DialogUtils {
|
||||
|
||||
private static boolean isShow = false;
|
||||
|
||||
// 快传成绩单
|
||||
public static void showKuaiChuanResult(final Activity activity, Handler handler, int requestCode, final String picName) {
|
||||
|
||||
AppController.remove("FileInfo");
|
||||
|
||||
List<Map<String, String>> mapList = (List<Map<String, String>>) AppController.get("sendData", true);
|
||||
if (mapList == null || mapList.size() == 0) return;
|
||||
|
||||
WifiMgr.getInstance(activity).disconnectCurrentNetwork(); // 断开当前WiFi
|
||||
|
||||
// int heightPixels = getContext().getResources().getDisplayMetrics().heightPixels;
|
||||
// int widthPixels = getContext().getResources().getDisplayMetrics().widthPixels;
|
||||
|
||||
int filesCount = mapList.size();
|
||||
int filesSize = 0;
|
||||
int sendTime = 0;
|
||||
|
||||
View view = View.inflate(activity
|
||||
, R.layout.dialog_kuaichuan, null);
|
||||
final LinearLayout mShareLl = (LinearLayout) view.findViewById(R.id.kuaichuan_dialog_ll);
|
||||
final LinearLayout mShareBottomLl = (LinearLayout) view.findViewById(R.id.kuaichuan_dialog_share_rl);
|
||||
RelativeLayout content = (RelativeLayout) view.findViewById(R.id.kuaichuan_dialog);
|
||||
LinearLayout shareIconLl = (LinearLayout) view.findViewById(R.id.kuaichuan_icon_ll);
|
||||
ImageView qrCode = (ImageView) view.findViewById(R.id.kuaichuan_qrcode);
|
||||
TextView dateTv = (TextView) view.findViewById(R.id.kuaichuan_dialog_date);
|
||||
TextView countTv = (TextView) view.findViewById(R.id.kuaichuan_send_count);
|
||||
TextView sizeTv = (TextView) view.findViewById(R.id.kuaichuan_send_size);
|
||||
TextView speedTv = (TextView) view.findViewById(R.id.kuaichuan_send_speed);
|
||||
TextView timeCount = (TextView) view.findViewById(R.id.kuaichuan_time_count);
|
||||
TextView timeTv = (TextView) view.findViewById(R.id.kuaichuan_time_tv);
|
||||
TextView sendCountTv = (TextView) view.findViewById(R.id.dialog_send_tv);
|
||||
ImageView closeIv = (ImageView) view.findViewById(R.id.kuaichuan_dialog_colse);
|
||||
// content.setLayoutParams(new LinearLayout.LayoutParams((int)(((float)heightPixels)*0.85), (int)((float)widthPixels*0.81)));
|
||||
|
||||
final Dialog dialog = new Dialog(activity);
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setCanceledOnTouchOutside(false);
|
||||
dialog.setContentView(view);
|
||||
dialog.show();
|
||||
|
||||
Window dialogWindow = dialog.getWindow();
|
||||
WindowManager m = activity.getWindowManager();
|
||||
Display d = m.getDefaultDisplay();
|
||||
WindowManager.LayoutParams p = dialogWindow.getAttributes();
|
||||
p.height = (int) (d.getHeight() * 0.82);
|
||||
p.width = (int) (d.getWidth() * 0.80);
|
||||
dialogWindow.setAttributes(p);
|
||||
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日", Locale.getDefault());
|
||||
dateTv.setText(format.format(new Date().getTime()));
|
||||
|
||||
for (Map<String, String> map : mapList) {
|
||||
int size = Integer.parseInt(map.get("apkSize"));
|
||||
int time = 10;
|
||||
try {
|
||||
time = Integer.parseInt(map.get("sendTime"));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
String apkPath = map.get("apkPath");
|
||||
filesSize = filesSize + size;
|
||||
sendTime = sendTime + time;
|
||||
|
||||
if (shareIconLl.getChildCount() >= 5) continue;
|
||||
|
||||
android.content.pm.PackageManager pm = activity.getPackageManager();
|
||||
PackageInfo info = pm.getPackageArchiveInfo(apkPath,
|
||||
android.content.pm.PackageManager.GET_ACTIVITIES);
|
||||
if (info != null) {
|
||||
ApplicationInfo appInfo = info.applicationInfo;
|
||||
appInfo.sourceDir = apkPath;
|
||||
appInfo.publicSourceDir = apkPath;
|
||||
Bitmap bitmap = BitmapUtils.drawableToBitmap(appInfo.loadIcon(pm));
|
||||
|
||||
ImageView imageView = new ImageView(activity);
|
||||
imageView.setLayoutParams(new LinearLayout.LayoutParams(DisplayUtils.dip2px(activity, 25)
|
||||
, DisplayUtils.dip2px(activity, 24)));
|
||||
imageView.setImageBitmap(bitmap);
|
||||
shareIconLl.addView(imageView);
|
||||
}
|
||||
}
|
||||
|
||||
if (requestCode == 0x170) { // 发送
|
||||
qrCode.setImageResource(R.drawable.kc_qrcode_120);
|
||||
sendCountTv.setText("成功传送游戏");
|
||||
} else {
|
||||
qrCode.setImageResource(R.drawable.kc_qrcode_110);
|
||||
sendCountTv.setText("成功接收游戏");
|
||||
}
|
||||
|
||||
double size = (((float)filesSize/1024)/1024);
|
||||
String sizeName;
|
||||
if (size > 1024) {
|
||||
DecimalFormat df = new DecimalFormat("#.0");
|
||||
sizeName = df.format(size/1024) + "GB";
|
||||
} else {
|
||||
DecimalFormat df = new DecimalFormat("#.0");
|
||||
sizeName = df.format(size) + "MB";
|
||||
}
|
||||
|
||||
|
||||
int i = (filesSize / 1024) / (sendTime / 1000);
|
||||
String speed ;
|
||||
if (i >= 1000) {
|
||||
float mSpeed = i / 1024f;
|
||||
DecimalFormat df = new DecimalFormat("#.0");
|
||||
String str = df.format(mSpeed);
|
||||
if (str.length() > 4) {
|
||||
str = str.substring(0, 4);
|
||||
}
|
||||
speed = str + "MB/s";
|
||||
} else {
|
||||
speed = i + "KB/s";
|
||||
}
|
||||
|
||||
if (sendTime > 60000) {
|
||||
timeCount.setText(String.valueOf(sendTime/1000/60));
|
||||
timeTv.setText("分钟传送完成");
|
||||
} else {
|
||||
timeCount.setText(String.valueOf(sendTime/1000));
|
||||
timeTv.setText("秒传送完成");
|
||||
}
|
||||
|
||||
sizeTv.setText(sizeName);
|
||||
speedTv.setText(speed);
|
||||
countTv.setText(filesCount + "个");
|
||||
|
||||
// 延迟操作,等待截图部分绘制完成
|
||||
handler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mShareLl.setDrawingCacheEnabled(true);
|
||||
mShareLl.buildDrawingCache();
|
||||
Bitmap drawingCache = mShareLl.getDrawingCache();
|
||||
saveBitmap(drawingCache, activity, picName);
|
||||
MessageShareUtils.getInstance(activity).showShareWindows(mShareBottomLl, drawingCache, picName, 2);
|
||||
mShareBottomLl.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}, 200);
|
||||
|
||||
closeIv.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
dialog.cancel();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void saveBitmap(Bitmap bm, Activity activity, String picName) {
|
||||
File file = new File(activity.getExternalCacheDir().getPath() + "/ShareImg");
|
||||
if (!file.isDirectory()) {
|
||||
file.delete();
|
||||
file.mkdirs();
|
||||
}
|
||||
if (!file.exists()) {
|
||||
file.mkdirs();
|
||||
}
|
||||
MessageShareUtils.getInstance(activity).writeBitmap(file.getPath(), picName, bm, false);
|
||||
|
||||
}
|
||||
|
||||
public static void showWarningDialog(Context context, String title, CharSequence msg, String cancel, String confirm,
|
||||
final ConfiremListener cmListener, final CancelListener clListener) {
|
||||
|
||||
@ -169,6 +349,8 @@ public class DialogUtils {
|
||||
|
||||
TextView hintdialog_confirm = (TextView) view.findViewById(R.id.hintdialog_confirm);
|
||||
|
||||
hintdialog_confirm.setText(confirm);
|
||||
|
||||
hintdialog_confirm.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
@ -9,8 +9,6 @@ import android.support.v7.widget.RecyclerView;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
@ -22,6 +20,7 @@ import com.gh.download.DownloadManager;
|
||||
import com.gh.download.DownloadStatus;
|
||||
import com.gh.gamecenter.DownloadManagerActivity;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.adapter.viewholder.GameViewHolder;
|
||||
import com.gh.gamecenter.entity.GameEntity;
|
||||
import com.gh.gamecenter.manager.PackageManager;
|
||||
|
||||
@ -87,14 +86,7 @@ public class DownloadItemUtils {
|
||||
}
|
||||
|
||||
// 更新正常的条目,只有一个apk包
|
||||
public static void updateNormalItem(Context context,
|
||||
TextView textView,
|
||||
ProgressBar game_progressbar,
|
||||
LinearLayout game_ll_info,
|
||||
TextView download_speed,
|
||||
TextView download_percentage,
|
||||
TextView downloadBtn,
|
||||
GameEntity gameEntity,
|
||||
public static void updateNormalItem(Context context, GameViewHolder holder, GameEntity gameEntity,
|
||||
boolean isShowPlatform) {
|
||||
|
||||
ArrayMap<String, DownloadEntity> entryMap = gameEntity.getEntryMap();
|
||||
@ -102,71 +94,63 @@ public class DownloadItemUtils {
|
||||
DownloadEntity downloadEntity = entryMap.get(gameEntity.getApk().get(0).getPlatform());
|
||||
if (downloadEntity != null) {
|
||||
// 更改进度条和提示文本的状态
|
||||
changeStatus(context, textView, game_progressbar, game_ll_info, download_speed, download_percentage, downloadBtn,
|
||||
downloadEntity, isShowPlatform, true);
|
||||
changeStatus(context, holder, downloadEntity, isShowPlatform, true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
textView.setVisibility(View.VISIBLE);
|
||||
game_progressbar.setVisibility(View.GONE);
|
||||
game_ll_info.setVisibility(View.GONE);
|
||||
holder.gameDes.setVisibility(View.VISIBLE);
|
||||
holder.gameProgressbar.setVisibility(View.GONE);
|
||||
holder.gameInfo.setVisibility(View.GONE);
|
||||
|
||||
downloadBtn.setTextColor(Color.WHITE);
|
||||
holder.gameDownloadBtn.setTextColor(Color.WHITE);
|
||||
if (gameEntity.isPluggable()) {
|
||||
downloadBtn.setText("插件化");
|
||||
holder.gameDownloadBtn.setText("插件化");
|
||||
DownloadEntity downloadEntity = DownloadManager.getInstance(context).getByPackage(
|
||||
gameEntity.getApk().get(0).getPackageName());
|
||||
if (downloadEntity == null
|
||||
|| downloadEntity.getUrl().equals(gameEntity.getApk().get(0).getUrl())) {
|
||||
downloadBtn.setClickable(true);
|
||||
downloadBtn.setBackgroundResource(R.drawable.game_item_btn_plugin_style);
|
||||
holder.gameDownloadBtn.setClickable(true);
|
||||
holder.gameDownloadBtn.setBackgroundResource(R.drawable.game_item_btn_plugin_style);
|
||||
} else {
|
||||
downloadBtn.setClickable(false);
|
||||
downloadBtn.setBackgroundResource(R.drawable.game_item_btn_pause_up);
|
||||
holder.gameDownloadBtn.setClickable(false);
|
||||
holder.gameDownloadBtn.setBackgroundResource(R.drawable.game_item_btn_pause_up);
|
||||
}
|
||||
} else if (PackageManager.isInstalled(gameEntity.getApk().get(0).getPackageName())) {
|
||||
if (PackageManager.isCanUpdate(gameEntity.getId(), gameEntity.getApk().get(0).getPackageName())) {
|
||||
downloadBtn.setText("更新");
|
||||
downloadBtn.setBackgroundResource(R.drawable.game_item_btn_download_style);
|
||||
holder.gameDownloadBtn.setText("更新");
|
||||
holder.gameDownloadBtn.setBackgroundResource(R.drawable.game_item_btn_download_style);
|
||||
} else {
|
||||
if (gameEntity.getTag() != null && gameEntity.getTag().size() != 0
|
||||
&& !TextUtils.isEmpty(gameEntity.getApk().get(0).getGhVersion())
|
||||
&& !PackageUtils.isSignature(context, gameEntity.getApk().get(0).getPackageName())) {
|
||||
downloadBtn.setText("插件化");
|
||||
holder.gameDownloadBtn.setText("插件化");
|
||||
DownloadEntity downloadEntity = DownloadManager.getInstance(context).getByPackage(
|
||||
gameEntity.getApk().get(0).getPackageName());
|
||||
if (downloadEntity == null
|
||||
|| downloadEntity.getUrl().equals(gameEntity.getApk().get(0).getUrl())) {
|
||||
downloadBtn.setClickable(true);
|
||||
downloadBtn.setBackgroundResource(R.drawable.game_item_btn_plugin_style);
|
||||
holder.gameDownloadBtn.setClickable(true);
|
||||
holder.gameDownloadBtn.setBackgroundResource(R.drawable.game_item_btn_plugin_style);
|
||||
} else {
|
||||
downloadBtn.setClickable(false);
|
||||
downloadBtn.setBackgroundResource(R.drawable.game_item_btn_pause_up);
|
||||
holder.gameDownloadBtn.setClickable(false);
|
||||
holder.gameDownloadBtn.setBackgroundResource(R.drawable.game_item_btn_pause_up);
|
||||
}
|
||||
} else {
|
||||
downloadBtn.setText("启动");
|
||||
downloadBtn.setBackgroundResource(R.drawable.game_item_btn_launch_style);
|
||||
holder.gameDownloadBtn.setText("启动");
|
||||
holder.gameDownloadBtn.setBackgroundResource(R.drawable.game_item_btn_launch_style);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
downloadBtn.setText("下载");
|
||||
downloadBtn.setBackgroundResource(R.drawable.game_item_btn_download_style);
|
||||
holder.gameDownloadBtn.setText("下载");
|
||||
holder.gameDownloadBtn.setBackgroundResource(R.drawable.game_item_btn_download_style);
|
||||
}
|
||||
}
|
||||
|
||||
// 更新插件的条目,有多个apk包
|
||||
public static void updatePluginItem(Context context,
|
||||
TextView textView,
|
||||
ProgressBar game_progressbar,
|
||||
LinearLayout game_ll_info,
|
||||
TextView download_speed,
|
||||
TextView download_percentage,
|
||||
TextView downloadBtn,
|
||||
GameEntity gameEntity,
|
||||
public static void updatePluginItem(Context context, GameViewHolder holder, GameEntity gameEntity,
|
||||
boolean isShowPlatform) {
|
||||
|
||||
GameUtils.setDownloadBtnStatus(context, gameEntity, downloadBtn);
|
||||
GameUtils.setDownloadBtnStatus(context, gameEntity, holder.gameDownloadBtn);
|
||||
|
||||
ArrayMap<String, DownloadEntity> entryMap = gameEntity.getEntryMap();
|
||||
if (entryMap != null && !entryMap.isEmpty()) {
|
||||
@ -182,31 +166,22 @@ public class DownloadItemUtils {
|
||||
|
||||
if (downloadEntity != null) {
|
||||
// 更改进度条和提示文本的状态
|
||||
changeStatus(context, textView, game_progressbar, game_ll_info, download_speed,
|
||||
download_percentage, downloadBtn, downloadEntity, isShowPlatform, false);
|
||||
changeStatus(context, holder, downloadEntity, isShowPlatform, false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
textView.setVisibility(View.VISIBLE);
|
||||
game_progressbar.setVisibility(View.GONE);
|
||||
game_ll_info.setVisibility(View.GONE);
|
||||
holder.gameDes.setVisibility(View.VISIBLE);
|
||||
holder.gameProgressbar.setVisibility(View.GONE);
|
||||
holder.gameInfo.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
// 更改进度条和提示文本的状态
|
||||
public static void changeStatus(Context context,
|
||||
TextView textView,
|
||||
ProgressBar game_progressbar,
|
||||
LinearLayout game_ll_info,
|
||||
TextView download_speed,
|
||||
TextView download_percentage,
|
||||
TextView downloadBtn,
|
||||
DownloadEntity downloadEntity,
|
||||
boolean isShowPlatform,
|
||||
boolean isNormal) {
|
||||
textView.setVisibility(View.GONE);
|
||||
game_progressbar.setVisibility(View.VISIBLE);
|
||||
game_ll_info.setVisibility(View.VISIBLE);
|
||||
public static void changeStatus(Context context, GameViewHolder holder, DownloadEntity downloadEntity,
|
||||
boolean isShowPlatform, boolean isNormal) {
|
||||
holder.gameDes.setVisibility(View.GONE);
|
||||
holder.gameProgressbar.setVisibility(View.VISIBLE);
|
||||
holder.gameInfo.setVisibility(View.VISIBLE);
|
||||
|
||||
String platform = PlatformUtils.getInstance(context)
|
||||
.getPlatformName(downloadEntity.getPlatform());
|
||||
@ -214,131 +189,128 @@ public class DownloadItemUtils {
|
||||
DownloadStatus status = downloadEntity.getStatus();
|
||||
if (status.equals(DownloadStatus.downloading)) {
|
||||
if (!"pause".equals(DownloadManager.getInstance(context).getStatus(downloadEntity.getUrl()))) {
|
||||
game_progressbar.setProgress((int) (downloadEntity.getPercent() * 10));
|
||||
holder.gameProgressbar.setProgress((int) (downloadEntity.getPercent() * 10));
|
||||
if (isShowPlatform && platform != null) {
|
||||
download_speed.setText(String.format("%s - %s(剩%s)", platform,
|
||||
holder.gameDownloadSpeed.setText(String.format("%s - %s(剩%s)", platform,
|
||||
SpeedUtils.getSpeed(downloadEntity.getSpeed()),
|
||||
SpeedUtils.getRemainTime(downloadEntity.getSize(), downloadEntity.getProgress(), downloadEntity.getSpeed() * 1024)));
|
||||
} else {
|
||||
download_speed.setText(String.format("%s(剩%s)", SpeedUtils.getSpeed(downloadEntity.getSpeed()),
|
||||
holder.gameDownloadSpeed.setText(String.format("%s(剩%s)", SpeedUtils.getSpeed(downloadEntity.getSpeed()),
|
||||
SpeedUtils.getRemainTime(downloadEntity.getSize(), downloadEntity.getProgress(), downloadEntity.getSpeed() * 1024)));
|
||||
}
|
||||
download_percentage.setText(downloadEntity.getPercent() + "%");
|
||||
holder.gameDownloadPercentage.setText(downloadEntity.getPercent() + "%");
|
||||
}
|
||||
|
||||
if (isNormal) {
|
||||
downloadBtn.setText("下载中");
|
||||
downloadBtn.setBackgroundResource(R.drawable.game_item_btn_downloading_style);
|
||||
downloadBtn.setTextColor(context.getResources().getColorStateList(R.color.text_downloading_style));
|
||||
holder.gameDownloadBtn.setText("下载中");
|
||||
holder.gameDownloadBtn.setBackgroundResource(R.drawable.game_item_btn_downloading_style);
|
||||
holder.gameDownloadBtn.setTextColor(context.getResources().getColorStateList(R.color.text_downloading_style));
|
||||
}
|
||||
} else if (status.equals(DownloadStatus.waiting)) {
|
||||
game_progressbar.setProgress((int) (downloadEntity.getPercent() * 10));
|
||||
holder.gameProgressbar.setProgress((int) (downloadEntity.getPercent() * 10));
|
||||
if (isShowPlatform && platform != null) {
|
||||
download_speed.setText(String.format("%s - 等待", platform));
|
||||
holder.gameDownloadSpeed.setText(String.format("%s - 等待", platform));
|
||||
} else {
|
||||
download_speed.setText("等待");
|
||||
holder.gameDownloadSpeed.setText("等待");
|
||||
}
|
||||
download_percentage.setText(downloadEntity.getPercent() + "%");
|
||||
holder.gameDownloadPercentage.setText(downloadEntity.getPercent() + "%");
|
||||
|
||||
if (isNormal) {
|
||||
downloadBtn.setText("下载中");
|
||||
downloadBtn.setBackgroundResource(R.drawable.game_item_btn_downloading_style);
|
||||
downloadBtn.setTextColor(context.getResources().getColorStateList(R.color.text_downloading_style));
|
||||
holder.gameDownloadBtn.setText("下载中");
|
||||
holder.gameDownloadBtn.setBackgroundResource(R.drawable.game_item_btn_downloading_style);
|
||||
holder.gameDownloadBtn.setTextColor(context.getResources().getColorStateList(R.color.text_downloading_style));
|
||||
}
|
||||
} else if (status.equals(DownloadStatus.pause)
|
||||
|| status.equals(DownloadStatus.timeout)
|
||||
|| status.equals(DownloadStatus.neterror)) {
|
||||
game_progressbar.setProgress((int) (downloadEntity.getPercent() * 10));
|
||||
holder.gameProgressbar.setProgress((int) (downloadEntity.getPercent() * 10));
|
||||
if (isShowPlatform && platform != null) {
|
||||
download_speed.setText(String.format("%s - 暂停", platform));
|
||||
holder.gameDownloadSpeed.setText(String.format("%s - 暂停", platform));
|
||||
} else {
|
||||
download_speed.setText("暂停");
|
||||
holder.gameDownloadSpeed.setText("暂停");
|
||||
}
|
||||
download_percentage.setText(downloadEntity.getPercent() + "%");
|
||||
holder.gameDownloadPercentage.setText(downloadEntity.getPercent() + "%");
|
||||
|
||||
if (isNormal) {
|
||||
downloadBtn.setText("下载中");
|
||||
downloadBtn.setBackgroundResource(R.drawable.game_item_btn_downloading_style);
|
||||
downloadBtn.setTextColor(context.getResources().getColorStateList(R.color.text_downloading_style));
|
||||
holder.gameDownloadBtn.setText("下载中");
|
||||
holder.gameDownloadBtn.setBackgroundResource(R.drawable.game_item_btn_downloading_style);
|
||||
holder.gameDownloadBtn.setTextColor(context.getResources().getColorStateList(R.color.text_downloading_style));
|
||||
}
|
||||
} else if (status.equals(DownloadStatus.done)) {
|
||||
game_progressbar.setProgress(1000);
|
||||
holder.gameProgressbar.setProgress(1000);
|
||||
if (isShowPlatform && platform != null) {
|
||||
download_speed.setText(String.format("%s - 下载完成", platform));
|
||||
holder.gameDownloadSpeed.setText(String.format("%s - 下载完成", platform));
|
||||
} else {
|
||||
download_speed.setText("下载完成");
|
||||
holder.gameDownloadSpeed.setText("下载完成");
|
||||
}
|
||||
download_percentage.setText(R.string.hundred_percent);
|
||||
holder.gameDownloadPercentage.setText(R.string.hundred_percent);
|
||||
|
||||
if (isNormal) {
|
||||
downloadBtn.setText("安装");
|
||||
downloadBtn.setTextColor(Color.WHITE);
|
||||
holder.gameDownloadBtn.setText("安装");
|
||||
holder.gameDownloadBtn.setTextColor(Color.WHITE);
|
||||
if (downloadEntity.isPluggable()
|
||||
&& PackageManager.isInstalled(downloadEntity.getPackageName())) {
|
||||
downloadBtn.setBackgroundResource(R.drawable.game_item_btn_plugin_style);
|
||||
holder.gameDownloadBtn.setBackgroundResource(R.drawable.game_item_btn_plugin_style);
|
||||
} else {
|
||||
downloadBtn.setBackgroundResource(R.drawable.game_item_btn_download_style);
|
||||
holder.gameDownloadBtn.setBackgroundResource(R.drawable.game_item_btn_download_style);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateItem(Context context,
|
||||
TextView textView,
|
||||
ProgressBar game_progressbar,
|
||||
LinearLayout game_ll_info,
|
||||
TextView download_speed,
|
||||
TextView download_percentage,
|
||||
TextView downloadBtn,
|
||||
GameEntity entity,
|
||||
boolean isShowPlatform) {
|
||||
public static void updateItem(Context context, GameEntity gameEntity, GameViewHolder holder, boolean isShowPlatform) {
|
||||
|
||||
// 控制是否显示下载按钮
|
||||
if (!Config.isShow(context) || "光环助手".equals(entity.getName())) {
|
||||
downloadBtn.setVisibility(View.GONE);
|
||||
if (!Config.isShow(context) || "光环助手".equals(gameEntity.getName())) {
|
||||
holder.gameDownloadBtn.setVisibility(View.GONE);
|
||||
} else {
|
||||
downloadBtn.setVisibility(View.VISIBLE);
|
||||
holder.gameDownloadBtn.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
if (entity.getApk() == null || entity.getApk().isEmpty()) {
|
||||
textView.setVisibility(View.VISIBLE);
|
||||
game_progressbar.setVisibility(View.GONE);
|
||||
game_ll_info.setVisibility(View.GONE);
|
||||
downloadBtn.setBackgroundResource(R.drawable.game_item_btn_pause_style);
|
||||
downloadBtn.setText("暂无");
|
||||
downloadBtn.setClickable(false);
|
||||
} else if (entity.getApk().size() == 1) {
|
||||
updateNormalItem(context, textView, game_progressbar, game_ll_info, download_speed,
|
||||
download_percentage, downloadBtn, entity, isShowPlatform);
|
||||
if (gameEntity.isLibaoExists()) {
|
||||
holder.gameLibaoIcon.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
updatePluginItem(context, textView, game_progressbar, game_ll_info, download_speed,
|
||||
download_percentage, downloadBtn, entity, isShowPlatform);
|
||||
holder.gameLibaoIcon.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
}
|
||||
// LibaoDao libaoDao = new LibaoDao(context);
|
||||
// if (libaoDao.isExist(gameEntity.getId())) {
|
||||
// holder.gameLibaoIcon.setVisibility(View.VISIBLE);
|
||||
// } else {
|
||||
//
|
||||
// }
|
||||
|
||||
if (gameEntity.getApk() == null || gameEntity.getApk().isEmpty()) {
|
||||
holder.gameDes.setVisibility(View.VISIBLE);
|
||||
holder.gameProgressbar.setVisibility(View.GONE);
|
||||
holder.gameInfo.setVisibility(View.GONE);
|
||||
holder.gameDownloadBtn.setBackgroundResource(R.drawable.game_item_btn_pause_style);
|
||||
holder.gameDownloadBtn.setText("暂无");
|
||||
holder.gameDownloadBtn.setClickable(false);
|
||||
} else if (gameEntity.getApk().size() == 1) {
|
||||
updateNormalItem(context, holder, gameEntity, isShowPlatform);
|
||||
} else {
|
||||
updatePluginItem(context, holder, gameEntity, isShowPlatform);
|
||||
}
|
||||
|
||||
public static void updateItem(Context context,
|
||||
TextView textView,
|
||||
ProgressBar game_progressbar,
|
||||
LinearLayout game_ll_info,
|
||||
TextView download_speed,
|
||||
TextView download_percentage,
|
||||
TextView downloadBtn,
|
||||
GameEntity entity) {
|
||||
updateItem(context, textView, game_progressbar, game_ll_info, download_speed,
|
||||
download_percentage, downloadBtn, entity, true);
|
||||
}
|
||||
|
||||
private static void setNormalOnClickListener(final Context context,
|
||||
final TextView downloadBtn,
|
||||
final GameEntity gameEntity,
|
||||
final int position,
|
||||
final RecyclerView.Adapter<RecyclerView.ViewHolder> adapter,
|
||||
final String entrance,
|
||||
final String location) {
|
||||
final TextView downloadBtn,
|
||||
final GameEntity gameEntity,
|
||||
final int position,
|
||||
final RecyclerView.Adapter<RecyclerView.ViewHolder> adapter,
|
||||
final String entrance,
|
||||
final String location, final boolean isCloseSoftInput) {
|
||||
downloadBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (isCloseSoftInput) {
|
||||
InputMethodManager imm = (InputMethodManager) context
|
||||
.getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
|
||||
}
|
||||
|
||||
String str = downloadBtn.getText().toString();
|
||||
if ("下载".equals(str)) {
|
||||
if (NetworkUtils.isWifiConnected(context)) {
|
||||
@ -370,6 +342,7 @@ public class DownloadItemUtils {
|
||||
PackageUtils.launchApplicationByPackageName(context, gameEntity.getApk().get(0).getPackageName());
|
||||
} else if ("下载中".equals(str)) {
|
||||
Intent intent = new Intent(context, DownloadManagerActivity.class);
|
||||
intent.putExtra("currentItem", 1);
|
||||
intent.putExtra("url", gameEntity.getApk().get(0).getUrl());
|
||||
intent.putExtra("entrance", entrance + "+(" + location.split(":")[0] + ")");
|
||||
context.startActivity(intent);
|
||||
@ -418,7 +391,7 @@ public class DownloadItemUtils {
|
||||
boolean isCloseSoftInput) {
|
||||
|
||||
if (gameEntity.getApk().size() == 1) {
|
||||
setNormalOnClickListener(context, downloadBtn, gameEntity, position, adapter, entrance, location);
|
||||
setNormalOnClickListener(context, downloadBtn, gameEntity, position, adapter, entrance, location, isCloseSoftInput);
|
||||
} else {
|
||||
setPluginOnClickListener(context, downloadBtn, gameEntity, entrance, location, isCloseSoftInput);
|
||||
}
|
||||
|
||||
@ -1,7 +1,10 @@
|
||||
package com.gh.common.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.util.TypedValue;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.LinearLayout.LayoutParams;
|
||||
import android.widget.TextView;
|
||||
@ -31,17 +34,24 @@ public class GameViewUtils {
|
||||
if (tag == null || tag.isEmpty()) {
|
||||
labelLayout.addView(getGameTagView(context, "官方版", 0));
|
||||
} else {
|
||||
for (int i = 0, size = tag.size() > 3 ? 3 : tag.size(); i < size; i++) {
|
||||
for (int i = 0, size = tag.size(); i < size; i++) {
|
||||
View view;
|
||||
if (i == size - 1) {
|
||||
labelLayout.addView(getGameTagView(context, tag.get(i), 0));
|
||||
view = getGameTagView(context, tag.get(i), 0);
|
||||
} else {
|
||||
labelLayout.addView(getGameTagView(context, tag.get(i), DisplayUtils.dip2px(context, 5)));
|
||||
view = getGameTagView(context, tag.get(i), DisplayUtils.dip2px(context, 5));
|
||||
}
|
||||
if (view != null) {
|
||||
labelLayout.addView(view);
|
||||
}
|
||||
if (labelLayout.getChildCount() == 3) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static TextView getGameTagView(Context context, String tagStr, int rightMargin) {
|
||||
private static TextView getGameTagView(Context context, String tagStr, int rightMargin) {
|
||||
LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams(
|
||||
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
|
||||
lparams.rightMargin = rightMargin;
|
||||
@ -53,8 +63,17 @@ public class GameViewUtils {
|
||||
tag.setBackgroundResource(R.drawable.border_green_bg);
|
||||
tag.setTextColor(context.getResources().getColor(R.color.tag_green));
|
||||
} else {
|
||||
tag.setBackgroundResource(R.drawable.border_blue_bg);
|
||||
tag.setTextColor(context.getResources().getColor(R.color.theme));
|
||||
String colorStr = TagUtils.getInstance(context).getColor(tagStr);
|
||||
if (colorStr == null) {
|
||||
return null;
|
||||
}
|
||||
int color = Color.parseColor(colorStr);
|
||||
GradientDrawable gradientDrawable = new GradientDrawable();
|
||||
gradientDrawable.setColor(Color.TRANSPARENT);
|
||||
gradientDrawable.setStroke(DisplayUtils.dip2px(context, 0.6f), color);
|
||||
tag.setBackgroundDrawable(gradientDrawable);
|
||||
// tag.setBackgroundResource(R.drawable.border_blue_bg);
|
||||
tag.setTextColor(color);
|
||||
}
|
||||
tag.setLayoutParams(lparams);
|
||||
tag.setPadding(DisplayUtils.dip2px(context, 3),
|
||||
|
||||
@ -85,7 +85,7 @@ public class HttpsUtils {
|
||||
private static KeyStore getHttpsKeyStore(Context context) {
|
||||
InputStream is = null;
|
||||
try {
|
||||
is = context.getResources().openRawResource(R.raw.download);
|
||||
is = context.getResources().openRawResource(R.raw.cacert);
|
||||
//读取证书
|
||||
CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509");
|
||||
certificateFactory.generateCertificate(is);
|
||||
@ -111,23 +111,15 @@ public class HttpsUtils {
|
||||
|
||||
public static HttpsURLConnection getHttpsURLConnection(URL url) throws Exception {
|
||||
HttpsURLConnection httpsURLConnection = (HttpsURLConnection) url.openConnection();
|
||||
if ("apk2.ghzhushou.com".equals(url.getHost())
|
||||
|| "download.ghzhushou.com".equals(url.getHost())) {
|
||||
if (mSSLSocketFactory == null || mHostnameVerifier == null) {
|
||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||
sslContext.init(null, TRUST_MANAGERS, null);
|
||||
mSSLSocketFactory = sslContext.getSocketFactory();
|
||||
|
||||
mHostnameVerifier = HOSTNAME_VERIFIER;
|
||||
}
|
||||
httpsURLConnection.setSSLSocketFactory(mSSLSocketFactory);
|
||||
httpsURLConnection.setHostnameVerifier(mHostnameVerifier);
|
||||
} else {
|
||||
if (mSSLSocketFactory == null || mHostnameVerifier == null) {
|
||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||
sslContext.init(null, TRUST_MANAGERS, null);
|
||||
httpsURLConnection.setSSLSocketFactory(sslContext.getSocketFactory());
|
||||
httpsURLConnection.setHostnameVerifier(HOSTNAME_VERIFIER);
|
||||
mSSLSocketFactory = sslContext.getSocketFactory();
|
||||
|
||||
mHostnameVerifier = HOSTNAME_VERIFIER;
|
||||
}
|
||||
httpsURLConnection.setSSLSocketFactory(mSSLSocketFactory);
|
||||
httpsURLConnection.setHostnameVerifier(mHostnameVerifier);
|
||||
return httpsURLConnection;
|
||||
}
|
||||
|
||||
|
||||
@ -36,6 +36,13 @@ public class ImageUtils {
|
||||
return singleton;
|
||||
}
|
||||
|
||||
public static void display(SimpleDraweeView simpleDraweeView, String url) {
|
||||
// if (url.startsWith("http://image.ghzhushou.com") && url.endsWith(".jpg")) {
|
||||
// url = url + "?x-oss-process=image/format,webp";
|
||||
// }
|
||||
simpleDraweeView.setImageURI(url);
|
||||
}
|
||||
|
||||
// 自适应图片宽高
|
||||
public void display(final SimpleDraweeView simpleDraweeView, String url, final int width) {
|
||||
ControllerListener<ImageInfo> listener = new BaseControllerListener<ImageInfo>(){
|
||||
@ -66,7 +73,8 @@ public class ImageUtils {
|
||||
.setBackground(new ColorDrawable(resources.getColor(R.color.placeholder_bg)))
|
||||
.setActualImageScaleType(scaleType)
|
||||
.build());
|
||||
simpleDraweeView.setImageURI(url);
|
||||
// simpleDraweeView.setImageURI(url);
|
||||
display(simpleDraweeView, url);
|
||||
}
|
||||
|
||||
// 设置占位符
|
||||
@ -77,7 +85,8 @@ public class ImageUtils {
|
||||
.setBackground(new ColorDrawable(resources.getColor(R.color.placeholder_bg)))
|
||||
.setPlaceholderImage(placeholderImage)
|
||||
.build());
|
||||
simpleDraweeView.setImageURI(url);
|
||||
// simpleDraweeView.setImageURI(url);
|
||||
display(simpleDraweeView, url);
|
||||
}
|
||||
|
||||
// 图片下载监听和设置低高分辨率图片
|
||||
|
||||
148
app/src/main/java/com/gh/common/util/InstallUtils.java
Normal file
148
app/src/main/java/com/gh/common/util/InstallUtils.java
Normal file
@ -0,0 +1,148 @@
|
||||
package com.gh.common.util;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
|
||||
import com.gh.gamecenter.eventbus.EBPackage;
|
||||
import com.gh.gamecenter.manager.CommentManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import de.greenrobot.event.EventBus;
|
||||
|
||||
/**
|
||||
*
|
||||
* 下载完成跳安装,
|
||||
*/
|
||||
public class InstallUtils {
|
||||
|
||||
private static final int MAX_TIME = 5 * 60 * 1000;
|
||||
|
||||
private static Map<String, Long> installMap;
|
||||
private static Map<String, Long> uninstallMap;
|
||||
|
||||
private static InstallUtils mInstance;
|
||||
|
||||
public static InstallUtils getInstance(Context context) {
|
||||
if (mInstance == null) {
|
||||
synchronized (CommentManager.class) {
|
||||
if (mInstance == null) {
|
||||
mInstance = new InstallUtils(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
return mInstance;
|
||||
}
|
||||
|
||||
private PackageManager packageManager;
|
||||
|
||||
private Handler handler;
|
||||
|
||||
private boolean isRunning;
|
||||
|
||||
private InstallUtils(Context context) {
|
||||
isRunning = false;
|
||||
|
||||
packageManager = context.getPackageManager();
|
||||
|
||||
handler = new Handler(context.getMainLooper()) {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
if (msg.what == 0x123 && packageManager != null) {
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
List<PackageInfo> packageInfos = packageManager.getInstalledPackages(0);
|
||||
for (PackageInfo packageInfo : packageInfos) {
|
||||
if ((packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
|
||||
list.add(packageInfo.packageName);
|
||||
}
|
||||
}
|
||||
if (installMap != null && installMap.size() != 0) {
|
||||
ArrayList<String> keys = new ArrayList<>();
|
||||
for (String packageName : installMap.keySet()) {
|
||||
long time = installMap.get(packageName);
|
||||
if (System.currentTimeMillis() - time >= MAX_TIME) {
|
||||
keys.add(packageName);
|
||||
} else if (list.contains(packageName)) {
|
||||
keys.add(packageName);
|
||||
EventBus.getDefault().post(new EBPackage("安装", packageName));
|
||||
}
|
||||
}
|
||||
for (String key : keys) {
|
||||
installMap.remove(key);
|
||||
}
|
||||
}
|
||||
if (uninstallMap != null && uninstallMap.size() != 0) {
|
||||
ArrayList<String> keys = new ArrayList<>();
|
||||
for (String packageName : uninstallMap.keySet()) {
|
||||
long time = uninstallMap.get(packageName);
|
||||
if (System.currentTimeMillis() - time >= MAX_TIME) {
|
||||
keys.add(packageName);
|
||||
} else if (list.contains(packageName)) {
|
||||
keys.add(packageName);
|
||||
EventBus.getDefault().post(new EBPackage("卸载", packageName));
|
||||
}
|
||||
}
|
||||
for (String key : keys) {
|
||||
uninstallMap.remove(key);
|
||||
}
|
||||
}
|
||||
if ((installMap != null && installMap.size() != 0)
|
||||
|| (uninstallMap != null && uninstallMap.size() != 0)) {
|
||||
sendEmptyMessageDelayed(0x123, 3000);
|
||||
} else {
|
||||
isRunning = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public void addInstall(String packageName) {
|
||||
if (installMap == null) {
|
||||
installMap = Collections.synchronizedMap(new HashMap<String, Long>());
|
||||
}
|
||||
installMap.put(packageName, System.currentTimeMillis());
|
||||
run();
|
||||
}
|
||||
|
||||
public void removeInstall(String packageName) {
|
||||
if (installMap != null) {
|
||||
installMap.remove(packageName);
|
||||
}
|
||||
}
|
||||
|
||||
public void addUninstall(String packageName) {
|
||||
if (uninstallMap == null) {
|
||||
uninstallMap = Collections.synchronizedMap(new HashMap<String, Long>());
|
||||
}
|
||||
uninstallMap.put(packageName, System.currentTimeMillis());
|
||||
run();
|
||||
}
|
||||
|
||||
public void removeUninstall(String packageName) {
|
||||
if (uninstallMap != null) {
|
||||
uninstallMap.remove(packageName);
|
||||
}
|
||||
}
|
||||
|
||||
public void run() {
|
||||
if ((installMap == null || installMap.isEmpty()) && (uninstallMap == null || uninstallMap.isEmpty())) {
|
||||
return;
|
||||
}
|
||||
if (isRunning) {
|
||||
return;
|
||||
}
|
||||
isRunning = true;
|
||||
handler.sendEmptyMessageDelayed(0x123, 10000);
|
||||
}
|
||||
|
||||
}
|
||||
@ -374,7 +374,7 @@ public class LibaoUtils {
|
||||
try {
|
||||
JSONObject errorJson = new JSONObject(exception.response().errorBody().string());
|
||||
String detail = errorJson.getString("detail");
|
||||
|
||||
Utils.toast(libaoBtn.getContext(), "返回::" + detail);
|
||||
if ("coming".equals(detail)) {
|
||||
Utils.toast(libaoBtn.getContext(), "礼包领取时间未开始");
|
||||
} else if ("finish".equals(detail)) {
|
||||
@ -396,7 +396,7 @@ public class LibaoUtils {
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
Utils.toast(libaoBtn.getContext(),"礼包处理异常");
|
||||
Utils.toast(libaoBtn.getContext(),"礼包处理异常"+ ex.toString());
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -474,8 +474,8 @@ public class LibaoUtils {
|
||||
HttpException exception = (HttpException) error;
|
||||
if (exception.code() == 403) {
|
||||
try {
|
||||
Utils.log("----403" + exception.response().errorBody().string());
|
||||
JSONObject errorJson = new JSONObject(exception.response().errorBody().string());
|
||||
String string = exception.response().errorBody().string();
|
||||
JSONObject errorJson = new JSONObject(string);
|
||||
String detail = errorJson.getString("detail");
|
||||
|
||||
if ("coming".equals(detail)) {
|
||||
|
||||
@ -72,6 +72,15 @@ public class MessageShareUtils {
|
||||
|
||||
private Activity activity; // 用来关闭分享页面
|
||||
|
||||
// 适配快传成绩单分享
|
||||
private int contentSize;
|
||||
private int paddTop;
|
||||
private int picSize;
|
||||
private int itemSize;
|
||||
private int gridCount;
|
||||
private int marImg;
|
||||
private int shareType;
|
||||
|
||||
public static MessageShareUtils getInstance(Context context) {
|
||||
if (instance == null) {
|
||||
instance = new MessageShareUtils();
|
||||
@ -82,22 +91,40 @@ public class MessageShareUtils {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public void showShareWindows(View view, Bitmap bitmap, String picName, boolean ispopupWindow){
|
||||
public void showShareWindows(View view, Bitmap bitmap, String picName, int shareType){
|
||||
this.shareBm = bitmap;
|
||||
this.picName = picName;
|
||||
this.shareType = shareType;
|
||||
this.activity= (Activity) context;
|
||||
|
||||
if (shareType == 2) {
|
||||
contentSize = 75;
|
||||
paddTop = 0;
|
||||
gridCount = 4;
|
||||
picSize = 30;
|
||||
itemSize = 75;
|
||||
marImg = 10;
|
||||
} else {
|
||||
contentSize = 100;
|
||||
paddTop = 10;
|
||||
gridCount = 5;
|
||||
picSize = 43;
|
||||
itemSize = 90;
|
||||
marImg = 13;
|
||||
|
||||
}
|
||||
|
||||
RelativeLayout contentView = new RelativeLayout(context);
|
||||
contentView.setBackgroundColor(0x8c000000);
|
||||
contentView.setFocusable(true);
|
||||
contentView.setFocusableInTouchMode(true);
|
||||
|
||||
RecyclerView shareRecyclerView = new RecyclerView(context);
|
||||
shareRecyclerView.setPadding(DisplayUtils.dip2px(context, 10), DisplayUtils.dip2px(context, 10), DisplayUtils.dip2px(context, 10), 0);
|
||||
shareRecyclerView.setPadding(DisplayUtils.dip2px(context, 10), DisplayUtils.dip2px(context, paddTop), DisplayUtils.dip2px(context, 10), 0);
|
||||
shareRecyclerView.setBackgroundColor(Color.WHITE);
|
||||
|
||||
//RecyclerView禁止滑动
|
||||
GridLayoutManager gridLayoutManager = new GridLayoutManager(context, 5){
|
||||
GridLayoutManager gridLayoutManager = new GridLayoutManager(context, gridCount){
|
||||
@Override
|
||||
public boolean canScrollVertically() {
|
||||
return false;
|
||||
@ -107,10 +134,10 @@ public class MessageShareUtils {
|
||||
shareRecyclerView.setLayoutManager(gridLayoutManager);
|
||||
shareRecyclerView.setAdapter(new ShareRecyclerViewAdapter());
|
||||
|
||||
if (!ispopupWindow) {
|
||||
if (shareType == 0 || shareType == 2) {
|
||||
LinearLayout llBottom = (LinearLayout) view;
|
||||
ViewGroup.LayoutParams layoutParams = llBottom.getLayoutParams();
|
||||
layoutParams.height = DisplayUtils.dip2px(context, 100);
|
||||
layoutParams.height = DisplayUtils.dip2px(context, contentSize);
|
||||
llBottom.addView(shareRecyclerView);
|
||||
return;
|
||||
}
|
||||
@ -151,13 +178,13 @@ public class MessageShareUtils {
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
LinearLayout linearLayout = new LinearLayout(context);
|
||||
linearLayout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, DisplayUtils.dip2px(context, 90)));
|
||||
linearLayout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, DisplayUtils.dip2px(context, itemSize)));
|
||||
linearLayout.setOrientation(LinearLayout.VERTICAL);
|
||||
linearLayout.setGravity(Gravity.CENTER_HORIZONTAL);
|
||||
linearLayout.setBackgroundResource(R.drawable.cardview_item_style);
|
||||
|
||||
ImageView shareLogo = new ImageView(context);
|
||||
LinearLayout.LayoutParams logoParams = new LinearLayout.LayoutParams(DisplayUtils.dip2px(context, 43), DisplayUtils.dip2px(context, 43));
|
||||
LinearLayout.LayoutParams logoParams = new LinearLayout.LayoutParams(DisplayUtils.dip2px(context, picSize), DisplayUtils.dip2px(context, picSize));
|
||||
logoParams.setMargins(0, DisplayUtils.dip2px(context, 10), 0, 0);
|
||||
shareLogo.setLayoutParams(logoParams);
|
||||
|
||||
@ -167,7 +194,7 @@ public class MessageShareUtils {
|
||||
shareLabel.setLayoutParams(layoutParams);
|
||||
shareLabel.setGravity(Gravity.CENTER);
|
||||
shareLabel.setTextColor(Color.parseColor("#3a3a3a"));
|
||||
shareLabel.setTextSize(13);
|
||||
shareLabel.setTextSize(marImg);
|
||||
|
||||
linearLayout.addView(shareLogo);
|
||||
linearLayout.addView(shareLabel);
|
||||
@ -185,11 +212,15 @@ public class MessageShareUtils {
|
||||
switch (holder.getPosition()){
|
||||
case 0:
|
||||
wechatSahre();
|
||||
activity.finish();
|
||||
if (shareType != 2) {
|
||||
activity.finish();
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
wechatMomentsSahre();
|
||||
activity.finish();
|
||||
if (shareType != 2) {
|
||||
activity.finish();
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
qqSahre();
|
||||
@ -213,7 +244,7 @@ public class MessageShareUtils {
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return arrLogo.length;
|
||||
return gridCount;
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder{
|
||||
|
||||
@ -3,10 +3,12 @@ package com.gh.common.util;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.text.TextUtils;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gh.gamecenter.NewsDetailActivity;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.WebActivity;
|
||||
import com.gh.gamecenter.entity.NewsEntity;
|
||||
import com.gh.gamecenter.retrofit.Response;
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager;
|
||||
@ -42,13 +44,23 @@ public class NewsUtils {
|
||||
* 启动新闻详情页面
|
||||
*/
|
||||
public static void startNewsDetailActivity(Context context, NewsEntity newsEntity, String entrance) {
|
||||
Intent intent = new Intent(context, NewsDetailActivity.class);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
intent.putExtra("id", newsEntity.getId());
|
||||
intent.putExtra("title", newsEntity.getTitle());
|
||||
intent.putExtra("type", newsEntity.getType());
|
||||
intent.putExtra("entrance", entrance);
|
||||
context.startActivity(intent);
|
||||
if (!TextUtils.isEmpty(newsEntity.getLink())) {
|
||||
Intent intent = new Intent(context, WebActivity.class);
|
||||
intent.putExtra("url", newsEntity.getLink());
|
||||
intent.putExtra("gameName", newsEntity.getGameName());
|
||||
intent.putExtra("newsId", newsEntity.getId());
|
||||
intent.putExtra("entrance", entrance + "+(消息详情[" + newsEntity.getGameName() + "])");
|
||||
context.startActivity(intent);
|
||||
} else {
|
||||
Intent intent = new Intent(context, NewsDetailActivity.class);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
intent.putExtra("id", newsEntity.getId());
|
||||
intent.putExtra("title", newsEntity.getTitle());
|
||||
intent.putExtra("type", newsEntity.getType());
|
||||
intent.putExtra("entrance", entrance);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -17,6 +17,27 @@ import com.gh.gamecenter.R;
|
||||
*/
|
||||
public class NotificationUtils {
|
||||
|
||||
// 快传传输完成消息
|
||||
public static void showKuaiChuanDoneNotification(Context context, String apkPath, String apkName, String packName) {
|
||||
NotificationManager nManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra("path", apkPath);
|
||||
intent.setAction("com.gh.gamecenter.INSTALL");
|
||||
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0x321,
|
||||
intent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
String title = "接收完成,点击立即安装";
|
||||
String text = apkName;
|
||||
|
||||
Notification notification = new NotificationCompat.Builder(context)
|
||||
.setSmallIcon(R.drawable.logo)
|
||||
.setTicker(title)
|
||||
.setContentTitle(text)
|
||||
.setContentText(title)
|
||||
.setContentIntent(pendingIntent).build();
|
||||
notification.flags |= Notification.FLAG_AUTO_CANCEL; // // FLAG_AUTO_CANCEL表明当通知被用户点击时,通知将被清除。
|
||||
nManager.notify(packName,0x321, notification);
|
||||
}
|
||||
|
||||
public static void showDownloadDoneNotification(Context context, DownloadEntity downloadEntity, int flag) {
|
||||
NotificationManager nManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
Intent intent = new Intent();
|
||||
|
||||
@ -13,7 +13,6 @@ import android.text.TextUtils;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.gh.gamecenter.entity.GameUpdateEntity;
|
||||
import com.gh.gamecenter.manager.FilterManager;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
@ -124,7 +123,7 @@ public class PackageUtils {
|
||||
*/
|
||||
public static void launchSetup(final Context context, final String path) {
|
||||
if (isCanLaunchSetup(context, path)) {
|
||||
context.startActivity(PackageUtils.getInstallIntent(path));
|
||||
context.startActivity(PackageUtils.getInstallIntent(context, path));
|
||||
} else {
|
||||
DialogUtils.showPluginDialog(context, new DialogUtils.ConfiremListener() {
|
||||
@Override
|
||||
@ -212,15 +211,12 @@ public class PackageUtils {
|
||||
* 获取所有已安装的软件的包名、版本(非系统应用)
|
||||
*/
|
||||
public static ArrayList<String> getAllPackageName(Context context) {
|
||||
FilterManager filterManager = new FilterManager(context);
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
List<PackageInfo> packageInfos = context.getPackageManager().getInstalledPackages(0);
|
||||
for (PackageInfo packageInfo : packageInfos) {
|
||||
if ((packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
|
||||
if (!context.getPackageName().equals(packageInfo.packageName)) {
|
||||
if (!filterManager.isFilter(packageInfo.packageName)) {
|
||||
list.add(packageInfo.packageName);
|
||||
}
|
||||
list.add(packageInfo.packageName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -272,19 +268,21 @@ public class PackageUtils {
|
||||
Intent uninstallIntent = new Intent();
|
||||
uninstallIntent.setAction("android.intent.action.DELETE");
|
||||
uninstallIntent.addCategory("android.intent.category.DEFAULT");
|
||||
uninstallIntent.setData(Uri.parse("package:"
|
||||
+ getPackageNameByPath(context, path)));
|
||||
String packageName = getPackageNameByPath(context, path);
|
||||
uninstallIntent.setData(Uri.parse("package:" + packageName));
|
||||
InstallUtils.getInstance(context).addUninstall(packageName);
|
||||
return uninstallIntent;
|
||||
}
|
||||
|
||||
/*
|
||||
* 根据路径,获取安装游戏的意图
|
||||
*/
|
||||
public static Intent getInstallIntent(String path) {
|
||||
public static Intent getInstallIntent(Context context, String path) {
|
||||
Uri uri = Uri.fromFile(new File(path));
|
||||
Intent installIntent = new Intent(Intent.ACTION_VIEW);
|
||||
installIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
installIntent.setDataAndType(uri, "application/vnd.android.package-archive");
|
||||
InstallUtils.getInstance(context).addInstall(getPackageNameByPath(context, path));
|
||||
return installIntent;
|
||||
}
|
||||
|
||||
|
||||
@ -16,9 +16,12 @@ import com.gh.gamecenter.retrofit.RetrofitManager;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
@ -251,7 +254,7 @@ public class PlatformUtils {
|
||||
return platformName;
|
||||
}
|
||||
|
||||
boolean isUpdate = false;
|
||||
private boolean isUpdate = false;
|
||||
|
||||
public void getPlatform() {
|
||||
if (isUpdate) {
|
||||
@ -273,6 +276,9 @@ public class PlatformUtils {
|
||||
initMap();
|
||||
EventBus.getDefault().post(new EBReuse("PlatformChanged"));
|
||||
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault());
|
||||
String today = format.format(new Date());
|
||||
sp.edit().putString("refresh_time", today).apply();
|
||||
isUpdate = false;
|
||||
}
|
||||
|
||||
|
||||
@ -12,7 +12,6 @@ import android.graphics.Color;
|
||||
import android.graphics.Matrix;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.support.v7.widget.GridLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.Gravity;
|
||||
@ -63,7 +62,7 @@ public class ShareUtils {
|
||||
private static IWXAPI api;
|
||||
private static Tencent mTencent;
|
||||
|
||||
private Handler handler;
|
||||
private Boolean ispopupWindow;
|
||||
|
||||
private int[] arrLogo = {R.drawable.share_wechat_logo, R.drawable.share_wechatmoments_logo, R.drawable.share_qq_logo
|
||||
, R.drawable.share_qzone_logo, R.drawable.share_sinaweibo_logo, R.drawable.share_shortmessage_logo
|
||||
@ -74,7 +73,8 @@ public class ShareUtils {
|
||||
|
||||
private Context context;
|
||||
|
||||
public static ShareUtils getInstance(Context context) {
|
||||
|
||||
public static ShareUtils getInstance(Activity context) {
|
||||
if (instance == null) {
|
||||
instance = new ShareUtils();
|
||||
mTencent = Tencent.createInstance("1104659243", context); //初始化QQ分享
|
||||
@ -84,21 +84,31 @@ public class ShareUtils {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public void showShareWindows(View view, String url, String gameName, String icon ,String newsTitle, boolean isPlugin){
|
||||
/**
|
||||
*
|
||||
* @param view ispopupWindow-true是绑定的布局, ispopupWindow-false 则是嵌套的父控件
|
||||
* @param url 分享链接
|
||||
* @param gameName 游戏名 与 新闻标题区分
|
||||
* @param icon 分享图标
|
||||
* @param newsTitle 新闻标题 与 游戏名区分
|
||||
* @param isPlugin 判断游戏是否是插件
|
||||
* @param ispopupWindow 判断是否是 PopupWindow false可直接嵌套进布局(分享光环),view是父控件
|
||||
*/
|
||||
public void showShareWindows(View view, String url, String gameName, String icon ,String newsTitle,
|
||||
boolean isPlugin, boolean ispopupWindow){
|
||||
this.shareIcon = icon;
|
||||
this.shareGameName = gameName;
|
||||
this.shareUrl = url;
|
||||
this.shareNewsTitle = newsTitle;
|
||||
this.isPlugin = isPlugin;
|
||||
this.ispopupWindow = ispopupWindow;
|
||||
|
||||
RelativeLayout contentView = new RelativeLayout(context);
|
||||
contentView.setBackgroundColor(0x8c000000);
|
||||
contentView.setFocusable(true);
|
||||
contentView.setFocusableInTouchMode(true);
|
||||
|
||||
RecyclerView shareRecyclerView = new RecyclerView(context);
|
||||
shareRecyclerView.setPadding(DisplayUtils.dip2px(context, 20), DisplayUtils.dip2px(context, 10), DisplayUtils.dip2px(context, 20), 0);
|
||||
shareRecyclerView.setBackgroundColor(Color.WHITE);
|
||||
|
||||
//RecyclerView禁止滑动
|
||||
GridLayoutManager gridLayoutManager = new GridLayoutManager(context, 4){
|
||||
@ -116,6 +126,23 @@ public class ShareUtils {
|
||||
rlParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
|
||||
contentView.addView(shareRecyclerView,rlParams);
|
||||
|
||||
if (!ispopupWindow) {
|
||||
RelativeLayout layout = (RelativeLayout) view;
|
||||
layout.addView(contentView);
|
||||
arrLabel[6] = "邮件";
|
||||
arrLogo[6] = R.drawable.share_email_logo;
|
||||
arrLabel[7] = "复制链接";
|
||||
arrLogo[7] = R.drawable.share_copyfont_logo;
|
||||
return;
|
||||
} else {
|
||||
arrLabel[6] = "复制链接";
|
||||
arrLogo[6] = R.drawable.share_copyfont_logo;
|
||||
arrLabel[7] = "取消";
|
||||
arrLogo[7] = R.drawable.share_cancel_logo;
|
||||
}
|
||||
contentView.setBackgroundColor(0x8c000000);
|
||||
shareRecyclerView.setBackgroundColor(Color.WHITE);
|
||||
|
||||
popupWindow = new PopupWindow(contentView, LinearLayout.LayoutParams.MATCH_PARENT
|
||||
, LinearLayout.LayoutParams.MATCH_PARENT, true);
|
||||
popupWindow.setAnimationStyle(R.style.mypopwindow_anim_style);
|
||||
@ -198,10 +225,28 @@ public class ShareUtils {
|
||||
shortMessageSahre();
|
||||
break;
|
||||
case 6:
|
||||
copyLink(shareUrl);
|
||||
if (ispopupWindow) {
|
||||
copyLink(shareUrl);
|
||||
} else {
|
||||
Intent data=new Intent(Intent.ACTION_SENDTO);
|
||||
data.setData(Uri.parse("mailto:"));
|
||||
data.putExtra(Intent.EXTRA_SUBJECT, "快来试试光环助手");
|
||||
data.putExtra(Intent.EXTRA_TEXT, "我用光环助手一段时间了,在里面可以下载各种热门卡牌手游的加速版,绿色安全,超级省心,做日常效率提高3-5倍!\n" +
|
||||
"\n" +
|
||||
"不用肝的感觉真好,快来试试。\n" +
|
||||
"\n" +
|
||||
"光环助手官网地址:\n" +
|
||||
"\n" +
|
||||
"http://www.ghzhushou.com/link?source=appshare333");
|
||||
context.startActivity(data);
|
||||
}
|
||||
break;
|
||||
case 7:
|
||||
popupWindow.dismiss();
|
||||
if (ispopupWindow) {
|
||||
popupWindow.dismiss();
|
||||
} else {
|
||||
copyLink("推荐光环助手,绿色安全的手游加速助手:" + shareUrl);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -228,22 +273,31 @@ public class ShareUtils {
|
||||
}
|
||||
|
||||
//QQ分享
|
||||
private void qqSahre(){
|
||||
private void qqSahre() {
|
||||
Utils.toast(context,"分享跳转中...");
|
||||
Bundle params = new Bundle();
|
||||
|
||||
if (shareNewsTitle != null){
|
||||
params.putString(QQShare.SHARE_TO_QQ_TITLE, shareNewsTitle);
|
||||
params.putString(QQShare.SHARE_TO_QQ_SUMMARY, "来自光环助手(最强卡牌神器)");
|
||||
}else {
|
||||
params.putString(QQShare.SHARE_TO_QQ_TITLE, "向你推荐:");
|
||||
if (isPlugin){
|
||||
params.putString(QQShare.SHARE_TO_QQ_SUMMARY, shareGameName + "(光环加速版)");
|
||||
}else {
|
||||
params.putString(QQShare.SHARE_TO_QQ_SUMMARY, shareGameName);
|
||||
}
|
||||
}
|
||||
String title;
|
||||
String summary;
|
||||
|
||||
if (ispopupWindow) {
|
||||
if (shareNewsTitle != null) {
|
||||
title = shareNewsTitle;
|
||||
summary = "来自光环助手(最强卡牌神器)";
|
||||
} else {
|
||||
title = "向你推荐:";
|
||||
if (isPlugin) {
|
||||
summary = shareGameName + "(光环加速版)";
|
||||
} else {
|
||||
summary = shareGameName;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
title = "玩手游不用肝的感觉真好";
|
||||
summary = "绿色安全的手游加速助手";
|
||||
}
|
||||
params.putString(QQShare.SHARE_TO_QQ_TITLE, title);
|
||||
params.putString(QQShare.SHARE_TO_QQ_SUMMARY, summary);
|
||||
params.putInt(QQShare.SHARE_TO_QQ_KEY_TYPE, QQShare.SHARE_TO_QQ_TYPE_DEFAULT);
|
||||
params.putString(QQShare.SHARE_TO_QQ_TARGET_URL, shareUrl);
|
||||
params.putString(QQShare.SHARE_TO_QQ_IMAGE_URL, shareIcon);
|
||||
@ -251,57 +305,84 @@ public class ShareUtils {
|
||||
|
||||
mTencent.shareToQQ(
|
||||
(Activity) context, params,QqShareListener);
|
||||
popupWindow.dismiss();
|
||||
|
||||
if (ispopupWindow) {
|
||||
popupWindow.dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
//微信好友分享
|
||||
private void wechatSahre(){
|
||||
private void wechatSahre() {
|
||||
Utils.toast(context,"分享跳转中...");
|
||||
WXWebpageObject webpage = new WXWebpageObject();
|
||||
WXMediaMessage msg = new WXMediaMessage(webpage);
|
||||
webpage.webpageUrl = shareUrl;
|
||||
|
||||
if (shareNewsTitle != null){
|
||||
msg.title = shareNewsTitle;
|
||||
msg.description = "来自光环助手(最强卡牌神器)";
|
||||
}else {
|
||||
if (isPlugin){
|
||||
msg.title = "向你推荐";
|
||||
msg.description = shareGameName + "(光环加速版)";
|
||||
}else {
|
||||
msg.title = "向你推荐";
|
||||
msg.description = shareGameName;
|
||||
String title;
|
||||
String summary;
|
||||
|
||||
if (ispopupWindow) {
|
||||
if (shareNewsTitle != null) {
|
||||
title = shareNewsTitle;
|
||||
summary = "来自光环助手(最强卡牌神器)";
|
||||
} else {
|
||||
title = "向你推荐";
|
||||
if (isPlugin){
|
||||
summary = shareGameName + "(光环加速版)";
|
||||
} else {
|
||||
summary = shareGameName;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
title = "玩手游不用肝的感觉真好";
|
||||
summary = "绿色安全的手游加速助手";
|
||||
}
|
||||
|
||||
msg.title = title;
|
||||
msg.description = summary;
|
||||
|
||||
SendMessageToWX.Req req = new SendMessageToWX.Req();
|
||||
req.transaction = buildTransaction("webpage");
|
||||
req.message = msg;
|
||||
req.scene = SendMessageToWX.Req.WXSceneSession;
|
||||
|
||||
loadBitMap(shareIcon, msg, req);
|
||||
popupWindow.dismiss();
|
||||
if (ispopupWindow) {
|
||||
popupWindow.dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
//QQ空间分享
|
||||
private void qZoneSahre(){
|
||||
private void qZoneSahre() {
|
||||
Utils.toast(context,"分享跳转中...");
|
||||
Bundle params = new Bundle();
|
||||
|
||||
if (shareNewsTitle != null){
|
||||
params.putString(QzoneShare.SHARE_TO_QQ_TITLE, shareNewsTitle);
|
||||
}else {
|
||||
params.putString(QzoneShare.SHARE_TO_QQ_TITLE, "向你推荐:");
|
||||
if (isPlugin){
|
||||
params.putString(QzoneShare.SHARE_TO_QQ_SUMMARY, shareGameName + "(光环加速版)");
|
||||
}else {
|
||||
params.putString(QzoneShare.SHARE_TO_QQ_SUMMARY, shareGameName);
|
||||
String title;
|
||||
String summary = null;
|
||||
|
||||
if (ispopupWindow) {
|
||||
if (shareNewsTitle != null) {
|
||||
title = shareNewsTitle;
|
||||
} else {
|
||||
title = "向你推荐:";
|
||||
if (isPlugin) {
|
||||
summary = shareGameName + "(光环加速版)";
|
||||
} else {
|
||||
summary = shareGameName;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
title = "玩手游不用肝的感觉真好";
|
||||
summary = "绿色安全的手游加速助手";
|
||||
}
|
||||
|
||||
ArrayList<String> imageUrls = new ArrayList<String>();
|
||||
imageUrls.add(shareIcon);
|
||||
|
||||
if (summary != null) {
|
||||
params.putString(QzoneShare.SHARE_TO_QQ_SUMMARY, summary);
|
||||
}
|
||||
params.putString(QzoneShare.SHARE_TO_QQ_TITLE, title);
|
||||
params.putInt(QzoneShare.SHARE_TO_QZONE_KEY_TYPE, QzoneShare.SHARE_TO_QZONE_TYPE_NO_TYPE);
|
||||
params.putString(QzoneShare.SHARE_TO_QQ_TARGET_URL, shareUrl);
|
||||
params.putStringArrayList(QzoneShare.SHARE_TO_QQ_IMAGE_URL, imageUrls);
|
||||
@ -309,26 +390,36 @@ public class ShareUtils {
|
||||
|
||||
mTencent.shareToQzone(
|
||||
(Activity) context, params,QqShareListener);
|
||||
popupWindow.dismiss();
|
||||
if (ispopupWindow) {
|
||||
popupWindow.dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
//微信朋友圈分享
|
||||
private void wechatMomentsSahre(){
|
||||
private void wechatMomentsSahre() {
|
||||
Utils.toast(context,"分享跳转中...");
|
||||
WXWebpageObject webpage = new WXWebpageObject();
|
||||
WXMediaMessage msg = new WXMediaMessage(webpage);
|
||||
|
||||
webpage.webpageUrl = shareUrl;
|
||||
if (shareNewsTitle != null){
|
||||
msg.title = shareNewsTitle;
|
||||
}else {
|
||||
if (isPlugin){
|
||||
msg.title = "向你推荐:" + shareGameName + "(光环加速版)";
|
||||
}else {
|
||||
msg.title = "向你推荐:" + shareGameName;
|
||||
|
||||
String title;
|
||||
|
||||
if (ispopupWindow) {
|
||||
if (shareNewsTitle != null) {
|
||||
title = shareNewsTitle;
|
||||
} else {
|
||||
if (isPlugin){
|
||||
title = shareGameName + "(光环加速版)";
|
||||
} else {
|
||||
title = shareGameName;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
title = "玩手游不用肝的感觉真好";
|
||||
}
|
||||
|
||||
msg.title = title;
|
||||
SendMessageToWX.Req req = new SendMessageToWX.Req();
|
||||
|
||||
req.transaction = buildTransaction("webpage");
|
||||
@ -336,12 +427,14 @@ public class ShareUtils {
|
||||
req.scene = SendMessageToWX.Req.WXSceneTimeline;
|
||||
|
||||
loadBitMap(shareIcon, msg, req);
|
||||
popupWindow.dismiss();
|
||||
if (ispopupWindow) {
|
||||
popupWindow.dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//新浪微博分享
|
||||
private void sinaWeiboSahre(){
|
||||
private void sinaWeiboSahre() {
|
||||
Intent intent = new Intent(context, WeiBoShareActivity.class);
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("shareNewsTitle", shareNewsTitle);
|
||||
@ -349,23 +442,31 @@ public class ShareUtils {
|
||||
bundle.putString("shareGameName", shareGameName);
|
||||
bundle.putString("shareUrl", shareUrl);
|
||||
bundle.putBoolean("isPlugin",isPlugin);
|
||||
bundle.putBoolean("ispopupWindow", ispopupWindow);
|
||||
intent.putExtras(bundle);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(intent);
|
||||
|
||||
popupWindow.dismiss();
|
||||
if (ispopupWindow) {
|
||||
popupWindow.dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
//短信分享
|
||||
private void shortMessageSahre(){
|
||||
private void shortMessageSahre() {
|
||||
String smsBody;
|
||||
if (shareNewsTitle != null){
|
||||
smsBody = shareNewsTitle + shareUrl;
|
||||
}else {
|
||||
if (isPlugin){
|
||||
smsBody = "向你推荐:" + shareGameName + "(光环加速版)" + shareUrl;
|
||||
if (ispopupWindow) {
|
||||
if (shareNewsTitle != null){
|
||||
smsBody = shareNewsTitle + shareUrl;
|
||||
}else {
|
||||
smsBody = "向你推荐:" + shareGameName + shareUrl;
|
||||
if (isPlugin){
|
||||
smsBody = "向你推荐:" + shareGameName + "(光环加速版)" + shareUrl;
|
||||
}else {
|
||||
smsBody = "向你推荐:" + shareGameName + shareUrl;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
smsBody = "这个App可以下载各种热门卡牌手游的加速版,绿色安全,超级省心,做日常效率提高3-5倍!光环助手官网地址:" + shareUrl;
|
||||
}
|
||||
|
||||
Intent sendIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("smsto:"));
|
||||
@ -373,13 +474,16 @@ public class ShareUtils {
|
||||
sendIntent.setType("vnd.android-dir/mms-sms");
|
||||
|
||||
try {
|
||||
sendIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(sendIntent);
|
||||
} catch (Exception e) {
|
||||
Utils.toast(context, "系统异常,分享失败");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
popupWindow.dismiss();
|
||||
if (ispopupWindow) {
|
||||
popupWindow.dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
private String buildTransaction(final String type) {
|
||||
@ -390,9 +494,12 @@ public class ShareUtils {
|
||||
private void copyLink(String copyContent) {
|
||||
ClipboardManager cmb = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
cmb.setText(copyContent);
|
||||
popupWindow.dismiss();
|
||||
|
||||
Utils.toast(context,"复制成功");
|
||||
if (ispopupWindow != null && ispopupWindow) {
|
||||
Utils.toast(context,"复制成功");
|
||||
popupWindow.dismiss();
|
||||
} else {
|
||||
Utils.toast(context,"复制成功,请到微信/QQ粘贴分享");
|
||||
}
|
||||
}
|
||||
|
||||
private void loadBitMap(final String iconUrl, final WXMediaMessage msg, final SendMessageToWX.Req req){
|
||||
|
||||
94
app/src/main/java/com/gh/common/util/TagUtils.java
Normal file
94
app/src/main/java/com/gh/common/util/TagUtils.java
Normal file
@ -0,0 +1,94 @@
|
||||
package com.gh.common.util;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.support.v4.util.ArrayMap;
|
||||
|
||||
import com.gh.gamecenter.entity.TagEntity;
|
||||
import com.gh.gamecenter.retrofit.Response;
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import retrofit2.adapter.rxjava.HttpException;
|
||||
import rx.android.schedulers.AndroidSchedulers;
|
||||
import rx.schedulers.Schedulers;
|
||||
|
||||
public class TagUtils {
|
||||
|
||||
private static TagUtils mInstance;
|
||||
|
||||
private Context context;
|
||||
|
||||
private ArrayMap<String, String> colorMap;
|
||||
|
||||
private TagUtils(Context con) {
|
||||
this.context = con.getApplicationContext();
|
||||
initTag();
|
||||
}
|
||||
|
||||
public static TagUtils getInstance(Context context) {
|
||||
if (mInstance == null) {
|
||||
mInstance = new TagUtils(context);
|
||||
}
|
||||
return mInstance;
|
||||
}
|
||||
|
||||
private void initTag() {
|
||||
colorMap = new ArrayMap<>();
|
||||
|
||||
SharedPreferences sharedPreferences = context.getSharedPreferences("gh_tag", Context.MODE_PRIVATE);
|
||||
Set<String> set = sharedPreferences.getStringSet("tag", null);
|
||||
if (set == null) {
|
||||
getTag();
|
||||
} else {
|
||||
for (String str : set) {
|
||||
String[] platform = str.split("=");
|
||||
colorMap.put(platform[0], platform[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getColor(String tag) {
|
||||
String color = colorMap.get(tag);
|
||||
if (color == null) {
|
||||
getTag();
|
||||
}
|
||||
return color;
|
||||
}
|
||||
|
||||
private boolean isUpdate = false;
|
||||
|
||||
public void getTag() {
|
||||
if (isUpdate) {
|
||||
return;
|
||||
}
|
||||
isUpdate = true;
|
||||
RetrofitManager.getApi().getTags()
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Response<List<TagEntity>>() {
|
||||
@Override
|
||||
public void onResponse(List<TagEntity> response) {
|
||||
Set<String> tagSet = new HashSet<>();
|
||||
for (TagEntity tagEntity : response) {
|
||||
tagSet.add(tagEntity.getName() + "=" + tagEntity.getColor());
|
||||
}
|
||||
SharedPreferences sp = context.getSharedPreferences("gh_tag", Context.MODE_PRIVATE);
|
||||
sp.edit().putStringSet("tag", tagSet).apply();
|
||||
initTag();
|
||||
|
||||
isUpdate = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(HttpException e) {
|
||||
isUpdate = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@ -134,7 +134,7 @@ public class TokenUtils {
|
||||
}).onErrorResumeNext(new Func1<Throwable, Observable<? extends String>>() {
|
||||
@Override
|
||||
public Observable<? extends String> call(Throwable throwable) {
|
||||
return Observable.empty();
|
||||
return Observable.error(throwable);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -142,7 +142,7 @@ public class TokenUtils {
|
||||
}
|
||||
|
||||
// 检查设备信息是否已经上传完整
|
||||
public static synchronized void checkDeviceInfo(final Context context) {
|
||||
public static synchronized void checkDeviceInfo(Context context, String token) {
|
||||
final SharedPreferences sp = context.getSharedPreferences(Config.PREFERENCE, Context.MODE_PRIVATE);
|
||||
final HashMap<String, String> params = new HashMap<>();
|
||||
if (!sp.getBoolean("isUploadExtra", false)) {
|
||||
@ -165,15 +165,10 @@ public class TokenUtils {
|
||||
}
|
||||
}
|
||||
if (params.size() != 0) {
|
||||
TokenUtils.getToken(context, true)
|
||||
.flatMap(new Func1<String, Observable<ResponseBody>>() {
|
||||
@Override
|
||||
public Observable<ResponseBody> call(String token) {
|
||||
RequestBody body = RequestBody.create(MediaType.parse("application/json"),
|
||||
new JSONObject(params).toString());
|
||||
return RetrofitManager.getUser().postDevice(token, body, TokenUtils.getDeviceId(context));
|
||||
}
|
||||
}).subscribeOn(Schedulers.io())
|
||||
RequestBody body = RequestBody.create(MediaType.parse("application/json"),
|
||||
new JSONObject(params).toString());
|
||||
RetrofitManager.getUser().postDevice(token, body, TokenUtils.getDeviceId(context))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Response<ResponseBody>() {
|
||||
@Override
|
||||
|
||||
60
app/src/main/java/com/gh/common/util/UserIconUtils.java
Normal file
60
app/src/main/java/com/gh/common/util/UserIconUtils.java
Normal file
@ -0,0 +1,60 @@
|
||||
package com.gh.common.util;
|
||||
|
||||
import com.gh.gamecenter.R;
|
||||
|
||||
/**
|
||||
* Created by khy on 2017/2/13.
|
||||
* 获取用户默认头像工具类
|
||||
*/
|
||||
public class UserIconUtils {
|
||||
|
||||
/**
|
||||
* @param i 默认图片位置(第几个)
|
||||
* @return fresco 能解析的url
|
||||
*/
|
||||
public static String getUserIcon(int i){
|
||||
switch (i) {
|
||||
case 1:
|
||||
return "res:///" + R.drawable.user_default_icon1;
|
||||
case 2:
|
||||
return "res:///" + R.drawable.user_default_icon2;
|
||||
case 3:
|
||||
return "res:///" + R.drawable.user_default_icon3;
|
||||
case 4:
|
||||
return "res:///" + R.drawable.user_default_icon4;
|
||||
case 5:
|
||||
return "res:///" + R.drawable.user_default_icon5;
|
||||
case 6:
|
||||
return "res:///" + R.drawable.user_default_icon6;
|
||||
case 7:
|
||||
return "res:///" + R.drawable.user_default_icon7;
|
||||
case 8:
|
||||
return "res:///" + R.drawable.user_default_icon8;
|
||||
default:
|
||||
return "res:///" + R.drawable.user_default_icon1;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getUserIconUrl(int i) {
|
||||
switch (i) {
|
||||
case 1:
|
||||
return "http://image.ghzhushou.com/pic/default_icon_1.png";
|
||||
case 2:
|
||||
return "http://image.ghzhushou.com/pic/default_icon_2.png";
|
||||
case 3:
|
||||
return "http://image.ghzhushou.com/pic/default_icon_3.png";
|
||||
case 4:
|
||||
return "http://image.ghzhushou.com/pic/default_icon_4.png";
|
||||
case 5:
|
||||
return "http://image.ghzhushou.com/pic/default_icon_5.png";
|
||||
case 6:
|
||||
return "http://image.ghzhushou.com/pic/default_icon_6.png";
|
||||
case 7:
|
||||
return "http://image.ghzhushou.com/pic/default_icon_7.png";
|
||||
case 8:
|
||||
return "http://image.ghzhushou.com/pic/default_icon_8.png";
|
||||
default:
|
||||
return "http://image.ghzhushou.com/pic/default_icon_1.png";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,40 @@
|
||||
package com.gh.common.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
/**
|
||||
* Created by khy on 2017/2/24.
|
||||
* 控制是否可以左右滑动
|
||||
*/
|
||||
public class NoScrollableViewPager extends ViewPager {
|
||||
|
||||
private boolean isScrollable;
|
||||
|
||||
public NoScrollableViewPager(Context context) {
|
||||
super(context);
|
||||
isScrollable = true;
|
||||
}
|
||||
|
||||
public NoScrollableViewPager(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
isScrollable = true;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent ev) {
|
||||
return isScrollable && super.onTouchEvent(ev);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
||||
return isScrollable && super.onInterceptTouchEvent(ev);
|
||||
}
|
||||
|
||||
public void setScrollable(boolean scrollable) {
|
||||
isScrollable = scrollable;
|
||||
}
|
||||
}
|
||||
255
app/src/main/java/com/gh/common/view/RadarLayout.java
Normal file
255
app/src/main/java/com/gh/common/view/RadarLayout.java
Normal file
@ -0,0 +1,255 @@
|
||||
package com.gh.common.view;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorSet;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.animation.LinearInterpolator;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by khy on 2017/2/16.
|
||||
* 快传接收方 的雷达动画
|
||||
*/
|
||||
public class RadarLayout extends FrameLayout {
|
||||
|
||||
public static final int INFINITE = 0;
|
||||
|
||||
private static final int DEFAULT_COUNT = 4;
|
||||
private static final int DEFAULT_COLOR = Color.rgb(0, 116, 193);
|
||||
private static final int DEFAULT_DURATION = 7000;
|
||||
private static final int DEFAULT_REPEAT = INFINITE;
|
||||
private static final int DEFAULT_STROKE_WIDTH = 2;
|
||||
|
||||
private int mCount;
|
||||
private int mDuration;
|
||||
private int mRepeat;
|
||||
|
||||
private AnimatorSet mAnimatorSet;
|
||||
|
||||
private Paint mPaint;
|
||||
private int mColor;
|
||||
private float mRadius;
|
||||
private float mCenterX;
|
||||
private float mCenterY;
|
||||
private int mStrokeWidth;
|
||||
private boolean mIsStarted;
|
||||
private boolean mUseRing;
|
||||
|
||||
public RadarLayout(Context context) {
|
||||
super(context);
|
||||
initGlobalparams();
|
||||
}
|
||||
|
||||
public RadarLayout(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
initGlobalparams();
|
||||
}
|
||||
|
||||
public RadarLayout(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
initGlobalparams();
|
||||
}
|
||||
|
||||
private void initGlobalparams() {
|
||||
mColor = DEFAULT_COLOR;
|
||||
mCount = DEFAULT_COUNT;
|
||||
mDuration = DEFAULT_DURATION;
|
||||
mRepeat = DEFAULT_REPEAT;
|
||||
mUseRing = false;
|
||||
mStrokeWidth = dip2px(DEFAULT_STROKE_WIDTH);
|
||||
|
||||
build();
|
||||
}
|
||||
|
||||
public synchronized void start() {
|
||||
if (mAnimatorSet == null || mIsStarted) {
|
||||
return;
|
||||
}
|
||||
|
||||
mAnimatorSet.start();
|
||||
}
|
||||
|
||||
public synchronized void stop() {
|
||||
if (mAnimatorSet == null || !mIsStarted) {
|
||||
return;
|
||||
}
|
||||
mAnimatorSet.end();
|
||||
}
|
||||
|
||||
public synchronized boolean isStarted() {
|
||||
return (mAnimatorSet != null && mIsStarted);
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
return mCount;
|
||||
}
|
||||
|
||||
public int getDuration() {
|
||||
return mDuration;
|
||||
}
|
||||
|
||||
public void setCount(int count) {
|
||||
if (count < 0) {
|
||||
throw new IllegalArgumentException("Count cannot be negative");
|
||||
}
|
||||
|
||||
if (count != mCount) {
|
||||
mCount = count;
|
||||
reset();
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
public void setDuration(int millis) {
|
||||
if (millis < 0) {
|
||||
throw new IllegalArgumentException("Duration cannot be negative");
|
||||
}
|
||||
|
||||
if (millis != mDuration) {
|
||||
mDuration = millis;
|
||||
reset();
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
public void setColor(int color) {
|
||||
if (mColor != color) {
|
||||
mColor = color;
|
||||
reset();
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
public void setUseRing(boolean useRing) {
|
||||
if (mUseRing != useRing) {
|
||||
mUseRing = useRing;
|
||||
reset();
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
|
||||
int width = getMeasuredWidth() - getPaddingLeft() - getPaddingRight();
|
||||
int height = getMeasuredHeight() - getPaddingTop() - getPaddingBottom();
|
||||
|
||||
// 确定圆的圆点坐标及半径
|
||||
mCenterX = width * 0.5f;
|
||||
mCenterY = height * 0.5f;
|
||||
mRadius = Math.min(width, height) * 0.5f;
|
||||
}
|
||||
|
||||
private void clear() {
|
||||
stop();
|
||||
removeAllViews();
|
||||
}
|
||||
|
||||
private void build() {
|
||||
|
||||
LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
|
||||
|
||||
int repeatCount = (mRepeat == INFINITE) ? ObjectAnimator.INFINITE : mRepeat;
|
||||
|
||||
List animators = new ArrayList();
|
||||
for (int index = 0; index < mCount; index++) {
|
||||
RadarView radarView = new RadarView(getContext());
|
||||
radarView.setScaleX(0);
|
||||
radarView.setScaleY(0);
|
||||
radarView.setAlpha(1);
|
||||
|
||||
addView(radarView, index, params);
|
||||
|
||||
// 计算时间间隔
|
||||
long delay = index * mDuration / mCount;
|
||||
|
||||
// 属性动画
|
||||
animators.add(create(radarView, "scaleX", repeatCount, delay, 0, 1));
|
||||
animators.add(create(radarView, "scaleY", repeatCount, delay, 0, 1));
|
||||
animators.add(create(radarView, "alpha", repeatCount, delay, 1, 0));
|
||||
}
|
||||
|
||||
mAnimatorSet = new AnimatorSet();
|
||||
mAnimatorSet.playTogether(animators);
|
||||
mAnimatorSet.setInterpolator(new LinearInterpolator());
|
||||
mAnimatorSet.setDuration(mDuration);
|
||||
mAnimatorSet.addListener(mAnimatorListener);
|
||||
}
|
||||
|
||||
private ObjectAnimator create(View target, String propertyName, int repeatCount, long delay, float from, float to) {
|
||||
ObjectAnimator animator = ObjectAnimator.ofFloat(target, propertyName, from, to);
|
||||
animator.setRepeatCount(repeatCount);
|
||||
animator.setRepeatMode(ObjectAnimator.RESTART);
|
||||
animator.setStartDelay(delay);
|
||||
return animator;
|
||||
}
|
||||
|
||||
private void reset() {
|
||||
boolean isStarted = isStarted();
|
||||
|
||||
clear();
|
||||
build();
|
||||
|
||||
if (isStarted) {
|
||||
start();
|
||||
}
|
||||
}
|
||||
|
||||
private class RadarView extends View {
|
||||
|
||||
public RadarView(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
if (null == mPaint) {
|
||||
mPaint = new Paint();
|
||||
mPaint.setColor(mColor);
|
||||
mPaint.setAntiAlias(true);
|
||||
// 注意Style的用法,【STROKE:画环】【FILL:画圆】
|
||||
mPaint.setStyle(mUseRing ? Paint.Style.STROKE : Paint.Style.FILL);
|
||||
mPaint.setStrokeWidth(mUseRing ? mStrokeWidth : 0);
|
||||
}
|
||||
// 画圆或环
|
||||
canvas.drawCircle(mCenterX, mCenterY, mUseRing ? mRadius - mStrokeWidth : mRadius, mPaint);
|
||||
}
|
||||
}
|
||||
|
||||
private int dip2px(float dpValue) {
|
||||
final float scale = getResources().getDisplayMetrics().density;
|
||||
return (int) (dpValue * scale + 0.5f);
|
||||
}
|
||||
|
||||
private final Animator.AnimatorListener mAnimatorListener = new Animator.AnimatorListener() {
|
||||
|
||||
@Override
|
||||
public void onAnimationStart(Animator animator) {
|
||||
mIsStarted = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animator) {
|
||||
mIsStarted = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationCancel(Animator animator) {
|
||||
mIsStarted = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animator animator) {
|
||||
}
|
||||
};
|
||||
}
|
||||
1716
app/src/main/java/com/gh/common/view/SwipeLayout.java
Normal file
1716
app/src/main/java/com/gh/common/view/SwipeLayout.java
Normal file
File diff suppressed because it is too large
Load Diff
@ -97,8 +97,12 @@ public class DownloadTask implements DownloadListener {
|
||||
|
||||
// 计算下载速度
|
||||
if (System.currentTimeMillis() - lastTime > Constants.SPEED_CHECK_INTERVAL) {
|
||||
entry.setSpeed(intervalDownloadedSize
|
||||
/ (Constants.SPEED_CHECK_INTERVAL));
|
||||
long speed = intervalDownloadedSize / (Constants.SPEED_CHECK_INTERVAL);
|
||||
if (speed < 0) {
|
||||
entry.setSpeed(0);
|
||||
} else {
|
||||
entry.setSpeed(speed);
|
||||
}
|
||||
lastTime = System.currentTimeMillis();
|
||||
intervalDownloadedSize = 0;
|
||||
DownloadDao.getInstance(context).newOrUpdate(entry);
|
||||
|
||||
63
app/src/main/java/com/gh/gamecenter/AboutActivity.java
Normal file
63
app/src/main/java/com/gh/gamecenter/AboutActivity.java
Normal file
@ -0,0 +1,63 @@
|
||||
package com.gh.gamecenter;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.view.View;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gh.base.BaseActivity;
|
||||
import com.gh.gamecenter.manager.UpdateManager;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.OnClick;
|
||||
|
||||
/**
|
||||
* Created by khy on 2017/2/28.
|
||||
*/
|
||||
public class AboutActivity extends BaseActivity {
|
||||
|
||||
@BindView(R.id.about_version_tv) TextView mAboutVersion;
|
||||
@BindView(R.id.about_version_pb) ProgressBar mAboutPb;
|
||||
|
||||
Handler handler = new Handler() {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
super.handleMessage(msg);
|
||||
if (msg.what == 0) {
|
||||
String version = (String) msg.obj;
|
||||
mAboutVersion.setText("发现新版本 V" + version);
|
||||
mAboutPb.setVisibility(View.GONE);
|
||||
} else if (msg.what ==1) {
|
||||
mAboutVersion.setText("已是最新版本");
|
||||
mAboutPb.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
View view = View.inflate(this, R.layout.activity_about, null);
|
||||
init(view, "关于");
|
||||
|
||||
UpdateManager.getInstance(this).checkUpdate(false, handler); // 自动检出更新
|
||||
}
|
||||
|
||||
@OnClick({R.id.about_version_tv, R.id.about_shengming})
|
||||
public void OnClick(View view) {
|
||||
if (view.getId() == R.id.about_version_tv) {
|
||||
String content = mAboutVersion.getText().toString();
|
||||
if (content.startsWith("发现新版本")) {
|
||||
UpdateManager.getInstance(this).checkUpdate(false, handler); // 自动检出更新
|
||||
}
|
||||
} else if (view.getId() == R.id.about_shengming) {
|
||||
Intent intent = new Intent(AboutActivity.this, WebActivity.class);
|
||||
intent.putExtra("gameName", "使用条款与免责声明");
|
||||
intent.putExtra("url","http://api.ghzhushou.com/disclaimer");
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
}
|
||||
607
app/src/main/java/com/gh/gamecenter/ChooseReceiverActivity.java
Normal file
607
app/src/main/java/com/gh/gamecenter/ChooseReceiverActivity.java
Normal file
@ -0,0 +1,607 @@
|
||||
package com.gh.gamecenter;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Color;
|
||||
import android.net.wifi.ScanResult;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.text.Html;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.animation.AccelerateInterpolator;
|
||||
import android.view.animation.AlphaAnimation;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.ScaleAnimation;
|
||||
import android.view.animation.TranslateAnimation;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.facebook.drawee.backends.pipeline.Fresco;
|
||||
import com.facebook.drawee.interfaces.DraweeController;
|
||||
import com.facebook.drawee.view.SimpleDraweeView;
|
||||
import com.gh.base.AppController;
|
||||
import com.gh.base.BaseActivity;
|
||||
import com.gh.common.constant.Config;
|
||||
import com.gh.common.util.DialogUtils;
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.UserIconUtils;
|
||||
import com.gh.common.util.Utils;
|
||||
import com.gh.gamecenter.kuaichuan.BaseTransfer;
|
||||
import com.gh.gamecenter.kuaichuan.Constant;
|
||||
import com.gh.gamecenter.kuaichuan.FileInfo;
|
||||
import com.gh.gamecenter.kuaichuan.HotspotManager;
|
||||
import com.gh.gamecenter.kuaichuan.WifiMgr;
|
||||
import com.gh.gamecenter.kuaichuan.WifiUtils;
|
||||
import com.gh.gamecenter.manager.SystemBarTintManager;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.net.DatagramPacket;
|
||||
import java.net.DatagramSocket;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.OnClick;
|
||||
|
||||
/**
|
||||
* Created by khy on 2017/1/20.
|
||||
*/
|
||||
public class ChooseReceiverActivity extends BaseActivity implements View.OnClickListener{
|
||||
|
||||
@BindView(R.id.choosereceiver_user1_name) TextView choosereceiver_user1_name;
|
||||
@BindView(R.id.choosereceiver_user2_name) TextView choosereceiver_user2_name;
|
||||
@BindView(R.id.choosereceiver_user3_name) TextView choosereceiver_user3_name;
|
||||
@BindView(R.id.choosereceiver_user4_name) TextView choosereceiver_user4_name;
|
||||
@BindView(R.id.choosereceiver_user1) LinearLayout choosereceiver_user1;
|
||||
@BindView(R.id.choosereceiver_user2) LinearLayout choosereceiver_user2;
|
||||
@BindView(R.id.choosereceiver_user3) LinearLayout choosereceiver_user3;
|
||||
@BindView(R.id.choosereceiver_user4) LinearLayout choosereceiver_user4;
|
||||
@BindView(R.id.choosereceiver_user1_icon) SimpleDraweeView userIcon1;
|
||||
@BindView(R.id.choosereceiver_user2_icon) SimpleDraweeView userIcon2;
|
||||
@BindView(R.id.choosereceiver_user3_icon) SimpleDraweeView userIcon3;
|
||||
@BindView(R.id.choosereceiver_user4_icon) SimpleDraweeView userIcon4;
|
||||
@BindView(R.id.scan_gif) SimpleDraweeView mScanGif;
|
||||
@BindView(R.id.scan_user) TextView mScanUser;
|
||||
@BindView(R.id.scan_user_des) TextView mScanUserDes;
|
||||
@BindView(R.id.reuse_actionbar) RelativeLayout mActionbar;
|
||||
@BindView(R.id.scan_hint) TextView mScanHint;
|
||||
@BindView(R.id.choosereceiver_roket_anim) RelativeLayout mRoketAnimRl;
|
||||
@BindView(R.id.choosereceiver_ready_rl) RelativeLayout mRoketRl;
|
||||
@BindView(R.id.choosereceiver_roket_anim_bottom) LinearLayout mRoketAnimBottom;
|
||||
@BindView(R.id.choosereceiver_roket_anim_top) ImageView mRoketTop;
|
||||
@BindView(R.id.choosereceiver_roket_left) ImageView mRoketAnimLeft;
|
||||
@BindView(R.id.choosereceiver_roket_right) ImageView mRoketAnimRight;
|
||||
|
||||
private List<ScanResult> mScanResultList;
|
||||
|
||||
private DatagramSocket mDatagramSocket;
|
||||
|
||||
private boolean isStopScan;
|
||||
|
||||
private boolean isDestroy;
|
||||
|
||||
private int conUserIconTag;
|
||||
|
||||
private SharedPreferences sp;
|
||||
|
||||
private ScaleAnimation mScaleAnimation; // 火箭喷火动画
|
||||
|
||||
private TranslateAnimation mTranslateAnimation; // 整个火箭移动页面
|
||||
|
||||
Handler handler = new Handler() {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
super.handleMessage(msg);
|
||||
if (msg.what == 0 && !isStopScan) {
|
||||
updateWifiScanResult();
|
||||
handler.sendEmptyMessageDelayed(0, 2000);
|
||||
} else if (msg.what == 2) {
|
||||
isStopScan = false;
|
||||
handler.sendEmptyMessage(0);
|
||||
connFailedAnimView();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
View contentView = View.inflate(this, R.layout.activity_choosereceiver, null);
|
||||
init(contentView, "发送游戏");
|
||||
|
||||
|
||||
// 添加分享图标
|
||||
TextView hintTv = new TextView(this);
|
||||
hintTv.setText("操作说明");
|
||||
hintTv.setTextColor(Color.WHITE);
|
||||
hintTv.setGravity(Gravity.CENTER);
|
||||
hintTv.setPadding(DisplayUtils.dip2px(this, 13),0 ,DisplayUtils.dip2px(this, 13),0);
|
||||
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT );
|
||||
RelativeLayout reuse_actionbar = (RelativeLayout) contentView.findViewById(
|
||||
R.id.reuse_actionbar);
|
||||
reuse_actionbar.addView(hintTv, params);
|
||||
|
||||
//修改沉浸栏以及ActionBar 颜色
|
||||
mActionbar.setBackgroundColor(getResources().getColor(R.color.scan_bg));
|
||||
SystemBarTintManager tintManager = getTintManager();
|
||||
if (tintManager != null) {
|
||||
tintManager.setStatusBarTintResource(R.color.scan_bg);
|
||||
}
|
||||
|
||||
init();
|
||||
|
||||
hintTv.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
showConnHintDialog();
|
||||
}
|
||||
});
|
||||
|
||||
boolean showConnHintDialog = sp.getBoolean("showConnHintDialog", true);
|
||||
if (showConnHintDialog || (getIntent() != null && getIntent().getExtras() != null
|
||||
&& getIntent().getExtras().getBoolean("showConnHintDialog"))) {
|
||||
if (showConnHintDialog) {
|
||||
sp.edit().putBoolean("showConnHintDialog", false).apply();
|
||||
}
|
||||
showConnHintDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void showConnHintDialog() {
|
||||
DialogUtils.showHintDialog(ChooseReceiverActivity.this, "请告诉你的好友这样操作:", "1.请好友拿出手机,打开光环助手 " +
|
||||
"\n2.点击首页左上角“↓”按钮 \n3.点击“我要接收”", "确定");
|
||||
}
|
||||
|
||||
@OnClick(R.id.scan_hint)
|
||||
public void onScanHintListener() {
|
||||
// DialogUtils.showHintDialog(this, "请告诉你的好友这样操作:", "1.拿出手机,打开光环助手 " +
|
||||
// "\n2.点击首页左上角,进入下载管理 \n3.点击“零流量传送”,再点击“我要接收”",
|
||||
// "确定");
|
||||
|
||||
// TODO 关闭扫描??
|
||||
|
||||
Intent intent = new Intent(this, ShareGhActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
private void init() {
|
||||
sp = getSharedPreferences(Config.PREFERENCE, Context.MODE_PRIVATE);
|
||||
conUserIconTag = 1;
|
||||
|
||||
DraweeController controller = Fresco.newDraweeControllerBuilder()
|
||||
.setUri("res:///" + R.drawable.scan_receiver)
|
||||
.setAutoPlayAnimations(true)
|
||||
.build();
|
||||
mScanGif.setController(controller);
|
||||
|
||||
mScanHint.setText(Html.fromHtml("<u>"+"好友还没安装光环助手?请点这里"+"</u>"));
|
||||
|
||||
isStopScan = false;
|
||||
isDestroy = false;
|
||||
|
||||
if (HotspotManager.isApOn(this)) {
|
||||
HotspotManager.disableAp(this);
|
||||
}
|
||||
|
||||
if(!WifiMgr.getInstance(this).isWifiEnable()) { //wifi未打开的情况
|
||||
WifiMgr.getInstance(this).openWifi();
|
||||
}
|
||||
|
||||
updateWifiScanResult();
|
||||
handler.sendEmptyMessageDelayed(0, 2000);
|
||||
}
|
||||
|
||||
private void updateWifiScanResult () {
|
||||
|
||||
if (mScanResultList != null && mScanResultList.size() > 0) {
|
||||
mScanUser.setText("点击头像开始发送");
|
||||
mScanUserDes.setVisibility(View.GONE);
|
||||
} else {
|
||||
mScanUserDes.setVisibility(View.VISIBLE);
|
||||
mScanUser.setText("正在寻找周围的小伙伴...");
|
||||
}
|
||||
|
||||
if (mScanResultList != null) {
|
||||
mScanResultList.clear();
|
||||
}
|
||||
|
||||
choosereceiver_user1.setVisibility(View.GONE);
|
||||
choosereceiver_user2.setVisibility(View.GONE);
|
||||
choosereceiver_user3.setVisibility(View.GONE);
|
||||
choosereceiver_user4.setVisibility(View.GONE);
|
||||
choosereceiver_user1.setEnabled(true);
|
||||
choosereceiver_user2.setEnabled(true);
|
||||
choosereceiver_user3.setEnabled(true);
|
||||
choosereceiver_user4.setEnabled(true);
|
||||
|
||||
WifiMgr.getInstance(this).startScan();
|
||||
mScanResultList = WifiMgr.getInstance(this).getScanResultList();
|
||||
Utils.log("======WifiCount::" + mScanResultList.size());
|
||||
mScanResultList = WifiUtils.filterWithNoPassword(mScanResultList);
|
||||
if(mScanResultList != null){
|
||||
for (int i = 0; i < mScanResultList.size(); i++) {
|
||||
ScanResult scanResult = mScanResultList.get(i);
|
||||
Utils.log(i + "=====" + scanResult.SSID );
|
||||
|
||||
int icon = 1;
|
||||
try {
|
||||
icon = Integer.parseInt(scanResult.SSID.substring(scanResult.SSID.length() - 1));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
switch (i) {
|
||||
case 0:
|
||||
choosereceiver_user1.setVisibility(View.VISIBLE);
|
||||
choosereceiver_user1_name.setText(scanResult.SSID);
|
||||
choosereceiver_user1.setOnClickListener(this);
|
||||
userIcon1.setImageURI(UserIconUtils.getUserIcon(icon));
|
||||
break;
|
||||
case 1:
|
||||
choosereceiver_user2.setVisibility(View.VISIBLE);
|
||||
choosereceiver_user2_name.setText(scanResult.SSID);
|
||||
choosereceiver_user2.setOnClickListener(this);
|
||||
userIcon2.setImageURI(UserIconUtils.getUserIcon(icon));
|
||||
break;
|
||||
case 2:
|
||||
choosereceiver_user3.setVisibility(View.VISIBLE);
|
||||
choosereceiver_user3_name.setText(scanResult.SSID);
|
||||
choosereceiver_user3.setOnClickListener(this);
|
||||
userIcon3.setImageURI(UserIconUtils.getUserIcon(icon));
|
||||
break;
|
||||
case 3:
|
||||
choosereceiver_user4.setVisibility(View.VISIBLE);
|
||||
choosereceiver_user4_name.setText(scanResult.SSID);
|
||||
choosereceiver_user4.setOnClickListener(this);
|
||||
userIcon4.setImageURI(UserIconUtils.getUserIcon(icon));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (v == choosereceiver_user1) {
|
||||
connReceiverWifi(0);
|
||||
} else if (v == choosereceiver_user2) {
|
||||
connReceiverWifi(1);
|
||||
} else if (v == choosereceiver_user3) {
|
||||
connReceiverWifi(2);
|
||||
} else if (v == choosereceiver_user4) {
|
||||
connReceiverWifi(3);
|
||||
}
|
||||
}
|
||||
|
||||
//1.连接网络
|
||||
private void connReceiverWifi(int connPosition) {
|
||||
|
||||
if (isStopScan) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 进入动画页面
|
||||
readyAnimView();
|
||||
|
||||
handler.sendEmptyMessageDelayed(2, 30000);
|
||||
|
||||
Utils.log("======开始连接热点");
|
||||
mScanUser.setText("开始连接对方设备...");
|
||||
isStopScan = true;
|
||||
// choosereceiver_user1.setEnabled(false);
|
||||
// choosereceiver_user2.setEnabled(false);
|
||||
// choosereceiver_user3.setEnabled(false);
|
||||
// choosereceiver_user4.setEnabled(false);
|
||||
|
||||
// handler.postAtTime(new Runnable() { // 5s后还收不到接收者的回馈消息 重新回到扫描页面
|
||||
// @Override
|
||||
// public void run() {
|
||||
// Utils.log("==========aa" + isConnSuccess);
|
||||
// if (!isConnSuccess) {
|
||||
// isStopScan = false;
|
||||
// updateWifiScanResult();
|
||||
// }
|
||||
// }
|
||||
// }, 5000);
|
||||
|
||||
String ssid = "ghzs";
|
||||
ssid = mScanResultList.get(connPosition).SSID;
|
||||
WifiMgr.getInstance(this).openWifi();
|
||||
WifiMgr.getInstance(this).addNetwork(WifiMgr.createWifiCfg(ssid, null, WifiMgr.WIFICIPHER_NOPASS));
|
||||
|
||||
try {
|
||||
conUserIconTag = Integer.parseInt(ssid.substring(ssid.length() - 1));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
createSendMsgToServerRunnable(WifiMgr.getInstance(this).getIpAddressFromHotspot());
|
||||
}
|
||||
|
||||
//发送UDP通知信息到 文件接收方 开启ServerSocketRunnable
|
||||
private void createSendMsgToServerRunnable(final String ipAddress) {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
startFileSenderServer(ipAddress);
|
||||
} catch (Exception e) {
|
||||
isStopScan = false;
|
||||
handler.sendEmptyMessage(0);
|
||||
Utils.log("UDP通信异常--startFileSenderServer" + e.toString());
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
private void startFileSenderServer(String ipAddress) throws Exception {
|
||||
int serverPort = Constant.DEFAULT_SERVER_COM_PORT;
|
||||
|
||||
// 确保Wifi连接上之后获取得到IP地址
|
||||
int count = 0;
|
||||
while(ipAddress.equals(Constant.DEFAULT_UNKOWN_IP) && count < Constant.DEFAULT_TRY_TIME) {
|
||||
Thread.sleep(1000);
|
||||
ipAddress = WifiMgr.getInstance(ChooseReceiverActivity.this).getIpAddressFromHotspot();
|
||||
count ++;
|
||||
}
|
||||
|
||||
// 即使获取到连接的热点wifi的IP地址也是无法连接网络 所以采取此策略
|
||||
count = 0;
|
||||
while(!WifiUtils.pingIpAddress(ipAddress) && count < Constant.DEFAULT_TRY_TIME) {
|
||||
Thread.sleep(500);
|
||||
count ++;
|
||||
}
|
||||
|
||||
if (mDatagramSocket == null) {
|
||||
mDatagramSocket = new DatagramSocket(null);
|
||||
mDatagramSocket.setReuseAddress(true);
|
||||
mDatagramSocket.bind(new InetSocketAddress(serverPort));
|
||||
}
|
||||
// mDatagramSocket = new DatagramSocket(serverPort);
|
||||
byte[] receiveData = new byte[1024];
|
||||
byte[] sendData;
|
||||
Utils.log("=====ip::" + ipAddress);
|
||||
if (!ipAddress.equals("192.168.43.1")) {
|
||||
// 连接失败,可能是连接的热点已经关闭, 关闭动画,开启扫描
|
||||
isStopScan = false;
|
||||
handler.sendEmptyMessage(0);
|
||||
handler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
connFailedAnimView();
|
||||
}
|
||||
});
|
||||
}
|
||||
InetAddress ipAddressName = InetAddress.getByName(ipAddress); // 转译
|
||||
|
||||
//发送 即将发送的文件列表 到文件接收方
|
||||
sendFileInfoListToFileReceiverWithUdp(serverPort, ipAddressName);
|
||||
|
||||
//发送 文件接收方 初始化
|
||||
|
||||
JSONObject senderData = new JSONObject();
|
||||
senderData.put(Constant.MSG_FILE_RECEIVER_INIT, sp.getString("user_name", "光环用户"));
|
||||
senderData.put("UserIcon", sp.getInt("default_user_icon", 1));
|
||||
|
||||
sendData = senderData.toString().getBytes(BaseTransfer.UTF_8);
|
||||
DatagramPacket sendPacket =
|
||||
new DatagramPacket(sendData, sendData.length, ipAddressName, serverPort);
|
||||
mDatagramSocket.send(sendPacket);
|
||||
|
||||
while(!isDestroy) {
|
||||
DatagramPacket receivePacket = new DatagramPacket(receiveData, receiveData.length);
|
||||
mDatagramSocket.receive(receivePacket);
|
||||
String response = new String(receivePacket.getData(), 0, receivePacket.getLength()).trim();
|
||||
Utils.log("ChooseReceiverActivity:: 接收UDP请求" + response);
|
||||
|
||||
if(response != null && response.contains(Constant.MSG_FILE_RECEIVER_INIT_SUCCESS)) {
|
||||
JSONObject jsonObject = new JSONObject(response);
|
||||
Utils.log("ChooseReceiverActivity:: 收到UDP请求::SUCCESS=" + jsonObject.getString(Constant.MSG_FILE_RECEIVER_INIT_SUCCESS));
|
||||
|
||||
Map<String, String> userMap = new HashMap<>();
|
||||
userMap.put("receiverName", jsonObject.getString(Constant.MSG_FILE_RECEIVER_INIT_SUCCESS));
|
||||
userMap.put("usericon", String.valueOf(conUserIconTag));
|
||||
|
||||
AppController.put("userMap", userMap);
|
||||
|
||||
handler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
connSuccessAnimView();
|
||||
}
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void sendFileInfoListToFileReceiverWithUdp(int serverPort, InetAddress ipAddress) {
|
||||
List<FileInfo> fileInfos = (List<FileInfo>) AppController.get("FileInfo", false);
|
||||
|
||||
for (FileInfo fileInfo : fileInfos) {
|
||||
String fileInfoJson = FileInfo.toJsonStr(fileInfo);
|
||||
Utils.log("ChooseReceiverActivity:: 发送的文件列表::" + fileInfoJson);
|
||||
DatagramPacket sendFileInfoListPacket =
|
||||
new DatagramPacket(fileInfoJson.getBytes(), fileInfoJson.getBytes().length, ipAddress, serverPort);
|
||||
try{
|
||||
mDatagramSocket.send(sendFileInfoListPacket);
|
||||
Utils.log("ChooseReceiverActivity:: UDP通知 Success::" + ipAddress + "==" + serverPort);
|
||||
} catch (Exception e) {
|
||||
Utils.log("ChooseReceiverActivity:: UDP通知 Failure!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 连接中-动画
|
||||
private void readyAnimView() {
|
||||
mActionbar.setVisibility(View.GONE);
|
||||
mRoketRl.setVisibility(View.VISIBLE);
|
||||
mRoketRl.animate()
|
||||
.alpha(1f)
|
||||
.setDuration(1000)
|
||||
.setListener(null);
|
||||
|
||||
mScaleAnimation = new ScaleAnimation(0.5f, 0.8f, 0.5f, 0.8f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
|
||||
mScaleAnimation.setDuration(250);
|
||||
mScaleAnimation.setRepeatCount(Animation.INFINITE);
|
||||
mScaleAnimation.setRepeatMode(Animation.REVERSE);
|
||||
|
||||
mRoketAnimLeft.startAnimation(mScaleAnimation);
|
||||
mRoketAnimRight.startAnimation(mScaleAnimation);
|
||||
}
|
||||
|
||||
// 连接成功-动画
|
||||
private void connSuccessAnimView() {
|
||||
handler.removeMessages(2);
|
||||
|
||||
if (mScaleAnimation != null) {
|
||||
mScaleAnimation.cancel();
|
||||
}
|
||||
AlphaAnimation alphaAnimation = new AlphaAnimation(1f, 0.6f);
|
||||
alphaAnimation.setDuration(250);
|
||||
alphaAnimation.setRepeatCount(Animation.INFINITE);
|
||||
alphaAnimation.setRepeatMode(Animation.REVERSE);
|
||||
mRoketAnimLeft.startAnimation(alphaAnimation);
|
||||
mRoketAnimRight.startAnimation(alphaAnimation);
|
||||
|
||||
mScaleAnimation = new ScaleAnimation(0.5f, 0.8f, 0.5f, 0.8f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
|
||||
mScaleAnimation.setDuration(250);
|
||||
mScaleAnimation.setRepeatCount(Animation.INFINITE);
|
||||
mScaleAnimation.setRepeatMode(Animation.REVERSE);
|
||||
|
||||
mRoketAnimLeft.setImageResource(R.drawable.kuaichuan_rocket_fire);
|
||||
mRoketAnimRight.setImageResource(R.drawable.kuaichuan_rocket_fire);
|
||||
|
||||
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) mRoketAnimRight.getLayoutParams();
|
||||
layoutParams.height = LinearLayout.LayoutParams.MATCH_PARENT;
|
||||
layoutParams.width = DisplayUtils.dip2px(this, 25);
|
||||
|
||||
mRoketAnimRight.setLayoutParams(layoutParams);
|
||||
LinearLayout.LayoutParams layoutParams2 = (LinearLayout.LayoutParams) mRoketAnimLeft.getLayoutParams();
|
||||
layoutParams2.height = LinearLayout.LayoutParams.MATCH_PARENT;
|
||||
layoutParams2.width = DisplayUtils.dip2px(this, 25);
|
||||
|
||||
layoutParams2.setMargins(0, 0, DisplayUtils.dip2px(ChooseReceiverActivity.this, 14), 0);
|
||||
mRoketAnimLeft.setLayoutParams(layoutParams2);
|
||||
|
||||
|
||||
if (mScaleAnimation == null) {
|
||||
mScaleAnimation.cancel();
|
||||
}
|
||||
|
||||
mTranslateAnimation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, -1000);
|
||||
mTranslateAnimation.setDuration(1000);
|
||||
mTranslateAnimation.setInterpolator(new AccelerateInterpolator(2.0f));
|
||||
// mTranslateAnimation.setFillAfter(true);
|
||||
|
||||
mRoketAnimRl.startAnimation(mTranslateAnimation);
|
||||
|
||||
mTranslateAnimation.setAnimationListener(new Animation.AnimationListener() {
|
||||
@Override
|
||||
public void onAnimationStart(Animation animation) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animation animation) {
|
||||
mRoketAnimRl.setVisibility(View.GONE);
|
||||
Intent intent = new Intent(ChooseReceiverActivity.this, FileSenderActivity.class);
|
||||
startActivity(intent);
|
||||
closeSocket();
|
||||
Intent resultIntent= new Intent();
|
||||
resultIntent.putExtra("isFinish", true);
|
||||
setResult(0x123, resultIntent);
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animation animation) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 连接失败-动画
|
||||
private void connFailedAnimView() {
|
||||
mActionbar.setVisibility(View.VISIBLE);
|
||||
Utils.toast(ChooseReceiverActivity.this, "连接失败");
|
||||
if (mScaleAnimation == null) {
|
||||
mScaleAnimation.cancel();
|
||||
}
|
||||
mRoketRl.animate()
|
||||
.alpha(0f)
|
||||
.setDuration(1000)
|
||||
.setListener(new Animator.AnimatorListener() {
|
||||
@Override
|
||||
public void onAnimationStart(Animator animation) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
mRoketRl.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationCancel(Animator animation) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animator animation) {
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
super.onBackPressed();
|
||||
closeSocket();
|
||||
AppController.remove("FileInfo");
|
||||
}
|
||||
|
||||
@OnClick(R.id.actionbar_rl_back)
|
||||
public void onBackListener() {
|
||||
closeSocket();
|
||||
AppController.remove("FileInfo");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
isDestroy = true;
|
||||
isStopScan = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭UDP Socket 流
|
||||
*/
|
||||
private void closeSocket(){
|
||||
isStopScan = true;
|
||||
if(mDatagramSocket != null) {
|
||||
// mDatagramSocket.disconnect();
|
||||
mDatagramSocket.close();
|
||||
mDatagramSocket = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
222
app/src/main/java/com/gh/gamecenter/CleanApkActivity.java
Normal file
222
app/src/main/java/com/gh/gamecenter/CleanApkActivity.java
Normal file
@ -0,0 +1,222 @@
|
||||
package com.gh.gamecenter;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.util.ArrayMap;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.text.Html;
|
||||
import android.view.View;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gh.base.BaseActivity;
|
||||
import com.gh.common.util.DialogUtils;
|
||||
import com.gh.common.util.Utils;
|
||||
import com.gh.gamecenter.adapter.CleanApkAdapter;
|
||||
import com.gh.gamecenter.entity.InstallGameEntity;
|
||||
import com.gh.gamecenter.eventbus.EBSkip;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.OnClick;
|
||||
import de.greenrobot.event.EventBus;
|
||||
|
||||
/**
|
||||
* Created by khy on 2017/1/24.
|
||||
*/
|
||||
public class CleanApkActivity extends BaseActivity implements CleanApkAdapter.OnScanListener {
|
||||
|
||||
@BindView(R.id.apk_count) TextView mApkCount;
|
||||
@BindView(R.id.apk_rv) RecyclerView mApkRv;
|
||||
@BindView(R.id.delete_btn) TextView mApkDeleteBtn;
|
||||
@BindView(R.id.select_game_all) CheckBox mApkSelectAll;
|
||||
@BindView(R.id.scan_pb) ProgressBar mScanPb;
|
||||
@BindView(R.id.reuse_nodata_skip_tv_hint) TextView mNodataSkipTv;
|
||||
@BindView(R.id.reuse_nodata_skip_tv_btn) TextView mNodataSkipBtn;
|
||||
@BindView(R.id.reuse_nodata_skip) LinearLayout mNodataSkipLl;
|
||||
@BindView(R.id.delete_bottom) LinearLayout mDeleteBottom;
|
||||
@BindView(R.id.select_game_installed_ll) RelativeLayout mInstallAllData;
|
||||
|
||||
private CleanApkAdapter mAdapter;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
View contentView = View.inflate(this, R.layout.activity_clean_apk, null);
|
||||
init(contentView, "安装包清理");
|
||||
|
||||
mNodataSkipLl.setVisibility(View.GONE);
|
||||
|
||||
mAdapter = new CleanApkAdapter(this, mApkDeleteBtn, mApkSelectAll);
|
||||
mApkRv.setLayoutManager(new LinearLayoutManager(this));
|
||||
mApkRv.setAdapter(mAdapter);
|
||||
|
||||
mApkSelectAll.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
ArrayMap<Integer, Boolean> selectPosition = new ArrayMap<>();
|
||||
ArrayMap<Integer, Boolean> selectPosition1 = mAdapter.getSelectPosition();
|
||||
int itemCount = mAdapter.getItemCount();
|
||||
if (isChecked) {
|
||||
for (int i = 0; i < itemCount; i++) {
|
||||
selectPosition.put(i, true);
|
||||
}
|
||||
} else {
|
||||
int selectCount = 0;
|
||||
for (Integer integer : selectPosition1.keySet()) {
|
||||
if (selectPosition1.get(integer)) {
|
||||
selectCount ++;
|
||||
}
|
||||
}
|
||||
|
||||
if (selectCount != itemCount) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < itemCount; i++) {
|
||||
selectPosition.put(i, false);
|
||||
}
|
||||
}
|
||||
|
||||
mAdapter.setSelectPosition(selectPosition);
|
||||
mAdapter.notifyItemRangeChanged(0, itemCount);
|
||||
mAdapter.checkBoxControl(isChecked, 0);
|
||||
}
|
||||
});
|
||||
|
||||
mNodataSkipBtn.setText("去首页看看");
|
||||
mNodataSkipTv.setText("安装包已清理干净\n快去发现更多好玩的游戏吧!");
|
||||
mNodataSkipTv.setLineSpacing(0, 1.5f);
|
||||
|
||||
}
|
||||
|
||||
@OnClick({R.id.delete_btn, R.id.reuse_nodata_skip_tv_btn})
|
||||
public void onClick(View view) {
|
||||
switch (view.getId()) {
|
||||
case R.id.delete_btn: {
|
||||
String s = mApkDeleteBtn.getText().toString();
|
||||
if ("停止扫描".equals(s)) {
|
||||
mAdapter.isStopScan();
|
||||
} else {
|
||||
if (s.equals("一键删除")) {
|
||||
Utils.toast(CleanApkActivity.this, "请选择需要删除的安装包");
|
||||
return;
|
||||
}
|
||||
|
||||
final List<InstallGameEntity> apkList = mAdapter.getApkList();
|
||||
final ArrayMap<Integer, Boolean> selectPosition = mAdapter.getSelectPosition();
|
||||
|
||||
for (int i = 0; i < apkList.size(); i++) {
|
||||
if (selectPosition.get(i) && apkList.get(i).getInstallStatus() == 1) {
|
||||
DialogUtils.showWarningDialog(CleanApkActivity.this, "删除安装包"
|
||||
, Html.fromHtml("你选择的安装包中包含"+ "<font color=\"#ff0000\">未安装</font>"
|
||||
+"的应用,确定删除吗?"), "取消 ", "确定"
|
||||
, new DialogUtils.ConfiremListener() {
|
||||
@Override
|
||||
public void onConfirem() {
|
||||
deleteApk(apkList, selectPosition);
|
||||
}
|
||||
}, null);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
deleteApk(apkList, selectPosition);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case R.id.reuse_nodata_skip_tv_btn: {
|
||||
Intent intent = new Intent(CleanApkActivity.this, MainActivity.class);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(intent);
|
||||
new Thread(){
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
sleep(300);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
EventBus.getDefault().post(new EBSkip("GameFragment", 0));
|
||||
}
|
||||
}.start();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteApk(List<InstallGameEntity> apkList, ArrayMap<Integer, Boolean> selectPosition) {
|
||||
long size = 0;
|
||||
for (int i = 0; i < apkList.size(); i++) {
|
||||
if (selectPosition.get(i)) {
|
||||
InstallGameEntity installGameEntity = apkList.get(i);
|
||||
size = size + installGameEntity.getGameSize();
|
||||
File file = new File(installGameEntity.getGamePath());
|
||||
if (file.isFile() && file.exists()) {
|
||||
file.delete();
|
||||
mAdapter.deleteApk(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
double allSize = (((float)size/1024)/1024);
|
||||
DecimalFormat df = new DecimalFormat("#.00");
|
||||
String sizeName = df.format(allSize) + "MB";
|
||||
Utils.toast(CleanApkActivity.this, "删除成功,已为您节省" + sizeName + "空间");
|
||||
mApkDeleteBtn.setText("一键删除");
|
||||
mAdapter.notifyDataSetChanged(); // 刷新Adapter position
|
||||
|
||||
updateScanData();
|
||||
|
||||
if (apkList.size() == 0) { // 全部删除
|
||||
mNodataSkipLl.setVisibility(View.VISIBLE);
|
||||
mInstallAllData.setVisibility(View.GONE);
|
||||
mDeleteBottom.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateScanData(){
|
||||
long allSize = 0;
|
||||
List<InstallGameEntity> apkList = mAdapter.getApkList();
|
||||
for (InstallGameEntity installGameEntity : apkList) {
|
||||
allSize = allSize + installGameEntity.getGameSize();
|
||||
}
|
||||
|
||||
double size = (((float)allSize/1024)/1024);
|
||||
DecimalFormat df = new DecimalFormat("0.00");
|
||||
String sizeName = df.format(size) + "MB";
|
||||
|
||||
mApkCount.setText(Html.fromHtml("找到" + apkList.size() + "个安装包,占用"
|
||||
+ "<font color=\"#ff4147\">" + sizeName + "</font>"+ "空间"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScanOver() {
|
||||
mApkDeleteBtn.setText("立即删除");
|
||||
mApkDeleteBtn.setBackgroundResource(R.drawable.game_item_btn_red_style);
|
||||
|
||||
updateScanData();
|
||||
|
||||
mScanPb.setVisibility(View.GONE);
|
||||
mApkSelectAll.setVisibility(View.VISIBLE);
|
||||
mApkSelectAll.setChecked(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void noData() {
|
||||
mNodataSkipBtn.setText("去首页看看");
|
||||
mNodataSkipTv.setText("暂无安装包");
|
||||
mNodataSkipLl.setVisibility(View.VISIBLE);
|
||||
mInstallAllData.setVisibility(View.GONE);
|
||||
mDeleteBottom.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
@ -117,8 +117,8 @@ public class ConcernActivity extends BaseActivity implements OnClickListener {
|
||||
concernInfo.setConcern(true);
|
||||
concernInfo.setIcon(gameEntity.getIcon());
|
||||
concernInfo.setId(gameEntity.getId());
|
||||
concernAdapter.getConcernList().add(concernInfo);
|
||||
concernAdapter.getConcernGameList().add(gameEntity);
|
||||
concernAdapter.getConcernList().add(0, concernInfo);
|
||||
concernAdapter.getConcernGameList().add(0, gameEntity);
|
||||
if (reuse_none_data.getVisibility() == View.VISIBLE) {
|
||||
reuse_none_data.setVisibility(View.GONE);
|
||||
concern_rv_show.setVisibility(View.VISIBLE);
|
||||
|
||||
@ -1,11 +1,14 @@
|
||||
package com.gh.gamecenter;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.text.TextUtils;
|
||||
import android.util.TypedValue;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup.LayoutParams;
|
||||
@ -28,6 +31,8 @@ import org.json.JSONObject;
|
||||
import java.io.File;
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import butterknife.BindView;
|
||||
import rx.Observable;
|
||||
@ -42,6 +47,8 @@ public class CropImageActivity extends BaseActivity {
|
||||
|
||||
private SoftReference<Bitmap> reference;
|
||||
|
||||
private SharedPreferences sp;
|
||||
|
||||
private Handler handler = new Handler() {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
@ -63,6 +70,8 @@ public class CropImageActivity extends BaseActivity {
|
||||
|
||||
init(contentView, "图片裁剪");
|
||||
|
||||
sp = getSharedPreferences(Config.PREFERENCE, Context.MODE_PRIVATE);
|
||||
|
||||
RelativeLayout reuse_actionbar = (RelativeLayout) findViewById(R.id.reuse_actionbar);
|
||||
|
||||
TextView confirm = new TextView(this);
|
||||
@ -135,11 +144,36 @@ public class CropImageActivity extends BaseActivity {
|
||||
try {
|
||||
int statusCode = result.getInt("statusCode");
|
||||
if (statusCode == HttpURLConnection.HTTP_OK) {
|
||||
handler.sendEmptyMessage(0);
|
||||
|
||||
String iconCount = sp.getString("updateIconCount", null);
|
||||
|
||||
long l = System.currentTimeMillis();
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
|
||||
String time = format.format(new Date(l));
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("time", time);
|
||||
|
||||
if (TextUtils.isEmpty(iconCount)) {
|
||||
jsonObject.put("count", 1);
|
||||
} else {
|
||||
JSONObject json = new JSONObject(iconCount);
|
||||
String lastTime = json.getString("time");
|
||||
if (lastTime.equals(time)) {
|
||||
jsonObject.put("count", json.getInt("count") + 1);
|
||||
} else {
|
||||
jsonObject.put("count", 1);
|
||||
}
|
||||
}
|
||||
|
||||
sp.edit().putString("updateIconCount", jsonObject.toString()).apply();
|
||||
|
||||
Intent data = new Intent();
|
||||
data.putExtra("url", result.getString("icon"));
|
||||
setResult(RESULT_OK, data);
|
||||
finish();
|
||||
handler.sendEmptyMessage(0);
|
||||
|
||||
} else if (statusCode == HttpURLConnection.HTTP_FORBIDDEN
|
||||
&& "too frequent".equals(result.getString("detail"))) {
|
||||
handler.sendEmptyMessage(2);
|
||||
|
||||
@ -15,6 +15,7 @@ import com.gh.base.BaseFragmentActivity;
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.download.DownloadManager;
|
||||
import com.gh.gamecenter.adapter.FragmentAdapter;
|
||||
import com.gh.gamecenter.download.FileSendFragment;
|
||||
import com.gh.gamecenter.download.GameDownLoadFragment;
|
||||
import com.gh.gamecenter.download.GameUpdateFragment;
|
||||
import com.gh.gamecenter.eventbus.EBDownloadChanged;
|
||||
@ -42,8 +43,10 @@ public class DownloadManagerActivity extends BaseFragmentActivity implements
|
||||
@BindView(R.id.downloadmanager_tv_download) TextView downloadmanager_tv_download;
|
||||
@BindView(R.id.downloadmanager_tv_update) TextView downloadmanager_tv_update;
|
||||
@BindView(R.id.downloadmanager_download_number) TextView downloadmanager_download_number;
|
||||
@BindView(R.id.downloadmanager_tv_send) TextView downloadmanager_tv_send;
|
||||
@BindView(R.id.downloadmanager_update_number) TextView downloadmanager_update_number;
|
||||
@BindView(R.id.downloadmanager_ll_download) LinearLayout downloadmanager_ll_download;
|
||||
@BindView(R.id.downloadmanager_ll_send) LinearLayout downloadmanager_ll_send;
|
||||
@BindView(R.id.downloadmanager_ll_update) LinearLayout downloadmanager_ll_update;
|
||||
@BindView(R.id.downloadmanager_slide_line) View downloadmanager_slide_line;
|
||||
|
||||
@ -68,6 +71,7 @@ public class DownloadManagerActivity extends BaseFragmentActivity implements
|
||||
|
||||
downloadmanager_ll_download.setOnClickListener(this);
|
||||
downloadmanager_ll_update.setOnClickListener(this);
|
||||
downloadmanager_ll_send.setOnClickListener(this);
|
||||
|
||||
int updateSize = PackageManager.getUpdateList().size();
|
||||
if (updateSize != 0) {
|
||||
@ -95,21 +99,19 @@ public class DownloadManagerActivity extends BaseFragmentActivity implements
|
||||
}
|
||||
}
|
||||
if (currentItem == -1) {
|
||||
if (updateSize != 0 && downloadSize == 0) {
|
||||
currentItem = 1;
|
||||
} else {
|
||||
currentItem = 0;
|
||||
}
|
||||
currentItem = 1; //默认游戏下载页面
|
||||
}
|
||||
|
||||
DisplayMetrics outMetrics = new DisplayMetrics();
|
||||
getWindowManager().getDefaultDisplay().getMetrics(outMetrics);
|
||||
width = outMetrics.widthPixels / 2;
|
||||
lparams = new LinearLayout.LayoutParams(width / 2, DisplayUtils.dip2px(getApplicationContext(), 2));
|
||||
lparams.leftMargin = (int) (width * (currentItem + 0.25f));
|
||||
width = outMetrics.widthPixels / 3;
|
||||
lparams = new LinearLayout.LayoutParams((int)(width * 0.7),
|
||||
DisplayUtils.dip2px(getApplicationContext(), 2));
|
||||
lparams.leftMargin = (int) (width * (currentItem + 0.17f));
|
||||
downloadmanager_slide_line.setLayoutParams(lparams);
|
||||
|
||||
List<Fragment> list = new ArrayList<>();
|
||||
list.add(new FileSendFragment());
|
||||
list.add(new GameDownLoadFragment());
|
||||
list.add(new GameUpdateFragment());
|
||||
downloadmanager_viewPager.setAdapter(new FragmentAdapter(getSupportFragmentManager(), list));
|
||||
@ -119,21 +121,27 @@ public class DownloadManagerActivity extends BaseFragmentActivity implements
|
||||
|
||||
@Override
|
||||
public void onPageSelected(int position) {
|
||||
if (position == 0) {
|
||||
EventBus.getDefault().post(new EBUISwitch("DownloadManagerActivity", 0));
|
||||
if (position == 1) {
|
||||
EventBus.getDefault().post(new EBUISwitch("DownloadManagerActivity", 1));
|
||||
downloadmanager_tv_download.setTextColor(getResources().getColor(R.color.theme));
|
||||
downloadmanager_tv_update.setTextColor(getResources().getColor(R.color.title));
|
||||
} else {
|
||||
EventBus.getDefault().post(new EBUISwitch("DownloadManagerActivity", 1));
|
||||
downloadmanager_tv_send.setTextColor(getResources().getColor(R.color.title));
|
||||
} else if (position == 2){
|
||||
EventBus.getDefault().post(new EBUISwitch("DownloadManagerActivity", 2));
|
||||
downloadmanager_tv_download.setTextColor(getResources().getColor(R.color.title));
|
||||
downloadmanager_tv_update.setTextColor(getResources().getColor(R.color.theme));
|
||||
downloadmanager_tv_send.setTextColor(getResources().getColor(R.color.title));
|
||||
} else {
|
||||
downloadmanager_tv_download.setTextColor(getResources().getColor(R.color.title));
|
||||
downloadmanager_tv_update.setTextColor(getResources().getColor(R.color.title));
|
||||
downloadmanager_tv_send.setTextColor(getResources().getColor(R.color.theme));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||
if (positionOffset != 0) {
|
||||
lparams.leftMargin = (int) (width * (positionOffset + 0.25f));
|
||||
lparams.leftMargin = (int) (width * (position + positionOffset + 0.17f));
|
||||
downloadmanager_slide_line.setLayoutParams(lparams);
|
||||
}
|
||||
}
|
||||
@ -149,9 +157,11 @@ public class DownloadManagerActivity extends BaseFragmentActivity implements
|
||||
if (id == R.id.actionbar_rl_back) {
|
||||
finish();
|
||||
} else if (id == R.id.downloadmanager_ll_download) {
|
||||
downloadmanager_viewPager.setCurrentItem(0);
|
||||
} else if (id == R.id.downloadmanager_ll_update) {
|
||||
downloadmanager_viewPager.setCurrentItem(1);
|
||||
} else if (id == R.id.downloadmanager_ll_update) {
|
||||
downloadmanager_viewPager.setCurrentItem(2);
|
||||
} else if (id == R.id.downloadmanager_ll_send) {
|
||||
downloadmanager_viewPager.setCurrentItem(0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -198,7 +208,7 @@ public class DownloadManagerActivity extends BaseFragmentActivity implements
|
||||
|
||||
public void onEventMainThread(EBSkip skip) {
|
||||
if ("DownloadManagerActivity".equals(skip.getType())) {
|
||||
if (skip.getCurrentItem() == 0) {
|
||||
if (skip.getCurrentItem() == 1) {
|
||||
handler.postDelayed(runnable, 300);
|
||||
}
|
||||
}
|
||||
|
||||
634
app/src/main/java/com/gh/gamecenter/FileReceiverActivity.java
Normal file
634
app/src/main/java/com/gh/gamecenter/FileReceiverActivity.java
Normal file
@ -0,0 +1,634 @@
|
||||
package com.gh.gamecenter;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.os.Parcelable;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.facebook.drawee.view.SimpleDraweeView;
|
||||
import com.gh.base.AppController;
|
||||
import com.gh.base.BaseActivity;
|
||||
import com.gh.common.constant.Config;
|
||||
import com.gh.common.util.DialogUtils;
|
||||
import com.gh.common.util.NotificationUtils;
|
||||
import com.gh.common.util.PackageUtils;
|
||||
import com.gh.common.util.UserIconUtils;
|
||||
import com.gh.common.util.Utils;
|
||||
import com.gh.download.DownloadDao;
|
||||
import com.gh.download.DownloadEntity;
|
||||
import com.gh.download.DownloadStatus;
|
||||
import com.gh.gamecenter.adapter.FileReceiverAdapter;
|
||||
import com.gh.gamecenter.eventbus.EBDownloadChanged;
|
||||
import com.gh.gamecenter.eventbus.EBDownloadStatus;
|
||||
import com.gh.gamecenter.eventbus.EBPackage;
|
||||
import com.gh.gamecenter.kuaichuan.BaseTransfer;
|
||||
import com.gh.gamecenter.kuaichuan.Constant;
|
||||
import com.gh.gamecenter.kuaichuan.FileInfo;
|
||||
import com.gh.gamecenter.kuaichuan.FileReceiver;
|
||||
import com.gh.gamecenter.kuaichuan.HotspotManager;
|
||||
import com.gh.gamecenter.kuaichuan.IpPortInfo;
|
||||
import com.gh.gamecenter.kuaichuan.WifiMgr;
|
||||
import com.gh.gamecenter.manager.DataCollectionManager;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.DatagramPacket;
|
||||
import java.net.DatagramSocket;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.OnClick;
|
||||
import de.greenrobot.event.EventBus;
|
||||
|
||||
/**
|
||||
* Created by khy on 2017/1/20.
|
||||
*/
|
||||
public class FileReceiverActivity extends BaseActivity implements FileReceiverAdapter.OnReceiverCancelListener{
|
||||
|
||||
@BindView(R.id.sender_rv) RecyclerView mReceiverRv;
|
||||
@BindView(R.id.sender_user_icon) SimpleDraweeView mSenderUserIcon;
|
||||
@BindView(R.id.sender_user_name) TextView mSenderUserName;
|
||||
@BindView(R.id.sender_user_send_des) TextView mSenderUserDes;
|
||||
@BindView(R.id.sender_hint) TextView mSenderHint;
|
||||
@BindView(R.id.sender_bottom) LinearLayout mReceiverBottom;
|
||||
@BindView(R.id.sender_keep_send) RelativeLayout mKeepReceiver;
|
||||
@BindView(R.id.sender_keep_send_tv) TextView mKeepReceiverTv;
|
||||
@BindView(R.id.sender_bottom_hint) TextView mReceiverBottomHint;
|
||||
@BindView(R.id.sender_bottom_control) LinearLayout mReceiverControl;
|
||||
|
||||
private FileReceiverAdapter mFileReceiverAdapter;
|
||||
|
||||
private FileInfo mCurFileInfo;
|
||||
|
||||
private List<FileInfo> mFileInfos;
|
||||
|
||||
private List<Map<String, String>> sendData; // 传送成绩单数据
|
||||
|
||||
private IpPortInfo mIpPortInfo;
|
||||
|
||||
private ServerRunnable mReceiverServer;
|
||||
|
||||
private FileReceiver mFileReceiver;
|
||||
|
||||
private DatagramSocket mDatagramSocket;
|
||||
|
||||
private SharedPreferences sp;
|
||||
|
||||
private boolean isReceivesOver;
|
||||
private boolean isOpenWifi; //记录开热点前的WiFi状态
|
||||
private boolean isDestroy;
|
||||
|
||||
|
||||
Handler handler = new Handler() {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
super.handleMessage(msg);
|
||||
if (mFileInfos == null) {
|
||||
Utils.log("接收器出现异常");
|
||||
return;
|
||||
}
|
||||
|
||||
int index = getCurrentFileInfoIndex();
|
||||
if (index == -100) {
|
||||
Utils.toast(FileReceiverActivity.this, "接收失败");
|
||||
colsePage();
|
||||
return;
|
||||
}
|
||||
|
||||
if (index == -1) {
|
||||
// Utils.toast(FileReceiverActivity.this, " 获取刷新位置异常");
|
||||
return;
|
||||
}
|
||||
FileInfo fileInfo = mFileInfos.get(index);
|
||||
if (msg.what == FileInfo.FLAG_DEFAULT) { // 传输中更新界面
|
||||
long progress = (long) msg.obj;
|
||||
fileInfo.setProgress(progress);
|
||||
fileInfo.setResult(FileInfo.FLAG_DEFAULT);
|
||||
} else if (msg.what == FileInfo.FLAG_SUCCESS) { // 传输成功更新界面
|
||||
fileInfo.setResult(FileInfo.FLAG_SUCCESS);
|
||||
if (index == mFileInfos.size() -1) initSenderHint(false);
|
||||
} else if (msg.what == FileInfo.FLAG_FAILURE) { // 传输失败更新界面
|
||||
fileInfo.setResult(FileInfo.FLAG_FAILURE);
|
||||
if (index == mFileInfos.size() -1) initSenderHint(false);
|
||||
} else if (msg.what == FileInfo.FLAG_CANCEL) { // 传输取消更新界面
|
||||
fileInfo.setResult(FileInfo.FLAG_CANCEL);
|
||||
if (index == mFileInfos.size() -1) initSenderHint(false);
|
||||
} else if (msg.what == FileInfo.FLAG_NO_MEMORY) {
|
||||
Utils.toast(FileReceiverActivity.this, "手机空间不足");
|
||||
fileInfo.setResult(FileInfo.FLAG_NO_MEMORY); // 接收方内存不足
|
||||
if (index == mFileInfos.size() -1) initSenderHint(true);
|
||||
}
|
||||
|
||||
Utils.log("FileReceiverActivity:: 刷新位置::" + index + "刷新状态::" + msg.what);
|
||||
mFileReceiverAdapter.notifyItemChanged(index);
|
||||
}
|
||||
};
|
||||
|
||||
private int getCurrentFileInfoIndex() {
|
||||
for (int i = 0; i < mFileInfos.size(); i++) {
|
||||
FileInfo fileInfo = mFileInfos.get(i);
|
||||
if (mCurFileInfo == null) {
|
||||
return -100;
|
||||
}
|
||||
Utils.log("===============" + fileInfo.getFileTag() + "====" + mCurFileInfo.getFileTag());
|
||||
Utils.log("===============" + fileInfo.getName() + "====" + mCurFileInfo.getName());
|
||||
if (fileInfo.getFileTag().equals(mCurFileInfo.getFileTag())) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
Utils.log("FileReceiverActivity:: 获取刷新位置异常" + mFileInfos.size());
|
||||
mFileInfos.add(mCurFileInfo);
|
||||
|
||||
return mFileInfos.size() - 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
View contentView = View.inflate(this, R.layout.activity_file_sender, null);
|
||||
init(contentView, "接收游戏");
|
||||
|
||||
isDestroy = false;
|
||||
|
||||
// mFileInfos = (List<FileInfo>) AppController.get("FileInfo", false);
|
||||
|
||||
sendData = new ArrayList<>();
|
||||
|
||||
mIpPortInfo = (IpPortInfo) getIntent().getSerializableExtra(Constant.KEY_IP_PORT_INFO);
|
||||
isOpenWifi = getIntent().getBooleanExtra("isOpenWifi", false);
|
||||
ArrayList<Parcelable> list = getIntent().getParcelableArrayListExtra(Constant.KEY_IP_FILE_INFO);
|
||||
mFileInfos = (List<FileInfo>) list.get(0);
|
||||
|
||||
mFileReceiverAdapter = new FileReceiverAdapter(this, mFileInfos);
|
||||
mReceiverRv.setLayoutManager(new LinearLayoutManager(this));
|
||||
mReceiverRv.setAdapter(mFileReceiverAdapter);
|
||||
|
||||
|
||||
mKeepReceiverTv.setText("继续接收");
|
||||
|
||||
sp = getSharedPreferences(Config.PREFERENCE, Context.MODE_PRIVATE);
|
||||
|
||||
initUserData();
|
||||
|
||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 200);
|
||||
} else {
|
||||
initServer(); //启动接收服务
|
||||
}
|
||||
|
||||
findViewById(R.id.actionbar_rl_back).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
backHint();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initUserData() {
|
||||
isReceivesOver = false;
|
||||
|
||||
long allGameSize = 0;
|
||||
for (FileInfo mFileInfo : mFileInfos) {
|
||||
allGameSize = allGameSize + mFileInfo.getSize();
|
||||
}
|
||||
|
||||
double size = (((float)allGameSize/1024)/1024);
|
||||
DecimalFormat df = new DecimalFormat("#.00");
|
||||
String sizeName = df.format(size) + "MB";
|
||||
|
||||
mSenderUserDes.setText(mFileInfos.size() + "个游戏,共" + sizeName);
|
||||
mSenderUserName.setText("来自 " + mIpPortInfo.getSenderName());
|
||||
mSenderUserIcon.setImageURI(UserIconUtils.getUserIcon(mIpPortInfo.getSenderIcon()));
|
||||
|
||||
mReceiverBottom.setVisibility(View.GONE);
|
||||
|
||||
mSenderHint.setText("已连接");
|
||||
}
|
||||
|
||||
/**
|
||||
* 开启文件接收端服务
|
||||
*/
|
||||
private void initServer() {
|
||||
mReceiverServer = new ServerRunnable(Constant.DEFAULT_SERVER_PORT);
|
||||
new Thread(mReceiverServer).start();
|
||||
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
receiverData();
|
||||
} catch (Exception e) {
|
||||
Utils.log("FileReceiverActivity:: UDP请求异常" + e.toString() );
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
|
||||
}
|
||||
|
||||
private void receiverData() throws Exception {
|
||||
if (mDatagramSocket == null) {
|
||||
mDatagramSocket = new DatagramSocket(Constant.DEFAULT_SERVER_SENDING_PORT);
|
||||
mDatagramSocket.setBroadcast(true);
|
||||
}
|
||||
|
||||
byte[] receiveData = new byte[1024];
|
||||
|
||||
Utils.log("FileReceiverActivity:: 开始接收UDP请求::" + Constant.DEFAULT_SERVER_SENDING_PORT + "::" +mDatagramSocket.getInetAddress());
|
||||
while (!isDestroy) {
|
||||
Utils.log("FileReceiverActivity:: 开始接收UDP请求" );
|
||||
DatagramPacket receivePacket = new DatagramPacket(receiveData, receiveData.length);
|
||||
mDatagramSocket.receive(receivePacket);
|
||||
String response = new String(receivePacket.getData(), 0, receivePacket.getLength()).trim();
|
||||
Utils.log("FileReceiverActivity:: 接收UDP请求" + response);
|
||||
if (response != null && response.equals(Constant.MSG_ADD_DATA_OVER)) {
|
||||
handler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mFileReceiverAdapter.update();
|
||||
initUserData();
|
||||
}
|
||||
});
|
||||
|
||||
sendMessageToSender(Constant.MSG_ADD_DATA_OVER);
|
||||
Utils.log("FileReceiverActivity:: 回复信息" + Constant.MSG_ADD_DATA_OVER);
|
||||
} else if (response != null) {
|
||||
parseFileInfo(response);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析FileInfo
|
||||
* @param msg
|
||||
*/
|
||||
private void parseFileInfo(String msg) {
|
||||
// mFileInfos = (List<FileInfo>) AppController.get("FileInfo", false); // mFileInfos 数据异常 需要重新获取
|
||||
FileInfo fileInfo = FileInfo.toObject(msg);
|
||||
if(fileInfo != null && fileInfo.getFilePath() != null){
|
||||
mFileInfos.add(fileInfo);
|
||||
Utils.log("FileReceiverActivity 添加一条数据::" + msg);
|
||||
// AppController.put("FileInfo", mFileInfos);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void OnCancelPosition(final int position) {
|
||||
// if (position == getCurrentFileInfoIndex()) {
|
||||
// mFileReceiver.cancel();
|
||||
// } else {
|
||||
// Utils.toast(this, "在传送中的游戏才可以取消");
|
||||
// }
|
||||
|
||||
|
||||
Utils.log("接收方发送取消消息 让发送方取消");
|
||||
|
||||
|
||||
try {
|
||||
// 接收方更改界面
|
||||
FileInfo fileInfo = mFileInfos.get(position);
|
||||
fileInfo.setResult(FileInfo.FLAG_CANCEL);
|
||||
mFileReceiverAdapter.notifyItemChanged(position);
|
||||
|
||||
// 发消息让发送方取消
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("controlStatus", Constant.MSG_RECEIVER_CANCEL);
|
||||
jsonObject.put("controlTag", position);
|
||||
|
||||
sendMessageToSender(jsonObject.toString());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//安装事件
|
||||
public void onEventMainThread(EBPackage busFour) {
|
||||
if ("安装".equals(busFour.getType())) {
|
||||
for (int i = 0; i < mFileInfos.size(); i++) {
|
||||
FileInfo fileInfo = mFileInfos.get(i);
|
||||
if (fileInfo.getResult() == FileInfo.FLAG_SUCCESS &&
|
||||
fileInfo.getPackageName().equals(busFour.getPackageName())) {
|
||||
fileInfo.setResult(FileInfo.FLAG_INSTALLED);
|
||||
mFileReceiverAdapter.notifyItemChanged(i);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void sendMessageToSender(final String sendData) throws Exception {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
byte[] bytes = sendData.getBytes(BaseTransfer.UTF_8);
|
||||
DatagramPacket sendPacket = new DatagramPacket(bytes, bytes.length, mIpPortInfo.getInetAddress(), Constant.DEFAULT_SERVER_SENDING_PORT);
|
||||
mDatagramSocket.send(sendPacket);
|
||||
|
||||
Utils.log("接收方消息已发送至接收方:" + sendData + "==" + mIpPortInfo.getInetAddress() + "==" + Constant.DEFAULT_SERVER_SENDING_PORT);
|
||||
} catch (Exception e) {
|
||||
Utils.log("接收方发送消息异常。。" + e.toString());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
/**
|
||||
* ServerSocket启动线程
|
||||
*/
|
||||
class ServerRunnable implements Runnable {
|
||||
ServerSocket serverSocket;
|
||||
private int port;
|
||||
|
||||
|
||||
public ServerRunnable(int port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Utils.log("接收线程:Socket已经开启");
|
||||
try {
|
||||
serverSocket = new ServerSocket(Constant.DEFAULT_SERVER_PORT);
|
||||
|
||||
while (!Thread.currentThread().isInterrupted()){
|
||||
Socket socket = serverSocket.accept();
|
||||
|
||||
mFileReceiver = new FileReceiver(socket, FileReceiverActivity.this);
|
||||
mFileReceiver.setOnReceiveListener(new FileReceiver.OnReceiveListener() {
|
||||
private long mStartTime;
|
||||
private long mNormalStartTime;
|
||||
@Override
|
||||
public void onStart() {
|
||||
Utils.log("快传文件接收::onStart");
|
||||
mStartTime = Utils.getTime(FileReceiverActivity.this);
|
||||
mNormalStartTime = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGetFileInfo(FileInfo fileInfo) { // 获取FileInfo
|
||||
mCurFileInfo = fileInfo;
|
||||
for (int i = 0; i < mFileInfos.size(); i++) {
|
||||
FileInfo info = mFileInfos.get(i);
|
||||
if (info.getName(). //NullPointerException
|
||||
equals(mCurFileInfo.getName())) {
|
||||
info.setBitmap(fileInfo.getBitmap());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProgress(long progress, long total) { // 获取传输进度
|
||||
// Utils.log("快传文件接收中..." + progress + "==" + total);
|
||||
Message message = new Message();
|
||||
message.what = FileInfo.FLAG_DEFAULT;
|
||||
message.obj = progress;
|
||||
handler.sendMessage(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess() { // 获取传输成功
|
||||
handler.sendEmptyMessage(FileInfo.FLAG_SUCCESS);
|
||||
|
||||
String ghVersion = (String) PackageUtils.getMetaData(FileReceiverActivity.this
|
||||
, mCurFileInfo.getPackageName(), "gh_version");
|
||||
if (TextUtils.isEmpty(ghVersion)) {
|
||||
ghVersion = "";
|
||||
}
|
||||
|
||||
long sendTime = Utils.getTime(FileReceiverActivity.this) - mStartTime;
|
||||
|
||||
Map<String, Object> hashMap = new HashMap<>();
|
||||
hashMap.put("send_time", mStartTime);
|
||||
hashMap.put("receive_time", Utils.getTime(FileReceiverActivity.this));
|
||||
hashMap.put("game_name", mCurFileInfo.getName());
|
||||
hashMap.put("package_name", mCurFileInfo.getPackageName());
|
||||
hashMap.put("package_size", mCurFileInfo.getSize());
|
||||
hashMap.put("expend_time", sendTime);
|
||||
hashMap.put("send_nickname", mIpPortInfo.getSenderName());
|
||||
hashMap.put("receive_nickname", mIpPortInfo.getReceiverName());
|
||||
hashMap.put("receive_token", sp.getString("token", null));
|
||||
hashMap.put("package_gh_version", ghVersion);
|
||||
DataCollectionManager.onEvent(FileReceiverActivity.this, "transfer", hashMap, false);
|
||||
|
||||
|
||||
Utils.log("快传文件接收成功::onSuccess:: 发送事件::" + sendTime);
|
||||
|
||||
long sendNormalTime = System.currentTimeMillis() - mNormalStartTime;
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("sendTime", String.valueOf(sendNormalTime));
|
||||
map.put("apkPath",Environment.getExternalStorageDirectory() + "/GH-KC/" + mCurFileInfo.getName() + ".apk");
|
||||
map.put("apkSize", String.valueOf(mCurFileInfo.getSize()));
|
||||
sendData.add(map);
|
||||
|
||||
NotificationUtils.showKuaiChuanDoneNotification(FileReceiverActivity.this,
|
||||
Environment.getExternalStorageDirectory() + "/GH-KC/" + mCurFileInfo.getName() + ".apk",
|
||||
mCurFileInfo.getName(), mCurFileInfo.getPackageName());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable t) { // 获取传输失败
|
||||
Utils.log("快传文件接收失败::onFailure");
|
||||
handler.sendEmptyMessage(FileInfo.FLAG_FAILURE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel() { // 获取传输取消
|
||||
Utils.log("快传文件接收取消::onCancel");
|
||||
handler.sendEmptyMessage(FileInfo.FLAG_CANCEL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNoMemory() {
|
||||
handler.sendEmptyMessage(FileInfo.FLAG_NO_MEMORY);
|
||||
}
|
||||
});
|
||||
|
||||
AppController.MAIN_EXECUTOR.execute(mFileReceiver);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭Socket 通信
|
||||
*/
|
||||
public void close(){
|
||||
if(serverSocket != null){
|
||||
try {
|
||||
serverSocket.close();
|
||||
serverSocket = null;
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void initSenderHint(boolean isNoMemory) {
|
||||
for (FileInfo mFileInfo : mFileInfos) {
|
||||
if (mFileInfo.getResult() == 0 || mFileInfo.getResult() == 1) { // 还有没完成的任务
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
mReceiverBottom.setVisibility(View.VISIBLE);
|
||||
mReceiverControl.setVisibility(View.VISIBLE);
|
||||
|
||||
|
||||
isReceivesOver = true;
|
||||
int sendSuccess = 0;
|
||||
for (FileInfo mFileInfo : mFileInfos) {
|
||||
if (mFileInfo.getResult() == FileInfo.FLAG_SUCCESS) {
|
||||
sendSuccess ++;
|
||||
}
|
||||
}
|
||||
|
||||
if (isNoMemory) {
|
||||
mKeepReceiverTv.setText("手机空间清理");
|
||||
}
|
||||
|
||||
if (sendSuccess > 0) {
|
||||
mSenderHint.setVisibility(View.VISIBLE);
|
||||
mSenderHint.setText("传输结束,成功接收" + sendSuccess + "个游戏");
|
||||
} else {
|
||||
if (mFileInfos.get(mFileInfos.size() - 1).getResult() == FileInfo.FLAG_CANCEL) {
|
||||
mSenderHint.setVisibility(View.VISIBLE);
|
||||
mSenderHint.setText("传输已取消");
|
||||
} else if (mFileInfos.get(mFileInfos.size() - 1).getResult() == FileInfo.FLAG_FAILURE) {
|
||||
mSenderHint.setVisibility(View.VISIBLE);
|
||||
mSenderHint.setText("传输失败");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
backHint();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
isDestroy = true;
|
||||
}
|
||||
|
||||
@OnClick({R.id.actionbar_rl_back, R.id.sender_keep_send, R.id.sender_back})
|
||||
public void back(View view) {
|
||||
switch (view.getId()) {
|
||||
case R.id.actionbar_rl_back:
|
||||
backHint();
|
||||
break;
|
||||
case R.id.sender_back:
|
||||
backHint();
|
||||
break;
|
||||
case R.id.sender_keep_send:
|
||||
if ("继续接收".equals(mKeepReceiverTv.getText())) {
|
||||
// mReceiverControl.setVisibility(View.GONE);
|
||||
mKeepReceiverTv.setBackgroundResource(R.drawable.game_item_btn_pause_style);
|
||||
Utils.toast(FileReceiverActivity.this, "无需操作,请让对方继续发送即可");
|
||||
} else { // 跳转安装包清理
|
||||
Intent intent = new Intent(this, CleanApkActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void colsePage() {
|
||||
|
||||
if(mDatagramSocket != null) {
|
||||
// mDatagramSocket.disconnect();
|
||||
mDatagramSocket.close();
|
||||
mDatagramSocket = null;
|
||||
}
|
||||
|
||||
//关闭热点
|
||||
HotspotManager.initUserAp(this);
|
||||
|
||||
if (isOpenWifi) {
|
||||
WifiMgr.getInstance(this).openWifi();
|
||||
}
|
||||
|
||||
for (FileInfo fileInfo : mFileInfos) {
|
||||
if (fileInfo.getResult() == FileInfo.FLAG_SUCCESS) {
|
||||
DownloadEntity entry = new DownloadEntity();
|
||||
entry.setName(fileInfo.getName());
|
||||
entry.setSize(fileInfo.getSize());
|
||||
entry.setPackageName(fileInfo.getPackageName());
|
||||
entry.setPath(Environment.getExternalStorageDirectory() + "/GH-KC/" + fileInfo.getName() + ".apk");
|
||||
entry.setPercent(100.0);
|
||||
entry.setUrl(fileInfo.getFilePath()); //url拿 路径替代
|
||||
entry.setStatus(DownloadStatus.done);
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
try {
|
||||
jsonObject.put("KuaiChuanIcon", Environment.getExternalStorageDirectory() + "/GH-KC/" + fileInfo.getName() + ".apk");
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
entry.setIcon(jsonObject.toString());
|
||||
DownloadDao.getInstance(this).newOrUpdate(entry);
|
||||
}
|
||||
}
|
||||
List<DownloadEntity> all = DownloadDao.getInstance(this).getAll();
|
||||
EventBus.getDefault().post(new EBDownloadChanged("download", View.VISIBLE, all.size()));
|
||||
EventBus.getDefault().post(new EBDownloadStatus("download"));
|
||||
|
||||
mReceiverServer.close();
|
||||
// AppController.remove("FileInfo");
|
||||
mFileInfos.clear();
|
||||
|
||||
AppController.put("sendData", sendData);
|
||||
|
||||
finish();
|
||||
}
|
||||
|
||||
private void backHint() {
|
||||
if (isReceivesOver) {
|
||||
colsePage();
|
||||
} else {
|
||||
DialogUtils.showWarningDialog(FileReceiverActivity.this, "退出提示", "退出会中断接收,确定要退出吗?"
|
||||
, "取消", "确定"
|
||||
, new DialogUtils.ConfiremListener() {
|
||||
@Override
|
||||
public void onConfirem() {
|
||||
colsePage();
|
||||
}
|
||||
}, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
464
app/src/main/java/com/gh/gamecenter/FileSenderActivity.java
Normal file
464
app/src/main/java/com/gh/gamecenter/FileSenderActivity.java
Normal file
@ -0,0 +1,464 @@
|
||||
package com.gh.gamecenter;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.facebook.drawee.view.SimpleDraweeView;
|
||||
import com.gh.base.AppController;
|
||||
import com.gh.base.BaseActivity;
|
||||
import com.gh.common.util.DialogUtils;
|
||||
import com.gh.common.util.UserIconUtils;
|
||||
import com.gh.common.util.Utils;
|
||||
import com.gh.gamecenter.adapter.FileSenderAdapter;
|
||||
import com.gh.gamecenter.kuaichuan.Constant;
|
||||
import com.gh.gamecenter.kuaichuan.FileInfo;
|
||||
import com.gh.gamecenter.kuaichuan.FileSender;
|
||||
import com.gh.gamecenter.kuaichuan.WifiMgr;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.net.DatagramPacket;
|
||||
import java.net.DatagramSocket;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.OnClick;
|
||||
|
||||
/**
|
||||
* Created by khy on 2017/1/20.
|
||||
*/
|
||||
public class FileSenderActivity extends BaseActivity implements FileSenderAdapter.OnCancelListener {
|
||||
|
||||
@BindView(R.id.sender_rv) RecyclerView mSenderRv;
|
||||
@BindView(R.id.sender_user_icon) SimpleDraweeView mSenderUserIcon;
|
||||
@BindView(R.id.sender_user_name) TextView mSenderUserName;
|
||||
@BindView(R.id.sender_user_send_des) TextView mSenderUserDes;
|
||||
@BindView(R.id.sender_hint) TextView mSenderHint;
|
||||
@BindView(R.id.sender_keep_send) RelativeLayout mKeepSend;
|
||||
@BindView(R.id.sender_bottom) LinearLayout mSenderBottom;
|
||||
|
||||
private FileSenderAdapter mSenderAdapter;
|
||||
|
||||
private DatagramSocket mDatagramSocket;
|
||||
|
||||
private List<FileInfo> mFileInfos;
|
||||
private List<Map<String, String>> sendData; // 传送成绩单数据
|
||||
private List<FileSender> mFileSenderList;
|
||||
|
||||
private boolean isSendOver;
|
||||
private boolean isDestroy;
|
||||
|
||||
private long mStartTime;
|
||||
|
||||
private Handler handler = new Handler() {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
super.handleMessage(msg);
|
||||
if (msg.what == FileInfo.FLAG_DEFAULT) {
|
||||
int position = (int) msg.obj;
|
||||
mFileInfos.get(position).setResult(FileInfo.FLAG_DEFAULT);
|
||||
mSenderAdapter.notifyItemChanged(position);
|
||||
} else if (msg.what == FileInfo.FLAG_SUCCESS) {
|
||||
int position = (int) msg.obj;
|
||||
mFileInfos.get(position).setResult(FileInfo.FLAG_SUCCESS);
|
||||
mSenderAdapter.notifyItemChanged(position);
|
||||
if (position == mFileInfos.size() -1) initSenderHint();
|
||||
} else if (msg.what == FileInfo.FLAG_FAILURE) {
|
||||
int position = (int) msg.obj;
|
||||
mFileInfos.get(position).setResult(FileInfo.FLAG_FAILURE);
|
||||
mSenderAdapter.notifyItemChanged(position);
|
||||
if (position == mFileInfos.size() -1) initSenderHint();
|
||||
} else if (msg.what == FileInfo.FLAG_CANCEL) {
|
||||
int position = (int) msg.obj;
|
||||
mFileInfos.get(position).setResult(FileInfo.FLAG_CANCEL);
|
||||
mSenderAdapter.notifyItemChanged(position);
|
||||
if (position == mFileInfos.size() -1) initSenderHint();
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
View contentView = View.inflate(this, R.layout.activity_file_sender, null);
|
||||
init(contentView, "发送游戏");
|
||||
|
||||
mFileInfos = (List<FileInfo>) AppController.get("FileInfo", false);
|
||||
|
||||
isDestroy = false;
|
||||
|
||||
sendData = new ArrayList<>();
|
||||
mFileSenderList = new ArrayList<>();
|
||||
mSenderAdapter = new FileSenderAdapter(this, mFileInfos);
|
||||
mSenderRv.setLayoutManager(new LinearLayoutManager(this));
|
||||
mSenderRv.setAdapter(mSenderAdapter);
|
||||
|
||||
init();
|
||||
|
||||
findViewById(R.id.actionbar_rl_back).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
backHint();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (resultCode == 0x130 && requestCode == 0x178) {
|
||||
mSenderAdapter.notifyDataSetChanged();
|
||||
initUserData();
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
sendFileInfo();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
}
|
||||
|
||||
private void sendFileInfo() throws Exception {
|
||||
if (mDatagramSocket == null) {
|
||||
mDatagramSocket = new DatagramSocket(null);
|
||||
mDatagramSocket.setReuseAddress(true);
|
||||
mDatagramSocket.bind(new InetSocketAddress(Constant.DEFAULT_SERVER_SENDING_PORT));
|
||||
}
|
||||
String ipAddress = WifiMgr.getInstance(this).getIpAddressFromHotspot();
|
||||
InetAddress ipAddressName = InetAddress.getByName(ipAddress); // 转译
|
||||
//发送apk列表
|
||||
for (FileInfo fileInfo : mFileInfos) {
|
||||
if (fileInfo.getResult() == 0) { // 过滤已发送过的列表
|
||||
String fileInfoJson = FileInfo.toJsonStr(fileInfo);
|
||||
Utils.log("FileSenderActivity:: 发送的文件列表::" + fileInfoJson );
|
||||
DatagramPacket sendFileInfoListPacket = new DatagramPacket(fileInfoJson.getBytes()
|
||||
, fileInfoJson.getBytes().length, ipAddressName, Constant.DEFAULT_SERVER_SENDING_PORT);
|
||||
mDatagramSocket.send(sendFileInfoListPacket);
|
||||
Utils.log("FileSenderActivity:: 发送的文件列表完成::" + ipAddressName + "==" + Constant.DEFAULT_SERVER_SENDING_PORT);
|
||||
}
|
||||
}
|
||||
|
||||
DatagramPacket sendFileInfoListPacket = new DatagramPacket(Constant.MSG_ADD_DATA_OVER.getBytes()
|
||||
, Constant.MSG_ADD_DATA_OVER.getBytes().length, ipAddressName, Constant.DEFAULT_SERVER_SENDING_PORT);
|
||||
mDatagramSocket.send(sendFileInfoListPacket);
|
||||
Utils.log("FileSenderActivity:: 发送结束请求完成");
|
||||
}
|
||||
|
||||
|
||||
private void init() {
|
||||
|
||||
Utils.log("FileSenderActivity == init()");
|
||||
|
||||
initUserData();
|
||||
|
||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, Constant.REQUEST_CODE_WRITE_FILE);
|
||||
} else{
|
||||
Utils.log("FileSenderActivity == initSendServer()" + mFileInfos.size());
|
||||
try {
|
||||
initSendServer();//开启传送文件
|
||||
startReceiver();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void startReceiver() {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
initTestReceiverData();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
private void initTestReceiverData() throws Exception {
|
||||
if (mDatagramSocket == null) {
|
||||
mDatagramSocket = new DatagramSocket(null);
|
||||
mDatagramSocket.setReuseAddress(true);
|
||||
mDatagramSocket.bind(new InetSocketAddress(Constant.DEFAULT_SERVER_SENDING_PORT));
|
||||
}
|
||||
Utils.log("接收方取消Socket端口" + Constant.DEFAULT_SERVER_SENDING_PORT);
|
||||
byte[] receiveData = new byte[1024];
|
||||
// 主要接收 接收方取消操作
|
||||
while (!isDestroy) {
|
||||
DatagramPacket receivePacket = new DatagramPacket(receiveData, receiveData.length);
|
||||
mDatagramSocket.receive(receivePacket);
|
||||
String response = new String( receivePacket.getData(),0 , receivePacket.getLength()).trim();
|
||||
Utils.log("====接收取消消息中。。。" + response);
|
||||
if(response != null && response.contains(Constant.MSG_RECEIVER_CANCEL)){
|
||||
Utils.log("====接收取消消息完毕。。。" + response);
|
||||
|
||||
// 进入文件发送列表界面 (并且通知文件接收方进入文件接收列表界面)
|
||||
JSONObject jsonObject = new JSONObject(response);
|
||||
int cancelPosition = (int) jsonObject.get("controlTag");
|
||||
FileSender fileSender = mFileSenderList.get(cancelPosition);
|
||||
Message message = new Message();
|
||||
message.what = FileInfo.FLAG_CANCEL;
|
||||
message.obj = cancelPosition;
|
||||
handler.sendMessage(message);
|
||||
if (fileSender != null && fileSender.isRunning()) {
|
||||
Utils.log("接收方取消发送");
|
||||
fileSender.cancel();
|
||||
}
|
||||
} else if (response != null && response.contains(Constant.MSG_ADD_DATA_OVER)) {
|
||||
try {
|
||||
Utils.log("====收到UDP结束请求 开始传送文件");
|
||||
initSendServer();//开启传送文件
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//初始化用户数据
|
||||
private void initUserData() {
|
||||
isSendOver = false;
|
||||
|
||||
Map<String, String> map = (Map<String, String>) AppController.get("userMap", false);
|
||||
|
||||
long allGameSize = 0;
|
||||
for (FileInfo mFileInfo : mFileInfos) {
|
||||
allGameSize = allGameSize + mFileInfo.getSize();
|
||||
}
|
||||
|
||||
double size = (((float)allGameSize/1024)/1024);
|
||||
DecimalFormat df = new DecimalFormat("#.00");
|
||||
String sizeName = df.format(size) + "MB";
|
||||
|
||||
mSenderUserDes.setText(mFileInfos.size() + "个游戏,共" + sizeName);
|
||||
mSenderUserName.setText("发给 " + map.get("receiverName"));
|
||||
mSenderUserIcon.setImageURI(UserIconUtils.getUserIcon(Integer.parseInt(map.get("usericon"))));
|
||||
|
||||
mSenderBottom.setVisibility(View.GONE);
|
||||
|
||||
mSenderHint.setText("已连接");
|
||||
}
|
||||
|
||||
private void initSendServer() throws Exception {
|
||||
String serverIp = WifiMgr.getInstance(this).getIpAddressFromHotspot();
|
||||
|
||||
Utils.log("====FileSenderActivity传送个数::" + mFileInfos.size());
|
||||
|
||||
|
||||
// TODO: 发送的首个游戏 socket被拒绝的概率较大 延迟0.5秒发送试试
|
||||
Thread.sleep(500); //test
|
||||
|
||||
for (final FileInfo fileInfo : mFileInfos) {
|
||||
Utils.log("FileSenderActivity == initSendServer()===" + fileInfo.getName() + "==" + fileInfo.getResult());
|
||||
|
||||
if (fileInfo.getResult() != 0) continue; // result != 0 是已经传送过的apk
|
||||
|
||||
FileSender fileSender = new FileSender(this, fileInfo, serverIp, Constant.DEFAULT_SERVER_PORT);
|
||||
fileSender.setOnSendListener(new FileSender.OnSendListener() {
|
||||
@Override
|
||||
public void onStart() {
|
||||
mStartTime = System.currentTimeMillis();
|
||||
Utils.log("快传文件发送::onStart" + "==" + fileInfo.getName());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProgress(long progress, long total) {
|
||||
// Utils.log("快传文件发送中..." + progress + "==" + total + "==" + fileInfo.getName());
|
||||
fileInfo.setProgress(progress);
|
||||
Message message = new Message();
|
||||
message.what = FileInfo.FLAG_DEFAULT;
|
||||
message.obj = getCurrentFileInfoIndex(fileInfo);
|
||||
handler.sendMessage(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(FileInfo fileInfo) {
|
||||
Utils.log("快传文件发送成功::onSuccess" + "==" + fileInfo.getName());
|
||||
Message message = new Message();
|
||||
message.what = FileInfo.FLAG_SUCCESS;
|
||||
message.obj = getCurrentFileInfoIndex(fileInfo);
|
||||
handler.sendMessage(message);
|
||||
|
||||
long sendTime = System.currentTimeMillis() - mStartTime;
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("sendTime", String.valueOf(sendTime));
|
||||
map.put("apkPath", fileInfo.getFilePath());
|
||||
map.put("apkSize", String.valueOf(fileInfo.getSize()));
|
||||
sendData.add(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable t, FileInfo fileInfo) {
|
||||
Utils.log("快传文件发送失败::onFailure" + "==" + fileInfo.getName());
|
||||
Message message = new Message();
|
||||
message.what = FileInfo.FLAG_FAILURE;
|
||||
message.obj = getCurrentFileInfoIndex(fileInfo);
|
||||
handler.sendMessage(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel(FileInfo fileInfo) {
|
||||
Utils.log("快传文件用户主动取消::onCancel" + "==" + fileInfo.getName());
|
||||
Message message = new Message();
|
||||
message.what = FileInfo.FLAG_CANCEL;
|
||||
message.obj = getCurrentFileInfoIndex(fileInfo);
|
||||
handler.sendMessage(message);
|
||||
}
|
||||
|
||||
});
|
||||
mFileSenderList.add(fileSender);
|
||||
AppController.FILE_SENDER_EXECUTOR.execute(fileSender);
|
||||
}
|
||||
}
|
||||
|
||||
private int getCurrentFileInfoIndex(FileInfo curFileInfo) {
|
||||
for (int i = 0; i < mFileInfos.size(); i++) {
|
||||
FileInfo fileInfo = mFileInfos.get(i);
|
||||
if (curFileInfo == null) {
|
||||
return -100;
|
||||
}
|
||||
if (fileInfo.getFileTag().equals(curFileInfo.getFileTag())) {
|
||||
Utils.log("FileSenderActivity === index::" + i);
|
||||
return i;
|
||||
}
|
||||
}
|
||||
Utils.log("FileReceiverActivity:: 获取刷新位置异常");
|
||||
return -1;
|
||||
}
|
||||
|
||||
private void initSenderHint(){
|
||||
for (FileInfo mFileInfo : mFileInfos) {
|
||||
if (mFileInfo.getResult() == 0 || mFileInfo.getResult() == 1) { // 还有没完成的任务
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
mSenderBottom.setVisibility(View.VISIBLE);
|
||||
|
||||
int sendSuccess = 0;
|
||||
isSendOver = true;
|
||||
for (FileInfo mFileInfo : mFileInfos) {
|
||||
if (mFileInfo.getResult() == FileInfo.FLAG_SUCCESS) {
|
||||
sendSuccess ++;
|
||||
}
|
||||
}
|
||||
|
||||
if (sendSuccess > 0) {
|
||||
mSenderHint.setVisibility(View.VISIBLE);
|
||||
mSenderHint.setText("传输结束,成功分享" + sendSuccess + "个游戏");
|
||||
} else {
|
||||
if (mFileInfos.get(mFileInfos.size() - 1).getResult() == FileInfo.FLAG_CANCEL) {
|
||||
mSenderHint.setVisibility(View.VISIBLE);
|
||||
mSenderHint.setText("传输已取消");
|
||||
} else if (mFileInfos.get(mFileInfos.size() - 1).getResult() == FileInfo.FLAG_FAILURE) {
|
||||
mSenderHint.setVisibility(View.VISIBLE);
|
||||
mSenderHint.setText("传输失败");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void OnCancelPosition(int position) {
|
||||
FileSender fileSender = mFileSenderList.get(position);
|
||||
Utils.log("发送方准备取消发送" + position);
|
||||
if (fileSender != null && fileSender.isRunning()) {
|
||||
Utils.log("发送方取消发送");
|
||||
fileSender.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
backHint();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
isDestroy = true;
|
||||
}
|
||||
|
||||
@OnClick({R.id.actionbar_rl_back, R.id.sender_keep_send, R.id.sender_back})
|
||||
public void onClick(View view) {
|
||||
if (view.getId() == R.id.actionbar_rl_back || view.getId() == R.id.sender_back) {
|
||||
backHint();
|
||||
} else if (view.getId() == R.id.sender_keep_send) {
|
||||
Intent intent = new Intent(this, KcSelectGameActivity.class);
|
||||
intent.putExtra("isConn", true);
|
||||
startActivityForResult(intent, 0x178);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 停止所有的文件发送任务
|
||||
*/
|
||||
private void stopAllFileSendingTask(){
|
||||
for(FileSender fileSender : mFileSenderList){
|
||||
if(fileSender != null){
|
||||
fileSender.cancel();
|
||||
fileSender.finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void colsePage() {
|
||||
if(mDatagramSocket != null) {
|
||||
// mDatagramSocket.disconnect();
|
||||
mDatagramSocket.close();
|
||||
mDatagramSocket = null;
|
||||
}
|
||||
|
||||
stopAllFileSendingTask();
|
||||
AppController.remove("FileInfo");
|
||||
AppController.put("sendData", sendData);
|
||||
|
||||
FileSenderActivity.this.finish();
|
||||
}
|
||||
|
||||
private void backHint() {
|
||||
if(!isSendOver){
|
||||
DialogUtils.showWarningDialog(FileSenderActivity.this, "退出传送", "退出会中断所有游戏的传送,确定要退出吗?"
|
||||
, "取消", "确定"
|
||||
, new DialogUtils.ConfiremListener() {
|
||||
@Override
|
||||
public void onConfirem() {
|
||||
colsePage();
|
||||
|
||||
}
|
||||
}, null);
|
||||
} else {
|
||||
colsePage();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
174
app/src/main/java/com/gh/gamecenter/KcSelectGameActivity.java
Normal file
174
app/src/main/java/com/gh/gamecenter/KcSelectGameActivity.java
Normal file
@ -0,0 +1,174 @@
|
||||
package com.gh.gamecenter;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gh.base.AppController;
|
||||
import com.gh.base.BaseActivity;
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.Utils;
|
||||
import com.gh.gamecenter.adapter.KcSelectGameAdapter;
|
||||
import com.gh.gamecenter.kuaichuan.FileInfo;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.BindView;
|
||||
|
||||
/**
|
||||
* Created by khy on 2017/1/20.
|
||||
* 快传-选择游戏
|
||||
*/
|
||||
public class KcSelectGameActivity extends BaseActivity {
|
||||
|
||||
@BindView(R.id.select_game_rv) RecyclerView mSelectRv;
|
||||
@BindView(R.id.select_game_send) TextView mSelectSend;
|
||||
@BindView(R.id.select_game_all) CheckBox selectAll;
|
||||
@BindView(R.id.install_count) TextView installCount;
|
||||
@BindView(R.id.select_game_installed_ll) RelativeLayout installRl;
|
||||
@BindView(R.id.select_game_pb) ProgressBar mSelectPb;
|
||||
|
||||
private KcSelectGameAdapter mAdapter;
|
||||
|
||||
private boolean mIsConn;
|
||||
private LinearLayoutManager layoutManager;
|
||||
private RelativeLayout.LayoutParams rparams;
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode == 0x123) {
|
||||
if (data != null && data.getExtras()!= null && data.getExtras().getBoolean("isFinish")) {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
View contentView = View.inflate(this, R.layout.activity_kc_select_game, null);
|
||||
init(contentView, "选择游戏");
|
||||
|
||||
if (getIntent() != null && getIntent().getExtras() != null) {
|
||||
mIsConn = getIntent().getExtras().getBoolean("isConn");
|
||||
} else {
|
||||
mIsConn = false;
|
||||
}
|
||||
|
||||
selectAll.setVisibility(View.GONE);
|
||||
|
||||
mAdapter = new KcSelectGameAdapter(this, mSelectSend, installCount, installRl, mSelectPb);
|
||||
layoutManager = new LinearLayoutManager(this);
|
||||
mSelectRv.setLayoutManager(layoutManager);
|
||||
mSelectRv.setAdapter(mAdapter);
|
||||
|
||||
rparams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
DisplayUtils.dip2px(this, 40));
|
||||
|
||||
mSelectSend.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
List<FileInfo> selectData = mAdapter.getSelectData();
|
||||
if (selectData.size() == 0) {
|
||||
Utils.toast(KcSelectGameActivity.this, "请选择要发送的游戏");
|
||||
return;
|
||||
}
|
||||
|
||||
if (mIsConn) {
|
||||
List<FileInfo> oldInfo = (List<FileInfo>) AppController.get("FileInfo", false);
|
||||
for (FileInfo fileInfo : selectData) {
|
||||
oldInfo.add(fileInfo);
|
||||
}
|
||||
setResult(0x130);
|
||||
finish();
|
||||
} else {
|
||||
AppController.put("FileInfo", selectData);
|
||||
Intent intent = new Intent(KcSelectGameActivity.this, ChooseReceiverActivity.class);
|
||||
startActivityForResult(intent, 0x123);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
selectAll.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
HashMap<Integer, Boolean> selectPosition = new HashMap<>();
|
||||
int itemCount = mAdapter.getItemCount();
|
||||
if (isChecked) {
|
||||
for (int i = 0; i < itemCount; i++) {
|
||||
selectPosition.put(i, true);
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < itemCount; i++) {
|
||||
selectPosition.put(i, false);
|
||||
}
|
||||
}
|
||||
|
||||
mAdapter.setSelectPosition(selectPosition);
|
||||
mAdapter.notifyItemRangeChanged(0, itemCount);
|
||||
}
|
||||
});
|
||||
|
||||
mSelectRv.setOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
@Override
|
||||
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
|
||||
super.onScrolled(recyclerView, dx, dy);
|
||||
int position = layoutManager.findFirstVisibleItemPosition();
|
||||
int gameSize = mAdapter.getGameSize();
|
||||
|
||||
if (gameSize == 0) { // 游戏列表为空
|
||||
if (position == gameSize) {
|
||||
int buttom = layoutManager.findViewByPosition(position).getBottom();
|
||||
int i = installRl.getHeight() + DisplayUtils.dip2px(KcSelectGameActivity.this, 43);
|
||||
if (buttom <= i && i/2 < buttom) {
|
||||
rparams.topMargin = buttom - installRl.getHeight() - DisplayUtils.dip2px(KcSelectGameActivity.this, 43);
|
||||
installRl.setLayoutParams(rparams);
|
||||
installCount.setText("已安装的游戏(" + gameSize +")");
|
||||
} else {
|
||||
installCount.setText("已安装的应用(" + mAdapter.getAppSize() +")");
|
||||
rparams.topMargin = 0;
|
||||
installRl.setLayoutParams(rparams);
|
||||
}
|
||||
} else {
|
||||
installCount.setText("已安装的应用(" + mAdapter.getAppSize() +")");
|
||||
rparams.topMargin = 0;
|
||||
installRl.setLayoutParams(rparams);
|
||||
}
|
||||
} else {
|
||||
if (position >= gameSize) {
|
||||
installCount.setText("已安装的应用(" + mAdapter.getAppSize() +")");
|
||||
} else {
|
||||
installCount.setText("已安装的游戏(" + mAdapter.getGameSize() +")");
|
||||
}
|
||||
|
||||
if (position == gameSize - 1) {
|
||||
int buttom = layoutManager.findViewByPosition(position).getBottom();
|
||||
if (buttom <= installRl.getHeight()) {
|
||||
rparams.topMargin = buttom - installRl.getHeight();
|
||||
installRl.setLayoutParams(rparams);
|
||||
} else {
|
||||
rparams.topMargin = 0;
|
||||
installRl.setLayoutParams(rparams);
|
||||
}
|
||||
} else {
|
||||
rparams.topMargin = 0;
|
||||
installRl.setLayoutParams(rparams);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
@ -11,7 +11,9 @@ import android.widget.TextView;
|
||||
|
||||
import com.gh.base.BaseFragmentActivity;
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.view.NoScrollableViewPager;
|
||||
import com.gh.gamecenter.adapter.FragmentAdapter;
|
||||
import com.gh.gamecenter.eventbus.EBReuse;
|
||||
import com.gh.gamecenter.eventbus.EBUISwitch;
|
||||
import com.gh.gamecenter.libao.Libao1Fragment;
|
||||
import com.gh.gamecenter.libao.Libao2Fragment;
|
||||
@ -30,9 +32,11 @@ import de.greenrobot.event.EventBus;
|
||||
public class LibaoActivity extends BaseFragmentActivity implements View.OnClickListener,
|
||||
ViewPager.OnPageChangeListener {
|
||||
|
||||
@BindView(R.id.libao_vp_content) ViewPager mLibaoVp;
|
||||
@BindView(R.id.libao_vp_content) NoScrollableViewPager mLibaoVp;
|
||||
@BindView(R.id.libao_ll_top) LinearLayout mLibaoTopLl;
|
||||
@BindView(R.id.libao_slide_line) View mLibaoLine;
|
||||
@BindView(R.id.vp_tab) LinearLayout mTabLl;
|
||||
@BindView(R.id.libao_history_title) TextView mHistoryTitle;
|
||||
|
||||
private TextView mZuixinTv;
|
||||
private TextView mGuanzhuTv;
|
||||
@ -164,4 +168,20 @@ public class LibaoActivity extends BaseFragmentActivity implements View.OnClickL
|
||||
public void onPageScrollStateChanged(int state) {
|
||||
|
||||
}
|
||||
|
||||
// 页面切换事件(查看历史礼包的页面)
|
||||
public void onEventMainThread(EBReuse reuse) {
|
||||
if ("openPage".equals(reuse.getType())) { //TODO 设置新的TAB
|
||||
mLibaoTopLl.setVisibility(View.GONE);
|
||||
mLibaoLine.setVisibility(View.GONE);
|
||||
mHistoryTitle.setVisibility(View.VISIBLE);
|
||||
mHistoryTitle.setTextColor(getResources().getColor(R.color.hint));
|
||||
mLibaoVp.setScrollable(false);
|
||||
} else if ("closePage".equals(reuse.getType())) {
|
||||
mLibaoTopLl.setVisibility(View.VISIBLE);
|
||||
mLibaoLine.setVisibility(View.VISIBLE);
|
||||
mHistoryTitle.setVisibility(View.GONE);
|
||||
mLibaoVp.setScrollable(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -46,7 +46,7 @@ public class LibaoDetailActivity extends BaseDetailActivity {
|
||||
detail_rv_show.setLayoutManager(new LinearLayoutManager(this));
|
||||
detail_rv_show.setAdapter(mAdapter);
|
||||
|
||||
if (mLibaoEntity.getGame().getId() != null) {
|
||||
if (mLibaoEntity != null && mLibaoEntity.getGame() != null && mLibaoEntity.getGame().getId() != null) {
|
||||
title = mLibaoEntity.getName();
|
||||
getGameDigest();
|
||||
}
|
||||
|
||||
@ -71,7 +71,6 @@ import com.gh.gamecenter.retrofit.Response;
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -117,7 +116,6 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
|
||||
|
||||
private int currentTab;
|
||||
|
||||
private boolean isNewFirstLaunch;
|
||||
private boolean isSkipped;
|
||||
|
||||
private Handler handler = new Handler();
|
||||
@ -145,7 +143,7 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
|
||||
if (DownloadStatus.done.equals(downloadEntity.getStatus())) {
|
||||
if (downloadEntity.getName().contains("光环助手")) {
|
||||
DataUtils.onEvent(MainActivity.this, "软件更新", "下载完成");
|
||||
startActivity(PackageUtils.getInstallIntent(downloadEntity.getPath()));
|
||||
startActivity(PackageUtils.getInstallIntent(MainActivity.this, downloadEntity.getPath()));
|
||||
DataLogUtils.uploadUpgradeLog(MainActivity.this, "install"); //上传更新安装数据
|
||||
} else {
|
||||
statDoneEvent(downloadEntity);
|
||||
@ -172,7 +170,7 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
|
||||
DownloadManager.getInstance(MainActivity.this).cancel(downloadEntity.getUrl());
|
||||
} else {
|
||||
if (PackageUtils.isCanLaunchSetup(getApplicationContext(), downloadEntity.getPath())) {
|
||||
startActivity(PackageUtils.getInstallIntent(downloadEntity.getPath()));
|
||||
startActivity(PackageUtils.getInstallIntent(MainActivity.this, downloadEntity.getPath()));
|
||||
} else {
|
||||
// 弹出卸载提示框
|
||||
EventBus.getDefault().post(new EBShowDialog("plugin", downloadEntity.getPath()));
|
||||
@ -227,25 +225,6 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
|
||||
}
|
||||
|
||||
DataCollectionUtils.uploadDownload(this, downloadEntity, "完成");
|
||||
|
||||
if (downloadEntity.getEntrance().matches("^" + "\\(游戏\\-插件:滚动图\\[.+\\]\\)" + "$")
|
||||
|| downloadEntity.getEntrance().matches("^" + "\\(游戏\\-专题:滚动图\\[.+\\]\\)" + "$")) {
|
||||
// 首页轮播图数据统计
|
||||
statLunbotuData(downloadEntity.getEntrance());
|
||||
}
|
||||
}
|
||||
|
||||
// 首页轮播图数据统计
|
||||
private void statLunbotuData(String entrance) {
|
||||
int start = entrance.indexOf("[");
|
||||
int end = entrance.indexOf("]");
|
||||
if (start != -1 && end != -1) {
|
||||
entrance = entrance.substring(start + 1, end);
|
||||
String[] values = entrance.split("=");
|
||||
if (values.length == 3) {
|
||||
DataLogUtils.uploadLunbotuLog(this, values[1], values[0], values[2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void processHijack(DownloadEntity downloadEntity) {
|
||||
@ -346,7 +325,7 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
|
||||
setContentView(contentView);
|
||||
|
||||
sp = getSharedPreferences(Config.PREFERENCE, Context.MODE_PRIVATE);
|
||||
isNewFirstLaunch = sp.getBoolean("isNewFirstLaunchV" + PackageUtils.getVersionName(getApplicationContext()), true);
|
||||
boolean isNewFirstLaunch = sp.getBoolean("isNewFirstLaunchV" + PackageUtils.getVersionName(getApplicationContext()), true);
|
||||
|
||||
isSkipped = false;
|
||||
|
||||
@ -365,16 +344,13 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
|
||||
|
||||
if (!isNewFirstLaunch && sp.getBoolean("autoupdate", true)) {
|
||||
// 检查助手更新
|
||||
UpdateManager.getInstance(this).checkUpdate(true);
|
||||
UpdateManager.getInstance(this).checkUpdate(true, null);
|
||||
}
|
||||
if (isNewFirstLaunch) {
|
||||
getPluginUpdate();
|
||||
sp.edit().putBoolean("isNewFirstLaunchV" + PackageUtils.getVersionName(getApplicationContext()), false).apply();
|
||||
}
|
||||
|
||||
// 获取免责声明
|
||||
getDisclaimer(isNewFirstLaunch);
|
||||
|
||||
// 初始化PlatformUtils
|
||||
PlatformUtils.getInstance(getApplicationContext());
|
||||
|
||||
@ -390,23 +366,35 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
|
||||
public void run() {
|
||||
// 注册设备
|
||||
TokenUtils.register(MainActivity.this);
|
||||
TokenUtils.getToken(MainActivity.this, false);
|
||||
TokenUtils.checkDeviceInfo(MainActivity.this);
|
||||
TokenUtils.getToken(MainActivity.this, false)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Response<String>() {
|
||||
@Override
|
||||
public void onResponse(String token) {
|
||||
TokenUtils.checkDeviceInfo(MainActivity.this, token);
|
||||
}
|
||||
});
|
||||
updateUserGhzs();
|
||||
initConcern(); // 初始化关注
|
||||
LibaoUtils.getCunHaoXiang(MainActivity.this, true);
|
||||
}
|
||||
}.start();
|
||||
} else {
|
||||
updateUserGhzs();
|
||||
}
|
||||
|
||||
// 更新用户使用的助手信息
|
||||
updateUserGhzs();
|
||||
|
||||
// 执行跳转事件
|
||||
handler.postDelayed(skipRun, 500);
|
||||
|
||||
Log.e("TD_CHANNEL_ID", (String) PackageUtils.getMetaData(this, getPackageName(), "TD_CHANNEL_ID"));
|
||||
|
||||
if (sp.getBoolean("changeDefaultIcon", false) && sp.getInt("default_user_icon", 0) != 0) {
|
||||
postDefaultIcon(true, sp.getInt("default_user_icon", 0));
|
||||
}
|
||||
}
|
||||
|
||||
// 更新用户使用的助手信息
|
||||
private void updateUserGhzs() {
|
||||
String version_code = sp.getString("version_code", null);
|
||||
String version_name = sp.getString("version_name", null);
|
||||
@ -574,15 +562,24 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
|
||||
|
||||
PackageManager.init(list);
|
||||
|
||||
final CountDownLatch latch = ObservableUtil.latch(list.size(), new Action1<Object>() {
|
||||
// 过滤助手收录的包
|
||||
ArrayList<String> localList = new ArrayList<>();
|
||||
FilterManager filterManager = new FilterManager(this);
|
||||
for (int i = 0, size = list.size(); i < size; i++) {
|
||||
if (filterManager.isFilter(list.get(i))) {
|
||||
localList.add(list.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
final CountDownLatch latch = ObservableUtil.latch(localList.size(), new Action1<Object>() {
|
||||
@Override
|
||||
public void call(Object o) {
|
||||
updateConcern();
|
||||
}
|
||||
});
|
||||
|
||||
for (int i = 0, size = list.size(); i < size; i++) {
|
||||
final String packageName = list.get(i);
|
||||
for (int i = 0, size = localList.size(); i < size; i++) {
|
||||
final String packageName = localList.get(i);
|
||||
RetrofitManager.getApi().getGameDigestByPackageName(packageName)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
@ -848,33 +845,6 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
|
||||
}
|
||||
}
|
||||
|
||||
// 获取免责声明
|
||||
private void getDisclaimer(final boolean isFirst) {
|
||||
RetrofitManager.getApi().getDisclaimer()
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new JSONObjectResponse() {
|
||||
@Override
|
||||
public void onResponse(JSONObject response) {
|
||||
if (response.length() != 0) {
|
||||
try {
|
||||
boolean isShow = response.getBoolean("isShow");
|
||||
sp.edit().putBoolean("isShowDisclaimer", isShow).apply();
|
||||
if (isShow) {
|
||||
String content = response.getString("content");
|
||||
sp.edit().putString("disclaimer", content).apply();
|
||||
if (isFirst) {
|
||||
DialogUtils.showDisclaimerDialog(MainActivity.this, content);
|
||||
}
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Runnable skipRun = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -1127,17 +1097,17 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
|
||||
DataUtils.onEvent(this, "插件化", mDownloadEntity.getName(), kv6);
|
||||
}
|
||||
|
||||
if (!mDownloadEntity.isPlugin() // 不是插件游戏,自己删除数据库数据和安装包
|
||||
|| PackageUtils.isSignature(this, packageName)) {// 是插件游戏,判断签名是否相同,是才删除数据库数据和安装包
|
||||
// if (!mDownloadEntity.isPlugin() // 不是插件游戏,自己删除数据库数据和安装包
|
||||
// || PackageUtils.isSignature(this, packageName)) {// 是插件游戏,判断签名是否相同,是才删除数据库数据和安装包
|
||||
DownloadManager.getInstance(getApplicationContext()).cancel(
|
||||
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);
|
||||
|
||||
startActivity(PackageUtils.getInstallIntent(mDownloadEntity.getPath()));
|
||||
startActivity(PackageUtils.getInstallIntent(this, mDownloadEntity.getPath()));
|
||||
}
|
||||
}
|
||||
if ("安装".equals(busFour.getType())) {
|
||||
@ -1148,7 +1118,7 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
|
||||
}
|
||||
} else if ("卸载".equals(busFour.getType())) {
|
||||
FilterManager filterManager = new FilterManager(getApplicationContext());
|
||||
if (!filterManager.isFilter(packageName)) {
|
||||
if (filterManager.isFilter(packageName)) {
|
||||
concernManager.updateByPackageName(packageName);
|
||||
}
|
||||
}
|
||||
@ -1249,6 +1219,46 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
DownloadManager.getInstance(this).removeObserver(dataWatcher);
|
||||
|
||||
if (sp.getBoolean("changeDefaultIcon", false) && sp.getInt("default_user_icon", 0) != 0) {
|
||||
postDefaultIcon(true, sp.getInt("default_user_icon", 0));
|
||||
}
|
||||
}
|
||||
|
||||
// 提交默认头像
|
||||
private void postDefaultIcon(boolean isCheck, final int i) {
|
||||
TokenUtils.getToken(this, isCheck)
|
||||
.flatMap(new Func1<String, Observable<ResponseBody>>() {
|
||||
@Override
|
||||
public Observable<ResponseBody> call(String token) {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("icon_key" , "icon" + i);
|
||||
RequestBody body = RequestBody.create(MediaType.parse("application/json"),
|
||||
new JSONObject(params).toString());
|
||||
return RetrofitManager.getUser().postDefaultIcon(token, body);
|
||||
}
|
||||
})
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new JSONObjectResponse(){
|
||||
@Override
|
||||
public void onResponse(JSONObject response) {
|
||||
super.onResponse(response);
|
||||
sp.edit().putBoolean("changeDefaultIcon", false);
|
||||
}
|
||||
@Override
|
||||
public void onFailure(HttpException e) {
|
||||
super.onFailure(e);
|
||||
if (e != null) {
|
||||
if (e.code() == 401) {
|
||||
postDefaultIcon(true, i);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -5,6 +5,7 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Rect;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
@ -27,6 +28,7 @@ import com.gh.base.AppController;
|
||||
import com.gh.base.BaseActivity;
|
||||
import com.gh.common.constant.Config;
|
||||
import com.gh.common.util.DialogUtils;
|
||||
import com.gh.common.util.ImageUtils;
|
||||
import com.gh.common.util.PostCommentUtils;
|
||||
import com.gh.common.util.TimestampUtils;
|
||||
import com.gh.common.util.TokenUtils;
|
||||
@ -55,7 +57,6 @@ import butterknife.OnClick;
|
||||
import butterknife.OnTouch;
|
||||
import retrofit2.adapter.rxjava.HttpException;
|
||||
import rx.android.schedulers.AndroidSchedulers;
|
||||
import rx.functions.Action1;
|
||||
import rx.schedulers.Schedulers;
|
||||
|
||||
/**
|
||||
@ -152,13 +153,12 @@ public class MessageDetailActivity extends BaseActivity implements MessageDetail
|
||||
MessageDetailActivity.this.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (sp.getString("user_icon", "res:///"+
|
||||
R.drawable.user_default_icon_comment).isEmpty()) {
|
||||
mMessageDetailIconDv.setImageURI("res:///" +
|
||||
R.drawable.user_default_icon_comment);
|
||||
String icon = sp.getString("user_icon", null);
|
||||
if (TextUtils.isEmpty(icon)) {
|
||||
mMessageDetailIconDv.setImageURI(
|
||||
Uri.parse("res:///" + R.drawable.user_default_icon_comment));
|
||||
} else {
|
||||
mMessageDetailIconDv.setImageURI(sp.getString("user_icon", "res:///"+
|
||||
R.drawable.user_default_icon_comment));
|
||||
ImageUtils.display(mMessageDetailIconDv, icon);
|
||||
}
|
||||
mMessageDetailUserNameTv.setText(sp.getString("user_name", "光环用户"));
|
||||
}
|
||||
@ -166,11 +166,12 @@ public class MessageDetailActivity extends BaseActivity implements MessageDetail
|
||||
}
|
||||
}).start();
|
||||
} else {
|
||||
if (sp.getString("user_icon", "res:///"+ R.drawable.user_default_icon_comment).isEmpty()) {
|
||||
mMessageDetailIconDv.setImageURI("res:///" + R.drawable.user_default_icon_comment);
|
||||
String icon = sp.getString("user_icon", null);
|
||||
if (TextUtils.isEmpty(icon)) {
|
||||
mMessageDetailIconDv.setImageURI(
|
||||
Uri.parse("res:///" + R.drawable.user_default_icon_comment));
|
||||
} else {
|
||||
mMessageDetailIconDv.setImageURI(sp.getString("user_icon", "res:///"+
|
||||
R.drawable.user_default_icon_comment));
|
||||
ImageUtils.display(mMessageDetailIconDv, icon);
|
||||
}
|
||||
mMessageDetailUserNameTv.setText(sp.getString("user_name", "光环用户"));
|
||||
}
|
||||
@ -209,8 +210,8 @@ public class MessageDetailActivity extends BaseActivity implements MessageDetail
|
||||
.subscribe(new com.gh.gamecenter.retrofit.Response<List<CommentnumEntity>>(){
|
||||
|
||||
@Override
|
||||
public void onNext(List<CommentnumEntity> response) {
|
||||
super.onNext(response);
|
||||
public void onResponse(List<CommentnumEntity> response) {
|
||||
super.onResponse(response);
|
||||
if (response.size() > 0) {
|
||||
if (!TextUtils.isEmpty(mConcernEntity.getId())){
|
||||
commentNum = response.get(0).getNum();
|
||||
@ -258,9 +259,9 @@ public class MessageDetailActivity extends BaseActivity implements MessageDetail
|
||||
.getNewsViews(newsId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Action1<List<ViewsEntity>>() {
|
||||
.subscribe(new Response<List<ViewsEntity>>(){
|
||||
@Override
|
||||
public void call(List<ViewsEntity> viewsEntities) {
|
||||
public void onResponse(List<ViewsEntity> viewsEntities) {
|
||||
if (viewsEntities.size() > 0) {
|
||||
mConcernEntity.setViews(viewsEntities.get(0).getViews());
|
||||
adapter.notifyItemChanged(0);
|
||||
|
||||
@ -423,6 +423,7 @@ public class NewsDetailActivity extends BaseActivity implements OnClickListener
|
||||
String str = detail_tv_per.getText().toString();
|
||||
if ("下载中".equals(str)) {
|
||||
Intent intent = new Intent(this, DownloadManagerActivity.class);
|
||||
intent.putExtra("currentItem", 1);
|
||||
intent.putExtra("url", gameEntity.getApk().get(0).getUrl());
|
||||
intent.putExtra("entrance", entrance + "(新闻详情[" + adapter.getTitle() + "])");
|
||||
startActivity(intent);
|
||||
|
||||
@ -6,6 +6,7 @@ import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.text.Html;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@ -205,6 +206,10 @@ public class NewsSearchActivity extends BaseActivity {
|
||||
isRemove = true;
|
||||
searchAdapter.notifyItemChanged(searchAdapter.getItemCount() - 1);
|
||||
}
|
||||
|
||||
if (response.size() < 20) {
|
||||
isRemove = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -261,7 +266,7 @@ public class NewsSearchActivity extends BaseActivity {
|
||||
public void onBindViewHolder(final RecyclerView.ViewHolder holder, int position) {
|
||||
if (holder instanceof ViewHolder){
|
||||
ViewHolder viewHolder = (ViewHolder) holder;
|
||||
viewHolder.tvTitle.setText(newsEntities.get(position).getTitle());
|
||||
viewHolder.tvTitle.setText(Html.fromHtml(newsEntities.get(position).getTitle()));
|
||||
viewHolder.linearLayout.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
406
app/src/main/java/com/gh/gamecenter/ReceiverWaitingActivity.java
Normal file
406
app/src/main/java/com/gh/gamecenter/ReceiverWaitingActivity.java
Normal file
@ -0,0 +1,406 @@
|
||||
package com.gh.gamecenter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.text.Html;
|
||||
import android.text.TextUtils;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.facebook.drawee.view.SimpleDraweeView;
|
||||
import com.gh.base.AppController;
|
||||
import com.gh.base.BaseActivity;
|
||||
import com.gh.common.constant.Config;
|
||||
import com.gh.common.util.DialogUtils;
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.RandomUtils;
|
||||
import com.gh.common.util.UserIconUtils;
|
||||
import com.gh.common.util.Utils;
|
||||
import com.gh.common.view.RadarLayout;
|
||||
import com.gh.gamecenter.kuaichuan.BaseTransfer;
|
||||
import com.gh.gamecenter.kuaichuan.Constant;
|
||||
import com.gh.gamecenter.kuaichuan.FileInfo;
|
||||
import com.gh.gamecenter.kuaichuan.HotspotManager;
|
||||
import com.gh.gamecenter.kuaichuan.IpPortInfo;
|
||||
import com.gh.gamecenter.kuaichuan.WifiMgr;
|
||||
import com.gh.gamecenter.manager.SystemBarTintManager;
|
||||
import com.gh.gamecenter.receiver.WifiAPBroadcastReceiver;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.net.DatagramPacket;
|
||||
import java.net.DatagramSocket;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.BindView;
|
||||
|
||||
/**
|
||||
* Created by khy on 2017/1/20.
|
||||
*/
|
||||
public class ReceiverWaitingActivity extends BaseActivity {
|
||||
|
||||
@BindView(R.id.waiting_user_icon) SimpleDraweeView mUserIcon;
|
||||
@BindView(R.id.waiting_user_name) TextView mUserName;
|
||||
@BindView(R.id.waiting_user_status) TextView mUserStatus;
|
||||
@BindView(R.id.waiting_conn) TextView mWaitingConn;
|
||||
@BindView(R.id.waiting_radar_layout) RadarLayout mRadarLayout;
|
||||
@BindView(R.id.waiting_hint) TextView mWaitingHint;
|
||||
@BindView(R.id.reuse_actionbar) RelativeLayout mActionbar;
|
||||
@BindView(R.id.waiting_gprs_hint) TextView mGPRSHint;
|
||||
@BindView(R.id.waiting_no_conn_hint) TextView mNoConnHint;
|
||||
|
||||
|
||||
private WifiAPBroadcastReceiver mWifiAPBroadcastReceiver;
|
||||
|
||||
private List<FileInfo> mFileInfos; // 接收到的文件列表
|
||||
|
||||
private SharedPreferences sp;
|
||||
|
||||
private boolean mIsInitialized;
|
||||
private boolean isOpenWifi; //记录开热点前的WiFi状态
|
||||
private boolean isDestroy;
|
||||
|
||||
private String mySsid;
|
||||
|
||||
/**
|
||||
* 与 文件发送方 通信的 线程
|
||||
*/
|
||||
Runnable mUdpServerRuannable;
|
||||
|
||||
Handler mHandler = new Handler(){
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
if(msg.what == 0){
|
||||
if (mFileInfos.size() == 0) {
|
||||
Utils.toast(ReceiverWaitingActivity.this, "接收异常::ReceiverWaitingActivity");
|
||||
return;
|
||||
}
|
||||
ArrayList list = new ArrayList();
|
||||
list.add(mFileInfos);
|
||||
IpPortInfo ipPortInfo = (IpPortInfo) msg.obj;
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putSerializable(Constant.KEY_IP_PORT_INFO, ipPortInfo);
|
||||
bundle.putSerializable(Constant.KEY_IP_FILE_INFO, (Serializable) mFileInfos);
|
||||
bundle.putParcelableArrayList(Constant.KEY_IP_FILE_INFO, list);
|
||||
bundle.putBoolean("isOpenWifi", isOpenWifi);
|
||||
|
||||
Intent intent = new Intent(ReceiverWaitingActivity.this, FileReceiverActivity.class);
|
||||
intent.putExtras(bundle);
|
||||
startActivity(intent);
|
||||
|
||||
colsePage();
|
||||
} else if (msg.what == 1) {
|
||||
mNoConnHint.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
View contentView = View.inflate(this, R.layout.activity_receiver_waiting, null);
|
||||
init(contentView, "接收游戏");
|
||||
|
||||
// 添加分享图标
|
||||
TextView hintTv = new TextView(this);
|
||||
hintTv.setText("操作说明");
|
||||
hintTv.setTextColor(Color.WHITE);
|
||||
hintTv.setGravity(Gravity.CENTER);
|
||||
hintTv.setPadding(DisplayUtils.dip2px(this, 13),0 ,DisplayUtils.dip2px(this, 13),0);
|
||||
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT );
|
||||
RelativeLayout reuse_actionbar = (RelativeLayout) contentView.findViewById(
|
||||
R.id.reuse_actionbar);
|
||||
reuse_actionbar.addView(hintTv, params);
|
||||
|
||||
//修改沉浸栏以及ActionBar 颜色
|
||||
mActionbar.setBackgroundColor(getResources().getColor(R.color.scan_bg));
|
||||
SystemBarTintManager tintManager = getTintManager();
|
||||
if (tintManager != null) {
|
||||
tintManager.setStatusBarTintResource(R.color.scan_bg);
|
||||
}
|
||||
|
||||
sp = getSharedPreferences(Config.PREFERENCE, Context.MODE_PRIVATE);
|
||||
mIsInitialized = false;
|
||||
isDestroy = false;
|
||||
isOpenWifi = WifiMgr.getInstance(this).isWifiEnable();
|
||||
|
||||
mUserName.setText(sp.getString("user_name", "光环用户"));
|
||||
|
||||
if (isOpenWifi) {
|
||||
WifiMgr.getInstance(this).closeWifi();
|
||||
}
|
||||
|
||||
mUserStatus.setText("正在初始化...");
|
||||
mRadarLayout.setUseRing(true);
|
||||
mRadarLayout.setColor(Color.WHITE);
|
||||
mRadarLayout.setCount(4);
|
||||
mRadarLayout.start();
|
||||
|
||||
|
||||
mFileInfos = new ArrayList<>();
|
||||
|
||||
HotspotManager.initApData(this); // 记录原始热点信息
|
||||
|
||||
//初始化热点
|
||||
if(HotspotManager.isApOn(this)){
|
||||
HotspotManager.disableAp(this);
|
||||
}
|
||||
|
||||
mWifiAPBroadcastReceiver = new WifiAPBroadcastReceiver() {
|
||||
@Override
|
||||
public void onWifiApEnabled() {
|
||||
if(!mIsInitialized) {
|
||||
mUdpServerRuannable = createSendMsgToFileSenderRunnable();
|
||||
AppController.MAIN_EXECUTOR.execute(mUdpServerRuannable);
|
||||
mIsInitialized = true;
|
||||
|
||||
mWaitingConn.setVisibility(View.VISIBLE);
|
||||
mUserStatus.setText(Html.fromHtml("成功创建热点:" + "<font color=\"#fff500\">" + mySsid + "</font>"));
|
||||
mWaitingHint.setVisibility(View.GONE);
|
||||
mUserName.setVisibility(View.GONE);
|
||||
mGPRSHint.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
IntentFilter filter = new IntentFilter(WifiAPBroadcastReceiver.ACTION_WIFI_AP_STATE_CHANGED);
|
||||
registerReceiver(mWifiAPBroadcastReceiver, filter);
|
||||
|
||||
HotspotManager.isApOn(this);
|
||||
|
||||
mySsid = sp.getString("hotspotName", null);
|
||||
if (TextUtils.isEmpty(mySsid)) {
|
||||
String chars = "abcdefghijklmnopqrstuvwxyz";
|
||||
int[] randomArray = RandomUtils.getRandomArray(2, 25);
|
||||
|
||||
mySsid = "ghZS-";
|
||||
for (int i : randomArray) {
|
||||
mySsid = mySsid + chars.charAt(i);
|
||||
}
|
||||
|
||||
int default_user_icon = sp.getInt("default_user_icon", 0);
|
||||
if (default_user_icon == 0) {
|
||||
default_user_icon = RandomUtils.nextInt(8) + 1;
|
||||
sp.edit().putInt("default_user_icon", default_user_icon).apply();
|
||||
}
|
||||
|
||||
mySsid = mySsid + default_user_icon;
|
||||
sp.edit().putString("hotspotName", mySsid).apply();
|
||||
}
|
||||
mUserIcon.setImageURI(UserIconUtils.getUserIcon(sp.getInt("default_user_icon", 1)));
|
||||
|
||||
HotspotManager.configApState(this, mySsid); // change Ap state :boolean
|
||||
|
||||
findViewById(R.id.actionbar_rl_back).setOnClickListener(
|
||||
new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
colsePage();
|
||||
//关闭热点
|
||||
HotspotManager.initUserAp(ReceiverWaitingActivity.this);
|
||||
|
||||
if (isOpenWifi) {
|
||||
WifiMgr.getInstance(ReceiverWaitingActivity.this).openWifi();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mHandler.sendEmptyMessageDelayed(1, 300000);
|
||||
|
||||
hintTv.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
showConnHintDialog();
|
||||
}
|
||||
});
|
||||
|
||||
boolean showConnHintReceiver = sp.getBoolean("showConnHintReceiver", true);
|
||||
|
||||
if (showConnHintReceiver) {
|
||||
showConnHintDialog();
|
||||
sp.edit().putBoolean("showConnHintReceiver", false).apply();
|
||||
}
|
||||
}
|
||||
|
||||
private void showConnHintDialog() {
|
||||
DialogUtils.showHintDialog(ReceiverWaitingActivity.this, "请告诉你的好友这样操作:", "1.请好友拿出手机,打开光环助手 " +
|
||||
"\n2.点击首页左上角“↓”按钮 \n3.点击“我要发送”", "确定");
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建发送UDP消息到 文件发送方 的服务线程
|
||||
*/
|
||||
private Runnable createSendMsgToFileSenderRunnable(){
|
||||
return new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
startFileReceiverServer(Constant.DEFAULT_SERVER_COM_PORT);
|
||||
} catch (Exception e) {
|
||||
Utils.log("发送UDP消息到 文件发送方 异常" + e.toString());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 开启 文件接收方 通信服务 (必须在子线程执行)
|
||||
* @param serverPort
|
||||
* @throws Exception
|
||||
*/
|
||||
DatagramSocket mDatagramSocket;
|
||||
private void startFileReceiverServer(int serverPort) throws Exception{
|
||||
//网络连接上,无法获取IP的问题
|
||||
int count = 0;
|
||||
String localAddress = WifiMgr.getInstance(ReceiverWaitingActivity.this).getHotspotLocalIpAddress();
|
||||
Utils.log("开启 文件接收方 通信服务 " + localAddress);
|
||||
|
||||
//ip地址无效 重新获取
|
||||
while(localAddress.equals(Constant.DEFAULT_UNKOWN_IP) && count < Constant.DEFAULT_TRY_TIME){
|
||||
Thread.sleep(1000);
|
||||
localAddress = WifiMgr.getInstance(ReceiverWaitingActivity.this).getHotspotLocalIpAddress();
|
||||
count ++;
|
||||
}
|
||||
|
||||
if (mDatagramSocket == null) {
|
||||
mDatagramSocket = new DatagramSocket(null);
|
||||
mDatagramSocket.setReuseAddress(true);
|
||||
mDatagramSocket.bind(new InetSocketAddress(serverPort));
|
||||
}
|
||||
|
||||
byte[] receiveData = new byte[1024];
|
||||
byte[] sendData;
|
||||
Utils.log("接收接受信息 ");
|
||||
while (!isDestroy) {
|
||||
//接收 文件发送方的消息
|
||||
DatagramPacket receivePacket = new DatagramPacket(receiveData, receiveData.length);
|
||||
mDatagramSocket.receive(receivePacket);
|
||||
String msg = new String( receivePacket.getData(), 0, receivePacket.getLength()).trim();
|
||||
InetAddress inetAddress = receivePacket.getAddress();
|
||||
|
||||
int port = receivePacket.getPort();
|
||||
Utils.log("接收信息中。。。" + msg );
|
||||
if(msg != null && msg.contains(Constant.MSG_FILE_RECEIVER_INIT)) {
|
||||
Utils.log("接收方初始化完毕准备进去传输页面 并回馈消息给发送者" + inetAddress);
|
||||
|
||||
// AppController.put("FileInfo", mFileInfos); //保存数据列表 启用改为Intent传输
|
||||
|
||||
// 反馈 文件发送方的消息
|
||||
// sendData = Constant.MSG_FILE_RECEIVER_INIT_SUCCESS.getBytes(BaseTransfer.UTF_8);
|
||||
JSONObject receiverData = new JSONObject();
|
||||
receiverData.put(Constant.MSG_FILE_RECEIVER_INIT_SUCCESS, sp.getString("user_name", "光环用户"));
|
||||
sendData = receiverData.toString().getBytes(BaseTransfer.UTF_8);
|
||||
|
||||
DatagramPacket sendPacket = new DatagramPacket(sendData, sendData.length, inetAddress, port);
|
||||
mDatagramSocket.send(sendPacket);
|
||||
|
||||
Message message = new Message();
|
||||
message.what = 0;
|
||||
JSONObject jsonObject = new JSONObject(msg);
|
||||
message.obj = new IpPortInfo(inetAddress, port, jsonObject.getString(Constant.MSG_FILE_RECEIVER_INIT),
|
||||
sp.getString("user_name", "光环用户"),jsonObject.getInt("UserIcon"));
|
||||
mHandler.sendMessage(message);
|
||||
|
||||
} else {
|
||||
if(msg != null){
|
||||
Utils.log("保存文件列表数据" + msg);
|
||||
parseFileInfo(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析FileInfo
|
||||
* @param msg
|
||||
*/
|
||||
private void parseFileInfo(String msg) {
|
||||
FileInfo fileInfo = FileInfo.toObject(msg);
|
||||
if(fileInfo != null && fileInfo.getFilePath() != null){
|
||||
mFileInfos.add(fileInfo);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭UDP Socket 流
|
||||
*/
|
||||
private void closeSocket(){
|
||||
if(mDatagramSocket != null){
|
||||
// mDatagramSocket.disconnect();
|
||||
mDatagramSocket.close();
|
||||
mDatagramSocket = null;
|
||||
}
|
||||
}
|
||||
|
||||
// @OnClick(R.id.actionbar_rl_back)
|
||||
// public void onBackListener() {
|
||||
// Utils.log("=========back");
|
||||
// colsePage();
|
||||
// //关闭热点
|
||||
// HotspotManager.disableAp(this);
|
||||
//
|
||||
// if (isOpenWifi) {
|
||||
// WifiMgr.getInstance(this).openWifi();
|
||||
// }
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
super.onBackPressed();
|
||||
colsePage();
|
||||
|
||||
//关闭热点
|
||||
HotspotManager.initUserAp(ReceiverWaitingActivity.this);
|
||||
|
||||
if (isOpenWifi) {
|
||||
WifiMgr.getInstance(this).openWifi();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭广播并关闭Socket流
|
||||
*/
|
||||
private void colsePage() {
|
||||
mRadarLayout.stop();
|
||||
|
||||
mHandler.removeMessages(1); // 取消无人连接消息
|
||||
|
||||
try {
|
||||
if(mWifiAPBroadcastReceiver != null){
|
||||
unregisterReceiver(mWifiAPBroadcastReceiver);
|
||||
mWifiAPBroadcastReceiver = null;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Utils.log("接收方d等待连接异常-关闭广播");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
closeSocket();
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
isDestroy = true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
165
app/src/main/java/com/gh/gamecenter/SelectUserIconActivity.java
Normal file
165
app/src/main/java/com/gh/gamecenter/SelectUserIconActivity.java
Normal file
@ -0,0 +1,165 @@
|
||||
package com.gh.gamecenter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.provider.MediaStore;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gh.base.BaseActivity;
|
||||
import com.gh.common.constant.Config;
|
||||
import com.gh.common.util.RandomUtils;
|
||||
import com.gh.common.util.UserIconUtils;
|
||||
import com.gh.common.util.Utils;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.OnClick;
|
||||
|
||||
/**
|
||||
* Created by khy on 2017/2/10.
|
||||
*/
|
||||
public class SelectUserIconActivity extends BaseActivity {
|
||||
|
||||
@BindView(R.id.skip_media_store) TextView mSkipMediaStore;
|
||||
|
||||
private SharedPreferences sp;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
View contentView = View.inflate(this, R.layout.activity_select_user_icon, null);
|
||||
init(contentView, "选择头像");
|
||||
|
||||
sp = getSharedPreferences(Config.PREFERENCE, Context.MODE_PRIVATE);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (data != null && requestCode == 0x123) {
|
||||
Uri selectedImage = data.getData();
|
||||
if (selectedImage == null) {
|
||||
return;
|
||||
}
|
||||
String[] filePathColumn = { MediaStore.Images.Media.DATA };
|
||||
|
||||
Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null);
|
||||
if (cursor == null) {
|
||||
return;
|
||||
}
|
||||
cursor.moveToFirst();
|
||||
|
||||
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
|
||||
String picturePath = cursor.getString(columnIndex);
|
||||
cursor.close();
|
||||
|
||||
Utils.log("picturePath = " + picturePath);
|
||||
// 上传头像
|
||||
Intent intent = new Intent(this, CropImageActivity.class);
|
||||
intent.putExtra("path", picturePath);
|
||||
intent.putExtra("entrance", "(我的光环)");
|
||||
startActivityForResult(intent, 0x124);
|
||||
} else if (data != null && requestCode == 0x124) {
|
||||
String url = data.getExtras().getString("url");
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra("url", url);
|
||||
setResult(0x125, intent);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
@OnClick({R.id.user_default_icon_1, R.id.user_default_icon_2, R.id.user_default_icon_3 ,R.id.user_default_icon_4,
|
||||
R.id.user_default_icon_5, R.id.user_default_icon_6, R.id.user_default_icon_7, R.id.user_default_icon_8, R.id.skip_media_store})
|
||||
public void onClick(View view){
|
||||
switch (view.getId()) {
|
||||
case R.id.user_default_icon_1:
|
||||
postUserIocn(1);
|
||||
break;
|
||||
case R.id.user_default_icon_2:
|
||||
postUserIocn(2);
|
||||
break;
|
||||
case R.id.user_default_icon_3:
|
||||
postUserIocn(3);
|
||||
break;
|
||||
case R.id.user_default_icon_4:
|
||||
postUserIocn(4);
|
||||
break;
|
||||
case R.id.user_default_icon_5:
|
||||
postUserIocn(5);
|
||||
break;
|
||||
case R.id.user_default_icon_6:
|
||||
postUserIocn(6);
|
||||
break;
|
||||
case R.id.user_default_icon_7:
|
||||
postUserIocn(7);
|
||||
break;
|
||||
case R.id.user_default_icon_8:
|
||||
postUserIocn(8);
|
||||
break;
|
||||
case R.id.skip_media_store:
|
||||
|
||||
String iconCount = sp.getString("updateIconCount", null);
|
||||
if (!TextUtils.isEmpty(iconCount)) {
|
||||
long l = System.currentTimeMillis();
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
|
||||
String time = format.format(new Date(l));
|
||||
|
||||
JSONObject json = null;
|
||||
try {
|
||||
json = new JSONObject(iconCount);
|
||||
String lastTime = json.getString("time");
|
||||
if (lastTime.equals(time) && json.getInt("count") == 2) {
|
||||
Utils.toast(SelectUserIconActivity.this, "每天最多只能上传2次头像");
|
||||
return;
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
|
||||
startActivityForResult(intent, 0x123);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void postUserIocn(int i) {
|
||||
postDefaultIcon(i);
|
||||
}
|
||||
|
||||
public void postDefaultIcon(final int i) {
|
||||
String iconUrl = UserIconUtils.getUserIconUrl(i);
|
||||
|
||||
//初始化热点名称
|
||||
String chars = "abcdefghijklmnopqrstuvwxyz";
|
||||
int[] randomArray = RandomUtils.getRandomArray(2, 25);
|
||||
|
||||
String mySsid = "ghZS-";
|
||||
for (int j : randomArray) {
|
||||
mySsid = mySsid + chars.charAt(j);
|
||||
}
|
||||
mySsid = mySsid + i;
|
||||
sp.edit().putString("hotspotName", mySsid).apply();
|
||||
|
||||
sp.edit().putInt("default_user_icon", i).apply();
|
||||
|
||||
sp.edit().putBoolean("changeDefaultIcon", true).apply();
|
||||
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra("url", iconUrl);
|
||||
setResult(0x125, intent);
|
||||
finish();
|
||||
}
|
||||
|
||||
}
|
||||
@ -8,7 +8,6 @@ import android.content.SharedPreferences;
|
||||
import android.content.SharedPreferences.Editor;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.Window;
|
||||
@ -21,10 +20,8 @@ import com.gh.base.BaseActivity;
|
||||
import com.gh.common.constant.Config;
|
||||
import com.gh.common.util.DialogUtils;
|
||||
import com.gh.common.util.FileUtils;
|
||||
import com.gh.common.util.PackageUtils;
|
||||
import com.gh.gamecenter.eventbus.EBReuse;
|
||||
import com.gh.gamecenter.eventbus.EBSkip;
|
||||
import com.gh.gamecenter.manager.UpdateManager;
|
||||
import com.kyleduo.switchbutton.SwitchButton;
|
||||
|
||||
import java.io.File;
|
||||
@ -43,9 +40,7 @@ public class SettingActivity extends BaseActivity implements OnClickListener {
|
||||
@BindView(R.id.setting_sb_autoinstall) SwitchButton setting_sb_autoinstall;
|
||||
@BindView(R.id.setting_sb_autodelete) SwitchButton setting_sb_autodelete;
|
||||
@BindView(R.id.setting_sb_deletedata) SwitchButton setting_sb_deletedata;
|
||||
@BindView(R.id.setting_sb_autoupdate) SwitchButton setting_sb_autoupdate;
|
||||
@BindView(R.id.setting_sb_concerngame) SwitchButton setting_sb_concerngame;
|
||||
@BindView(R.id.setting_tv_version) TextView setting_tv_version;
|
||||
@BindView(R.id.setting_tv_cache) TextView setting_tv_cache;
|
||||
@BindView(R.id.setting_tv_size) TextView setting_tv_size;
|
||||
|
||||
@ -76,14 +71,11 @@ public class SettingActivity extends BaseActivity implements OnClickListener {
|
||||
findViewById(R.id.setting_rl_autoinstall).setOnClickListener(this);
|
||||
findViewById(R.id.setting_rl_autodelete).setOnClickListener(this);
|
||||
findViewById(R.id.setting_rl_deletedata).setOnClickListener(this);
|
||||
findViewById(R.id.setting_rl_autoupdate).setOnClickListener(this);
|
||||
findViewById(R.id.setting_rl_update).setOnClickListener(this);
|
||||
findViewById(R.id.setting_rl_feedback).setOnClickListener(this);
|
||||
findViewById(R.id.setting_rl_cache).setOnClickListener(this);
|
||||
findViewById(R.id.setting_cv_font_size).setOnClickListener(this);
|
||||
findViewById(R.id.setting_rl_concerngame).setOnClickListener(this);
|
||||
|
||||
setting_tv_version.setText(String.format("当前版本:V%s", PackageUtils.getVersionName(getApplicationContext())));
|
||||
findViewById(R.id.setting_rl_about).setOnClickListener(this);
|
||||
|
||||
setting_tv_cache.setText(getCacheSize());
|
||||
|
||||
@ -98,16 +90,8 @@ public class SettingActivity extends BaseActivity implements OnClickListener {
|
||||
setting_sb_autoinstall.setChecked(sp.getBoolean("autoinstall", true));
|
||||
setting_sb_autodelete.setChecked(sp.getBoolean("autodelete", true));
|
||||
setting_sb_deletedata.setChecked(sp.getBoolean("deletedata", true));
|
||||
setting_sb_autoupdate.setChecked(sp.getBoolean("autoupdate", true));
|
||||
setting_sb_concerngame.setChecked(sp.getBoolean("concerngame", true));
|
||||
|
||||
if (sp.getBoolean("isShowDisclaimer", false)) {
|
||||
TextView setting_tv_disclaimer = (TextView) findViewById(R.id.setting_tv_disclaimer);
|
||||
findViewById(R.id.setting_disclaimer_line).setVisibility(View.VISIBLE);
|
||||
setting_tv_disclaimer.setVisibility(View.VISIBLE);
|
||||
setting_tv_disclaimer.setOnClickListener(this);
|
||||
}
|
||||
|
||||
checkSizeIndex = sp.getInt("fontsize", 1);
|
||||
if (checkSizeIndex == 0){
|
||||
checkSizeIndex = 1;
|
||||
@ -155,7 +139,6 @@ public class SettingActivity extends BaseActivity implements OnClickListener {
|
||||
mEditor.putBoolean("autoinstall", setting_sb_autoinstall.isChecked());
|
||||
mEditor.putBoolean("autodelete", setting_sb_autodelete.isChecked());
|
||||
mEditor.putBoolean("deletedata", setting_sb_deletedata.isChecked());
|
||||
mEditor.putBoolean("autoupdate", setting_sb_autoupdate.isChecked());
|
||||
mEditor.putBoolean("concerngame", setting_sb_concerngame.isChecked());
|
||||
mEditor.putInt("fontsize",checkSizeIndex);
|
||||
mEditor.apply();
|
||||
@ -196,12 +179,6 @@ public class SettingActivity extends BaseActivity implements OnClickListener {
|
||||
case R.id.setting_rl_deletedata:
|
||||
setting_sb_deletedata.performClick();
|
||||
break;
|
||||
case R.id.setting_rl_autoupdate:
|
||||
setting_sb_autoupdate.performClick();
|
||||
break;
|
||||
case R.id.setting_rl_update:
|
||||
UpdateManager.getInstance(this).checkUpdate(false);
|
||||
break;
|
||||
case R.id.setting_rl_cache:
|
||||
DialogUtils.showWarningDialog(this, "清除缓存", "清空缓存后未安装的游戏可能需要重新下载,确定清空?",
|
||||
new DialogUtils.ConfiremListener() {
|
||||
@ -217,15 +194,13 @@ public class SettingActivity extends BaseActivity implements OnClickListener {
|
||||
intent.putExtra("entrance", "(设置)");
|
||||
startActivity(intent);
|
||||
break;
|
||||
case R.id.setting_tv_disclaimer:
|
||||
String content = sp.getString("disclaimer", null);
|
||||
if (!TextUtils.isEmpty(content)) {
|
||||
DialogUtils.showDisclaimerDialog(this, content);
|
||||
}
|
||||
break;
|
||||
case R.id.setting_cv_font_size:
|
||||
fontSize();
|
||||
break;
|
||||
case R.id.setting_rl_about:
|
||||
Intent intentAbout = new Intent(this, AboutActivity.class);
|
||||
startActivity(intentAbout);
|
||||
break;
|
||||
case R.id.setting_rl_concerngame:
|
||||
setting_sb_concerngame.performClick();
|
||||
default:
|
||||
|
||||
@ -15,6 +15,7 @@ import android.widget.TextView;
|
||||
|
||||
import com.facebook.drawee.view.SimpleDraweeView;
|
||||
import com.gh.base.BaseActivity;
|
||||
import com.gh.common.util.ImageUtils;
|
||||
import com.gh.common.util.MessageShareUtils;
|
||||
import com.gh.common.util.QRCodeUtils;
|
||||
import com.gh.gamecenter.manager.SystemBarTintManager;
|
||||
@ -80,7 +81,8 @@ public class ShareCardActivity extends BaseActivity {
|
||||
|
||||
mShareGameNameTv.setText(gameName);
|
||||
mShareContentTv.setText(Html.fromHtml(shareContent));
|
||||
mShareGameIconDv.setImageURI(gameIconUrl);
|
||||
// mShareGameIconDv.setImageURI(gameIconUrl);
|
||||
ImageUtils.display(mShareGameIconDv, gameIconUrl);
|
||||
mShareQrCodeDv.setImageResource(R.drawable.test_qrcode);
|
||||
|
||||
// 延迟操作,等待截图部分绘制完成
|
||||
@ -91,7 +93,7 @@ public class ShareCardActivity extends BaseActivity {
|
||||
mShareScreenshotLl.buildDrawingCache();
|
||||
Bitmap drawingCache = mShareScreenshotLl.getDrawingCache();
|
||||
saveBitmap(drawingCache);
|
||||
MessageShareUtils.getInstance(ShareCardActivity.this).showShareWindows(mShareBottomLl, drawingCache, picName, false);
|
||||
MessageShareUtils.getInstance(ShareCardActivity.this).showShareWindows(mShareBottomLl, drawingCache, picName, 0);
|
||||
}
|
||||
}, 200);
|
||||
|
||||
|
||||
@ -23,6 +23,7 @@ import com.facebook.drawee.interfaces.DraweeController;
|
||||
import com.facebook.drawee.view.SimpleDraweeView;
|
||||
import com.facebook.imagepipeline.image.ImageInfo;
|
||||
import com.gh.base.BaseActivity;
|
||||
import com.gh.common.util.ImageUtils;
|
||||
import com.gh.common.util.MessageShareUtils;
|
||||
import com.gh.common.util.QRCodeUtils;
|
||||
import com.gh.gamecenter.manager.SystemBarTintManager;
|
||||
@ -128,7 +129,8 @@ public class ShareCardPicActivity extends BaseActivity {
|
||||
|
||||
mShareGameNameTv.setText(gameName);
|
||||
mShareContentTv.setText(Html.fromHtml(shareContent));
|
||||
mShareGameIconDv.setImageURI(gameIconUrl);
|
||||
// mShareGameIconDv.setImageURI(gameIconUrl);
|
||||
ImageUtils.display(mShareGameIconDv, gameIconUrl);
|
||||
mShareQrCodeDv.setImageResource(R.drawable.test_qrcode);
|
||||
|
||||
if (shareArrImg.size() > 1) {
|
||||
@ -223,7 +225,7 @@ public class ShareCardPicActivity extends BaseActivity {
|
||||
|
||||
shareBm = getBitmapByView(mShareScreenshotRl);
|
||||
saveBitmap(shareBm);
|
||||
MessageShareUtils.getInstance(ShareCardPicActivity.this).showShareWindows(new View(ShareCardPicActivity.this), shareBm, picName, true);
|
||||
MessageShareUtils.getInstance(ShareCardPicActivity.this).showShareWindows(new View(ShareCardPicActivity.this), shareBm, picName, 1);
|
||||
}
|
||||
|
||||
@OnClick(R.id.sharecard_chang_img)
|
||||
|
||||
82
app/src/main/java/com/gh/gamecenter/ShareGhActivity.java
Normal file
82
app/src/main/java/com/gh/gamecenter/ShareGhActivity.java
Normal file
@ -0,0 +1,82 @@
|
||||
package com.gh.gamecenter;
|
||||
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.os.Bundle;
|
||||
import android.text.Html;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gh.base.BaseActivity;
|
||||
import com.gh.common.util.QRCodeUtils;
|
||||
import com.gh.common.util.ShareUtils;
|
||||
import com.gh.common.util.Utils;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
|
||||
/**
|
||||
* Created by khy on 2017/2/6.
|
||||
*/
|
||||
public class ShareGhActivity extends BaseActivity {
|
||||
|
||||
@BindView(R.id.gh_address_qrcode) ImageView mGhQrcode;
|
||||
@BindView(R.id.gh_address_tv) TextView mGhAddress;
|
||||
@BindView(R.id.wifi_share_btn) Button mWifiShareBtn;
|
||||
@BindView(R.id.content_ll) LinearLayout mContentLl;
|
||||
@BindView(R.id.share_rl) RelativeLayout mShareRl;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
View contentView = View.inflate(this, R.layout.activity_share_gh, null);
|
||||
init(contentView, "分享光环");
|
||||
ButterKnife.bind(this);
|
||||
|
||||
mGhAddress.setText(Html.fromHtml("<u>"+"www.ghzhushou.com"+"</u>"));
|
||||
createQrCode();
|
||||
ShareUtils.getInstance(this).showShareWindows(mShareRl, "http://www.ghzhushou.com/link?source=appshare300", "光环助手"
|
||||
, "http://image.ghzhushou.com/pic/57d604808ab49e467d8b4568.png", null, false, false);
|
||||
}
|
||||
|
||||
@OnClick(R.id.wifi_share_btn)
|
||||
public void skipWifiShare() {
|
||||
Intent intent = new Intent(this, ShareGhWfifActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@OnClick(R.id.gh_address_tv)
|
||||
public void copyAddress() {
|
||||
ClipboardManager cmb = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
cmb.setText("http://www.ghzhushou.com/link?source=appshare100");
|
||||
|
||||
Utils.toast(this, "网址复制成功,请到微信/QQ粘贴分享");
|
||||
}
|
||||
|
||||
|
||||
private void createQrCode() {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final String filePath = getExternalCacheDir().getPath() + "/ShareImg/ShareQRCode.jpg";
|
||||
boolean success = QRCodeUtils.createQRImage("http://www.ghzhushou.com/link?source=appshare100"
|
||||
, 200, 200, filePath, ShareGhActivity.this);
|
||||
if (success) {
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mGhQrcode.setImageBitmap(BitmapFactory.decodeFile(filePath));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
}
|
||||
348
app/src/main/java/com/gh/gamecenter/ShareGhWfifActivity.java
Normal file
348
app/src/main/java/com/gh/gamecenter/ShareGhWfifActivity.java
Normal file
@ -0,0 +1,348 @@
|
||||
package com.gh.gamecenter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.text.Html;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gh.base.AppController;
|
||||
import com.gh.base.BaseActivity;
|
||||
import com.gh.common.constant.Config;
|
||||
import com.gh.common.util.DialogUtils;
|
||||
import com.gh.common.util.RandomUtils;
|
||||
import com.gh.common.util.Utils;
|
||||
import com.gh.gamecenter.entity.KcWebRequestEntity;
|
||||
import com.gh.gamecenter.kuaichuan.Constant;
|
||||
import com.gh.gamecenter.kuaichuan.DownloadUriHandler;
|
||||
import com.gh.gamecenter.kuaichuan.HotspotManager;
|
||||
import com.gh.gamecenter.kuaichuan.HtmlUriHandler;
|
||||
import com.gh.gamecenter.kuaichuan.ImageUriHandler;
|
||||
import com.gh.gamecenter.kuaichuan.KcUriHandler;
|
||||
import com.gh.gamecenter.kuaichuan.WifiMgr;
|
||||
import com.gh.gamecenter.receiver.WifiAPBroadcastReceiver;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
|
||||
/**
|
||||
* Created by khy on 2017/2/6.
|
||||
*/
|
||||
public class ShareGhWfifActivity extends BaseActivity {
|
||||
|
||||
// @BindView(R.id.hotspot_name) TextView mHotSpotName;
|
||||
@BindView(R.id.init_hotpost_pb) ProgressBar mInitHotspostPb;
|
||||
@BindView(R.id.init_status_icon) ImageView mInitStatusIcon;
|
||||
@BindView(R.id.init_status_tv) TextView mInitStatusTv;
|
||||
@BindView(R.id.init_hotpost_hint) TextView mInitHotpostHint;
|
||||
@BindView(R.id.init_success_ll) LinearLayout mInitSuccessLl;
|
||||
@BindView(R.id.init_conn_hint) TextView initConnHint;
|
||||
|
||||
private ServerSocket mServerSocket;
|
||||
|
||||
private WifiAPBroadcastReceiver mWifiAPBroadcastReceiver;
|
||||
|
||||
private boolean mIsInitialized = false;
|
||||
|
||||
private List<KcUriHandler> mUriHandlers;
|
||||
|
||||
private SharedPreferences sp;
|
||||
|
||||
private boolean isColseActivity;
|
||||
|
||||
private boolean isOpenWifi; //记录开热点前的WiFi状态
|
||||
|
||||
private boolean initSuccess;
|
||||
|
||||
private String mySsid;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
View contentView = View.inflate(this, R.layout.activity_share_gh_wifi, null);
|
||||
init(contentView, "免流量分享");
|
||||
ButterKnife.bind(this);
|
||||
|
||||
mUriHandlers = new ArrayList<>();
|
||||
mUriHandlers.add(new HtmlUriHandler(this));
|
||||
mUriHandlers.add(new ImageUriHandler(this));
|
||||
mUriHandlers.add(new DownloadUriHandler(this));
|
||||
|
||||
sp = getSharedPreferences(Config.PREFERENCE, Context.MODE_PRIVATE);
|
||||
isColseActivity = false;
|
||||
initSuccess = false;
|
||||
|
||||
if (WifiMgr.getInstance(this).isWifiEnable()) {
|
||||
isOpenWifi = true;
|
||||
WifiMgr.getInstance(this).closeWifi();
|
||||
}
|
||||
|
||||
HotspotManager.initApData(this); // 记录原始热点信息
|
||||
|
||||
initHotSpotView(0);
|
||||
initHotSpot();
|
||||
}
|
||||
|
||||
private void initHotSpot() {
|
||||
|
||||
mWifiAPBroadcastReceiver = new WifiAPBroadcastReceiver() {
|
||||
|
||||
@Override
|
||||
public void onWifiApEnabled() {
|
||||
if(!mIsInitialized){
|
||||
Utils.log("===初始化热点成功");
|
||||
AppController.MAIN_EXECUTOR.execute(checkHotSpot());
|
||||
mIsInitialized = true;
|
||||
// mHotSpotName.setText(mySsid);
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
IntentFilter filter = new IntentFilter(WifiAPBroadcastReceiver.ACTION_WIFI_AP_STATE_CHANGED);
|
||||
registerReceiver(mWifiAPBroadcastReceiver, filter);
|
||||
|
||||
HotspotManager.isApOn(this);
|
||||
|
||||
mySsid = sp.getString("hotspotName", null);
|
||||
if (TextUtils.isEmpty(mySsid)) {
|
||||
String chars = "abcdefghijklmnopqrstuvwxyz";
|
||||
int[] randomArray = RandomUtils.getRandomArray(2, 25);
|
||||
|
||||
mySsid = "ghZS-";
|
||||
for (int i : randomArray) {
|
||||
mySsid = mySsid + chars.charAt(i);
|
||||
}
|
||||
|
||||
int default_user_icon = sp.getInt("default_user_icon", 0);
|
||||
if (default_user_icon == 0) {
|
||||
default_user_icon = RandomUtils.nextInt(8) + 1;
|
||||
sp.edit().putInt("default_user_icon", default_user_icon).apply();
|
||||
}
|
||||
|
||||
mySsid = mySsid + default_user_icon;
|
||||
sp.edit().putString("hotspotName", mySsid).apply();
|
||||
}
|
||||
HotspotManager.configApState(this, mySsid); // change Ap state :boolean
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化创建热点View
|
||||
* @param i i=0 初始化中, i=1 初始化成功, i=2 初始化失败
|
||||
*/
|
||||
|
||||
public void initHotSpotView(int i) {
|
||||
switch (i) {
|
||||
case 0:
|
||||
mInitHotspostPb.setVisibility(View.VISIBLE);
|
||||
mInitStatusIcon.setVisibility(View.GONE);
|
||||
mInitStatusTv.setText("正在创建热点...");
|
||||
mInitStatusTv.setTextColor(getResources().getColor(R.color.title));
|
||||
mInitHotpostHint.setVisibility(View.VISIBLE);
|
||||
mInitHotpostHint.setText("如果出现获取权限的提示,请点击允许");
|
||||
break;
|
||||
case 1:
|
||||
mInitStatusIcon.setVisibility(View.VISIBLE);
|
||||
mInitStatusIcon.setImageResource(R.drawable.kc_checkbox_select);
|
||||
mInitStatusTv.setText(Html.fromHtml("热点创建成功:" + "<font color=\"#00B7FA\">" + mySsid + "</font>"));
|
||||
mInitHotpostHint.setVisibility(View.VISIBLE);
|
||||
mInitHotpostHint.setText("为了避免消耗流量,请关闭你手机的移动网络");
|
||||
mInitHotspostPb.setVisibility(View.GONE);
|
||||
|
||||
initConnHint.setText(Html.fromHtml("请好友打开Wi-Fi设置,连接我的热点:" + "<font color=\"#00B7FA\">" + mySsid + "</font>"));
|
||||
mInitSuccessLl.setVisibility(View.VISIBLE);
|
||||
initSuccess = true;
|
||||
break;
|
||||
case 2:
|
||||
mInitStatusIcon.setVisibility(View.VISIBLE);
|
||||
mInitStatusIcon.setImageResource(R.drawable.hotspot_failed_icon);
|
||||
mInitStatusTv.setText("初始化失败, 请退出重试");
|
||||
mInitStatusTv.setTextColor(Color.parseColor("#ff4147"));
|
||||
mInitHotpostHint.setVisibility(View.VISIBLE);
|
||||
mInitHotspostPb.setVisibility(View.GONE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private Runnable checkHotSpot() {
|
||||
return new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try{
|
||||
// 确保热点开启之后获取得到IP地址
|
||||
String hotspotIpAddr = WifiMgr.getInstance(ShareGhWfifActivity.this).getHotspotLocalIpAddress();
|
||||
int count = 0;
|
||||
while(hotspotIpAddr.equals(Constant.DEFAULT_UNKOWN_IP) && count < Constant.DEFAULT_TRY_TIME){
|
||||
Thread.sleep(1000);
|
||||
hotspotIpAddr = WifiMgr.getInstance(ShareGhWfifActivity.this).getIpAddressFromHotspot();
|
||||
count ++;
|
||||
}
|
||||
|
||||
// 即使热点wifi的IP地址也是无法连接网络 所以采取此策略
|
||||
// count = 0;
|
||||
// while(!WifiUtils.pingIpAddress(hotspotIpAddr) && count < Constant.DEFAULT_TRY_TIME){
|
||||
// Thread.sleep(500);
|
||||
// count ++;
|
||||
// }
|
||||
} catch(Exception e) {
|
||||
Utils.log("==热点启动异常::" + e.toString());
|
||||
}
|
||||
|
||||
Utils.log("===热点可用");
|
||||
|
||||
initMicroServer();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void initMicroServer() {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
Utils.log("===准备开启微型服务器");
|
||||
if (mServerSocket == null) {
|
||||
mServerSocket = new ServerSocket();
|
||||
mServerSocket.setReuseAddress(true);
|
||||
mServerSocket.bind(new InetSocketAddress(Constant.DEFAULT_MICRO_SERVER_PORT));
|
||||
}
|
||||
|
||||
while (!isColseActivity) {
|
||||
if (!initSuccess) {
|
||||
mInitStatusTv.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
initHotSpotView(1);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Utils.log("===循环等待客户端请求");
|
||||
Socket socket = mServerSocket.accept();
|
||||
KcWebRequestEntity requestEntity = hanlderSocket(socket);
|
||||
for (KcUriHandler uriHandler : mUriHandlers) {
|
||||
if (!uriHandler.matches(requestEntity.getUri())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Utils.log("====请求处理::" + requestEntity.getUri() + "==" + uriHandler.getClass().toString());
|
||||
uriHandler.handler(requestEntity);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
Utils.log("===网页传下载出现异常" + e.toString());
|
||||
e.printStackTrace();
|
||||
|
||||
if (!e.toString().contains("Socket closed")) {
|
||||
mInitStatusTv.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
initHotSpotView(2);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
private KcWebRequestEntity hanlderSocket(Socket socket) {
|
||||
KcWebRequestEntity requestEntity = new KcWebRequestEntity();
|
||||
|
||||
requestEntity.setSocket(socket);
|
||||
|
||||
try {
|
||||
InputStream is = socket.getInputStream();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int a = 0, b = 0;
|
||||
while((b != -1) && !(a == '\r' && b == '\n')){
|
||||
a = b;
|
||||
b = is.read();
|
||||
sb.append((char)(b));
|
||||
}
|
||||
String[] split = sb.toString().split(" ");
|
||||
if (split.length > 1) {
|
||||
String requestUri = split[1];
|
||||
requestEntity.setUri(requestUri);
|
||||
Utils.log("===客户端请求链接::" + requestUri);
|
||||
} else {
|
||||
requestEntity.setUri("/ERROR");
|
||||
Utils.log("===客户端请求链接异常::" + sb.toString());
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return requestEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
backActivity();
|
||||
}
|
||||
|
||||
@OnClick(R.id.actionbar_rl_back)
|
||||
public void OnBackClikListener() {
|
||||
backActivity();
|
||||
}
|
||||
|
||||
private void backActivity() {
|
||||
DialogUtils.showWarningDialog(this, "退出分享", "退出本页面即会关闭分享热点,确定退出吗?"
|
||||
, "取消", "确定"
|
||||
, new DialogUtils.ConfiremListener() {
|
||||
@Override
|
||||
public void onConfirem() {
|
||||
isColseActivity = true;
|
||||
unregisterReceiver(mWifiAPBroadcastReceiver);
|
||||
try {
|
||||
if(mWifiAPBroadcastReceiver != null){
|
||||
unregisterReceiver(mWifiAPBroadcastReceiver);
|
||||
mWifiAPBroadcastReceiver = null;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Utils.log("网页传发送异常-关闭广播");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
for (KcUriHandler uriHandler : mUriHandlers) {
|
||||
uriHandler.destroy();
|
||||
}
|
||||
|
||||
if (mServerSocket != null) {
|
||||
try {
|
||||
mServerSocket.close();
|
||||
mServerSocket = null;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
HotspotManager.initUserAp(ShareGhWfifActivity.this);
|
||||
if (isOpenWifi) {
|
||||
WifiMgr.getInstance(ShareGhWfifActivity.this).openWifi();
|
||||
}
|
||||
|
||||
finish();
|
||||
}
|
||||
}, null);
|
||||
|
||||
}
|
||||
}
|
||||
@ -23,6 +23,7 @@ import com.gh.common.constant.Config;
|
||||
import com.gh.common.util.FileUtils;
|
||||
import com.gh.common.util.PackageUtils;
|
||||
import com.gh.common.util.PlatformUtils;
|
||||
import com.gh.common.util.TagUtils;
|
||||
import com.gh.common.util.TimestampUtils;
|
||||
import com.gh.common.util.TokenUtils;
|
||||
import com.gh.common.util.Utils;
|
||||
@ -178,28 +179,24 @@ public class SplashScreenActivity extends BaseActivity {
|
||||
isFirst = false;
|
||||
|
||||
// 第一次启动,把package.txt文件内容加载进数据库
|
||||
FilterManager filterManager = null;
|
||||
if (!sp.getBoolean("isLoadFilter", false)) {
|
||||
filterManager = new FilterManager(getApplicationContext());
|
||||
FilterManager filterManager = new FilterManager(getApplicationContext());
|
||||
if (!sp.getBoolean("isLoadFilterV2d4", false)) {
|
||||
filterManager.loadFilter();
|
||||
}
|
||||
// 获取过滤包
|
||||
filterManager.getFilterFromServer(0);
|
||||
|
||||
// 检查是否存在旧版本光环助手包
|
||||
checkOldGhFile();
|
||||
|
||||
// 更新过滤表,获取自动刷新的cd,获取版本对应表
|
||||
String time = sp.getString("filter_time", null);
|
||||
String time = sp.getString("refresh_time", null);
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault());
|
||||
String today = format.format(new Date());
|
||||
if (!today.equals(time)) {
|
||||
// 获取过滤包
|
||||
if (filterManager == null) {
|
||||
filterManager = new FilterManager(getApplicationContext());
|
||||
}
|
||||
filterManager.getFilterFromServer(today);
|
||||
|
||||
// 获取版本代码、名称
|
||||
PlatformUtils.getInstance(getApplicationContext()).getPlatform();
|
||||
TagUtils.getInstance(getApplicationContext()).getTag();
|
||||
}
|
||||
|
||||
// 获取下载按钮状态、开启or关闭
|
||||
@ -328,6 +325,12 @@ public class SplashScreenActivity extends BaseActivity {
|
||||
bundle = getIntent().getBundleExtra("data");
|
||||
}
|
||||
|
||||
if (sp.getBoolean("isNewFirstLaunchV" + PackageUtils.getVersionName(getApplicationContext()), true)) {
|
||||
bundle = new Bundle();
|
||||
bundle.putString("to", "DownloadManagerActivity");
|
||||
bundle.putInt("currentItem", 0);
|
||||
}
|
||||
|
||||
Intent intent = new Intent(SplashScreenActivity.this, MainActivity.class);
|
||||
intent.putExtra("data", bundle);
|
||||
startActivity(intent);
|
||||
|
||||
@ -54,6 +54,25 @@ public class StrategyActivity extends BaseActivity implements StrategyDialogAdap
|
||||
View contentView = View.inflate(this, R.layout.activity_strategy, null);
|
||||
init(contentView, "攻略");
|
||||
|
||||
ConcernManager concernManager = new ConcernManager(this);
|
||||
List<ConcernInfo> concernGame = concernManager.getConcernGame();
|
||||
|
||||
if (!TextUtils.isEmpty(gameName)) {
|
||||
for (ConcernInfo concernInfo : concernGame) {
|
||||
if (gameName.equals(concernInfo.getGameName())) {
|
||||
mGameName.setText(gameName);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String str = mGameName.getText().toString();
|
||||
if (TextUtils.isEmpty(str) || str.equals("全部游戏")) {
|
||||
gameId = null;
|
||||
gameName = null;
|
||||
mDialogGamePosition = -1;
|
||||
}
|
||||
|
||||
mStrategyAdapter = new StrategyAdapter(this, gameId, mNoData);
|
||||
final LinearLayoutManager layoutManager = new LinearLayoutManager(this);
|
||||
mStrategyRv.setLayoutManager(layoutManager);
|
||||
@ -70,17 +89,11 @@ public class StrategyActivity extends BaseActivity implements StrategyDialogAdap
|
||||
}
|
||||
});
|
||||
|
||||
ConcernManager concernManager = new ConcernManager(this);
|
||||
List<ConcernInfo> concernGame = concernManager.getConcernGame();
|
||||
if (concernGame.size() >1 || (concernGame.size() == 1
|
||||
&& !concernGame.get(0).getId().equals("5618b86e8ab49e17088b4575"))) {
|
||||
mSelectGameRl.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
if (!TextUtils.isEmpty(gameName)) {
|
||||
mGameName.setText(gameName);
|
||||
}
|
||||
|
||||
// 防抖处理
|
||||
RxView.clicks(mSelectGameRl)
|
||||
.throttleFirst(1, TimeUnit.SECONDS)
|
||||
|
||||
@ -250,7 +250,8 @@ public class ViewImageActivity extends BaseActivity implements OnPageChangeListe
|
||||
.build();
|
||||
imageView.setController(controller);
|
||||
}else {
|
||||
imageView.setImageURI(url);
|
||||
// imageView.setImageURI(url);
|
||||
ImageUtils.display(imageView, url);
|
||||
// ImageUtils.getInstance(getApplicationContext()).display(url, imageView, new BaseControllerListener(){
|
||||
// @Override
|
||||
// public void onFinalImageSet(String id, Object imageInfo, Animatable animatable) {
|
||||
|
||||
@ -105,7 +105,7 @@ public class WebActivity extends BaseActivity {
|
||||
@Override
|
||||
public void onReceivedTitle(WebView view, String title) {
|
||||
super.onReceivedTitle(view, title);
|
||||
if (TextUtils.isEmpty(newsId)) {
|
||||
if (TextUtils.isEmpty(newsId) && TextUtils.isEmpty(newsTitle.getText().toString())) {
|
||||
newsTitle.setEllipsize(TextUtils.TruncateAt.END);
|
||||
newsTitle.setPadding(DisplayUtils.dip2px(getApplication(), 30), 0,DisplayUtils.dip2px(getApplication(), 30), 0);
|
||||
newsTitle.setSingleLine();
|
||||
|
||||
@ -43,6 +43,7 @@ public class WeiBoShareActivity extends Activity implements IWeiboHandler.Respon
|
||||
private String shareNewsTitle; // shareNewsTitle不为空就是新闻分享,否则是游戏分享
|
||||
|
||||
private boolean isPlugin;
|
||||
private boolean ispopupWindow;
|
||||
|
||||
private IWeiboShareAPI mWeiboShareAPI;
|
||||
|
||||
@ -55,6 +56,7 @@ public class WeiBoShareActivity extends Activity implements IWeiboHandler.Respon
|
||||
shareIcon = extras.getString("shareIcon");
|
||||
shareNewsTitle = extras.getString("shareNewsTitle");
|
||||
isPlugin = extras.getBoolean("isPlugin");
|
||||
ispopupWindow = extras.getBoolean("ispopupWindow");
|
||||
|
||||
Utils.toast(this, "分享跳转中...");
|
||||
|
||||
@ -94,17 +96,21 @@ public class WeiBoShareActivity extends Activity implements IWeiboHandler.Respon
|
||||
protected void onNewResultImpl(Bitmap bitmap) {
|
||||
Utils.log("分享获取bitmap成功,准备分享");
|
||||
|
||||
Bitmap bgBitmap = ShareUtils.getInstance(getApplication()).addBackGround(bitmap);
|
||||
Bitmap bgBitmap = ShareUtils.getInstance(WeiBoShareActivity.this).addBackGround(bitmap);
|
||||
|
||||
TextObject textObject = new TextObject();
|
||||
if (shareNewsTitle != null){
|
||||
textObject.text = shareNewsTitle + "@光环助手";
|
||||
}else {
|
||||
if (isPlugin){
|
||||
textObject.text ="向你推荐:" + shareGameName + "(光环加速版)" + " @光环助手 ";
|
||||
if (ispopupWindow) {
|
||||
if (shareNewsTitle != null){
|
||||
textObject.text = shareNewsTitle + "@光环助手";
|
||||
}else {
|
||||
textObject.text ="向你推荐:" + shareGameName + " @光环助手 " ;
|
||||
if (isPlugin){
|
||||
textObject.text ="向你推荐:" + shareGameName + "(光环加速版)" + " @光环助手 ";
|
||||
}else {
|
||||
textObject.text ="向你推荐:" + shareGameName + " @光环助手 " ;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
textObject.text = "这个App可以下载各种热门卡牌手游的加速版,绿色安全,超级省心,做日常效率提高3-5倍!不用肝的感觉真好! @光环助手";
|
||||
}
|
||||
|
||||
ImageObject imageObject = new ImageObject();
|
||||
|
||||
382
app/src/main/java/com/gh/gamecenter/adapter/CleanApkAdapter.java
Normal file
382
app/src/main/java/com/gh/gamecenter/adapter/CleanApkAdapter.java
Normal file
@ -0,0 +1,382 @@
|
||||
package com.gh.gamecenter.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Environment;
|
||||
import android.os.Handler;
|
||||
import android.support.v4.util.ArrayMap;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gh.common.util.BitmapUtils;
|
||||
import com.gh.common.util.PackageUtils;
|
||||
import com.gh.common.view.CardLinearLayout;
|
||||
import com.gh.gamecenter.CleanApkActivity;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.adapter.viewholder.KcSelectGameViewHolder;
|
||||
import com.gh.gamecenter.entity.InstallGameEntity;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by khy on 2017/1/24.
|
||||
*/
|
||||
public class CleanApkAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
private Context mContext;
|
||||
|
||||
private CheckBox mApkSelectAll;
|
||||
|
||||
private TextView mApkDeleteBtn;
|
||||
|
||||
private List<InstallGameEntity> mApkList;
|
||||
|
||||
private OnScanListener scanListener;
|
||||
|
||||
private ArrayMap<Integer, Boolean> mSelectPosition;
|
||||
|
||||
private List<String> mApkPath;
|
||||
|
||||
private static int INSTALLED = 0; // 表示已经安装
|
||||
private static int UNINSTALLED = 1; // 表示未安装
|
||||
|
||||
private int cardMargin;
|
||||
|
||||
private boolean isStopScan;
|
||||
|
||||
private boolean isScanOver;
|
||||
|
||||
|
||||
Handler handler = new Handler();
|
||||
|
||||
public CleanApkAdapter(CleanApkActivity activity, TextView apkDeleteBtn, CheckBox apkSelectAll) {
|
||||
this.mContext = activity;
|
||||
this.mApkDeleteBtn = apkDeleteBtn;
|
||||
this.mApkSelectAll = apkSelectAll;
|
||||
|
||||
scanListener = activity;
|
||||
|
||||
mApkList = new ArrayList<>();
|
||||
mSelectPosition = new ArrayMap<>();
|
||||
mApkPath = new ArrayList<>();
|
||||
isStopScan = false;
|
||||
isScanOver = false;
|
||||
|
||||
cardMargin = (int) mContext.getResources().getDimension(R.dimen.cardview_margin);
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// 扫描和获取apk数据 分步操作 尽量避免 StackoverflowError
|
||||
FindAllAPKPath(Environment.getExternalStorageDirectory());
|
||||
LoadApkData();
|
||||
|
||||
handler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
isScanOver = true;
|
||||
scanListener.onScanOver();
|
||||
if (mApkList.size() == 0) {
|
||||
scanListener.noData();
|
||||
}
|
||||
notifyItemRangeChanged(0, getItemCount());
|
||||
}
|
||||
});
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据apk文件路径检查可用的apk和获取apk数据
|
||||
*/
|
||||
private void LoadApkData() {
|
||||
for (String apk_path : mApkPath) {
|
||||
InstallGameEntity apkEntity = new InstallGameEntity();
|
||||
PackageManager pm = mContext.getPackageManager();
|
||||
PackageInfo packageInfo = pm.getPackageArchiveInfo(apk_path, PackageManager.GET_ACTIVITIES);
|
||||
if (packageInfo == null) continue;
|
||||
|
||||
ApplicationInfo appInfo = packageInfo.applicationInfo;
|
||||
|
||||
|
||||
/**获取apk的图标 */
|
||||
appInfo.sourceDir = apk_path;
|
||||
appInfo.publicSourceDir = apk_path;
|
||||
Drawable apk_icon = appInfo.loadIcon(pm);
|
||||
apkEntity.setGameBm(BitmapUtils.drawableToBitmap(apk_icon));
|
||||
/** apk的绝对路劲 */
|
||||
apkEntity.setGamePath(apk_path);
|
||||
/** apk的版本名称 String */
|
||||
String versionName = packageInfo.versionName;
|
||||
apkEntity.setGameVersion(versionName);
|
||||
|
||||
String apkName = packageInfo.applicationInfo.loadLabel(pm).toString();
|
||||
apkEntity.setGameName(apkName);
|
||||
|
||||
File file = new File(apk_path);
|
||||
apkEntity.setGameSize(file.length());
|
||||
|
||||
/**安装处理类型*/
|
||||
/** 得到包名 */
|
||||
String packageName = packageInfo.packageName;
|
||||
int type = doType(pm, packageName);
|
||||
apkEntity.setInstallStatus(type);
|
||||
|
||||
mApkList.add(apkEntity);
|
||||
mSelectPosition.put((mApkList.size() - 1), false);
|
||||
|
||||
handler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
notifyItemChanged((mApkList.size() - 1));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 扫描内存卡 获取apk文件路径
|
||||
* @param file 文件路径
|
||||
*/
|
||||
public void FindAllAPKPath(File file) {
|
||||
|
||||
if (isStopScan) {
|
||||
return;
|
||||
}
|
||||
if (file.isFile()) {
|
||||
// Utils.log("===== 是文件" + file.getAbsolutePath().toString());
|
||||
String name_s = file.getName();
|
||||
String apk_path = null;
|
||||
if (name_s.toLowerCase().endsWith(".apk")) {
|
||||
apk_path = file.getAbsolutePath();// apk文件的绝对路劲
|
||||
mApkPath.add(apk_path);
|
||||
}
|
||||
} else {
|
||||
// Utils.log("===== 是文件夹" + file.getAbsolutePath().toString());
|
||||
File[] files = file.listFiles();
|
||||
if (files != null && files.length > 0) {
|
||||
for (File file_str : files) {
|
||||
FindAllAPKPath(file_str);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int doType(PackageManager pm, String packageName) {
|
||||
List<PackageInfo> pakageinfos = pm.getInstalledPackages(0);
|
||||
for (PackageInfo pi : pakageinfos) {
|
||||
if ((pi.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
|
||||
String pi_packageName = pi.packageName;
|
||||
//如果这个包名在系统已经安装过的应用中存在
|
||||
if(packageName.endsWith(pi_packageName)){
|
||||
return INSTALLED;
|
||||
}
|
||||
}
|
||||
}
|
||||
return UNINSTALLED;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(
|
||||
R.layout.kc_game_select_item, parent, false);
|
||||
return new KcSelectGameViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, final int position) {
|
||||
final InstallGameEntity gameEntity = mApkList.get(position);
|
||||
if (viewHolder instanceof KcSelectGameViewHolder) {
|
||||
final KcSelectGameViewHolder holder = (KcSelectGameViewHolder) viewHolder;
|
||||
// 第一个
|
||||
if (position == 0) {
|
||||
((CardLinearLayout) holder.itemView).setmTop(cardMargin);
|
||||
} else {
|
||||
((CardLinearLayout) holder.itemView).setmTop(0);
|
||||
}
|
||||
|
||||
// 最后一个
|
||||
if (position == mApkList.size() - 1) {
|
||||
((CardLinearLayout) holder.itemView).setBottom(true);
|
||||
} else {
|
||||
((CardLinearLayout) holder.itemView).setBottom(false);
|
||||
}
|
||||
|
||||
double size = (((float)gameEntity.getGameSize()/1024)/1024);
|
||||
DecimalFormat df = new DecimalFormat("#.00");
|
||||
String sizeName = df.format(size) + "MB";
|
||||
|
||||
// Spanned spanned = Html.fromHtml("大小:" + "<font color=\"#00B7FA\">" + sizeName + "</font>");
|
||||
// holder.gameSize.setText(spanned);
|
||||
holder.checkBoxRl.setVisibility(View.VISIBLE);
|
||||
holder.selectCB.setVisibility(View.VISIBLE);
|
||||
if (mSelectPosition.get(position)) {
|
||||
holder.selectCB.setChecked(true);
|
||||
} else {
|
||||
holder.selectCB.setChecked(false);
|
||||
}
|
||||
|
||||
holder.gameNameAndSize.setText(gameEntity.getGameName());
|
||||
holder.gameDes.setText("版本:V" + gameEntity.getGameVersion() + " | " + sizeName);
|
||||
holder.gameDes.setTextColor(mContext.getResources().getColor(R.color.content));
|
||||
|
||||
holder.gameThumb.setImageBitmap(gameEntity.getGameBm());
|
||||
|
||||
if (gameEntity.getInstallStatus() == INSTALLED) {
|
||||
holder.gameSize.setText("已安装");
|
||||
holder.gameSize.setTextColor(mContext.getResources().getColor(R.color.theme));
|
||||
} else {
|
||||
holder.gameSize.setText("未安装");
|
||||
holder.gameSize.setTextColor(Color.parseColor("#ff4147"));
|
||||
}
|
||||
|
||||
if (isScanOver) {
|
||||
holder.selectCB.setEnabled(true);
|
||||
} else {
|
||||
holder.selectCB.setEnabled(false);
|
||||
}
|
||||
|
||||
holder.checkBoxRl.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (mSelectPosition.get(position)) {
|
||||
checkBoxControl(false, position);
|
||||
holder.selectCB.setChecked(false);
|
||||
} else {
|
||||
checkBoxControl(true, position);
|
||||
holder.selectCB.setChecked(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
holder.selectCB.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (mSelectPosition.get(position)) {
|
||||
checkBoxControl(false, position);
|
||||
holder.selectCB.setChecked(false);
|
||||
} else {
|
||||
checkBoxControl(true, position);
|
||||
holder.selectCB.setChecked(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
holder.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (isScanOver) {
|
||||
PackageUtils.launchSetup(mContext, gameEntity.getGamePath());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
public void checkBoxControl(boolean isChecked, int position) {
|
||||
if (isChecked) {
|
||||
mSelectPosition.put(position, true);
|
||||
} else {
|
||||
mSelectPosition.put(position, false);
|
||||
}
|
||||
|
||||
long gameSize = 0;
|
||||
int i = 0;
|
||||
|
||||
if (mApkList.size() == 0) return;
|
||||
for (Integer integer : mSelectPosition.keySet()) {
|
||||
if (mSelectPosition.get(integer)) {
|
||||
gameSize = gameSize + mApkList.get(integer).getGameSize();
|
||||
i ++;
|
||||
}
|
||||
}
|
||||
|
||||
if (i == mApkList.size()) {
|
||||
mApkSelectAll.setChecked(true);
|
||||
} else {
|
||||
mApkSelectAll.setChecked(false);
|
||||
}
|
||||
|
||||
if (gameSize == 0) {
|
||||
mApkDeleteBtn.setText("一键删除");
|
||||
} else {
|
||||
double size = (((float)gameSize/1024)/1024);
|
||||
DecimalFormat df = new DecimalFormat("0.00");
|
||||
String sizeName = df.format(size) + "MB";
|
||||
mApkDeleteBtn.setText("一键删除("+ i + "个,释放" + sizeName +")");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mApkList.size();
|
||||
}
|
||||
|
||||
public List<InstallGameEntity> getApkList() {
|
||||
return mApkList;
|
||||
}
|
||||
|
||||
public ArrayMap<Integer, Boolean> getSelectPosition() {
|
||||
return mSelectPosition;
|
||||
}
|
||||
|
||||
public void setSelectPosition(ArrayMap<Integer, Boolean> selectPosition) {
|
||||
this.mSelectPosition = selectPosition;
|
||||
}
|
||||
|
||||
public void isStopScan () {
|
||||
this.isStopScan = true;
|
||||
}
|
||||
|
||||
public void deleteApk(int position) {
|
||||
mApkList.remove(position);
|
||||
|
||||
Iterator<Map.Entry<Integer, Boolean>> iterator = mSelectPosition.entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<Integer, Boolean> entry = iterator.next();
|
||||
Integer key = entry.getKey();
|
||||
|
||||
if (key == position) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
|
||||
ArrayMap<Integer, Boolean> newMap = new ArrayMap<>(mSelectPosition);
|
||||
for (Integer integer : newMap.keySet()) {
|
||||
if (integer > position) {
|
||||
int newPosition = integer - 1;
|
||||
mSelectPosition.put(newPosition, mSelectPosition.get(integer));
|
||||
}
|
||||
}
|
||||
|
||||
if (mSelectPosition.size() > mApkList.size()) {
|
||||
mSelectPosition.removeAt(mSelectPosition.size() - 1);
|
||||
}
|
||||
|
||||
notifyItemRemoved(position);
|
||||
}
|
||||
|
||||
public interface OnScanListener {
|
||||
void onScanOver();
|
||||
void noData();
|
||||
}
|
||||
|
||||
}
|
||||
@ -11,6 +11,7 @@ import com.gh.common.util.DataCollectionUtils;
|
||||
import com.gh.common.util.DataUtils;
|
||||
import com.gh.common.util.DialogUtils;
|
||||
import com.gh.common.util.GameUtils;
|
||||
import com.gh.common.util.ImageUtils;
|
||||
import com.gh.gamecenter.ConcernActivity;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.adapter.viewholder.ConcernViewHolder;
|
||||
@ -22,6 +23,8 @@ import com.gh.gamecenter.retrofit.Response;
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -64,6 +67,14 @@ public class ConcernAdapter extends RecyclerView.Adapter<ConcernViewHolder> {
|
||||
}
|
||||
|
||||
private void initConcernGame() {
|
||||
|
||||
// 按时间排序
|
||||
Collections.sort(concernList, new Comparator<ConcernInfo>() {
|
||||
@Override
|
||||
public int compare(ConcernInfo lhs, ConcernInfo rhs) {
|
||||
return String.valueOf(rhs.getTime()).compareTo(String.valueOf(lhs.getTime()));
|
||||
}
|
||||
});
|
||||
final List<GameEntity> result = new ArrayList<>();
|
||||
List<Observable<GameEntity>> sequences = new ArrayList<>();
|
||||
for (ConcernInfo concernInfo : concernList) {
|
||||
@ -108,6 +119,19 @@ public class ConcernAdapter extends RecyclerView.Adapter<ConcernViewHolder> {
|
||||
@Override
|
||||
public void onBindViewHolder(final ConcernViewHolder holder, int position) {
|
||||
ConcernInfo concernInfo = concernList.get(position);
|
||||
// holder.concern_item_icon.setImageURI(concernInfo.getIcon());
|
||||
ImageUtils.display(holder.concern_item_icon, concernInfo.getIcon());
|
||||
|
||||
if (concernGameList != null) {
|
||||
GameEntity gameEntity = concernGameList.get(position);
|
||||
|
||||
if (gameEntity.isLibaoExists()) {
|
||||
holder.concern_libao_icon.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
holder.concern_libao_icon.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
// ImageUtils.getInstance(context).display(concernInfo.getIcon(), holder.concern_item_icon);
|
||||
holder.concern_item_icon.setImageURI(concernInfo.getIcon());
|
||||
holder.concern_item_name.setText(concernInfo.getGameName());
|
||||
|
||||
@ -10,6 +10,7 @@ import android.widget.Toast;
|
||||
import com.gh.common.util.DataCollectionUtils;
|
||||
import com.gh.common.util.DataUtils;
|
||||
import com.gh.common.util.GameUtils;
|
||||
import com.gh.common.util.ImageUtils;
|
||||
import com.gh.gamecenter.ConcernActivity;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.adapter.viewholder.ConcernViewHolder;
|
||||
@ -128,8 +129,17 @@ public class ConcernRecommendAdapter extends RecyclerView.Adapter<ConcernViewHol
|
||||
@Override
|
||||
public void onBindViewHolder(final ConcernViewHolder holder, int position) {
|
||||
GameEntity gameEntity = recommendGameList.get(position);
|
||||
// holder.concern_item_icon.setImageURI(gameEntity.getIcon());
|
||||
ImageUtils.display(holder.concern_item_icon, gameEntity.getIcon());
|
||||
// ImageUtils.getInstance(context).display(
|
||||
// gameEntity.getIcon(), holder.concern_item_icon);
|
||||
|
||||
if (gameEntity.isLibaoExists()) {
|
||||
holder.concern_libao_icon.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
holder.concern_libao_icon.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
holder.concern_item_icon.setImageURI(gameEntity.getIcon());
|
||||
holder.concern_item_name.setText(gameEntity.getName());
|
||||
holder.concern_item_concern.setText("关注");
|
||||
|
||||
@ -0,0 +1,181 @@
|
||||
package com.gh.gamecenter.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.Environment;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.PackageUtils;
|
||||
import com.gh.common.util.SpeedUtils;
|
||||
import com.gh.gamecenter.FileReceiverActivity;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.adapter.viewholder.KcSelectGameViewHolder;
|
||||
import com.gh.gamecenter.kuaichuan.FileInfo;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by khy on 2017/1/22.
|
||||
*/
|
||||
public class FileReceiverAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
private Context mContext;
|
||||
private List<FileInfo> mFileInfos;
|
||||
|
||||
private long lastProgress;
|
||||
|
||||
private OnReceiverCancelListener cancelListener;
|
||||
|
||||
|
||||
public FileReceiverAdapter(FileReceiverActivity activity, List<FileInfo> infos) {
|
||||
this.mContext = activity;
|
||||
this.cancelListener = activity;
|
||||
|
||||
mFileInfos = infos;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新数据
|
||||
*/
|
||||
public void update(){
|
||||
// mFileInfos = (List<FileInfo>) AppController.get("FileInfo", false);
|
||||
notifyItemRangeChanged(0, getItemCount());
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(mContext).inflate(R.layout.kc_game_select_item, parent, false);
|
||||
return new KcSelectGameViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
|
||||
final FileInfo fileInfo = mFileInfos.get(position);
|
||||
|
||||
if (holder instanceof KcSelectGameViewHolder) {
|
||||
final KcSelectGameViewHolder viewHolder = (KcSelectGameViewHolder) holder;
|
||||
viewHolder.gameNameAndSize.setText(fileInfo.getName());
|
||||
viewHolder.downloadStatus.setVisibility(View.VISIBLE);
|
||||
viewHolder.sendOverIcon.setVisibility(View.GONE);
|
||||
viewHolder.gameProgressbar.setMax(100);
|
||||
viewHolder.gameProgressbar.setVisibility(View.VISIBLE);
|
||||
viewHolder.gameLlInfo.setVisibility(View.VISIBLE);
|
||||
viewHolder.gameSize.setVisibility(View.GONE);
|
||||
viewHolder.gameNameAndSize.setPadding(0, 0, 0, DisplayUtils.dip2px(mContext, 5));
|
||||
if (fileInfo.getBitmap() != null) {
|
||||
viewHolder.gameThumb.setImageBitmap(fileInfo.getBitmap());
|
||||
} else {
|
||||
viewHolder.gameThumb.setImageResource(R.drawable.ocupy);
|
||||
}
|
||||
|
||||
viewHolder.downloadSpeed.setText("等待中");
|
||||
viewHolder.downloadSpeed.setTextColor(mContext.getResources().getColor(R.color.content));
|
||||
viewHolder.gameProgressbar.setProgress(0);
|
||||
viewHolder.sendOverIcon.setVisibility(View.GONE);
|
||||
viewHolder.downloadStatus.setText("取消");
|
||||
viewHolder.downloadStatus.setTextColor(mContext.getResources().getColor(R.color.content));
|
||||
viewHolder.downloadStatus.setBackgroundResource(R.drawable.kuaichuan_cancel_bg);
|
||||
|
||||
int percent = (int)(fileInfo.getProgress() * 100 / fileInfo.getSize());
|
||||
viewHolder.downloadPercentage.setText(percent + "%");
|
||||
|
||||
if (fileInfo.getResult() == FileInfo.FLAG_SUCCESS || fileInfo.getResult() == FileInfo.FLAG_INSTALLED) { // 传输完成...
|
||||
viewHolder.gameProgressbar.setProgress(100);
|
||||
viewHolder.downloadPercentage.setText("100%");
|
||||
|
||||
if (fileInfo.getResult() == FileInfo.FLAG_SUCCESS) {
|
||||
viewHolder.downloadStatus.setText("安装");
|
||||
viewHolder.downloadStatus.setTextColor(Color.WHITE);
|
||||
viewHolder.downloadStatus.setBackgroundResource(R.drawable.game_item_btn_download_style);
|
||||
} else {
|
||||
viewHolder.downloadStatus.setText("已安装");
|
||||
viewHolder.downloadStatus.setTextColor(mContext.getResources().getColor(R.color.theme));
|
||||
viewHolder.downloadStatus.setBackgroundDrawable(new ColorDrawable(0));
|
||||
}
|
||||
|
||||
double size = (((float)fileInfo.getSize()/1024)/1024);
|
||||
DecimalFormat df = new DecimalFormat("0.00");
|
||||
String sizeName = df.format(size) + "MB";
|
||||
viewHolder.downloadSpeed.setTextColor(mContext.getResources().getColor(R.color.content));
|
||||
viewHolder.downloadSpeed.setText(sizeName + "/" + sizeName);
|
||||
} else if (fileInfo.getResult() == FileInfo.FLAG_FAILURE || fileInfo.getResult() == FileInfo.FLAG_NO_MEMORY) { // 传输失败...
|
||||
double sizeMb = (((float)fileInfo.getSize()/1024)/1024);
|
||||
double curSizeMb = (((float)fileInfo.getProgress()/1024)/1024);
|
||||
DecimalFormat df = new DecimalFormat("0.00");
|
||||
String sizeName = df.format(sizeMb) + "MB";
|
||||
String curSizeName = df.format(curSizeMb) + "MB";
|
||||
viewHolder.downloadSpeed.setTextColor(mContext.getResources().getColor(R.color.content));
|
||||
viewHolder.downloadSpeed.setText(curSizeName + "/" + sizeName);
|
||||
viewHolder.downloadStatus.setTextColor(mContext.getResources().getColor(R.color.type_huodong));
|
||||
viewHolder.downloadStatus.setBackgroundDrawable(new ColorDrawable(0));
|
||||
viewHolder.gameProgressbar.setProgress(percent);
|
||||
// viewHolder.downloadPercentage.setText(percent + "%");
|
||||
if (fileInfo.getResult() == FileInfo.FLAG_FAILURE) {
|
||||
viewHolder.downloadStatus.setText("传输失败");
|
||||
} else {
|
||||
viewHolder.downloadStatus.setText("空间不足");
|
||||
}
|
||||
} else if (fileInfo.getResult() == FileInfo.FLAG_CANCEL) { // 取消传输
|
||||
double sizeMb = (((float)fileInfo.getSize()/1024)/1024);
|
||||
double curSizeMb = (((float)fileInfo.getProgress()/1024)/1024);
|
||||
DecimalFormat df = new DecimalFormat("0.00");
|
||||
String sizeName = df.format(sizeMb) + "MB";
|
||||
String curSizeName = df.format(curSizeMb) + "MB";
|
||||
viewHolder.downloadSpeed.setTextColor(mContext.getResources().getColor(R.color.content));
|
||||
viewHolder.downloadSpeed.setText(curSizeName + "/" + sizeName);
|
||||
viewHolder.downloadStatus.setText("已取消");
|
||||
viewHolder.downloadStatus.setBackgroundDrawable(new ColorDrawable(0));
|
||||
|
||||
viewHolder.gameProgressbar.setProgress(percent);
|
||||
// viewHolder.downloadPercentage.setText(percent + "%");
|
||||
} else if (fileInfo.getResult() == FileInfo.FLAG_DEFAULT){ // 传输中...
|
||||
viewHolder.gameProgressbar.setProgress(percent);
|
||||
viewHolder.downloadStatus.setText("取消");
|
||||
viewHolder.downloadStatus.setTextColor(mContext.getResources().getColor(R.color.content));
|
||||
viewHolder.downloadStatus.setBackgroundResource(R.drawable.kuaichuan_cancel_bg);
|
||||
|
||||
long speed = (fileInfo.getProgress() - lastProgress) / 1024;
|
||||
if (speed < 0) {
|
||||
speed = 0;
|
||||
}
|
||||
|
||||
// viewHolder.downloadPercentage.setText(percent + "%");
|
||||
viewHolder.downloadSpeed.setTextColor(mContext.getResources().getColor(R.color.theme));
|
||||
viewHolder.downloadSpeed.setText(String.format("%s(剩%s)",
|
||||
SpeedUtils.getSpeed(speed),
|
||||
SpeedUtils.getRemainTime(fileInfo.getSize(), fileInfo.getProgress(), speed * 1024)));
|
||||
lastProgress = fileInfo.getProgress();
|
||||
}
|
||||
|
||||
viewHolder.downloadStatus.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
String s = viewHolder.downloadStatus.getText().toString();
|
||||
if ("取消".equals(s)) {
|
||||
cancelListener.OnCancelPosition(position);
|
||||
} else if ("安装".equals(s)) {
|
||||
PackageUtils.launchSetup(mContext, Environment.getExternalStorageDirectory() + "/GH-KC/" + fileInfo.getName() + ".apk");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
if (mFileInfos == null) {
|
||||
return 0;
|
||||
}
|
||||
return mFileInfos.size();
|
||||
}
|
||||
|
||||
public interface OnReceiverCancelListener {
|
||||
void OnCancelPosition(int position);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,161 @@
|
||||
package com.gh.gamecenter.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.SpeedUtils;
|
||||
import com.gh.common.util.Utils;
|
||||
import com.gh.gamecenter.FileSenderActivity;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.adapter.viewholder.KcSelectGameViewHolder;
|
||||
import com.gh.gamecenter.kuaichuan.FileInfo;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by khy on 2017/1/20.
|
||||
*/
|
||||
public class FileSenderAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
private Context mContext;
|
||||
private List<FileInfo> mFileInfos;
|
||||
|
||||
private long lastProgress;
|
||||
|
||||
private OnCancelListener cancelListener;
|
||||
|
||||
public FileSenderAdapter(FileSenderActivity activity, List<FileInfo> fileInfos) {
|
||||
this.mContext = activity;
|
||||
this.cancelListener = activity;
|
||||
this.mFileInfos = fileInfos;
|
||||
lastProgress = 0;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(mContext).inflate(R.layout.kc_game_select_item, parent, false);
|
||||
return new KcSelectGameViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
|
||||
FileInfo fileInfo = mFileInfos.get(position);
|
||||
|
||||
if (holder instanceof KcSelectGameViewHolder) {
|
||||
KcSelectGameViewHolder viewHolder = (KcSelectGameViewHolder) holder;
|
||||
viewHolder.gameNameAndSize.setText(fileInfo.getName());
|
||||
viewHolder.downloadStatus.setVisibility(View.VISIBLE);
|
||||
viewHolder.sendOverIcon.setVisibility(View.GONE);
|
||||
viewHolder.gameProgressbar.setMax(100);
|
||||
viewHolder.gameProgressbar.setVisibility(View.VISIBLE);
|
||||
viewHolder.gameLlInfo.setVisibility(View.VISIBLE);
|
||||
viewHolder.gameSize.setVisibility(View.GONE);
|
||||
viewHolder.gameNameAndSize.setPadding(0, 0, 0, DisplayUtils.dip2px(mContext, 5));
|
||||
|
||||
viewHolder.downloadSpeed.setText("等待中");
|
||||
viewHolder.downloadSpeed.setTextColor(mContext.getResources().getColor(R.color.content));
|
||||
viewHolder.gameProgressbar.setProgress(0);
|
||||
viewHolder.sendOverIcon.setVisibility(View.GONE);
|
||||
viewHolder.downloadStatus.setText("取消");
|
||||
viewHolder.downloadStatus.setTextColor(mContext.getResources().getColor(R.color.content));
|
||||
viewHolder.downloadStatus.setBackgroundResource(R.drawable.kuaichuan_cancel_bg);
|
||||
|
||||
int percent = (int)(fileInfo.getProgress() * 100 / fileInfo.getSize());
|
||||
viewHolder.downloadPercentage.setText(percent + "%");
|
||||
|
||||
|
||||
if (fileInfo.getBitmap() != null) {
|
||||
viewHolder.gameThumb.setImageBitmap(fileInfo.getBitmap());
|
||||
}
|
||||
|
||||
if (fileInfo.getResult() == FileInfo.FLAG_SUCCESS) { // 传输完成...
|
||||
viewHolder.gameProgressbar.setProgress(100);
|
||||
viewHolder.downloadPercentage.setText("100%");
|
||||
// viewHolder.downloadStatus.setText("传输成功");
|
||||
viewHolder.downloadStatus.setVisibility(View.GONE);
|
||||
viewHolder.sendOverIcon.setVisibility(View.VISIBLE);
|
||||
double size = (((float)fileInfo.getSize()/1024)/1024);
|
||||
DecimalFormat df = new DecimalFormat("0.00");
|
||||
String sizeName = df.format(size) + "MB";
|
||||
viewHolder.downloadSpeed.setTextColor(mContext.getResources().getColor(R.color.content));
|
||||
viewHolder.downloadSpeed.setText(sizeName + "/" + sizeName);
|
||||
} else if (fileInfo.getResult() == FileInfo.FLAG_FAILURE) { // 传输失败...
|
||||
double sizeMb = (((float)fileInfo.getSize()/1024)/1024);
|
||||
double curSizeMb = (((float)fileInfo.getProgress()/1024)/1024);
|
||||
DecimalFormat df = new DecimalFormat("0.00");
|
||||
String sizeName = df.format(sizeMb) + "MB";
|
||||
String curSizeName;
|
||||
if (curSizeMb == 0) {
|
||||
curSizeName= "0.00MB";
|
||||
} else {
|
||||
curSizeName= df.format(curSizeMb) + "MB";
|
||||
}
|
||||
viewHolder.gameProgressbar.setProgress(percent);
|
||||
viewHolder.downloadSpeed.setTextColor(mContext.getResources().getColor(R.color.content));
|
||||
viewHolder.downloadSpeed.setText(curSizeName + "/" + sizeName);
|
||||
viewHolder.downloadStatus.setText("传输失败");
|
||||
viewHolder.sendOverIcon.setVisibility(View.GONE);
|
||||
viewHolder.downloadStatus.setTextColor(mContext.getResources().getColor(R.color.type_huodong));
|
||||
viewHolder.downloadStatus.setBackgroundDrawable(new ColorDrawable(0));
|
||||
// viewHolder.downloadPercentage.setText(percent + "%");
|
||||
} else if (fileInfo.getResult() == FileInfo.FLAG_CANCEL) { // 取消传输
|
||||
double sizeMb = (((float)fileInfo.getSize()/1024)/1024);
|
||||
double curSizeMb = (((float)fileInfo.getProgress()/1024)/1024);
|
||||
DecimalFormat df = new DecimalFormat("0.00");
|
||||
String sizeName = df.format(sizeMb) + "MB";
|
||||
String curSizeName = df.format(curSizeMb) + "MB";
|
||||
viewHolder.sendOverIcon.setVisibility(View.GONE);
|
||||
viewHolder.downloadSpeed.setTextColor(mContext.getResources().getColor(R.color.content));
|
||||
viewHolder.downloadSpeed.setText(curSizeName + "/" + sizeName);
|
||||
viewHolder.downloadStatus.setText("已取消");
|
||||
viewHolder.downloadStatus.setBackgroundDrawable(new ColorDrawable(0));
|
||||
|
||||
Utils.log("==========已取消" + percent + "===" + fileInfo.getProgress());
|
||||
viewHolder.gameProgressbar.setProgress(percent);
|
||||
} else if (fileInfo.getResult() == FileInfo.FLAG_DEFAULT){ // 传输中...
|
||||
viewHolder.gameProgressbar.setProgress(percent);
|
||||
viewHolder.sendOverIcon.setVisibility(View.GONE);
|
||||
viewHolder.downloadStatus.setText("取消");
|
||||
viewHolder.downloadStatus.setTextColor(mContext.getResources().getColor(R.color.content));
|
||||
viewHolder.downloadStatus.setBackgroundResource(R.drawable.kuaichuan_cancel_bg);
|
||||
|
||||
long speed = (fileInfo.getProgress() - lastProgress) / 1024;
|
||||
if (speed < 0) {
|
||||
speed = 0;
|
||||
}
|
||||
|
||||
// viewHolder.downloadPercentage.setText(percent + "%");
|
||||
viewHolder.downloadSpeed.setTextColor(mContext.getResources().getColor(R.color.theme));
|
||||
viewHolder.downloadSpeed.setText(String.format("%s(剩%s)",
|
||||
SpeedUtils.getSpeed(speed),
|
||||
SpeedUtils.getRemainTime(fileInfo.getSize(), fileInfo.getProgress(), speed * 1024)));
|
||||
lastProgress = fileInfo.getProgress();
|
||||
|
||||
viewHolder.downloadStatus.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
cancelListener.OnCancelPosition(position);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
Utils.log("FileSenderActivity :: adapter" + mFileInfos.size());
|
||||
return mFileInfos.size();
|
||||
}
|
||||
|
||||
public interface OnCancelListener {
|
||||
void OnCancelPosition(int position);
|
||||
}
|
||||
|
||||
}
|
||||
@ -4,6 +4,7 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.support.v7.widget.GridLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.text.Html;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@ -198,7 +199,7 @@ public class GameNewsAdapter extends RecyclerView.Adapter {
|
||||
final NewsEntity newsEntity = newsList.get(position - 2);
|
||||
viewHolder.type.setBackgroundResource(NewsUtils.getDrawableIdByType(newsEntity.getType()));
|
||||
viewHolder.type.setText(newsEntity.getType());
|
||||
viewHolder.title.setText(newsEntity.getTitle());
|
||||
viewHolder.title.setText(Html.fromHtml(newsEntity.getTitle()));
|
||||
viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
@ -0,0 +1,416 @@
|
||||
package com.gh.gamecenter.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Handler;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.text.Html;
|
||||
import android.text.Spanned;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gh.base.AppController;
|
||||
import com.gh.common.constant.ItemViewType;
|
||||
import com.gh.common.util.BitmapUtils;
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.Utils;
|
||||
import com.gh.common.view.CardLinearLayout;
|
||||
import com.gh.gamecenter.KcSelectGameActivity;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.adapter.viewholder.FooterViewHolder;
|
||||
import com.gh.gamecenter.adapter.viewholder.KcSelectGameViewHolder;
|
||||
import com.gh.gamecenter.db.info.ConcernInfo;
|
||||
import com.gh.gamecenter.entity.InstallGameEntity;
|
||||
import com.gh.gamecenter.kuaichuan.FileInfo;
|
||||
import com.gh.gamecenter.manager.ConcernManager;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by khy on 2017/1/20.
|
||||
*/
|
||||
public class KcSelectGameAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
private Context context;
|
||||
|
||||
private TextView mSelectCount;
|
||||
private TextView installCount;
|
||||
|
||||
private ProgressBar mSelectPb;
|
||||
|
||||
private RelativeLayout installRl;
|
||||
|
||||
private HashMap<Integer, Boolean> selectPosition; // 记录选择游戏的位置
|
||||
|
||||
private List<InstallGameEntity> gameList;
|
||||
|
||||
private List<InstallGameEntity> apkList;
|
||||
|
||||
private List<FileInfo> sendOverList; //发送过的游戏
|
||||
|
||||
private int cardMargin;
|
||||
|
||||
private boolean isLoadApp;
|
||||
|
||||
Handler handler = new Handler();
|
||||
|
||||
public KcSelectGameAdapter(KcSelectGameActivity activity,
|
||||
TextView selectCount,
|
||||
TextView installCount,
|
||||
RelativeLayout installRl,
|
||||
ProgressBar selectPb) {
|
||||
this.context = activity;
|
||||
this.mSelectCount = selectCount;
|
||||
this.installCount = installCount;
|
||||
this.installRl = installRl;
|
||||
this.mSelectPb = selectPb;
|
||||
|
||||
gameList = new ArrayList<>();
|
||||
apkList = new ArrayList<>();
|
||||
selectPosition = new HashMap<>();
|
||||
|
||||
isLoadApp = false;
|
||||
|
||||
sendOverList = (List<FileInfo>) AppController.get("FileInfo", false);
|
||||
|
||||
|
||||
cardMargin = (int) context.getResources().getDimension(R.dimen.cardview_margin);
|
||||
|
||||
ConcernManager cManager = new ConcernManager(context);
|
||||
final List<ConcernInfo> runnableGame = cManager.getInstalledGame();
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
init(runnableGame);
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
//初始化
|
||||
private void init(List<ConcernInfo> runnableGame) {
|
||||
PackageManager pm = context.getPackageManager();
|
||||
List<PackageInfo> installedPackages = pm.getInstalledPackages(0);
|
||||
|
||||
List<String> arrInstallPackage = new ArrayList<>();
|
||||
|
||||
for (ConcernInfo concernInfo : runnableGame) {
|
||||
for (String s : concernInfo.getPackageNames().keySet()) {
|
||||
if (concernInfo.getPackageNames().get(s)) {
|
||||
arrInstallPackage.add(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<InstallGameEntity> game = new ArrayList<>(); // 防止数据加载时recyclerView首次刷新时造成的数据残缺
|
||||
List<InstallGameEntity> apk = new ArrayList<>();
|
||||
|
||||
for (PackageInfo installedPackage : installedPackages) {
|
||||
if ((installedPackage.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
|
||||
InstallGameEntity installGameEntity = new InstallGameEntity();
|
||||
installGameEntity.setGamePath(installedPackage.applicationInfo.sourceDir);
|
||||
try{
|
||||
Drawable drawable = installedPackage.applicationInfo.loadIcon(pm);
|
||||
installGameEntity.setGameBm(BitmapUtils.drawableToBitmap(drawable));
|
||||
|
||||
installGameEntity.setGameVersion(installedPackage.versionName);
|
||||
installGameEntity.setGameName(installedPackage.applicationInfo.loadLabel(pm).toString());
|
||||
installGameEntity.setPackageName(installedPackage.packageName);
|
||||
|
||||
File file = new File(installedPackage.applicationInfo.sourceDir);
|
||||
installGameEntity.setGameSize(file.length());
|
||||
boolean isAdd = false;
|
||||
for (int j = 0; j < arrInstallPackage.size(); j++) {
|
||||
if (installedPackage.packageName.equals(arrInstallPackage.get(j))) {
|
||||
game.add(installGameEntity);
|
||||
isAdd = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isAdd) {
|
||||
apk.add(installGameEntity);
|
||||
}
|
||||
}catch(Exception e){
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gameList.addAll(game);
|
||||
apkList.addAll(apk);
|
||||
|
||||
for (int i = 0; i < (gameList.size() + apkList.size() + 1); i++) {
|
||||
selectPosition.put(i, false);
|
||||
}
|
||||
|
||||
handler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
mSelectPb.setVisibility(View.GONE);
|
||||
installCount.setText("已安装的游戏(" + gameList.size() + ")");
|
||||
notifyItemRangeChanged(0, getItemCount() - 1);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
if (viewType == ItemViewType.GAME_NORMAL) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(
|
||||
R.layout.kc_game_select_item, parent, false);
|
||||
return new KcSelectGameViewHolder(view);
|
||||
} else if (viewType == ItemViewType.LOADING) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(
|
||||
R.layout.refresh_footerview, parent, false);
|
||||
return new FooterViewHolder(view);
|
||||
} else if (viewType == 101) {
|
||||
TextView textView = new TextView(context);
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
DisplayUtils.dip2px(context, 40));
|
||||
if (gameList.size() == 0) {
|
||||
params.setMargins(0, DisplayUtils.dip2px(context, 43), 0, 0);
|
||||
}
|
||||
textView.setLayoutParams(params);
|
||||
textView.setGravity(Gravity.CENTER_VERTICAL);
|
||||
textView.setPadding(DisplayUtils.dip2px(context, 20), 0, 0, 0);
|
||||
textView.setBackgroundColor(Color.WHITE);
|
||||
textView.setText("已安装的应用(" + apkList.size() + ")");
|
||||
return new TitleViewHolder(textView) ;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
|
||||
if (holder instanceof KcSelectGameViewHolder) {
|
||||
if (gameList.size() >= position + 1) {
|
||||
initGameNormal((KcSelectGameViewHolder) holder, gameList.get(position), position);
|
||||
} else {
|
||||
if (gameList.isEmpty()) {
|
||||
initGameNormal((KcSelectGameViewHolder) holder, apkList.get(position - 1), position);
|
||||
} else {
|
||||
initGameNormal((KcSelectGameViewHolder) holder, apkList.get(position - gameList.size() - 1), position);
|
||||
}
|
||||
}
|
||||
|
||||
} else if (holder instanceof FooterViewHolder) {
|
||||
FooterViewHolder viewHolder = ((FooterViewHolder) holder);
|
||||
if (position > 0) {
|
||||
viewHolder.loading.setVisibility(View.GONE);
|
||||
viewHolder.hint.setTextColor(context.getResources().getColor(R.color.theme));
|
||||
viewHolder.hint.setText("查看更多");
|
||||
holder.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
isLoadApp = true;
|
||||
notifyItemRangeChanged(0, getItemCount() - 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
if (gameList.isEmpty() && apkList.isEmpty()) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (gameList.isEmpty() && !apkList.isEmpty()) {
|
||||
return apkList.size() + 1;
|
||||
}
|
||||
|
||||
if (isLoadApp) {
|
||||
return gameList.size() + apkList.size() + 1;
|
||||
}
|
||||
return gameList.size() + 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
if (gameList.size() != 0 && position >= 0 && position < gameList.size()) {
|
||||
return ItemViewType.GAME_NORMAL;
|
||||
}
|
||||
|
||||
if (gameList.isEmpty() && !apkList.isEmpty() && position <= apkList.size()) {
|
||||
if (position == 0) {
|
||||
return 101;
|
||||
}
|
||||
return ItemViewType.GAME_NORMAL;
|
||||
}
|
||||
|
||||
if (gameList.size() == position) {
|
||||
if (isLoadApp) {
|
||||
return 101;
|
||||
} else {
|
||||
return ItemViewType.LOADING;
|
||||
}
|
||||
}
|
||||
if (isLoadApp) {
|
||||
return ItemViewType.GAME_NORMAL;
|
||||
}
|
||||
return ItemViewType.LOADING;
|
||||
}
|
||||
|
||||
private void initGameNormal(final KcSelectGameViewHolder holder, final InstallGameEntity gameEntity, final int i) {
|
||||
|
||||
// 第一个
|
||||
if (i == 0 || i == gameList.size() + 1 || (gameList.isEmpty() && i == 1)) {
|
||||
if (i == 0) {
|
||||
((CardLinearLayout) holder.itemView).setmTop(DisplayUtils.dip2px(context, 49));
|
||||
} else {
|
||||
((CardLinearLayout) holder.itemView).setmTop(cardMargin);
|
||||
}
|
||||
} else {
|
||||
((CardLinearLayout) holder.itemView).setmTop(0);
|
||||
}
|
||||
|
||||
// 最后一个
|
||||
if (i == gameList.size() - 1) {
|
||||
((CardLinearLayout) holder.itemView).setBottom(true);
|
||||
} else {
|
||||
((CardLinearLayout) holder.itemView).setBottom(false);
|
||||
}
|
||||
|
||||
double size = (((float)gameEntity.getGameSize()/1024)/1024);
|
||||
DecimalFormat df = new DecimalFormat("0.00");
|
||||
String sizeName = df.format(size) + "MB";
|
||||
|
||||
Spanned spanned = Html.fromHtml("大小:" + "<font color=\"#00B7FA\">" + sizeName + "</font>");
|
||||
holder.gameSize.setText(spanned);
|
||||
holder.gameDes.setText("版本:V" + gameEntity.getGameVersion());
|
||||
|
||||
holder.gameThumb.setImageBitmap(gameEntity.getGameBm());
|
||||
|
||||
holder.gameNameAndSize.setText(gameEntity.getGameName());
|
||||
holder.gameNameAndSize.setTextColor(context.getResources().getColor(R.color.title));
|
||||
if (sendOverList != null && sendOverList.size() > 0) {
|
||||
for (FileInfo fileInfo : sendOverList) {
|
||||
if (fileInfo.getFilePath().equals(gameEntity.getGamePath())) {
|
||||
holder.gameNameAndSize.setTextColor(context.getResources().getColor(R.color.hint));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
holder.selectCB.setVisibility(View.VISIBLE);
|
||||
if (selectPosition.get(i) != null && selectPosition.get(i)) {
|
||||
holder.selectCB.setChecked(true);
|
||||
} else {
|
||||
holder.selectCB.setChecked(false);
|
||||
}
|
||||
|
||||
holder.selectCB.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (selectPosition.get(i)) {
|
||||
checkBoxControl(false, i);
|
||||
holder.selectCB.setChecked(false);
|
||||
} else {
|
||||
checkBoxControl(true, i);
|
||||
holder.selectCB.setChecked(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
holder.checkBoxRl.setVisibility(View.VISIBLE);
|
||||
holder.checkBoxRl.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (selectPosition.get(i)) {
|
||||
checkBoxControl(false, i);
|
||||
holder.selectCB.setChecked(false);
|
||||
} else {
|
||||
checkBoxControl(true, i);
|
||||
holder.selectCB.setChecked(true);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void checkBoxControl(boolean isChecked, int i) {
|
||||
if (isChecked) {
|
||||
selectPosition.put(i, true);
|
||||
} else {
|
||||
selectPosition.put(i, false);
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
for (Integer integer : selectPosition.keySet()) {
|
||||
if (selectPosition.get(integer)) {
|
||||
count ++;
|
||||
}
|
||||
}
|
||||
|
||||
if (count == 0) {
|
||||
mSelectCount.setText("发送");
|
||||
} else {
|
||||
mSelectCount.setText("发送("+ count +")");
|
||||
}
|
||||
}
|
||||
|
||||
public List<FileInfo> getSelectData() {
|
||||
List<FileInfo> fileInfos = new ArrayList<>();
|
||||
long l = System.currentTimeMillis();
|
||||
for (int i = 0; i < selectPosition.keySet().size(); i++) {
|
||||
if (selectPosition.get(i) != null && selectPosition.get(i)) {
|
||||
InstallGameEntity installGameEntity;
|
||||
if (i + 1 <= gameList.size()) {
|
||||
installGameEntity = gameList.get(i);
|
||||
} else {
|
||||
installGameEntity = apkList.get(i - gameList.size() - 1);
|
||||
}
|
||||
Utils.log("======" + installGameEntity.getGameName());
|
||||
FileInfo fileInfo = new FileInfo();
|
||||
fileInfo.setName(installGameEntity.getGameName());
|
||||
fileInfo.setFilePath(installGameEntity.getGamePath());
|
||||
fileInfo.setSize(installGameEntity.getGameSize());
|
||||
fileInfo.setBitmap(installGameEntity.getGameBm());
|
||||
fileInfo.setPackageName(installGameEntity.getPackageName());
|
||||
fileInfo.setFileTag(String.valueOf(l + i));
|
||||
fileInfos.add(fileInfo);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return fileInfos;
|
||||
}
|
||||
|
||||
public void setSelectPosition(HashMap<Integer, Boolean> selectPosition) {
|
||||
this.selectPosition = selectPosition;
|
||||
}
|
||||
|
||||
public int getGameSize() {
|
||||
return gameList.size();
|
||||
}
|
||||
|
||||
public int getAppSize() {
|
||||
return apkList.size();
|
||||
}
|
||||
|
||||
public class TitleViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
public TitleViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -13,6 +13,7 @@ import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.ImageUtils;
|
||||
import com.gh.common.util.LibaoUtils;
|
||||
import com.gh.common.util.PlatformUtils;
|
||||
import com.gh.gamecenter.LibaoDetailActivity;
|
||||
@ -189,7 +190,8 @@ public class LibaoDetailAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
|
||||
, LinearLayout.LayoutParams.WRAP_CONTENT);
|
||||
params.setMargins(0, DisplayUtils.dip2px(mContext, 5),0,0);
|
||||
holder.itemView.setLayoutParams(params);
|
||||
holder.libaoGameIcon.setImageURI(mLibaoEntity.getIcon());
|
||||
// holder.libaoGameIcon.setImageURI(mLibaoEntity.getIcon());
|
||||
ImageUtils.display(holder.libaoGameIcon, mLibaoEntity.getIcon());
|
||||
holder.libaoName.setText(mLibaoEntity.getName());
|
||||
if (TextUtils.isEmpty(mLibaoEntity.getPlatform())) {
|
||||
holder.libaoGameName.setText(mLibaoEntity.getGame().getName());
|
||||
|
||||
@ -5,6 +5,7 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Color;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.text.Html;
|
||||
@ -21,6 +22,7 @@ import com.gh.common.util.ConcernContentUtils;
|
||||
import com.gh.common.util.DataCollectionUtils;
|
||||
import com.gh.common.util.DataUtils;
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.ImageUtils;
|
||||
import com.gh.common.util.NewsUtils;
|
||||
import com.gh.common.util.PostCommentUtils;
|
||||
import com.gh.common.util.TimestampUtils;
|
||||
@ -369,7 +371,8 @@ public class MessageDetailAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
mContext.getResources().getDisplayMetrics().widthPixels - DisplayUtils.dip2px(mContext, 34));
|
||||
}
|
||||
|
||||
viewHolder.thumb.setImageURI(mConcernEntity.getGameIcon());
|
||||
// viewHolder.thumb.setImageURI(mConcernEntity.getGameIcon());
|
||||
ImageUtils.display(viewHolder.thumb, mConcernEntity.getGameIcon());
|
||||
viewHolder.title.setText(mConcernEntity.getGameName());
|
||||
NewsUtils.setNewsPublishOn(viewHolder.time, mConcernEntity.getTime());
|
||||
|
||||
@ -523,13 +526,15 @@ public class MessageDetailAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
if (userName != null && userIcon != null && !userIcon.isEmpty()&&
|
||||
!userIcon.isEmpty() && mCommentDao.isMyComment(commentEntity.getId())){
|
||||
holder.commentUserNameTv.setText(sp.getString("user_name", null));
|
||||
holder.commentUserIconDv.setImageURI(sp.getString("user_icon", null));
|
||||
// holder.commentUserIconDv.setImageURI(sp.getString("user_icon", null));
|
||||
ImageUtils.display(holder.commentUserIconDv, sp.getString("user_icon", null));
|
||||
} else {
|
||||
holder.commentUserNameTv.setText(commentEntity.getUser().getName());
|
||||
if(commentEntity.getUser().getIcon().isEmpty()) {
|
||||
holder.commentUserIconDv.setImageURI("res:///" + R.drawable.user_default_icon_comment);
|
||||
holder.commentUserIconDv.setImageURI(Uri.parse("res:///" + R.drawable.user_default_icon_comment));
|
||||
} else {
|
||||
holder.commentUserIconDv.setImageURI(commentEntity.getUser().getIcon());
|
||||
// holder.commentUserIconDv.setImageURI(commentEntity.getUser().getIcon());
|
||||
ImageUtils.display(holder.commentUserIconDv, commentEntity.getUser().getIcon());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -26,6 +26,7 @@ import com.gh.common.util.DataUtils;
|
||||
import com.gh.common.util.DialogUtils;
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.FileUtils;
|
||||
import com.gh.common.util.ImageUtils;
|
||||
import com.gh.common.util.NetworkUtils;
|
||||
import com.gh.common.util.PackageUtils;
|
||||
import com.gh.common.util.PlatformUtils;
|
||||
@ -138,6 +139,7 @@ public class PlatformAdapter extends RecyclerView.Adapter<PlatformViewHolder> {
|
||||
|| "更新下载中".equals(status)) {
|
||||
// 打开下载管理界面
|
||||
Intent intent = new Intent(context, DownloadManagerActivity.class);
|
||||
intent.putExtra("currentItem", 1);
|
||||
intent.putExtra("url", apkEntity.getUrl());
|
||||
intent.putExtra("entrance", entrance + "(" + location.split(":")[0] + ")");
|
||||
context.startActivity(intent);
|
||||
@ -246,7 +248,7 @@ public class PlatformAdapter extends RecyclerView.Adapter<PlatformViewHolder> {
|
||||
apkEntity.getPlatform());
|
||||
if (id != 0) {
|
||||
viewHolder.download_item_iv_pic.setVisibility(View.VISIBLE);
|
||||
viewHolder.download_item_iv_pic.setImageURI("res:///" + id);
|
||||
viewHolder.download_item_iv_pic.setImageURI(Uri.parse("res:///" + id));
|
||||
viewHolder.download_item_tv_hint.setVisibility(View.GONE);
|
||||
viewHolder.download_item_progressbar.setVisibility(View.GONE);
|
||||
viewHolder.download_item_tv_name.setVisibility(View.GONE);
|
||||
@ -257,8 +259,6 @@ public class PlatformAdapter extends RecyclerView.Adapter<PlatformViewHolder> {
|
||||
.getPlatformPicPath(apkEntity.getPlatform());
|
||||
if (path != null) {
|
||||
viewHolder.download_item_iv_pic.setVisibility(View.VISIBLE);
|
||||
// ImageUtils.getInstance(context).display(
|
||||
// "file://" + path, viewHolder.download_item_iv_pic);
|
||||
viewHolder.download_item_iv_pic.setImageURI(Uri.fromFile(new File(path)));
|
||||
viewHolder.download_item_tv_hint.setVisibility(View.GONE);
|
||||
viewHolder.download_item_progressbar.setVisibility(View.GONE);
|
||||
@ -315,9 +315,8 @@ public class PlatformAdapter extends RecyclerView.Adapter<PlatformViewHolder> {
|
||||
viewHolder.download_item_tv_status.setVisibility(View.GONE);
|
||||
viewHolder.itemView.setBackgroundColor(0x00ffffff);
|
||||
|
||||
// ImageUtils.getInstance(context).display(
|
||||
// apkEntity.getApkCollection().getIcon(), viewHolder.download_item_iv_pic);
|
||||
viewHolder.download_item_iv_pic.setImageURI(apkEntity.getApkCollection().getIcon());
|
||||
// viewHolder.download_item_iv_pic.setImageURI(apkEntity.getApkCollection().getIcon());
|
||||
ImageUtils.display(viewHolder.download_item_iv_pic, apkEntity.getApkCollection().getIcon());
|
||||
if (closeEntity.getPosition() == position && adapterPosition == closeEntity.getAdapterPosition()) {
|
||||
viewHolder.download_item_open_collection.setVisibility(View.GONE);
|
||||
viewHolder.download_item_colse_collection.setVisibility(View.VISIBLE);
|
||||
|
||||
@ -13,6 +13,7 @@ import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.DownloadItemUtils;
|
||||
import com.gh.common.util.GameUtils;
|
||||
import com.gh.common.util.GameViewUtils;
|
||||
import com.gh.common.util.ImageUtils;
|
||||
import com.gh.common.util.PlatformUtils;
|
||||
import com.gh.common.view.CardLinearLayout;
|
||||
import com.gh.download.DownloadManager;
|
||||
@ -154,21 +155,22 @@ public class PluginAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||
|
||||
final GameEntity gameEntity = pluginList.get(position);
|
||||
|
||||
viewHolder.home1_game_order.setVisibility(View.GONE);
|
||||
viewHolder.gameOrder.setVisibility(View.GONE);
|
||||
|
||||
viewHolder.gameThumb.setImageURI(gameEntity.getIcon());
|
||||
// viewHolder.gameThumb.setImageURI(gameEntity.getIcon());
|
||||
ImageUtils.display(viewHolder.gameThumb, gameEntity.getIcon());
|
||||
if (gameEntity.isPluggable()) {
|
||||
viewHolder.gameNameAndSize.setText(gameEntity.getName() + " - " +
|
||||
viewHolder.gameName.setText(gameEntity.getName() + " - " +
|
||||
PlatformUtils.getInstance(context).getPlatformName(gameEntity.getApk().get(0).getPlatform()));
|
||||
} else {
|
||||
viewHolder.gameNameAndSize.setText(gameEntity.getName());
|
||||
viewHolder.gameName.setText(gameEntity.getName());
|
||||
}
|
||||
if (gameEntity.getApk() == null || gameEntity.getApk().isEmpty()) {
|
||||
viewHolder.gameDes.setText(gameEntity.getBrief());
|
||||
} else {
|
||||
viewHolder.gameDes.setText(gameEntity.getApk().get(0).getSize() + " " + gameEntity.getBrief());
|
||||
}
|
||||
GameViewUtils.setLabelList(context, viewHolder.labelList, gameEntity.getTag());
|
||||
GameViewUtils.setLabelList(context, viewHolder.gameLabelList, gameEntity.getTag());
|
||||
|
||||
viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
@ -184,12 +186,10 @@ public class PluginAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||
}
|
||||
});
|
||||
|
||||
DownloadItemUtils.setOnClickListener(context, viewHolder.downloadBtn, gameEntity, position,
|
||||
DownloadItemUtils.setOnClickListener(context, viewHolder.gameDownloadBtn, gameEntity, position,
|
||||
PluginAdapter.this, entrance + "+(插件化[" + (viewHolder.getPosition() + 1) + "])", "插件化:" + gameEntity.getName(), false);
|
||||
|
||||
DownloadItemUtils.updateItem(context, viewHolder.gameDes,
|
||||
viewHolder.game_progressbar, viewHolder.game_ll_info, viewHolder.download_speed,
|
||||
viewHolder.download_percentage, viewHolder.downloadBtn, gameEntity, false);
|
||||
DownloadItemUtils.updateItem(context, gameEntity, viewHolder, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -16,6 +16,7 @@ import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.DownloadItemUtils;
|
||||
import com.gh.common.util.GameUtils;
|
||||
import com.gh.common.util.GameViewUtils;
|
||||
import com.gh.common.util.ImageUtils;
|
||||
import com.gh.common.view.CardLinearLayout;
|
||||
import com.gh.download.DownloadManager;
|
||||
import com.gh.gamecenter.R;
|
||||
@ -24,7 +25,6 @@ import com.gh.gamecenter.adapter.viewholder.FooterViewHolder;
|
||||
import com.gh.gamecenter.adapter.viewholder.GameImageViewHolder;
|
||||
import com.gh.gamecenter.adapter.viewholder.GameNormalViewHolder;
|
||||
import com.gh.gamecenter.adapter.viewholder.GameTestViewHolder;
|
||||
import com.gh.gamecenter.db.LibaoDao;
|
||||
import com.gh.gamecenter.entity.ApkEntity;
|
||||
import com.gh.gamecenter.entity.GameEntity;
|
||||
import com.gh.gamecenter.listener.OnCallBackListener;
|
||||
@ -53,8 +53,6 @@ public class SubjectAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
||||
|
||||
private ArrayMap<String, ArrayList<Integer>> locationMap;
|
||||
|
||||
private LibaoDao libaoDao;
|
||||
|
||||
private String id;
|
||||
private String name;
|
||||
private String entrance;
|
||||
@ -85,7 +83,6 @@ public class SubjectAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
||||
subjectList = new ArrayList<>();
|
||||
isLoaded = false;
|
||||
isNetworkError = false;
|
||||
libaoDao = new LibaoDao(context);
|
||||
|
||||
initList(1);
|
||||
}
|
||||
@ -241,7 +238,8 @@ public class SubjectAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
||||
initFooterViewHolder((FooterViewHolder) viewHolder);
|
||||
} else if (viewHolder instanceof GameImageViewHolder) {
|
||||
GameImageViewHolder holder = ((GameImageViewHolder) viewHolder);
|
||||
holder.image.setImageURI(subjectList.get(position).getToutu());
|
||||
// holder.image.setImageURI(subjectList.get(position).getToutu());
|
||||
ImageUtils.display(holder.image, subjectList.get(position).getToutu());
|
||||
((CardLinearLayout) holder.itemView).setmTop(DisplayUtils.dip2px(context, 8));
|
||||
((CardLinearLayout) holder.itemView).setmBottom(DisplayUtils.dip2px(context, 8));
|
||||
}
|
||||
@ -294,22 +292,17 @@ public class SubjectAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
||||
if (subjectList.get(0).getToutu() != null) {
|
||||
index = 0;
|
||||
}
|
||||
holder.home2_game_order.setVisibility(View.VISIBLE);
|
||||
holder.home2_game_order.setText(String.valueOf(position + index));
|
||||
holder.gameOrder.setVisibility(View.VISIBLE);
|
||||
holder.gameOrder.setText(String.valueOf(position + index));
|
||||
} else {
|
||||
holder.home2_game_order.setVisibility(View.GONE);
|
||||
holder.gameOrder.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
final GameEntity gameEntity = subjectList.get(position);
|
||||
|
||||
if (gameEntity.isLibaoExists()) {
|
||||
holder.libaoIcon.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
holder.libaoIcon.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
holder.gameThumb.setImageURI(gameEntity.getIcon());
|
||||
holder.gameNameAndSize.setText(gameEntity.getName());
|
||||
// holder.gameThumb.setImageURI(gameEntity.getIcon());
|
||||
ImageUtils.display(holder.gameThumb, gameEntity.getIcon());
|
||||
holder.gameName.setText(gameEntity.getName());
|
||||
if (gameEntity.getApk() == null || gameEntity.getApk().isEmpty()) {
|
||||
holder.gameDes.setText(gameEntity.getBrief());
|
||||
} else {
|
||||
@ -346,12 +339,10 @@ public class SubjectAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
||||
}
|
||||
|
||||
DownloadItemUtils.setOnClickListener(context,
|
||||
holder.downloadBtn, gameEntity, position,
|
||||
holder.gameDownloadBtn, gameEntity, position,
|
||||
SubjectAdapter.this, entrance + "+(" + name + "[" + (holder.getPosition() + 1) + "])", name + ":" + gameEntity.getName(), false);
|
||||
|
||||
DownloadItemUtils.updateItem(context, holder.gameDes,
|
||||
holder.game_progressbar, holder.game_ll_info, holder.download_speed,
|
||||
holder.download_percentage, holder.downloadBtn, gameEntity);
|
||||
DownloadItemUtils.updateItem(context, gameEntity, holder, true);
|
||||
}
|
||||
|
||||
private void initGameNormalViewHolder(final GameNormalViewHolder holder, int position) {
|
||||
@ -375,33 +366,24 @@ public class SubjectAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
||||
if (subjectList.get(0).getToutu() != null) {
|
||||
index = 0;
|
||||
}
|
||||
holder.home1_game_order.setVisibility(View.VISIBLE);
|
||||
holder.home1_game_order.setText(String.valueOf(position + index));
|
||||
holder.gameOrder.setVisibility(View.VISIBLE);
|
||||
holder.gameOrder.setText(String.valueOf(position + index));
|
||||
} else {
|
||||
holder.home1_game_order.setVisibility(View.GONE);
|
||||
holder.gameOrder.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
final GameEntity gameEntity = subjectList.get(position);
|
||||
|
||||
if (libaoDao.isExist(gameEntity.getId())) {
|
||||
holder.libaoIcon.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
if (gameEntity.isLibaoExists()) {
|
||||
holder.libaoIcon.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
holder.libaoIcon.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
holder.gameThumb.setImageURI(gameEntity.getIcon());
|
||||
holder.gameNameAndSize.setText(gameEntity.getName());
|
||||
// holder.gameThumb.setImageURI(gameEntity.getIcon());
|
||||
ImageUtils.display(holder.gameThumb, gameEntity.getIcon());
|
||||
holder.gameName.setText(gameEntity.getName());
|
||||
if (gameEntity.getApk() == null || gameEntity.getApk().isEmpty()) {
|
||||
holder.gameDes.setText(gameEntity.getBrief());
|
||||
} else {
|
||||
holder.gameDes.setText(String.format("%s %s", gameEntity.getApk().get(0).getSize(), gameEntity.getBrief()));
|
||||
}
|
||||
|
||||
GameViewUtils.setLabelList(context, holder.labelList, gameEntity.getTag());
|
||||
GameViewUtils.setLabelList(context, holder.gameLabelList, gameEntity.getTag());
|
||||
|
||||
holder.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
@ -417,13 +399,10 @@ public class SubjectAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
||||
}
|
||||
});
|
||||
|
||||
DownloadItemUtils.setOnClickListener(context, holder.downloadBtn,
|
||||
DownloadItemUtils.setOnClickListener(context, holder.gameDownloadBtn,
|
||||
gameEntity, position, this, entrance + "+(" + name + "[" + (holder.getPosition() + 1) + "])", name + ":" + gameEntity.getName(), false);
|
||||
|
||||
DownloadItemUtils.updateItem(context, holder.gameDes,
|
||||
holder.game_progressbar, holder.game_ll_info,
|
||||
holder.download_speed, holder.download_percentage,
|
||||
holder.downloadBtn, gameEntity);
|
||||
DownloadItemUtils.updateItem(context, gameEntity, holder, true);
|
||||
}
|
||||
|
||||
public List<GameEntity> getSubjectList() {
|
||||
|
||||
@ -2,6 +2,7 @@ package com.gh.gamecenter.adapter.viewholder;
|
||||
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.facebook.drawee.view.SimpleDraweeView;
|
||||
@ -15,6 +16,7 @@ public class ConcernViewHolder extends RecyclerView.ViewHolder {
|
||||
public SimpleDraweeView concern_item_icon;
|
||||
public TextView concern_item_name;
|
||||
public TextView concern_item_concern;
|
||||
public ImageView concern_libao_icon;
|
||||
|
||||
public ConcernViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
@ -22,6 +24,7 @@ public class ConcernViewHolder extends RecyclerView.ViewHolder {
|
||||
concern_item_icon = (SimpleDraweeView) itemView.findViewById(R.id.concern_item_icon);
|
||||
concern_item_name = (TextView) itemView.findViewById(R.id.concern_item_name);
|
||||
concern_item_concern = (TextView) itemView.findViewById(R.id.concern_item_concern);
|
||||
concern_libao_icon = (ImageView) itemView.findViewById(R.id.concern_libao_icon);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,46 @@
|
||||
package com.gh.gamecenter.adapter.viewholder;
|
||||
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.facebook.drawee.view.SimpleDraweeView;
|
||||
import com.gh.common.view.CardLinearLayout;
|
||||
import com.gh.common.view.SwipeLayout;
|
||||
import com.gh.gamecenter.R;
|
||||
|
||||
import static com.gh.gamecenter.R.id.home1_game_order;
|
||||
|
||||
/**
|
||||
* Created by LGT on 2016/7/2.
|
||||
*/
|
||||
public class GameNormalSwipeViewHolder extends GameViewHolder {
|
||||
|
||||
public CardLinearLayout cardView;
|
||||
public SwipeLayout swipeLayout;
|
||||
public TextView swipeText;
|
||||
public TextView swipeShareText;
|
||||
|
||||
public GameNormalSwipeViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
|
||||
gameLibaoIcon = (ImageView) itemView.findViewById(R.id.home1_game_libao);
|
||||
gameOrder = (TextView) itemView.findViewById(home1_game_order);
|
||||
gameThumb = (SimpleDraweeView) itemView.findViewById(R.id.home1_game_thumb);
|
||||
gameName = (TextView) itemView.findViewById(R.id.home1_game_nameAndsize);
|
||||
gameDownloadBtn = (TextView) itemView.findViewById(R.id.home1_download_btn);
|
||||
gameDes = (TextView) itemView.findViewById(R.id.home1_game_des);
|
||||
gameLabelList = (LinearLayout) itemView.findViewById(R.id.home1_label_list);
|
||||
gameInfo = (LinearLayout) itemView.findViewById(R.id.home1_game_ll_info);
|
||||
gameProgressbar = (ProgressBar) itemView.findViewById(R.id.home1_game_progressbar);
|
||||
gameDownloadSpeed = (TextView) itemView.findViewById(R.id.home1_download_speed);
|
||||
gameDownloadPercentage = (TextView) itemView.findViewById(R.id.home1_download_percentage);
|
||||
cardView = (CardLinearLayout) itemView.findViewById(R.id.home1_game_card);
|
||||
swipeLayout = (SwipeLayout) itemView.findViewById(R.id.swipeLayout);
|
||||
swipeText = (TextView) itemView.findViewById(R.id.swipe_text);
|
||||
swipeShareText = (TextView) itemView.findViewById(R.id.swipe_share_text);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,6 +1,5 @@
|
||||
package com.gh.gamecenter.adapter.viewholder;
|
||||
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
@ -10,37 +9,25 @@ import android.widget.TextView;
|
||||
import com.facebook.drawee.view.SimpleDraweeView;
|
||||
import com.gh.gamecenter.R;
|
||||
|
||||
/**
|
||||
* Created by LGT on 2016/7/2.
|
||||
*/
|
||||
public class GameNormalViewHolder extends RecyclerView.ViewHolder {
|
||||
import static com.gh.gamecenter.R.id.home1_game_order;
|
||||
|
||||
public TextView home1_game_order;
|
||||
public SimpleDraweeView gameThumb;
|
||||
public TextView gameNameAndSize;
|
||||
public TextView downloadBtn;
|
||||
public TextView gameDes;
|
||||
public LinearLayout labelList;
|
||||
public ProgressBar game_progressbar;
|
||||
public LinearLayout game_ll_info;
|
||||
public TextView download_speed;
|
||||
public TextView download_percentage;
|
||||
public ImageView libaoIcon;
|
||||
|
||||
public class GameNormalViewHolder extends GameViewHolder {
|
||||
|
||||
public GameNormalViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
|
||||
home1_game_order = (TextView) itemView.findViewById(R.id.home1_game_order);
|
||||
gameLibaoIcon = (ImageView) itemView.findViewById(R.id.home1_game_libao);
|
||||
gameOrder = (TextView) itemView.findViewById(home1_game_order);
|
||||
gameThumb = (SimpleDraweeView) itemView.findViewById(R.id.home1_game_thumb);
|
||||
gameNameAndSize = (TextView) itemView.findViewById(R.id.home1_game_nameAndsize);
|
||||
downloadBtn = (TextView) itemView.findViewById(R.id.home1_download_btn);
|
||||
gameName = (TextView) itemView.findViewById(R.id.home1_game_nameAndsize);
|
||||
gameDownloadBtn = (TextView) itemView.findViewById(R.id.home1_download_btn);
|
||||
gameDes = (TextView) itemView.findViewById(R.id.home1_game_des);
|
||||
labelList = (LinearLayout) itemView.findViewById(R.id.home1_label_list);
|
||||
game_ll_info = (LinearLayout) itemView.findViewById(R.id.home1_game_ll_info);
|
||||
game_progressbar = (ProgressBar) itemView.findViewById(R.id.home1_game_progressbar);
|
||||
download_speed = (TextView) itemView.findViewById(R.id.home1_download_speed);
|
||||
download_percentage = (TextView) itemView.findViewById(R.id.home1_download_percentage);
|
||||
libaoIcon = (ImageView) itemView.findViewById(R.id.home1_game_libao);
|
||||
gameLabelList = (LinearLayout) itemView.findViewById(R.id.home1_label_list);
|
||||
gameInfo = (LinearLayout) itemView.findViewById(R.id.home1_game_ll_info);
|
||||
gameProgressbar = (ProgressBar) itemView.findViewById(R.id.home1_game_progressbar);
|
||||
gameDownloadSpeed = (TextView) itemView.findViewById(R.id.home1_download_speed);
|
||||
gameDownloadPercentage = (TextView) itemView.findViewById(R.id.home1_download_percentage);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
package com.gh.gamecenter.adapter.viewholder;
|
||||
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
@ -10,40 +9,30 @@ import android.widget.TextView;
|
||||
import com.facebook.drawee.view.SimpleDraweeView;
|
||||
import com.gh.gamecenter.R;
|
||||
|
||||
/**
|
||||
* Created by LGT on 2016/7/2.
|
||||
*/
|
||||
public class GameTestViewHolder extends RecyclerView.ViewHolder {
|
||||
import static com.gh.gamecenter.R.id.home2_game_order;
|
||||
|
||||
|
||||
public class GameTestViewHolder extends GameViewHolder {
|
||||
|
||||
public TextView home2_game_order;
|
||||
public SimpleDraweeView gameThumb;
|
||||
public TextView gameNameAndSize;
|
||||
public TextView downloadBtn;
|
||||
public TextView gameDes;
|
||||
public TextView gameTestType;
|
||||
public TextView gameTestTime;
|
||||
public LinearLayout labelList;
|
||||
public ProgressBar game_progressbar;
|
||||
public LinearLayout game_ll_info;
|
||||
public TextView download_speed;
|
||||
public TextView download_percentage;
|
||||
public ImageView libaoIcon;
|
||||
|
||||
public GameTestViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
|
||||
home2_game_order = (TextView) itemView.findViewById(R.id.home2_game_order);
|
||||
gameLibaoIcon = (ImageView) itemView.findViewById(R.id.home2_game_libao);
|
||||
gameOrder = (TextView) itemView.findViewById(home2_game_order);
|
||||
gameThumb = (SimpleDraweeView) itemView.findViewById(R.id.home2_game_thumb);
|
||||
gameNameAndSize = (TextView) itemView.findViewById(R.id.home2_game_nameAndsize);
|
||||
downloadBtn = (TextView) itemView.findViewById(R.id.home2_download_btn);
|
||||
gameName = (TextView) itemView.findViewById(R.id.home2_game_nameAndsize);
|
||||
gameDownloadBtn = (TextView) itemView.findViewById(R.id.home2_download_btn);
|
||||
gameDes = (TextView) itemView.findViewById(R.id.home2_game_des);
|
||||
gameLabelList = (LinearLayout) itemView.findViewById(R.id.home2_label_list);
|
||||
gameTestType = (TextView) itemView.findViewById(R.id.home2_test_type);
|
||||
gameTestTime = (TextView) itemView.findViewById(R.id.home2_test_time);
|
||||
game_ll_info = (LinearLayout) itemView.findViewById(R.id.home2_game_ll_info);
|
||||
game_progressbar = (ProgressBar) itemView.findViewById(R.id.home2_game_progressbar);
|
||||
download_speed = (TextView) itemView.findViewById(R.id.home2_download_speed);
|
||||
download_percentage = (TextView) itemView.findViewById(R.id.home2_download_percentage);
|
||||
libaoIcon = (ImageView) itemView.findViewById(R.id.home2_game_libao);
|
||||
gameInfo = (LinearLayout) itemView.findViewById(R.id.home2_game_ll_info);
|
||||
gameProgressbar = (ProgressBar) itemView.findViewById(R.id.home2_game_progressbar);
|
||||
gameDownloadSpeed = (TextView) itemView.findViewById(R.id.home2_download_speed);
|
||||
gameDownloadPercentage = (TextView) itemView.findViewById(R.id.home2_download_percentage);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,31 @@
|
||||
package com.gh.gamecenter.adapter.viewholder;
|
||||
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.facebook.drawee.view.SimpleDraweeView;
|
||||
|
||||
|
||||
public class GameViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
public ImageView gameLibaoIcon;
|
||||
public TextView gameOrder;
|
||||
public SimpleDraweeView gameThumb;
|
||||
public TextView gameName;
|
||||
public TextView gameDownloadBtn;
|
||||
public TextView gameDes;
|
||||
public LinearLayout gameLabelList;
|
||||
public LinearLayout gameInfo;
|
||||
public ProgressBar gameProgressbar;
|
||||
public TextView gameDownloadSpeed;
|
||||
public TextView gameDownloadPercentage;
|
||||
|
||||
public GameViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,41 @@
|
||||
package com.gh.gamecenter.adapter.viewholder;
|
||||
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gh.gamecenter.R;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
/**
|
||||
* Created by khy on 2017/1/20.
|
||||
*/
|
||||
public class KcSelectGameViewHolder extends RecyclerView.ViewHolder{
|
||||
|
||||
@BindView(R.id.select_game_order) public TextView gameOrder;
|
||||
@BindView(R.id.select_game_thumb) public ImageView gameThumb;
|
||||
@BindView(R.id.select_game_nameAndsize) public TextView gameNameAndSize;
|
||||
@BindView(R.id.select_game_btn) public CheckBox selectCB;
|
||||
@BindView(R.id.select_game_des) public TextView gameDes;
|
||||
@BindView(R.id.select_game_size) public TextView gameSize;
|
||||
@BindView(R.id.select_game_progressbar) public ProgressBar gameProgressbar;
|
||||
@BindView(R.id.select_game_ll_info) public LinearLayout gameLlInfo;
|
||||
@BindView(R.id.select_status_btn) public TextView downloadStatus;
|
||||
@BindView(R.id.download_percentage) public TextView downloadPercentage;
|
||||
@BindView(R.id.select_download_speed) public TextView downloadSpeed;
|
||||
@BindView(R.id.send_over_icon) public ImageView sendOverIcon;
|
||||
@BindView(R.id.select_game_rl) public RelativeLayout selectGameRl;
|
||||
@BindView(R.id.select_game_cb_rl) public RelativeLayout checkBoxRl;
|
||||
|
||||
public KcSelectGameViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
ButterKnife.bind(this, itemView);
|
||||
}
|
||||
}
|
||||
@ -12,6 +12,7 @@ import com.gh.gamecenter.db.info.DataCollectionInfo;
|
||||
import com.gh.gamecenter.db.info.FilterInfo;
|
||||
import com.gh.gamecenter.db.info.GameInfo;
|
||||
import com.gh.gamecenter.db.info.LibaoInfo;
|
||||
import com.gh.gamecenter.db.info.PackageInfo;
|
||||
import com.gh.gamecenter.db.info.SearchHistoryInfo;
|
||||
import com.gh.gamecenter.db.info.VoteInfo;
|
||||
import com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper;
|
||||
@ -24,10 +25,10 @@ import java.sql.SQLException;
|
||||
public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||
|
||||
private static final String DATABASE_NAME = "gh_assist.db";
|
||||
private static final int DATABASE_VERSION = 4;
|
||||
private static final int DATABASE_VERSION = 5;
|
||||
|
||||
private static DatabaseHelper instance;
|
||||
private ArrayMap<String, Dao> daos = new ArrayMap<String, Dao>();
|
||||
private ArrayMap<String, Dao> daos = new ArrayMap<>();
|
||||
|
||||
private DatabaseHelper(Context context) {
|
||||
super(context, DATABASE_NAME, null, DATABASE_VERSION);
|
||||
@ -52,32 +53,27 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(SQLiteDatabase database,
|
||||
ConnectionSource connectionSource) {
|
||||
|
||||
public void onCreate(SQLiteDatabase database, ConnectionSource connectionSource) {
|
||||
try {
|
||||
Utils.log("onCreate");
|
||||
Utils.log("DatabaseHelper onCreate");
|
||||
TableUtils.createTable(connectionSource, ConcernInfo.class);
|
||||
TableUtils.createTable(connectionSource, SearchHistoryInfo.class);
|
||||
TableUtils.createTable(connectionSource, GameInfo.class);
|
||||
TableUtils.createTable(connectionSource, FilterInfo.class);
|
||||
TableUtils.createTable(connectionSource, DataCollectionInfo.class);
|
||||
TableUtils.createTable(connectionSource, VoteInfo.class);
|
||||
TableUtils.createTable(connectionSource, CommentInfo.class);
|
||||
TableUtils.createTable(connectionSource, LibaoInfo.class);
|
||||
TableUtils.createTable(connectionSource, AppRunTimeInfo.class);
|
||||
TableUtils.createTable(connectionSource, PackageInfo.class);
|
||||
} catch (SQLException e) {
|
||||
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpgrade(SQLiteDatabase database,
|
||||
ConnectionSource connectionSource, int oldVersion, int newVersion) {
|
||||
|
||||
public void onUpgrade(SQLiteDatabase database, ConnectionSource connectionSource, int oldVersion, int newVersion) {
|
||||
try {
|
||||
Utils.log("onUpgrade");
|
||||
Utils.log("DatabaseHelper onUpgrade");
|
||||
TableUtils.dropTable(connectionSource, ConcernInfo.class, true);
|
||||
TableUtils.dropTable(connectionSource, SearchHistoryInfo.class, true);
|
||||
TableUtils.dropTable(connectionSource, GameInfo.class, true);
|
||||
@ -87,9 +83,9 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||
TableUtils.dropTable(connectionSource, CommentInfo.class, true);
|
||||
TableUtils.dropTable(connectionSource, LibaoInfo.class, true);
|
||||
TableUtils.dropTable(connectionSource, AppRunTimeInfo.class, true);
|
||||
TableUtils.dropTable(connectionSource, PackageInfo.class, true);
|
||||
onCreate(database, connectionSource);
|
||||
} catch (SQLException e) {
|
||||
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,60 +2,79 @@ package com.gh.gamecenter.db;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.gh.gamecenter.db.info.FilterInfo;
|
||||
import com.gh.gamecenter.db.info.PackageInfo;
|
||||
import com.j256.ormlite.dao.Dao;
|
||||
import com.j256.ormlite.stmt.QueryBuilder;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
public class FilterDao {
|
||||
|
||||
|
||||
private DatabaseHelper helper;
|
||||
private Dao<FilterInfo, String> dao;
|
||||
private Dao<PackageInfo, String> dao;
|
||||
|
||||
public FilterDao(Context context) {
|
||||
try {
|
||||
helper = DatabaseHelper.getHelper(context);
|
||||
dao = helper.getDao(FilterInfo.class);
|
||||
dao = helper.getDao(PackageInfo.class);
|
||||
} catch (SQLException e) {
|
||||
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public long getSince() {
|
||||
try {
|
||||
QueryBuilder<PackageInfo, String> builder = dao.queryBuilder();
|
||||
builder.orderBy("time", false).limit(1L);
|
||||
List<PackageInfo> list = builder.query();
|
||||
if (list != null && list.size() != 0) {
|
||||
return list.get(0).getTime();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public boolean isFilter(String packageName){
|
||||
try {
|
||||
FilterInfo filterEntity = dao.queryForId(packageName);
|
||||
PackageInfo filterEntity = dao.queryForId(packageName);
|
||||
if (filterEntity != null) {
|
||||
return true;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 添加一个过滤包名
|
||||
*/
|
||||
public void add(FilterInfo entity) {
|
||||
public void add(PackageInfo entity) {
|
||||
try {
|
||||
dao.create(entity);
|
||||
} catch (SQLException e) {
|
||||
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 添加一堆过滤包名
|
||||
*/
|
||||
public void addAll(List<FilterInfo> list) {
|
||||
public void addAll(List<PackageInfo> list) {
|
||||
try {
|
||||
dao.create(list);
|
||||
} catch (SQLException e) {
|
||||
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteAll(List<PackageInfo> list) {
|
||||
try {
|
||||
dao.delete(list);
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@ -67,7 +86,6 @@ public class FilterDao {
|
||||
try {
|
||||
dao.deleteById(packageName);
|
||||
} catch (SQLException e) {
|
||||
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@ -75,16 +93,15 @@ public class FilterDao {
|
||||
/**
|
||||
* 获取所有的过滤包名
|
||||
*/
|
||||
public List<FilterInfo> getAll() {
|
||||
public List<PackageInfo> getAll() {
|
||||
try {
|
||||
return dao.queryForAll();
|
||||
} catch (SQLException e) {
|
||||
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取表中数据总数
|
||||
*/
|
||||
@ -92,10 +109,9 @@ public class FilterDao {
|
||||
try {
|
||||
return dao.countOf();
|
||||
} catch (SQLException e) {
|
||||
|
||||
e.printStackTrace();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -71,10 +71,9 @@ public class LibaoDao {
|
||||
|
||||
public boolean isExist(String gameId) {
|
||||
try {
|
||||
if (dao.queryBuilder().where().eq("gameId", gameId).query().size() > 0) {
|
||||
List<LibaoInfo> list = dao.queryBuilder().where().eq("gameId", gameId).query();
|
||||
if (list != null && list.size() > 0) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
42
app/src/main/java/com/gh/gamecenter/db/info/PackageInfo.java
Normal file
42
app/src/main/java/com/gh/gamecenter/db/info/PackageInfo.java
Normal file
@ -0,0 +1,42 @@
|
||||
package com.gh.gamecenter.db.info;
|
||||
|
||||
import com.j256.ormlite.field.DatabaseField;
|
||||
import com.j256.ormlite.table.DatabaseTable;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@DatabaseTable(tableName = "tb_package")
|
||||
public class PackageInfo implements Serializable {
|
||||
|
||||
@DatabaseField(id = true, columnName = "packageName")
|
||||
private String packageName;
|
||||
|
||||
@DatabaseField(columnName = "time")
|
||||
private long time;
|
||||
|
||||
public PackageInfo() {
|
||||
|
||||
}
|
||||
|
||||
public PackageInfo(String packageName, long time) {
|
||||
this.packageName = packageName;
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public String getPackageName() {
|
||||
return packageName;
|
||||
}
|
||||
|
||||
public void setPackageName(String packageName) {
|
||||
this.packageName = packageName;
|
||||
}
|
||||
|
||||
public long getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(long time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,91 @@
|
||||
package com.gh.gamecenter.download;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.text.Html;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gh.common.util.DialogUtils;
|
||||
import com.gh.gamecenter.CleanApkActivity;
|
||||
import com.gh.gamecenter.KcSelectGameActivity;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.ReceiverWaitingActivity;
|
||||
import com.gh.gamecenter.ShareGhActivity;
|
||||
|
||||
/**
|
||||
* Created by khy on 2017/1/20.
|
||||
*/
|
||||
public class FileSendFragment extends Fragment {
|
||||
|
||||
View view;
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(final LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
if (view == null) {
|
||||
view = inflater.inflate(R.layout.fragment_file_send, container, false);
|
||||
|
||||
view.findViewById(R.id.file_send_btn).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(getActivity(), KcSelectGameActivity.class);
|
||||
startActivityForResult(intent, 0x170);
|
||||
}
|
||||
});
|
||||
|
||||
view.findViewById(R.id.file_receiver_btn).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(getActivity(), ReceiverWaitingActivity.class);
|
||||
startActivityForResult(intent, 0x180);
|
||||
}
|
||||
});
|
||||
|
||||
TextView shareGh = (TextView) view.findViewById(R.id.share_gh);
|
||||
shareGh.setText(Html.fromHtml("<u>"+"好友还没安装光环助手?请点这里"+"</u>"));
|
||||
shareGh.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(getActivity(), ShareGhActivity.class);
|
||||
getActivity().startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
TextView cleanApk = (TextView) view.findViewById(R.id.clean_apk_tv);
|
||||
cleanApk.setText(Html.fromHtml("手机空间不足?试试 " +"<font color=\"#05c400\">"+"安装包清理"+"</font>"));
|
||||
|
||||
cleanApk.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(getActivity(), CleanApkActivity.class);
|
||||
getActivity().startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
|
||||
// 分享成绩单
|
||||
if (requestCode == 0x170 || requestCode == 0x180) {
|
||||
DialogUtils.showKuaiChuanResult(getActivity(), new Handler(),requestCode, "shareKc.jpg");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,7 @@
|
||||
package com.gh.gamecenter.download;
|
||||
|
||||
import android.app.NotificationManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Message;
|
||||
@ -294,9 +296,9 @@ public class GameDownLoadFragment extends Fragment implements View.OnClickListen
|
||||
if (location != null) {
|
||||
if ("安装".equals(busFour.getType())) {
|
||||
DownloadEntity downloadEntity = DownloadManager.getInstance(getActivity()).get(url);
|
||||
if (downloadEntity == null
|
||||
|| !downloadEntity.isPlugin() // 不是插件游戏,自己删除数据库数据和安装包
|
||||
|| PackageUtils.isSignature(getActivity(), packageName)) {// 是插件游戏,判断签名是否相同,是才删除数据库数据和安装包
|
||||
// if (downloadEntity == null
|
||||
// || !downloadEntity.isPlugin() // 不是插件游戏,自己删除数据库数据和安装包
|
||||
// || PackageUtils.isSignature(getActivity(), packageName)) {// 是插件游戏,判断签名是否相同,是才删除数据库数据和安装包
|
||||
if (adapter.getDownloadingList().isEmpty() && adapter.getDoneList().size() == 1) {
|
||||
adapter.getDoneList().remove(location.intValue());
|
||||
adapter.getLocationMap().clear();
|
||||
@ -318,15 +320,21 @@ public class GameDownLoadFragment extends Fragment implements View.OnClickListen
|
||||
EventBus.getDefault().post(new EBDownloadChanged("download", View.VISIBLE,
|
||||
adapter.getDoneList().size() + adapter.getDownloadingList().size()));
|
||||
}
|
||||
}
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ("安装".equals(busFour.getType())) {
|
||||
// 取消快传完成通知栏
|
||||
NotificationManager nManager = (NotificationManager) getContext().getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
nManager.cancel(packageName, 0x321);
|
||||
}
|
||||
}
|
||||
|
||||
public void onEventMainThread(EBUISwitch busNine) {
|
||||
if ("DownloadManagerActivity".equals(busNine.getFrom())) {
|
||||
if (busNine.getPosition() != 0) {
|
||||
if (busNine.getPosition() != 1) {
|
||||
adapter.getDeleteList().clear();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,10 @@
|
||||
package com.gh.gamecenter.download;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.graphics.Bitmap;
|
||||
import android.net.Uri;
|
||||
import android.os.Message;
|
||||
import android.support.v4.util.ArrayMap;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
@ -13,10 +17,12 @@ import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.gh.common.constant.Constants;
|
||||
import com.gh.common.util.BitmapUtils;
|
||||
import com.gh.common.util.DataUtils;
|
||||
import com.gh.common.util.DialogUtils;
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.FileUtils;
|
||||
import com.gh.common.util.ImageUtils;
|
||||
import com.gh.common.util.NetworkUtils;
|
||||
import com.gh.common.util.PackageUtils;
|
||||
import com.gh.common.util.PlatformUtils;
|
||||
@ -32,6 +38,9 @@ import com.gh.gamecenter.adapter.viewholder.GameDownloadViewHolder;
|
||||
import com.gh.gamecenter.eventbus.EBDownloadChanged;
|
||||
import com.gh.gamecenter.manager.PackageManager;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
@ -154,10 +163,29 @@ class GameDownloadFragmentAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
}
|
||||
|
||||
String icon = downloadEntity.getIcon();
|
||||
if (!TextUtils.isEmpty(icon)) {
|
||||
viewHolder.dm_item_iv_icon.setImageURI(icon);
|
||||
if (!TextUtils.isEmpty(icon) && icon.contains("KuaiChuanIcon")) { // 来自快传的apk
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject(icon);
|
||||
String apkPath = jsonObject.getString("KuaiChuanIcon");
|
||||
android.content.pm.PackageManager pm = context.getPackageManager();
|
||||
PackageInfo info = pm.getPackageArchiveInfo(apkPath,
|
||||
android.content.pm.PackageManager.GET_ACTIVITIES);
|
||||
if (info != null) {
|
||||
ApplicationInfo appInfo = info.applicationInfo;
|
||||
appInfo.sourceDir = apkPath;
|
||||
appInfo.publicSourceDir = apkPath;
|
||||
Bitmap bitmap = BitmapUtils.drawableToBitmap(appInfo.loadIcon(pm));
|
||||
viewHolder.dm_item_iv_icon.setImageBitmap(bitmap);
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
} else if (!TextUtils.isEmpty(icon)) {
|
||||
// viewHolder.dm_item_iv_icon.setImageURI(icon);
|
||||
ImageUtils.display(viewHolder.dm_item_iv_icon, icon);
|
||||
} else {
|
||||
viewHolder.dm_item_iv_icon.setImageURI("res:///" + R.drawable.logo);
|
||||
viewHolder.dm_item_iv_icon.setImageURI(Uri.parse("res:///" + R.drawable.logo));
|
||||
}
|
||||
|
||||
if (downloadEntity.getName().contains("光环助手")
|
||||
@ -300,7 +328,7 @@ class GameDownloadFragmentAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
removeDownload(downloadEntity);
|
||||
} else {
|
||||
if (downloadEntity.getName().contains("光环助手")) {
|
||||
context.startActivity(PackageUtils.getInstallIntent(path));
|
||||
context.startActivity(PackageUtils.getInstallIntent(context, path));
|
||||
} else {
|
||||
PackageUtils.launchSetup(context, path);
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@ package com.gh.gamecenter.download;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.net.Uri;
|
||||
import android.support.v4.util.ArrayMap;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.text.TextUtils;
|
||||
@ -16,6 +17,7 @@ import com.gh.common.util.DataUtils;
|
||||
import com.gh.common.util.DialogUtils;
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.FileUtils;
|
||||
import com.gh.common.util.ImageUtils;
|
||||
import com.gh.common.util.MD5Utils;
|
||||
import com.gh.common.util.NetworkUtils;
|
||||
import com.gh.common.util.PackageUtils;
|
||||
@ -382,9 +384,10 @@ class GameUpdateFragmentAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
|
||||
}
|
||||
|
||||
if (updateEntity.getName().contains("光环助手")) {
|
||||
viewHolder.gu_item_iv_icon.setImageResource(R.drawable.logo);
|
||||
viewHolder.gu_item_iv_icon.setImageURI(Uri.parse("res:///" + R.drawable.logo));
|
||||
} else {
|
||||
viewHolder.gu_item_iv_icon.setImageURI(updateEntity.getIcon());
|
||||
// viewHolder.gu_item_iv_icon.setImageURI(updateEntity.getIcon());
|
||||
ImageUtils.display(viewHolder.gu_item_iv_icon, updateEntity.getIcon());
|
||||
}
|
||||
|
||||
final String platform = PlatformUtils.getInstance(context)
|
||||
@ -453,7 +456,7 @@ class GameUpdateFragmentAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
|
||||
updateEntity.getPackageName());
|
||||
} else if ("更新中".equals(str) || "插件化中".equals(str)) {
|
||||
notifyItemChanged(0);
|
||||
EventBus.getDefault().post(new EBSkip("DownloadManagerActivity", 0));
|
||||
EventBus.getDefault().post(new EBSkip("DownloadManagerActivity", 1));
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -581,7 +584,7 @@ class GameUpdateFragmentAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
|
||||
DataCollectionUtils.uploadDownload(context, downloadEntity, "开始");
|
||||
|
||||
notifyItemChanged(0);
|
||||
EventBus.getDefault().post(new EBSkip("DownloadManagerActivity", 0));
|
||||
EventBus.getDefault().post(new EBSkip("DownloadManagerActivity", 1));
|
||||
}
|
||||
|
||||
public List<GameUpdateEntity> getUpdateList() {
|
||||
|
||||
@ -9,7 +9,7 @@ public class GameDetailEntity {
|
||||
|
||||
private List<ServerEntity> serverInfo;
|
||||
private ArrayList<TagEntity> tag;
|
||||
private String remind;
|
||||
private TipsEntity tips;
|
||||
private List<NewsEntity> news;
|
||||
private ArrayList<String> gallery;
|
||||
private String des;
|
||||
@ -64,14 +64,6 @@ public class GameDetailEntity {
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
public String getRemind() {
|
||||
return remind;
|
||||
}
|
||||
|
||||
public void setRemind(String remind) {
|
||||
this.remind = remind;
|
||||
}
|
||||
|
||||
public List<NewsEntity> getNews() {
|
||||
return news;
|
||||
}
|
||||
@ -112,4 +104,11 @@ public class GameDetailEntity {
|
||||
this.shareCode = shareCode;
|
||||
}
|
||||
|
||||
public TipsEntity getTips() {
|
||||
return tips;
|
||||
}
|
||||
|
||||
public void setTips(TipsEntity tips) {
|
||||
this.tips = tips;
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,82 @@
|
||||
package com.gh.gamecenter.entity;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
|
||||
/**
|
||||
* Created by khy on 2017/1/23.
|
||||
*/
|
||||
public class InstallGameEntity {
|
||||
|
||||
private String gameName;
|
||||
|
||||
private String gameVersion;
|
||||
|
||||
private long gameSize;
|
||||
|
||||
private Bitmap gameBm;
|
||||
|
||||
private String gamePath;
|
||||
|
||||
/**
|
||||
* 安装状态 用于清理安装包
|
||||
*/
|
||||
private int installStatus;
|
||||
|
||||
private String packageName;
|
||||
|
||||
public String getGameName() {
|
||||
return gameName;
|
||||
}
|
||||
|
||||
public void setGameName(String gameName) {
|
||||
this.gameName = gameName;
|
||||
}
|
||||
|
||||
public String getGameVersion() {
|
||||
return gameVersion;
|
||||
}
|
||||
|
||||
public void setGameVersion(String gameVersion) {
|
||||
this.gameVersion = gameVersion;
|
||||
}
|
||||
|
||||
public long getGameSize() {
|
||||
return gameSize;
|
||||
}
|
||||
|
||||
public void setGameSize(long gameSize) {
|
||||
this.gameSize = gameSize;
|
||||
}
|
||||
|
||||
public Bitmap getGameBm() {
|
||||
return gameBm;
|
||||
}
|
||||
|
||||
public void setGameBm(Bitmap gameBm) {
|
||||
this.gameBm = gameBm;
|
||||
}
|
||||
|
||||
public String getGamePath() {
|
||||
return gamePath;
|
||||
}
|
||||
|
||||
public void setGamePath(String gamePath) {
|
||||
this.gamePath = gamePath;
|
||||
}
|
||||
|
||||
public int getInstallStatus() {
|
||||
return installStatus;
|
||||
}
|
||||
|
||||
public void setInstallStatus(int installStatus) {
|
||||
this.installStatus = installStatus;
|
||||
}
|
||||
|
||||
public String getPackageName() {
|
||||
return packageName;
|
||||
}
|
||||
|
||||
public void setPackageName(String packageName) {
|
||||
this.packageName = packageName;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
package com.gh.gamecenter.entity;
|
||||
|
||||
import java.net.Socket;
|
||||
|
||||
/**
|
||||
* Created by khy on 2017/2/6.
|
||||
*/
|
||||
public class KcWebRequestEntity {
|
||||
|
||||
private Socket socket;
|
||||
|
||||
private String uri;
|
||||
|
||||
public Socket getSocket() {
|
||||
return socket;
|
||||
}
|
||||
|
||||
public void setSocket(Socket socket) {
|
||||
this.socket = socket;
|
||||
}
|
||||
|
||||
public String getUri() {
|
||||
return uri;
|
||||
}
|
||||
|
||||
public void setUri(String uri) {
|
||||
this.uri = uri;
|
||||
}
|
||||
}
|
||||
@ -22,6 +22,11 @@ public class NewsEntity {
|
||||
|
||||
private int views;
|
||||
|
||||
private String link;
|
||||
|
||||
@SerializedName("game_name")
|
||||
private String gameName;
|
||||
|
||||
public int getViews() {
|
||||
return views;
|
||||
}
|
||||
@ -85,4 +90,20 @@ public class NewsEntity {
|
||||
public void setThumbnail(ThumbnailEntity thumbnail) {
|
||||
this.thumbnail = thumbnail;
|
||||
}
|
||||
|
||||
public String getLink() {
|
||||
return link;
|
||||
}
|
||||
|
||||
public void setLink(String link) {
|
||||
this.link = link;
|
||||
}
|
||||
|
||||
public String getGameName() {
|
||||
return gameName;
|
||||
}
|
||||
|
||||
public void setGameName(String gameName) {
|
||||
this.gameName = gameName;
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,39 @@
|
||||
package com.gh.gamecenter.entity;
|
||||
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class PackageEntity {
|
||||
|
||||
@SerializedName("package")
|
||||
private String packageName;
|
||||
|
||||
private long time;
|
||||
|
||||
private String action;
|
||||
|
||||
public String getPackageName() {
|
||||
return packageName;
|
||||
}
|
||||
|
||||
public void setPackageName(String packageName) {
|
||||
this.packageName = packageName;
|
||||
}
|
||||
|
||||
public long getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(long time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public String getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
public void setAction(String action) {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
}
|
||||
@ -6,6 +6,7 @@ public class TagEntity {
|
||||
private String name;
|
||||
private String icon;
|
||||
private String des;
|
||||
private String color;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
@ -31,4 +32,11 @@ public class TagEntity {
|
||||
this.des = des;
|
||||
}
|
||||
|
||||
public String getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public void setColor(String color) {
|
||||
this.color = color;
|
||||
}
|
||||
}
|
||||
|
||||
33
app/src/main/java/com/gh/gamecenter/entity/TipsEntity.java
Normal file
33
app/src/main/java/com/gh/gamecenter/entity/TipsEntity.java
Normal file
@ -0,0 +1,33 @@
|
||||
package com.gh.gamecenter.entity;
|
||||
|
||||
|
||||
public class TipsEntity {
|
||||
|
||||
private String icon;
|
||||
private TitleEntity title;
|
||||
private String content;
|
||||
|
||||
public String getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
public void setIcon(String icon) {
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
public TitleEntity getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(TitleEntity title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
}
|
||||
24
app/src/main/java/com/gh/gamecenter/entity/TitleEntity.java
Normal file
24
app/src/main/java/com/gh/gamecenter/entity/TitleEntity.java
Normal file
@ -0,0 +1,24 @@
|
||||
package com.gh.gamecenter.entity;
|
||||
|
||||
|
||||
public class TitleEntity {
|
||||
|
||||
private String color;
|
||||
private String value;
|
||||
|
||||
public String getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public void setColor(String color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
@ -4,6 +4,7 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Color;
|
||||
import android.net.Uri;
|
||||
import android.support.v4.util.ArrayMap;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.support.v4.widget.SwipeRefreshLayout;
|
||||
@ -51,7 +52,6 @@ import com.gh.gamecenter.adapter.viewholder.GameImageViewHolder;
|
||||
import com.gh.gamecenter.adapter.viewholder.GameNormalViewHolder;
|
||||
import com.gh.gamecenter.adapter.viewholder.GameTestViewHolder;
|
||||
import com.gh.gamecenter.adapter.viewholder.GameViewPagerViewHolder;
|
||||
import com.gh.gamecenter.db.LibaoDao;
|
||||
import com.gh.gamecenter.entity.ApkEntity;
|
||||
import com.gh.gamecenter.entity.GameEntity;
|
||||
import com.gh.gamecenter.entity.GameUpdateEntity;
|
||||
@ -97,8 +97,6 @@ class GameFragmentAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||
private ArrayMap<String, ArrayList<Integer>> locationMap;
|
||||
private ArrayMap<String, List<GameEntity>> subjectChangedMap; //存储换一换的数据
|
||||
|
||||
private LibaoDao libaoDao;
|
||||
|
||||
private int itemCount;
|
||||
private int pluginSize;
|
||||
|
||||
@ -120,8 +118,6 @@ class GameFragmentAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||
this.context = fragment.getActivity();
|
||||
this.listener = fragment;
|
||||
|
||||
libaoDao = new LibaoDao(context);
|
||||
|
||||
game_swipe_refresh = refreshLayout;
|
||||
|
||||
slideList = new ArrayList<>();
|
||||
@ -238,7 +234,7 @@ class GameFragmentAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||
}
|
||||
|
||||
private void initSubjectList() {
|
||||
RetrofitManager.getApi().getChajian()
|
||||
RetrofitManager.getApi().getColumn()
|
||||
.map(new Func1<List<SubjectEntity>, List<SubjectEntity>>() {
|
||||
@Override
|
||||
public List<SubjectEntity> call(List<SubjectEntity> list) {
|
||||
@ -700,13 +696,14 @@ class GameFragmentAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||
viewHolder.subjectLl.addView(contentView);
|
||||
|
||||
if (subjectDigestList.size() == 3 && i < 3) {
|
||||
subjectIcon.setImageURI(subjectDigestList.get(i).getIcon());
|
||||
// subjectIcon.setImageURI(subjectDigestList.get(i).getIcon());
|
||||
ImageUtils.display(subjectIcon, subjectDigestList.get(i).getIcon());
|
||||
subjectName.setText(subjectDigestList.get(i).getName());
|
||||
}
|
||||
|
||||
if (i == 3) {
|
||||
subjectName.setText("礼包");
|
||||
subjectIcon.setImageURI("res:///" + R.drawable.home_entrance_libao);
|
||||
subjectIcon.setImageURI(Uri.parse("res:///" + R.drawable.home_entrance_libao));
|
||||
if (sp.getBoolean("showGiftNewIcon", true)) {
|
||||
subjectNewIcon.setVisibility(View.VISIBLE);
|
||||
}
|
||||
@ -714,7 +711,7 @@ class GameFragmentAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||
|
||||
if (i == 4) {
|
||||
subjectName.setText("攻略");
|
||||
subjectIcon.setImageURI("res:///" + R.drawable.home_entrance_strategy);
|
||||
subjectIcon.setImageURI(Uri.parse("res:///" + R.drawable.home_entrance_strategy));
|
||||
}
|
||||
|
||||
final int finalI = i;
|
||||
@ -787,25 +784,16 @@ class GameFragmentAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||
}
|
||||
}
|
||||
|
||||
if (libaoDao.isExist(gameEntity.getId())) {
|
||||
holder.libaoIcon.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
if (gameEntity.isLibaoExists()) {
|
||||
holder.libaoIcon.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
holder.libaoIcon.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
if (subjectEntity.isOrder()) {
|
||||
holder.home2_game_order.setVisibility(View.VISIBLE);
|
||||
holder.home2_game_order.setText(String.valueOf(i + 1));
|
||||
holder.gameOrder.setVisibility(View.VISIBLE);
|
||||
holder.gameOrder.setText(String.valueOf(i + 1));
|
||||
} else {
|
||||
holder.home2_game_order.setVisibility(View.GONE);
|
||||
holder.gameOrder.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
holder.gameThumb.setImageURI(gameEntity.getIcon());
|
||||
holder.gameNameAndSize.setText(gameEntity.getName());
|
||||
// holder.gameThumb.setImageURI(gameEntity.getIcon());
|
||||
ImageUtils.display(holder.gameThumb, gameEntity.getIcon());
|
||||
holder.gameName.setText(gameEntity.getName());
|
||||
if (gameEntity.getApk() == null || gameEntity.getApk().isEmpty()) {
|
||||
holder.gameDes.setText(gameEntity.getBrief());
|
||||
} else {
|
||||
@ -842,13 +830,11 @@ class GameFragmentAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||
}
|
||||
|
||||
DownloadItemUtils.setOnClickListener(context,
|
||||
holder.downloadBtn, gameEntity, i,
|
||||
holder.gameDownloadBtn, gameEntity, i,
|
||||
GameFragmentAdapter.this, "(游戏-专题:" + subjectEntity.getName() + "-列表[" + (i + 1) + "])",
|
||||
"游戏-专题-" + subjectEntity.getName() + ":" + gameEntity.getName(), false);
|
||||
|
||||
DownloadItemUtils.updateItem(context, holder.gameDes,
|
||||
holder.game_progressbar, holder.game_ll_info, holder.download_speed,
|
||||
holder.download_percentage, holder.downloadBtn, gameEntity);
|
||||
DownloadItemUtils.updateItem(context, gameEntity, holder, true);
|
||||
}
|
||||
|
||||
private void initGameNormalViewHolder(GameNormalViewHolder holder, int position) {
|
||||
@ -907,36 +893,27 @@ class GameFragmentAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||
}
|
||||
}
|
||||
|
||||
if (libaoDao.isExist(gameEntity.getId())) {
|
||||
holder.libaoIcon.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
if (gameEntity.isLibaoExists()) {
|
||||
holder.libaoIcon.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
holder.libaoIcon.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
if (subjectEntity.isOrder()) {
|
||||
holder.home1_game_order.setVisibility(View.VISIBLE);
|
||||
holder.home1_game_order.setText(String.valueOf(i + 1));
|
||||
holder.gameOrder.setVisibility(View.VISIBLE);
|
||||
holder.gameOrder.setText(String.valueOf(i + 1));
|
||||
} else {
|
||||
holder.home1_game_order.setVisibility(View.GONE);
|
||||
holder.gameOrder.setVisibility(View.GONE);
|
||||
}
|
||||
holder.gameThumb.setImageURI(gameEntity.getIcon());
|
||||
// holder.gameThumb.setImageURI(gameEntity.getIcon());
|
||||
ImageUtils.display(holder.gameThumb, gameEntity.getIcon());
|
||||
if (gameEntity.isPluggable()) {
|
||||
holder.gameNameAndSize.setText(String.format("%s - %s", gameEntity.getName(),
|
||||
holder.gameName.setText(String.format("%s - %s", gameEntity.getName(),
|
||||
PlatformUtils.getInstance(context).getPlatformName(
|
||||
gameEntity.getApk().get(0).getPlatform())));
|
||||
} else {
|
||||
holder.gameNameAndSize.setText(gameEntity.getName());
|
||||
holder.gameName.setText(gameEntity.getName());
|
||||
}
|
||||
if (gameEntity.getApk() == null || gameEntity.getApk().isEmpty()) {
|
||||
holder.gameDes.setText(gameEntity.getBrief());
|
||||
} else {
|
||||
holder.gameDes.setText(String.format("%s %s", gameEntity.getApk().get(0).getSize(), gameEntity.getBrief()));
|
||||
}
|
||||
GameViewUtils.setLabelList(context, holder.labelList, gameEntity.getTag());
|
||||
GameViewUtils.setLabelList(context, holder.gameLabelList, gameEntity.getTag());
|
||||
|
||||
holder.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
@ -956,13 +933,11 @@ class GameFragmentAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||
}
|
||||
});
|
||||
|
||||
DownloadItemUtils.setOnClickListener(context, holder.downloadBtn, gameEntity, i,
|
||||
DownloadItemUtils.setOnClickListener(context, holder.gameDownloadBtn, gameEntity, i,
|
||||
GameFragmentAdapter.this, "(游戏-专题:" + subjectEntity.getName() + "-列表[" + (i + 1) + "])",
|
||||
"游戏-专题-" + subjectEntity.getName() + ":" + gameEntity.getName(), false);
|
||||
|
||||
DownloadItemUtils.updateItem(context, holder.gameDes,
|
||||
holder.game_progressbar, holder.game_ll_info, holder.download_speed,
|
||||
holder.download_percentage, holder.downloadBtn, gameEntity, !gameEntity.isPluggable());
|
||||
DownloadItemUtils.updateItem(context, gameEntity, holder, !gameEntity.isPluggable());
|
||||
}
|
||||
|
||||
private void initGameImageViewHolder(GameImageViewHolder holder, int position) {
|
||||
|
||||
@ -6,6 +6,7 @@ import android.graphics.Color;
|
||||
import android.support.v7.widget.GridLayoutManager;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.text.Html;
|
||||
import android.text.TextUtils;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
@ -21,6 +22,7 @@ import com.gh.common.util.DataCollectionUtils;
|
||||
import com.gh.common.util.DataUtils;
|
||||
import com.gh.common.util.DialogUtils;
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.ImageUtils;
|
||||
import com.gh.common.util.NewsUtils;
|
||||
import com.gh.common.view.HorizontalItemDecoration;
|
||||
import com.gh.gamecenter.GameDetailActivity;
|
||||
@ -60,7 +62,6 @@ import java.util.Map;
|
||||
import okhttp3.ResponseBody;
|
||||
import retrofit2.adapter.rxjava.HttpException;
|
||||
import rx.android.schedulers.AndroidSchedulers;
|
||||
import rx.functions.Action1;
|
||||
import rx.functions.Func1;
|
||||
import rx.schedulers.Schedulers;
|
||||
|
||||
@ -142,7 +143,7 @@ public class GameDetailAdapter extends RecyclerView.Adapter {
|
||||
}
|
||||
|
||||
private void addLibaoList(){
|
||||
RetrofitManager.getLibao().getLibaoByGame(gameEntity.getId(),0 , 128)
|
||||
RetrofitManager.getLibao().getLibaoByGame(gameEntity.getId(), 0 , 128)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Response<List<LibaoEntity>>(){
|
||||
@ -208,9 +209,10 @@ public class GameDetailAdapter extends RecyclerView.Adapter {
|
||||
})
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Action1<Object>() {
|
||||
.subscribe(new Response<Object>(){
|
||||
@Override
|
||||
public void call(Object o) {
|
||||
public void onResponse(Object response) {
|
||||
super.onResponse(response);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
@ -534,7 +536,7 @@ public class GameDetailAdapter extends RecyclerView.Adapter {
|
||||
tv_tag.setText(newsList.get(i).getType());
|
||||
|
||||
TextView tv_title = (TextView) view.findViewById(R.id.gamedetail_news_item_title);
|
||||
tv_title.setText(newsList.get(i).getTitle());
|
||||
tv_title.setText(Html.fromHtml(newsList.get(i).getTitle()));
|
||||
|
||||
final NewsEntity newsEntity = newsList.get(i);
|
||||
final int ii = i;
|
||||
@ -565,12 +567,12 @@ public class GameDetailAdapter extends RecyclerView.Adapter {
|
||||
viewHolder.open_plugin_detail_ll.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (viewHolder.gamedetail_ll_plugin.getVisibility() == View.GONE){
|
||||
if (viewHolder.gamedetail_ll_plugin.getVisibility() == View.GONE) {
|
||||
viewHolder.gamedetail_ll_plugin.setVisibility(View.VISIBLE);
|
||||
viewHolder.gamedetail_ll_plugin_colse.setVisibility(View.GONE);
|
||||
viewHolder.open_plugin_detail_img.setImageResource(R.drawable.up_img);
|
||||
viewHolder.open_plugin_detail_tv.setText("收起");
|
||||
}else {
|
||||
} else {
|
||||
viewHolder.gamedetail_ll_plugin.setVisibility(View.GONE);
|
||||
viewHolder.gamedetail_ll_plugin_colse.setVisibility(View.VISIBLE);
|
||||
viewHolder.open_plugin_detail_img.setImageResource(R.drawable.down_img);
|
||||
@ -585,51 +587,60 @@ public class GameDetailAdapter extends RecyclerView.Adapter {
|
||||
TextView tv_hint;
|
||||
TextView tv_content;
|
||||
TagEntity tagEntity;
|
||||
for (int i = 0, size = tags.size() + 1; i < size; i++) {
|
||||
if (gameDetailEntity.getTips() != null && !TextUtils.isEmpty(gameDetailEntity.getTips().getContent())) {
|
||||
view = View.inflate(context, R.layout.gamedetail_plugin_item, null);
|
||||
iv_hint = (SimpleDraweeView) view.findViewById(R.id.gamedetail_iv_hint);
|
||||
tv_hint = (TextView) view.findViewById(R.id.gamedetail_tv_hint);
|
||||
tv_content = (TextView) view.findViewById(R.id.gamedetail_tv_content);
|
||||
if (i == 0) {
|
||||
tv_hint.setTextColor(Color.parseColor("#00B7FA"));
|
||||
if (TextUtils.isEmpty(gameDetailEntity.getRemind())) {
|
||||
tv_content.setText("无需root尽享插件功能");
|
||||
} else {
|
||||
tv_content.setText(gameDetailEntity.getRemind());
|
||||
}
|
||||
} else {
|
||||
tagEntity = tags.get(i - 1);
|
||||
ImageUtils.display(iv_hint, gameDetailEntity.getTips().getIcon());
|
||||
tv_hint.setTextColor(Color.parseColor(gameDetailEntity.getTips().getTitle().getColor()));
|
||||
tv_hint.setText(gameDetailEntity.getTips().getTitle().getValue());
|
||||
tv_content.setText(gameDetailEntity.getTips().getContent());
|
||||
viewHolder.gamedetail_ll_plugin.addView(view);
|
||||
|
||||
view = View.inflate(context, R.layout.gamedetail_plugin_item, null);
|
||||
iv_hint = (SimpleDraweeView) view.findViewById(R.id.gamedetail_iv_hint);
|
||||
tv_hint = (TextView) view.findViewById(R.id.gamedetail_tv_hint);
|
||||
tv_content = (TextView) view.findViewById(R.id.gamedetail_tv_content);
|
||||
ImageUtils.display(iv_hint, gameDetailEntity.getTips().getIcon());
|
||||
tv_hint.setTextColor(Color.parseColor(gameDetailEntity.getTips().getTitle().getColor()));
|
||||
tv_hint.setText(gameDetailEntity.getTips().getTitle().getValue());
|
||||
tv_content.setText(gameDetailEntity.getTips().getContent());
|
||||
viewHolder.gamedetail_ll_plugin_colse.addView(view);
|
||||
}
|
||||
|
||||
if (tags.isEmpty()) {
|
||||
viewHolder.open_plugin_detail_ll.setVisibility(View.GONE);
|
||||
} else {
|
||||
viewHolder.open_plugin_detail_ll.setVisibility(View.VISIBLE);
|
||||
|
||||
for (int i = 0, size = tags.size(); i < size; i++) {
|
||||
view = View.inflate(context, R.layout.gamedetail_plugin_item, null);
|
||||
iv_hint = (SimpleDraweeView) view.findViewById(R.id.gamedetail_iv_hint);
|
||||
tv_hint = (TextView) view.findViewById(R.id.gamedetail_tv_hint);
|
||||
tv_content = (TextView) view.findViewById(R.id.gamedetail_tv_content);
|
||||
tagEntity = tags.get(i);
|
||||
tv_content.setText(tagEntity.getDes());
|
||||
tv_hint.setText(tagEntity.getName());
|
||||
iv_hint.setImageURI(tagEntity.getIcon());
|
||||
tv_hint.setTextColor(Color.parseColor(tagEntity.getColor()));
|
||||
// iv_hint.setImageURI(tagEntity.getIcon());
|
||||
ImageUtils.display(iv_hint, tagEntity.getIcon());
|
||||
viewHolder.gamedetail_ll_plugin.addView(view);
|
||||
}
|
||||
viewHolder.gamedetail_ll_plugin.addView(view);
|
||||
|
||||
RecyclerView recyclerView = new RecyclerView(context);
|
||||
recyclerView.setLayoutManager(new GridLayoutManager(context, 3));
|
||||
|
||||
int index = (int) Math.ceil(tags.size() / 3.0);
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT, DisplayUtils.dip2px(context, index * 28));
|
||||
params.setMargins(0, DisplayUtils.dip2px(context, index * 3), 0, 0);
|
||||
|
||||
recyclerView.setLayoutParams(params);
|
||||
recyclerView.setAdapter(new PluginAdapter(tags));
|
||||
viewHolder.gamedetail_ll_plugin_colse.addView(recyclerView);
|
||||
}
|
||||
|
||||
view = View.inflate(context, R.layout.gamedetail_plugin_item, null);
|
||||
tv_hint = (TextView) view.findViewById(R.id.gamedetail_tv_hint);
|
||||
tv_content = (TextView) view.findViewById(R.id.gamedetail_tv_content);
|
||||
if (TextUtils.isEmpty(gameDetailEntity.getRemind())) {
|
||||
tv_content.setText("无需root尽享插件功能");
|
||||
} else {
|
||||
tv_content.setText(gameDetailEntity.getRemind());
|
||||
}
|
||||
tv_hint.setText("温馨提示");
|
||||
tv_hint.setTextColor(Color.parseColor("#00B7FA"));
|
||||
|
||||
viewHolder.gamedetail_ll_plugin_colse.addView(view);
|
||||
|
||||
RecyclerView recyclerView = new RecyclerView(context);
|
||||
recyclerView.setLayoutManager(new GridLayoutManager(context, 3));
|
||||
|
||||
int index = (int) Math.ceil(tags.size() / 3.0);
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT, DisplayUtils.dip2px(context, index * 28));
|
||||
params.setMargins(0, DisplayUtils.dip2px(context, index * 3), 0, 0);
|
||||
|
||||
recyclerView.setLayoutParams(params);
|
||||
recyclerView.setAdapter(new PluginAdapter(tags));
|
||||
viewHolder.gamedetail_ll_plugin_colse.addView(recyclerView);
|
||||
}
|
||||
}
|
||||
|
||||
@ -680,7 +691,9 @@ public class GameDetailAdapter extends RecyclerView.Adapter {
|
||||
@Override
|
||||
public void onBindViewHolder(ViewHolder holder, int position) {
|
||||
holder.pluginTitle.setText(tags.get(position).getName());
|
||||
holder.pluginIcon.setImageURI(tags.get(position).getIcon());
|
||||
holder.pluginTitle.setTextColor(Color.parseColor(tags.get(position).getColor()));
|
||||
// holder.pluginIcon.setImageURI(tags.get(position).getIcon());
|
||||
ImageUtils.display(holder.pluginIcon, tags.get(position).getIcon());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -715,7 +728,8 @@ public class GameDetailAdapter extends RecyclerView.Adapter {
|
||||
}
|
||||
|
||||
viewHolder.gamedetail_tv_name.setText(gameEntity.getName());
|
||||
viewHolder.gamedetail_iv_thumb.setImageURI(gameEntity.getIcon());
|
||||
// viewHolder.gamedetail_iv_thumb.setImageURI(gameEntity.getIcon());
|
||||
ImageUtils.display(viewHolder.gamedetail_iv_thumb, gameEntity.getIcon());
|
||||
if (gameEntity.getApk() == null || gameEntity.getApk().isEmpty()) {
|
||||
viewHolder.gamedetail_tv_info.setText("");
|
||||
} else {
|
||||
|
||||
@ -9,6 +9,7 @@ import android.view.ViewGroup;
|
||||
|
||||
import com.gh.common.util.DataCollectionUtils;
|
||||
import com.gh.common.util.DataUtils;
|
||||
import com.gh.common.util.ImageUtils;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.ViewImageActivity;
|
||||
|
||||
@ -43,7 +44,8 @@ class GameGalleryAdapter extends RecyclerView.Adapter<GameGalleryViewHolder> {
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(final GameGalleryViewHolder holder, int position) {
|
||||
holder.screenshot_item_iv.setImageURI(gallery.get(position));
|
||||
// holder.screenshot_item_iv.setImageURI(gallery.get(position));
|
||||
ImageUtils.display(holder.screenshot_item_iv, gallery.get(position));
|
||||
holder.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
@ -0,0 +1,30 @@
|
||||
package com.gh.gamecenter.kuaichuan;
|
||||
|
||||
/**
|
||||
* Created by khy on 2017/1/20.
|
||||
*/
|
||||
public abstract class BaseTransfer implements Transferable{
|
||||
|
||||
/**
|
||||
* 头部分割字符
|
||||
*/
|
||||
public static final String SPERATOR = "::";
|
||||
|
||||
/**
|
||||
* 字节数组长度
|
||||
*/
|
||||
public static final int BYTE_SIZE_HEADER = 1024 * 10;
|
||||
public static final int BYTE_SIZE_SCREENSHOT = 1024 * 40;
|
||||
public static final int BYTE_SIZE_DATA = 1024 * 4;
|
||||
|
||||
/**
|
||||
* 传输文件类型
|
||||
*/
|
||||
public static final int TYPE_FILE = 1; //文件类型
|
||||
public static final int TYPE_MSG = 2; //消息类型
|
||||
|
||||
/**
|
||||
* 传输字节类型
|
||||
*/
|
||||
public static final String UTF_8 = "UTF-8";
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user