Android Open Source - mobile2-android Response Count View Helper






From Project

Back to project page mobile2-android.

License

The source code is released under:

Apache License

If you think the Android project mobile2-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.ecollege.android.view.helpers;
//from ww w  .  j  a v  a2s  . c  o m
import com.ecollege.android.R;
import com.ecollege.api.model.ResponseCount;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

public class ResponseCountViewHelper {

  private String totalResponsesFormat;
  private String totalResponseFormat;
  private String responsesByYouFormat;
  private String responseByYouFormat;
  private String noResponsesString;
  
  private ImageView topicIcon;
  private TextView unreadResponseCountText;
  private TextView totalResponseCountText;
  private TextView userResponseCountText;

  public ResponseCountViewHelper(Context context, ImageView topicIcon, TextView unreadResponseCountText, TextView totalResponseCountText, TextView userResponseCountText) {
    totalResponsesFormat = context.getString(R.string.d_total_reponses);
    totalResponseFormat = context.getString(R.string.d_total_reponse);
    responsesByYouFormat = context.getString(R.string.d_responses_by_you);
    responseByYouFormat = context.getString(R.string.d_response_by_you);
    noResponsesString = context.getString(R.string.no_responses);
    
    this.topicIcon = topicIcon;
    this.unreadResponseCountText = unreadResponseCountText;
    this.totalResponseCountText = totalResponseCountText;
    this.userResponseCountText = userResponseCountText;
  }

  public void setResponseCount(ResponseCount responseCount) {
    String correctFormat = "%d";
    if (responseCount.getUnreadResponseCount() == 0) {
      unreadResponseCountText.setVisibility(View.GONE);
    } else {
      unreadResponseCountText.setText(Long.toString(responseCount.getUnreadResponseCount()));
      unreadResponseCountText.setVisibility(View.VISIBLE);
    }
    
    if (responseCount.getTotalResponseCount() == 0) {
      totalResponseCountText.setText(noResponsesString);
    } else {
      correctFormat = (responseCount.getTotalResponseCount() == 1) ? totalResponseFormat : totalResponsesFormat; 
      totalResponseCountText.setText(String.format(correctFormat, responseCount.getTotalResponseCount()));
    }
    
    if (responseCount.getPersonalResponseCount() == 0) {
      userResponseCountText.setVisibility(View.GONE);
    } else {
      correctFormat = (responseCount.getPersonalResponseCount() == 1) ? responseByYouFormat : responsesByYouFormat; 
      userResponseCountText.setText(String.format(correctFormat, responseCount.getPersonalResponseCount()));
      userResponseCountText.setVisibility(View.VISIBLE);
    }
    
    if (responseCount.getLast24HourResponseCount() >= 10) {
      topicIcon.setImageResource(R.drawable.ic_discussions_hot_topic);
    } else if (responseCount.getTotalResponseCount() == 0) {
      topicIcon.setImageResource(R.drawable.ic_discussions_no_responses);
    } else {
      topicIcon.setImageResource(R.drawable.ic_discussions_responses);
    }
  }

}




Java Source Code List

com.ecollege.android.AnnouncementActivity.java
com.ecollege.android.CourseActivity.java
com.ecollege.android.CourseAnnouncementsActivity.java
com.ecollege.android.CourseDiscussionsActivity.java
com.ecollege.android.CourseGradebookActivity.java
com.ecollege.android.CoursePeopleActivity.java
com.ecollege.android.CourseThreadActivity.java
com.ecollege.android.CoursesActivity.java
com.ecollege.android.DiscussionsActivity.java
com.ecollege.android.DropboxMessageActivity.java
com.ecollege.android.ECollegeApplication.java
com.ecollege.android.GradeActivity.java
com.ecollege.android.HomeActivity.java
com.ecollege.android.HtmlContentActivity.java
com.ecollege.android.LoginActivity.java
com.ecollege.android.MainActivity.java
com.ecollege.android.PersonActivity.java
com.ecollege.android.ProfileActivity.java
com.ecollege.android.SingleSignonActivity.java
com.ecollege.android.SplashActivity.java
com.ecollege.android.UserDiscussionActivity.java
com.ecollege.android.UserResponseActivity.java
com.ecollege.android.UserTopicActivity.java
com.ecollege.android.activities.ECollegeActivityHelper.java
com.ecollege.android.activities.ECollegeActivity.java
com.ecollege.android.activities.ECollegeDefaultActivity.java
com.ecollege.android.activities.ECollegeListActivity.java
com.ecollege.android.activities.ECollegeTabActivity.java
com.ecollege.android.adapter.ActivityFeedAdapter.java
com.ecollege.android.adapter.GroupedAdapter.java
com.ecollege.android.adapter.LoadMoreAdapter.java
com.ecollege.android.adapter.ParentAdapterObserver.java
com.ecollege.android.adapter.ResponseAdapter.java
com.ecollege.android.adapter.TopicsAdapter.java
com.ecollege.android.adapter.UberAdapter.java
com.ecollege.android.adapter.UberItem.java
com.ecollege.android.adapter.UpcomingEventsAdapter.java
com.ecollege.android.adapter.WaitingForApiAdapter.java
com.ecollege.android.errors.ECollegeAlertException.java
com.ecollege.android.errors.ECollegeException.java
com.ecollege.android.errors.ECollegePromptException.java
com.ecollege.android.errors.ECollegePromptRetryException.java
com.ecollege.android.tasks.ECollegeAsyncTask.java
com.ecollege.android.tasks.ServiceCallTask.java
com.ecollege.android.tasks.TaskPostProcessor.java
com.ecollege.android.util.CacheConfiguration.java
com.ecollege.android.util.DateTimeUtil.java
com.ecollege.android.util.FileCacheManager.java
com.ecollege.android.util.VolatileCacheManager.java
com.ecollege.android.view.HeaderView.java
com.ecollege.android.view.helpers.ResponseCountViewHelper.java