コード例 #1
0
  public void initUI() {

    LinearLayout parent = EditManager.INSTANCE.getToolsLayout();
    Context context = parent.getContext();
    ILayer editLayer = EditManager.INSTANCE.getEditLayer();
    int padding = 2;

    if (editLayer != null) {
      createFeatureButton = new ImageButton(context);
      createFeatureButton.setLayoutParams(
          new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
      createFeatureButton.setBackground(
          Compat.getDrawable(context, R.drawable.editing_create_line));
      createFeatureButton.setPadding(0, padding, 0, padding);
      createFeatureButton.setOnClickListener(this);
      createFeatureButton.setOnTouchListener(this);
      parent.addView(createFeatureButton);

      selectEditableButton = new ImageButton(context);
      selectEditableButton.setLayoutParams(
          new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
      selectEditableButton.setBackground(
          Compat.getDrawable(context, R.drawable.editing_select_editable));
      selectEditableButton.setPadding(0, padding, 0, padding);
      selectEditableButton.setOnClickListener(this);
      selectEditableButton.setOnTouchListener(this);
      parent.addView(selectEditableButton);
    }

    selectAllButton = new ImageButton(context);
    selectAllButton.setLayoutParams(
        new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    selectAllButton.setBackground(Compat.getDrawable(context, R.drawable.editing_select_all));
    selectAllButton.setPadding(0, padding, 0, padding);
    selectAllButton.setOnClickListener(this);
    selectAllButton.setOnTouchListener(this);
    parent.addView(selectAllButton);

    if (editLayer != null) {
      undoButton = new ImageButton(context);
      undoButton.setLayoutParams(
          new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
      undoButton.setBackground(Compat.getDrawable(context, R.drawable.editing_undo));
      undoButton.setPadding(0, padding, 0, padding);
      undoButton.setOnTouchListener(this);
      undoButton.setOnClickListener(this);
      parent.addView(undoButton);
      undoButton.setVisibility(View.GONE);

      commitButton = new ImageButton(context);
      commitButton.setLayoutParams(
          new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
      commitButton.setBackground(Compat.getDrawable(context, R.drawable.editing_commit));
      commitButton.setPadding(0, padding, 0, padding);
      commitButton.setOnTouchListener(this);
      commitButton.setOnClickListener(this);
      parent.addView(commitButton);
      commitButton.setVisibility(View.GONE);
    }
  }
コード例 #2
0
ファイル: NewShopActivity.java プロジェクト: GracieZhou/test
 @Override
 public void onDestroy() {
   if (myOnClickListener != null) {
     myOnClickListener = null;
   }
   super.onDestroy();
   mBtnShopTop.setBackground(null);
   mBtnShopBottom.setBackground(null);
   mBtnShopLeft.setBackground(null);
 }
コード例 #3
0
  /** Sets Buttons visibility */
  @SuppressWarnings("deprecation")
  @SuppressLint("NewApi")
  protected void setupButtons() {

    if (mCardHeader.isButtonOverflowVisible()) {
      visibilityButtonHelper(VISIBLE, GONE, GONE);
      // Add popup
      addPopup();
    } else {

      if (mCardHeader.isButtonExpandVisible()) {
        visibilityButtonHelper(GONE, VISIBLE, GONE);
      } else {

        if (mCardHeader.isOtherButtonVisible() && mImageButtonOther != null) {
          visibilityButtonHelper(GONE, GONE, VISIBLE);
          // Check if button is not null
          if (mImageButtonOther != null) {
            if (mCardHeader.getOtherButtonDrawable() > 0) {
              if (Build.VERSION.SDK_INT >= 16) {
                mImageButtonOther.setBackground(
                    getResources().getDrawable(mCardHeader.getOtherButtonDrawable()));
              } else {
                mImageButtonOther.setBackgroundDrawable(
                    getResources().getDrawable(mCardHeader.getOtherButtonDrawable()));
              }
            }
            addOtherListener();
          }
        } else {
          visibilityButtonHelper(GONE, GONE, GONE);
        }
      }
    }
  }
コード例 #4
0
 @SuppressWarnings("deprecation")
 private void handleToolIcons(View activeToolButton) {
   Context context = activeToolButton.getContext();
   Tool currentTool = EditManager.INSTANCE.getActiveTool();
   if (selectEditableButton != null) {
     if (currentTool != null && activeToolButton == selectEditableButton) {
       selectEditableButton.setBackground(
           Compat.getDrawable(context, R.drawable.editing_select_editable_active));
     } else {
       selectEditableButton.setBackground(
           Compat.getDrawable(context, R.drawable.editing_select_editable));
     }
   }
   if (selectAllButton != null)
     if (currentTool != null && activeToolButton == selectAllButton) {
       selectAllButton.setBackground(
           Compat.getDrawable(context, R.drawable.editing_select_all_active));
     } else {
       selectAllButton.setBackground(Compat.getDrawable(context, R.drawable.editing_select_all));
     }
 }
コード例 #5
0
  /**
   * Constructs a layout for the specified InfoBar. After calling this, be sure to set the message,
   * the buttons, and/or the custom content using setMessage(), setButtons(), and
   * setCustomContent().
   *
   * @param context The context used to render.
   * @param infoBarView InfoBarView that listens to events.
   * @param iconResourceId ID of the icon to use for the InfoBar.
   * @param iconBitmap Bitmap for the icon to use, if the resource ID wasn't passed through.
   * @param message The message to show in the infobar.
   */
  public InfoBarLayout(
      Context context,
      InfoBarView infoBarView,
      int iconResourceId,
      Bitmap iconBitmap,
      CharSequence message) {
    super(context);
    mInfoBarView = infoBarView;

    // Grab the dimensions.
    Resources res = getResources();
    mMargin = res.getDimensionPixelOffset(R.dimen.infobar_margin);
    mIconSize = res.getDimensionPixelSize(R.dimen.infobar_icon_size);
    mMinWidth = res.getDimensionPixelSize(R.dimen.infobar_min_width);
    mAccentColor = ApiCompatibilityUtils.getColor(res, R.color.infobar_accent_blue);

    // Set up the close button. Apply padding so it has a big touch target.
    mCloseButton = new ImageButton(context);
    mCloseButton.setId(R.id.infobar_close_button);
    mCloseButton.setImageResource(R.drawable.btn_close);
    TypedArray a = getContext().obtainStyledAttributes(new int[] {R.attr.selectableItemBackground});
    Drawable closeButtonBackground = a.getDrawable(0);
    a.recycle();
    mCloseButton.setBackground(closeButtonBackground);
    mCloseButton.setPadding(mMargin, mMargin, mMargin, mMargin);
    mCloseButton.setOnClickListener(this);
    mCloseButton.setContentDescription(res.getString(R.string.infobar_close));
    mCloseButton.setLayoutParams(new LayoutParams(0, -mMargin, -mMargin, -mMargin));

    // Set up the icon.
    if (iconResourceId != 0 || iconBitmap != null) {
      mIconView = new ImageView(context);
      if (iconResourceId != 0) {
        mIconView.setImageResource(iconResourceId);
      } else if (iconBitmap != null) {
        mIconView.setImageBitmap(iconBitmap);
      }
      mIconView.setLayoutParams(new LayoutParams(0, 0, mMargin / 2, 0));
      mIconView.getLayoutParams().width = mIconSize;
      mIconView.getLayoutParams().height = mIconSize;
      mIconView.setFocusable(false);
    }

    // Set up the message view.
    mMessageTextView = (TextView) LayoutInflater.from(context).inflate(R.layout.infobar_text, null);
    mMessageTextView.setText(message, TextView.BufferType.SPANNABLE);
    mMessageTextView.setMovementMethod(LinkMovementMethod.getInstance());
    mMessageTextView.setLinkTextColor(mAccentColor);
    mMessageView = mMessageTextView;
  }
コード例 #6
0
  /** 放大级别 3 - 19 */
  @SuppressLint("NewApi")
  private void perfomZoom(boolean isZoomIn) {
    try {
      MapStatusUpdate u;
      zoomLevel = mBaiduMap.getMapStatus().zoom;
      if (isZoomIn) {
        zoomOutButton.setImageResource(R.drawable.main_icon_zoomout);
        if (zoomLevel + 0.5 < mBaiduMap.getMaxZoomLevel() * 0.9) {
          zoomLevel += 0.5;
          u = MapStatusUpdateFactory.zoomTo(zoomLevel);
        } else {
          zoomLevel = (float) (mBaiduMap.getMaxZoomLevel() * 0.9);
          u = MapStatusUpdateFactory.zoomTo(zoomLevel);
          zoomInButton.setImageResource(R.drawable.main_icon_zoomin_dis);
        }
        zoomInButton.setBackground(
            getResources().getDrawable(R.drawable.main_widget_bottombutton_selector));

      } else {
        zoomInButton.setImageResource(R.drawable.main_icon_zoomin);
        if (zoomLevel - 0.5 > mBaiduMap.getMinZoomLevel() + 5) {
          zoomLevel -= 0.5;
          u = MapStatusUpdateFactory.zoomTo(zoomLevel);
        } else {
          zoomLevel = mBaiduMap.getMinZoomLevel() + 5;
          u = MapStatusUpdateFactory.zoomTo(zoomLevel);
          zoomOutButton.setImageResource(R.drawable.main_icon_zoomout_dis);
        }
        zoomOutButton.setBackground(
            getResources().getDrawable(R.drawable.main_widget_bottombutton_selector));
      }

      mBaiduMap.animateMapStatus(u);
    } catch (NumberFormatException e) {
      e.printStackTrace();
    }
  }
コード例 #7
0
  @SuppressWarnings("deprecation")
  private void setKeyStowDrawableAndVisibility() {
    Drawable replacer = null;
    if (layoutKeys.getVisibility() == View.GONE)
      replacer = getResources().getDrawable(R.drawable.showkeys);
    else replacer = getResources().getDrawable(R.drawable.hidekeys);

    int sdk = android.os.Build.VERSION.SDK_INT;
    if (sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) {
      keyStow.setBackgroundDrawable(replacer);
    } else {
      keyStow.setBackground(replacer);
    }

    if (connection.getExtraKeysToggleType() == Constants.EXTRA_KEYS_OFF)
      keyStow.setVisibility(View.GONE);
    else keyStow.setVisibility(View.VISIBLE);
  }
コード例 #8
0
ファイル: QuickLaunchView.java プロジェクト: the3sky/SnowBall
 @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
 @Override
 public Object instantiateItem(ViewGroup container, int position) {
   LayoutInflater inflater =
       (LayoutInflater) QuickLaunchView.this.getContext().getSystemService("layout_inflater");
   LinearLayout pageView =
       (LinearLayout) inflater.inflate(R.layout.shade_quick_launch_page, null);
   for (int i = position * 5; i < (position * 5) + 5; i++) {
     ImageButton button = (ImageButton) inflater.inflate(R.layout.quicklaunch_button, null);
     button.setScaleType(ScaleType.FIT_CENTER);
     if (i < this.quickLaunchApps.size()) {
       App app = this.quickLaunchApps.get(i);
       button.setImageDrawable(app.getAppIcon());
       button.setOnClickListener(new AnonymousClass_1(app));
     } else {
       button.setBackground(null);
       button.setOnClickListener(null);
     }
     pageView.addView(button, new LayoutParams(-1, -1, 0.5f));
   }
   container.addView(pageView);
   return pageView;
 }
コード例 #9
0
ファイル: NewShopActivity.java プロジェクト: GracieZhou/test
  private void initView() {
    myOnClickListener = new MyOnClickListener();
    mBtnShopLeft.setOnClickListener(myOnClickListener);
    mBtnShopTop.setOnClickListener(myOnClickListener);
    mBtnShopBottom.setOnClickListener(myOnClickListener);

    myOnKeyListener = new MyOnKeyListener();
    mBtnShopLeft.setOnKeyListener(myOnKeyListener);
    mBtnShopTop.setOnKeyListener(myOnKeyListener);
    mBtnShopBottom.setOnKeyListener(myOnKeyListener);

    myOnFocusChangeListener = new MyOnFocusChangeListener();
    mBtnShopLeft.setOnFocusChangeListener(myOnFocusChangeListener);
    mBtnShopTop.setOnFocusChangeListener(myOnFocusChangeListener);
    mBtnShopBottom.setOnFocusChangeListener(myOnFocusChangeListener);

    mViewBean.setmFocusObject(myFocusView);
    myFocusView.setVisibility(View.INVISIBLE);

    PublicFragment pu = new PublicFragment();
    pu.addViewGlobalLayoutListener(mBtnShopLeft, mViewBean);
    pu.addViewGlobalLayoutListener(mBtnShopTop, mViewBean);
    pu.addViewGlobalLayoutListener(mBtnShopBottom, mViewBean);

    if (Utils.isNetworkState) {
      mBtnShopLeft.setBackground(
          HomeApplication.getInstance().getResources().getDrawable(R.drawable.shop_left));
      mBtnShopTop.setBackground(
          HomeApplication.getInstance().getResources().getDrawable(R.drawable.shop_right_up1));
      mBtnShopBottom.setBackground(
          HomeApplication.getInstance().getResources().getDrawable(R.drawable.shop_right_up2));
    } else {
      mBtnShopLeft.setBackground(
          HomeApplication.getInstance().getResources().getDrawable(R.drawable.shop_left));
      mBtnShopTop.setBackground(
          HomeApplication.getInstance().getResources().getDrawable(R.drawable.shop_right_up));
      mBtnShopBottom.setBackground(
          HomeApplication.getInstance().getResources().getDrawable(R.drawable.shop_right_up));
    }
    Log.d(TAG, "NewShopFragment---start end!!!");
  }
コード例 #10
0
 public void refreshButtons() {
   if (mNumberofButtons == 0) {
     return;
   }
   int navBarColor = Settings.System.getInt(mContentRes, Settings.System.NAVIGATION_BAR_COLOR, -1);
   int navButtonColor =
       Settings.System.getInt(mContentRes, Settings.System.NAVIGATION_BAR_TINT, -1);
   float navButtonAlpha =
       Settings.System.getFloat(
           mContentRes, Settings.System.NAVIGATION_BAR_BUTTON_ALPHA, STOCK_ALPHA);
   int glowColor =
       Settings.System.getInt(mContentRes, Settings.System.NAVIGATION_BAR_GLOW_TINT, 0);
   float BarAlpha = 1.0f;
   String alphas[];
   String settingValue =
       Settings.System.getString(mContentRes, Settings.System.NAVIGATION_BAR_ALPHA_CONFIG);
   if (!TextUtils.isEmpty(settingValue)) {
     alphas = settingValue.split(";");
     BarAlpha = Float.parseFloat(alphas[0]) / 255;
   }
   int a = Math.round(BarAlpha * 255);
   Drawable mBackground =
       AwesomeConstants.getSystemUIDrawable(mContext, "com.android.systemui:drawable/nav_bar_bg");
   if (mBackground instanceof ColorDrawable) {
     BackgroundAlphaColorDrawable bacd =
         new BackgroundAlphaColorDrawable(
             navBarColor > 0 ? navBarColor : ((ColorDrawable) mBackground).getColor());
     bacd.setAlpha(a);
     mNavBarContainer.setBackground(bacd);
   } else {
     mBackground.setAlpha(a);
     mNavBarContainer.setBackground(mBackground);
   }
   for (int i = 0; i < mNumberofButtons; i++) {
     ImageButton ib = mButtonViews.get(i);
     Drawable d = mButtons.get(i).getIcon();
     if (navButtonColor != -1) {
       d.setColorFilter(navButtonColor, PorterDuff.Mode.SRC_ATOP);
     }
     ib.setImageDrawable(d);
     ib.setOnClickListener(mNavBarClickListener);
     ib.setVisibility(View.VISIBLE);
     ib.setAlpha(navButtonAlpha);
     StateListDrawable sld = new StateListDrawable();
     sld.addState(new int[] {android.R.attr.state_pressed}, new ColorDrawable(glowColor));
     sld.addState(StateSet.WILD_CARD, mNavBarContainer.getBackground());
     ib.setBackground(sld);
   }
   for (int i = mNumberofButtons; i < mButtonViews.size(); i++) {
     ImageButton ib = mButtonViews.get(i);
     ib.setVisibility(View.GONE);
   }
   int menuloc = Settings.System.getInt(mContentRes, Settings.System.MENU_LOCATION, 0);
   switch (menuloc) {
     case SHOW_BOTH_MENU:
       mLeftMenu.setVisibility(View.VISIBLE);
       mRightMenu.setVisibility(View.VISIBLE);
       break;
     case SHOW_LEFT_MENU:
       mLeftMenu.setVisibility(View.VISIBLE);
       mRightMenu.setVisibility(View.INVISIBLE);
       break;
     case SHOW_RIGHT_MENU:
       mLeftMenu.setVisibility(View.INVISIBLE);
       mRightMenu.setVisibility(View.VISIBLE);
       break;
     case SHOW_DONT:
       mLeftMenu.setVisibility(View.GONE);
       mRightMenu.setVisibility(View.GONE);
       break;
   }
   if (navButtonColor != -1) {
     mLeftMenu.setColorFilter(navButtonColor);
     mRightMenu.setColorFilter(navButtonColor);
   }
 }
コード例 #11
0
  @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
  @Override
  public View onCreateView(
      LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    mRoot = inflater.inflate(R.layout.fragment_moviedetail, container, false);
    if (VersionUtils.isJellyBean() && container != null) {
      mRoot.setMinimumHeight(container.getMinimumHeight());
    }
    ButterKnife.inject(this, mRoot);

    if (!VersionUtils.isJellyBean()) {
      mPlayButton.setBackgroundDrawable(
          PixelUtils.changeDrawableColor(
              mPlayButton.getContext(), R.drawable.play_button_circle, sMovie.color));
    } else {
      mPlayButton.setBackground(
          PixelUtils.changeDrawableColor(
              mPlayButton.getContext(), R.drawable.play_button_circle, sMovie.color));
    }

    mTitle.setText(sMovie.title);
    if (!sMovie.rating.equals("-1")) {
      Double rating = Double.parseDouble(sMovie.rating);
      mRating.setProgress(rating.intValue());
      mRating.setVisibility(View.VISIBLE);
    } else {
      mRating.setVisibility(View.GONE);
    }

    String metaDataStr = sMovie.year;
    if (!TextUtils.isEmpty(sMovie.runtime)) {
      metaDataStr += " • ";
      metaDataStr += sMovie.runtime + " " + getString(R.string.minutes);
    }

    if (!TextUtils.isEmpty(sMovie.genre)) {
      metaDataStr += " • ";
      metaDataStr += sMovie.genre;
    }

    mMeta.setText(metaDataStr);

    if (!TextUtils.isEmpty(sMovie.synopsis)) {
      mSynopsis.setText(sMovie.synopsis);
      mSynopsis.post(
          new Runnable() {
            @Override
            public void run() {
              boolean ellipsized = false;
              Layout layout = mSynopsis.getLayout();
              if (layout == null) return;
              int lines = layout.getLineCount();
              if (lines > 0) {
                int ellipsisCount = layout.getEllipsisCount(lines - 1);
                if (ellipsisCount > 0) {
                  ellipsized = true;
                }
              }
              mReadMore.setVisibility(ellipsized ? View.VISIBLE : View.GONE);
            }
          });
    } else {
      mSynopsis.setClickable(false);
      mReadMore.setVisibility(View.GONE);
    }

    mWatchTrailer.setVisibility(
        sMovie.trailer == null || sMovie.trailer.isEmpty() ? View.GONE : View.VISIBLE);

    mSubtitles.setFragmentManager(getFragmentManager());
    mQuality.setFragmentManager(getFragmentManager());
    mSubtitles.setTitle(R.string.subtitles);
    mQuality.setTitle(R.string.quality);

    mSubtitles.setText(R.string.loading_subs);
    mSubtitles.setClickable(false);

    if (sMovie.getSubsProvider() != null) {
      sMovie
          .getSubsProvider()
          .getList(
              sMovie,
              new SubsProvider.Callback() {
                @Override
                public void onSuccess(Map<String, String> subtitles) {
                  if (!mAttached) return;

                  if (subtitles == null) {
                    ThreadUtils.runOnUiThread(
                        new Runnable() {
                          @Override
                          public void run() {
                            mSubtitles.setText(R.string.no_subs_available);
                          }
                        });
                    return;
                  }

                  sMovie.subtitles = subtitles;

                  String[] languages = subtitles.keySet().toArray(new String[subtitles.size()]);
                  Arrays.sort(languages);
                  final String[] adapterLanguages = new String[languages.length + 1];
                  adapterLanguages[0] = "no-subs";
                  System.arraycopy(languages, 0, adapterLanguages, 1, languages.length);

                  String[] readableNames = new String[adapterLanguages.length];
                  for (int i = 0; i < readableNames.length; i++) {
                    String language = adapterLanguages[i];
                    if (language.equals("no-subs")) {
                      readableNames[i] = getString(R.string.no_subs);
                    } else {
                      Locale locale = LocaleUtils.toLocale(language);
                      readableNames[i] = locale.getDisplayName(locale);
                    }
                  }

                  mSubtitles.setListener(
                      new OptionSelector.SelectorListener() {
                        @Override
                        public void onSelectionChanged(int position, String value) {
                          onSubtitleLanguageSelected(adapterLanguages[position]);
                        }
                      });
                  mSubtitles.setData(readableNames);
                  ThreadUtils.runOnUiThread(
                      new Runnable() {
                        @Override
                        public void run() {
                          mSubtitles.setClickable(true);
                        }
                      });

                  String defaultSubtitle =
                      PrefUtils.get(mSubtitles.getContext(), Prefs.SUBTITLE_DEFAULT, null);
                  if (subtitles.containsKey(defaultSubtitle)) {
                    onSubtitleLanguageSelected(defaultSubtitle);
                    mSubtitles.setDefault(Arrays.asList(adapterLanguages).indexOf(defaultSubtitle));
                  } else {
                    onSubtitleLanguageSelected("no-subs");
                    mSubtitles.setDefault(Arrays.asList(adapterLanguages).indexOf("no-subs"));
                  }
                }

                @Override
                public void onFailure(Exception e) {
                  mSubtitles.setData(new String[0]);
                  mSubtitles.setClickable(true);
                }
              });
    } else {
      mSubtitles.setClickable(false);
      mSubtitles.setText(R.string.no_subs_available);
    }

    if (sMovie.torrents.size() > 0) {
      final String[] qualities =
          sMovie.torrents.keySet().toArray(new String[sMovie.torrents.size()]);
      SortUtils.sortQualities(qualities);
      mQuality.setData(qualities);
      mQuality.setListener(
          new OptionSelector.SelectorListener() {
            @Override
            public void onSelectionChanged(int position, String value) {
              mSelectedQuality = value;
              renderHealth();
              updateMagnet();
            }
          });
      String defaultQuality = PrefUtils.get(mQuality.getContext(), Prefs.QUALITY_DEFAULT, "720p");
      int qualityIndex =
          Arrays.asList(qualities).contains(defaultQuality)
              ? Arrays.asList(qualities).indexOf(defaultQuality)
              : qualities.length - 1;
      mSelectedQuality = qualities[qualityIndex];
      mQuality.setText(mSelectedQuality);
      mQuality.setDefault(qualityIndex);
      renderHealth();
      updateMagnet();
    }

    if (mCoverImage != null) {
      Picasso.with(mCoverImage.getContext()).load(sMovie.image).into(mCoverImage);
    }

    return mRoot;
  }
コード例 #12
0
  @SuppressLint("NewApi")
  @Override
  public void initView() {
    setHeaderBackgroudResource(R.drawable.header_backgroud);

    setHeaderCenterViewText("微信");

    right1 = new ImageButton(this);
    right1.setImageResource(R.drawable.header_right_btn);
    right1.setBackground(getResources().getDrawable(R.drawable.header_btn_normal));
    setHeaderRightView(right1);

    right2 = new Button(this);
    right2.setText("添加");
    right2.setTextColor(Color.WHITE);
    right2.setTextSize(15);
    right2.setBackground(getResources().getDrawable(R.drawable.header_btn_normal));

    setFooterVisible(true);
    setFooterButtonBackgroud(0, android.R.drawable.ic_menu_call);
    setFooterButtonBackgroud(1, android.R.drawable.ic_menu_gallery);
    setFooterButtonBackgroud(2, android.R.drawable.ic_menu_camera);
    setFooterButtonBackgroud(3, android.R.drawable.ic_menu_compass);

    //		chatView = new LinearLayout(this);
    //		chatView.setLayoutParams(new RelativeLayout.LayoutParams(
    //				LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    //		chatView.setBackgroundColor(Color.WHITE);
    //		TextView textView = new TextView(this);
    //		textView.setText("xixixixixi");
    //		textView.setTextSize(20);
    //		chatView.addView(textView);

    chatView = (LinearLayout) LinearLayout.inflate(this, R.layout.layout_weixin, null);
    setContent(chatView);

    //		contactView = new RelativeLayout(this);
    //		contactView.setLayoutParams(new RelativeLayout.LayoutParams(
    //				LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    //		contactView.setBackgroundColor(Color.WHITE);
    //		ListView listView = new ListView(this);
    //		listView.setAdapter(new ArrayAdapter<String>(this,
    //				android.R.layout.simple_list_item_1, new String[] { "1", "2",
    //						"3", "4", "5", "6", "7", "8", "9", "10"}));
    //		contactView.addView(listView);
    contactView = (LinearLayout) LinearLayout.inflate(this, R.layout.layout_contact, null);

    //		findView = new RelativeLayout(this);
    //		findView.setLayoutParams(new RelativeLayout.LayoutParams(
    //				LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    //		findView.setBackgroundColor(Color.WHITE);
    //		TextView textView2 = new TextView(this);
    //		textView2.setText("Yeah!");
    //		textView2.setTextSize(25);
    //		findView.addView(textView2);
    findView = (LinearLayout) LinearLayout.inflate(this, R.layout.layout_find, null);

    //		meView = new RelativeLayout(this);
    //		meView.setLayoutParams(new RelativeLayout.LayoutParams(
    //				LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    //		meView.setBackgroundColor(Color.WHITE);
    //		TextView textView3 = new TextView(this);
    //		textView3.setText("Settings");
    //		textView3.setTextSize(25);
    //		meView.addView(textView3);
    meView = (LinearLayout) LinearLayout.inflate(this, R.layout.layout_me, null);
  }
コード例 #13
0
ファイル: MainActivity.java プロジェクト: mjcarsjens/getpekt
  // Draws the Events
  private void drawEvents() {

    int counter = 0;
    layout.removeAllViews();
    for (JSONObject j : events) {
      try {
        final String eid = j.getString("eid");
        final String name = j.getString("name");
        final int icon = j.getInt("icon");
        final int creator = j.getInt("creator");
        String update = j.getString("updated");
        final String temp = j.getString("datetime");
        String month = temp.substring(5, 7);
        String day = temp.substring(8, 10);
        String date = day + '-' + month;

        RelativeLayout.LayoutParams lp_icon = new RelativeLayout.LayoutParams(height, height);
        RelativeLayout.LayoutParams lp_button = new RelativeLayout.LayoutParams(width, height);
        RelativeLayout.LayoutParams lp_date = new RelativeLayout.LayoutParams(dateWidth, height);
        RelativeLayout.LayoutParams lp_div = new RelativeLayout.LayoutParams(width, divHeight);

        /**
         * Adds the icon: to limit the use of data we store the images in a local database, and in
         * an online database. Whenever someone uploads a new icon a new random icon_ID gets
         * generated when the icon_ID in your local DB doesn't equal the one in the online database,
         * the one in the online DB gets downloaded and the offline DB gets updated with this EID
         * and image.
         */
        lp_icon.setMargins(0, (height + divHeight) * counter, 0, 0);
        final ImageButton img = new ImageButton(this);
        if (icon == 0) {
          img.setImageResource(R.drawable.group);
          img.setPadding(12, 12, 12, 12);
          user_db.deleteBlob(eid);
        } else {
          if (icon == user_db.getVersion(eid)) {
            byte[] image = user_db.getBlob(eid);
            img.setImageBitmap(BitmapFactory.decodeByteArray(image, 0, image.length));
            img.setPadding(7, 7, 7, 7);
          } else {
            String tag_icon = "req_icon";
            StringRequest stringRequest =
                new StringRequest(
                    Request.Method.POST,
                    URL_ICON,
                    new Response.Listener<String>() {

                      @Override
                      public void onResponse(String response) {
                        try {
                          JSONObject jObj = new JSONObject(response);
                          boolean error = jObj.getBoolean("error");

                          if (!error) {
                            byte[] blob = Base64.decode(jObj.getString("blob"), Base64.DEFAULT);
                            if (user_db.getVersion(eid) == 0) {
                              user_db.addBLOB(eid, icon, blob);
                            } else {
                              user_db.updateBlob(eid, icon, blob);
                            }
                            img.setImageBitmap(BitmapFactory.decodeByteArray(blob, 0, blob.length));
                            img.setPadding(7, 7, 7, 7);
                          }
                        } catch (JSONException e) {
                          e.printStackTrace();
                        }
                      }
                    },
                    new Response.ErrorListener() {

                      @Override
                      public void onErrorResponse(VolleyError error) {}
                    }) {

                  @Override
                  protected Map<String, String> getParams() {
                    Map<String, String> params = new HashMap<String, String>();
                    params.put("tag", "get");
                    params.put("eid", eid);
                    return params;
                  }
                };
            AppController.getInstance().addToRequestQueue(stringRequest, tag_icon);
          }
        }
        img.setLayoutParams(lp_icon);
        img.setBackground(null);
        img.setScaleType(ImageView.ScaleType.FIT_CENTER);
        layout.addView(img);

        // Add the button
        lp_button.setMargins(height, (height + divHeight) * counter, height, 0);
        TextView button = new TextView(this);
        button.setText(name);
        button.setTypeface(express);
        button.setTextSize(getResources().getDimension(R.dimen.button_text));
        button.setTextColor(getResources().getColor(R.color.black));
        button.setGravity(Gravity.CENTER_VERTICAL);
        button.setLayoutParams(lp_button);
        layout.addView(button);
        button.setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this, EventActivity.class);
                Bundle b = new Bundle();
                b.putString("eid", eid);
                b.putString("name", name);
                b.putInt("icon", icon);
                b.putInt("creator", creator);
                b.putString("date", temp);
                intent.putExtras(b);
                startActivity(intent);
              }
            });

        // Add the Date
        if (!month.equals("00") && !day.equals("00")) {
          lp_date.setMargins(0, (height + divHeight) * counter, 0, 0);
          lp_date.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE);
          TextView datetime = new TextView(this);
          datetime.setText(date);
          datetime.setGravity(Gravity.CENTER);
          datetime.setLayoutParams(lp_date);
          layout.addView(datetime);
        }

        // Add the Divider
        lp_div.setMargins(height, (height + divHeight) * counter + height, 20, 0);
        ImageView div = new ImageView(this);
        div.setImageResource(R.drawable.divider);
        div.setLayoutParams(lp_div);
        layout.addView(div);

        counter++;
      } catch (JSONException ex) {

      }
    }
  }