コード例 #1
0
ファイル: MainPage.java プロジェクト: Tacus/eigthtegame
 private void startGame(SingleGameItem gameItem) {
   int gameId = gameItem.getGame_id();
   DownloadApk downloadApk = MainActivity.map.get(gameId);
   if (downloadApk != null) {
     Toast.makeText(activity, R.string.apk_loading, Toast.LENGTH_SHORT).show();
   } else {
     String packname = gameItem.getGame_gamepack();
     if (ApkManager.startGame(packname)) return;
     else {
       String apkPath = MyUtils.gameId2path(gameId);
       File apkFile = new File(apkPath);
       if (apkFile.exists()) {
         ApkManager.installGame(apkPath);
       } else {
         String apkUrl = gameItem.getGame_apk_url();
         downloadApk = new DownloadApk(this, gameId);
         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
           downloadApk.executeOnExecutor(MainActivity.apkExecutor, apkUrl, apkPath);
         } else {
           downloadApk.execute(apkUrl, apkPath);
         }
         MainActivity.sqlOpenHelper.insert(gameItem);
         MainActivity.map.put(gameId, downloadApk);
         MainActivity.mainPage.update();
         MainActivity.categoryPage.update();
       }
     }
   }
 }
コード例 #2
0
ファイル: MainPage.java プロジェクト: Tacus/eigthtegame
 private void bindData2(List<SingleGameItem> list) {
   for (int i = 0; i < holders.size(); i++) {
     SingleGameItem gameItem = list.get(i);
     Holder holder = holders.get(i);
     if (i >= 12) {
       MyUtils.setImage(holder.game_logo, gameItem.getGame_icon_url(), 2);
       BitmapDrawable drawable = (BitmapDrawable) holder.game_logo.getDrawable();
       Bitmap srcBitmap = drawable.getBitmap();
       holder.game_reflect.setVisibility(View.VISIBLE);
       holder.game_reflect.setImageBitmap(MyUtils.createReflectedImage(srcBitmap));
     } else {
       holder.game_reflect.setVisibility(View.GONE);
       MyUtils.setImage(holder.game_logo, gameItem.getGame_icon_url(), 2);
     }
     holder.game_name.setText(gameItem.getGame_name());
     DownloadApk downloadApk = MainActivity.map.get(gameItem.getGame_id());
     if (downloadApk != null) {
       holder.game_progress.setVisibility(View.VISIBLE);
       downloadApk.addloadPercentageTextView(holder.game_progress);
     } else {
       holder.game_progress.setVisibility(View.GONE);
     }
     holder.game_logo.setTag(gameItem);
   }
 }