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); } }
@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)); } */ }
private void updateView(ViewHolder viewHolder, TimeLineListEntity entity, int position) { TimeLineEntity timeLineEntity = null; if ("reply".equals(entity.type)) { timeLineEntity = entity.reply; TextLinkHelper.addSchemesWithoutEvent(viewHolder.titleTextView, timeLineEntity.topic.content); } else if ("comment".equals(entity.type)) { timeLineEntity = entity.comment; TimeLineGroupEntity groupEntity = null; if ("article".equals(timeLineEntity.type)) { groupEntity = timeLineEntity.article; } else if ("weibo".equals(timeLineEntity.type)) { groupEntity = timeLineEntity.weibo; } else if ("twitter".equals(timeLineEntity.type)) { groupEntity = timeLineEntity.twitter; } else if ("instagram".equals(timeLineEntity.type)) { groupEntity = timeLineEntity.instagram; } if (groupEntity != null) TextLinkHelper.addSchemesWithoutEvent(viewHolder.titleTextView, groupEntity.title); } mImageLoader.displayImage(user.getAvatar(), viewHolder.headImageView, thumbOtions); viewHolder.nameTextView.setText(user.getUsername()); viewHolder.timeTextView.setText(DateUtil.formatTime_GMT_8(timeLineEntity.created_at)); TextLinkHelper.addSchemesWithoutEvent(viewHolder.contentTextView, timeLineEntity.content); viewHolder.agreeTextView.setText(String.valueOf(timeLineEntity.up)); viewHolder.titleLayout.setTag(position); viewHolder.descLayout.setTag(position); viewHolder.titleLayout.setOnClickListener(mTitleOnClickListener); viewHolder.descLayout.setOnClickListener(mDescOnClickListener); }
private View fillStandView(View convertView, int position) { StandViewHolder eliminatedHolder = null; EliminatedTotalEntity entity = getItem(position); if (convertView == null) { eliminatedHolder = new StandViewHolder(); convertView = LayoutInflater.from(context).inflate(R.layout.standings_common_item_layout, null); setupChildViews(convertView, eliminatedHolder); convertView.setTag(eliminatedHolder); } else if (convertView.getTag() != null && convertView.getTag() instanceof EliminatedHolder) { eliminatedHolder = (StandViewHolder) convertView.getTag(); } else { eliminatedHolder = new StandViewHolder(); convertView = LayoutInflater.from(context).inflate(R.layout.standings_common_item_layout, null); setupChildViews(convertView, eliminatedHolder); convertView.setTag(eliminatedHolder); } if (entity.getRank() != null) { if (entity.getRank().equals("1") || entity.getRank().equals("2")) { eliminatedHolder.line.setBackgroundColor(context.getResources().getColor(R.color.title)); eliminatedHolder.greenlinestand.setVisibility(View.VISIBLE); eliminatedHolder.greylinestand.setVisibility(View.INVISIBLE); } else { eliminatedHolder.line.setBackgroundColor( context.getResources().getColor(R.color.user_info_message)); eliminatedHolder.greylinestand.setVisibility(View.VISIBLE); eliminatedHolder.greenlinestand.setVisibility(View.INVISIBLE); } eliminatedHolder.mNumber.setText(entity.getRank()); eliminatedHolder.mTeam.setText(entity.getClub_name()); eliminatedHolder.mTeam.setOnClickListener( new TeamClick(getItem(position).getTeam_id(), context)); eliminatedHolder.ico.setOnClickListener( new TeamClick(getItem(position).getTeam_id(), context)); // if (App.LOGOS.containsKey(entity.getClub_name())) { // // mImageLoader.displayImage("drawable://" + // // App.LOGOS.get(entity.getClub_name()), // // eliminatedHolder.ico, options,null); // eliminatedHolder.ico.setImageResource(App.LOGOS.get(getItem(position) // .getClub_name())); // } else { mImageLoader.displayImage( Urls.PIC_PATH + entity.getTeam_id() + ".png", eliminatedHolder.ico, options, null); // } eliminatedHolder.round.setText(entity.getMatches_total()); eliminatedHolder.mLose.setText(entity.getMatches_lost()); eliminatedHolder.mDraw.setText(entity.getMatches_draw()); eliminatedHolder.mWin.setText(entity.getMatches_won()); eliminatedHolder.mPoint.setText(entity.getPoints()); String goal = entity.getGoals_pro(); String conceded = entity.getGoals_against(); eliminatedHolder.mGoalConceded.setText(goal + "/" + conceded); } return convertView; }
private View fillEliminatedView(View convertView, int position) { EliminatedHolder eliminatedHolder = null; EliminatedTotalEntity entity = getItem(position); if (convertView == null) { convertView = LayoutInflater.from(context).inflate(R.layout.eliminated_item_per, null); eliminatedHolder = new EliminatedHolder(); setupEliminatedChildViews(convertView, eliminatedHolder); convertView.setTag(eliminatedHolder); } else if (convertView.getTag() != null && convertView.getTag() instanceof EliminatedHolder) { eliminatedHolder = (EliminatedHolder) convertView.getTag(); } else { eliminatedHolder = new EliminatedHolder(); convertView = LayoutInflater.from(context).inflate(R.layout.eliminated_item_per, null); setupEliminatedChildViews(convertView, eliminatedHolder); convertView.setTag(eliminatedHolder); } if (entity.getStart_play() != null && !entity.getStart_play().equals("")) { try { utcFormater.setTimeZone(TimeZone.getTimeZone("UTC")); Date mGmsDate = utcFormater.parse(entity.getStart_play()); long mGmsTime = mGmsDate.getTime(); String localTime = localFormater.format(mGmsTime); eliminatedHolder.time.setText(localTime); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } eliminatedHolder.back.setBackgroundColor( context.getResources().getColor(R.color.total_point_back)); } else { eliminatedHolder.time.setText(context.getString(R.string.ranking_total)); eliminatedHolder.back.setBackgroundColor( context.getResources().getColor(R.color.total_point)); } if (entity.getTeam_A_name() != null) { // if (App.LOGOS.containsKey(entity.getTeam_A_name())) { // // mImageLoader.displayImage("drawable://" + // // App.LOGOS.get(entity.getTeam_A_name()), // // eliminatedHolder.fs_a_ico, options,null); // eliminatedHolder.fs_a_ico.setImageResource(App.LOGOS.get(entity.getTeam_A_name())); // } else { mImageLoader.displayImage( Urls.PIC_PATH + entity.getTeam_A_id() + ".png", eliminatedHolder.fs_a_ico, options, null); // } eliminatedHolder.fs_a_ico.setOnClickListener( new TeamClick(getItem(position).getTeam_A_id(), context)); } if (entity.getTeam_B_name() != null) { // if (App.LOGOS.containsKey(entity.getTeam_B_name())) { // // mImageLoader.displayImage("drawable://" + // // App.LOGOS.get(entity.getTeam_B_name()), // // eliminatedHolder.fs_b_ico, options,null); // eliminatedHolder.fs_b_ico.setImageResource(App.LOGOS.get(entity.getTeam_B_name())); // } else { mImageLoader.displayImage( Urls.PIC_PATH + entity.getTeam_B_id() + ".png", eliminatedHolder.fs_b_ico, options, null); // } eliminatedHolder.fs_b_ico.setOnClickListener( new TeamClick(getItem(position).getTeam_B_id(), context)); } eliminatedHolder.fs_a_name.setText(entity.getTeam_A_name()); eliminatedHolder.fs_a_name.setOnClickListener( new TeamClick(getItem(position).getTeam_A_id(), context)); if (entity.getFs_A() != null && entity.getFs_A().equals("") && entity.getFs_B() != null && entity.getFs_B().equals("")) { eliminatedHolder.fs.setText("VS"); } else { eliminatedHolder.fs.setText(entity.getFs_A() + ":" + entity.getFs_B()); } eliminatedHolder.fs_b_name.setText(entity.getTeam_B_name()); eliminatedHolder.fs_b_name.setOnClickListener( new TeamClick(getItem(position).getTeam_B_id(), context)); return convertView; }
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; } } }