Î÷ÄϿƼ¼´óѧ±¾¿ÆÉú±ÏÒµÂÛÎÄ
// ×Ô¶¨¼ÓÔظü¶àListView @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { // ÊÇ·ñÊÇÏòϹö¶¯ boolean isPullDown = firstVisibleItem > mFirstVisibleItem; if (mEnableLoad && !mIsLoading && isPullDown) { int lastVisibleItem = firstVisibleItem + visibleItemCount; // ÊÇ·ñ¹ö¶¯µ½ÁË×îºóÒ»Ìõ if (lastVisibleItem >= totalItemCount - 1) { // ¼ÓÔظü¶à onLoad(); } } mFirstVisibleItem = firstVisibleItem; } ²¹³ä˵Ã÷ ÔÚÏßÒôÀÖÐèÒªÁ¬½ÓÍøÂ磬²¥·ÅÔÚÏ߸èÇúʱ»áÔÝÍ£±¾µØ¸èÇúµÄ²¥·Å (3) ÔÚÏßÒôÀÖ½çÃæÉè¼Æ
ͼ5-2ÔÚÏßÒôÀÖ½çÃæÉè¼Æ(1) ͼ5-3ÔÚÏßÒôÀÖ½çÃæÉè¼Æ(2)
33
Î÷ÄϿƼ¼´óѧ±¾¿ÆÉú±ÏÒµÂÛÎÄ
5.2.3 ÔÚÏßËÑË÷ÏêϸÉè¼Æ
Æô¶¯Ó¦Ó㬵ã»÷ËÑË÷°´Å¥£¬½øÈëËÑË÷½çÃ棬ÊäÈë¸èÇúÏà¹ØÐÅÏ¢£¬Èç¸èÊÖÃû£¬¸èÇúÃûµÈ£¬µã»÷ËÑË÷£¬¿ÉÒÔËÑË÷Ïà¹Ø¸èÇú£¬ËÑË÷½á¹ûÒÔÁбíÐÎʽչʾ£¬µã»÷¿ÉÒÔ²¥·Å£¬µã»÷ÁбíÓÒ²à¿ÉÒÔ·ÖÏí£¬ÏÂÔصȡ£
(1) ÔÚÏßËÑË÷Ïà¹ØÀàÏêϸ˵Ã÷
±í5-5 ÔÚÏßËÑË÷Ïà¹ØÀàÏêϸ˵Ã÷
ÀàÃû SearchMusicActivity ¸¸Àà BaseActivity ½Ó¿Ú OnQueryTextListener OnItemClickListener OnMoreClickListener SearchMusicAdapter SearchView BaseAdapter LinearLayoutCompat CollapsibleActionView ËÑË÷½á¹û¸èÇúÁбíÊÊÅäÆ÷ ËÑË÷ÊÓͼ º¬Òå ÔÚÏßËÑË÷½çÃæ (2) ÔÚÏßËÑË÷Éè¼ÆÓëʵÏÖ
±í5-6 ÔÚÏßËÑË÷Éè¼ÆÓëʵÏÖ
¹¦ÄÜÃèÊö ½Ó¿ÚÓëÊôÐÔ ºËÐÄ´úÂë ¸ù¾Ý¸èÇúÐÅÏ¢£¬Èç¸èÊÖÃû£¬¸èÇúÃûµÈ¼ìË÷Ïà¹Ø¸èÇú Æô¶¯Ó¦Ó㬵ã»÷ËÑË÷°´Å¥ // SearchViewµÄ³õʼ»¯ // »ñµÃSearchView¶ÔÏó SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView(); searchView.onActionViewExpanded(); // ÉèÖÃËÑË÷¿òhintÄÚÈÝ searchView.setQueryHint(getString(R.string.search_tips)); // ÉèÖüàÌýÆ÷ searchView.setOnQueryTextListener(this); searchView.setSubmitButtonEnabled(true); ImageView // Ìæ»»ËÑË÷°´Å¥Í¼±ê mGoButton.setImageResource(R.drawable.ic_menu_search); // ÔÚÏßËÑË÷ÇëÇó OkHttpUtils.get().url(Constants.BASE_URL) .addParams(Constants.PARAM_METHOD, Constants.METHOD_SEARCH_MUSIC) .addParams(Constants.PARAM_QUERY, keyword) mGoButton = (ImageView) searchView.findViewById(R.id.search_go_btn); 34
Î÷ÄϿƼ¼´óѧ±¾¿ÆÉú±ÏÒµÂÛÎÄ
.build() .execute(new JsonCallback
ͼ5-4 ÔÚÏßËÑË÷½çÃæÉè¼Æ
5.2.4 ²¥·Å¿ØÖÆÏêϸÉè¼Æ
Æô¶¯Ó¦Ó㬵ײ¿²¥·Å¿ØÖÆÌõÖ§³Ö²¥·Å/ÔÝÍ£ºÍÏÂÒ»Çú¿ì½Ý²Ù×÷£¬µã»÷²¥·Å¿ì½Ý¿ØÖÆÌõ£¬½øÈë²¥·Å¿ØÖƽçÃ棬¿ÉÒԲ鿴ר¼·âÃ棬¸è´Ê£¬µ÷½Ú²¥·Å½ø¶È£¬Çл»²¥·Åģʽ£¬µ÷½ÚÒôÁ¿µÈ¡£
35
Î÷ÄϿƼ¼´óѧ±¾¿ÆÉú±ÏÒµÂÛÎÄ
(1) ²¥·Å¿ØÖÆÏà¹ØÀàÏêϸ˵Ã÷
±í5-7 ²¥·Å¿ØÖÆÏà¹ØÀàÏêϸ˵Ã÷
ÀàÃû PlayFragment ¸¸Àà BaseFragment ½Ó¿Ú OnClickListener OnPageChangeListener OnPageChangeListener AlbumCoverView LrcView IndicatorLayout View View LinearLayout AnimatorUpdateListener ר¼·âÃæ×Ô¶¨ÒåÊÓͼ ¸è´Ê×Ô¶¨ÒåÊÓͼ ViewPager Indicator×Ô¶¨ÒåÊÓͼ º¬Òå ²¥·Å¿ØÖƽçÃæ (2) ²¥·Å¿ØÖÆÉè¼ÆÓëʵÏÖ
±í5-8 ²¥·Å¿ØÖÆÉè¼ÆÓëʵÏÖ
¹¦ÄÜÃèÊö ½Ó¿ÚÓëÊôÐÔ ºËÐÄ´úÂë ¶Ôµ±Ç°²¥·ÅµÄ¸èÇú½øÐÐÏêϸ¿ØÖÆ£¬ÏÔʾר¼ÁбíºÍ¸è´Ê Æô¶¯Ó¦Ó㬵ã»÷µ×²¿¿ì½Ý²¥·Å¿ØÖÆÌõ ר¼·âÃæ¿Ø¼þ: // ÉèÖÃÐýת½Ç¶ÈºÍÔ²ÐÄ mDiscMatrix.setRotate(mDiscRotation, mDiscPX, mDiscPY); mCoverMatrix.setRotate(mDiscRotation, mCoverPX, mCoverPY); mNeedleMatrix.setRotate(mNeedleRotation, mNeedlePX, mNeedlePY); // ÉèÖÃÐýת°ë¾¶¶Ëµã×ø±ê mDiscMatrix.preTranslate(mDiscDX, mDiscDY); mCoverMatrix.preTranslate(mCoverDX, mCoverDY); mNeedleMatrix.preTranslate(mNeedleDX, mNeedleDY); mTopLine.setBounds(0, getTop(), getWidth(), getTop() + mTopLineHeight); // »æÖÆ mTopLine.draw(canvas); mCoverBorder.draw(canvas); canvas.drawBitmap(mCoverBitmap, mCoverMatrix, null); canvas.drawBitmap(mDiscBitmap, mDiscMatrix, null); canvas.drawBitmap(mNeedleBitmap, mNeedleMatrix, null); ¸è´Ê¿Ø¼þ: // ÖÐÐÄY×ø±ê float centerY = getHeight() / 2 + mTextSize / 2 + mAnimOffset; // »µ±Ç°ÐÐ String currStr = mLrcTexts.get(mCurrentLine); float currX = (getWidth() - mCurrentPaint.measureText(currStr)) / 2; canvas.drawText(currStr, currX, centerY, mCurrentPaint); // »µ±Ç°ÐÐÉÏÃæµÄ for (int i = mCurrentLine - 1; i >= 0; i--) { 36