├── NiceApp ├── .gitignore ├── app │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ │ ├── androidTest │ │ └── java │ │ │ └── com │ │ │ └── hrm │ │ │ └── niceapp │ │ │ └── ApplicationTest.java │ │ └── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ └── com │ │ │ ├── handmark │ │ │ └── pulltorefresh │ │ │ │ ├── extras │ │ │ │ ├── listfragment │ │ │ │ │ ├── PullToRefreshBaseListFragment.java │ │ │ │ │ ├── PullToRefreshExpandableListFragment.java │ │ │ │ │ └── PullToRefreshListFragment.java │ │ │ │ └── viewpager │ │ │ │ │ └── PullToRefreshViewPager.java │ │ │ │ └── library │ │ │ │ ├── ILoadingLayout.java │ │ │ │ ├── IPullToRefresh.java │ │ │ │ ├── LoadingLayoutProxy.java │ │ │ │ ├── OverscrollHelper.java │ │ │ │ ├── PullToRefreshAdapterViewBase.java │ │ │ │ ├── PullToRefreshBase.java │ │ │ │ ├── PullToRefreshExpandableListView.java │ │ │ │ ├── PullToRefreshGridView.java │ │ │ │ ├── PullToRefreshHorizontalScrollView.java │ │ │ │ ├── PullToRefreshListView.java │ │ │ │ ├── PullToRefreshScrollView.java │ │ │ │ ├── PullToRefreshWebView.java │ │ │ │ ├── extras │ │ │ │ ├── PullToRefreshWebView2.java │ │ │ │ └── SoundPullEventListener.java │ │ │ │ └── internal │ │ │ │ ├── EmptyViewMethodAccessor.java │ │ │ │ ├── FlipLoadingLayout.java │ │ │ │ ├── IndicatorLayout.java │ │ │ │ ├── LoadingLayout.java │ │ │ │ ├── RotateLoadingLayout.java │ │ │ │ ├── Utils.java │ │ │ │ └── ViewCompat.java │ │ │ └── shine │ │ │ └── niceapp │ │ │ ├── bean │ │ │ └── Card.java │ │ │ ├── control │ │ │ ├── IRhythmItemListener.java │ │ │ ├── RhythmAdapter.java │ │ │ ├── RhythmLayout.java │ │ │ └── ViewPagerScroller.java │ │ │ ├── ui │ │ │ ├── activity │ │ │ │ └── MainActivity.java │ │ │ ├── adapter │ │ │ │ └── CardPagerAdapter.java │ │ │ ├── fragment │ │ │ │ ├── AbsBaseFragment.java │ │ │ │ ├── CardFragment.java │ │ │ │ └── CardViewPagerFragment.java │ │ │ └── widget │ │ │ │ ├── HtmlTextView.java │ │ │ │ ├── ProgressHUD.java │ │ │ │ ├── RoundedDrawable.java │ │ │ │ └── RoundedImageView.java │ │ │ └── utils │ │ │ ├── AnimatorUtils.java │ │ │ ├── AppUtils.java │ │ │ ├── HexUtils.java │ │ │ ├── LogUtil.java │ │ │ ├── NetWorkHelper.java │ │ │ └── PreferenceUtils.java │ │ └── res │ │ ├── anim │ │ ├── slide_in_from_bottom.xml │ │ ├── slide_in_from_top.xml │ │ ├── slide_out_to_bottom.xml │ │ ├── slide_out_to_top.xml │ │ └── spinner.xml │ │ ├── drawable-hdpi │ │ └── ic_launcher.png │ │ ├── drawable-mdpi │ │ └── ic_launcher.png │ │ ├── drawable-xhdpi │ │ ├── backtohome_normal.png │ │ ├── backtohome_pressed.png │ │ ├── card_cover1.png │ │ ├── card_cover2.png │ │ ├── card_cover3.png │ │ ├── card_cover4.png │ │ ├── card_cover5.png │ │ ├── card_cover6.png │ │ ├── card_cover7.png │ │ ├── card_cover8.png │ │ ├── card_flower.png │ │ ├── card_flower_bg.9.png │ │ ├── card_icon1.png │ │ ├── card_icon2.png │ │ ├── card_icon3.png │ │ ├── card_icon4.png │ │ ├── card_icon5.png │ │ ├── card_icon6.png │ │ ├── card_icon7.png │ │ ├── card_icon8.png │ │ ├── common_logo_normal.png │ │ ├── common_logo_pressed.png │ │ ├── default_ptr_flip.png │ │ ├── default_ptr_rotate.png │ │ ├── home_card_bg.9.png │ │ ├── home_icon_bg.9.png │ │ ├── ic_launcher.png │ │ ├── indicator_arrow.png │ │ ├── shadow_bottom.png │ │ ├── shadow_left.png │ │ ├── shadow_right.png │ │ └── subject_bg.9.png │ │ ├── drawable-xxhdpi │ │ ├── ic_launcher.png │ │ ├── loading_1.png │ │ ├── loading_2.png │ │ ├── loading_3.png │ │ ├── loading_4.png │ │ ├── loading_5.png │ │ ├── loading_6.png │ │ ├── loading_7.png │ │ └── loading_8.png │ │ ├── drawable │ │ ├── btn_common_logo.xml │ │ ├── btn_rocket_to_first.xml │ │ ├── indicator_bg_bottom.xml │ │ └── indicator_bg_top.xml │ │ ├── layout │ │ ├── activity_main.xml │ │ ├── adapter_rhythm_icon.xml │ │ ├── fragment_card.xml │ │ ├── fragment_niceapp.xml │ │ ├── progress_hud.xml │ │ ├── pull_to_refresh_header_horizontal.xml │ │ ├── pull_to_refresh_header_vertical.xml │ │ ├── slidingmenumain.xml │ │ └── swipeback_layout.xml │ │ ├── menu │ │ └── menu_main.xml │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── attrs.xml │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── ids.xml │ │ ├── strings.xml │ │ └── styles.xml ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle └── README.md /NiceApp/.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | /local.properties 3 | /.idea/workspace.xml 4 | /.idea/libraries 5 | .DS_Store 6 | /build 7 | -------------------------------------------------------------------------------- /NiceApp/app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /NiceApp/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 21 5 | buildToolsVersion "21.1.0" 6 | 7 | defaultConfig { 8 | applicationId "com.shine.niceapp" 9 | minSdkVersion 14 10 | targetSdkVersion 21 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(dir: 'libs', include: ['*.jar']) 24 | compile 'com.android.support:appcompat-v7:21.0.2' 25 | } 26 | -------------------------------------------------------------------------------- /NiceApp/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/huangruimin/Development/android-sdk-macosx/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /NiceApp/app/src/androidTest/java/com/hrm/niceapp/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.hrm.niceapp; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /NiceApp/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 15 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /NiceApp/app/src/main/java/com/handmark/pulltorefresh/extras/listfragment/PullToRefreshBaseListFragment.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2011, 2012 Chris Banes. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *******************************************************************************/ 16 | package com.handmark.pulltorefresh.extras.listfragment; 17 | 18 | import android.os.Bundle; 19 | import android.support.v4.app.ListFragment; 20 | import android.view.LayoutInflater; 21 | import android.view.View; 22 | import android.view.ViewGroup; 23 | import android.widget.AbsListView; 24 | import android.widget.ListView; 25 | 26 | import com.handmark.pulltorefresh.library.PullToRefreshBase; 27 | 28 | 29 | abstract class PullToRefreshBaseListFragment> extends ListFragment { 30 | 31 | private T mPullToRefreshListView; 32 | 33 | @Override 34 | public final View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 35 | View layout = super.onCreateView(inflater, container, savedInstanceState); 36 | 37 | ListView lv = (ListView) layout.findViewById(android.R.id.list); 38 | ViewGroup parent = (ViewGroup) lv.getParent(); 39 | 40 | // Remove ListView and add PullToRefreshListView in its place 41 | int lvIndex = parent.indexOfChild(lv); 42 | parent.removeViewAt(lvIndex); 43 | mPullToRefreshListView = onCreatePullToRefreshListView(inflater, savedInstanceState); 44 | parent.addView(mPullToRefreshListView, lvIndex, lv.getLayoutParams()); 45 | 46 | return layout; 47 | } 48 | 49 | /** 50 | * @return The {@link PullToRefreshBase} attached to this ListFragment. 51 | */ 52 | public final T getPullToRefreshListView() { 53 | return mPullToRefreshListView; 54 | } 55 | 56 | /** 57 | * Returns the {@link PullToRefreshBase} which will replace the ListView 58 | * created from ListFragment. You should override this method if you wish to 59 | * customise the {@link PullToRefreshBase} from the default. 60 | * 61 | * @param inflater - LayoutInflater which can be used to inflate from XML. 62 | * @param savedInstanceState - Bundle passed through from 63 | * {@link ListFragment#onCreateView(LayoutInflater, ViewGroup, Bundle) 64 | * onCreateView(...)} 65 | * @return The {@link PullToRefreshBase} which will replace the ListView. 66 | */ 67 | protected abstract T onCreatePullToRefreshListView(LayoutInflater inflater, Bundle savedInstanceState); 68 | 69 | } -------------------------------------------------------------------------------- /NiceApp/app/src/main/java/com/handmark/pulltorefresh/extras/listfragment/PullToRefreshExpandableListFragment.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2011, 2012 Chris Banes. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *******************************************************************************/ 16 | package com.handmark.pulltorefresh.extras.listfragment; 17 | 18 | import android.os.Bundle; 19 | import android.view.LayoutInflater; 20 | 21 | import com.handmark.pulltorefresh.library.PullToRefreshExpandableListView; 22 | 23 | 24 | /** 25 | * A sample implementation of how to use {@link PullToRefreshExpandableListView} 26 | * with {@link android.support.v4.app.ListFragment}. This implementation simply replaces the ListView 27 | * that {@code ListFragment} creates with a new 28 | * {@code PullToRefreshExpandableListView}. This means that ListFragment still 29 | * works 100% (e.g. setListShown(...) ). 30 | *

31 | * The new PullToRefreshListView is created in the method 32 | * {@link #onCreatePullToRefreshListView(LayoutInflater, Bundle)}. If you wish 33 | * to customise the {@code PullToRefreshExpandableListView} then override this 34 | * method and return your customised instance. 35 | * 36 | * @author Chris Banes 37 | * 38 | */ 39 | public class PullToRefreshExpandableListFragment extends PullToRefreshBaseListFragment { 40 | 41 | protected PullToRefreshExpandableListView onCreatePullToRefreshListView(LayoutInflater inflater, 42 | Bundle savedInstanceState) { 43 | return new PullToRefreshExpandableListView(getActivity()); 44 | } 45 | 46 | } -------------------------------------------------------------------------------- /NiceApp/app/src/main/java/com/handmark/pulltorefresh/extras/listfragment/PullToRefreshListFragment.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2011, 2012 Chris Banes. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *******************************************************************************/ 16 | package com.handmark.pulltorefresh.extras.listfragment; 17 | 18 | import android.os.Bundle; 19 | import android.view.LayoutInflater; 20 | 21 | import com.handmark.pulltorefresh.library.PullToRefreshListView; 22 | 23 | 24 | /** 25 | * A sample implementation of how to use {@link PullToRefreshListView} with 26 | * {@link android.support.v4.app.ListFragment}. This implementation simply replaces the ListView that 27 | * {@code ListFragment} creates with a new PullToRefreshListView. This means 28 | * that ListFragment still works 100% (e.g. setListShown(...) ). 29 | *

30 | * The new PullToRefreshListView is created in the method 31 | * {@link #onCreatePullToRefreshListView(LayoutInflater, Bundle)}. If you wish 32 | * to customise the {@code PullToRefreshListView} then override this method and 33 | * return your customised instance. 34 | * 35 | * @author Chris Banes 36 | * 37 | */ 38 | public class PullToRefreshListFragment extends PullToRefreshBaseListFragment { 39 | 40 | protected PullToRefreshListView onCreatePullToRefreshListView(LayoutInflater inflater, Bundle savedInstanceState) { 41 | return new PullToRefreshListView(getActivity()); 42 | } 43 | 44 | } -------------------------------------------------------------------------------- /NiceApp/app/src/main/java/com/handmark/pulltorefresh/extras/viewpager/PullToRefreshViewPager.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2011, 2012 Chris Banes. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *******************************************************************************/ 16 | package com.handmark.pulltorefresh.extras.viewpager; 17 | 18 | import android.content.Context; 19 | import android.support.v4.view.PagerAdapter; 20 | import android.support.v4.view.ViewPager; 21 | import android.util.AttributeSet; 22 | 23 | import com.handmark.pulltorefresh.library.PullToRefreshBase; 24 | import com.shine.niceapp.R; 25 | 26 | public class PullToRefreshViewPager extends PullToRefreshBase { 27 | 28 | public PullToRefreshViewPager(Context context) { 29 | super(context); 30 | } 31 | 32 | public PullToRefreshViewPager(Context context, AttributeSet attrs) { 33 | super(context, attrs); 34 | } 35 | 36 | @Override 37 | public final Orientation getPullToRefreshScrollDirection() { 38 | return Orientation.HORIZONTAL; 39 | } 40 | 41 | @Override 42 | protected ViewPager createRefreshableView(Context context, AttributeSet attrs) { 43 | ViewPager viewPager = new ViewPager(context, attrs); 44 | viewPager.setId(R.id.viewpager); 45 | return viewPager; 46 | } 47 | 48 | @Override 49 | protected boolean isReadyForPullStart() { 50 | ViewPager refreshableView = getRefreshableView(); 51 | 52 | PagerAdapter adapter = refreshableView.getAdapter(); 53 | if (null != adapter) { 54 | return refreshableView.getCurrentItem() == 0; 55 | } 56 | 57 | return false; 58 | } 59 | 60 | @Override 61 | protected boolean isReadyForPullEnd() { 62 | ViewPager refreshableView = getRefreshableView(); 63 | 64 | PagerAdapter adapter = refreshableView.getAdapter(); 65 | if (null != adapter) { 66 | return refreshableView.getCurrentItem() == adapter.getCount() - 1; 67 | } 68 | 69 | return false; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /NiceApp/app/src/main/java/com/handmark/pulltorefresh/library/ILoadingLayout.java: -------------------------------------------------------------------------------- 1 | package com.handmark.pulltorefresh.library; 2 | 3 | import android.graphics.Typeface; 4 | import android.graphics.drawable.Drawable; 5 | 6 | public interface ILoadingLayout { 7 | 8 | /** 9 | * Set the Last Updated Text. This displayed under the main label when 10 | * Pulling 11 | * 12 | * @param label - Label to set 13 | */ 14 | public void setLastUpdatedLabel(CharSequence label); 15 | 16 | /** 17 | * Set the drawable used in the loading layout. This is the same as calling 18 | * setLoadingDrawable(drawable, Mode.BOTH) 19 | * 20 | * @param drawable - Drawable to display 21 | */ 22 | public void setLoadingDrawable(Drawable drawable); 23 | 24 | /** 25 | * Set Text to show when the Widget is being Pulled 26 | * setPullLabel(releaseLabel, Mode.BOTH) 27 | * 28 | * @param pullLabel - CharSequence to display 29 | */ 30 | public void setPullLabel(CharSequence pullLabel); 31 | 32 | /** 33 | * Set Text to show when the Widget is refreshing 34 | * setRefreshingLabel(releaseLabel, Mode.BOTH) 35 | * 36 | * @param refreshingLabel - CharSequence to display 37 | */ 38 | public void setRefreshingLabel(CharSequence refreshingLabel); 39 | 40 | /** 41 | * Set Text to show when the Widget is being pulled, and will refresh when 42 | * released. This is the same as calling 43 | * setReleaseLabel(releaseLabel, Mode.BOTH) 44 | * 45 | * @param releaseLabel - CharSequence to display 46 | */ 47 | public void setReleaseLabel(CharSequence releaseLabel); 48 | 49 | /** 50 | * Set's the Sets the typeface and style in which the text should be 51 | * displayed. Please see 52 | * {@link android.widget.TextView#setTypeface(Typeface) 53 | * TextView#setTypeface(Typeface)}. 54 | */ 55 | public void setTextTypeface(Typeface tf); 56 | 57 | } 58 | -------------------------------------------------------------------------------- /NiceApp/app/src/main/java/com/handmark/pulltorefresh/library/IPullToRefresh.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2011, 2012 Chris Banes. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *******************************************************************************/ 16 | package com.handmark.pulltorefresh.library; 17 | 18 | import android.view.View; 19 | import android.view.animation.Interpolator; 20 | 21 | 22 | 23 | public interface IPullToRefresh { 24 | 25 | /** 26 | * Demos the Pull-to-Refresh functionality to the user so that they are 27 | * aware it is there. This could be useful when the user first opens your 28 | * app, etc. The animation will only happen if the Refresh View (ListView, 29 | * ScrollView, etc) is in a state where a Pull-to-Refresh could occur by a 30 | * user's touch gesture (i.e. scrolled to the top/bottom). 31 | * 32 | * @return true - if the Demo has been started, false if not. 33 | */ 34 | public boolean demo(); 35 | 36 | /** 37 | * Get the mode that this view is currently in. This is only really useful 38 | * when using Mode.BOTH. 39 | * 40 | * @return Mode that the view is currently in 41 | */ 42 | public PullToRefreshBase.Mode getCurrentMode(); 43 | 44 | /** 45 | * Returns whether the Touch Events are filtered or not. If true is 46 | * returned, then the View will only use touch events where the difference 47 | * in the Y-axis is greater than the difference in the X-axis. This means 48 | * that the View will not interfere when it is used in a horizontal 49 | * scrolling View (such as a ViewPager). 50 | * 51 | * @return boolean - true if the View is filtering Touch Events 52 | */ 53 | public boolean getFilterTouchEvents(); 54 | 55 | /** 56 | * Returns a proxy object which allows you to call methods on all of the 57 | * LoadingLayouts (the Views which show when Pulling/Refreshing). 58 | *

59 | * You should not keep the result of this method any longer than you need 60 | * it. 61 | * 62 | * @return Object which will proxy any calls you make on it, to all of the 63 | * LoadingLayouts. 64 | */ 65 | public ILoadingLayout getLoadingLayoutProxy(); 66 | 67 | /** 68 | * Returns a proxy object which allows you to call methods on the 69 | * LoadingLayouts (the Views which show when Pulling/Refreshing). The actual 70 | * LoadingLayout(s) which will be affected, are chosen by the parameters you 71 | * give. 72 | *

73 | * You should not keep the result of this method any longer than you need 74 | * it. 75 | * 76 | * @param includeStart - Whether to include the Start/Header Views 77 | * @param includeEnd - Whether to include the End/Footer Views 78 | * @return Object which will proxy any calls you make on it, to the 79 | * LoadingLayouts included. 80 | */ 81 | public ILoadingLayout getLoadingLayoutProxy(boolean includeStart, boolean includeEnd); 82 | 83 | /** 84 | * Get the mode that this view has been set to. If this returns 85 | * Mode.BOTH, you can use getCurrentMode() to 86 | * check which mode the view is currently in 87 | * 88 | * @return Mode that the view has been set to 89 | */ 90 | public PullToRefreshBase.Mode getMode(); 91 | 92 | /** 93 | * Get the Wrapped Refreshable View. Anything returned here has already been 94 | * added to the content view. 95 | * 96 | * @return The View which is currently wrapped 97 | */ 98 | public T getRefreshableView(); 99 | 100 | /** 101 | * Get whether the 'Refreshing' View should be automatically shown when 102 | * refreshing. Returns true by default. 103 | * 104 | * @return - true if the Refreshing View will be show 105 | */ 106 | public boolean getShowViewWhileRefreshing(); 107 | 108 | /** 109 | * @return - The state that the View is currently in. 110 | */ 111 | public PullToRefreshBase.State getState(); 112 | 113 | /** 114 | * Whether Pull-to-Refresh is enabled 115 | * 116 | * @return enabled 117 | */ 118 | public boolean isPullToRefreshEnabled(); 119 | 120 | /** 121 | * Gets whether Overscroll support is enabled. This is different to 122 | * Android's standard Overscroll support (the edge-glow) which is available 123 | * from GINGERBREAD onwards 124 | * 125 | * @return true - if both PullToRefresh-OverScroll and Android's inbuilt 126 | * OverScroll are enabled 127 | */ 128 | public boolean isPullToRefreshOverScrollEnabled(); 129 | 130 | /** 131 | * Returns whether the Widget is currently in the Refreshing mState 132 | * 133 | * @return true if the Widget is currently refreshing 134 | */ 135 | public boolean isRefreshing(); 136 | 137 | /** 138 | * Returns whether the widget has enabled scrolling on the Refreshable View 139 | * while refreshing. 140 | * 141 | * @return true if the widget has enabled scrolling while refreshing 142 | */ 143 | public boolean isScrollingWhileRefreshingEnabled(); 144 | 145 | /** 146 | * Mark the current Refresh as complete. Will Reset the UI and hide the 147 | * Refreshing View 148 | */ 149 | public void onRefreshComplete(); 150 | 151 | /** 152 | * Set the Touch Events to be filtered or not. If set to true, then the View 153 | * will only use touch events where the difference in the Y-axis is greater 154 | * than the difference in the X-axis. This means that the View will not 155 | * interfere when it is used in a horizontal scrolling View (such as a 156 | * ViewPager), but will restrict which types of finger scrolls will trigger 157 | * the View. 158 | * 159 | * @param filterEvents - true if you want to filter Touch Events. Default is 160 | * true. 161 | */ 162 | public void setFilterTouchEvents(boolean filterEvents); 163 | 164 | /** 165 | * Set the mode of Pull-to-Refresh that this view will use. 166 | * 167 | * @param mode - Mode to set the View to 168 | */ 169 | public void setMode(PullToRefreshBase.Mode mode); 170 | 171 | /** 172 | * Set OnPullEventListener for the Widget 173 | * 174 | * @param listener - Listener to be used when the Widget has a pull event to 175 | * propogate. 176 | */ 177 | public void setOnPullEventListener(PullToRefreshBase.OnPullEventListener listener); 178 | 179 | /** 180 | * Set OnRefreshListener for the Widget 181 | * 182 | * @param listener - Listener to be used when the Widget is set to Refresh 183 | */ 184 | public void setOnRefreshListener(PullToRefreshBase.OnRefreshListener listener); 185 | 186 | /** 187 | * Set OnRefreshListener for the Widget 188 | * 189 | * @param listener - Listener to be used when the Widget is set to Refresh 190 | */ 191 | public void setOnRefreshListener(PullToRefreshBase.OnRefreshListener2 listener); 192 | 193 | /** 194 | * Sets whether Overscroll support is enabled. This is different to 195 | * Android's standard Overscroll support (the edge-glow). This setting only 196 | * takes effect when running on device with Android v2.3 or greater. 197 | * 198 | * @param enabled - true if you want Overscroll enabled 199 | */ 200 | public void setPullToRefreshOverScrollEnabled(boolean enabled); 201 | 202 | /** 203 | * Sets the Widget to be in the refresh state. The UI will be updated to 204 | * show the 'Refreshing' view, and be scrolled to show such. 205 | */ 206 | public void setRefreshing(); 207 | 208 | /** 209 | * Sets the Widget to be in the refresh state. The UI will be updated to 210 | * show the 'Refreshing' view. 211 | * 212 | * @param doScroll - true if you want to force a scroll to the Refreshing 213 | * view. 214 | */ 215 | public void setRefreshing(boolean doScroll); 216 | 217 | /** 218 | * Sets the Animation Interpolator that is used for animated scrolling. 219 | * Defaults to a DecelerateInterpolator 220 | * 221 | * @param interpolator - Interpolator to use 222 | */ 223 | public void setScrollAnimationInterpolator(Interpolator interpolator); 224 | 225 | /** 226 | * By default the Widget disables scrolling on the Refreshable View while 227 | * refreshing. This method can change this behaviour. 228 | * 229 | * @param scrollingWhileRefreshingEnabled - true if you want to enable 230 | * scrolling while refreshing 231 | */ 232 | public void setScrollingWhileRefreshingEnabled(boolean scrollingWhileRefreshingEnabled); 233 | 234 | /** 235 | * A mutator to enable/disable whether the 'Refreshing' View should be 236 | * automatically shown when refreshing. 237 | * 238 | * @param showView 239 | */ 240 | public void setShowViewWhileRefreshing(boolean showView); 241 | 242 | } -------------------------------------------------------------------------------- /NiceApp/app/src/main/java/com/handmark/pulltorefresh/library/LoadingLayoutProxy.java: -------------------------------------------------------------------------------- 1 | package com.handmark.pulltorefresh.library; 2 | 3 | 4 | import android.graphics.Typeface; 5 | import android.graphics.drawable.Drawable; 6 | 7 | import java.util.HashSet; 8 | 9 | 10 | public class LoadingLayoutProxy implements com.handmark.pulltorefresh.library.ILoadingLayout { 11 | 12 | private final HashSet mLoadingLayouts; 13 | 14 | LoadingLayoutProxy() { 15 | mLoadingLayouts = new HashSet(); 16 | } 17 | 18 | /** 19 | * This allows you to add extra LoadingLayout instances to this proxy. This 20 | * is only necessary if you keep your own instances, and want to have them 21 | * included in any 22 | * {@link com.handmark.pulltorefresh.library.PullToRefreshBase#createLoadingLayoutProxy(boolean, boolean) 23 | * createLoadingLayoutProxy(...)} calls. 24 | * 25 | * @param layout - LoadingLayout to have included. 26 | */ 27 | public void addLayout(com.handmark.pulltorefresh.library.internal.LoadingLayout layout) { 28 | if (null != layout) { 29 | mLoadingLayouts.add(layout); 30 | } 31 | } 32 | 33 | @Override 34 | public void setLastUpdatedLabel(CharSequence label) { 35 | for (com.handmark.pulltorefresh.library.internal.LoadingLayout layout : mLoadingLayouts) { 36 | layout.setLastUpdatedLabel(label); 37 | } 38 | } 39 | 40 | @Override 41 | public void setLoadingDrawable(Drawable drawable) { 42 | for (com.handmark.pulltorefresh.library.internal.LoadingLayout layout : mLoadingLayouts) { 43 | layout.setLoadingDrawable(drawable); 44 | } 45 | } 46 | 47 | @Override 48 | public void setRefreshingLabel(CharSequence refreshingLabel) { 49 | for (com.handmark.pulltorefresh.library.internal.LoadingLayout layout : mLoadingLayouts) { 50 | layout.setRefreshingLabel(refreshingLabel); 51 | } 52 | } 53 | 54 | @Override 55 | public void setPullLabel(CharSequence label) { 56 | for (com.handmark.pulltorefresh.library.internal.LoadingLayout layout : mLoadingLayouts) { 57 | layout.setPullLabel(label); 58 | } 59 | } 60 | 61 | @Override 62 | public void setReleaseLabel(CharSequence label) { 63 | for (com.handmark.pulltorefresh.library.internal.LoadingLayout layout : mLoadingLayouts) { 64 | layout.setReleaseLabel(label); 65 | } 66 | } 67 | 68 | public void setTextTypeface(Typeface tf) { 69 | for (com.handmark.pulltorefresh.library.internal.LoadingLayout layout : mLoadingLayouts) { 70 | layout.setTextTypeface(tf); 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /NiceApp/app/src/main/java/com/handmark/pulltorefresh/library/OverscrollHelper.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2011, 2012 Chris Banes. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *******************************************************************************/ 16 | package com.handmark.pulltorefresh.library; 17 | 18 | import android.annotation.TargetApi; 19 | import android.util.Log; 20 | import android.view.View; 21 | 22 | 23 | @TargetApi(9) 24 | public final class OverscrollHelper { 25 | 26 | static final String LOG_TAG = "OverscrollHelper"; 27 | static final float DEFAULT_OVERSCROLL_SCALE = 1f; 28 | 29 | /** 30 | * Helper method for Overscrolling that encapsulates all of the necessary 31 | * function. 32 | *

33 | * This should only be used on AdapterView's such as ListView as it just 34 | * calls through to overScrollBy() with the scrollRange = 0. AdapterView's 35 | * do not have a scroll range (i.e. getScrollY() doesn't work). 36 | * 37 | * @param view - PullToRefreshView that is calling this. 38 | * @param deltaX - Change in X in pixels, passed through from from 39 | * overScrollBy call 40 | * @param scrollX - Current X scroll value in pixels before applying deltaY, 41 | * passed through from from overScrollBy call 42 | * @param deltaY - Change in Y in pixels, passed through from from 43 | * overScrollBy call 44 | * @param scrollY - Current Y scroll value in pixels before applying deltaY, 45 | * passed through from from overScrollBy call 46 | * @param isTouchEvent - true if this scroll operation is the result of a 47 | * touch event, passed through from from overScrollBy call 48 | */ 49 | public static void overScrollBy(final com.handmark.pulltorefresh.library.PullToRefreshBase view, final int deltaX, final int scrollX, 50 | final int deltaY, final int scrollY, final boolean isTouchEvent) { 51 | overScrollBy(view, deltaX, scrollX, deltaY, scrollY, 0, isTouchEvent); 52 | } 53 | 54 | /** 55 | * Helper method for Overscrolling that encapsulates all of the necessary 56 | * function. This version of the call is used for Views that need to specify 57 | * a Scroll Range but scroll back to it's edge correctly. 58 | * 59 | * @param view - PullToRefreshView that is calling this. 60 | * @param deltaX - Change in X in pixels, passed through from from 61 | * overScrollBy call 62 | * @param scrollX - Current X scroll value in pixels before applying deltaY, 63 | * passed through from from overScrollBy call 64 | * @param deltaY - Change in Y in pixels, passed through from from 65 | * overScrollBy call 66 | * @param scrollY - Current Y scroll value in pixels before applying deltaY, 67 | * passed through from from overScrollBy call 68 | * @param scrollRange - Scroll Range of the View, specifically needed for 69 | * ScrollView 70 | * @param isTouchEvent - true if this scroll operation is the result of a 71 | * touch event, passed through from from overScrollBy call 72 | */ 73 | public static void overScrollBy(final com.handmark.pulltorefresh.library.PullToRefreshBase view, final int deltaX, final int scrollX, 74 | final int deltaY, final int scrollY, final int scrollRange, final boolean isTouchEvent) { 75 | overScrollBy(view, deltaX, scrollX, deltaY, scrollY, scrollRange, 0, DEFAULT_OVERSCROLL_SCALE, isTouchEvent); 76 | } 77 | 78 | /** 79 | * Helper method for Overscrolling that encapsulates all of the necessary 80 | * function. This is the advanced version of the call. 81 | * 82 | * @param view - PullToRefreshView that is calling this. 83 | * @param deltaX - Change in X in pixels, passed through from from 84 | * overScrollBy call 85 | * @param scrollX - Current X scroll value in pixels before applying deltaY, 86 | * passed through from from overScrollBy call 87 | * @param deltaY - Change in Y in pixels, passed through from from 88 | * overScrollBy call 89 | * @param scrollY - Current Y scroll value in pixels before applying deltaY, 90 | * passed through from from overScrollBy call 91 | * @param scrollRange - Scroll Range of the View, specifically needed for 92 | * ScrollView 93 | * @param fuzzyThreshold - Threshold for which the values how fuzzy we 94 | * should treat the other values. Needed for WebView as it 95 | * doesn't always scroll back to it's edge. 0 = no fuzziness. 96 | * @param scaleFactor - Scale Factor for overscroll amount 97 | * @param isTouchEvent - true if this scroll operation is the result of a 98 | * touch event, passed through from from overScrollBy call 99 | */ 100 | public static void overScrollBy(final com.handmark.pulltorefresh.library.PullToRefreshBase view, final int deltaX, final int scrollX, 101 | final int deltaY, final int scrollY, final int scrollRange, final int fuzzyThreshold, 102 | final float scaleFactor, final boolean isTouchEvent) { 103 | 104 | final int deltaValue, currentScrollValue, scrollValue; 105 | switch (view.getPullToRefreshScrollDirection()) { 106 | case HORIZONTAL: 107 | deltaValue = deltaX; 108 | scrollValue = scrollX; 109 | currentScrollValue = view.getScrollX(); 110 | break; 111 | case VERTICAL: 112 | default: 113 | deltaValue = deltaY; 114 | scrollValue = scrollY; 115 | currentScrollValue = view.getScrollY(); 116 | break; 117 | } 118 | 119 | // Check that OverScroll is enabled and that we're not currently 120 | // refreshing. 121 | if (view.isPullToRefreshOverScrollEnabled() && !view.isRefreshing()) { 122 | final PullToRefreshBase.Mode mode = view.getMode(); 123 | 124 | // Check that Pull-to-Refresh is enabled, and the event isn't from 125 | // touch 126 | if (mode.permitsPullToRefresh() && !isTouchEvent && deltaValue != 0) { 127 | final int newScrollValue = (deltaValue + scrollValue); 128 | 129 | if (com.handmark.pulltorefresh.library.PullToRefreshBase.DEBUG) { 130 | Log.d(LOG_TAG, "OverScroll. DeltaX: " + deltaX + ", ScrollX: " + scrollX + ", DeltaY: " + deltaY 131 | + ", ScrollY: " + scrollY + ", NewY: " + newScrollValue + ", ScrollRange: " + scrollRange 132 | + ", CurrentScroll: " + currentScrollValue); 133 | } 134 | 135 | if (newScrollValue < (0 - fuzzyThreshold)) { 136 | // Check the mode supports the overscroll direction, and 137 | // then move scroll 138 | if (mode.showHeaderLoadingLayout()) { 139 | // If we're currently at zero, we're about to start 140 | // overscrolling, so change the state 141 | if (currentScrollValue == 0) { 142 | view.setState(PullToRefreshBase.State.OVERSCROLLING); 143 | } 144 | 145 | view.setHeaderScroll((int) (scaleFactor * (currentScrollValue + newScrollValue))); 146 | } 147 | } else if (newScrollValue > (scrollRange + fuzzyThreshold)) { 148 | // Check the mode supports the overscroll direction, and 149 | // then move scroll 150 | if (mode.showFooterLoadingLayout()) { 151 | // If we're currently at zero, we're about to start 152 | // overscrolling, so change the state 153 | if (currentScrollValue == 0) { 154 | view.setState(PullToRefreshBase.State.OVERSCROLLING); 155 | } 156 | 157 | view.setHeaderScroll((int) (scaleFactor * (currentScrollValue + newScrollValue - scrollRange))); 158 | } 159 | } else if (Math.abs(newScrollValue) <= fuzzyThreshold 160 | || Math.abs(newScrollValue - scrollRange) <= fuzzyThreshold) { 161 | // Means we've stopped overscrolling, so scroll back to 0 162 | view.setState(PullToRefreshBase.State.RESET); 163 | } 164 | } else if (isTouchEvent && PullToRefreshBase.State.OVERSCROLLING == view.getState()) { 165 | // This condition means that we were overscrolling from a fling, 166 | // but the user has touched the View and is now overscrolling 167 | // from touch instead. We need to just reset. 168 | view.setState(PullToRefreshBase.State.RESET); 169 | } 170 | } 171 | } 172 | 173 | static boolean isAndroidOverScrollEnabled(View view) { 174 | return view.getOverScrollMode() != View.OVER_SCROLL_NEVER; 175 | } 176 | } 177 | -------------------------------------------------------------------------------- /NiceApp/app/src/main/java/com/handmark/pulltorefresh/library/PullToRefreshExpandableListView.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2011, 2012 Chris Banes. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *******************************************************************************/ 16 | package com.handmark.pulltorefresh.library; 17 | 18 | import android.annotation.TargetApi; 19 | import android.content.Context; 20 | import android.os.Build.VERSION; 21 | import android.os.Build.VERSION_CODES; 22 | import android.util.AttributeSet; 23 | import android.view.View; 24 | import android.widget.ExpandableListView; 25 | 26 | import com.handmark.pulltorefresh.library.internal.EmptyViewMethodAccessor; 27 | 28 | 29 | public class PullToRefreshExpandableListView extends PullToRefreshAdapterViewBase { 30 | 31 | public PullToRefreshExpandableListView(Context context) { 32 | super(context); 33 | } 34 | 35 | public PullToRefreshExpandableListView(Context context, AttributeSet attrs) { 36 | super(context, attrs); 37 | } 38 | 39 | public PullToRefreshExpandableListView(Context context, Mode mode) { 40 | super(context, mode); 41 | } 42 | 43 | public PullToRefreshExpandableListView(Context context, Mode mode, AnimationStyle style) { 44 | super(context, mode, style); 45 | } 46 | 47 | @Override 48 | public final Orientation getPullToRefreshScrollDirection() { 49 | return Orientation.VERTICAL; 50 | } 51 | 52 | @Override 53 | protected ExpandableListView createRefreshableView(Context context, AttributeSet attrs) { 54 | final ExpandableListView lv; 55 | if (VERSION.SDK_INT >= VERSION_CODES.GINGERBREAD) { 56 | lv = new InternalExpandableListViewSDK9(context, attrs); 57 | } else { 58 | lv = new InternalExpandableListView(context, attrs); 59 | } 60 | 61 | // Set it to this so it can be used in ListActivity/ListFragment 62 | lv.setId(android.R.id.list); 63 | return lv; 64 | } 65 | 66 | class InternalExpandableListView extends ExpandableListView implements EmptyViewMethodAccessor { 67 | 68 | public InternalExpandableListView(Context context, AttributeSet attrs) { 69 | super(context, attrs); 70 | } 71 | 72 | @Override 73 | public void setEmptyView(View emptyView) { 74 | PullToRefreshExpandableListView.this.setEmptyView(emptyView); 75 | } 76 | 77 | @Override 78 | public void setEmptyViewInternal(View emptyView) { 79 | super.setEmptyView(emptyView); 80 | } 81 | } 82 | 83 | @TargetApi(9) 84 | final class InternalExpandableListViewSDK9 extends InternalExpandableListView { 85 | 86 | public InternalExpandableListViewSDK9(Context context, AttributeSet attrs) { 87 | super(context, attrs); 88 | } 89 | 90 | @Override 91 | protected boolean overScrollBy(int deltaX, int deltaY, int scrollX, int scrollY, int scrollRangeX, 92 | int scrollRangeY, int maxOverScrollX, int maxOverScrollY, boolean isTouchEvent) { 93 | 94 | final boolean returnValue = super.overScrollBy(deltaX, deltaY, scrollX, scrollY, scrollRangeX, 95 | scrollRangeY, maxOverScrollX, maxOverScrollY, isTouchEvent); 96 | 97 | // Does all of the hard work... 98 | OverscrollHelper.overScrollBy(PullToRefreshExpandableListView.this, deltaX, scrollX, deltaY, scrollY, 99 | isTouchEvent); 100 | 101 | return returnValue; 102 | } 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /NiceApp/app/src/main/java/com/handmark/pulltorefresh/library/PullToRefreshGridView.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2011, 2012 Chris Banes. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *******************************************************************************/ 16 | package com.handmark.pulltorefresh.library; 17 | 18 | import android.annotation.TargetApi; 19 | import android.content.Context; 20 | import android.os.Build.VERSION; 21 | import android.os.Build.VERSION_CODES; 22 | import android.util.AttributeSet; 23 | import android.view.View; 24 | import android.widget.GridView; 25 | 26 | import com.handmark.pulltorefresh.library.internal.EmptyViewMethodAccessor; 27 | import com.shine.niceapp.R; 28 | 29 | 30 | public class PullToRefreshGridView extends PullToRefreshAdapterViewBase { 31 | 32 | public PullToRefreshGridView(Context context) { 33 | super(context); 34 | } 35 | 36 | public PullToRefreshGridView(Context context, AttributeSet attrs) { 37 | super(context, attrs); 38 | } 39 | 40 | public PullToRefreshGridView(Context context, Mode mode) { 41 | super(context, mode); 42 | } 43 | 44 | public PullToRefreshGridView(Context context, Mode mode, AnimationStyle style) { 45 | super(context, mode, style); 46 | } 47 | 48 | @Override 49 | public final Orientation getPullToRefreshScrollDirection() { 50 | return Orientation.VERTICAL; 51 | } 52 | 53 | @Override 54 | protected final GridView createRefreshableView(Context context, AttributeSet attrs) { 55 | final GridView gv; 56 | if (VERSION.SDK_INT >= VERSION_CODES.GINGERBREAD) { 57 | gv = new InternalGridViewSDK9(context, attrs); 58 | } else { 59 | gv = new InternalGridView(context, attrs); 60 | } 61 | 62 | // Use Generated ID (from res/values/ids.xml) 63 | gv.setId(R.id.gridview); 64 | return gv; 65 | } 66 | 67 | class InternalGridView extends GridView implements EmptyViewMethodAccessor { 68 | 69 | public InternalGridView(Context context, AttributeSet attrs) { 70 | super(context, attrs); 71 | } 72 | 73 | @Override 74 | public void setEmptyView(View emptyView) { 75 | PullToRefreshGridView.this.setEmptyView(emptyView); 76 | } 77 | 78 | @Override 79 | public void setEmptyViewInternal(View emptyView) { 80 | super.setEmptyView(emptyView); 81 | } 82 | } 83 | 84 | @TargetApi(9) 85 | final class InternalGridViewSDK9 extends InternalGridView { 86 | 87 | public InternalGridViewSDK9(Context context, AttributeSet attrs) { 88 | super(context, attrs); 89 | } 90 | 91 | @Override 92 | protected boolean overScrollBy(int deltaX, int deltaY, int scrollX, int scrollY, int scrollRangeX, 93 | int scrollRangeY, int maxOverScrollX, int maxOverScrollY, boolean isTouchEvent) { 94 | 95 | final boolean returnValue = super.overScrollBy(deltaX, deltaY, scrollX, scrollY, scrollRangeX, 96 | scrollRangeY, maxOverScrollX, maxOverScrollY, isTouchEvent); 97 | 98 | // Does all of the hard work... 99 | OverscrollHelper.overScrollBy(PullToRefreshGridView.this, deltaX, scrollX, deltaY, scrollY, isTouchEvent); 100 | 101 | return returnValue; 102 | } 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /NiceApp/app/src/main/java/com/handmark/pulltorefresh/library/PullToRefreshHorizontalScrollView.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2011, 2012 Chris Banes. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *******************************************************************************/ 16 | package com.handmark.pulltorefresh.library; 17 | 18 | import android.annotation.TargetApi; 19 | import android.content.Context; 20 | import android.os.Build.VERSION; 21 | import android.os.Build.VERSION_CODES; 22 | import android.util.AttributeSet; 23 | import android.view.View; 24 | import android.widget.HorizontalScrollView; 25 | 26 | import com.shine.niceapp.R; 27 | 28 | 29 | public class PullToRefreshHorizontalScrollView extends PullToRefreshBase { 30 | 31 | public PullToRefreshHorizontalScrollView(Context context) { 32 | super(context); 33 | } 34 | 35 | public PullToRefreshHorizontalScrollView(Context context, AttributeSet attrs) { 36 | super(context, attrs); 37 | } 38 | 39 | public PullToRefreshHorizontalScrollView(Context context, Mode mode) { 40 | super(context, mode); 41 | } 42 | 43 | public PullToRefreshHorizontalScrollView(Context context, Mode mode, AnimationStyle style) { 44 | super(context, mode, style); 45 | } 46 | 47 | @Override 48 | public final Orientation getPullToRefreshScrollDirection() { 49 | return Orientation.HORIZONTAL; 50 | } 51 | 52 | @Override 53 | protected HorizontalScrollView createRefreshableView(Context context, AttributeSet attrs) { 54 | HorizontalScrollView scrollView; 55 | 56 | if (VERSION.SDK_INT >= VERSION_CODES.GINGERBREAD) { 57 | scrollView = new InternalHorizontalScrollViewSDK9(context, attrs); 58 | } else { 59 | scrollView = new HorizontalScrollView(context, attrs); 60 | } 61 | 62 | scrollView.setId(R.id.scrollview); 63 | return scrollView; 64 | } 65 | 66 | @Override 67 | protected boolean isReadyForPullStart() { 68 | return mRefreshableView.getScrollX() == 0; 69 | } 70 | 71 | @Override 72 | protected boolean isReadyForPullEnd() { 73 | View scrollViewChild = mRefreshableView.getChildAt(0); 74 | if (null != scrollViewChild) { 75 | return mRefreshableView.getScrollX() >= (scrollViewChild.getWidth() - getWidth()); 76 | } 77 | return false; 78 | } 79 | 80 | @TargetApi(9) 81 | final class InternalHorizontalScrollViewSDK9 extends HorizontalScrollView { 82 | 83 | public InternalHorizontalScrollViewSDK9(Context context, AttributeSet attrs) { 84 | super(context, attrs); 85 | } 86 | 87 | @Override 88 | protected boolean overScrollBy(int deltaX, int deltaY, int scrollX, int scrollY, int scrollRangeX, 89 | int scrollRangeY, int maxOverScrollX, int maxOverScrollY, boolean isTouchEvent) { 90 | 91 | final boolean returnValue = super.overScrollBy(deltaX, deltaY, scrollX, scrollY, scrollRangeX, 92 | scrollRangeY, maxOverScrollX, maxOverScrollY, isTouchEvent); 93 | 94 | // Does all of the hard work... 95 | OverscrollHelper.overScrollBy(PullToRefreshHorizontalScrollView.this, deltaX, scrollX, deltaY, scrollY, 96 | getScrollRange(), isTouchEvent); 97 | 98 | return returnValue; 99 | } 100 | 101 | /** 102 | * Taken from the AOSP ScrollView source 103 | */ 104 | private int getScrollRange() { 105 | int scrollRange = 0; 106 | if (getChildCount() > 0) { 107 | View child = getChildAt(0); 108 | scrollRange = Math.max(0, child.getWidth() - (getWidth() - getPaddingLeft() - getPaddingRight())); 109 | } 110 | return scrollRange; 111 | } 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /NiceApp/app/src/main/java/com/handmark/pulltorefresh/library/PullToRefreshListView.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2011, 2012 Chris Banes. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *******************************************************************************/ 16 | package com.handmark.pulltorefresh.library; 17 | 18 | import android.annotation.TargetApi; 19 | import android.content.Context; 20 | import android.content.res.TypedArray; 21 | import android.graphics.Canvas; 22 | import android.os.Build.VERSION; 23 | import android.os.Build.VERSION_CODES; 24 | import android.util.AttributeSet; 25 | import android.view.Gravity; 26 | import android.view.MotionEvent; 27 | import android.view.View; 28 | import android.widget.FrameLayout; 29 | import android.widget.ListAdapter; 30 | import android.widget.ListView; 31 | 32 | import com.handmark.pulltorefresh.library.internal.EmptyViewMethodAccessor; 33 | import com.handmark.pulltorefresh.library.internal.LoadingLayout; 34 | import com.shine.niceapp.R; 35 | 36 | 37 | public class PullToRefreshListView extends PullToRefreshAdapterViewBase { 38 | 39 | private LoadingLayout mHeaderLoadingView; 40 | private LoadingLayout mFooterLoadingView; 41 | 42 | private FrameLayout mLvFooterLoadingFrame; 43 | 44 | private boolean mListViewExtrasEnabled; 45 | 46 | public PullToRefreshListView(Context context) { 47 | super(context); 48 | } 49 | 50 | public PullToRefreshListView(Context context, AttributeSet attrs) { 51 | super(context, attrs); 52 | } 53 | 54 | public PullToRefreshListView(Context context, Mode mode) { 55 | super(context, mode); 56 | } 57 | 58 | public PullToRefreshListView(Context context, Mode mode, AnimationStyle style) { 59 | super(context, mode, style); 60 | } 61 | 62 | @Override 63 | public final Orientation getPullToRefreshScrollDirection() { 64 | return Orientation.VERTICAL; 65 | } 66 | 67 | @Override 68 | protected void onRefreshing(final boolean doScroll) { 69 | /** 70 | * If we're not showing the Refreshing view, or the list is empty, the 71 | * the header/footer views won't show so we use the normal method. 72 | */ 73 | ListAdapter adapter = mRefreshableView.getAdapter(); 74 | if (!mListViewExtrasEnabled || !getShowViewWhileRefreshing() || null == adapter || adapter.isEmpty()) { 75 | super.onRefreshing(doScroll); 76 | return; 77 | } 78 | 79 | super.onRefreshing(false); 80 | 81 | final LoadingLayout origLoadingView, listViewLoadingView, oppositeListViewLoadingView; 82 | final int selection, scrollToY; 83 | 84 | switch (getCurrentMode()) { 85 | case MANUAL_REFRESH_ONLY: 86 | case PULL_FROM_END: 87 | origLoadingView = getFooterLayout(); 88 | listViewLoadingView = mFooterLoadingView; 89 | oppositeListViewLoadingView = mHeaderLoadingView; 90 | selection = mRefreshableView.getCount() - 1; 91 | scrollToY = getScrollY() - getFooterSize(); 92 | break; 93 | case PULL_FROM_START: 94 | default: 95 | origLoadingView = getHeaderLayout(); 96 | listViewLoadingView = mHeaderLoadingView; 97 | oppositeListViewLoadingView = mFooterLoadingView; 98 | selection = 0; 99 | scrollToY = getScrollY() + getHeaderSize(); 100 | break; 101 | } 102 | 103 | // Hide our original Loading View 104 | origLoadingView.reset(); 105 | origLoadingView.hideAllViews(); 106 | 107 | // Make sure the opposite end is hidden too 108 | oppositeListViewLoadingView.setVisibility(View.GONE); 109 | 110 | // Show the ListView Loading View and set it to refresh. 111 | listViewLoadingView.setVisibility(View.VISIBLE); 112 | listViewLoadingView.refreshing(); 113 | 114 | if (doScroll) { 115 | // We need to disable the automatic visibility changes for now 116 | disableLoadingLayoutVisibilityChanges(); 117 | 118 | // We scroll slightly so that the ListView's header/footer is at the 119 | // same Y position as our normal header/footer 120 | setHeaderScroll(scrollToY); 121 | 122 | // Make sure the ListView is scrolled to show the loading 123 | // header/footer 124 | mRefreshableView.setSelection(selection); 125 | 126 | // Smooth scroll as normal 127 | smoothScrollTo(0); 128 | } 129 | } 130 | 131 | @Override 132 | protected void onReset() { 133 | /** 134 | * If the extras are not enabled, just call up to super and return. 135 | */ 136 | if (!mListViewExtrasEnabled) { 137 | super.onReset(); 138 | return; 139 | } 140 | 141 | final LoadingLayout originalLoadingLayout, listViewLoadingLayout; 142 | final int scrollToHeight, selection; 143 | final boolean scrollLvToEdge; 144 | 145 | switch (getCurrentMode()) { 146 | case MANUAL_REFRESH_ONLY: 147 | case PULL_FROM_END: 148 | originalLoadingLayout = getFooterLayout(); 149 | listViewLoadingLayout = mFooterLoadingView; 150 | selection = mRefreshableView.getCount() - 1; 151 | scrollToHeight = getFooterSize(); 152 | scrollLvToEdge = Math.abs(mRefreshableView.getLastVisiblePosition() - selection) <= 1; 153 | break; 154 | case PULL_FROM_START: 155 | default: 156 | originalLoadingLayout = getHeaderLayout(); 157 | listViewLoadingLayout = mHeaderLoadingView; 158 | scrollToHeight = -getHeaderSize(); 159 | selection = 0; 160 | scrollLvToEdge = Math.abs(mRefreshableView.getFirstVisiblePosition() - selection) <= 1; 161 | break; 162 | } 163 | 164 | // If the ListView header loading layout is showing, then we need to 165 | // flip so that the original one is showing instead 166 | if (listViewLoadingLayout.getVisibility() == View.VISIBLE) { 167 | 168 | // Set our Original View to Visible 169 | originalLoadingLayout.showInvisibleViews(); 170 | 171 | // Hide the ListView Header/Footer 172 | listViewLoadingLayout.setVisibility(View.GONE); 173 | 174 | /** 175 | * Scroll so the View is at the same Y as the ListView 176 | * header/footer, but only scroll if: we've pulled to refresh, it's 177 | * positioned correctly 178 | */ 179 | if (scrollLvToEdge && getState() != State.MANUAL_REFRESHING) { 180 | mRefreshableView.setSelection(selection); 181 | setHeaderScroll(scrollToHeight); 182 | } 183 | } 184 | 185 | // Finally, call up to super 186 | super.onReset(); 187 | } 188 | 189 | @Override 190 | protected LoadingLayoutProxy createLoadingLayoutProxy(final boolean includeStart, final boolean includeEnd) { 191 | LoadingLayoutProxy proxy = super.createLoadingLayoutProxy(includeStart, includeEnd); 192 | 193 | if (mListViewExtrasEnabled) { 194 | final Mode mode = getMode(); 195 | 196 | if (includeStart && mode.showHeaderLoadingLayout()) { 197 | proxy.addLayout(mHeaderLoadingView); 198 | } 199 | if (includeEnd && mode.showFooterLoadingLayout()) { 200 | proxy.addLayout(mFooterLoadingView); 201 | } 202 | } 203 | 204 | return proxy; 205 | } 206 | 207 | protected ListView createListView(Context context, AttributeSet attrs) { 208 | final ListView lv; 209 | if (VERSION.SDK_INT >= VERSION_CODES.GINGERBREAD) { 210 | lv = new InternalListViewSDK9(context, attrs); 211 | } else { 212 | lv = new InternalListView(context, attrs); 213 | } 214 | return lv; 215 | } 216 | 217 | @Override 218 | protected ListView createRefreshableView(Context context, AttributeSet attrs) { 219 | ListView lv = createListView(context, attrs); 220 | 221 | // Set it to this so it can be used in ListActivity/ListFragment 222 | lv.setId(android.R.id.list); 223 | return lv; 224 | } 225 | 226 | @Override 227 | protected void handleStyledAttributes(TypedArray a) { 228 | super.handleStyledAttributes(a); 229 | 230 | mListViewExtrasEnabled = a.getBoolean(R.styleable.PullToRefresh_ptrListViewExtrasEnabled, true); 231 | 232 | if (mListViewExtrasEnabled) { 233 | final FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, 234 | FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL); 235 | 236 | // Create Loading Views ready for use later 237 | FrameLayout frame = new FrameLayout(getContext()); 238 | mHeaderLoadingView = createLoadingLayout(getContext(), Mode.PULL_FROM_START, a); 239 | mHeaderLoadingView.setVisibility(View.GONE); 240 | frame.addView(mHeaderLoadingView, lp); 241 | mRefreshableView.addHeaderView(frame, null, false); 242 | 243 | mLvFooterLoadingFrame = new FrameLayout(getContext()); 244 | mFooterLoadingView = createLoadingLayout(getContext(), Mode.PULL_FROM_END, a); 245 | mFooterLoadingView.setVisibility(View.GONE); 246 | mLvFooterLoadingFrame.addView(mFooterLoadingView, lp); 247 | 248 | /** 249 | * If the value for Scrolling While Refreshing hasn't been 250 | * explicitly set via XML, enable Scrolling While Refreshing. 251 | */ 252 | if (!a.hasValue(R.styleable.PullToRefresh_ptrScrollingWhileRefreshingEnabled)) { 253 | setScrollingWhileRefreshingEnabled(true); 254 | } 255 | } 256 | } 257 | 258 | @TargetApi(9) 259 | final class InternalListViewSDK9 extends InternalListView { 260 | 261 | public InternalListViewSDK9(Context context, AttributeSet attrs) { 262 | super(context, attrs); 263 | } 264 | 265 | @Override 266 | protected boolean overScrollBy(int deltaX, int deltaY, int scrollX, int scrollY, int scrollRangeX, 267 | int scrollRangeY, int maxOverScrollX, int maxOverScrollY, boolean isTouchEvent) { 268 | 269 | final boolean returnValue = super.overScrollBy(deltaX, deltaY, scrollX, scrollY, scrollRangeX, 270 | scrollRangeY, maxOverScrollX, maxOverScrollY, isTouchEvent); 271 | 272 | // Does all of the hard work... 273 | OverscrollHelper.overScrollBy(PullToRefreshListView.this, deltaX, scrollX, deltaY, scrollY, isTouchEvent); 274 | 275 | return returnValue; 276 | } 277 | } 278 | 279 | protected class InternalListView extends ListView implements EmptyViewMethodAccessor { 280 | 281 | private boolean mAddedLvFooter = false; 282 | 283 | public InternalListView(Context context, AttributeSet attrs) { 284 | super(context, attrs); 285 | } 286 | 287 | @Override 288 | protected void dispatchDraw(Canvas canvas) { 289 | /** 290 | * This is a bit hacky, but Samsung's ListView has got a bug in it 291 | * when using Header/Footer Views and the list is empty. This masks 292 | * the issue so that it doesn't cause an FC. See Issue #66. 293 | */ 294 | try { 295 | super.dispatchDraw(canvas); 296 | } catch (IndexOutOfBoundsException e) { 297 | e.printStackTrace(); 298 | } 299 | } 300 | 301 | @Override 302 | public boolean dispatchTouchEvent(MotionEvent ev) { 303 | /** 304 | * This is a bit hacky, but Samsung's ListView has got a bug in it 305 | * when using Header/Footer Views and the list is empty. This masks 306 | * the issue so that it doesn't cause an FC. See Issue #66. 307 | */ 308 | try { 309 | return super.dispatchTouchEvent(ev); 310 | } catch (IndexOutOfBoundsException e) { 311 | e.printStackTrace(); 312 | return false; 313 | } 314 | } 315 | 316 | @Override 317 | public void setAdapter(ListAdapter adapter) { 318 | // Add the Footer View at the last possible moment 319 | if (null != mLvFooterLoadingFrame && !mAddedLvFooter) { 320 | addFooterView(mLvFooterLoadingFrame, null, false); 321 | mAddedLvFooter = true; 322 | } 323 | 324 | super.setAdapter(adapter); 325 | } 326 | 327 | @Override 328 | public void setEmptyView(View emptyView) { 329 | PullToRefreshListView.this.setEmptyView(emptyView); 330 | } 331 | 332 | @Override 333 | public void setEmptyViewInternal(View emptyView) { 334 | super.setEmptyView(emptyView); 335 | } 336 | 337 | } 338 | 339 | } 340 | -------------------------------------------------------------------------------- /NiceApp/app/src/main/java/com/handmark/pulltorefresh/library/PullToRefreshScrollView.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2011, 2012 Chris Banes. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *******************************************************************************/ 16 | package com.handmark.pulltorefresh.library; 17 | 18 | import android.annotation.TargetApi; 19 | import android.content.Context; 20 | import android.os.Build.VERSION; 21 | import android.os.Build.VERSION_CODES; 22 | import android.util.AttributeSet; 23 | import android.view.View; 24 | import android.widget.ScrollView; 25 | 26 | import com.shine.niceapp.R; 27 | 28 | 29 | public class PullToRefreshScrollView extends PullToRefreshBase { 30 | 31 | public PullToRefreshScrollView(Context context) { 32 | super(context); 33 | } 34 | 35 | public PullToRefreshScrollView(Context context, AttributeSet attrs) { 36 | super(context, attrs); 37 | } 38 | 39 | public PullToRefreshScrollView(Context context, Mode mode) { 40 | super(context, mode); 41 | } 42 | 43 | public PullToRefreshScrollView(Context context, Mode mode, AnimationStyle style) { 44 | super(context, mode, style); 45 | } 46 | 47 | @Override 48 | public final Orientation getPullToRefreshScrollDirection() { 49 | return Orientation.VERTICAL; 50 | } 51 | 52 | @Override 53 | protected ScrollView createRefreshableView(Context context, AttributeSet attrs) { 54 | ScrollView scrollView; 55 | if (VERSION.SDK_INT >= VERSION_CODES.GINGERBREAD) { 56 | scrollView = new InternalScrollViewSDK9(context, attrs); 57 | } else { 58 | scrollView = new ScrollView(context, attrs); 59 | } 60 | 61 | scrollView.setId(R.id.scrollview); 62 | return scrollView; 63 | } 64 | 65 | @Override 66 | protected boolean isReadyForPullStart() { 67 | return mRefreshableView.getScrollY() == 0; 68 | } 69 | 70 | @Override 71 | protected boolean isReadyForPullEnd() { 72 | View scrollViewChild = mRefreshableView.getChildAt(0); 73 | if (null != scrollViewChild) { 74 | return mRefreshableView.getScrollY() >= (scrollViewChild.getHeight() - getHeight()); 75 | } 76 | return false; 77 | } 78 | 79 | @TargetApi(9) 80 | final class InternalScrollViewSDK9 extends ScrollView { 81 | 82 | public InternalScrollViewSDK9(Context context, AttributeSet attrs) { 83 | super(context, attrs); 84 | } 85 | 86 | @Override 87 | protected boolean overScrollBy(int deltaX, int deltaY, int scrollX, int scrollY, int scrollRangeX, 88 | int scrollRangeY, int maxOverScrollX, int maxOverScrollY, boolean isTouchEvent) { 89 | 90 | final boolean returnValue = super.overScrollBy(deltaX, deltaY, scrollX, scrollY, scrollRangeX, 91 | scrollRangeY, maxOverScrollX, maxOverScrollY, isTouchEvent); 92 | 93 | // Does all of the hard work... 94 | OverscrollHelper.overScrollBy(PullToRefreshScrollView.this, deltaX, scrollX, deltaY, scrollY, 95 | getScrollRange(), isTouchEvent); 96 | 97 | return returnValue; 98 | } 99 | 100 | /** 101 | * Taken from the AOSP ScrollView source 102 | */ 103 | private int getScrollRange() { 104 | int scrollRange = 0; 105 | if (getChildCount() > 0) { 106 | View child = getChildAt(0); 107 | scrollRange = Math.max(0, child.getHeight() - (getHeight() - getPaddingBottom() - getPaddingTop())); 108 | } 109 | return scrollRange; 110 | } 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /NiceApp/app/src/main/java/com/handmark/pulltorefresh/library/PullToRefreshWebView.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2011, 2012 Chris Banes. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *******************************************************************************/ 16 | package com.handmark.pulltorefresh.library; 17 | 18 | import android.annotation.TargetApi; 19 | import android.content.Context; 20 | import android.os.Build.VERSION; 21 | import android.os.Build.VERSION_CODES; 22 | import android.os.Bundle; 23 | import android.util.AttributeSet; 24 | import android.util.FloatMath; 25 | import android.webkit.WebChromeClient; 26 | import android.webkit.WebView; 27 | 28 | import com.shine.niceapp.R; 29 | 30 | 31 | public class PullToRefreshWebView extends PullToRefreshBase { 32 | 33 | private static final OnRefreshListener defaultOnRefreshListener = new OnRefreshListener() { 34 | 35 | @Override 36 | public void onRefresh(PullToRefreshBase refreshView) { 37 | refreshView.getRefreshableView().reload(); 38 | } 39 | 40 | }; 41 | 42 | private final WebChromeClient defaultWebChromeClient = new WebChromeClient() { 43 | 44 | @Override 45 | public void onProgressChanged(WebView view, int newProgress) { 46 | if (newProgress == 100) { 47 | onRefreshComplete(); 48 | } 49 | } 50 | 51 | }; 52 | 53 | public PullToRefreshWebView(Context context) { 54 | super(context); 55 | 56 | /** 57 | * Added so that by default, Pull-to-Refresh refreshes the page 58 | */ 59 | setOnRefreshListener(defaultOnRefreshListener); 60 | mRefreshableView.setWebChromeClient(defaultWebChromeClient); 61 | } 62 | 63 | public PullToRefreshWebView(Context context, AttributeSet attrs) { 64 | super(context, attrs); 65 | 66 | /** 67 | * Added so that by default, Pull-to-Refresh refreshes the page 68 | */ 69 | setOnRefreshListener(defaultOnRefreshListener); 70 | mRefreshableView.setWebChromeClient(defaultWebChromeClient); 71 | } 72 | 73 | public PullToRefreshWebView(Context context, Mode mode) { 74 | super(context, mode); 75 | 76 | /** 77 | * Added so that by default, Pull-to-Refresh refreshes the page 78 | */ 79 | setOnRefreshListener(defaultOnRefreshListener); 80 | mRefreshableView.setWebChromeClient(defaultWebChromeClient); 81 | } 82 | 83 | public PullToRefreshWebView(Context context, Mode mode, AnimationStyle style) { 84 | super(context, mode, style); 85 | 86 | /** 87 | * Added so that by default, Pull-to-Refresh refreshes the page 88 | */ 89 | setOnRefreshListener(defaultOnRefreshListener); 90 | mRefreshableView.setWebChromeClient(defaultWebChromeClient); 91 | } 92 | 93 | @Override 94 | public final Orientation getPullToRefreshScrollDirection() { 95 | return Orientation.VERTICAL; 96 | } 97 | 98 | @Override 99 | protected WebView createRefreshableView(Context context, AttributeSet attrs) { 100 | WebView webView; 101 | if (VERSION.SDK_INT >= VERSION_CODES.GINGERBREAD) { 102 | webView = new InternalWebViewSDK9(context, attrs); 103 | } else { 104 | webView = new WebView(context, attrs); 105 | } 106 | 107 | webView.setId(R.id.webview); 108 | return webView; 109 | } 110 | 111 | @Override 112 | protected boolean isReadyForPullStart() { 113 | return mRefreshableView.getScrollY() == 0; 114 | } 115 | 116 | @Override 117 | protected boolean isReadyForPullEnd() { 118 | float exactContentHeight = FloatMath.floor(mRefreshableView.getContentHeight() * mRefreshableView.getScale()); 119 | return mRefreshableView.getScrollY() >= (exactContentHeight - mRefreshableView.getHeight()); 120 | } 121 | 122 | @Override 123 | protected void onPtrRestoreInstanceState(Bundle savedInstanceState) { 124 | super.onPtrRestoreInstanceState(savedInstanceState); 125 | mRefreshableView.restoreState(savedInstanceState); 126 | } 127 | 128 | @Override 129 | protected void onPtrSaveInstanceState(Bundle saveState) { 130 | super.onPtrSaveInstanceState(saveState); 131 | mRefreshableView.saveState(saveState); 132 | } 133 | 134 | @TargetApi(9) 135 | final class InternalWebViewSDK9 extends WebView { 136 | 137 | // WebView doesn't always scroll back to it's edge so we add some 138 | // fuzziness 139 | static final int OVERSCROLL_FUZZY_THRESHOLD = 2; 140 | 141 | // WebView seems quite reluctant to overscroll so we use the scale 142 | // factor to scale it's value 143 | static final float OVERSCROLL_SCALE_FACTOR = 1.5f; 144 | 145 | public InternalWebViewSDK9(Context context, AttributeSet attrs) { 146 | super(context, attrs); 147 | } 148 | 149 | @Override 150 | protected boolean overScrollBy(int deltaX, int deltaY, int scrollX, int scrollY, int scrollRangeX, 151 | int scrollRangeY, int maxOverScrollX, int maxOverScrollY, boolean isTouchEvent) { 152 | 153 | final boolean returnValue = super.overScrollBy(deltaX, deltaY, scrollX, scrollY, scrollRangeX, 154 | scrollRangeY, maxOverScrollX, maxOverScrollY, isTouchEvent); 155 | 156 | // Does all of the hard work... 157 | OverscrollHelper.overScrollBy(PullToRefreshWebView.this, deltaX, scrollX, deltaY, scrollY, 158 | getScrollRange(), OVERSCROLL_FUZZY_THRESHOLD, OVERSCROLL_SCALE_FACTOR, isTouchEvent); 159 | 160 | return returnValue; 161 | } 162 | 163 | private int getScrollRange() { 164 | return (int) Math.max(0, FloatMath.floor(mRefreshableView.getContentHeight() * mRefreshableView.getScale()) 165 | - (getHeight() - getPaddingBottom() - getPaddingTop())); 166 | } 167 | } 168 | } 169 | -------------------------------------------------------------------------------- /NiceApp/app/src/main/java/com/handmark/pulltorefresh/library/extras/PullToRefreshWebView2.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2011, 2012 Chris Banes. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *******************************************************************************/ 16 | package com.handmark.pulltorefresh.library.extras; 17 | 18 | import android.content.Context; 19 | import android.util.AttributeSet; 20 | import android.webkit.WebView; 21 | 22 | import com.handmark.pulltorefresh.library.PullToRefreshWebView; 23 | 24 | import java.util.concurrent.atomic.AtomicBoolean; 25 | 26 | /** 27 | * An advanced version of {@link PullToRefreshWebView} which delegates the 28 | * triggering of the PullToRefresh gesture to the Javascript running within the 29 | * WebView. This means that you should only use this class if: 30 | *

31 | *

38 | *

39 | *

40 | * The way this call works is that when a PullToRefresh gesture is in action, 41 | * the following Javascript methods will be called: 42 | * isReadyForPullDown() and isReadyForPullUp(), it is 43 | * your job to calculate whether the view is in a state where a PullToRefresh 44 | * can happen, and return the result via the callback mechanism. An example can 45 | * be seen below: 46 | *

47 | * 48 | *

 49 |  * function isReadyForPullDown() {
 50 |  *   var result = ...  // Probably using the .scrollTop DOM attribute
 51 |  *   ptr.isReadyForPullDownResponse(result);
 52 |  * }
 53 |  * 
 54 |  * function isReadyForPullUp() {
 55 |  *   var result = ...  // Probably using the .scrollBottom DOM attribute
 56 |  *   ptr.isReadyForPullUpResponse(result);
 57 |  * }
 58 |  * 
59 | * 60 | * @author Chris Banes 61 | */ 62 | public class PullToRefreshWebView2 extends PullToRefreshWebView { 63 | 64 | static final String JS_INTERFACE_PKG = "ptr"; 65 | static final String DEF_JS_READY_PULL_DOWN_CALL = "javascript:isReadyForPullDown();"; 66 | static final String DEF_JS_READY_PULL_UP_CALL = "javascript:isReadyForPullUp();"; 67 | 68 | public PullToRefreshWebView2(Context context) { 69 | super(context); 70 | } 71 | 72 | public PullToRefreshWebView2(Context context, AttributeSet attrs) { 73 | super(context, attrs); 74 | } 75 | 76 | public PullToRefreshWebView2(Context context, Mode mode) { 77 | super(context, mode); 78 | } 79 | 80 | private JsValueCallback mJsCallback; 81 | private final AtomicBoolean mIsReadyForPullDown = new AtomicBoolean(false); 82 | private final AtomicBoolean mIsReadyForPullUp = new AtomicBoolean(false); 83 | 84 | @Override 85 | protected WebView createRefreshableView(Context context, AttributeSet attrs) { 86 | WebView webView = super.createRefreshableView(context, attrs); 87 | 88 | // Need to add JS Interface so we can get the response back 89 | mJsCallback = new JsValueCallback(); 90 | webView.addJavascriptInterface(mJsCallback, JS_INTERFACE_PKG); 91 | 92 | return webView; 93 | } 94 | 95 | @Override 96 | protected boolean isReadyForPullStart() { 97 | // Call Javascript... 98 | getRefreshableView().loadUrl(DEF_JS_READY_PULL_DOWN_CALL); 99 | 100 | // Response will be given to JsValueCallback, which will update 101 | // mIsReadyForPullDown 102 | 103 | return mIsReadyForPullDown.get(); 104 | } 105 | 106 | @Override 107 | protected boolean isReadyForPullEnd() { 108 | // Call Javascript... 109 | getRefreshableView().loadUrl(DEF_JS_READY_PULL_UP_CALL); 110 | 111 | // Response will be given to JsValueCallback, which will update 112 | // mIsReadyForPullUp 113 | 114 | return mIsReadyForPullUp.get(); 115 | } 116 | 117 | /** 118 | * Used for response from Javascript 119 | * 120 | * @author Chris Banes 121 | */ 122 | final class JsValueCallback { 123 | 124 | public void isReadyForPullUpResponse(boolean response) { 125 | mIsReadyForPullUp.set(response); 126 | } 127 | 128 | public void isReadyForPullDownResponse(boolean response) { 129 | mIsReadyForPullDown.set(response); 130 | } 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /NiceApp/app/src/main/java/com/handmark/pulltorefresh/library/extras/SoundPullEventListener.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2011, 2012 Chris Banes. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *******************************************************************************/ 16 | package com.handmark.pulltorefresh.library.extras; 17 | 18 | import android.content.Context; 19 | import android.media.MediaPlayer; 20 | import android.view.View; 21 | 22 | import com.handmark.pulltorefresh.library.PullToRefreshBase; 23 | 24 | import java.util.HashMap; 25 | 26 | 27 | public class SoundPullEventListener implements PullToRefreshBase.OnPullEventListener { 28 | 29 | private final Context mContext; 30 | private final HashMap mSoundMap; 31 | 32 | private MediaPlayer mCurrentMediaPlayer; 33 | 34 | /** 35 | * Constructor 36 | * 37 | * @param context - Context 38 | */ 39 | public SoundPullEventListener(Context context) { 40 | mContext = context; 41 | mSoundMap = new HashMap(); 42 | } 43 | 44 | @Override 45 | public final void onPullEvent(PullToRefreshBase refreshView, PullToRefreshBase.State event, PullToRefreshBase.Mode direction) { 46 | Integer soundResIdObj = mSoundMap.get(event); 47 | if (null != soundResIdObj) { 48 | playSound(soundResIdObj.intValue()); 49 | } 50 | } 51 | 52 | /** 53 | * Set the Sounds to be played when a Pull Event happens. You specify which 54 | * sound plays for which events by calling this method multiple times for 55 | * each event. 56 | *

57 | * If you've already set a sound for a certain event, and add another sound 58 | * for that event, only the new sound will be played. 59 | * 60 | * @param event - The event for which the sound will be played. 61 | * @param resId - Resource Id of the sound file to be played (e.g. 62 | * R.raw.pull_sound) 63 | */ 64 | public void addSoundEvent(PullToRefreshBase.State event, int resId) { 65 | mSoundMap.put(event, resId); 66 | } 67 | 68 | /** 69 | * Clears all of the previously set sounds and events. 70 | */ 71 | public void clearSounds() { 72 | mSoundMap.clear(); 73 | } 74 | 75 | /** 76 | * Gets the current (or last) MediaPlayer instance. 77 | */ 78 | public MediaPlayer getCurrentMediaPlayer() { 79 | return mCurrentMediaPlayer; 80 | } 81 | 82 | private void playSound(int resId) { 83 | // Stop current player, if there's one playing 84 | if (null != mCurrentMediaPlayer) { 85 | mCurrentMediaPlayer.stop(); 86 | mCurrentMediaPlayer.release(); 87 | } 88 | 89 | mCurrentMediaPlayer = MediaPlayer.create(mContext, resId); 90 | if (null != mCurrentMediaPlayer) { 91 | mCurrentMediaPlayer.start(); 92 | } 93 | } 94 | 95 | } 96 | -------------------------------------------------------------------------------- /NiceApp/app/src/main/java/com/handmark/pulltorefresh/library/internal/EmptyViewMethodAccessor.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2011, 2012 Chris Banes. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *******************************************************************************/ 16 | package com.handmark.pulltorefresh.library.internal; 17 | 18 | import android.view.View; 19 | 20 | /** 21 | * Interface that allows PullToRefreshBase to hijack the call to 22 | * AdapterView.setEmptyView() 23 | * 24 | * @author chris 25 | */ 26 | public interface EmptyViewMethodAccessor { 27 | 28 | /** 29 | * Calls upto AdapterView.setEmptyView() 30 | * 31 | * @param emptyView - to set as Empty View 32 | */ 33 | public void setEmptyViewInternal(View emptyView); 34 | 35 | /** 36 | * Should call PullToRefreshBase.setEmptyView() which will then 37 | * automatically call through to setEmptyViewInternal() 38 | * 39 | * @param emptyView - to set as Empty View 40 | */ 41 | public void setEmptyView(View emptyView); 42 | 43 | } 44 | -------------------------------------------------------------------------------- /NiceApp/app/src/main/java/com/handmark/pulltorefresh/library/internal/FlipLoadingLayout.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2011, 2012 Chris Banes. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *******************************************************************************/ 16 | package com.handmark.pulltorefresh.library.internal; 17 | 18 | import android.annotation.SuppressLint; 19 | import android.content.Context; 20 | import android.content.res.TypedArray; 21 | import android.graphics.Matrix; 22 | import android.graphics.drawable.Drawable; 23 | import android.view.View; 24 | import android.view.ViewGroup; 25 | import android.view.animation.Animation; 26 | import android.view.animation.RotateAnimation; 27 | import android.widget.ImageView.ScaleType; 28 | 29 | import com.handmark.pulltorefresh.library.PullToRefreshBase; 30 | import com.shine.niceapp.R; 31 | 32 | 33 | @SuppressLint("ViewConstructor") 34 | public class FlipLoadingLayout extends LoadingLayout { 35 | 36 | static final int FLIP_ANIMATION_DURATION = 150; 37 | 38 | private final Animation mRotateAnimation, mResetRotateAnimation; 39 | 40 | public FlipLoadingLayout(Context context, final PullToRefreshBase.Mode mode, final PullToRefreshBase.Orientation scrollDirection, TypedArray attrs) { 41 | super(context, mode, scrollDirection, attrs); 42 | 43 | final int rotateAngle = mode == PullToRefreshBase.Mode.PULL_FROM_START ? -180 : 180; 44 | 45 | mRotateAnimation = new RotateAnimation(0, rotateAngle, Animation.RELATIVE_TO_SELF, 0.5f, 46 | Animation.RELATIVE_TO_SELF, 0.5f); 47 | mRotateAnimation.setInterpolator(ANIMATION_INTERPOLATOR); 48 | mRotateAnimation.setDuration(FLIP_ANIMATION_DURATION); 49 | mRotateAnimation.setFillAfter(true); 50 | 51 | mResetRotateAnimation = new RotateAnimation(rotateAngle, 0, Animation.RELATIVE_TO_SELF, 0.5f, 52 | Animation.RELATIVE_TO_SELF, 0.5f); 53 | mResetRotateAnimation.setInterpolator(ANIMATION_INTERPOLATOR); 54 | mResetRotateAnimation.setDuration(FLIP_ANIMATION_DURATION); 55 | mResetRotateAnimation.setFillAfter(true); 56 | } 57 | 58 | @Override 59 | protected void onLoadingDrawableSet(Drawable imageDrawable) { 60 | if (null != imageDrawable) { 61 | final int dHeight = imageDrawable.getIntrinsicHeight(); 62 | final int dWidth = imageDrawable.getIntrinsicWidth(); 63 | 64 | /** 65 | * We need to set the width/height of the ImageView so that it is 66 | * square with each side the size of the largest drawable dimension. 67 | * This is so that it doesn't clip when rotated. 68 | */ 69 | ViewGroup.LayoutParams lp = mHeaderImage.getLayoutParams(); 70 | lp.width = lp.height = Math.max(dHeight, dWidth); 71 | mHeaderImage.requestLayout(); 72 | 73 | /** 74 | * We now rotate the Drawable so that is at the correct rotation, 75 | * and is centered. 76 | */ 77 | mHeaderImage.setScaleType(ScaleType.MATRIX); 78 | Matrix matrix = new Matrix(); 79 | matrix.postTranslate((lp.width - dWidth) / 2f, (lp.height - dHeight) / 2f); 80 | matrix.postRotate(getDrawableRotationAngle(), lp.width / 2f, lp.height / 2f); 81 | mHeaderImage.setImageMatrix(matrix); 82 | } 83 | } 84 | 85 | @Override 86 | protected void onPullImpl(float scaleOfLayout) { 87 | // NO-OP 88 | } 89 | 90 | @Override 91 | protected void pullToRefreshImpl() { 92 | // Only start reset Animation, we've previously show the rotate anim 93 | if (mRotateAnimation == mHeaderImage.getAnimation()) { 94 | mHeaderImage.startAnimation(mResetRotateAnimation); 95 | } 96 | } 97 | 98 | @Override 99 | protected void refreshingImpl() { 100 | mHeaderImage.clearAnimation(); 101 | mHeaderImage.setVisibility(View.INVISIBLE); 102 | mHeaderProgress.setVisibility(View.VISIBLE); 103 | } 104 | 105 | @Override 106 | protected void releaseToRefreshImpl() { 107 | mHeaderImage.startAnimation(mRotateAnimation); 108 | } 109 | 110 | @Override 111 | protected void resetImpl() { 112 | mHeaderImage.clearAnimation(); 113 | mHeaderProgress.setVisibility(View.GONE); 114 | mHeaderImage.setVisibility(View.VISIBLE); 115 | } 116 | 117 | @Override 118 | protected int getDefaultDrawableResId() { 119 | return R.drawable.default_ptr_flip; 120 | } 121 | 122 | private float getDrawableRotationAngle() { 123 | float angle = 0f; 124 | switch (mMode) { 125 | case PULL_FROM_END: 126 | if (mScrollDirection == PullToRefreshBase.Orientation.HORIZONTAL) { 127 | angle = 90f; 128 | } else { 129 | angle = 180f; 130 | } 131 | break; 132 | 133 | case PULL_FROM_START: 134 | if (mScrollDirection == PullToRefreshBase.Orientation.HORIZONTAL) { 135 | angle = 270f; 136 | } 137 | break; 138 | 139 | default: 140 | break; 141 | } 142 | 143 | return angle; 144 | } 145 | 146 | } 147 | -------------------------------------------------------------------------------- /NiceApp/app/src/main/java/com/handmark/pulltorefresh/library/internal/IndicatorLayout.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2011, 2012 Chris Banes. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *******************************************************************************/ 16 | package com.handmark.pulltorefresh.library.internal; 17 | 18 | import android.annotation.SuppressLint; 19 | import android.content.Context; 20 | import android.graphics.Matrix; 21 | import android.graphics.drawable.Drawable; 22 | import android.view.View; 23 | import android.view.animation.Animation; 24 | import android.view.animation.Animation.AnimationListener; 25 | import android.view.animation.AnimationUtils; 26 | import android.view.animation.Interpolator; 27 | import android.view.animation.LinearInterpolator; 28 | import android.view.animation.RotateAnimation; 29 | import android.widget.FrameLayout; 30 | import android.widget.ImageView; 31 | import android.widget.ImageView.ScaleType; 32 | 33 | import com.handmark.pulltorefresh.library.PullToRefreshBase; 34 | import com.shine.niceapp.R; 35 | 36 | @SuppressLint("ViewConstructor") 37 | public class IndicatorLayout extends FrameLayout implements AnimationListener { 38 | 39 | static final int DEFAULT_ROTATION_ANIMATION_DURATION = 150; 40 | 41 | private Animation mInAnim, mOutAnim; 42 | private ImageView mArrowImageView; 43 | 44 | private final Animation mRotateAnimation, mResetRotateAnimation; 45 | 46 | public IndicatorLayout(Context context, PullToRefreshBase.Mode mode) { 47 | super(context); 48 | mArrowImageView = new ImageView(context); 49 | 50 | Drawable arrowD = getResources().getDrawable(R.drawable.indicator_arrow); 51 | mArrowImageView.setImageDrawable(arrowD); 52 | 53 | final int padding = getResources().getDimensionPixelSize(R.dimen.indicator_internal_padding); 54 | mArrowImageView.setPadding(padding, padding, padding, padding); 55 | addView(mArrowImageView); 56 | 57 | int inAnimResId, outAnimResId; 58 | switch (mode) { 59 | case PULL_FROM_END: 60 | inAnimResId = R.anim.slide_in_from_bottom; 61 | outAnimResId = R.anim.slide_out_to_bottom; 62 | setBackgroundResource(R.drawable.indicator_bg_bottom); 63 | 64 | // Rotate Arrow so it's pointing the correct way 65 | mArrowImageView.setScaleType(ScaleType.MATRIX); 66 | Matrix matrix = new Matrix(); 67 | matrix.setRotate(180f, arrowD.getIntrinsicWidth() / 2f, arrowD.getIntrinsicHeight() / 2f); 68 | mArrowImageView.setImageMatrix(matrix); 69 | break; 70 | default: 71 | case PULL_FROM_START: 72 | inAnimResId = R.anim.slide_in_from_top; 73 | outAnimResId = R.anim.slide_out_to_top; 74 | setBackgroundResource(R.drawable.indicator_bg_top); 75 | break; 76 | } 77 | 78 | mInAnim = AnimationUtils.loadAnimation(context, inAnimResId); 79 | mInAnim.setAnimationListener(this); 80 | 81 | mOutAnim = AnimationUtils.loadAnimation(context, outAnimResId); 82 | mOutAnim.setAnimationListener(this); 83 | 84 | final Interpolator interpolator = new LinearInterpolator(); 85 | mRotateAnimation = new RotateAnimation(0, -180, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 86 | 0.5f); 87 | mRotateAnimation.setInterpolator(interpolator); 88 | mRotateAnimation.setDuration(DEFAULT_ROTATION_ANIMATION_DURATION); 89 | mRotateAnimation.setFillAfter(true); 90 | 91 | mResetRotateAnimation = new RotateAnimation(-180, 0, Animation.RELATIVE_TO_SELF, 0.5f, 92 | Animation.RELATIVE_TO_SELF, 0.5f); 93 | mResetRotateAnimation.setInterpolator(interpolator); 94 | mResetRotateAnimation.setDuration(DEFAULT_ROTATION_ANIMATION_DURATION); 95 | mResetRotateAnimation.setFillAfter(true); 96 | 97 | } 98 | 99 | public final boolean isVisible() { 100 | Animation currentAnim = getAnimation(); 101 | if (null != currentAnim) { 102 | return mInAnim == currentAnim; 103 | } 104 | 105 | return getVisibility() == View.VISIBLE; 106 | } 107 | 108 | public void hide() { 109 | startAnimation(mOutAnim); 110 | } 111 | 112 | public void show() { 113 | mArrowImageView.clearAnimation(); 114 | startAnimation(mInAnim); 115 | } 116 | 117 | @Override 118 | public void onAnimationEnd(Animation animation) { 119 | if (animation == mOutAnim) { 120 | mArrowImageView.clearAnimation(); 121 | setVisibility(View.GONE); 122 | } else if (animation == mInAnim) { 123 | setVisibility(View.VISIBLE); 124 | } 125 | 126 | clearAnimation(); 127 | } 128 | 129 | @Override 130 | public void onAnimationRepeat(Animation animation) { 131 | // NO-OP 132 | } 133 | 134 | @Override 135 | public void onAnimationStart(Animation animation) { 136 | setVisibility(View.VISIBLE); 137 | } 138 | 139 | public void releaseToRefresh() { 140 | mArrowImageView.startAnimation(mRotateAnimation); 141 | } 142 | 143 | public void pullToRefresh() { 144 | mArrowImageView.startAnimation(mResetRotateAnimation); 145 | } 146 | 147 | } 148 | -------------------------------------------------------------------------------- /NiceApp/app/src/main/java/com/handmark/pulltorefresh/library/internal/LoadingLayout.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2011, 2012 Chris Banes. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *******************************************************************************/ 16 | package com.handmark.pulltorefresh.library.internal; 17 | 18 | import android.annotation.SuppressLint; 19 | import android.content.Context; 20 | import android.content.res.ColorStateList; 21 | import android.content.res.TypedArray; 22 | import android.graphics.Typeface; 23 | import android.graphics.drawable.AnimationDrawable; 24 | import android.graphics.drawable.Drawable; 25 | import android.text.TextUtils; 26 | import android.util.TypedValue; 27 | import android.view.Gravity; 28 | import android.view.LayoutInflater; 29 | import android.view.View; 30 | import android.view.ViewGroup; 31 | import android.view.animation.Interpolator; 32 | import android.view.animation.LinearInterpolator; 33 | import android.widget.FrameLayout; 34 | import android.widget.ImageView; 35 | import android.widget.ProgressBar; 36 | import android.widget.TextView; 37 | 38 | import com.handmark.pulltorefresh.library.ILoadingLayout; 39 | import com.handmark.pulltorefresh.library.PullToRefreshBase; 40 | import com.shine.niceapp.R; 41 | 42 | 43 | @SuppressLint("ViewConstructor") 44 | public abstract class LoadingLayout extends FrameLayout implements ILoadingLayout { 45 | 46 | static final String LOG_TAG = "PullToRefresh-LoadingLayout"; 47 | 48 | static final Interpolator ANIMATION_INTERPOLATOR = new LinearInterpolator(); 49 | 50 | private FrameLayout mInnerLayout; 51 | 52 | protected final ImageView mHeaderImage; 53 | protected final ProgressBar mHeaderProgress; 54 | 55 | private boolean mUseIntrinsicAnimation; 56 | 57 | private final TextView mHeaderText; 58 | private final TextView mSubHeaderText; 59 | 60 | protected final PullToRefreshBase.Mode mMode; 61 | protected final PullToRefreshBase.Orientation mScrollDirection; 62 | 63 | private CharSequence mPullLabel; 64 | private CharSequence mRefreshingLabel; 65 | private CharSequence mReleaseLabel; 66 | 67 | public LoadingLayout(Context context, final PullToRefreshBase.Mode mode, final PullToRefreshBase.Orientation scrollDirection, TypedArray attrs) { 68 | super(context); 69 | mMode = mode; 70 | mScrollDirection = scrollDirection; 71 | 72 | switch (scrollDirection) { 73 | case HORIZONTAL: 74 | LayoutInflater.from(context).inflate(R.layout.pull_to_refresh_header_horizontal, this); 75 | break; 76 | case VERTICAL: 77 | default: 78 | LayoutInflater.from(context).inflate(R.layout.pull_to_refresh_header_vertical, this); 79 | break; 80 | } 81 | 82 | mInnerLayout = (FrameLayout) findViewById(R.id.fl_inner); 83 | mHeaderText = (TextView) mInnerLayout.findViewById(R.id.pull_to_refresh_text); 84 | mHeaderProgress = (ProgressBar) mInnerLayout.findViewById(R.id.pull_to_refresh_progress); 85 | mSubHeaderText = (TextView) mInnerLayout.findViewById(R.id.pull_to_refresh_sub_text); 86 | mHeaderImage = (ImageView) mInnerLayout.findViewById(R.id.pull_to_refresh_image); 87 | 88 | LayoutParams lp = (LayoutParams) mInnerLayout.getLayoutParams(); 89 | 90 | switch (mode) { 91 | case PULL_FROM_END: 92 | lp.gravity = scrollDirection == PullToRefreshBase.Orientation.VERTICAL ? Gravity.TOP : Gravity.LEFT; 93 | 94 | // Load in labels 95 | mPullLabel = context.getString(R.string.pull_to_refresh_from_bottom_pull_label); 96 | mRefreshingLabel = context.getString(R.string.pull_to_refresh_from_bottom_refreshing_label); 97 | mReleaseLabel = context.getString(R.string.pull_to_refresh_from_bottom_release_label); 98 | break; 99 | 100 | case PULL_FROM_START: 101 | default: 102 | lp.gravity = scrollDirection == PullToRefreshBase.Orientation.VERTICAL ? Gravity.BOTTOM : Gravity.RIGHT; 103 | 104 | // Load in labels 105 | mPullLabel = context.getString(R.string.pull_to_refresh_pull_label); 106 | mRefreshingLabel = context.getString(R.string.pull_to_refresh_refreshing_label); 107 | mReleaseLabel = context.getString(R.string.pull_to_refresh_release_label); 108 | break; 109 | } 110 | 111 | if (attrs.hasValue(R.styleable.PullToRefresh_ptrHeaderBackground)) { 112 | Drawable background = attrs.getDrawable(R.styleable.PullToRefresh_ptrHeaderBackground); 113 | if (null != background) { 114 | ViewCompat.setBackground(this, background); 115 | } 116 | } 117 | 118 | if (attrs.hasValue(R.styleable.PullToRefresh_ptrHeaderTextAppearance)) { 119 | TypedValue styleID = new TypedValue(); 120 | attrs.getValue(R.styleable.PullToRefresh_ptrHeaderTextAppearance, styleID); 121 | setTextAppearance(styleID.data); 122 | } 123 | if (attrs.hasValue(R.styleable.PullToRefresh_ptrSubHeaderTextAppearance)) { 124 | TypedValue styleID = new TypedValue(); 125 | attrs.getValue(R.styleable.PullToRefresh_ptrSubHeaderTextAppearance, styleID); 126 | setSubTextAppearance(styleID.data); 127 | } 128 | 129 | // Text Color attrs need to be set after TextAppearance attrs 130 | if (attrs.hasValue(R.styleable.PullToRefresh_ptrHeaderTextColor)) { 131 | ColorStateList colors = attrs.getColorStateList(R.styleable.PullToRefresh_ptrHeaderTextColor); 132 | if (null != colors) { 133 | setTextColor(colors); 134 | } 135 | } 136 | if (attrs.hasValue(R.styleable.PullToRefresh_ptrHeaderSubTextColor)) { 137 | ColorStateList colors = attrs.getColorStateList(R.styleable.PullToRefresh_ptrHeaderSubTextColor); 138 | if (null != colors) { 139 | setSubTextColor(colors); 140 | } 141 | } 142 | 143 | // Try and get defined drawable from Attrs 144 | Drawable imageDrawable = null; 145 | if (attrs.hasValue(R.styleable.PullToRefresh_ptrDrawable)) { 146 | imageDrawable = attrs.getDrawable(R.styleable.PullToRefresh_ptrDrawable); 147 | } 148 | 149 | // Check Specific Drawable from Attrs, these overrite the generic 150 | // drawable attr above 151 | switch (mode) { 152 | case PULL_FROM_START: 153 | default: 154 | if (attrs.hasValue(R.styleable.PullToRefresh_ptrDrawableStart)) { 155 | imageDrawable = attrs.getDrawable(R.styleable.PullToRefresh_ptrDrawableStart); 156 | } else if (attrs.hasValue(R.styleable.PullToRefresh_ptrDrawableTop)) { 157 | Utils.warnDeprecation("ptrDrawableTop", "ptrDrawableStart"); 158 | imageDrawable = attrs.getDrawable(R.styleable.PullToRefresh_ptrDrawableTop); 159 | } 160 | break; 161 | 162 | case PULL_FROM_END: 163 | if (attrs.hasValue(R.styleable.PullToRefresh_ptrDrawableEnd)) { 164 | imageDrawable = attrs.getDrawable(R.styleable.PullToRefresh_ptrDrawableEnd); 165 | } else if (attrs.hasValue(R.styleable.PullToRefresh_ptrDrawableBottom)) { 166 | Utils.warnDeprecation("ptrDrawableBottom", "ptrDrawableEnd"); 167 | imageDrawable = attrs.getDrawable(R.styleable.PullToRefresh_ptrDrawableBottom); 168 | } 169 | break; 170 | } 171 | 172 | // If we don't have a user defined drawable, load the default 173 | if (null == imageDrawable) { 174 | imageDrawable = context.getResources().getDrawable(getDefaultDrawableResId()); 175 | } 176 | 177 | // Set Drawable, and save width/height 178 | setLoadingDrawable(imageDrawable); 179 | 180 | reset(); 181 | } 182 | 183 | public final void setHeight(int height) { 184 | ViewGroup.LayoutParams lp = (ViewGroup.LayoutParams) getLayoutParams(); 185 | lp.height = height; 186 | requestLayout(); 187 | } 188 | 189 | public final void setWidth(int width) { 190 | ViewGroup.LayoutParams lp = (ViewGroup.LayoutParams) getLayoutParams(); 191 | lp.width = width; 192 | requestLayout(); 193 | } 194 | 195 | public final int getContentSize() { 196 | switch (mScrollDirection) { 197 | case HORIZONTAL: 198 | return mInnerLayout.getWidth(); 199 | case VERTICAL: 200 | default: 201 | return mInnerLayout.getHeight(); 202 | } 203 | } 204 | 205 | public final void hideAllViews() { 206 | if (View.VISIBLE == mHeaderText.getVisibility()) { 207 | mHeaderText.setVisibility(View.INVISIBLE); 208 | } 209 | if (View.VISIBLE == mHeaderProgress.getVisibility()) { 210 | mHeaderProgress.setVisibility(View.INVISIBLE); 211 | } 212 | if (View.VISIBLE == mHeaderImage.getVisibility()) { 213 | mHeaderImage.setVisibility(View.INVISIBLE); 214 | } 215 | if (View.VISIBLE == mSubHeaderText.getVisibility()) { 216 | mSubHeaderText.setVisibility(View.INVISIBLE); 217 | } 218 | } 219 | 220 | public final void onPull(float scaleOfLayout) { 221 | if (!mUseIntrinsicAnimation) { 222 | onPullImpl(scaleOfLayout); 223 | } 224 | } 225 | 226 | public final void pullToRefresh() { 227 | if (null != mHeaderText) { 228 | mHeaderText.setText(mPullLabel); 229 | } 230 | 231 | // Now call the callback 232 | pullToRefreshImpl(); 233 | } 234 | 235 | public final void refreshing() { 236 | if (null != mHeaderText) { 237 | mHeaderText.setText(mRefreshingLabel); 238 | } 239 | 240 | if (mUseIntrinsicAnimation) { 241 | ((AnimationDrawable) mHeaderImage.getDrawable()).start(); 242 | } else { 243 | // Now call the callback 244 | refreshingImpl(); 245 | } 246 | 247 | if (null != mSubHeaderText) { 248 | mSubHeaderText.setVisibility(View.GONE); 249 | } 250 | } 251 | 252 | public final void releaseToRefresh() { 253 | if (null != mHeaderText) { 254 | mHeaderText.setText(mReleaseLabel); 255 | } 256 | 257 | // Now call the callback 258 | releaseToRefreshImpl(); 259 | } 260 | 261 | public final void reset() { 262 | if (null != mHeaderText) { 263 | mHeaderText.setText(mPullLabel); 264 | } 265 | mHeaderImage.setVisibility(View.VISIBLE); 266 | 267 | if (mUseIntrinsicAnimation) { 268 | ((AnimationDrawable) mHeaderImage.getDrawable()).stop(); 269 | } else { 270 | // Now call the callback 271 | resetImpl(); 272 | } 273 | 274 | if (null != mSubHeaderText) { 275 | if (TextUtils.isEmpty(mSubHeaderText.getText())) { 276 | mSubHeaderText.setVisibility(View.GONE); 277 | } else { 278 | mSubHeaderText.setVisibility(View.VISIBLE); 279 | } 280 | } 281 | } 282 | 283 | @Override 284 | public void setLastUpdatedLabel(CharSequence label) { 285 | setSubHeaderText(label); 286 | } 287 | 288 | public final void setLoadingDrawable(Drawable imageDrawable) { 289 | // Set Drawable 290 | mHeaderImage.setImageDrawable(imageDrawable); 291 | mUseIntrinsicAnimation = (imageDrawable instanceof AnimationDrawable); 292 | 293 | // Now call the callback 294 | onLoadingDrawableSet(imageDrawable); 295 | } 296 | 297 | public void setPullLabel(CharSequence pullLabel) { 298 | mPullLabel = pullLabel; 299 | } 300 | 301 | public void setRefreshingLabel(CharSequence refreshingLabel) { 302 | mRefreshingLabel = refreshingLabel; 303 | } 304 | 305 | public void setReleaseLabel(CharSequence releaseLabel) { 306 | mReleaseLabel = releaseLabel; 307 | } 308 | 309 | @Override 310 | public void setTextTypeface(Typeface tf) { 311 | mHeaderText.setTypeface(tf); 312 | } 313 | 314 | public final void showInvisibleViews() { 315 | if (View.INVISIBLE == mHeaderText.getVisibility()) { 316 | mHeaderText.setVisibility(View.VISIBLE); 317 | } 318 | if (View.INVISIBLE == mHeaderProgress.getVisibility()) { 319 | mHeaderProgress.setVisibility(View.VISIBLE); 320 | } 321 | if (View.INVISIBLE == mHeaderImage.getVisibility()) { 322 | mHeaderImage.setVisibility(View.VISIBLE); 323 | } 324 | if (View.INVISIBLE == mSubHeaderText.getVisibility()) { 325 | mSubHeaderText.setVisibility(View.VISIBLE); 326 | } 327 | } 328 | 329 | /** 330 | * Callbacks for derivative Layouts 331 | */ 332 | 333 | protected abstract int getDefaultDrawableResId(); 334 | 335 | protected abstract void onLoadingDrawableSet(Drawable imageDrawable); 336 | 337 | protected abstract void onPullImpl(float scaleOfLayout); 338 | 339 | protected abstract void pullToRefreshImpl(); 340 | 341 | protected abstract void refreshingImpl(); 342 | 343 | protected abstract void releaseToRefreshImpl(); 344 | 345 | protected abstract void resetImpl(); 346 | 347 | private void setSubHeaderText(CharSequence label) { 348 | if (null != mSubHeaderText) { 349 | if (TextUtils.isEmpty(label)) { 350 | mSubHeaderText.setVisibility(View.GONE); 351 | } else { 352 | mSubHeaderText.setText(label); 353 | 354 | // Only set it to Visible if we're GONE, otherwise VISIBLE will 355 | // be set soon 356 | if (View.GONE == mSubHeaderText.getVisibility()) { 357 | mSubHeaderText.setVisibility(View.VISIBLE); 358 | } 359 | } 360 | } 361 | } 362 | 363 | private void setSubTextAppearance(int value) { 364 | if (null != mSubHeaderText) { 365 | mSubHeaderText.setTextAppearance(getContext(), value); 366 | } 367 | } 368 | 369 | private void setSubTextColor(ColorStateList color) { 370 | if (null != mSubHeaderText) { 371 | mSubHeaderText.setTextColor(color); 372 | } 373 | } 374 | 375 | private void setTextAppearance(int value) { 376 | if (null != mHeaderText) { 377 | mHeaderText.setTextAppearance(getContext(), value); 378 | } 379 | if (null != mSubHeaderText) { 380 | mSubHeaderText.setTextAppearance(getContext(), value); 381 | } 382 | } 383 | 384 | private void setTextColor(ColorStateList color) { 385 | if (null != mHeaderText) { 386 | mHeaderText.setTextColor(color); 387 | } 388 | if (null != mSubHeaderText) { 389 | mSubHeaderText.setTextColor(color); 390 | } 391 | } 392 | 393 | } 394 | -------------------------------------------------------------------------------- /NiceApp/app/src/main/java/com/handmark/pulltorefresh/library/internal/RotateLoadingLayout.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2011, 2012 Chris Banes. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *******************************************************************************/ 16 | package com.handmark.pulltorefresh.library.internal; 17 | 18 | import android.content.Context; 19 | import android.content.res.TypedArray; 20 | import android.graphics.Matrix; 21 | import android.graphics.drawable.Drawable; 22 | import android.view.animation.Animation; 23 | import android.view.animation.RotateAnimation; 24 | import android.widget.ImageView.ScaleType; 25 | 26 | import com.handmark.pulltorefresh.library.PullToRefreshBase; 27 | import com.shine.niceapp.R; 28 | 29 | 30 | public class RotateLoadingLayout extends LoadingLayout { 31 | 32 | static final int ROTATION_ANIMATION_DURATION = 1200; 33 | 34 | private final Animation mRotateAnimation; 35 | private final Matrix mHeaderImageMatrix; 36 | 37 | private float mRotationPivotX, mRotationPivotY; 38 | 39 | private final boolean mRotateDrawableWhilePulling; 40 | 41 | public RotateLoadingLayout(Context context, PullToRefreshBase.Mode mode, PullToRefreshBase.Orientation scrollDirection, TypedArray attrs) { 42 | super(context, mode, scrollDirection, attrs); 43 | 44 | mRotateDrawableWhilePulling = attrs.getBoolean(R.styleable.PullToRefresh_ptrRotateDrawableWhilePulling, true); 45 | 46 | mHeaderImage.setScaleType(ScaleType.MATRIX); 47 | mHeaderImageMatrix = new Matrix(); 48 | mHeaderImage.setImageMatrix(mHeaderImageMatrix); 49 | 50 | mRotateAnimation = new RotateAnimation(0, 720, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 51 | 0.5f); 52 | mRotateAnimation.setInterpolator(ANIMATION_INTERPOLATOR); 53 | mRotateAnimation.setDuration(ROTATION_ANIMATION_DURATION); 54 | mRotateAnimation.setRepeatCount(Animation.INFINITE); 55 | mRotateAnimation.setRepeatMode(Animation.RESTART); 56 | } 57 | 58 | public void onLoadingDrawableSet(Drawable imageDrawable) { 59 | if (null != imageDrawable) { 60 | mRotationPivotX = Math.round(imageDrawable.getIntrinsicWidth() / 2f); 61 | mRotationPivotY = Math.round(imageDrawable.getIntrinsicHeight() / 2f); 62 | } 63 | } 64 | 65 | protected void onPullImpl(float scaleOfLayout) { 66 | float angle; 67 | if (mRotateDrawableWhilePulling) { 68 | angle = scaleOfLayout * 90f; 69 | } else { 70 | angle = Math.max(0f, Math.min(180f, scaleOfLayout * 360f - 180f)); 71 | } 72 | 73 | mHeaderImageMatrix.setRotate(angle, mRotationPivotX, mRotationPivotY); 74 | mHeaderImage.setImageMatrix(mHeaderImageMatrix); 75 | } 76 | 77 | @Override 78 | protected void refreshingImpl() { 79 | mHeaderImage.startAnimation(mRotateAnimation); 80 | } 81 | 82 | @Override 83 | protected void resetImpl() { 84 | mHeaderImage.clearAnimation(); 85 | resetImageRotation(); 86 | } 87 | 88 | private void resetImageRotation() { 89 | if (null != mHeaderImageMatrix) { 90 | mHeaderImageMatrix.reset(); 91 | mHeaderImage.setImageMatrix(mHeaderImageMatrix); 92 | } 93 | } 94 | 95 | @Override 96 | protected void pullToRefreshImpl() { 97 | // NO-OP 98 | } 99 | 100 | @Override 101 | protected void releaseToRefreshImpl() { 102 | // NO-OP 103 | } 104 | 105 | @Override 106 | protected int getDefaultDrawableResId() { 107 | return R.drawable.default_ptr_rotate; 108 | } 109 | 110 | } 111 | -------------------------------------------------------------------------------- /NiceApp/app/src/main/java/com/handmark/pulltorefresh/library/internal/Utils.java: -------------------------------------------------------------------------------- 1 | package com.handmark.pulltorefresh.library.internal; 2 | 3 | import android.util.Log; 4 | 5 | public class Utils { 6 | 7 | static final String LOG_TAG = "PullToRefresh"; 8 | 9 | public static void warnDeprecation(String depreacted, String replacement) { 10 | Log.w(LOG_TAG, "You're using the deprecated " + depreacted + " attr, please switch over to " + replacement); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /NiceApp/app/src/main/java/com/handmark/pulltorefresh/library/internal/ViewCompat.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2011, 2012 Chris Banes. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *******************************************************************************/ 16 | package com.handmark.pulltorefresh.library.internal; 17 | 18 | import android.annotation.TargetApi; 19 | import android.graphics.drawable.Drawable; 20 | import android.os.Build.VERSION; 21 | import android.os.Build.VERSION_CODES; 22 | import android.view.View; 23 | 24 | @SuppressWarnings("deprecation") 25 | public class ViewCompat { 26 | 27 | public static void postOnAnimation(View view, Runnable runnable) { 28 | if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) { 29 | SDK16.postOnAnimation(view, runnable); 30 | } else { 31 | view.postDelayed(runnable, 16); 32 | } 33 | } 34 | 35 | public static void setBackground(View view, Drawable background) { 36 | if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) { 37 | SDK16.setBackground(view, background); 38 | } else { 39 | view.setBackgroundDrawable(background); 40 | } 41 | } 42 | 43 | public static void setLayerType(View view, int layerType) { 44 | if (VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB) { 45 | SDK11.setLayerType(view, layerType); 46 | } 47 | } 48 | 49 | @TargetApi(11) 50 | static class SDK11 { 51 | 52 | public static void setLayerType(View view, int layerType) { 53 | view.setLayerType(layerType, null); 54 | } 55 | } 56 | 57 | @TargetApi(16) 58 | static class SDK16 { 59 | 60 | public static void postOnAnimation(View view, Runnable runnable) { 61 | view.postOnAnimation(runnable); 62 | } 63 | 64 | public static void setBackground(View view, Drawable background) { 65 | view.setBackground(background); 66 | } 67 | 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /NiceApp/app/src/main/java/com/shine/niceapp/bean/Card.java: -------------------------------------------------------------------------------- 1 | package com.shine.niceapp.bean; 2 | 3 | import java.io.Serializable; 4 | 5 | public class Card implements Serializable { 6 | private static final long serialVersionUID = -5376313495678563362L; 7 | 8 | private int id; 9 | 10 | private int uid; 11 | 12 | private int upNum; 13 | 14 | private String title; 15 | 16 | private String backgroundColor; 17 | 18 | private String subTitle; 19 | 20 | private String digest; 21 | 22 | private String authorName; 23 | 24 | private String coverImgerUrl; 25 | 26 | private String iconUrl; 27 | 28 | public String getIconUrl() { 29 | return iconUrl; 30 | } 31 | 32 | public void setIconUrl(String iconUrl) { 33 | this.iconUrl = iconUrl; 34 | } 35 | 36 | public String getCoverImgerUrl() { 37 | return coverImgerUrl; 38 | } 39 | 40 | public void setCoverImgerUrl(String coverImgerUrl) { 41 | this.coverImgerUrl = coverImgerUrl; 42 | } 43 | 44 | public String getAuthorName() { 45 | return authorName; 46 | } 47 | 48 | public void setAuthorName(String authorName) { 49 | this.authorName = authorName; 50 | } 51 | 52 | public int getUpNum() { 53 | return upNum; 54 | } 55 | 56 | public void setUpNum(int upNum) { 57 | this.upNum = upNum; 58 | } 59 | 60 | public String getDigest() { 61 | return digest; 62 | } 63 | 64 | public void setDigest(String digest) { 65 | this.digest = digest; 66 | } 67 | 68 | public String getSubTitle() { 69 | return subTitle; 70 | } 71 | 72 | public void setSubTitle(String subTitle) { 73 | this.subTitle = subTitle; 74 | } 75 | 76 | public String getBackgroundColor() { 77 | return backgroundColor; 78 | } 79 | 80 | public void setBackgroundColor(String backgroundColor) { 81 | this.backgroundColor = backgroundColor; 82 | } 83 | 84 | public int getUid() { 85 | return uid; 86 | } 87 | 88 | public void setUid(int uid) { 89 | this.uid = uid; 90 | } 91 | 92 | public int getId() { 93 | return id; 94 | } 95 | 96 | public void setId(int id) { 97 | this.id = id; 98 | } 99 | 100 | public String getTitle() { 101 | return title; 102 | } 103 | 104 | public void setTitle(String title) { 105 | this.title = title; 106 | } 107 | } -------------------------------------------------------------------------------- /NiceApp/app/src/main/java/com/shine/niceapp/control/IRhythmItemListener.java: -------------------------------------------------------------------------------- 1 | package com.shine.niceapp.control; 2 | 3 | public abstract interface IRhythmItemListener { 4 | public abstract void onRhythmItemChanged(int paramInt); 5 | 6 | public abstract void onSelected(int paramInt); 7 | 8 | public abstract void onStartSwipe(); 9 | } -------------------------------------------------------------------------------- /NiceApp/app/src/main/java/com/shine/niceapp/control/RhythmAdapter.java: -------------------------------------------------------------------------------- 1 | package com.shine.niceapp.control; 2 | 3 | import android.content.Context; 4 | import android.view.LayoutInflater; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | import android.widget.BaseAdapter; 8 | import android.widget.ImageView; 9 | import android.widget.RelativeLayout; 10 | 11 | import com.shine.niceapp.R; 12 | import com.shine.niceapp.bean.Card; 13 | import com.shine.niceapp.utils.AppUtils; 14 | 15 | import java.util.ArrayList; 16 | import java.util.List; 17 | 18 | public class RhythmAdapter extends BaseAdapter { 19 | 20 | /** 21 | * item的宽度 22 | */ 23 | private float itemWidth; 24 | /** 25 | * 数据源 26 | */ 27 | private List mCardList; 28 | 29 | private LayoutInflater mInflater; 30 | private Context mContext; 31 | private RhythmLayout mRhythmLayout; 32 | 33 | public RhythmAdapter(Context context, RhythmLayout rhythmLayout, List cardList) { 34 | this.mContext = context; 35 | this.mRhythmLayout = rhythmLayout; 36 | this.mCardList = new ArrayList(); 37 | this.mCardList.addAll(cardList); 38 | if (context != null) 39 | this.mInflater = LayoutInflater.from(context); 40 | } 41 | 42 | public List getCardList() { 43 | return this.mCardList; 44 | } 45 | 46 | public void addCardList(List cardList) { 47 | mCardList.addAll(cardList); 48 | } 49 | 50 | public int getCount() { 51 | return this.mCardList.size(); 52 | } 53 | 54 | public Object getItem(int position) { 55 | return this.mCardList.get(position); 56 | } 57 | 58 | public long getItemId(int paramInt) { 59 | return (this.mCardList.get(paramInt)).getUid(); 60 | } 61 | 62 | 63 | @Override 64 | public View getView(int position, View convertView, ViewGroup parent) { 65 | RelativeLayout relativeLayout = (RelativeLayout) this.mInflater.inflate(R.layout.adapter_rhythm_icon, null); 66 | //设置item布局的大小以及Y轴的位置 67 | relativeLayout.setLayoutParams(new RelativeLayout.LayoutParams((int) itemWidth, mContext.getResources().getDimensionPixelSize(R.dimen.rhythm_item_height))); 68 | relativeLayout.setTranslationY(itemWidth); 69 | 70 | //设置第二层RelativeLayout布局的宽和高 71 | RelativeLayout childRelativeLayout = (RelativeLayout) relativeLayout.getChildAt(0); 72 | int relativeLayoutWidth = (int) itemWidth - 2 * mContext.getResources().getDimensionPixelSize(R.dimen.rhythm_icon_margin); 73 | childRelativeLayout.setLayoutParams(new RelativeLayout.LayoutParams(relativeLayoutWidth, mContext.getResources().getDimensionPixelSize(R.dimen.rhythm_item_height) - 2 * mContext.getResources().getDimensionPixelSize(R.dimen.rhythm_icon_margin))); 74 | 75 | ImageView imageIcon = (ImageView) relativeLayout.findViewById(R.id.image_icon); 76 | //计算ImageView的大小 77 | int iconSize = (relativeLayoutWidth - 2 * mContext.getResources().getDimensionPixelSize(R.dimen.rhythm_icon_margin)); 78 | ViewGroup.LayoutParams iconParams = imageIcon.getLayoutParams(); 79 | iconParams.width = iconSize; 80 | iconParams.height = iconSize; 81 | imageIcon.setLayoutParams(iconParams); 82 | //设置背景图片 83 | imageIcon.setBackgroundResource(AppUtils.getDrawableIdByName(mContext, mCardList.get(position).getIconUrl())); 84 | 85 | return relativeLayout; 86 | } 87 | 88 | public void notifyDataSetChanged() { 89 | super.notifyDataSetChanged(); 90 | this.mRhythmLayout.invalidateData(); 91 | } 92 | 93 | public void setCardList(List paramList) { 94 | this.mCardList = paramList; 95 | } 96 | 97 | /** 98 | * 设置每个item的宽度 99 | */ 100 | public void setItemWidth(float width) { 101 | this.itemWidth = width; 102 | } 103 | } -------------------------------------------------------------------------------- /NiceApp/app/src/main/java/com/shine/niceapp/control/ViewPagerScroller.java: -------------------------------------------------------------------------------- 1 | package com.shine.niceapp.control; 2 | 3 | import android.content.Context; 4 | import android.view.animation.Interpolator; 5 | import android.widget.Scroller; 6 | 7 | public class ViewPagerScroller extends Scroller 8 | { 9 | private int mDuration; 10 | 11 | public ViewPagerScroller(Context paramContext) 12 | { 13 | super(paramContext); 14 | } 15 | 16 | public ViewPagerScroller(Context paramContext, Interpolator paramInterpolator) 17 | { 18 | super(paramContext, paramInterpolator); 19 | } 20 | 21 | public ViewPagerScroller(Context paramContext, Interpolator paramInterpolator, boolean paramBoolean) 22 | { 23 | super(paramContext, paramInterpolator, paramBoolean); 24 | } 25 | 26 | public void setDuration(int paramInt) 27 | { 28 | this.mDuration = paramInt; 29 | } 30 | 31 | public void startScroll(int paramInt1, int paramInt2, int paramInt3, int paramInt4) 32 | { 33 | super.startScroll(paramInt1, paramInt2, paramInt3, paramInt4, this.mDuration); 34 | } 35 | 36 | public void startScroll(int paramInt1, int paramInt2, int paramInt3, int paramInt4, int paramInt5) 37 | { 38 | super.startScroll(paramInt1, paramInt2, paramInt3, paramInt4, this.mDuration); 39 | } 40 | } -------------------------------------------------------------------------------- /NiceApp/app/src/main/java/com/shine/niceapp/ui/activity/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.shine.niceapp.ui.activity; 2 | 3 | import android.os.Bundle; 4 | import android.support.v4.app.FragmentActivity; 5 | import android.support.v4.app.FragmentTransaction; 6 | 7 | import com.shine.niceapp.R; 8 | import com.shine.niceapp.ui.fragment.CardViewPagerFragment; 9 | 10 | 11 | public class MainActivity extends FragmentActivity { 12 | 13 | @Override 14 | protected void onCreate(Bundle savedInstanceState) { 15 | super.onCreate(savedInstanceState); 16 | setContentView(R.layout.activity_main); 17 | 18 | CardViewPagerFragment fragment = CardViewPagerFragment.getInstance(); 19 | 20 | FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); 21 | transaction.add(R.id.frameLayout, fragment); 22 | transaction.commit(); 23 | 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /NiceApp/app/src/main/java/com/shine/niceapp/ui/adapter/CardPagerAdapter.java: -------------------------------------------------------------------------------- 1 | package com.shine.niceapp.ui.adapter; 2 | 3 | import android.support.v4.app.Fragment; 4 | import android.support.v4.app.FragmentManager; 5 | import android.support.v4.app.FragmentStatePagerAdapter; 6 | 7 | import com.shine.niceapp.bean.Card; 8 | import com.shine.niceapp.ui.fragment.CardFragment; 9 | 10 | import java.util.ArrayList; 11 | import java.util.Iterator; 12 | import java.util.List; 13 | 14 | public class CardPagerAdapter extends FragmentStatePagerAdapter { 15 | private List mPostList; 16 | private List mFragments = new ArrayList(); 17 | 18 | public CardPagerAdapter(FragmentManager paramFragmentManager, List paramList) { 19 | super(paramFragmentManager); 20 | Iterator localIterator = paramList.iterator(); 21 | while (localIterator.hasNext()) { 22 | Card localAppModel = (Card) localIterator.next(); 23 | this.mFragments.add(CardFragment.getInstance(localAppModel)); 24 | } 25 | this.mPostList = paramList; 26 | } 27 | 28 | public void addCardList(List cardList) { 29 | ArrayList localArrayList = new ArrayList(); 30 | Iterator localIterator = cardList.iterator(); 31 | while (localIterator.hasNext()) 32 | localArrayList.add(CardFragment.getInstance((Card) localIterator.next())); 33 | if (this.mFragments == null) 34 | this.mFragments = new ArrayList(); 35 | this.mFragments.addAll(localArrayList); 36 | this.mPostList.addAll(cardList); 37 | } 38 | 39 | public List getCardList() { 40 | return this.mPostList; 41 | } 42 | 43 | public int getCount() { 44 | return this.mFragments.size(); 45 | } 46 | 47 | public List getFragments() { 48 | return this.mFragments; 49 | } 50 | 51 | public Fragment getItem(int paramInt) { 52 | return this.mFragments.get(paramInt); 53 | } 54 | 55 | public void setCardList(List cardList) { 56 | ArrayList localArrayList = new ArrayList(); 57 | Iterator localIterator = cardList.iterator(); 58 | while (localIterator.hasNext()) 59 | localArrayList.add(CardFragment.getInstance((Card) localIterator.next())); 60 | this.mFragments = localArrayList; 61 | this.mPostList = cardList; 62 | } 63 | 64 | public void setFragments(List paramList) { 65 | this.mFragments = paramList; 66 | } 67 | } -------------------------------------------------------------------------------- /NiceApp/app/src/main/java/com/shine/niceapp/ui/fragment/AbsBaseFragment.java: -------------------------------------------------------------------------------- 1 | package com.shine.niceapp.ui.fragment; 2 | 3 | 4 | import android.os.Bundle; 5 | import android.os.Handler; 6 | import android.support.v4.app.Fragment; 7 | import android.view.LayoutInflater; 8 | import android.view.View; 9 | import android.view.ViewGroup; 10 | 11 | /** 12 | * User: huangruimin 13 | * Date: 2014-12-13 14 | * Time: 19:43 15 | * Description: 16 | */ 17 | public abstract class AbsBaseFragment extends Fragment { 18 | protected Handler mHandler = new Handler(); 19 | 20 | protected abstract void initActions(View paramView); 21 | 22 | protected abstract void initData(); 23 | 24 | protected abstract View initViews(LayoutInflater paramLayoutInflater); 25 | 26 | public void onCreate(Bundle paramBundle) { 27 | super.onCreate(paramBundle); 28 | initData(); 29 | } 30 | 31 | public View onCreateView(LayoutInflater paramLayoutInflater, ViewGroup paramViewGroup, Bundle paramBundle) { 32 | super.onCreateView(paramLayoutInflater, paramViewGroup, paramBundle); 33 | View localView = initViews(paramLayoutInflater); 34 | initActions(localView); 35 | return localView; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /NiceApp/app/src/main/java/com/shine/niceapp/ui/fragment/CardFragment.java: -------------------------------------------------------------------------------- 1 | package com.shine.niceapp.ui.fragment; 2 | 3 | import android.os.Bundle; 4 | import android.text.Html; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | import android.widget.ImageView; 9 | import android.widget.RelativeLayout; 10 | import android.widget.TextView; 11 | 12 | import com.shine.niceapp.R; 13 | import com.shine.niceapp.bean.Card; 14 | import com.shine.niceapp.ui.widget.HtmlTextView; 15 | import com.shine.niceapp.utils.AppUtils; 16 | 17 | public class CardFragment extends AbsBaseFragment { 18 | protected Card mCard; 19 | 20 | 21 | protected TextView mAuthorText; 22 | protected ImageView mBottomEdgeImageView; 23 | protected TextView mBravoNumText; 24 | protected RelativeLayout mCardLayout; 25 | protected ImageView mCoverImageView; 26 | protected HtmlTextView mDigestText; 27 | protected TextView mSubTitleText; 28 | protected TextView mTitleText; 29 | 30 | public static CardFragment getInstance(Card card) { 31 | CardFragment localCardFragment = new CardFragment(); 32 | Bundle localBundle = new Bundle(); 33 | localBundle.putSerializable("card", card); 34 | localCardFragment.setArguments(localBundle); 35 | return localCardFragment; 36 | } 37 | 38 | 39 | protected View initViews(LayoutInflater paramLayoutInflater) { 40 | View view = paramLayoutInflater.inflate(R.layout.fragment_card, null); 41 | mCardLayout = ((RelativeLayout) view.findViewById(R.id.box_card)); 42 | mBottomEdgeImageView = ((ImageView) view.findViewById(R.id.image_bottom_edge)); 43 | mCoverImageView = ((ImageView) view.findViewById(R.id.image_cover)); 44 | mTitleText = ((TextView) view.findViewById(R.id.text_title)); 45 | mSubTitleText = ((TextView) view.findViewById(R.id.text_subtitle)); 46 | mDigestText = ((HtmlTextView) view.findViewById(R.id.text_digest)); 47 | mAuthorText = ((TextView) view.findViewById(R.id.text_author)); 48 | mBravoNumText = ((TextView) view.findViewById(R.id.text_bravos)); 49 | 50 | mTitleText.setText(this.mCard.getTitle()); 51 | mSubTitleText.setText(this.mCard.getSubTitle()); 52 | this.mBravoNumText.setText(" " + this.mCard.getUpNum()); 53 | this.mDigestText.setTextViewHtml(mCard.getDigest()); 54 | this.mAuthorText.setText(Html.fromHtml("" + this.mCard.getAuthorName() + "")); 55 | initAndDisplayCoverImage(); 56 | 57 | return view; 58 | } 59 | 60 | protected void initAndDisplayCoverImage() { 61 | int coverWidth = AppUtils.getScreenDisplayMetrics(getActivity()).widthPixels - 2 * getResources().getDimensionPixelSize(R.dimen.card_margin); 62 | int coverHeight = (int) (180.0F * (coverWidth / 320.0F)); 63 | ViewGroup.LayoutParams localLayoutParams = this.mCoverImageView.getLayoutParams(); 64 | localLayoutParams.height = Float.valueOf(coverHeight).intValue(); 65 | //加载图片 66 | int picResource = AppUtils.getDrawableIdByName(getActivity(), mCard.getCoverImgerUrl()); 67 | mCoverImageView.setBackgroundResource(picResource); 68 | } 69 | 70 | protected void initData() { 71 | this.mCard = (Card) getArguments().getSerializable("card"); 72 | } 73 | 74 | protected void initActions(View paramView) { 75 | } 76 | 77 | public void onDestroy() { 78 | this.mCoverImageView.setImageBitmap(null); 79 | super.onDestroy(); 80 | } 81 | 82 | public void onDestroyView() { 83 | this.mCoverImageView.setImageBitmap(null); 84 | super.onDestroyView(); 85 | } 86 | } -------------------------------------------------------------------------------- /NiceApp/app/src/main/java/com/shine/niceapp/ui/widget/HtmlTextView.java: -------------------------------------------------------------------------------- 1 | package com.shine.niceapp.ui.widget; 2 | 3 | import android.content.Context; 4 | import android.text.Html; 5 | import android.text.Layout; 6 | import android.text.SpannableStringBuilder; 7 | import android.text.StaticLayout; 8 | import android.text.TextPaint; 9 | import android.util.AttributeSet; 10 | import android.view.MotionEvent; 11 | import android.widget.TextView; 12 | 13 | public class HtmlTextView extends TextView { 14 | boolean dontConsumeNonUrlClicks = true; 15 | boolean linkHit; 16 | private String mEllipsis = "..."; 17 | private boolean mNeedsResize = false; 18 | 19 | public HtmlTextView(Context paramContext) { 20 | super(paramContext); 21 | } 22 | 23 | public HtmlTextView(Context paramContext, AttributeSet paramAttributeSet) { 24 | super(paramContext, paramAttributeSet); 25 | } 26 | 27 | public HtmlTextView(Context paramContext, AttributeSet paramAttributeSet, int paramInt) { 28 | super(paramContext, paramAttributeSet, paramInt); 29 | } 30 | 31 | protected void onLayout(boolean paramBoolean, int paramInt1, int paramInt2, int paramInt3, int paramInt4) { 32 | if ((paramBoolean) || (this.mNeedsResize)) 33 | resizeText(paramInt3 - paramInt1 - getCompoundPaddingLeft() - getCompoundPaddingRight(), paramInt4 - paramInt2 - getCompoundPaddingBottom() - getCompoundPaddingTop()); 34 | super.onLayout(paramBoolean, paramInt1, paramInt2, paramInt3, paramInt4); 35 | } 36 | 37 | protected void onSizeChanged(int paramInt1, int paramInt2, int paramInt3, int paramInt4) { 38 | if ((paramInt1 != paramInt3) || (paramInt2 != paramInt4)) 39 | this.mNeedsResize = true; 40 | } 41 | 42 | public boolean onTouchEvent(MotionEvent paramMotionEvent) { 43 | this.linkHit = false; 44 | boolean bool = super.onTouchEvent(paramMotionEvent); 45 | if (this.dontConsumeNonUrlClicks) 46 | bool = this.linkHit; 47 | return bool; 48 | } 49 | 50 | public void resizeText() { 51 | int i = getHeight() - getPaddingBottom() - getPaddingTop(); 52 | resizeText(getWidth() - getPaddingLeft() - getPaddingRight(), i); 53 | } 54 | 55 | public void resizeText(int paramInt1, int paramInt2) { 56 | CharSequence localCharSequence = getText(); 57 | if ((localCharSequence == null) || (localCharSequence.length() == 0) || (paramInt2 <= 0) || (paramInt1 <= 0)) 58 | return; 59 | TextPaint localTextPaint = getPaint(); 60 | StaticLayout localStaticLayout = new StaticLayout(localCharSequence, localTextPaint, paramInt1, Layout.Alignment.ALIGN_NORMAL, 1.25F, 0.0F, true); 61 | int i = localStaticLayout.getLineCount(); 62 | int j = paramInt2 / (localStaticLayout.getHeight() / i); 63 | if (i > j) { 64 | int k = localStaticLayout.getLineStart(j - 1); 65 | int m = localStaticLayout.getLineEnd(j - 1); 66 | float f1 = localStaticLayout.getLineWidth(j - 1); 67 | float f2 = localTextPaint.measureText(this.mEllipsis); 68 | while (paramInt1 < f1 + f2) { 69 | m--; 70 | f1 = localTextPaint.measureText(localCharSequence.subSequence(k, m + 1).toString()); 71 | } 72 | setText(localCharSequence.subSequence(0, m) + this.mEllipsis); 73 | } 74 | setMaxLines(j); 75 | this.mNeedsResize = false; 76 | } 77 | 78 | public void setTextViewHtml(String paramString) { 79 | setText(new SpannableStringBuilder(Html.fromHtml(paramString))); 80 | } 81 | } -------------------------------------------------------------------------------- /NiceApp/app/src/main/java/com/shine/niceapp/ui/widget/ProgressHUD.java: -------------------------------------------------------------------------------- 1 | package com.shine.niceapp.ui.widget; 2 | 3 | import android.app.Dialog; 4 | import android.content.Context; 5 | import android.content.DialogInterface; 6 | import android.graphics.drawable.AnimationDrawable; 7 | import android.graphics.drawable.Drawable; 8 | import android.view.View; 9 | import android.view.WindowManager; 10 | import android.widget.ImageView; 11 | import android.widget.TextView; 12 | 13 | import com.shine.niceapp.R; 14 | 15 | 16 | public class ProgressHUD extends Dialog { 17 | private int drawableId; 18 | private ImageView imageView; 19 | 20 | public ProgressHUD(Context paramContext) { 21 | super(paramContext); 22 | } 23 | 24 | public ProgressHUD(Context paramContext, int paramInt) { 25 | super(paramContext, paramInt); 26 | } 27 | 28 | public static void safeDismiss(Dialog paramDialog) { 29 | if (paramDialog != null) ; 30 | try { 31 | paramDialog.dismiss(); 32 | return; 33 | } catch (Exception localException) { 34 | localException.printStackTrace(); 35 | } 36 | } 37 | 38 | public static ProgressHUD show(Context context, CharSequence textCharSequence, int drawableRes, boolean isCancelable, DialogInterface.OnCancelListener onCancelListener) { 39 | ProgressHUD progressHUD = new ProgressHUD(context, R.style.ProgressHUD); 40 | progressHUD.drawableId = drawableRes; 41 | progressHUD.setTitle(""); 42 | progressHUD.setContentView(R.layout.progress_hud); 43 | if ((textCharSequence == null) || (textCharSequence.length() == 0)) 44 | progressHUD.findViewById(R.id.text_message).setVisibility(View.GONE); 45 | else { 46 | progressHUD.imageView = ((ImageView) progressHUD.findViewById(R.id.image_spinner)); 47 | progressHUD.setCancelable(isCancelable); 48 | progressHUD.setOnCancelListener(onCancelListener); 49 | progressHUD.getWindow().getAttributes().gravity = 17; 50 | WindowManager.LayoutParams localLayoutParams = progressHUD.getWindow().getAttributes(); 51 | localLayoutParams.dimAmount = 0.2F; 52 | progressHUD.getWindow().setAttributes(localLayoutParams); 53 | ((TextView) progressHUD.findViewById(R.id.text_message)).setText(textCharSequence); 54 | progressHUD.show(); 55 | } 56 | return progressHUD; 57 | } 58 | 59 | public void onWindowFocusChanged(boolean paramBoolean) { 60 | Drawable localDrawable = getContext().getResources().getDrawable(this.drawableId); 61 | this.imageView.setBackgroundDrawable(localDrawable); 62 | if ((localDrawable instanceof AnimationDrawable)) 63 | ((AnimationDrawable) this.imageView.getBackground()).start(); 64 | } 65 | 66 | public void setMessage(CharSequence paramCharSequence) { 67 | if ((paramCharSequence != null) && (paramCharSequence.length() > 0)) { 68 | TextView msgTv = (TextView) findViewById(R.id.text_message); 69 | msgTv.setVisibility(View.VISIBLE); 70 | msgTv.setText(paramCharSequence); 71 | msgTv.invalidate(); 72 | } 73 | } 74 | 75 | public void setSpinnerImage(int drawableRes) { 76 | if (drawableRes <= 0) { 77 | return; 78 | } 79 | Drawable localDrawable; 80 | this.drawableId = drawableRes; 81 | if ((this.imageView.getBackground() instanceof AnimationDrawable)) 82 | ((AnimationDrawable) this.imageView.getBackground()).stop(); 83 | this.imageView.setBackgroundResource(drawableRes); 84 | this.imageView.invalidate(); 85 | localDrawable = getContext().getResources().getDrawable(drawableRes); 86 | if (!(localDrawable instanceof AnimationDrawable)) 87 | ((AnimationDrawable) localDrawable).start(); 88 | } 89 | } -------------------------------------------------------------------------------- /NiceApp/app/src/main/java/com/shine/niceapp/utils/AnimatorUtils.java: -------------------------------------------------------------------------------- 1 | package com.shine.niceapp.utils; 2 | 3 | import android.animation.Animator; 4 | import android.animation.ArgbEvaluator; 5 | import android.animation.ObjectAnimator; 6 | import android.view.View; 7 | import android.view.animation.AccelerateDecelerateInterpolator; 8 | import android.view.animation.OvershootInterpolator; 9 | 10 | 11 | public class AnimatorUtils { 12 | public static Animator animViewFadeIn(View paramView) { 13 | return animViewFadeIn(paramView, 200L, null); 14 | } 15 | 16 | public static Animator animViewFadeIn(View paramView, long paramLong, Animator.AnimatorListener paramAnimatorListener) { 17 | ObjectAnimator localObjectAnimator = ObjectAnimator.ofFloat(paramView, "alpha", new float[]{0.0F, 1.0F}); 18 | localObjectAnimator.setDuration(paramLong); 19 | if (paramAnimatorListener != null) 20 | localObjectAnimator.addListener(paramAnimatorListener); 21 | localObjectAnimator.start(); 22 | return localObjectAnimator; 23 | } 24 | 25 | public static Animator animViewFadeOut(View paramView) { 26 | return animViewFadeOut(paramView, 200L, null); 27 | } 28 | 29 | public static Animator animViewFadeOut(View paramView, long paramLong, Animator.AnimatorListener paramAnimatorListener) { 30 | ObjectAnimator localObjectAnimator = ObjectAnimator.ofFloat(paramView, "alpha", new float[]{1.0F, 0.0F}); 31 | localObjectAnimator.setDuration(paramLong); 32 | if (paramAnimatorListener != null) 33 | localObjectAnimator.addListener(paramAnimatorListener); 34 | localObjectAnimator.start(); 35 | return localObjectAnimator; 36 | } 37 | 38 | 39 | /** 40 | * 移动ScrollView的x轴 41 | * 42 | * @param view 要移动的ScrollView 43 | * @param toX 要移动到的X轴坐标 44 | * @param time 动画持续时间 45 | * @param delayTime 延迟开始动画的时间 46 | * @param isStart 是否开始动画 47 | * @return 48 | */ 49 | public static Animator moveScrollViewToX(View view, int toX, int time, int delayTime, boolean isStart) { 50 | ObjectAnimator objectAnimator = ObjectAnimator.ofInt(view, "scrollX", new int[]{toX}); 51 | objectAnimator.setDuration(time); 52 | objectAnimator.setInterpolator(new AccelerateDecelerateInterpolator()); 53 | objectAnimator.setStartDelay(delayTime); 54 | if (isStart) 55 | objectAnimator.start(); 56 | return objectAnimator; 57 | } 58 | 59 | /** 60 | * 将View的背景颜色更改,使背景颜色转换更和谐的过渡动画 61 | * 62 | * @param view 要改变背景颜色的View 63 | * @param preColor 上个颜色值 64 | * @param currColor 当前颜色值 65 | * @param duration 动画持续时间 66 | */ 67 | public static void showBackgroundColorAnimation(View view, int preColor, int currColor, int duration) { 68 | ObjectAnimator animator = ObjectAnimator.ofInt(view, "backgroundColor", new int[]{preColor, currColor}); 69 | animator.setDuration(duration); 70 | animator.setEvaluator(new ArgbEvaluator()); 71 | animator.start(); 72 | } 73 | 74 | /** 75 | * @param view 需要设置动画的view 76 | * @param translationY 偏移量 77 | * @param animatorTime 动画时间 78 | * @param isStartAnimator 是否开启指示器 79 | * @param isStartInterpolator 是否开始动画 80 | * @return 平移动画 81 | */ 82 | public static Animator showUpAndDownBounce(View view, int translationY, int animatorTime, boolean isStartAnimator, boolean isStartInterpolator) { 83 | ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(view, "translationY", translationY); 84 | if (isStartInterpolator) { 85 | objectAnimator.setInterpolator(new OvershootInterpolator()); 86 | } 87 | objectAnimator.setDuration(animatorTime); 88 | if (isStartAnimator) { 89 | objectAnimator.start(); 90 | } 91 | return objectAnimator; 92 | } 93 | 94 | } -------------------------------------------------------------------------------- /NiceApp/app/src/main/java/com/shine/niceapp/utils/AppUtils.java: -------------------------------------------------------------------------------- 1 | package com.shine.niceapp.utils; 2 | 3 | import android.app.Activity; 4 | import android.content.Context; 5 | import android.util.DisplayMetrics; 6 | 7 | /** 8 | * User: huangruimin 9 | * Date: 2014-12-12 10 | * Time: 10:34 11 | * Description: 12 | */ 13 | public class AppUtils { 14 | public static DisplayMetrics getScreenDisplayMetrics(Context context) { 15 | DisplayMetrics localDisplayMetrics = new DisplayMetrics(); 16 | ((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(localDisplayMetrics); 17 | return localDisplayMetrics; 18 | } 19 | 20 | public static int getDrawableIdByName(Context context, String drawableName) { 21 | 22 | return context.getResources().getIdentifier(drawableName, "drawable", context.getPackageName()); 23 | } 24 | 25 | 26 | } 27 | -------------------------------------------------------------------------------- /NiceApp/app/src/main/java/com/shine/niceapp/utils/HexUtils.java: -------------------------------------------------------------------------------- 1 | package com.shine.niceapp.utils; 2 | 3 | import android.graphics.Color; 4 | 5 | public class HexUtils { 6 | public static String byte2HexStr(byte[] paramArrayOfByte) { 7 | StringBuilder localStringBuilder = new StringBuilder(""); 8 | int i = 0; 9 | if (i < paramArrayOfByte.length) { 10 | String str1 = Integer.toHexString(0xFF & paramArrayOfByte[i]); 11 | if (str1.length() == 1) ; 12 | for (String str2 = "0" + str1; ; str2 = str1) { 13 | localStringBuilder.append(str2); 14 | localStringBuilder.append(" "); 15 | i++; 16 | break; 17 | } 18 | } 19 | return localStringBuilder.toString().toUpperCase().trim(); 20 | } 21 | 22 | public static int getHexColor(String paramString) { 23 | int i = Long.decode("0xFF8080FF").intValue(); 24 | try { 25 | int j = Color.parseColor(paramString); 26 | return j; 27 | } catch (Exception localException) { 28 | } 29 | return i; 30 | } 31 | 32 | public static byte[] hexStr2Bytes(String paramString) { 33 | int i = paramString.length() / 2; 34 | System.out.println(i); 35 | byte[] arrayOfByte = new byte[i]; 36 | for (int j = 0; j < i; j++) { 37 | int k = 1 + j * 2; 38 | int m = k + 1; 39 | arrayOfByte[j] = Byte.decode("0x" + paramString.substring(j * 2, k) + paramString.substring(k, m)).byteValue(); 40 | } 41 | return arrayOfByte; 42 | } 43 | 44 | public static String strToUnicode(String paramString) 45 | throws Exception { 46 | StringBuilder localStringBuilder = new StringBuilder(); 47 | int i = 0; 48 | if (i < paramString.length()) { 49 | int j = paramString.charAt(i); 50 | String str = Integer.toHexString(j); 51 | if (j > 128) 52 | localStringBuilder.append("\\u" + str); 53 | else { 54 | i++; 55 | localStringBuilder.append("\\u00" + str); 56 | } 57 | } 58 | return localStringBuilder.toString(); 59 | } 60 | 61 | 62 | public static String unicodeToString(String paramString) { 63 | int i = paramString.length() / 6; 64 | StringBuilder localStringBuilder = new StringBuilder(); 65 | for (int j = 0; j < i; j++) { 66 | String str1 = paramString.substring(j * 6, 6 * (j + 1)); 67 | String str2 = str1.substring(2, 4) + "00"; 68 | String str3 = str1.substring(4); 69 | localStringBuilder.append(new String(Character.toChars(Integer.valueOf(str2, 16).intValue() + Integer.valueOf(str3, 16).intValue()))); 70 | } 71 | return localStringBuilder.toString(); 72 | } 73 | } -------------------------------------------------------------------------------- /NiceApp/app/src/main/java/com/shine/niceapp/utils/LogUtil.java: -------------------------------------------------------------------------------- 1 | package com.shine.niceapp.utils; 2 | 3 | import android.util.Log; 4 | 5 | public class LogUtil { 6 | public static int DEBUG; 7 | public static int ERROR; 8 | public static int INFO; 9 | public static int VERBOSE = 1; 10 | public static int WARN; 11 | private static boolean isLog; 12 | private static int level; 13 | 14 | static { 15 | DEBUG = 2; 16 | INFO = 3; 17 | WARN = 4; 18 | ERROR = 5; 19 | level = VERBOSE; 20 | isLog = true; 21 | } 22 | 23 | public static void d(String paramString) { 24 | if ((isPrintLog()) && (level <= DEBUG)) 25 | Log.d("LogUtil", paramString + ""); 26 | } 27 | 28 | public static void d(String paramString1, String paramString2) { 29 | if ((isPrintLog()) && (level <= DEBUG)) 30 | Log.d(paramString1, paramString2 + ""); 31 | } 32 | 33 | public static void e(String paramString) { 34 | if ((isPrintLog()) && (level <= ERROR)) 35 | Log.e("LogUtil", paramString + ""); 36 | } 37 | 38 | public static void e(String paramString1, String paramString2) { 39 | if ((isPrintLog()) && (level <= ERROR)) 40 | Log.e(paramString1, paramString2 + ""); 41 | } 42 | 43 | public static void e(String paramString, Throwable paramThrowable) { 44 | if ((isPrintLog()) && (level <= ERROR)) 45 | Log.e("LogUtil", paramString + "", paramThrowable); 46 | } 47 | 48 | public static void i(String paramString) { 49 | if ((isPrintLog()) && (level <= INFO)) 50 | Log.i("LogUtil", paramString + ""); 51 | } 52 | 53 | public static void i(String paramString1, String paramString2) { 54 | if ((isPrintLog()) && (level <= INFO)) 55 | Log.i(paramString1, paramString2 + ""); 56 | } 57 | 58 | public static boolean isPrintLog() { 59 | return isLog; 60 | } 61 | 62 | public static void v(String paramString) { 63 | if ((isPrintLog()) && (level <= VERBOSE)) 64 | Log.v("LogUtil", paramString + ""); 65 | } 66 | 67 | public static void v(String paramString1, String paramString2) { 68 | if ((isPrintLog()) && (level <= VERBOSE)) 69 | Log.v(paramString1, paramString2 + ""); 70 | } 71 | 72 | public static void w(String paramString) { 73 | if ((isPrintLog()) && (level <= WARN)) 74 | Log.w("LogUtil", paramString + ""); 75 | } 76 | 77 | public static void w(String paramString1, String paramString2) { 78 | if ((isPrintLog()) && (level <= WARN)) 79 | Log.w(paramString1, paramString2 + ""); 80 | } 81 | } -------------------------------------------------------------------------------- /NiceApp/app/src/main/java/com/shine/niceapp/utils/NetWorkHelper.java: -------------------------------------------------------------------------------- 1 | package com.shine.niceapp.utils; 2 | 3 | import android.content.Context; 4 | import android.net.ConnectivityManager; 5 | import android.net.Uri; 6 | 7 | public class NetWorkHelper { 8 | private static String LOG_TAG = "NetWorkHelper"; 9 | public static Uri uri = Uri.parse("content://telephony/carriers"); 10 | 11 | public static boolean isMobileDataEnable(Context paramContext) 12 | throws Exception { 13 | return ((ConnectivityManager) paramContext.getSystemService(Context.CONNECTIVITY_SERVICE)).getNetworkInfo(0).isConnectedOrConnecting(); 14 | } 15 | 16 | 17 | public static boolean isWifiDataEnable(Context paramContext) { 18 | try { 19 | boolean bool = ((ConnectivityManager) paramContext.getSystemService(Context.CONNECTIVITY_SERVICE)).getNetworkInfo(ConnectivityManager.TYPE_WIFI).isConnectedOrConnecting(); 20 | return bool; 21 | } catch (Exception e) { 22 | e.printStackTrace(); 23 | } 24 | return false; 25 | } 26 | 27 | 28 | } -------------------------------------------------------------------------------- /NiceApp/app/src/main/java/com/shine/niceapp/utils/PreferenceUtils.java: -------------------------------------------------------------------------------- 1 | 2 | package com.shine.niceapp.utils; 3 | 4 | import android.content.Context; 5 | import android.content.SharedPreferences; 6 | import android.content.SharedPreferences.Editor; 7 | import android.preference.PreferenceManager; 8 | 9 | public class PreferenceUtils { 10 | public static String getPrefString(Context context, String key, final String defaultValue) { 11 | final SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context); 12 | return settings.getString(key, defaultValue); 13 | } 14 | 15 | public static void setPrefString(Context context, final String key, final String value) { 16 | final SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context); 17 | settings.edit().putString(key, value).commit(); 18 | } 19 | 20 | public static boolean getPrefBoolean(Context context, final String key, 21 | final boolean defaultValue) { 22 | final SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context); 23 | return settings.getBoolean(key, defaultValue); 24 | } 25 | 26 | public static boolean hasKey(Context context, final String key) { 27 | return PreferenceManager.getDefaultSharedPreferences(context).contains(key); 28 | } 29 | 30 | public static void setPrefBoolean(Context context, final String key, final boolean value) { 31 | final SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context); 32 | settings.edit().putBoolean(key, value).commit(); 33 | } 34 | 35 | public static void setPrefInt(Context context, final String key, final int value) { 36 | final SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context); 37 | settings.edit().putInt(key, value).commit(); 38 | } 39 | 40 | public static int getPrefInt(Context context, final String key, final int defaultValue) { 41 | final SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context); 42 | return settings.getInt(key, defaultValue); 43 | } 44 | 45 | public static void setPrefFloat(Context context, final String key, final float value) { 46 | final SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context); 47 | settings.edit().putFloat(key, value).commit(); 48 | } 49 | 50 | public static float getPrefFloat(Context context, final String key, final float defaultValue) { 51 | final SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context); 52 | return settings.getFloat(key, defaultValue); 53 | } 54 | 55 | public static void setSettingLong(Context context, final String key, final long value) { 56 | final SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context); 57 | settings.edit().putLong(key, value).commit(); 58 | } 59 | 60 | public static long getPrefLong(Context context, final String key, final long defaultValue) { 61 | final SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context); 62 | return settings.getLong(key, defaultValue); 63 | } 64 | 65 | public static void clearPreference(Context context, final SharedPreferences p) { 66 | final Editor editor = p.edit(); 67 | editor.clear(); 68 | editor.commit(); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /NiceApp/app/src/main/res/anim/slide_in_from_bottom.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 22 | -------------------------------------------------------------------------------- /NiceApp/app/src/main/res/anim/slide_in_from_top.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 22 | -------------------------------------------------------------------------------- /NiceApp/app/src/main/res/anim/slide_out_to_bottom.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 22 | -------------------------------------------------------------------------------- /NiceApp/app/src/main/res/anim/slide_out_to_top.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 22 | -------------------------------------------------------------------------------- /NiceApp/app/src/main/res/anim/spinner.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /NiceApp/app/src/main/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaoKunGitHub/NiceAppDemo/b6060b79c245044e237fbd09141aa9f750744176/NiceApp/app/src/main/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /NiceApp/app/src/main/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaoKunGitHub/NiceAppDemo/b6060b79c245044e237fbd09141aa9f750744176/NiceApp/app/src/main/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /NiceApp/app/src/main/res/drawable-xhdpi/backtohome_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaoKunGitHub/NiceAppDemo/b6060b79c245044e237fbd09141aa9f750744176/NiceApp/app/src/main/res/drawable-xhdpi/backtohome_normal.png -------------------------------------------------------------------------------- /NiceApp/app/src/main/res/drawable-xhdpi/backtohome_pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaoKunGitHub/NiceAppDemo/b6060b79c245044e237fbd09141aa9f750744176/NiceApp/app/src/main/res/drawable-xhdpi/backtohome_pressed.png -------------------------------------------------------------------------------- /NiceApp/app/src/main/res/drawable-xhdpi/card_cover1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaoKunGitHub/NiceAppDemo/b6060b79c245044e237fbd09141aa9f750744176/NiceApp/app/src/main/res/drawable-xhdpi/card_cover1.png -------------------------------------------------------------------------------- /NiceApp/app/src/main/res/drawable-xhdpi/card_cover2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaoKunGitHub/NiceAppDemo/b6060b79c245044e237fbd09141aa9f750744176/NiceApp/app/src/main/res/drawable-xhdpi/card_cover2.png -------------------------------------------------------------------------------- /NiceApp/app/src/main/res/drawable-xhdpi/card_cover3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaoKunGitHub/NiceAppDemo/b6060b79c245044e237fbd09141aa9f750744176/NiceApp/app/src/main/res/drawable-xhdpi/card_cover3.png -------------------------------------------------------------------------------- /NiceApp/app/src/main/res/drawable-xhdpi/card_cover4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaoKunGitHub/NiceAppDemo/b6060b79c245044e237fbd09141aa9f750744176/NiceApp/app/src/main/res/drawable-xhdpi/card_cover4.png -------------------------------------------------------------------------------- /NiceApp/app/src/main/res/drawable-xhdpi/card_cover5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaoKunGitHub/NiceAppDemo/b6060b79c245044e237fbd09141aa9f750744176/NiceApp/app/src/main/res/drawable-xhdpi/card_cover5.png -------------------------------------------------------------------------------- /NiceApp/app/src/main/res/drawable-xhdpi/card_cover6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaoKunGitHub/NiceAppDemo/b6060b79c245044e237fbd09141aa9f750744176/NiceApp/app/src/main/res/drawable-xhdpi/card_cover6.png -------------------------------------------------------------------------------- /NiceApp/app/src/main/res/drawable-xhdpi/card_cover7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaoKunGitHub/NiceAppDemo/b6060b79c245044e237fbd09141aa9f750744176/NiceApp/app/src/main/res/drawable-xhdpi/card_cover7.png -------------------------------------------------------------------------------- /NiceApp/app/src/main/res/drawable-xhdpi/card_cover8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaoKunGitHub/NiceAppDemo/b6060b79c245044e237fbd09141aa9f750744176/NiceApp/app/src/main/res/drawable-xhdpi/card_cover8.png -------------------------------------------------------------------------------- /NiceApp/app/src/main/res/drawable-xhdpi/card_flower.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaoKunGitHub/NiceAppDemo/b6060b79c245044e237fbd09141aa9f750744176/NiceApp/app/src/main/res/drawable-xhdpi/card_flower.png -------------------------------------------------------------------------------- /NiceApp/app/src/main/res/drawable-xhdpi/card_flower_bg.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaoKunGitHub/NiceAppDemo/b6060b79c245044e237fbd09141aa9f750744176/NiceApp/app/src/main/res/drawable-xhdpi/card_flower_bg.9.png -------------------------------------------------------------------------------- /NiceApp/app/src/main/res/drawable-xhdpi/card_icon1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaoKunGitHub/NiceAppDemo/b6060b79c245044e237fbd09141aa9f750744176/NiceApp/app/src/main/res/drawable-xhdpi/card_icon1.png -------------------------------------------------------------------------------- /NiceApp/app/src/main/res/drawable-xhdpi/card_icon2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaoKunGitHub/NiceAppDemo/b6060b79c245044e237fbd09141aa9f750744176/NiceApp/app/src/main/res/drawable-xhdpi/card_icon2.png -------------------------------------------------------------------------------- /NiceApp/app/src/main/res/drawable-xhdpi/card_icon3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaoKunGitHub/NiceAppDemo/b6060b79c245044e237fbd09141aa9f750744176/NiceApp/app/src/main/res/drawable-xhdpi/card_icon3.png -------------------------------------------------------------------------------- /NiceApp/app/src/main/res/drawable-xhdpi/card_icon4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaoKunGitHub/NiceAppDemo/b6060b79c245044e237fbd09141aa9f750744176/NiceApp/app/src/main/res/drawable-xhdpi/card_icon4.png -------------------------------------------------------------------------------- /NiceApp/app/src/main/res/drawable-xhdpi/card_icon5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaoKunGitHub/NiceAppDemo/b6060b79c245044e237fbd09141aa9f750744176/NiceApp/app/src/main/res/drawable-xhdpi/card_icon5.png -------------------------------------------------------------------------------- /NiceApp/app/src/main/res/drawable-xhdpi/card_icon6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaoKunGitHub/NiceAppDemo/b6060b79c245044e237fbd09141aa9f750744176/NiceApp/app/src/main/res/drawable-xhdpi/card_icon6.png -------------------------------------------------------------------------------- /NiceApp/app/src/main/res/drawable-xhdpi/card_icon7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaoKunGitHub/NiceAppDemo/b6060b79c245044e237fbd09141aa9f750744176/NiceApp/app/src/main/res/drawable-xhdpi/card_icon7.png -------------------------------------------------------------------------------- /NiceApp/app/src/main/res/drawable-xhdpi/card_icon8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaoKunGitHub/NiceAppDemo/b6060b79c245044e237fbd09141aa9f750744176/NiceApp/app/src/main/res/drawable-xhdpi/card_icon8.png -------------------------------------------------------------------------------- /NiceApp/app/src/main/res/drawable-xhdpi/common_logo_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaoKunGitHub/NiceAppDemo/b6060b79c245044e237fbd09141aa9f750744176/NiceApp/app/src/main/res/drawable-xhdpi/common_logo_normal.png -------------------------------------------------------------------------------- /NiceApp/app/src/main/res/drawable-xhdpi/common_logo_pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaoKunGitHub/NiceAppDemo/b6060b79c245044e237fbd09141aa9f750744176/NiceApp/app/src/main/res/drawable-xhdpi/common_logo_pressed.png -------------------------------------------------------------------------------- /NiceApp/app/src/main/res/drawable-xhdpi/default_ptr_flip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaoKunGitHub/NiceAppDemo/b6060b79c245044e237fbd09141aa9f750744176/NiceApp/app/src/main/res/drawable-xhdpi/default_ptr_flip.png -------------------------------------------------------------------------------- /NiceApp/app/src/main/res/drawable-xhdpi/default_ptr_rotate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaoKunGitHub/NiceAppDemo/b6060b79c245044e237fbd09141aa9f750744176/NiceApp/app/src/main/res/drawable-xhdpi/default_ptr_rotate.png -------------------------------------------------------------------------------- /NiceApp/app/src/main/res/drawable-xhdpi/home_card_bg.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaoKunGitHub/NiceAppDemo/b6060b79c245044e237fbd09141aa9f750744176/NiceApp/app/src/main/res/drawable-xhdpi/home_card_bg.9.png -------------------------------------------------------------------------------- /NiceApp/app/src/main/res/drawable-xhdpi/home_icon_bg.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaoKunGitHub/NiceAppDemo/b6060b79c245044e237fbd09141aa9f750744176/NiceApp/app/src/main/res/drawable-xhdpi/home_icon_bg.9.png -------------------------------------------------------------------------------- /NiceApp/app/src/main/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaoKunGitHub/NiceAppDemo/b6060b79c245044e237fbd09141aa9f750744176/NiceApp/app/src/main/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /NiceApp/app/src/main/res/drawable-xhdpi/indicator_arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaoKunGitHub/NiceAppDemo/b6060b79c245044e237fbd09141aa9f750744176/NiceApp/app/src/main/res/drawable-xhdpi/indicator_arrow.png -------------------------------------------------------------------------------- /NiceApp/app/src/main/res/drawable-xhdpi/shadow_bottom.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaoKunGitHub/NiceAppDemo/b6060b79c245044e237fbd09141aa9f750744176/NiceApp/app/src/main/res/drawable-xhdpi/shadow_bottom.png -------------------------------------------------------------------------------- /NiceApp/app/src/main/res/drawable-xhdpi/shadow_left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaoKunGitHub/NiceAppDemo/b6060b79c245044e237fbd09141aa9f750744176/NiceApp/app/src/main/res/drawable-xhdpi/shadow_left.png -------------------------------------------------------------------------------- /NiceApp/app/src/main/res/drawable-xhdpi/shadow_right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaoKunGitHub/NiceAppDemo/b6060b79c245044e237fbd09141aa9f750744176/NiceApp/app/src/main/res/drawable-xhdpi/shadow_right.png -------------------------------------------------------------------------------- /NiceApp/app/src/main/res/drawable-xhdpi/subject_bg.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaoKunGitHub/NiceAppDemo/b6060b79c245044e237fbd09141aa9f750744176/NiceApp/app/src/main/res/drawable-xhdpi/subject_bg.9.png -------------------------------------------------------------------------------- /NiceApp/app/src/main/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaoKunGitHub/NiceAppDemo/b6060b79c245044e237fbd09141aa9f750744176/NiceApp/app/src/main/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /NiceApp/app/src/main/res/drawable-xxhdpi/loading_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaoKunGitHub/NiceAppDemo/b6060b79c245044e237fbd09141aa9f750744176/NiceApp/app/src/main/res/drawable-xxhdpi/loading_1.png -------------------------------------------------------------------------------- /NiceApp/app/src/main/res/drawable-xxhdpi/loading_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaoKunGitHub/NiceAppDemo/b6060b79c245044e237fbd09141aa9f750744176/NiceApp/app/src/main/res/drawable-xxhdpi/loading_2.png -------------------------------------------------------------------------------- /NiceApp/app/src/main/res/drawable-xxhdpi/loading_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaoKunGitHub/NiceAppDemo/b6060b79c245044e237fbd09141aa9f750744176/NiceApp/app/src/main/res/drawable-xxhdpi/loading_3.png -------------------------------------------------------------------------------- /NiceApp/app/src/main/res/drawable-xxhdpi/loading_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaoKunGitHub/NiceAppDemo/b6060b79c245044e237fbd09141aa9f750744176/NiceApp/app/src/main/res/drawable-xxhdpi/loading_4.png -------------------------------------------------------------------------------- /NiceApp/app/src/main/res/drawable-xxhdpi/loading_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaoKunGitHub/NiceAppDemo/b6060b79c245044e237fbd09141aa9f750744176/NiceApp/app/src/main/res/drawable-xxhdpi/loading_5.png -------------------------------------------------------------------------------- /NiceApp/app/src/main/res/drawable-xxhdpi/loading_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaoKunGitHub/NiceAppDemo/b6060b79c245044e237fbd09141aa9f750744176/NiceApp/app/src/main/res/drawable-xxhdpi/loading_6.png -------------------------------------------------------------------------------- /NiceApp/app/src/main/res/drawable-xxhdpi/loading_7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaoKunGitHub/NiceAppDemo/b6060b79c245044e237fbd09141aa9f750744176/NiceApp/app/src/main/res/drawable-xxhdpi/loading_7.png -------------------------------------------------------------------------------- /NiceApp/app/src/main/res/drawable-xxhdpi/loading_8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaoKunGitHub/NiceAppDemo/b6060b79c245044e237fbd09141aa9f750744176/NiceApp/app/src/main/res/drawable-xxhdpi/loading_8.png -------------------------------------------------------------------------------- /NiceApp/app/src/main/res/drawable/btn_common_logo.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /NiceApp/app/src/main/res/drawable/btn_rocket_to_first.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /NiceApp/app/src/main/res/drawable/indicator_bg_bottom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 11 | 17 | 18 | -------------------------------------------------------------------------------- /NiceApp/app/src/main/res/drawable/indicator_bg_top.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 11 | 17 | 18 | -------------------------------------------------------------------------------- /NiceApp/app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /NiceApp/app/src/main/res/layout/adapter_rhythm_icon.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 13 | 14 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /NiceApp/app/src/main/res/layout/fragment_card.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 15 | 16 | 22 | 23 | 27 | 28 | 39 | 40 | 52 | 53 | 54 | 61 | 62 | 73 | 74 | 89 | 90 | 103 | 104 | -------------------------------------------------------------------------------- /NiceApp/app/src/main/res/layout/fragment_niceapp.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 |