@Before
  public void setUp() throws Exception {
    Activity context = Robolectric.buildActivity(Activity.class).create().get();
    relativeLayout = new RelativeLayout(context);
    relativeLayout.setId((int) Utils.generateUniqueId());
    viewGroup = new LinearLayout(context);

    BaseForwardingNativeAd baseForwardingNativeAd = new BaseForwardingNativeAd() {};
    baseForwardingNativeAd.setTitle("test title");
    baseForwardingNativeAd.setText("test text");
    baseForwardingNativeAd.setCallToAction("test call to action");
    baseForwardingNativeAd.setClickDestinationUrl("destinationUrl");

    nativeResponse =
        new NativeResponse(
            context,
            "impressionTrackerUrl",
            "clickTrackerUrl",
            "test ID",
            baseForwardingNativeAd,
            mock(MoPubNative.MoPubNativeListener.class));

    titleView = new TextView(context);
    titleView.setId((int) Utils.generateUniqueId());
    textView = new TextView(context);
    textView.setId((int) Utils.generateUniqueId());
    callToActionView = new Button(context);
    callToActionView.setId((int) Utils.generateUniqueId());
    mainImageView = new ImageView(context);
    mainImageView.setId((int) Utils.generateUniqueId());
    iconImageView = new ImageView(context);
    iconImageView.setId((int) Utils.generateUniqueId());
    badView = new ImageView(context);
    badView.setId((int) Utils.generateUniqueId());

    relativeLayout.addView(titleView);
    relativeLayout.addView(textView);
    relativeLayout.addView(callToActionView);
    relativeLayout.addView(mainImageView);
    relativeLayout.addView(iconImageView);
    relativeLayout.addView(badView);

    viewBinder =
        new ViewBinder.Builder(relativeLayout.getId())
            .titleId(titleView.getId())
            .textId(textView.getId())
            .callToActionId(callToActionView.getId())
            .mainImageId(mainImageView.getId())
            .iconImageId(iconImageView.getId())
            .build();

    subject = new MoPubNativeAdRenderer(viewBinder);
  }
Example #2
0
 public boolean onTouch(View v, MotionEvent event) {
   if (event.getAction() == MotionEvent.ACTION_DOWN) {
     if (v.getId() == _imgSourceLang.getId()) {
       ShowFlags(RESULT_FLAG_SOURCE);
     } else if (v.getId() == _imgDestLang.getId()) {
       ShowFlags(RESULT_FLAG_DEST);
     } else if (v.getId() == _imgAccept.getId()) Accept();
     else if (v.getId() == _txtEmail.getId()) ShowContactsList(true);
     else if (v.getId() == _txtSms.getId()) ShowContactsList(false);
   }
   return true;
 }
  @Test
  public void renderAdView_shouldReturnPopulatedView() {
    subject.renderAdView(relativeLayout, nativeResponse);

    assertThat(((TextView) relativeLayout.findViewById(titleView.getId())).getText())
        .isEqualTo("test title");
    assertThat(((TextView) relativeLayout.findViewById(textView.getId())).getText())
        .isEqualTo("test text");
    assertThat(((TextView) relativeLayout.findViewById(callToActionView.getId())).getText())
        .isEqualTo("test call to action");

    // not testing images due to testing complexity
  }
Example #4
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
    countSensor = sensorManager.getDefaultSensor(Sensor.TYPE_STEP_COUNTER);
    mAccelerometer = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
    mMagnetometer = sensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD);

    sensorManager.registerListener(this, countSensor, SensorManager.SENSOR_DELAY_UI);
    sensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_UI);
    sensorManager.registerListener(this, mMagnetometer, SensorManager.SENSOR_DELAY_UI);

    setContentView(R.layout.activity_main);
    layout = (RelativeLayout) findViewById(R.id.relativeLayout);
    count = (TextView) findViewById(R.id.count);
    angle = (TextView) findViewById(R.id.Angle);

    drawView = new DrawView(this);
    drawView.setBackgroundColor(Color.BLACK);
    drawView.setMinimumHeight(73);
    RelativeLayout.LayoutParams params =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    params.addRule(RelativeLayout.BELOW, count.getId());

    layout.addView(drawView, params);
  }
  private void init(Context context) {
    mContext = context;
    loadDefaults();
    initGraphicTools();
    setWillNotDraw(false);

    setFocusable(false);
    setClickable(false);

    mTimerView = new TextView(mContext);
    mTimerView.setId(ViewHelper.generateViewId());
    mTimerView.setTextColor(
        mContext.getResources().getColor(R.color.camera_overlay_timerTextColor));
    mTimerView.setTextSize(
        mContext.getResources().getDimension(R.dimen.camera_overlay_timerTextSize));

    float shadowRadius = mContext.getResources().getDimension(R.dimen.camera_overlay_shadowRadius);
    mTimerView.setShadowLayer(shadowRadius, 0, 0, Color.BLACK);
    LayoutParams timerLParams =
        new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

    timerLParams.addRule(CENTER_IN_PARENT, mTimerView.getId());
    addView(mTimerView, timerLParams);

    mCountdownAnimation = AnimationUtils.loadAnimation(mContext, R.anim.shot_countdown_scale_up);
  }
Example #6
0
  @Override
  public boolean onLongClick(View view) {
    final EditText et = new EditText(getActivity());
    final View tmp = view;
    final String column;
    final String jobNoText = jobNo.getText().toString();
    int id = view.getId();
    et.setText(((TextView) view).getText().toString());
    editDialog.setView(et);
    if (id == jobProblem.getId()) {
      column = "jobProblem";
    } else {
      column = "remark";
    }

    editDialog.setPositiveButton(
        "Edit",
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialogInterface, int i) {
            ((TextView) tmp).setText(et.getText().toString());
            DatabaseView.exec(
                "UPDATE ServiceJob SET "
                    + column
                    + " = '"
                    + et.getText().toString()
                    + "' WHERE jobNo = '"
                    + jobNoText
                    + "'");
          }
        });
    editDialog.show();
    return true;
  }
  public HierarchyElementView(Context context, HierarchyElement it) {
    super(context);

    setColor(it.getColor());

    mIcon = new ImageView(context);
    mIcon.setImageDrawable(it.getIcon());
    mIcon.setId(1);
    mIcon.setPadding(0, 15, 5, 0);
    addView(
        mIcon,
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

    mPrimaryTextView = new TextView(context);
    mPrimaryTextView.setTextAppearance(context, android.R.style.TextAppearance_Large);
    mPrimaryTextView.setText(it.getPrimaryText());
    mPrimaryTextView.setPadding(0, 7, 0, 0);
    mPrimaryTextView.setId(2);
    LayoutParams l =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    l.addRule(RelativeLayout.RIGHT_OF, mIcon.getId());
    addView(mPrimaryTextView, l);

    mSecondaryTextView = new TextView(context);
    mSecondaryTextView.setText(it.getSecondaryText());
    mSecondaryTextView.setPadding(0, 0, 0, 7);
    mSecondaryTextView.setTextAppearance(context, android.R.style.TextAppearance_Small);
    LayoutParams lp =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    lp.addRule(RelativeLayout.BELOW, mPrimaryTextView.getId());
    lp.addRule(RelativeLayout.RIGHT_OF, mIcon.getId());
    addView(mSecondaryTextView, lp);
  }
 @Override
 public void onClick(View v) {
   if ((v.getId() == editProfileImageText.getId()) || (v.getId() == profileImage.getId())) {
     popupMenu = new PopupMenu(getActivity(), v);
     popupMenu
         .getMenuInflater()
         .inflate(R.menu.edit_profile_edit_picture_dropdown, popupMenu.getMenu());
     popupMenu.setOnMenuItemClickListener(
         new OnMenuItemClickListener() {
           @Override
           public boolean onMenuItemClick(MenuItem item) {
             if (item.getTitle().toString().equalsIgnoreCase("From Camera")) {
               /* TODO */
             } else if (item.getTitle().toString().equalsIgnoreCase("From Gallery")) {
               /* TODO */
             }
             popupMenu.dismiss();
             return true;
           }
         });
     popupMenu.show();
   } else if (v.getId() == submitButton.getId()) {
     if (IsValid()) {
       PostToServer();
     }
   }
 }
    private static ArrayList<String> extractTextFromNotification(Service service, RemoteViews view) {
    	LayoutInflater inflater = (LayoutInflater) service.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	    ArrayList<String> result = new ArrayList<String>();
	    if (view == null) {
	    	Log.d(TAG, "View is empty");
	    	return null;
	    }
		try {
			int layoutid = view.getLayoutId();
			ViewGroup localView = (ViewGroup) inflater.inflate(layoutid, null);
		    view.reapply(service.getApplicationContext(), localView);
		    ArrayList<View> outViews = new ArrayList<View>();
		    extractViewType(outViews, TextView.class, localView);
		    for (View  ttv: outViews) {
		    	TextView tv = (TextView) ttv;
		    	String txt = tv.getText().toString();
		    	if (!TextUtils.isEmpty(txt) && tv.getId() != TIMESTAMPID) {
		    		result.add(txt);
		    	}
			}
		} catch (Exception e) {
			Log.d(TAG, "FAILED to load notification " + e.toString());
			Log.wtf(TAG, e);
			return null;
			//notification might have dissapeared by now
		}
		Log.d(TAG, "Return result" + result);
	    return result;
    }
Example #10
0
  private void resetSelectedDrawerItem(TableRow tr, TextView tv) {
    if (tr != null && tv != null) {
      tr.setBackgroundColor(Color.parseColor(getResources().getString(R.color.color_white)));
      tv.setTextColor(Color.parseColor(getResources().getString(R.color.list_text_color)));
      switch (tv.getId()) {
        case R.id.tv_apply:
          tv.setCompoundDrawablesWithIntrinsicBounds(R.drawable.apply_icon, 0, 0, 0);
          break;
        case R.id.tv_card_services:
          tv.setCompoundDrawablesWithIntrinsicBounds(R.drawable.card_details, 0, 0, 0);
          break;
        case R.id.tv_learn_more:
          tv.setCompoundDrawablesWithIntrinsicBounds(R.drawable.learn_more, 0, 0, 0);
          break;
        case R.id.tv_personal_details:
          tv.setCompoundDrawablesWithIntrinsicBounds(R.drawable.p_details, 0, 0, 0);
          break;
        case R.id.tv_account_details:
          tv.setCompoundDrawablesWithIntrinsicBounds(R.drawable.a_details, 0, 0, 0);
          break;
        case R.id.tv_contact_us:
          tv.setCompoundDrawablesWithIntrinsicBounds(R.drawable.contact_us, 0, 0, 0);
          break;
        case R.id.tv_store_locator:
          tv.setCompoundDrawablesWithIntrinsicBounds(R.drawable.map_locator, 0, 0, 0);
          break;
        case R.id.tv_faq:
          tv.setCompoundDrawablesWithIntrinsicBounds(R.drawable.faq, 0, 0, 0);
          break;

        default:
          break;
      }
    }
  }
 @OnClick({R.id.mid_left_ys, R.id.mid_right_yy})
 public void midIcon(TextView textView) {
   if (tempTv != textView)
     if (textView.getId() == R.id.mid_left_ys) {
       midLeftText.setTextColor(getResources().getColor(R.color.white));
       midLeftText.setBackgroundResource(R.drawable.bg_tab_left_hl);
       midRightText.setTextColor(getResources().getColor(R.color.global_title_color));
       midRightText.setBackgroundResource(R.drawable.bg_tab_right);
       tempTv = midLeftText;
       NetworkAPI.getNetworkAPI()
           .chuzhenbydoc(
               getApp().getLongitude() + "",
               getApp().getLatitude() + "",
               showProgressDialog(),
               this);
     } else {
       midLeftText.setTextColor(getResources().getColor(R.color.global_title_color));
       midLeftText.setBackgroundResource(R.drawable.bg_tab_left);
       midRightText.setTextColor(getResources().getColor(R.color.white));
       midRightText.setBackgroundResource(R.drawable.bg_tab_right_hl);
       tempTv = midRightText;
       NetworkAPI.getNetworkAPI()
           .nearbyhosp(
               getApp().getLongitude() + "",
               getApp().getLatitude() + "",
               showProgressDialog(),
               this);
     }
 }
Example #12
0
 @Override
 public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
   if (v.getId() == R.id.txtPwd && btnLogin.isEnabled()) {
     btnLogin.performClick();
   }
   return true;
 }
Example #13
0
  private void createDayOfWeekView(final Context context) {
    mDayOfWeekGrid = new DayOfWeekGridView(context);
    mDayOfWeekGrid.setId(2);

    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    params.addRule(BELOW, mTitle.getId());
    addView(mDayOfWeekGrid, params);
  }
 public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
   switch (v.getId()) {
     case R.id.discussionText:
       savePosting();
       return true;
   }
   return false;
 }
  public void renderAdView_withFailedViewBinder_shouldReturnEmptyViews() {
    viewBinder =
        new ViewBinder.Builder(relativeLayout.getId())
            .titleId(titleView.getId())
            .textId(badView.getId())
            .callToActionId(callToActionView.getId())
            .mainImageId(mainImageView.getId())
            .iconImageId(iconImageView.getId())
            .build();

    subject = new MoPubNativeAdRenderer(viewBinder);
    subject.renderAdView(relativeLayout, nativeResponse);

    assertThat(((TextView) relativeLayout.findViewById(titleView.getId())).getText()).isEqualTo("");
    assertThat(((TextView) relativeLayout.findViewById(textView.getId())).getText()).isEqualTo("");
    assertThat(((TextView) relativeLayout.findViewById(callToActionView.getId())).getText())
        .isEqualTo("");
  }
 @Override
 public boolean onEditorAction(TextView arg0, int arg1, KeyEvent arg2) {
   if (arg0.getId() == R.id.edtFilename) {
     OnChange();
     PopulateUI();
     return true;
   }
   return false;
 }
Example #17
0
  /**
   * Show Contact View
   *
   * @param txtHomePhone home phone text view
   * @param txtMobilePhone mobile phone text view
   * @param txtEmail email text view
   * @param textAddress address text view
   */
  private void setUpContactDetailsView(
      TextView txtHomePhone, TextView txtMobilePhone, TextView txtEmail, TextView textAddress) {

    // Get and store view IDs. This would be needed for user actions on these views
    homePhoneViewId = txtHomePhone.getId();
    mobilePhoneViewId = txtMobilePhone.getId();
    emailViewId = txtEmail.getId();
    addressViewId = textAddress.getId();

    if (mContacts.hasHomePhone()) {
      txtHomePhone.setText(mContacts.getHomePhone());
      if (Contacts.canCall(activity)) {
        // Enable link
        makeContactFieldClickable(txtHomePhone);
      }
    } else {
      txtHomePhone.setVisibility(TextView.GONE);
    }

    if (mContacts.hasMobile()) {
      txtMobilePhone.setText(mContacts.getMobilePhone());
      if (Contacts.canCall(activity)) {
        makeContactFieldClickable(txtMobilePhone);
      }
    } else txtMobilePhone.setVisibility(TextView.GONE);

    if (mContacts.hasEmail()) {
      final String email = mContacts.getEmail();
      txtEmail.setText(email);
      if (Contacts.canSendEmail(activity, email)) makeContactFieldClickable(txtEmail);
    } else txtEmail.setVisibility(TextView.GONE);

    if (mContacts.hasAddresses()) {
      final String address = mContacts.getAddressString();
      textAddress.setText(address);
      // Do not make address clickable if in offline mode
      if (!AppHelper.isAppInOffLineMode()) {
        makeContactFieldClickable(textAddress);
      }
    } else {
      textAddress.setVisibility(TextView.GONE);
    }
  }
 @Override
 public void onClick(View v) {
   AppSettings settings = AppSettings.getInstance(getActivity());
   if (v.getId() == R.id.next) {
     mListener.onOptionSelected();
   } else if (v.getId() == R.id.prev) {
     getActivity().onBackPressed();
   } else if (v.getId() == m12h.getId()) {
     m12h.setSelected(true);
     m24h.setSelected(false);
     settings.setTimeFormatFor(mParam1, PrayTime.TIME_12);
     mListener.onOptionSelected();
   } else if (v.getId() == m24h.getId()) {
     m12h.setSelected(false);
     m24h.setSelected(true);
     settings.setTimeFormatFor(mParam1, PrayTime.TIME_24);
     mListener.onOptionSelected();
   }
 }
Example #19
0
 /**
  * This adds a divider at the bottom of this layout. Used to separate fields in lists.
  * 
  * @param v
  */
 public void addDivider(ImageView v) {
     RelativeLayout.LayoutParams dividerParams =
         new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
     if (mImageView != null) {
         dividerParams.addRule(RelativeLayout.BELOW, mImageView.getId());
     } else if (mMissingImage != null) {
         dividerParams.addRule(RelativeLayout.BELOW, mMissingImage.getId());
     } else if (mVideoButton != null) {
         dividerParams.addRule(RelativeLayout.BELOW, mVideoButton.getId());
     } else if (mAudioButton != null) {
         dividerParams.addRule(RelativeLayout.BELOW, mAudioButton.getId());
     } else if (mView_Text != null) {
         // No picture
         dividerParams.addRule(RelativeLayout.BELOW, mView_Text.getId());
     } else {
         Log.e(t, "Tried to add divider to uninitialized ATVWidget");
         return;
     }
     addView(v, dividerParams);
 }
Example #20
0
 /* (non-Javadoc)
  * calls {@link #convText for formatting the values retrieved from the cursor}
  * @see android.widget.SimpleCursorAdapter#setViewText(android.widget.TextView, java.lang.String)
  */
 @Override
 public void setViewText(TextView v, String text) {
   switch (v.getId()) {
     case R.id.date:
       text = Utils.convDateTime(text, itemDateFormat);
       break;
     case R.id.amount:
       text = Utils.convAmount(text, mAccount.currency);
   }
   super.setViewText(v, text);
 }
Example #21
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    if (savedInstanceState == null)
      getSupportFragmentManager()
          .beginTransaction()
          .add(HeadlessFragment.newInstance(), "fragment_headless")
          .commit();
    textView = (TextView) findViewById(R.id.not_button);
    mysteryText = (TextView) findViewById(R.id.output_text);

    buttonRight = (Button) findViewById(R.id.up_button);
    buttonLeft = (Button) findViewById(R.id.down_button);
    mysteryButton = (Button) findViewById(R.id.mystery_button);
    activityButton = (Button) findViewById(R.id.new_activity_button);
    fragmentButton = (Button) findViewById(R.id.fragment_button);

    mysteryButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            if (((HeadlessFragment)
                    getSupportFragmentManager().findFragmentByTag("fragment_headless"))
                .work("d20")) {
              mysteryText.setText(R.string.default_loading_text);
              // new LoadingTask(MainActivity.this).execute();
            }
          }
        });

    buttonRight.setOnClickListener(this);
    buttonLeft.setOnClickListener(this);
    activityButton.setOnClickListener(this);
    fragmentButton.setOnClickListener(this);

    if (savedInstanceState != null) {
      textView.setText(savedInstanceState.getString(String.valueOf(textView.getId())));
      mysteryText.setText(savedInstanceState.getString(String.valueOf(mysteryText.getId())));
    }
  }
    @Override
    public void setViewText(TextView v, String text) {
      switch (v.getId()) {
        case R.id.date:
          final Date d = new Date(Long.parseLong(text));
          v.setText(d.toLocaleString());
          break;

        default:
          super.setViewText(v, text);
      }
    }
Example #23
0
  private boolean setViewValue(final TextView view, final Cursor cursor, final Binding binding) {
    switch (view.getId()) {
      case R.id.goal_time:
        return setTimeValue(view, cursor, binding);

      case R.id.goal_player:
        return setGoalPlayerValue(view, cursor, binding);

      default:
        return false;
    }
  }
Example #24
0
 @Override
 public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
   switch (v.getId()) {
     case R.id.useridEdittext:
       if (actionId == EditorInfo.IME_ACTION_NEXT
           || (event != null && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) {
         // do something;
         txtPassword.setFocusable(true);
         return false;
       }
       break;
   }
   return false;
 }
  private void addAnswerRadioButtons() {
    respRadioButton = new RadioButton[NUMBER_OF_ANSWERS];
    for (int i = 0; i < NUMBER_OF_ANSWERS; i++) {
      addAnswerRadioButton(i, rg); // AƱadir respueta al array.
    }
    RelativeLayout.LayoutParams params =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);

    params.addRule(RelativeLayout.ALIGN_LEFT);
    TextView question =
        (TextView) mRootView.findViewById(R.id.exerciseQuestion); // Obtener pregunta.
    params.addRule(RelativeLayout.BELOW, question.getId()); // Debajo de la pregunta.
    ((RelativeLayout) mCardView).addView(rg, params);
  }
 @Override
 public void onClick(View v) {
   Log.i(TAG, "onClick");
   if (v.getId() == mTextViewSalir.getId()) {
     finish();
   } else {
     if (mOfficeSelected > 0) {
       Intent intent = new Intent(this, QuestionsActivity.class);
       intent.putExtra("officeSelected", mOfficeSelected);
       startActivity(intent);
     } else {
       DialogAlertFragment dialogError =
           DialogAlertFragment.newInstance("Debe Seleccionar una oficina del mapa");
       dialogError.show(getSupportFragmentManager(), "dialogErrorMap");
     }
   }
 }
  private void solve(
      TextView tv,
      Spinner regressionType,
      EditText input,
      Vector<Double> time,
      Vector<Double> data) {
    DecimalFormat df = new DecimalFormat("0.000000");

    if (!input.getText().toString().equals("")) {
      switch (tv.getId()) {
        case R.id.xOutput:
          switch (regressionType.getSelectedItemPosition()) {
            case 0:
              tv.setText(df.format(lEQX.valueAt(Double.parseDouble(input.getText().toString()))));
              break;
            case 1:
              tv.setText(df.format(qEQX.valueAt(Double.parseDouble(input.getText().toString()))));
              break;
          }
          break;
        case R.id.yOutput:
          switch (regressionType.getSelectedItemPosition()) {
            case 0:
              tv.setText(df.format(lEQY.valueAt(Double.parseDouble(input.getText().toString()))));
              break;
            case 1:
              tv.setText(df.format(qEQY.valueAt(Double.parseDouble(input.getText().toString()))));
              break;
          }
          break;
        case R.id.zOutput:
          switch (regressionType.getSelectedItemPosition()) {
            case 0:
              tv.setText(df.format(lEQZ.valueAt(Double.parseDouble(input.getText().toString()))));
              break;
            case 1:
              tv.setText(df.format(qEQZ.valueAt(Double.parseDouble(input.getText().toString()))));
              break;
          }
          break;
      }
    } else {
      Toast.makeText(this, "Invalid Input", Toast.LENGTH_LONG).show();
    }
  }
Example #28
0
  private void setSelectedDrawerItem(TableRow tr, TextView tv) {
    tr.setBackgroundColor(
        Color.parseColor(getResources().getString(R.color.list_background_pressed)));
    tv.setTextColor(Color.parseColor(getResources().getString(R.color.color_action_bar)));
    switch (tv.getId()) {
      case R.id.tv_apply:
        tv.setCompoundDrawablesWithIntrinsicBounds(R.drawable.apply_icon_highlighted, 0, 0, 0);
        break;
      case R.id.tv_card_services:
        tv.setCompoundDrawablesWithIntrinsicBounds(R.drawable.card_details_highlighted, 0, 0, 0);
        break;
      case R.id.tv_learn_more:
        tv.setCompoundDrawablesWithIntrinsicBounds(R.drawable.learn_more_higlighted, 0, 0, 0);
        break;
      case R.id.tv_personal_details:
        tv.setCompoundDrawablesWithIntrinsicBounds(R.drawable.p_details_highlighted, 0, 0, 0);
        break;
      case R.id.tv_account_details:
        tv.setCompoundDrawablesWithIntrinsicBounds(R.drawable.a_details_highlighted, 0, 0, 0);
        break;
      case R.id.tv_contact_us:
        tv.setCompoundDrawablesWithIntrinsicBounds(R.drawable.contact_us_highlighted, 0, 0, 0);
        break;
      case R.id.tv_store_locator:
        tv.setCompoundDrawablesWithIntrinsicBounds(R.drawable.map_locator_highlighted, 0, 0, 0);
        break;
      case R.id.tv_faq:
        tv.setCompoundDrawablesWithIntrinsicBounds(R.drawable.faq_highlighted, 0, 0, 0);
        break;

      default:
        break;
    }

    if (tr != null
        && !tr.equals(highlightedTableRow)
        && tv != null
        && !tv.equals(highlightedTextView)) {
      resetSelectedDrawerItem(highlightedTableRow, highlightedTextView);
      highlightedTableRow = tr;
      highlightedTextView = tv;
    }
  }
  @Override
  public void onClick(View v) {

    int id = v.getId();

    if (id == mBackLayout.getId() || id == mTitleTextView.getId()) {

      mMediaPlayerController.onBackPress(MediaPlayMode.PLAYMODE_WINDOW);

    } else if (id == mPlaybackImageView.getId()) {

      if (mMediaPlayerController.isPlaying()) {
        mMediaPlayerController.pause();
        show(0);
      } else if (!mMediaPlayerController.isPlaying()) {
        mMediaPlayerController.start();
        show();
      }
    }
  }
    @Override
    public void onEvent(final Short s) {
      final String shortString = textView.getText().toString();

      if (textView.getId() == R.id.consumableEventCount) {
        numberMessage.setText("New event in: " + s);
      }

      if (shortString.length() == 0) {
        textView.setText("0");
      } else {
        Short value = Short.parseShort(shortString);
        ++value;
        textView.setText(value + "");
      }

      // end game
      if (s == Short.MAX_VALUE) {
        eventBus.stop();
      }
    }