private void init() {
    setVerticalFadingEdgeEnabled(false);

    headerContainer =
        (LinearLayout) LayoutInflater.from(getContext()).inflate(R.layout.ptr_header, null);
    header = (RelativeLayout) headerContainer.findViewById(R.id.ptr_id_header);
    text = (TextView) header.findViewById(R.id.ptr_id_text);
    lastUpdatedTextView = (TextView) header.findViewById(R.id.ptr_id_last_updated);
    image = (ImageView) header.findViewById(R.id.ptr_id_image);
    spinner = (ProgressBar) header.findViewById(R.id.ptr_id_spinner);

    pullToRefreshText = getContext().getString(R.string.ptr_pull_to_refresh);
    releaseToRefreshText = getContext().getString(R.string.ptr_release_to_refresh);
    refreshingText = getContext().getString(R.string.ptr_refreshing);
    lastUpdatedText = getContext().getString(R.string.ptr_last_updated);

    flipAnimation =
        new RotateAnimation(
            0,
            -180,
            RotateAnimation.RELATIVE_TO_SELF,
            0.5f,
            RotateAnimation.RELATIVE_TO_SELF,
            0.5f);
    flipAnimation.setInterpolator(new LinearInterpolator());
    flipAnimation.setDuration(ROTATE_ARROW_ANIMATION_DURATION);
    flipAnimation.setFillAfter(true);

    reverseFlipAnimation =
        new RotateAnimation(
            -180,
            0,
            RotateAnimation.RELATIVE_TO_SELF,
            0.5f,
            RotateAnimation.RELATIVE_TO_SELF,
            0.5f);
    reverseFlipAnimation.setInterpolator(new LinearInterpolator());
    reverseFlipAnimation.setDuration(ROTATE_ARROW_ANIMATION_DURATION);
    reverseFlipAnimation.setFillAfter(true);

    addHeaderView(headerContainer);
    setState(State.PULL_TO_REFRESH);
    scrollbarEnabled = isVerticalScrollBarEnabled();

    ViewTreeObserver vto = header.getViewTreeObserver();
    vto.addOnGlobalLayoutListener(new PTROnGlobalLayoutListener());

    super.setOnItemClickListener(new PTROnItemClickListener());
    super.setOnItemLongClickListener(new PTROnItemLongClickListener());
  }
 /**
  * Sets the indicator colors, when QuickScroll.TYPE_INDICATOR is selected as type.
  *
  * <p>
  *
  * @param background the background color of the square
  * @param tip the background color of the tip triangle
  * @param text the color of the text
  */
 public void setIndicatorColor(final int background, final int tip, final int text) {
   if (mType == TYPE_INDICATOR || mType == TYPE_INDICATOR_WITH_HANDLE) {
     ((Pin) mScrollIndicator.findViewById(ID_PIN)).setColor(tip);
     mScrollIndicatorText.setTextColor(text);
     mScrollIndicatorText.setBackgroundColor(background);
   }
 }
    public View getView(int position, View convertView, ViewGroup parent) {
      RelativeLayout rowLayout;
      ServiceAcctInfo acct = acctList[position];
      if (convertView == null) {
        rowLayout =
            (RelativeLayout)
                LayoutInflater.from(context).inflate(R.layout.realm_login_row, parent, false);
      } else {
        rowLayout = (RelativeLayout) convertView;
      }

      String acctType = msgsetNames[acct.type.ordinal()];
      if (acct.name.acctType != null) acctType = acctType + " (" + acct.name.acctType + ')';
      if (acct.name.acctId != null) acctType = acctType + "\nAccount: " + acct.name.acctId;
      ((TextView) rowLayout.findViewById(R.id.Name)).setText(acct.desc);
      ((TextView) rowLayout.findViewById(R.id.TaskList)).setText(acctType);

      return rowLayout;
    }
 private void hideIndicatorCompat() {
   if (mScrollIndicatorText != null) {
     mScrollIndicatorText.setVisibility(View.INVISIBLE);
     mScrollIndicatorText.startAnimation(mFadeOut);
   }
   if (mScrollIndicator != null) {
     mScrollIndicator.findViewById(ID_PIN).setVisibility(View.INVISIBLE);
     mScrollIndicator.startAnimation(mFadeOut);
   }
 }
	public void setDrawerContentView(int layout_id) {
		
		LayoutInflater inflater = LayoutInflater.from(this);
		rightSideAppScreenView = inflater.inflate(layout_id, null);
		mAttachedViewID = rightSideAppScreenView.getId();
		
		mHeaderRelativeLayout = (RelativeLayout)rightSideAppScreenView.findViewById(R.id.navigation_header);
		
		mTitleTextView = (TextView)mHeaderRelativeLayout.findViewById(R.id.tv_header_title);
		mSubtitleTextView = (TextView)mHeaderRelativeLayout.findViewById(R.id.tv_header_subtitle);
		mHeaderImageView = (ImageView)mHeaderRelativeLayout.findViewById(R.id.iv_header_icon);
		
		mTimeTrackerTextView = (TextView) mHeaderRelativeLayout.findViewById(R.id.menu_header_time_tracker);
		mTimerLayout = (LinearLayout)mHeaderRelativeLayout.findViewById(R.id.timer_layout);
		
		mSubtitleTextView.setOnClickListener(this);
		mTimeTrackerTextView.setOnClickListener(this);
		mTimerLayout.setOnClickListener(this);

		ViewGroup tabBar = (ViewGroup) rightSideAppScreenView.findViewById(mAttachedViewID);

		btnSlide = (ImageButton) tabBar.findViewById(R.id.bt_slider);
		btnSlide.setVisibility(View.VISIBLE);

		mSliderClickListener = new ClickListenerForScrolling(mSliderView, leftSideListView, menuOut);
		btnSlide.setOnClickListener(mSliderClickListener);
		
		mHomeBtnLayout = (LinearLayout)mHeaderRelativeLayout.findViewById(R.id.home_layout);
		if(mHomeBtnLayout!= null)
		{
			mHomeBtnLayout.setOnClickListener(mSliderClickListener);
		}

		View[] children = new View[] { leftSideListView, rightSideAppScreenView };

		int scrollToViewIdx = 1;

		mSliderView.initViews(children, scrollToViewIdx, new SizeCallbackForMenu(btnSlide));
		
		setSubTitle(AppConfig.getAppConfigInstance(this).getUserName());
	     setTitle(getResources().getString(R.string.app_title));
		
		displayHeaderMenuBar();
		//If learn mode is active, the titlebar color must be changed.
		if (AppConfig.getAppConfigInstance(this).getDeviceSynched())
			mPresenter.checkLearnMode(this, rightSideAppScreenView,
					mSubtitleTextView);
	}
Exemple #6
0
  protected void FillViewGroup(
      LinearLayout layout, String title, String center, String content, String result) {
    exchange_icon_item =
        (RelativeLayout) LayoutInflater.from(getApplicationContext()).inflate(R.layout.item, null);
    item_img_icon = (ImageView) exchange_icon_item.findViewById(R.id.img_icon);
    tv_item_title = (TextView) exchange_icon_item.findViewById(R.id.tv_item_title);
    tv_item_center = (TextView) exchange_icon_item.findViewById(R.id.tv_item_center);
    tv_item_content = (TextView) exchange_icon_item.findViewById(R.id.tv_item_content);
    tv_result = (TextView) exchange_icon_item.findViewById(R.id.tv_result);
    ibtn_arrow = (ImageButton) exchange_icon_item.findViewById(R.id.btn_arrow);

    tv_item_title.setText(title);
    tv_item_content.setText(content);
    tv_item_center.setText(center);
    tv_result.setText(result);

    layout.addView(exchange_icon_item);
  }
  @Override
  public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    if (getActivity().getIntent().getExtras() != null) {
      idSession = getActivity().getIntent().getExtras().getLong(UIUtils.MESSAGE);
      typeSession = getActivity().getIntent().getExtras().getString(UIUtils.TYPE);
    } else {
      // On gere le cas ou on tourne l'écran en restorant les états de la vue
      idSession = savedInstanceState.getLong("ID_SESSION");
      ;
      typeSession = savedInstanceState.getString("TYPE_SESSION");
    }
    Conference conference = null;
    // On recupere la session concernee
    if (TypeFile.lightningtalks.name().equals(typeSession)) {
      conference = ConferenceFacade.getInstance().getLightningtalk(getActivity(), idSession);
    } else {
      conference = ConferenceFacade.getInstance().getTalk(getActivity(), idSession);
    }

    List<Membre> speakers = new ArrayList<Membre>();
    for (Long id : conference.getSpeakers()) {
      Membre membre =
          MembreFacade.getInstance().getMembre(getActivity(), TypeFile.members.name(), id);
      if (membre != null) {
        speakers.add(membre);
      }
    }

    // On affiche les liens que si on a recuperer des choses
    if (!speakers.isEmpty()) {
      // On utilisait auparavant une liste pour afficher ces éléments dans la page mais cette liste
      // empêche d'avoir un ScrollView englobant pour toute la page. Nous utilisons donc un tableau
      linearLayoutRoot =
          (LinearLayout) mInflater.inflate(R.layout.fragment_linear, mRootView, false);

      // On vide les éléments
      linearLayoutRoot.removeAllViews();

      // On ajoute un table layout
      TableLayout.LayoutParams tableParams =
          new TableLayout.LayoutParams(
              TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT);
      TableLayout tableLayout = new TableLayout(getActivity().getBaseContext());
      tableLayout.setLayoutParams(tableParams);

      for (final Membre membre : speakers) {
        RelativeLayout row = (RelativeLayout) mInflater.inflate(R.layout.person_item, null);
        row.setBackgroundResource(R.drawable.row_transparent_background);

        // Dans lequel nous allons ajouter le contenu que nous faisons mappé dans
        userName = (TextView) row.findViewById(R.id.person_user_name);
        descriptif = (TextView) row.findViewById(R.id.person_shortdesciptif);
        level = (TextView) row.findViewById(R.id.person_level);
        profileImage = (ImageView) row.findViewById(R.id.person_user_image);

        userName.setText(membre.getCompleteName());

        if (membre.getShortdesc() != null) {
          descriptif.setText(membre.getShortdesc().trim());
        }

        if (membre.getLevel() != null && !membre.getLevel().isEmpty()) {
          level.setText("[" + membre.getLevel().trim() + "]");
        }

        // Recuperation de l'mage liee au profil
        Bitmap image = FileUtils.getImageProfile(getActivity(), membre);
        if (image == null) {
          profileImage.setImageDrawable(getResources().getDrawable(R.drawable.person_image_empty));
        } else {
          // On regarde dans les images embarquees
          profileImage.setImageBitmap(image);
        }

        row.setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                Map<String, Object> parameters = new HashMap<String, Object>(2);
                parameters.put(UIUtils.MESSAGE, membre.getId());
                parameters.put(UIUtils.TYPE, TypeFile.speaker);
                UIUtils.startActivity(MembreActivity.class, getActivity(), parameters);
              }
            });

        tableLayout.addView(row);
      }

      linearLayoutRoot.addView(tableLayout);
      mRootView.addView(linearLayoutRoot);
    }
  }
	/**
	 * This method makes header menu bar visible to user.
	 */
	public void displayHeaderMenuBar() {
		button = mHeaderRelativeLayout.findViewById(R.id.bt_header_dropdown_menu_icon);
		mHeaderRelativeLayout = (RelativeLayout) mHeaderRelativeLayout.findViewById(R.id.ll_header_clickable_menubar);
		mHeaderRelativeLayout.setOnClickListener(this);
		mPresenter.displayHeaderMenuBar(button);
	}
  @Override
  public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    if (savedInstanceState != null && savedInstanceState.getBoolean("isConflict", false)) return;
    inputMethodManager =
        (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
    errorItem = (RelativeLayout) getView().findViewById(R.id.rl_error_item);
    errorText = (TextView) errorItem.findViewById(R.id.tv_connect_errormsg);

    conversationList.addAll(loadConversationsWithRecentChat());
    listView = (ListView) getView().findViewById(R.id.list);
    back = (ImageView) getView().findViewById(R.id.back);
    back.setOnClickListener(this);
    adapter = new ChatAllHistoryAdapter(getActivity(), 1, conversationList);
    // 设置adapter
    listView.setAdapter(adapter);

    final String st2 = getResources().getString(R.string.Cant_chat_with_yourself);
    listView.setOnItemClickListener(
        new OnItemClickListener() {

          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            EMConversation conversation = adapter.getItem(position);
            String username = conversation.getUserName();
            if (username.equals(PricesApplication.getInstance().getUserName()))
              Toast.makeText(getActivity(), st2, Toast.LENGTH_SHORT).show();
            else {
              // 进入聊天页面
              Intent intent = new Intent(getActivity(), ChatActivity.class);
              if (conversation.isGroup()) {
                if (conversation.getType() == EMConversationType.ChatRoom) {
                  // it is group chat
                  intent.putExtra("chatType", ChatActivity.CHATTYPE_CHATROOM);
                  intent.putExtra("groupId", username);
                } else {
                  // it is group chat
                  intent.putExtra("chatType", ChatActivity.CHATTYPE_GROUP);
                  intent.putExtra("groupId", username);
                }

              } else {
                // it is single chat
                intent.putExtra("userId", username);
              }
              startActivity(intent);
            }
          }
        });
    // 注册上下文菜单
    registerForContextMenu(listView);

    listView.setOnTouchListener(
        new OnTouchListener() {

          @Override
          public boolean onTouch(View v, MotionEvent event) {
            // 隐藏软键盘
            hideSoftKeyboard();
            return false;
          }
        });
    // 搜索框
    query = (EditText) getView().findViewById(R.id.query);
    String strSearch = getResources().getString(R.string.search);
    query.setHint(strSearch);
    // 搜索框中清除button
    clearSearch = (ImageButton) getView().findViewById(R.id.search_clear);
    query.addTextChangedListener(
        new TextWatcher() {
          public void onTextChanged(CharSequence s, int start, int before, int count) {
            adapter.getFilter().filter(s);
            if (s.length() > 0) {
              clearSearch.setVisibility(View.VISIBLE);
            } else {
              clearSearch.setVisibility(View.INVISIBLE);
            }
          }

          public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

          public void afterTextChanged(Editable s) {}
        });
    clearSearch.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            query.getText().clear();
            hideSoftKeyboard();
          }
        });
  }
  /**
   * 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);
  }