@Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (DEBUG_LIFECYCLE) logger.warn("{} onCreateView()", fullName);
    View v = inflater.inflate(R.layout.chatview_main, container, false);

    uiLines = (ListView) v.findViewById(R.id.chatview_lines);
    uiInput = (EditText) v.findViewById(R.id.chatview_input);
    uiSend = (ImageButton) v.findViewById(R.id.chatview_send);
    uiTab = (ImageButton) v.findViewById(R.id.chatview_tab);

    uiSend.setOnClickListener(this);
    uiTab.setOnClickListener(this);
    uiInput.setOnKeyListener(this); // listen for hardware keyboard
    uiInput.addTextChangedListener(
        this); // listen for software keyboard through watching input box text
    uiInput.setOnEditorActionListener(
        this); // listen for software keyboard's “send” click. see onEditorAction()

    uiLines.setFocusable(false);
    uiLines.setFocusableInTouchMode(false);

    CopyPaste cp = new CopyPaste(activity, uiInput);
    uiInput.setOnLongClickListener(cp);
    uiLines.setOnItemLongClickListener(cp);

    return v;
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (DEBUG_LIFECYCLE) logger.debug("onCreateView()");
    View v = inflater.inflate(R.layout.chatview_main, container, false);

    uiLines = (ListView) v.findViewById(R.id.chatview_lines);
    uiInput = (EditText) v.findViewById(R.id.chatview_input);
    uiSend = (ImageButton) v.findViewById(R.id.chatview_send);
    uiTab = (ImageButton) v.findViewById(R.id.chatview_tab);

    uiSend.setOnClickListener(this);
    uiTab.setOnClickListener(this);
    uiInput.setOnKeyListener(this); // listen for hardware keyboard
    uiInput.addTextChangedListener(
        this); // listen for software keyboard through watching input box text
    uiInput.setOnEditorActionListener(
        this); // listen for software keyboard's “send” click. see onEditorAction()

    uiLines.setFocusable(false);
    uiLines.setFocusableInTouchMode(false);

    CopyPaste cp = new CopyPaste(activity, uiInput);
    uiInput.setOnLongClickListener(cp);
    uiLines.setOnItemLongClickListener(cp);

    uiMore = (ViewGroup) inflater.inflate(R.layout.more_button, null);
    uiMoreButton = (Button) uiMore.findViewById(R.id.button_more);
    uiMoreButton.setOnClickListener(this);
    uiLines.addHeaderView(uiMore);
    status = Buffer.LINES.CAN_FETCH_MORE;

    online = true;
    return v;
  }
  public TiListView(TiViewProxy proxy, Activity activity) {
    super(proxy);

    // initializing variables
    sections = new ArrayList<ListSectionProxy>();
    itemTypeCount = new AtomicInteger(2);
    templatesByBinding = new HashMap<String, TiListViewTemplate>();
    defaultTemplateBinding = UIModule.LIST_ITEM_TEMPLATE_DEFAULT;
    caseInsensitive = true;

    // handling marker
    HashMap<String, Integer> preloadMarker = ((ListViewProxy) proxy).getPreloadMarker();
    if (preloadMarker != null) {
      setMarker(preloadMarker);
    } else {
      resetMarker();
    }

    // initializing listView and adapter
    ListViewWrapper wrapper = new ListViewWrapper(activity);
    wrapper.setFocusable(false);
    wrapper.setFocusableInTouchMode(false);
    listView = new ListView(activity);
    listView.setLayoutParams(
        new ViewGroup.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    wrapper.addView(listView);
    adapter = new TiBaseAdapter(activity);

    // init inflater
    if (inflater == null) {
      inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }

    listView.setCacheColorHint(Color.TRANSPARENT);
    getLayoutParams().autoFillsHeight = true;
    getLayoutParams().autoFillsWidth = true;
    listView.setFocusable(true);
    listView.setFocusableInTouchMode(true);
    listView.setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);

    try {
      headerFooterId = TiRHelper.getResource("layout.titanium_ui_list_header_or_footer");
      listItemId = TiRHelper.getResource("layout.titanium_ui_list_item");
      titleId = TiRHelper.getResource("id.titanium_ui_list_header_or_footer_title");
      listContentId = TiRHelper.getResource("id.titanium_ui_list_item_content");
      isCheck = TiRHelper.getResource("drawable.btn_check_buttonless_on_64");
      hasChild = TiRHelper.getResource("drawable.btn_more_64");
      disclosure = TiRHelper.getResource("drawable.disclosure_64");
      accessory = TiRHelper.getResource("id.titanium_ui_list_item_accessoryType");
    } catch (ResourceNotFoundException e) {
      Log.e(TAG, "XML resources could not be found!!!", Log.DEBUG_MODE);
    }

    this.wrapper = wrapper;
    setNativeView(wrapper);
  }
 /** 当ListView被触摸时调用,其中处理了各种下拉刷新的具体逻辑。 */
 @Override
 public boolean onTouch(View v, MotionEvent event) {
   setIsAbleToPull(event);
   if (ableToPull) {
     switch (event.getAction()) {
       case MotionEvent.ACTION_DOWN:
         yDown = event.getRawY();
         break;
       case MotionEvent.ACTION_MOVE:
         float yMove = event.getRawY();
         int distance = (int) (yMove - yDown);
         // 如果手指是下滑状态,并且下拉头是完全隐藏的,就屏蔽下拉事件
         if (distance <= 0 && headerLayoutParams.topMargin <= hideHeaderHeight) {
           return false;
         }
         if (distance < touchSlop) {
           return false;
         }
         if (currentStatus != STATUS_REFRESHING) {
           if (headerLayoutParams.topMargin > 0) {
             currentStatus = STATUS_RELEASE_TO_REFRESH;
           } else {
             currentStatus = STATUS_PULL_TO_REFRESH;
           }
           // 通过偏移下拉头的topMargin值,来实现下拉效果
           headerLayoutParams.topMargin = (distance / 2) + hideHeaderHeight;
           header.setLayoutParams(headerLayoutParams);
         }
         break;
       case MotionEvent.ACTION_UP:
       default:
         if (currentStatus == STATUS_RELEASE_TO_REFRESH) {
           // 松手时如果是释放立即刷新状态,就去调用正在刷新的任务
           new RefreshingTask().execute();
         } else if (currentStatus == STATUS_PULL_TO_REFRESH) {
           // 松手时如果是下拉状态,就去调用隐藏下拉头的任务
           new HideHeaderTask().execute();
         }
         break;
     }
     // 时刻记得更新下拉头中的信息
     if (currentStatus == STATUS_PULL_TO_REFRESH || currentStatus == STATUS_RELEASE_TO_REFRESH) {
       updateHeaderView();
       // 当前正处于下拉或释放状态,要让ListView失去焦点,否则被点击的那一项会一直处于选中状态
       listView.setPressed(false);
       listView.setFocusable(false);
       listView.setFocusableInTouchMode(false);
       lastStatus = currentStatus;
       // 当前正处于下拉或释放状态,通过返回true屏蔽掉ListView的滚动事件
       return true;
     }
   }
   return false;
 }
  @Override
  public void onActivityCreated(final Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    mAdapter = new StudentAdapter(getActivity(), null, 0);
    mListView.setAdapter(mAdapter);

    mListView.setOnItemClickListener(this);
    mListView.setItemsCanFocus(false);
    mListView.setFocusableInTouchMode(false);
    mListView.setClipToPadding(false);
    mListView.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY);

    getActivity().getLoaderManager().initLoader(0, savedInstanceState, this);
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Intent intent = this.getIntent();
    setContentView(R.layout.facebook_friends_ui);
    friendList = (ListView) this.findViewById(R.id.facebook_user_list);
    friendList.setFocusableInTouchMode(true);
    friendList.setFocusable(true);
    friendList.setOnCreateContextMenuListener(this);
    friendList.setOnItemClickListener(listItemClickListener);
    friendList.setOnScrollListener(scrollListener);

    current_postion = (TextView) this.findViewById(R.id.current_postion);
    // current_postion.setVisibility(View.GONE);

    searchSpan = this.findViewById(R.id.facebook_search_span);
    searchSpan.setVisibility(View.VISIBLE);
    keyEdit = (EditText) this.findViewById(R.id.embedded_text_editor);
    watcher = new MyWatcher();
    keyEdit.addTextChangedListener(watcher);

    pageHandler = new PageHandler();
    View v = findViewById(R.id.progress_horizontal);
    if (v != null) {
      progressHorizontal = (ProgressBar) v;
    }

    setTitle("");
    SocialORM.Account account = orm.getFacebookAccount();

    if (checkFacebookAccount(this, account)) {
      perm_session = loginHelper.getPermanentSesstion(this);
      if (perm_session != null) {
        perm_session.attachActivity(this);

        facebookA = new AsyncFacebook(perm_session);
        handler.obtainMessage(FACEBOOK_PAGE_UI).sendToTarget();
        Cursor tmp = orm.getAllPageCursor();
        if (tmp == null || tmp.getCount() == 0) {
          Log.d(TAG, "I have no data, so load from web server");
          lauchGetPages();
        }
      } else {
        launchFacebookLogin();
      }
    }
  }
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.facebook_event_ui);
    contentList = (ListView) this.findViewById(R.id.facebook_event_list);
    contentList.setFocusableInTouchMode(true);
    contentList.setFocusable(true);
    contentList.setOnCreateContextMenuListener(this);
    contentList.setOnItemClickListener(itemClick);

    infoSpan = (View) findViewById(R.id.facebook_info_span);
    eventinfoview = (TextView) findViewById(R.id.facebook_info);
    fornotification = this.getIntent().getBooleanExtra("fornotification", false);
    eids = this.getIntent().getLongArrayExtra("eids");

    setTitle();
    setTitle(title);
    SocialORM.Account account = orm.getFacebookAccount();
    if (checkFacebookAccount(this, account)) {
      perm_session = loginHelper.getPermanentSesstion(this);
      if (perm_session != null) {
        perm_session.attachActivity(this);
        facebookA = new AsyncFacebook(perm_session);
        if (fornotification == true) {
          event = orm.getFacebookeventsNotificationCursor(eids);

          if (event != null && event.getCount() > 0) {
            handler.obtainMessage(FACEBOOK_EVENT_UI).sendToTarget();
          }
          launchLoadEvents();
        } else {
          event = orm.getFacebookeventsCursor();

          if (event == null || event.getCount() == 0) {
            launchLoadEvents();
          } else {

            handler.obtainMessage(FACEBOOK_EVENT_UI).sendToTarget();
          }
        }
      } else {
        launchFacebookLogin();
      }
    }
  }
Example #8
0
  /**
   * Sets the view data from a given overlay item.
   *
   * @param item - The overlay item containing the relevant view data (title and line1).
   */
  public void setData(PlacesOverlayItem item) {

    mLayout.setVisibility(VISIBLE);
    if (item.getName() != null) {
      mTitle.setVisibility(VISIBLE);
      mTitle.setText(item.getName());
    } else {
      mTitle.setVisibility(GONE);
    }

    if (item.getVisitTimes() != null) {
      mList.setVisibility(VISIBLE);
      mList.setFocusable(false);
      mList.setClickable(false);
      mList.setSelected(false);
      mList.setFocusableInTouchMode(false);
      mList.setDividerHeight(0);

      VisitTimeAdapter adapter =
          new VisitTimeAdapter(mCxt, R.layout.balloon_overlay_item, item.getVisitTimes());
      mList.setAdapter(adapter);

    } else {
      mList.setVisibility(GONE);
    }

    Drawable drawable = null;

    int type = item.getType();

    if (type == Places.TYPE_GPS) {
      drawable = mCxt.getResources().getDrawable(R.drawable.icon_satellite);
      mIcon.setVisibility(VISIBLE);
      mIcon.setImageDrawable(drawable);
    } else if (type == Places.TYPE_WIFI) {
      drawable = mCxt.getResources().getDrawable(R.drawable.icon_wifi);
      mIcon.setVisibility(VISIBLE);
      mIcon.setImageDrawable(drawable);
    } else {
      mIcon.setVisibility(GONE);
    }
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    onCreateView(inflater, container);

    /// M:should create list Adapter here for child class init the right status.@{
    mAdapter = createListAdapter();
    /// @}

    boolean searchMode = isSearchMode();
    mAdapter.setSearchMode(searchMode);
    mAdapter.configureDefaultPartition(false, searchMode);
    mAdapter.setPhotoLoader(mPhotoManager);
    mListView.setAdapter(mAdapter);

    if (!isSearchMode()) {
      mListView.setFocusableInTouchMode(true);
      mListView.requestFocus();
    }

    return mView;
  }
  protected void initView() {
    mHandler = new Handler();

    mScrollView = (XScrollView) findViewById(R.id.scroll_view);
    mScrollView.setPullRefreshEnable(true);
    mScrollView.setPullLoadEnable(true);
    mScrollView.setIXScrollViewListener(this);
    mScrollView.setRefreshTime(getTime());

    View content = LayoutInflater.from(this).inflate(R.layout.vw_scroll_view_content, null);

    if (null != content) {
      mListView = (ListView) content.findViewById(R.id.content_list);
      mListView.setFocusable(false);
      mListView.setFocusableInTouchMode(false);

      mAdapter = new ArrayAdapter<String>(this, R.layout.vw_list_item, mItems);
      mListView.setAdapter(mAdapter);
      measureHeight();
    }

    mScrollView.setView(content);
  }
Example #11
0
  @SuppressWarnings("deprecation")
  public PopMenu(Context context) {
    // TODO Auto-generated constructor stub
    this.context = context;

    itemList = new ArrayList<String>(5);

    View view = LayoutInflater.from(context).inflate(R.layout.liu_popmenu, null);

    listView = (ListView) view.findViewById(R.id.listView);
    listView.setAdapter(new PopAdapter());
    listView.setFocusableInTouchMode(true);
    listView.setFocusable(true);

    popupWindow = new PopupWindow(view, 100, LayoutParams.WRAP_CONTENT);
    popupWindow =
        new PopupWindow(
            view,
            context.getResources().getDimensionPixelSize(R.dimen.popmenu_width),
            LayoutParams.WRAP_CONTENT);

    popupWindow.setBackgroundDrawable(new BitmapDrawable());
  }
Example #12
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mContext = TwitterListActivity.this;
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.twitter_list_account);

    listview = (ListView) this.findViewById(R.id.twitter_tweets_list);
    listview.setFocusableInTouchMode(true);
    listview.setFocusable(true);
    listview.setOnItemClickListener(itemClickListener);

    ArrayList<String> useraccounts = this.getIntent().getStringArrayListExtra("foruseraccount");
    ArrayList<String> forsearch = this.getIntent().getStringArrayListExtra("forsearch");

    if (useraccounts != null && useraccounts.size() > 0) {
      issearch = false;
      listview.setAdapter(new TwitterSimpleAdapter(this, useraccounts, false));
    }
    if (forsearch != null && forsearch.size() > 0) {
      issearch = true;
      listview.setAdapter(new TwitterSimpleAdapter(this, forsearch, true));
    }
  }
Example #13
0
  public TOCDlg(BaseActivity coolReader, ReaderView readerView, TOCItem toc, int currentPage) {
    super(coolReader, coolReader.getResources().getString(R.string.win_title_toc), false, false);
    setCancelable(true);
    //		this.mCoolReader = coolReader;
    this.mReaderView = readerView;
    this.mTOC = toc;
    this.mCurrentPage = currentPage;
    this.mListView = new BaseListView(getContext(), true);
    mListView.setOnItemClickListener(
        new OnItemClickListener() {

          @Override
          public void onItemClick(AdapterView<?> listview, View view, int position, long id) {
            TOCItem item = mItems.get(position);
            if (item.getChildCount() == 0 || item.getExpanded()) {
              mReaderView.goToPage(item.getPage() + 1);
              dismiss();
            } else {
              expand(item);
            }
          }
        });
    mListView.setOnItemLongClickListener(
        new OnItemLongClickListener() {

          @Override
          public boolean onItemLongClick(
              AdapterView<?> listview, View view, int position, long id) {
            TOCItem item = mItems.get(position);
            if (item.getChildCount() == 0) {
              mReaderView.goToPage(item.getPage() + 1);
              dismiss();
            } else {
              if (item.getExpanded()) collapse(item);
              else expand(item);
            }
            return true;
          }
        });
    mListView.setLongClickable(true);
    mListView.setClickable(true);
    mListView.setFocusable(true);
    mListView.setFocusableInTouchMode(true);
    mListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    setView(mListView);
    setFlingHandlers(
        mListView,
        new Runnable() {
          @Override
          public void run() {
            // cancel
            TOCDlg.this.dismiss();
          }
        },
        new Runnable() {
          @Override
          public void run() {
            //
            TOCDlg.this.dismiss();
          }
        });
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.twitter_compose_msg);

    textCount = (TextView) this.findViewById(R.id.twitter_message_text_counter);
    sendcontent = (EditText) this.findViewById(R.id.twitter_message_editor);
    sendcontent.setHint(getString(R.string.twitter_compose_message));
    InputFilter[] filters = new InputFilter[] {new InputFilter.LengthFilter(defaultTextLength)};
    sendcontent.setFilters(filters);
    sendcontent.setVerticalScrollBarEnabled(true);
    watcher = new MyWatcher();
    sendcontent.addTextChangedListener(watcher);

    // addresspad for send message to multiuser
    receiver_span = this.findViewById(R.id.twitter_message_receiver_span);
    message_rev = (AddressPad) this.findViewById(R.id.twitter_message_receiver_editor);
    message_revB = (Button) this.findViewById(R.id.twitter_message_receivers_button);
    twitter_mail_send_button = (Button) this.findViewById(R.id.twitter_mail_send_button);
    twitter_mail_reply_cancel = (Button) this.findViewById(R.id.twitter_mail_reply_cancel);

    commentsView = (ListView) this.findViewById(R.id.twitter_message_list);
    commentsView.setFocusableInTouchMode(true);
    commentsView.setFocusable(true);

    twitter_mail_send_button.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View arg0) {
            titleSelected();
          }
        });

    twitter_mail_reply_cancel.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View arg0) {
            TwitterComposeActivity.this.finish();
          }
        });
    // direct
    to_uid = this.getIntent().getStringExtra(TWITTER_ID);
    TWITTER_UserName = this.getIntent().getStringExtra(TWITTER_UserName);
    status_id = this.getIntent().getLongExtra(STATUS_ID, -1);
    isReply = this.getIntent().getBooleanExtra(REPLY, false);
    isForward = this.getIntent().getBooleanExtra(FORWARD, false);
    isRetweet = this.getIntent().getBooleanExtra(RETWEET, false);
    isDirect = this.getIntent().getBooleanExtra(DIRECT, false);
    isUpdate = this.getIntent().getBooleanExtra(UPDATE, false);
    isComments = this.getIntent().getBooleanExtra(COMMENTS, false);
    Log.d(
        TAG,
        "twitter_id="
            + to_uid
            + " status_id="
            + status_id
            + " reply="
            + isReply
            + " isRetweet="
            + isRetweet
            + " isDirect="
            + isDirect
            + " isUpdate"
            + isUpdate
            + " isComments="
            + isComments);

    if (isForward) // set content
    {
      String tweetContent = this.getIntent().getStringExtra(CONTENT);
      String whoname = to_uid;
      ArrayList<Follow> follows = orm.getTwitterUserByID(to_uid);
      if (follows != null && follows.size() > 0) {
        whoname = follows.get(0).SName;
      }

      sendcontent.setText("FW @" + whoname + " " + tweetContent);
    }

    if (isDirect || isForward || isReply) {
      receiver_span.setVisibility(View.VISIBLE);
      message_revB.setVisibility(View.VISIBLE);

      String tweetContent = this.getIntent().getStringExtra(CONTENT);
      if (isReply && isEmpty(tweetContent) == false) {
        sendcontent.setText(tweetContent);
      }

      initAddressBarView();
    }

    noImpactTitle = true;
    setHeadTitle(getString(R.string.menu_twitter_title_messages));

    // to remember the title
    setTitle();

    setTitle(finalTitle);
    checkTwitterAccount(this, orm.getTwitterAccount());

    twitter_action.setVisibility(View.VISIBLE);
    twitter_refresh.setVisibility(View.GONE);

    if (status_id != -1) {
      loadRefresh();
    }
  }
package com.chang.news.util;