Пример #1
0
  protected void applyTheme(int theme) {
    Resources res = getResources();

    mRootView.setBackgroundColor(
        res.getColor(MODE_NIGHT == theme ? R.color.background_night : R.color.background));

    if (!mHideTitle) {
      final RelativeLayout titleView = (RelativeLayout) findViewById(R.id.title_bar);
      final TextView titleText = (TextView) findViewById(R.id.title_text);
      final View divider = findViewById(R.id.split_h);
      final ImageView backBtn = (ImageView) findViewById(R.id.ic_arrow);

      final View leftView = findViewById(R.id.back_view);

      if (MODE_NIGHT == theme) {
        titleView.setBackgroundColor(0xFF1C1C1C);
        titleText.setTextColor(0xFF666666);
        divider.setBackgroundColor(0xFF303030);
        if (null != backBtn) {
          backBtn.setImageResource(R.drawable.ic_back_night);
        }
        if (null != leftView) leftView.setBackgroundResource(R.drawable.feedback_bkg_night);
      } else {
        titleView.setBackgroundColor(res.getColor(R.color.action_bar_color));
        titleText.setTextColor(res.getColor(R.color.white));
        divider.setBackgroundColor(0xFFCACACA);
        if (null != backBtn) {
          backBtn.setImageResource(R.drawable.ic_back);
        }
        if (null != leftView) leftView.setBackgroundResource(R.drawable.feedback_bkg);
      }
    }
  }
Пример #2
0
 public void onConfigurationChanged(Configuration newConfig) {
   int orientation = activity.getResources().getConfiguration().orientation;
   if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
     hideSoftInput();
     Window win = activity.getWindow();
     win.setSoftInputMode(
         WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN
             | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
     rlPage.setBackgroundColor(DIM_COLOR);
     rlPage.postDelayed(
         new Runnable() {
           public void run() {
             getBackground();
             rlPage.setBackgroundDrawable(background);
           }
         },
         1000);
   } else {
     hideSoftInput();
     Window win = activity.getWindow();
     win.setSoftInputMode(
         WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE
             | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
     rlPage.setBackgroundColor(DIM_COLOR);
     rlPage.postDelayed(
         new Runnable() {
           public void run() {
             getBackground();
             rlPage.setBackgroundDrawable(background);
           }
         },
         1000);
   }
 }
Пример #3
0
 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
   // TODO Auto-generated method stub
   if (isChecked) {
     noteLayout.setBackgroundColor(0xffcdc9c8);
   } else {
     noteLayout.setBackgroundColor(0);
   }
 }
  /**
   * Called from within the base RestService after a rest call completes.
   *
   * @param result Can be any result type. This function should check the type and handle
   *     accordingly.
   */
  @Override
  public void onRestReturn(RestResult result) {
    if (result == null) {
      return;
    }

    if (result instanceof GetLoyaltyCardByIdResult) {

      this.loyaltyCard = ((GetLoyaltyCardByIdResult) result).getLoyaltyCard();

      TextView lblLoyaltyName = (TextView) findViewById(R.id.lblLoyaltyName);
      TextView lblLoyaltyDescription = (TextView) findViewById(R.id.lblLoyaltyDescription);
      TextView lblLoyaltyCount = (TextView) findViewById(R.id.lblLoyaltyCount);
      TextView lblLoyaltyPrize = (TextView) findViewById(R.id.lblLoyaltyPrize);
      ImageView viewButton = (ImageView) findViewById(R.id.viewButton);
      RelativeLayout lblLoyaltyCountHolder =
          (RelativeLayout) findViewById(R.id.lblLoyaltyCountHolder);
      RelativeLayout lblLoyaltyIsWonHolder =
          (RelativeLayout) findViewById(R.id.lblLoyaltyIsWonHolder);

      lblLoyaltyName.setText(this.loyaltyCard.getLoyalty().getName());
      lblLoyaltyDescription.setText(this.loyaltyCard.getLoyalty().getDescription());

      if (this.loyaltyCard.getIsWon()) {
        lblLoyaltyCount.setText("Go get your prize");
        lblLoyaltyCountHolder.setBackgroundColor(Color.parseColor("#27ae60"));
        lblLoyaltyIsWonHolder.setBackgroundColor(Color.parseColor("#2ecc71"));
        // viewButton.setVisibility(View.VISIBLE);
      } else {
        Integer total_left =
            Integer.parseInt(this.loyaltyCard.getLoyalty().getWinCount())
                - Integer.parseInt(this.loyaltyCard.getCount());
        lblLoyaltyCount.setText(total_left + " more");
        lblLoyaltyCountHolder.setBackgroundColor(Color.parseColor("#7f8c8d"));
        lblLoyaltyIsWonHolder.setBackgroundColor(Color.parseColor("#95a5a6"));
        // viewButton.setVisibility(View.INVISIBLE);
      }

      // holder.lblLoyaltyWinCount.setText(loyaltyCard.getLoyalty().getWinCount())
      lblLoyaltyPrize.setText(this.loyaltyCard.getLoyalty().getPrize());

      ListView list = (ListView) findViewById(R.id.lstStores);

      StoreListAdapter storeListAdapter =
          new StoreListAdapter(this, R.layout.store_item_row, this.loyaltyCard.getStoreItems());
      list.setAdapter(storeListAdapter);
    }
  }
Пример #5
0
  private RelativeLayout getPageView() {
    rlPage = new RelativeLayout(getContext());
    rlPage.setBackgroundDrawable(background);
    if (dialogMode) {
      RelativeLayout rlDialog = new RelativeLayout(getContext());
      rlDialog.setBackgroundColor(0xc0323232);
      int dp_8 = dipToPx(getContext(), 8);
      int width = getScreenWidth(getContext()) - dp_8 * 2;
      RelativeLayout.LayoutParams lpDialog =
          new RelativeLayout.LayoutParams(width, LayoutParams.WRAP_CONTENT);
      lpDialog.topMargin = dp_8;
      lpDialog.bottomMargin = dp_8;
      lpDialog.addRule(RelativeLayout.CENTER_IN_PARENT);
      rlDialog.setLayoutParams(lpDialog);
      rlPage.addView(rlDialog);

      rlDialog.addView(getPageTitle());
      rlDialog.addView(getPageBody());
      rlDialog.addView(getImagePin());
    } else {
      rlPage.addView(getPageTitle());
      rlPage.addView(getPageBody());
      rlPage.addView(getImagePin());
    }
    return rlPage;
  }
Пример #6
0
  /**
   * Initializing the QuickScroll, this function must be called.
   *
   * <p>
   *
   * @param type the QuickScroll type. Available inputs: <b>QuickScroll.TYPE_POPUP</b> or
   *     <b>QuickScroll.TYPE_INDICATOR</b>
   * @param list the ListView
   * @param scrollable the adapter, must implement Scrollable interface
   */
  public void init(
      final int type, final ListView list, final Scrollable scrollable, final int style) {
    if (mInitialized) return;

    mType = type;
    mList = list;
    mScrollable = scrollable;
    mGroupPosition = -1;
    mFadeIn = new AlphaAnimation(.0f, 1.0f);
    mFadeIn.setFillAfter(true);
    mFadeOut = new AlphaAnimation(1.0f, .0f);
    mFadeOut.setFillAfter(true);
    mFadeOut.setAnimationListener(
        new AnimationListener() {

          public void onAnimationStart(Animation animation) {}

          public void onAnimationRepeat(Animation animation) {}

          public void onAnimationEnd(Animation animation) {
            mScrolling = false;
          }
        });
    mScrolling = false;

    final float density = getResources().getDisplayMetrics().density;

    mList.setOnTouchListener(
        new OnTouchListener() {

          public boolean onTouch(View v, MotionEvent event) {
            if (mScrolling
                && (event.getAction() == MotionEvent.ACTION_MOVE
                    || event.getAction() == MotionEvent.ACTION_DOWN)) {
              return true;
            }
            return false;
          }
        });

    final RelativeLayout.LayoutParams containerparams =
        new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    final RelativeLayout container = new RelativeLayout(getContext());
    container.setBackgroundColor(Color.TRANSPARENT);
    containerparams.addRule(RelativeLayout.ALIGN_TOP, getId());
    containerparams.addRule(RelativeLayout.ALIGN_BOTTOM, getId());
    container.setLayoutParams(containerparams);

    if (mType == TYPE_POPUP || mType == TYPE_POPUP_WITH_HANDLE) {

      mScrollIndicatorText = new TextView(getContext());
      mScrollIndicatorText.setTextColor(Color.WHITE);
      mScrollIndicatorText.setVisibility(View.INVISIBLE);
      mScrollIndicatorText.setGravity(Gravity.CENTER);
      final RelativeLayout.LayoutParams popupparams =
          new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

      popupparams.addRule(RelativeLayout.CENTER_IN_PARENT);
      mScrollIndicatorText.setLayoutParams(popupparams);

      setPopupColor(GREY_LIGHT, GREY_DARK, 1, Color.WHITE, 1);
      setTextPadding(mTextPadding, mTextPadding, mTextPadding, mTextPadding);

      container.addView(mScrollIndicatorText);
    } else if (mType == TYPE_INDICATOR || mType == TYPE_INDICATOR_WITH_HANDLE) {
      mScrollIndicator = createPin();
      mScrollIndicatorText = (TextView) mScrollIndicator.findViewById(ID_PIN_TEXT);

      (mScrollIndicator.findViewById(ID_PIN)).getLayoutParams().width = 25;

      container.addView(mScrollIndicator);
    }

    // setting scrollbar width
    getLayoutParams().width = (int) (30 * density);
    mScrollIndicatorText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 32);

    // scrollbar setup
    if (style != STYLE_NONE) {
      final RelativeLayout layout = new RelativeLayout(getContext());
      final RelativeLayout.LayoutParams params =
          new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
      params.addRule(RelativeLayout.ALIGN_LEFT, getId());
      params.addRule(RelativeLayout.ALIGN_TOP, getId());
      params.addRule(RelativeLayout.ALIGN_RIGHT, getId());
      params.addRule(RelativeLayout.ALIGN_BOTTOM, getId());
      layout.setLayoutParams(params);

      mScrollbar = new View(getContext());
      mScrollbar.setBackgroundColor(GREY_SCROLLBAR);
      final RelativeLayout.LayoutParams scrollbarparams =
          new RelativeLayout.LayoutParams(1, LayoutParams.MATCH_PARENT);
      scrollbarparams.addRule(RelativeLayout.CENTER_HORIZONTAL);
      scrollbarparams.topMargin = mScrollbarMargin;
      scrollbarparams.bottomMargin = mScrollbarMargin;
      mScrollbar.setLayoutParams(scrollbarparams);
      layout.addView(mScrollbar);
      ((ViewGroup) mList.getParent()).addView(layout);
      // creating the handlebar
      if (mType == TYPE_INDICATOR_WITH_HANDLE || mType == TYPE_POPUP_WITH_HANDLE) {
        mHandlebar = new View(getContext());
        setHandlebarColor(BLUE_LIGHT, BLUE_LIGHT, BLUE_LIGHT_SEMITRANSPARENT);
        final RelativeLayout.LayoutParams handleparams =
            new RelativeLayout.LayoutParams((int) (12 * density), (int) (36 * density));
        mHandlebar.setLayoutParams(handleparams);
        ((RelativeLayout.LayoutParams) mHandlebar.getLayoutParams())
            .addRule(RelativeLayout.CENTER_HORIZONTAL);
        layout.addView(mHandlebar);

        mList.setOnScrollListener(
            new OnScrollListener() {

              public void onScrollStateChanged(AbsListView view, int scrollState) {}

              @SuppressLint("NewApi")
              public void onScroll(
                  AbsListView view,
                  int firstVisibleItem,
                  int visibleItemCount,
                  int totalItemCount) {
                if (!mScrolling && totalItemCount - visibleItemCount > 0) {
                  moveHandlebar(
                      getHeight() * firstVisibleItem / (totalItemCount - visibleItemCount));
                }
              }
            });
      }
    }

    mInitialized = true;

    ((ViewGroup) mList.getParent()).addView(container);
  }