@Override
  public void onWindowFocusChanged(boolean b) {

    RelativeLayout relativeLayout = (RelativeLayout) findViewById(R.id.RelativeContainer);

    int height = relativeLayout.getHeight();
    int width = relativeLayout.getWidth();

    Log.i("Width is:", Integer.toString(width));
    Log.i("Height is:", Integer.toString(height));

    if (width < height) {
      Log.i("WIDTH <    ", "    HEIGHT");

      LinearLayout.LayoutParams layout_description = new LinearLayout.LayoutParams(width, width);
      relativeLayout.setLayoutParams(layout_description);
    } else {
      Log.i("HEIGHT <    ", "    WIDTH");

      LinearLayout.LayoutParams layout_description = new LinearLayout.LayoutParams(height, height);
      relativeLayout.setGravity(Gravity.CENTER);
      relativeLayout.setLayoutParams(layout_description);
    }

    height = relativeLayout.getLayoutParams().height;
    width = relativeLayout.getLayoutParams().width;
  }
  private void createView() {
    // Linear Layout
    LinearLayout linearLayout = new LinearLayout(this);
    linearLayout.setId(1);
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    linearLayout.setGravity(Gravity.CENTER);
    linearLayout.setBackgroundColor(Color.BLACK);
    this.setContentView(linearLayout);

    // Relative Layout
    RelativeLayout relativeLayout = new RelativeLayout(this);
    relativeLayout.setId(2);
    relativeLayout.setGravity(Gravity.CENTER);
    relativeLayout.setBackgroundColor(Color.BLACK);
    RelativeLayout.LayoutParams relativeLayoutParams =
        new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT);
    relativeLayout.setLayoutParams(relativeLayoutParams);
    linearLayout.addView(relativeLayout);

    // Video View
    videoView = new VideoView(this);
    videoView.setId(3);
    RelativeLayout.LayoutParams videoViewParams =
        new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    videoViewParams.addRule(RelativeLayout.CENTER_IN_PARENT);
    videoView.setLayoutParams(videoViewParams);
    relativeLayout.addView(videoView);
  }
 private void layoutSearchView(TiViewProxy searchView) {
   TiUIView search = searchView.getOrCreateView();
   RelativeLayout layout = new RelativeLayout(proxy.getActivity());
   layout.setGravity(Gravity.NO_GRAVITY);
   layout.setPadding(0, 0, 0, 0);
   addSearchLayout(layout, searchView, search);
   setNativeView(layout);
 }
  /**
   * get a view that displays the data at the specified position in the data set. This function is
   * called for each rows a bubble contains information loaded thanks to the controller
   *
   * @param position the position of the item in the listview
   * @param convertView the old view to rescue
   * @param parent the parent that this view will eventually be attached to (conversationActivity)
   * @return the view of a bubble. Created view by us
   */
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder holder;
    View bubbleViewRow = convertView;

    if (convertView == null) {
      // create a new object with the same properties that the buuble_item
      bubbleViewRow = this.mLayoutInflater.inflate(R.layout.bubble_item, null);

      holder = new ViewHolder();
      holder.messageBody = (TextView) bubbleViewRow.findViewById(R.id.b_contenu);
      holder.photo = (ImageView) bubbleViewRow.findViewById(R.id.imageViewPhotoContact);

      bubbleViewRow.setTag(holder);
    } else {
      holder = (ViewHolder) bubbleViewRow.getTag();
    }

    Message item = mBubbles.get(position);

    /**
     * if it's an instance of Message, we create an item with a messageBody, imageBubble etc...
     * Else, We write the date.
     */
    if (item instanceof Message) {
      Message message = (Message) item;
      holder.messageBody.setText(message.getContent());

      RelativeLayout layout = (RelativeLayout) bubbleViewRow.findViewById(R.id.layoutBubble);
      if (message.isSendByMe()) {
        holder.messageBody.setBackgroundResource(R.drawable.bulle_me);
        layout.setGravity(Gravity.RIGHT);
      } else {
        holder.photo.setImageBitmap(message.getContact().getPhoto(contentResolver));
        holder.messageBody.setBackgroundResource(R.drawable.bulle_not_me);
        layout.setGravity(Gravity.LEFT);
      }
      holder.messageBody.setPadding(50, 50, 50, 50);
    } else {
      holder.messageBody.setTextSize(13);
      holder.messageBody.setText(item.getManagedDate());
    }

    return bubbleViewRow;
  }
  /** Create the view in which the video will be rendered. */
  private void setupView() {
    LinearLayout lLinLayout = new LinearLayout(this);
    lLinLayout.setId(1);
    lLinLayout.setOrientation(LinearLayout.VERTICAL);
    lLinLayout.setGravity(Gravity.CENTER);
    lLinLayout.setBackgroundColor(Color.BLACK);

    LayoutParams lLinLayoutParms =
        new LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT);
    lLinLayout.setLayoutParams(lLinLayoutParms);

    this.setContentView(lLinLayout);

    RelativeLayout lRelLayout = new RelativeLayout(this);
    lRelLayout.setId(2);
    lRelLayout.setGravity(Gravity.CENTER);
    lRelLayout.setBackgroundColor(Color.BLACK);
    android.widget.RelativeLayout.LayoutParams lRelLayoutParms =
        new android.widget.RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT);
    lRelLayout.setLayoutParams(lRelLayoutParms);
    lLinLayout.addView(lRelLayout);

    mVideoView = new VideoView(this);
    mVideoView.setId(3);
    android.widget.RelativeLayout.LayoutParams lVidViewLayoutParams =
        new android.widget.RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    lVidViewLayoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
    mVideoView.setLayoutParams(lVidViewLayoutParams);
    lRelLayout.addView(mVideoView);

    mProgressBar = new ProgressBar(this);
    mProgressBar.setIndeterminate(true);
    mProgressBar.setVisibility(View.VISIBLE);
    mProgressBar.setEnabled(true);
    mProgressBar.setId(4);
    android.widget.RelativeLayout.LayoutParams lProgressBarLayoutParms =
        new android.widget.RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    lProgressBarLayoutParms.addRule(RelativeLayout.CENTER_IN_PARENT);
    mProgressBar.setLayoutParams(lProgressBarLayoutParms);
    lRelLayout.addView(mProgressBar);

    mProgressMessage = new TextView(this);
    mProgressMessage.setId(5);
    android.widget.RelativeLayout.LayoutParams lProgressMsgLayoutParms =
        new android.widget.RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    lProgressMsgLayoutParms.addRule(RelativeLayout.CENTER_HORIZONTAL);
    lProgressMsgLayoutParms.addRule(RelativeLayout.BELOW, 4);
    mProgressMessage.setLayoutParams(lProgressMsgLayoutParms);
    mProgressMessage.setTextColor(Color.LTGRAY);
    mProgressMessage.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12);
    mProgressMessage.setText("...");
    lRelLayout.addView(mProgressMessage);
  }
  @Override
  public void processProperties(KrollDict d) {
    tableView = new TiTableView(proxy.getTiContext(), (TableViewProxy) proxy);
    tableView.setOnItemClickListener(this);

    if (d.containsKey(TiC.PROPERTY_SEARCH)) {
      RelativeLayout layout = new RelativeLayout(proxy.getTiContext().getActivity());
      layout.setGravity(Gravity.NO_GRAVITY);
      layout.setPadding(0, 0, 0, 0);

      TiViewProxy searchView = (TiViewProxy) d.get(TiC.PROPERTY_SEARCH);
      TiUISearchBar searchBar =
          (TiUISearchBar) searchView.getView(proxy.getTiContext().getActivity());
      searchBar.setOnSearchChangeListener(tableView);
      searchBar.getNativeView().setId(102);

      RelativeLayout.LayoutParams p =
          new RelativeLayout.LayoutParams(
              RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT);
      p.addRule(RelativeLayout.ALIGN_PARENT_TOP);
      p.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
      p.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
      p.height = 52;

      layout.addView(searchBar.getNativeView(), p);

      p =
          new RelativeLayout.LayoutParams(
              RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT);
      p.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
      p.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
      p.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
      p.addRule(RelativeLayout.BELOW, 102);
      layout.addView(tableView, p);
      setNativeView(layout);
    } else {
      setNativeView(tableView);
    }

    if (d.containsKey(TiC.PROPERTY_FILTER_ATTRIBUTE)) {
      tableView.setFilterAttribute(TiConvert.toString(d, TiC.PROPERTY_FILTER_ATTRIBUTE));
    } else {
      // Default to title to match iPhone default.
      proxy.setProperty(TiC.PROPERTY_FILTER_ATTRIBUTE, TiC.PROPERTY_TITLE, false);
      tableView.setFilterAttribute(TiC.PROPERTY_TITLE);
    }

    boolean filterCaseInsensitive = true;
    if (d.containsKey(TiC.PROPERTY_FILTER_CASE_INSENSITIVE)) {
      filterCaseInsensitive = TiConvert.toBoolean(d, TiC.PROPERTY_FILTER_CASE_INSENSITIVE);
    }
    tableView.setFilterCaseInsensitive(filterCaseInsensitive);
    super.processProperties(d);
  }
  /** Smart item expansion. */
  private void expandItem(int position) {
    final int first = getFirstVisiblePosition();
    RelativeLayout v = (RelativeLayout) getChildAt(position - first);
    if (v != null && mFloatView != null) {
      // Log.d("mobeta", "  expanding item "+position);
      ViewGroup.LayoutParams lp = v.getLayoutParams();

      int oldHeight = lp.height;
      if (lp.height == mItemHeightCollapsed && position == mSrcDragPos) {
        // expanding collapsed src item
        lp.height = ViewGroup.LayoutParams.WRAP_CONTENT;
      } else if (lp.height == ViewGroup.LayoutParams.WRAP_CONTENT && position != mExpDragPos) {
        // expanding normal item
        lp.height = v.getHeight() + mFloatViewHeight;

        // must set gravity in this case
        if (position > mSrcDragPos) {
          v.setGravity(Gravity.TOP);
        } else {
          v.setGravity(Gravity.BOTTOM);
        }

        // what if expanding first position?
        // if (position == first && mDragState == SRC_ABOVE) {
        // setSelectionFromTop(first, getChildAt(0).getTop() -
        // mFloatViewHeight + getPaddingTop());
        // }

      } else {
        Log.d("mobeta", "expand item skipped");
      }

      if (lp.height != oldHeight) {
        v.requestLayout();
      }
    }
  }
  public final void setupLayout(Camera camera) {
    // removeAllViews();

    mPreview = new CameraView(getContext(), camera, this);
    if (cameraLayout == null) {
      removeView(cameraLayout);
    }

    cameraLayout = new RelativeLayout(getContext());
    cameraLayout.setGravity(Gravity.CENTER);
    cameraLayout.setBackgroundColor(Color.BLACK);
    cameraLayout.addView(mPreview);
    addView(cameraLayout);
    moveToBack(cameraLayout);
  }
Esempio n. 9
0
  private void init(Context context, AttributeSet attrs) {
    mListView = new InternalListView(getContext(), attrs);
    LayoutParams listParams =
        new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    listParams.addRule(ALIGN_PARENT_TOP);
    mListView.setLayoutParams(listParams);
    mListView.setOnScrollListener(new HeaderListViewOnScrollListener());
    mListView.setVerticalScrollBarEnabled(false);
    mListView.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (mAdapter != null) {
              mAdapter.onItemClick(parent, view, position, id);
            }
          }
        });
    addView(mListView);

    mHeader = new RelativeLayout(getContext());
    LayoutParams headerParams =
        new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    headerParams.addRule(ALIGN_PARENT_TOP);
    mHeader.setLayoutParams(headerParams);
    mHeader.setGravity(Gravity.BOTTOM);
    addView(mHeader);

    // The list view's scroll bar can be hidden by the header, so we display our own scroll bar
    // instead
    Drawable scrollBarDrawable =
        getResources().getDrawable(R.drawable.scrollbar_handle_holo_light, null);
    mScrollView = new FrameLayout(getContext());
    LayoutParams scrollParams =
        new LayoutParams(scrollBarDrawable.getIntrinsicWidth(), LayoutParams.MATCH_PARENT);
    scrollParams.addRule(ALIGN_PARENT_RIGHT);
    scrollParams.rightMargin = (int) dpToPx(2);
    mScrollView.setLayoutParams(scrollParams);

    ImageView scrollIndicator = new ImageView(context);
    scrollIndicator.setLayoutParams(
        new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    scrollIndicator.setImageDrawable(scrollBarDrawable);
    scrollIndicator.setScaleType(ScaleType.FIT_XY);
    mScrollView.addView(scrollIndicator);
    mScrollView.setVisibility(INVISIBLE);

    addView(mScrollView);
  }
Esempio n. 10
0
 // METHOD - shows progress bar
 public void showProgress(Context context) {
   if (layoutProgress == null) {
     layoutProgress = new RelativeLayout(context);
     progressBar = new ProgressBar(context);
     progressBar.setIndeterminate(true);
     RelativeLayout.LayoutParams rlp =
         new RelativeLayout.LayoutParams(
             RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
     layoutProgress.setLayoutParams(rlp);
     layoutProgress.addView(progressBar);
     rootView.addView(layoutProgress);
     layoutProgress.bringToFront();
     layoutProgress.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL);
   }
   layoutProgress.setVisibility(View.VISIBLE);
 }
Esempio n. 11
0
  private ImageView createCompanionAdImageView(final Context context) {
    RelativeLayout relativeLayout = new RelativeLayout(context);
    relativeLayout.setGravity(Gravity.CENTER);
    RelativeLayout.LayoutParams layoutParams =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
    layoutParams.addRule(RelativeLayout.BELOW, mVastVideoToolbar.getId());
    getLayout().addView(relativeLayout, layoutParams);

    ImageView imageView = new ImageView(context);
    // Set to invisible to have it be drawn to calculate size
    imageView.setVisibility(View.INVISIBLE);

    final RelativeLayout.LayoutParams companionAdLayout =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);

    relativeLayout.addView(imageView, companionAdLayout);
    return imageView;
  }
        @SuppressLint("RtlHardcoded")
        @Override
        public View instantiateItem(ViewGroup container, final int position) {
          RelativeLayout rl = new RelativeLayout(container.getContext());
          rl.setGravity(Gravity.CENTER);
          TouchImageView img = new TouchImageView(container.getContext());
          img.setImageBitmap(browserDefaultBitmap);
          loadBrowserImageAsync(
              img,
              imageDetails[position].getPath(),
              displayMetrics.widthPixels,
              displayMetrics.heightPixels,
              imageDetails[position].getOrientation());

          rl.addView(
              img, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);

          final CheckBox cb = new CheckBox(rl.getContext());
          cb.setChecked(imageDetails[position].isSelected());
          cb.setGravity(Gravity.TOP | Gravity.RIGHT);
          cb.setOnClickListener(
              new android.view.View.OnClickListener() {
                public void onClick(View v) {
                  browserCheckboxChecked(position, cb);
                }
              });
          img.setOnClickListener(
              new android.view.View.OnClickListener() {
                public void onClick(View v) {
                  browserCheckboxChecked(position, cb);
                }
              });

          rl.addView(
              cb, LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);

          container.addView(
              rl, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);

          return rl;
        }
Esempio n. 13
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_video);

    init();

    event_id = this.getIntent().getIntExtra("event_id", -1);

    if (event_id == -1) {
      Toast.makeText(getApplicationContext(), "连接失败,请检查网络是否连接并重试", Toast.LENGTH_LONG).show();
    } else {
      String event_id_string = String.valueOf(event_id);

      //            final String url_mp4 = "http://120.24.208.130:1501/video/201.mp4";

      final String url_mp4 = url_part + "/video/" + event_id_string + ".mp4";

      boolean mp4 = RequestHandler.TestGetURL(url_mp4);

      if (!mp4) {
        Toast.makeText(getApplicationContext(), "没有相应的视频", Toast.LENGTH_SHORT).show();
      } else {
        RelativeLayout RL = (RelativeLayout) findViewById(R.id.video_layout);
        RL.setGravity(Gravity.CENTER);
        VideoView vv = new VideoView(VideoActivity.this);
        vv.setId(R.id.id_video);
        RL.addView(vv);

        video_view = (VideoView) findViewById(R.id.id_video);

        Uri uri = Uri.parse(url_mp4);
        video_view.setMediaController(new MediaController(VideoActivity.this));
        video_view.setVideoURI(uri);
        video_view.start();
        video_view.requestFocus();
      }
    }
  }
  @Inject
  public ProgressBarHandler(Context context) {
    mContext = context;

    ViewGroup layout =
        (ViewGroup) ((RoboActivity) context).findViewById(android.R.id.content).getRootView();

    mProgressBar = new ProgressBar(context, null, android.R.attr.progressBarStyleLarge);
    mProgressBar.setIndeterminate(true);

    RelativeLayout.LayoutParams params =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);

    RelativeLayout rl = new RelativeLayout(context);

    rl.setGravity(Gravity.CENTER);
    rl.addView(mProgressBar);

    layout.addView(rl, params);

    hide();
  }
Esempio n. 15
0
  /** 填充日历(包含日期、标记、背景等) */
  protected void setCalendarDate() {
    // 根据日历的日子获取这一天是星期几
    int weekday = calendarday.getDay();
    // 每个月第一天
    int firstDay = 1;
    // 每个月中间号,根据循环会自动++
    int day = firstDay;
    // 每个月的最后一天
    int lastDay = getDateNum(calendarday.getYear(), calendarday.getMonth());
    // 下个月第一天
    int nextMonthDay = 1;
    int lastMonthDay = 1;
    // 填充每一个空格
    for (int i = 0; i < ROWS_TOTAL; i++) {
      for (int j = 0; j < COLS_TOTAL; j++) {
        // 这个月第一天不是礼拜天,则需要绘制上个月的剩余几天
        if (i == 0 && j == 0 && weekday != 0) {
          int year = 0;
          int month = 0;
          int lastMonthDays = 0;
          // 如果这个月是1月,上一个月就是去年的12月
          if (calendarday.getMonth() == 0) {
            year = calendarday.getYear() - 1;
            month = Calendar.DECEMBER;
          } else {
            year = calendarday.getYear();
            month = calendarday.getMonth() - 1;
          }
          // 上个月的最后一天是几号
          lastMonthDays = getDateNum(year, month);
          // 第一个格子展示的是几号
          int firstShowDay = lastMonthDays - weekday + 1;
          // 上月
          for (int k = 0; k < weekday; k++) {
            lastMonthDay = firstShowDay + k;
            RelativeLayout group = getDateView(0, k);
            group.setGravity(Gravity.CENTER);
            TextView view = null;
            if (group.getChildCount() > 0) {
              view = (TextView) group.getChildAt(0);
            } else {
              LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(-1, -1);
              view = new TextView(getContext());
              view.setLayoutParams(params);
              view.setGravity(Gravity.CENTER);
              group.addView(view);
            }
            view.setText(Integer.toString(lastMonthDay));
            view.setTextColor(COLOR_TX_OTHER_MONTH_DAY);
            dates[0][k] = format(new Date(year, month, lastMonthDay));

            // 设置日期背景色
            if (dayBgColorMap.get(dates[0][k]) != null) {
              view.setBackgroundColor(dayBgColorMap.get(dates[0][k]));
            } else {
              view.setBackgroundColor(Color.TRANSPARENT);
            }
            // 设置标记
            if (selectRow == 0 && selectCol == k) {
              view.setBackgroundColor(COLOR_BG_SELECT_DAY);
            }

            setMarker(group, 0, k);
          }
          j = weekday - 1;
          // 这个月第一天是礼拜天,不用绘制上个月的日期,直接绘制这个月的日期
        } else {
          RelativeLayout group = getDateView(i, j);
          group.setGravity(Gravity.CENTER);
          TextView view = null;
          if (group.getChildCount() > 0) {
            view = (TextView) group.getChildAt(0);
          } else {
            LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(-1, -1);
            view = new TextView(getContext());
            view.setLayoutParams(params);
            view.setGravity(Gravity.CENTER);
            group.addView(view);
          }
          // 本月
          if (day <= lastDay) {
            dates[i][j] = format(new Date(calendarday.getYear(), calendarday.getMonth(), day));
            view.setText(Integer.toString(day));

            // 当天
            if (thisday.getDate() == day
                && thisday.getMonth() == calendarday.getMonth()
                && thisday.getYear() == calendarday.getYear()) {
              view.setTextColor(COLOR_TX_THIS_DAY);
              view.setBackgroundColor(COLOR_BG_THIS_DAY);
            } else {
              view.setTextColor(COLOR_TX_THIS_MONTH_DAY);
              view.setBackgroundColor(Color.TRANSPARENT);
            }

            if (selectRow == i && selectCol == j) {
              view.setBackgroundColor(COLOR_BG_SELECT_DAY);
            }
            // 上面首先设置了一下默认的"当天"背景色,当有特殊需求时,才给当日填充背景色
            // 设置日期背景色
            if (dayBgColorMap.get(dates[i][j]) != null) {
              view.setBackgroundColor(dayBgColorMap.get(dates[i][j]));
            }
            // 设置标记
            setMarker(group, i, j);

            day++;
            // 下个月
          } else {
            if (calendarday.getMonth() == Calendar.DECEMBER) {
              dates[i][j] =
                  format(new Date(calendarday.getYear() + 1, Calendar.JANUARY, nextMonthDay));
            } else {
              dates[i][j] =
                  format(new Date(calendarday.getYear(), calendarday.getMonth() + 1, nextMonthDay));
            }
            view.setText(Integer.toString(nextMonthDay));
            view.setTextColor(COLOR_TX_OTHER_MONTH_DAY);
            // 设置日期背景色
            if (dayBgColorMap.get(dates[i][j]) != null) {
              view.setBackgroundColor(dayBgColorMap.get(dates[i][j]));
            } else {
              view.setBackgroundColor(Color.TRANSPARENT);
            }
            if (selectRow == i && selectCol == j) {
              view.setBackgroundColor(COLOR_BG_SELECT_DAY);
            }

            // 设置标记
            setMarker(group, i, j);
            nextMonthDay++;
          }
        }
      }
    }
  }
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

      RelativeLayout v;
      View child;

      // Log.d("mobeta",
      // "getView: position="+position+" convertView="+convertView);
      if (convertView != null) {

        v = (RelativeLayout) convertView;
        View oldChild = v.getChildAt(0);

        // child = super.getView(position, oldChild, v);
        child = mAdapter.getView(position, oldChild, v);
        if (child != oldChild) {
          // shouldn't get here if user is reusing convertViews
          // properly
          v.removeViewAt(0);
          v.addView(child);
          // check that tags are equal too?
          v.setTag(child.findViewById(R.id.drag));
        }

      } else {
        AbsListView.LayoutParams params =
            new AbsListView.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        v = new RelativeLayout(getContext());
        v.setLayoutParams(params);
        child = mAdapter.getView(position, null, v);
        v.addView(child);

        v.setTag(child.findViewById(R.id.drag));
      }

      ViewGroup.LayoutParams lp = v.getLayoutParams();
      final int numHeaders = getHeaderViewsCount();

      final int srcAdapter = mSrcDragPos - numHeaders;
      final int expAdapter = mExpDragPos - numHeaders;

      boolean itemIsNormal = position != srcAdapter && position != expAdapter;
      boolean listHasExpPos = mDragState == SRC_ABOVE || mDragState == SRC_BELOW;
      boolean itemNeedsWC = itemIsNormal || !listHasExpPos;

      int oldHeight = lp.height;
      if (itemNeedsWC && lp.height != ViewGroup.LayoutParams.WRAP_CONTENT) {
        // items that have a user-provided height
        lp.height = ViewGroup.LayoutParams.WRAP_CONTENT;
      } else if (listHasExpPos) {
        if (position == srcAdapter && lp.height != mItemHeightCollapsed) {
          // collapsed items
          lp.height = mItemHeightCollapsed;
        } else if (position == expAdapter) {
          // what if a previously-expanded wrapper view is used
          // as a convertView for a different expanded item?
          // Always measure child
          int spec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
          child.measure(spec, spec);

          mExpandedChildHeight = child.getMeasuredHeight();
          // Log.d("mobeta",
          // "childh="+mExpandedChildHeight+" pos="+position);
          int height = mExpandedChildHeight + mFloatViewHeight;
          if (lp.height != height) {
            lp.height = height;
          }

          // set gravity
          if (mDragState == SRC_ABOVE) {
            v.setGravity(Gravity.TOP);
          } else {
            v.setGravity(Gravity.BOTTOM);
          }
        }
      }

      if (lp.height != oldHeight) {
        v.setLayoutParams(lp);
      }

      int oldVis = v.getVisibility();
      int vis = oldVis;

      if (position == srcAdapter && mDragState != NO_DRAG) {
        if (vis == View.VISIBLE) {
          vis = View.INVISIBLE;
        }
      } else if (vis == View.INVISIBLE) {
        vis = View.VISIBLE;
      }

      if (vis != oldVis) {
        v.setVisibility(vis);
      }

      return v;
    }
Esempio n. 17
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_map);

    com.google.android.gms.ads.AdView adView =
        new com.google.android.gms.ads.AdView(MapActivity.this);
    adView.setAdUnitId("ca-app-pub-1878227272753934/2393548800");
    adView.setAdSize(AdSize.BANNER);
    RelativeLayout layout = (RelativeLayout) findViewById(R.id.addshows);
    layout.addView(adView);
    layout.setGravity(Gravity.CENTER);
    com.google.android.gms.ads.AdRequest request =
        new com.google.android.gms.ads.AdRequest.Builder().build();
    adView.loadAd(request);

    Bundle extras = getIntent().getExtras();
    if (extras != null) {
      lat = extras.getDouble("latitude");
      lon = extras.getDouble("longitude");
    }

    btn_search = (Button) findViewById(R.id.button_search);
    btn_search.setOnClickListener(this);

    spinner_items = (Spinner) findViewById(R.id.spinner_items);

    mPlaceType = getResources().getStringArray(R.array.place_type);
    mPlaceTypeName = getResources().getStringArray(R.array.place_type_name);

    ArrayAdapter<String> adapter =
        new ArrayAdapter<String>(
            this, android.R.layout.simple_spinner_dropdown_item, mPlaceTypeName);
    spinner_items.setAdapter(adapter);

    try {
      // Loading map
      initilizeMap();

      // Changing map type
      googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
      // googleMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);
      // googleMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
      // googleMap.setMapType(GoogleMap.MAP_TYPE_TERRAIN);
      // googleMap.setMapType(GoogleMap.MAP_TYPE_NONE);

      // Showing / hiding your current location
      googleMap.setMyLocationEnabled(true);

      // Enable / Disable zooming controls
      googleMap.getUiSettings().setZoomControlsEnabled(false);

      // Enable / Disable my location button
      googleMap.getUiSettings().setMyLocationButtonEnabled(true);

      // Enable / Disable Compass icon
      googleMap.getUiSettings().setCompassEnabled(true);

      // Enable / Disable Rotate gesture
      googleMap.getUiSettings().setRotateGesturesEnabled(true);

      // Enable / Disable zooming functionality
      googleMap.getUiSettings().setZoomGesturesEnabled(true);

      double[] randomLocation = createRandLocation(lat, lon);

      CameraPosition cameraPosition =
          new CameraPosition.Builder().target(new LatLng(lat, lon)).zoom(15).build();

      googleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));

    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  @Override
  public void createControl(TitaniumModuleManager tmm) {
    tv = new EditText(tmm.getAppContext());
    tv.isFocusable();
    tv.setId(100);

    tv.addTextChangedListener(this);
    tv.setOnEditorActionListener(this);
    tv.setText(value);
    tv.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
    tv.setPadding(4, 2, 4, 2);
    tv.setSingleLine();
    TitaniumUIHelper.styleText(tv, fontSize, fontWeight);

    if (color != null) {
      tv.setTextColor(TitaniumColorHelper.parseColor(color));
    }
    if (backgroundColor != null) {
      tv.setBackgroundColor(TitaniumColorHelper.parseColor(backgroundColor));
    }

    cancelBtn = new ImageButton(tmm.getAppContext());
    cancelBtn.isFocusable();
    cancelBtn.setId(101);
    cancelBtn.setPadding(0, 0, 0, 0);
    Drawable d = new BitmapDrawable(this.getClass().getResourceAsStream("cancel.png"));
    cancelBtn.setImageDrawable(d);
    cancelBtn.setMinimumWidth(48);

    cancelBtn.setVisibility(showCancel ? View.VISIBLE : View.GONE);
    cancelBtn.setOnClickListener(
        new OnClickListener() {

          public void onClick(View view) {
            handler.sendEmptyMessage(MSG_CANCEL);
          }
        });

    RelativeLayout layout = new RelativeLayout(tmm.getAppContext());
    control = layout;

    layout.setGravity(Gravity.NO_GRAVITY);
    layout.setPadding(0, 0, 0, 0);
    if (barColor != null) {
      layout.setBackgroundColor(TitaniumColorHelper.parseColor(barColor));
    }

    RelativeLayout.LayoutParams params =
        new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
    params.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
    params.addRule(RelativeLayout.CENTER_VERTICAL);
    params.addRule(RelativeLayout.LEFT_OF, 101);
    params.setMargins(4, 4, 0, 4);
    layout.addView(tv, params);

    params = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    params.addRule(RelativeLayout.CENTER_VERTICAL);
    params.setMargins(0, 4, 4, 4);
    layout.addView(cancelBtn, params);
  }
  @Override
  public View getView(final int position, View convertView, ViewGroup parent) {

    RelativeLayout relative = new RelativeLayout(context);
    relative.setLayoutParams(
        new GridView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    relative.setGravity(Gravity.CENTER);
    relative.setBackgroundColor(Color.WHITE);

    ProgressBar progressBar = new ProgressBar(context);
    progressBar.setLayoutParams(new RelativeLayout.LayoutParams(40, 40));

    /*
     * BuiltImageView class takes built file as parameter and set image in it.
     *
     * Dynamically declaration of BuiltImageView.
     * and adding properties to it.
     */
    final BuiltImageView imageView = new BuiltImageView(context);
    imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
    imageView.setAdjustViewBounds(true);
    imageView.setLayoutParams(new GridView.LayoutParams(width, 325));

    /*
     * Setting target width for heavy image.
     */
    imageView.setTargetedWidth(300);

    /*
     * Setting progress bar object to show before download.
     */
    imageView.showProgressOnLoading(progressBar);

    /*
     * Setting image inside BuiltImageView using BuiltFile object.
     */
    imageView.setBuiltUpload(
        context,
        builtFileList.get(position),
        new BuiltImageDownloadCallback() {

          @Override
          public void onCompletion(
              BuiltConstant.ResponseType responseType, Bitmap bitmap, BuiltError builtError) {

            if (builtError == null) {
              Log.i(context.getClass().getSimpleName(), bitmap.toString());
            } else {
              Toast.makeText(context, "Error :" + builtError.getErrorMessage(), Toast.LENGTH_SHORT)
                  .show();
            }
          }
        });
    relative.addView(progressBar);
    relative.addView(imageView);

    imageView.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {

            Dialog dialog = new Dialog(context, android.R.style.Theme_Black_NoTitleBar);
            dialog.setContentView(R.layout.preview_image);
            dialog.setTitle("Preview Image");

            /*
             * layout declaration of BuiltImageView
             */
            BuiltImageView image = (BuiltImageView) dialog.findViewById(R.id.previewImage);
            image.setTargetedWidth(300);
            /*
             * Setting download image from the cache.
             */
            image.setImageBitmap(imageView.getCachedImage());

            dialog.show();
          }
        });

    return relative;
  }