Java新浪微博客户端开发第三步

实现:”下拉刷新”及提示语。

这次的包结构如下:


1、修改MyScrollPane,关键代码:

        verticalScrollBar. addAdjustmentListener ( new  AdjustmentListener ( )  {
             public  void adjustmentValueChanged ( AdjustmentEvent e )  {
                 // getMaximum()滚动条的最大值为最大跨度。
                 // getVisibleAmount()可见的大小
                 int currentValue  = getVerticalScrollBar ( ). getMaximum ( )
                         - getVerticalScrollBar ( ). getVisibleAmount ( ) ;
                 if  (e. getValue ( )  == currentValue  &&  !friendTL. isLoading ( ) )  {
                    friendTL. addPage ( ) ;
                 }
             }
         } ) ;

2、修改FriendTimeline和Timeline类,关键代码:

         try  {
             if (lastId  ==  Long. MAX_VALUE ) {
                statusWapper  = tm. getFriendsTimeline ( 00,
                         new Paging ( 1 ) ) ;
             } else {
                statusWapper  = tm. getFriendsTimeline ( 00, lastId ) ;
             }
         }  catch  (WeiboException e )  {
            e. printStackTrace ( ) ;
         }

注意:

statusWapper  = tm. getFriendsTimeline ( 00, lastId ) ;中的getFriendsTimeline ( 00, lastI )

方法是要在新浪提供的API中的Timeline中添加的,如下:

     public StatusWapper getFriendsTimeline ( Integer baseAPP,  Integer feature,  Long max_id )  throws WeiboException  {
         return Status. constructWapperStatus (Weibo. client. get (
                WeiboConfig. getValue ( "baseURL" )  +  "statuses/friends_timeline.json",
                 new PostParameter [ ]  {
                         new PostParameter ( "base_app", baseAPP. toString ( ) ),
                         new PostParameter ( "feature", feature. toString ( ) ),
                         new PostParameter ( "max_id", max_id. toString ( ) )  } ) ) ;
         }

3、增加TipDialog类,用作提示语。
4、修改Main类,增加字段

public  static MainDialog mainDialog ;

运行结果如下:

代码下载:

Java新浪微博客户端开发第三步( 微盘的

Java新浪微博客户端开发第三步( CSDN的)

更多内容请参看:

Java新浪微博客户端开发第一步

Java新浪微博客户端开发第二步

原创作品,转载请注明出处:蜗牛都知道

猜你喜欢

转载自blog.csdn.net/Cannel_2020/article/details/7871456