@Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    String response = getIntent().getStringExtra("response");
    boolean success = getIntent().getBooleanExtra("success", false);

    LinearLayout l = new LinearLayout(this);
    l.setOrientation(LinearLayout.VERTICAL);
    l.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    l.setPadding(10, 10, 10, 10);

    TextView t = new TextView(this);
    t.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    t.setGravity(Gravity.CENTER);
    if (success) {
      t.setText(R.string.sync_ok);
    } else {
      t.setText(R.string.sync_failed);
    }
    t.setTextSize(22);
    l.addView(t);
    t = new TextView(this);
    t.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    t.setText(response);
    l.addView(t);
    setContentView(l);
  }
예제 #2
0
  // if platform selected form platform gridview is SinaWeibo,
  // TencentWeibo, Facebook, or Twitter, there will be a button
  // in the left-bottom of the page, which provides At-friends function
  private LinearLayout getAtLine(String platform) {
    if (!isShowAtUserLayout(platform)) {
      return null;
    }
    LinearLayout llAt = new LinearLayout(getContext());
    LayoutParams lpAt = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    lpAt.rightMargin = dipToPx(getContext(), 4);
    lpAt.gravity = Gravity.LEFT | Gravity.BOTTOM;
    lpAt.weight = 1;
    llAt.setLayoutParams(lpAt);
    llAt.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            if (platforms != null && platforms.size() > 0) {
              FollowListPage subPage = new FollowListPage();
              subPage.setPlatform(platforms.get(0));
              subPage.showForResult(activity, null, EditPage.this);
            } else {
              int resId = getStringRes(activity, "ssdk_oks_select_one_plat_at_least");
              if (resId > 0) {
                Toast.makeText(getContext(), resId, Toast.LENGTH_SHORT).show();
              }
            }
          }
        });

    TextView tvAt = new TextView(getContext());
    int resId = getBitmapRes(activity, "ssdk_oks_btn_back_nor");
    if (resId > 0) {
      tvAt.setBackgroundResource(resId);
    }
    int dp_32 = dipToPx(getContext(), 32);
    tvAt.setLayoutParams(new LayoutParams(dp_32, dp_32));
    tvAt.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
    tvAt.setText(getAtUserButtonText(platform));
    int dp_2 = dipToPx(getContext(), 2);
    tvAt.setPadding(0, 0, 0, dp_2);
    tvAt.setTypeface(Typeface.DEFAULT_BOLD);
    tvAt.setTextColor(0xff000000);
    tvAt.setGravity(Gravity.CENTER);
    llAt.addView(tvAt);

    TextView tvName = new TextView(getContext());
    tvName.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
    tvName.setTextColor(0xff000000);
    resId = getStringRes(activity, "ssdk_oks_list_friends");
    String text = getContext().getString(resId, getName(platform));
    tvName.setText(text);
    LayoutParams lpName = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    lpName.gravity = Gravity.CENTER_VERTICAL;
    tvName.setLayoutParams(lpName);
    llAt.addView(tvName);

    return llAt;
  }
예제 #3
0
  protected void setRightButtonText(String text) {
    RelativeLayout rightView = (RelativeLayout) findViewById(R.id.right_view);
    rightView.removeAllViews();

    int padding = dp2px(6);
    RelativeLayout.LayoutParams lp =
        new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    lp.addRule(RelativeLayout.CENTER_IN_PARENT);
    lp.setMargins(0, 0, dp2px(8), 0);
    TextView tv = new TextView(this);
    tv.setText(text);
    tv.setTextColor(0xFF666666);
    tv.setTextSize(16.f);
    tv.setLayoutParams(lp);
    tv.setBackgroundResource(R.drawable.btn_gray);
    tv.setPadding(2 * padding, padding, 2 * padding, padding);
    tv.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            onRightButtonClicked(v);
          }
        });

    rightView.addView(tv);
    rightView.setVisibility(View.VISIBLE);
  }
예제 #4
0
  // platform logos
  private LinearLayout getPlatformList() {
    LinearLayout llToolBar = new LinearLayout(getContext());
    LayoutParams lpTb = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    llToolBar.setLayoutParams(lpTb);

    TextView tvShareTo = new TextView(getContext());
    int resId = getStringRes(activity, "ssdk_oks_share_to");
    if (resId > 0) {
      tvShareTo.setText(resId);
    }
    tvShareTo.setTextColor(0xffcfcfcf);
    tvShareTo.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
    int dp_9 = dipToPx(getContext(), 9);
    LayoutParams lpShareTo = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    lpShareTo.gravity = Gravity.CENTER_VERTICAL;
    lpShareTo.setMargins(dp_9, 0, 0, 0);
    tvShareTo.setLayoutParams(lpShareTo);
    llToolBar.addView(tvShareTo);

    HorizontalScrollView sv = new HorizontalScrollView(getContext());
    sv.setHorizontalScrollBarEnabled(false);
    sv.setHorizontalFadingEdgeEnabled(false);
    LayoutParams lpSv = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    lpSv.setMargins(dp_9, dp_9, dp_9, dp_9);
    sv.setLayoutParams(lpSv);
    llToolBar.addView(sv);

    llPlat = new LinearLayout(getContext());
    llPlat.setLayoutParams(
        new HorizontalScrollView.LayoutParams(
            LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
    sv.addView(llPlat);

    return llToolBar;
  }
    @Override
    public void onSuccess(int i, Header[] headers, String s, List<NewsTypeList> newsTypeLists) {
      if (dialog.isShowing()) {
        dialog.dismiss();
      }

      if (newsTypeLists != null) {
        fragmentManager = getSupportFragmentManager();
        fragmentList = new ArrayList<Fragment>();
        for (int y = 0; y < newsTypeLists.size(); y++) {
          DisplayMetrics dm = new DisplayMetrics();
          getWindowManager().getDefaultDisplay().getMetrics(dm);
          int width = dm.widthPixels;
          // 标题相关
          TextView textView = new TextView(XYNewsActivity.this);
          textView.setLayoutParams(
              new LinearLayout.LayoutParams(width / 3, LinearLayout.LayoutParams.MATCH_PARENT));
          textView.setGravity(Gravity.CENTER);
          textView.setText(newsTypeLists.get(y).getNewsTypeTitle());
          horizontalScrollView.addView(textView);
          textView.setTag(y);
          textView.setOnClickListener(XYNewsActivity.this);
          // 页面相关
          Fragment fragment = new NewsFragment();
          fragmentList.add(fragment);
        }
        mAboutPagerAdapter = new AboutPagerAdapter(fragmentManager, fragmentList);
        mViewPager.setAdapter(mAboutPagerAdapter);
        mViewPager.setCurrentItem(0);
        ((NewsFragment) fragmentList.get(0)).showView(1, 0, 20);
        ((TextView) horizontalScrollView.getChildAt(0)).setTextSize(16);
        ((TextView) horizontalScrollView.getChildAt(0))
            .setTextColor(getResources().getColor(R.color.bg_title_bar));
      }
    }
예제 #6
0
  private RelativeLayout createPin() {
    final RelativeLayout pinLayout = new RelativeLayout(getContext());
    pinLayout.setVisibility(View.INVISIBLE);

    final Pin pin = new Pin(getContext());
    pin.setId(ID_PIN);
    final RelativeLayout.LayoutParams pinParams =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    pinParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    pinParams.addRule(RelativeLayout.ALIGN_BOTTOM, ID_PIN_TEXT);
    pinParams.addRule(RelativeLayout.ALIGN_TOP, ID_PIN_TEXT);
    pin.setLayoutParams(pinParams);
    pinLayout.addView(pin);

    final TextView indicatorTextView = new TextView(getContext());
    indicatorTextView.setId(ID_PIN_TEXT);
    final RelativeLayout.LayoutParams indicatorParams =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    indicatorParams.addRule(RelativeLayout.LEFT_OF, ID_PIN);
    indicatorTextView.setLayoutParams(indicatorParams);
    indicatorTextView.setTextColor(Color.WHITE);
    indicatorTextView.setGravity(Gravity.CENTER);
    indicatorTextView.setBackgroundColor(GREY_LIGHT);
    pinLayout.addView(indicatorTextView);

    return pinLayout;
  }
예제 #7
0
  private TableRow createRow(String key, String value) {
    TableRow row = new TableRow(context);
    TextView pinName = new TextView(context);
    TextView pinValue = new TextView(context);

    row.setLayoutParams(
        new TableLayout.LayoutParams(
            TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT));
    pinName.setText(key);
    pinName.setLayoutParams(new TableRow.LayoutParams(MP, WC, 1));
    pinName.setTextSize(textSize);
    pinValue.setText(value);
    pinValue.setLayoutParams(new TableRow.LayoutParams(MP, WC, 1));
    pinValue.setTextSize(textSize);

    row.addView(pinName);
    row.addView(pinValue);
    return row;
  }
  private void addWeightElement() {
    //        currentItemsCnt++;
    WeightItem item = new WeightItem();
    item.position = helper.itemsList.size();
    item.weight = 100 / currentItemsCnt;
    helper.itemsList.add(item);

    TextView text = new TextView(this);
    text.setText("pos" + item.position);

    LinearLayout.LayoutParams params =
        new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    params.weight = item.weight;
    text.setLayoutParams(params);
    text.setId(0x00001000 + item.position);
    text.setBackgroundColor(
        Color.rgb(
            0xFF / (item.position + 1), 0x7F / (item.position + 1), 0xFF / (item.position + 1)));
    weightView.addView(text);

    // Liean container

    TextView seekText = new TextView(this);
    seekText.setText("pos " + item.position);
    seekText.setPadding(0, 0, 10, 0);
    SeekBar seekBar = new SeekBar(this);
    seekBar.setId(0x00001000 + item.position + 30);
    seekBar.setMax(100 / currentItemsCnt);
    seekBar.setOnSeekBarChangeListener(new SeekListener(item));
    seekBar.setPadding(0, 5, 0, 5);
    seekBar.setProgress(seekBar.getMax());

    LinearLayout linearLayout = new LinearLayout(this);
    //            LinearLayout.LayoutParams params = new
    // LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
    //                    ViewGroup.LayoutParams.WRAP_CONTENT);
    seekBar.setLayoutParams(params);
    linearLayout.addView(seekText);
    linearLayout.addView(seekBar);

    seekView.addView(linearLayout);

    TextView ttt = new TextView(this);

    ttt.setId(0x00002000 + item.position);
    ttt.setText("weight of item " + item.position + " w = " + item.weight);
    changeView.addView(ttt);
  }
예제 #9
0
  private void SetBackGroundforList() {
    // TODO Auto-generated method stub
    mDownView_parent_txt1 = new TextView(activity.getApplicationContext());
    RelativeLayout.LayoutParams lp1 =
        new RelativeLayout.LayoutParams(
            LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    lp1.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    mDownView_parent_txt1.setId(Integer.parseInt("111111"));
    mDownView_parent_txt1.setLayoutParams(lp1);
    mDownView_parent_txt1.setGravity(Gravity.CENTER_HORIZONTAL);
    mDownView_parent_txt1.setText(HalfText);
    mDownView_parent_txt1.setWidth(textwidth2);
    mDownView_parent_txt1.setPadding(0, textheight / 4, 0, 0);
    mDownView_parent_txt1.setHeight(textheight);
    mDownView_parent_txt1.setBackgroundColor(Color.parseColor(FullColor));
    mDownView_parent_txt1.setTextColor(Color.parseColor(TextColor));
    mDownView_parent_txt1.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
    mDownView_parent.addView(mDownView_parent_txt1, 0);

    //         if(SwipeType==Double){
    //             mDownView_parent_txt2 = new TextView(activity.getApplicationContext());
    //             mDownView_parent_txt2.setId(222222);
    //             RelativeLayout.LayoutParams lp2 =new
    // RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,android.widget.RelativeLayout.LayoutParams.WRAP_CONTENT);
    //             lp2.addRule(RelativeLayout.LEFT_OF,mDownView_parent_txt1.getId());
    //             mDownView_parent_txt2.setLayoutParams(lp2);
    //             mDownView_parent_txt2.setGravity(Gravity.CENTER_HORIZONTAL);
    //             mDownView_parent_txt2.setText(FullText);
    //             mDownView_parent_txt2.setWidth(textwidth);
    //             mDownView_parent_txt2.setPadding(0, textheight/4, 0, 0);
    //             mDownView_parent_txt2.setHeight(textheight);
    //             mDownView_parent_txt2.setBackgroundColor(Color.parseColor(FullColor));
    //             mDownView_parent_txt2.setTextColor(Color.parseColor(TextColor));
    //             mDownView_parent_txt2.setCompoundDrawablesWithIntrinsicBounds(null ,
    // FullDrawable, null, null );
    //             mDownView_parent.addView(mDownView_parent_txt2, 1);
    //         }
  }
예제 #10
0
  private LinearLayout getBodyBottom() {
    LinearLayout llBottom = new LinearLayout(getContext());
    llBottom.setLayoutParams(
        new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

    LinearLayout line = getAtLine(platforms.get(0).getName());
    if (line != null) {
      llBottom.addView(line);
    }

    // Words counter
    tvCounter = new TextView(getContext());
    tvCounter.setText(String.valueOf(MAX_TEXT_COUNT));
    tvCounter.setTextColor(0xffcfcfcf);
    tvCounter.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
    tvCounter.setTypeface(Typeface.DEFAULT_BOLD);
    LayoutParams lpCounter = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    lpCounter.gravity = Gravity.CENTER_VERTICAL;
    tvCounter.setLayoutParams(lpCounter);
    llBottom.addView(tvCounter);

    return llBottom;
  }
예제 #11
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);
  }