Пример #1
0
 @Override
 public void onReceive(Context context, Intent intent) {
   if (intent.getAction().equals(DownloadManager.ACTION_DOWNLOAD_COMPLETE)) {
     long downId = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1);
     List<Long> ids = AppSharePreferences.getDownloadIds(context);
     if (ids == null || !ids.contains(downId)) return;
     AppSharePreferences.deleteDownloadId(context, downId);
     DownloadManager manager =
         (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
     Cursor c = manager.query(new DownloadManager.Query().setFilterById(downId));
     if (c == null || !c.moveToFirst()) return;
     String url = c.getString(c.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI));
     if (TextUtils.isEmpty(url)) {
       AppUtils.showToast(context, getResources().getString(R.string.download_fail) + "!");
       return;
     }
     Uri uri = Uri.parse(url);
     c.close();
     Intent i = new Intent();
     i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
     i.setAction("android.intent.action.VIEW");
     i.addCategory("android.intent.category.DEFAULT");
     i.setType("application/vnd.android.package-archive");
     i.setData(uri);
     i.setDataAndType(uri, "application/vnd.android.package-archive");
     startActivity(i);
   }
 }
Пример #2
0
 public void onEventMainThread(SubscriptionFavSettingActivity.MajorTeamEvent event) {
   if (event != null) {
     majorTeamGsonModel = event.model;
     if (majorTeamGsonModel != null && !TextUtils.isEmpty(majorTeamGsonModel.avatar)) {
       File file =
           DiskCacheUtils.findInCache(majorTeamGsonModel.avatar, imageLoader.getDiskCache());
       if (file == null || !file.exists()) {
         imageLoader.displayImage(majorTeamGsonModel.avatar, majorImageView, options);
       } else {
         majorImageView.setImageBitmap(BitmapFactory.decodeFile(file.getAbsolutePath()));
       }
     } else {
       if (mFragment instanceof FeedFragment) {
         if (AppSharePreferences.getFollowFlag(getApplicationContext())) {
           majorImageView.setImageResource(R.drawable.tab_center_notset_pressed);
         } else {
           majorImageView.setImageResource(R.drawable.tab_center_selected);
         }
       } else {
         if (AppSharePreferences.getFollowFlag(getApplicationContext())) {
           majorImageView.setImageResource(R.drawable.tab_center_notset_normal);
         } else {
           majorImageView.setImageResource(R.drawable.tab_center_normal);
         }
       }
     }
     if (mFragment instanceof FeedFragment) {
       if (majorTeamGsonModel != null && !TextUtils.isEmpty(majorTeamGsonModel.color))
         majorImageView.setBackgroundColor(Color.parseColor(majorTeamGsonModel.color));
       else majorImageView.setBackgroundResource(R.color.title);
     } else majorImageView.setBackgroundResource(R.color.main_tab_center);
   }
 }
Пример #3
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    AppUtils.switchLanguage(getApplicationContext());
    exitWithUserOption = false;
    EventBus.getDefault().register(this);
    initSlidingMenu();
    setContentView(R.layout.activity_main);
    Trace.e(tag, getString(R.string.lang));
    fMgr = getSupportFragmentManager();
    imageLoader = BaseApplication.getImageLoader(this);
    options =
        new DisplayImageOptions.Builder()
            .bitmapConfig(Bitmap.Config.RGB_565)
            .showStubImage(R.drawable.tab_center_normal)
            .showImageForEmptyUri(R.drawable.tab_center_normal)
            .showImageOnFail(R.drawable.tab_center_normal)
            .cacheInMemory(true)
            .cacheOnDisc(true)
            .build();
    if (AppUtils.isLogin(this)) majorTeamGsonModel = AppSharePreferences.getMajorTeam(this);
    mTitleView = (TitleView) findViewById(R.id.titlebar_layout);
    mTitleView.initTitleBar(null, 0, 0);
    mTitleView.setRightMenuButton();
    mTitleView.setTitleViewListener(mTitleViewListener);
    dealBottomButtonsClickEvent();
    initFragment(savedInstanceState);
    if (majorTeamGsonModel != null && !TextUtils.isEmpty(majorTeamGsonModel.avatar)) {
      File file = DiskCacheUtils.findInCache(majorTeamGsonModel.avatar, imageLoader.getDiskCache());
      if (file == null || !file.exists()) {
        imageLoader.displayImage(majorTeamGsonModel.avatar, majorImageView, options);
      } else {
        majorImageView.setImageBitmap(BitmapFactory.decodeFile(file.getAbsolutePath()));
      }
    } else {
      if (AppSharePreferences.getFollowFlag(getApplicationContext())) {
        majorImageView.setImageResource(R.drawable.tab_center_notset_normal);
      } else {
        majorImageView.setImageResource(R.drawable.tab_center_normal);
      }
    }

    mWindowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE);

    AppService.startCheckVersion(this, false);
    mDownloadReceiver = new DownloadCompleteReceiver();
    registerReceiver(mDownloadReceiver, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
    FeedbackAgent agent = new FeedbackAgent(this);
    agent.sync();

    /*
     * if
     * (AppSharePreferences.getDefault().getBoolean("MAIN_TOURNAMENT_GUIDE",
     * true)) { startActivity(new Intent(MainActivity.this,
     * GuideActivity.class)); }
     */

  }
Пример #4
0
 @Override
 public void onResume() {
   super.onResume();
   if (jumpSetting) {
     if (AppUtils.isLogin(getActivity()) && !AppSharePreferences.getFollowFlag(getActivity())) {
       Intent intent = new Intent(getActivity(), SubscriptionAddActivity.class);
       intent.putExtra(EXTRA_SUBSCRIPTION_SETTING, true);
       startActivity(intent);
     }
     jumpSetting = false;
   }
   if (AppSharePreferences.getFollowFlag(getActivity())) startRefreshNews();
 }
Пример #5
0
 @Override
 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
   super.onActivityResult(requestCode, resultCode, data);
   if (requestCode == LanguageChangeActivity.LANGUAGE_CHANGE_REQUEST_CODE
       && resultCode == LanguageChangeActivity.LANGUAGE_CHANGE_RESULT_CODE) {
     AppSharePreferences.getDefault(getApplicationContext()).edit().remove("MENU_LAST_MODIFY");
     AppSharePreferences.deleteSplashLastModify(getApplicationContext());
     DatabaseHelper.deleteMenuCache(getApplicationContext());
     AppUtils.initMenuFromCache(getApplicationContext());
     AppSharePreferences.saveGroupExtendIds(this, null);
     if (Build.VERSION.SDK_INT >= 11) recreate();
     else {
       Intent intent = new Intent(this, BaseSplashActivity.class);
       startActivity(intent);
       finish();
     }
   }
 }
Пример #6
0
 @Override
 public View onCreateView(
     LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
   View v = inflater.inflate(R.layout.fragment_feed, container, false);
   ButterKnife.inject(this, v);
   if (AppSharePreferences.getFollowFlag(getActivity())) {
     listLayout = mListViewStub.inflate();
     initListView(listLayout);
   } else {
     settingLayout = mSetting.inflate();
     initSettingView(settingLayout);
   }
   return v;
 }
Пример #7
0
  @Override
  protected void onResume() {
    super.onResume();
    MobclickAgent.onResume(this);
    if (AppConstant.menuFlag) {
      AppConstant.menuFlag = false;
      showMenu();
    }
    if (AppConstant.VIDEOMODE == AppConstant.NIGHTMODE) {
      night();
    } else {
      day();
    }

    BaseApplication.setMainActivityState(BaseApplication.FLAG_MAIN_STATE_FOREGROUND);
    if (AppSharePreferences.getNOtifyCount(getApplicationContext()) > 0) {
      ShortcutBadger.with(this).count(0);
    }
  }
 public boolean matchOnLiveVideoAd(String input) {
   Pattern pattern = Pattern.compile(AppSharePreferences.getAdMatcher(this).toString());
   Matcher matcher = pattern.matcher(input);
   boolean match = matcher.matches();
   return match;
 }
Пример #9
0
  private void initBottomButton() {
    newsButton.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.tab1_normal, 0, 0);
    newsButton.setTextColor(getResources().getColor(R.color.calendar_header));
    gameButton.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.tab2_normal, 0, 0);
    gameButton.setTextColor(getResources().getColor(R.color.calendar_header));
    threadButton.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.tab3_normal, 0, 0);
    threadButton.setTextColor(getResources().getColor(R.color.calendar_header));
    dataButton.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.tab4_normal, 0, 0);
    dataButton.setTextColor(getResources().getColor(R.color.calendar_header));
    if (majorTeamGsonModel == null || TextUtils.isEmpty(majorTeamGsonModel.avatar)) {
      if (AppSharePreferences.getFollowFlag(getApplicationContext())) {
        majorImageView.setImageResource(R.drawable.tab_center_notset_normal);
      } else {
        majorImageView.setImageResource(R.drawable.tab_center_normal);
      }
    } else {
      File file = DiskCacheUtils.findInCache(majorTeamGsonModel.avatar, imageLoader.getDiskCache());
      if (file == null || !file.exists()) {
        imageLoader.displayImage(majorTeamGsonModel.avatar, majorImageView, options);
      } else {
        majorImageView.setImageBitmap(BitmapFactory.decodeFile(file.getAbsolutePath()));
      }
    }
    mTitleView.setLeftButton(0);
    majorImageView.setBackgroundResource(R.drawable.main_tab_center);
    switch (index) {
      case 0:
        {
          mTitleView.setTitle(null);
          newsButton.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.tab1_selected, 0, 0);
          newsButton.setTextColor(getResources().getColor(R.color.title));
          break;
        }
      case 1:
        {
          mTitleView.setTitle(getString(R.string.top_toolbar_small_online));
          gameButton.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.tab2_selected, 0, 0);
          gameButton.setTextColor(getResources().getColor(R.color.title));
          break;
        }
      case 2:
        {
          mTitleView.setTitle(null);
          // ((Button)v).setCompoundDrawablesWithIntrinsicBounds(0,
          // R.drawable.tab2_selected, 0, 0);

          if (majorTeamGsonModel == null || TextUtils.isEmpty(majorTeamGsonModel.avatar)) {
            if (AppSharePreferences.getFollowFlag(getApplicationContext())) {
              majorImageView.setImageResource(R.drawable.tab_center_notset_pressed);
            } else {
              majorImageView.setImageResource(R.drawable.tab_center_selected);
            }
            majorImageView.setBackgroundColor(getResources().getColor(R.color.title));
          } else {
            if (!TextUtils.isEmpty(majorTeamGsonModel.color))
              majorImageView.setBackgroundColor(Color.parseColor(majorTeamGsonModel.color));
            else majorImageView.setBackgroundColor(getResources().getColor(R.color.title));
          }
          if (AppSharePreferences.getFollowFlag(getApplicationContext()))
            mTitleView.setLeftButton(getString(R.string.feed_edit));
          break;
        }
      case 3:
        {
          mTitleView.setTitle(getString(R.string.title_football_group));
          threadButton.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.tab3_selected, 0, 0);
          threadButton.setTextColor(getResources().getColor(R.color.title));
          break;
        }
      case 4:
        {
          mTitleView.setTitle(getString(R.string.title_football_top));
          dataButton.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.tab4_selected, 0, 0);
          dataButton.setTextColor(getResources().getColor(R.color.title));
          break;
        }
    }
  }