├── packer.properties ├── .idea ├── .name ├── copyright │ └── profiles_settings.xml ├── vcs.xml ├── inspectionProfiles │ ├── profiles_settings.xml │ └── Project_Default.xml ├── modules.xml ├── runConfigurations.xml ├── gradle.xml ├── compiler.xml └── misc.xml ├── app ├── .gitignore ├── packer.properties ├── src │ ├── main │ │ ├── res │ │ │ ├── drawable │ │ │ │ ├── ic_avatar.png │ │ │ │ ├── ic_photo_24dp.xml │ │ │ │ └── ic_today_24dp.xml │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── values │ │ │ │ ├── ids.xml │ │ │ │ ├── styles.xml │ │ │ │ ├── colors.xml │ │ │ │ ├── dimens.xml │ │ │ │ └── strings.xml │ │ │ ├── values-w820dp │ │ │ │ └── dimens.xml │ │ │ ├── menu │ │ │ │ └── menu_home.xml │ │ │ ├── values-v21 │ │ │ │ └── styles.xml │ │ │ ├── layout │ │ │ │ ├── toolbar_pref.xml │ │ │ │ ├── activity_settings.xml │ │ │ │ ├── fragment_item_list.xml │ │ │ │ ├── activity_status.xml │ │ │ │ ├── activity_home.xml │ │ │ │ ├── card_list_item.xml │ │ │ │ └── card_status.xml │ │ │ ├── xml │ │ │ │ └── main_prefs.xml │ │ │ └── values-zh │ │ │ │ └── strings.xml │ │ ├── java │ │ │ └── io │ │ │ │ └── github │ │ │ │ └── anthonyeef │ │ │ │ └── fanfoudaily │ │ │ │ ├── ui │ │ │ │ ├── UIBase.java │ │ │ │ ├── UISettings.java │ │ │ │ ├── UIPreference.java │ │ │ │ ├── AppCompatPreferenceActivity.java │ │ │ │ ├── UIStatus.java │ │ │ │ └── UIHome.java │ │ │ │ ├── callbacks │ │ │ │ ├── FanfouLoadedListener.java │ │ │ │ └── RecyclerItemClickListener.java │ │ │ │ ├── model │ │ │ │ ├── Date.java │ │ │ │ └── Fanfou.java │ │ │ │ ├── extras │ │ │ │ ├── Constants.java │ │ │ │ ├── Keys.java │ │ │ │ └── FanfouUtils.java │ │ │ │ ├── Utils │ │ │ │ ├── UrlUtils.java │ │ │ │ ├── LogUtils.java │ │ │ │ ├── HttpUtils.java │ │ │ │ └── DateUtils.java │ │ │ │ ├── volley │ │ │ │ ├── VolleySingleton.java │ │ │ │ ├── Requestor.java │ │ │ │ └── Parser.java │ │ │ │ ├── adapter │ │ │ │ ├── PagerAdapter.java │ │ │ │ └── FanfouAdapter.java │ │ │ │ ├── fragment │ │ │ │ ├── FragmentSettings.java │ │ │ │ ├── FragmentWeekly.java │ │ │ │ └── FragmentDaily.java │ │ │ │ ├── animation │ │ │ │ └── ScrollAwareFABBehavior.java │ │ │ │ └── MyApplication.java │ │ └── AndroidManifest.xml │ ├── test │ │ └── java │ │ │ └── io │ │ │ └── github │ │ │ └── anthonyeef │ │ │ └── fanfoudaily │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── io │ │ └── github │ │ └── anthonyeef │ │ └── fanfoudaily │ │ └── ApplicationTest.java ├── proguard-rules.pro ├── build.gradle └── app.iml ├── settings.gradle ├── config └── markets.txt ├── screenshots ├── QRcode.png ├── ic_launcher.png ├── Screenshot_1.jpg ├── Screenshot_2.jpg └── Screenshot_3.jpg ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── gradle.properties ├── FanfouDaily.iml ├── README.md ├── gradlew.bat └── gradlew /packer.properties: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.idea/.name: -------------------------------------------------------------------------------- 1 | FanfouDaily -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /config/markets.txt: -------------------------------------------------------------------------------- 1 | Google_Play# play store market 2 | -------------------------------------------------------------------------------- /app/packer.properties: -------------------------------------------------------------------------------- 1 | #Sat Nov 07 22:47:22 CST 2015 2 | version=16 3 | -------------------------------------------------------------------------------- /screenshots/QRcode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Anthonyeef/FanfouDaily/HEAD/screenshots/QRcode.png -------------------------------------------------------------------------------- /screenshots/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Anthonyeef/FanfouDaily/HEAD/screenshots/ic_launcher.png -------------------------------------------------------------------------------- /screenshots/Screenshot_1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Anthonyeef/FanfouDaily/HEAD/screenshots/Screenshot_1.jpg -------------------------------------------------------------------------------- /screenshots/Screenshot_2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Anthonyeef/FanfouDaily/HEAD/screenshots/Screenshot_2.jpg -------------------------------------------------------------------------------- /screenshots/Screenshot_3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Anthonyeef/FanfouDaily/HEAD/screenshots/Screenshot_3.jpg -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Anthonyeef/FanfouDaily/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_avatar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Anthonyeef/FanfouDaily/HEAD/app/src/main/res/drawable/ic_avatar.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Anthonyeef/FanfouDaily/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Anthonyeef/FanfouDaily/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Anthonyeef/FanfouDaily/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Anthonyeef/FanfouDaily/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Anthonyeef/FanfouDaily/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/values/ids.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/anthonyeef/fanfoudaily/ui/UIBase.java: -------------------------------------------------------------------------------- 1 | package io.github.anthonyeef.fanfoudaily.ui; 2 | 3 | /** 4 | * Created by anthonyeef on 11/11/15. 5 | * Waiting to be done 6 | */ 7 | public class UIBase { 8 | } 9 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Oct 13 13:56:22 CST 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip 7 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/anthonyeef/fanfoudaily/callbacks/FanfouLoadedListener.java: -------------------------------------------------------------------------------- 1 | package io.github.anthonyeef.fanfoudaily.callbacks; 2 | 3 | import java.util.ArrayList; 4 | 5 | import io.github.anthonyeef.fanfoudaily.model.Fanfou; 6 | 7 | /** 8 | * Created by anthonyeef on 10/17/15. 9 | */ 10 | public interface FanfouLoadedListener { 11 | public void onFanfouLoaded(ArrayList fanfous); 12 | } 13 | -------------------------------------------------------------------------------- /app/src/test/java/io/github/anthonyeef/fanfoudaily/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package io.github.anthonyeef.fanfoudaily; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * To work on unit tests, switch the Test Artifact in the Build Variants view. 9 | */ 10 | public class ExampleUnitTest { 11 | @Test 12 | public void addition_isCorrect() throws Exception { 13 | assertEquals(4, 2 + 2); 14 | } 15 | } -------------------------------------------------------------------------------- /app/src/main/res/menu/menu_home.xml: -------------------------------------------------------------------------------- 1 | 5 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /app/src/androidTest/java/io/github/anthonyeef/fanfoudaily/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package io.github.anthonyeef.fanfoudaily; 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 | } -------------------------------------------------------------------------------- /app/src/main/java/io/github/anthonyeef/fanfoudaily/model/Date.java: -------------------------------------------------------------------------------- 1 | package io.github.anthonyeef.fanfoudaily.model; 2 | 3 | /** 4 | * Created by anthonyeef on 11/7/15. 5 | */ 6 | public class Date { 7 | private String sDate; 8 | 9 | public Date(String date) { 10 | this.sDate = date; 11 | } 12 | 13 | public String getDate() { 14 | return sDate; 15 | } 16 | 17 | public void setDate(String date) { 18 | this.sDate = date; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_photo_24dp.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_today_24dp.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #2196F3 4 | #1976D2 5 | #1E88E5 6 | 7 | #EEEEEE 8 | #ffffff 9 | 10 | #990000 11 | #FF9900 12 | #000099 13 | #009900 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/values-v21/styles.xml: -------------------------------------------------------------------------------- 1 | > 2 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/anthonyeef/fanfoudaily/extras/Constants.java: -------------------------------------------------------------------------------- 1 | package io.github.anthonyeef.fanfoudaily.extras; 2 | 3 | /** 4 | * Created by anthonyeef on 10/16/15. 5 | */ 6 | public class Constants { 7 | public static final String URL_BASE = "http://blog.fanfou.com/digest/json/"; 8 | public static final String URL_DAILY = ".daily"; 9 | public static final String URL_WEEKLY = ".weekly"; 10 | public static final String URL_END = ".json"; 11 | 12 | public static final String URL_TEMP = "2015-11-06"; 13 | public static final String URL_TEMP2 = "2015-11-02"; 14 | } 15 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/anthonyeef/fanfoudaily/Utils/UrlUtils.java: -------------------------------------------------------------------------------- 1 | package io.github.anthonyeef.fanfoudaily.Utils; 2 | 3 | import io.github.anthonyeef.fanfoudaily.extras.Constants; 4 | 5 | /** 6 | * Created by anthonyeef on 10/17/15. 7 | */ 8 | public class UrlUtils { 9 | public static String getRequestUrlHead() { 10 | return Constants.URL_BASE; 11 | } 12 | 13 | public static String getRequestUrlDailyEnd() { 14 | return Constants.URL_DAILY+Constants.URL_END; 15 | } 16 | public static String getRequestUrlWeeklyEnd() { 17 | return Constants.URL_WEEKLY+Constants.URL_END; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 16dp 6 | 7 | 3dp 8 | 1dp 9 | 10 | 52dp 11 | 52dp 12 | 13 | 16dp 14 | 16dp 15 | 5dp 16 | 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | /local.properties 3 | /.idea/workspace.xml 4 | /.idea/libraries 5 | .DS_Store 6 | /build 7 | /captures 8 | 9 | # Built application files 10 | *.apk 11 | *.ap_ 12 | 13 | # Files for the Dalvik VM 14 | *.dex 15 | 16 | # Java class files 17 | *.class 18 | 19 | # Generated files 20 | bin/ 21 | gen/ 22 | 23 | # Gradle files 24 | .gradle/ 25 | build/ 26 | 27 | # Local configuration file (sdk path, etc) 28 | local.properties 29 | 30 | # Proguard folder generated by Eclipse 31 | proguard/ 32 | 33 | # Log Files 34 | *.log 35 | 36 | # Android Studio Navigation editor temp files 37 | .navigation/ 38 | 39 | # Android Studio captures folder 40 | captures/ 41 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/anthonyeef/fanfoudaily/Utils/LogUtils.java: -------------------------------------------------------------------------------- 1 | package io.github.anthonyeef.fanfoudaily.Utils; 2 | 3 | import android.content.Context; 4 | import android.util.Log; 5 | import android.widget.Toast; 6 | 7 | /** 8 | * Created by anthonyeef on 10/17/15. 9 | */ 10 | public class LogUtils { 11 | public static void m(String message) { 12 | Log.d("FanfouDaily :", "" + message); 13 | } 14 | 15 | public static void t(Context context, String message) { 16 | Toast.makeText(context, message + "", Toast.LENGTH_SHORT).show(); 17 | } 18 | 19 | public static void T(Context context, String message) { 20 | Toast.makeText(context, message + "", Toast.LENGTH_LONG).show(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/anthonyeef/fanfoudaily/extras/Keys.java: -------------------------------------------------------------------------------- 1 | package io.github.anthonyeef.fanfoudaily.extras; 2 | 3 | /** 4 | * Created by anthonyeef on 10/16/15. 5 | */ 6 | public interface Keys { 7 | public interface ComeoutSomeKeys { 8 | public static final String KEY_ID = "id"; 9 | public static final String KEY_REALNAME = "realname"; 10 | public static final String KEY_LOGINNAME = "loginname"; 11 | public static final String KEY_AVATAR = "avatar"; 12 | public static final String KEY_TIME = "time"; 13 | public static final String KEY_MESSAGE = "msg"; 14 | public static final String KEY_IMG = "img"; 15 | public static final String KEY_PREVIEW = "preview"; 16 | 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /app/src/main/res/layout/toolbar_pref.xml: -------------------------------------------------------------------------------- 1 | 2 | 15 | 16 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 22 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/anthonyeef/fanfoudaily/Utils/HttpUtils.java: -------------------------------------------------------------------------------- 1 | package io.github.anthonyeef.fanfoudaily.Utils; 2 | import android.content.Context; 3 | import android.net.ConnectivityManager; 4 | import android.net.NetworkInfo; 5 | 6 | /** 7 | * Created by anthonyeef on 11/7/15. 8 | */ 9 | public class HttpUtils { 10 | 11 | public static boolean isNetworkConnected (Context context) { 12 | if (context != null) { 13 | ConnectivityManager manager = (ConnectivityManager) context 14 | .getSystemService(Context.CONNECTIVITY_SERVICE); 15 | NetworkInfo info = manager.getActiveNetworkInfo(); 16 | if (info != null) { 17 | return info.isAvailable(); 18 | } 19 | } 20 | return false; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 12 | 13 | 17 | 18 | -------------------------------------------------------------------------------- /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/anthonyeef/Library/Android/sdk/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 | 19 | -keepclassmembers class * implements android.os.Parcelable { 20 | static ** CREATOR; 21 | } -------------------------------------------------------------------------------- /app/src/main/java/io/github/anthonyeef/fanfoudaily/volley/VolleySingleton.java: -------------------------------------------------------------------------------- 1 | package io.github.anthonyeef.fanfoudaily.volley; 2 | 3 | import com.android.volley.RequestQueue; 4 | import com.android.volley.toolbox.Volley; 5 | 6 | import io.github.anthonyeef.fanfoudaily.MyApplication; 7 | 8 | /** 9 | * Created by anthonyeef on 10/17/15. 10 | */ 11 | public class VolleySingleton { 12 | public static VolleySingleton instance = null; 13 | private RequestQueue mRequestQueue; 14 | private VolleySingleton() { 15 | mRequestQueue = Volley.newRequestQueue(MyApplication.getAppContext()); 16 | } 17 | public static VolleySingleton getInstance() { 18 | if (instance == null) { 19 | instance = new VolleySingleton(); 20 | } 21 | return instance; 22 | } 23 | 24 | public RequestQueue getRequestQueue() { 25 | return mRequestQueue; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /FanfouDaily.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /app/src/main/res/xml/main_prefs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 10 | 11 | 14 | 16 | 17 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_item_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 14 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /app/src/main/res/values-zh/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 饭否精选 4 | 设置 5 | 正在加载该日饭否精选--> 6 | 请先检查下网络数据 7 | 8 | Screen Name 9 | Timestamp 10 | io.github.anthonyeef.fanfoudaily.animation.ScrollAwareFABBehavior 11 | 每日精选 12 | 每周精选 13 | 14 | 15 | 关于 16 | 项目主页 17 | 查看 GitHub repository 18 | 更新记录 19 | 开发者 20 | \u0040Anthonyeef 21 | 22 | https://anthonyeef.github.io 23 | https://anthonyeef.github.io/project/android/fanfoudaily 24 | https://github.com/Anthonyeef/FanfouDaily 25 | 26 | 27 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_status.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 14 | 15 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/anthonyeef/fanfoudaily/adapter/PagerAdapter.java: -------------------------------------------------------------------------------- 1 | package io.github.anthonyeef.fanfoudaily.adapter; 2 | 3 | import android.support.v4.app.Fragment; 4 | import android.support.v4.app.FragmentManager; 5 | import android.support.v4.app.FragmentPagerAdapter; 6 | 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | /** 11 | * Created by anthonyeef on 10/14/15. 12 | */ 13 | public class PagerAdapter extends FragmentPagerAdapter{ 14 | private final List mFragments = new ArrayList<>(); 15 | private final List mFragmentTitles = new ArrayList<>(); 16 | 17 | public PagerAdapter(FragmentManager fm) { 18 | super(fm); 19 | } 20 | 21 | public void addFragment(Fragment fragment, String title) { 22 | mFragments.add(fragment); 23 | mFragmentTitles.add(title); 24 | } 25 | 26 | @Override 27 | public Fragment getItem(int position) { 28 | return mFragments.get(position); 29 | } 30 | 31 | @Override 32 | public int getCount() { 33 | return mFragments.size(); 34 | } 35 | @Override 36 | public CharSequence getPageTitle(int position) { 37 | return mFragmentTitles.get(position); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | FanfouDaily 3 | Settings 4 | Loading Fanfou on date: 5 | Hey you don\'t have internet yet. 6 | 7 | Screen Name 8 | Timestamp 9 | Daily 10 | Weekly 11 | io.github.anthonyeef.fanfoudaily.animation.ScrollAwareFABBehavior 12 | 13 | 14 | About 15 | Visit FanfouDaily Homepage 16 | Check Github Repository 17 | Changelog 18 | Developer 19 | 20 | \u0040Anthonyeef 21 | 22 | https://anthonyeef.github.io 23 | https://anthonyeef.github.io/project/android/fanfoudaily 24 | https://github.com/Anthonyeef/FanfouDaily 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/anthonyeef/fanfoudaily/extras/FanfouUtils.java: -------------------------------------------------------------------------------- 1 | package io.github.anthonyeef.fanfoudaily.extras; 2 | 3 | import com.android.volley.RequestQueue; 4 | 5 | import org.json.JSONObject; 6 | 7 | import java.util.ArrayList; 8 | 9 | import io.github.anthonyeef.fanfoudaily.Utils.UrlUtils; 10 | import io.github.anthonyeef.fanfoudaily.model.Fanfou; 11 | import io.github.anthonyeef.fanfoudaily.volley.Parser; 12 | import io.github.anthonyeef.fanfoudaily.volley.Requestor; 13 | 14 | /** 15 | * Created by anthonyeef on 10/16/15. 16 | */ 17 | public class FanfouUtils { 18 | public static ArrayList loadFanfouDailyFeeds(RequestQueue requestQueue, String date) { 19 | JSONObject response = Requestor.requestJSON(requestQueue, UrlUtils.getRequestUrlHead() + date + UrlUtils.getRequestUrlDailyEnd()); 20 | ArrayList fanfous = Parser.parseFanfouJSON(response); 21 | 22 | return fanfous; 23 | } 24 | 25 | public static ArrayList loadFanfouWeeklyFeeds(RequestQueue requestQueue, String date) { 26 | 27 | JSONObject response = Requestor.requestJSON(requestQueue, UrlUtils.getRequestUrlHead() + date + UrlUtils.getRequestUrlWeeklyEnd()); 28 | ArrayList fanfous = Parser.parseFanfouJSON(response); 29 | 30 | return fanfous; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/anthonyeef/fanfoudaily/ui/UISettings.java: -------------------------------------------------------------------------------- 1 | package io.github.anthonyeef.fanfoudaily.ui; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.support.v7.widget.Toolbar; 6 | import android.view.View; 7 | 8 | import butterknife.Bind; 9 | import butterknife.ButterKnife; 10 | import io.github.anthonyeef.fanfoudaily.R; 11 | import io.github.anthonyeef.fanfoudaily.fragment.FragmentSettings; 12 | 13 | /** 14 | * Created by anthonyeef on 11/11/15. 15 | */ 16 | public class UISettings extends AppCompatActivity{ 17 | 18 | private FragmentSettings mFragment; 19 | @Bind(R.id.pref_toolbar) Toolbar mToolbar; 20 | 21 | @Override 22 | public void onCreate(Bundle savedInstanceState) { 23 | super.onCreate(savedInstanceState); 24 | ButterKnife.bind(this); 25 | 26 | setContentView(R.layout.activity_settings); 27 | setSupportActionBar(mToolbar); 28 | getSupportActionBar().setDisplayHomeAsUpEnabled(true); 29 | mToolbar.setTitle(R.string.action_settings); 30 | 31 | mToolbar.setNavigationOnClickListener(new View.OnClickListener() { 32 | @Override 33 | public void onClick(View v) { 34 | finish(); 35 | } 36 | }); 37 | 38 | 39 | getFragmentManager().beginTransaction() 40 | .replace(R.id.pref_container, mFragment) 41 | .commit(); 42 | 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/anthonyeef/fanfoudaily/Utils/DateUtils.java: -------------------------------------------------------------------------------- 1 | package io.github.anthonyeef.fanfoudaily.Utils; 2 | 3 | import java.text.SimpleDateFormat; 4 | import java.util.Calendar; 5 | 6 | /** 7 | * Created by anthonyeef on 11/7/15. 8 | */ 9 | public class DateUtils { 10 | public static SimpleDateFormat formator = new SimpleDateFormat("yyyy-MM-dd"); 11 | 12 | public static String getCurrentDate() { 13 | Calendar c = Calendar.getInstance(); 14 | // int hour = c.get(Calendar.HOUR); 15 | int hour = c.get(Calendar.HOUR_OF_DAY); 16 | if (hour == 8) { 17 | hour = 9; 18 | } 19 | 20 | if (hour < 8 && hour >= 0) { 21 | c.add(Calendar.DATE, -1); 22 | } 23 | return formator.format(c.getTime()); 24 | } 25 | 26 | public static String getCurrentMonday() { 27 | Calendar c = Calendar.getInstance(); 28 | 29 | int day = c.get(Calendar.DAY_OF_WEEK); 30 | LogUtils.m("Now is day:" + day); 31 | int hour = c.get(Calendar.HOUR_OF_DAY); 32 | LogUtils.m("Now is hour:" + hour); 33 | c.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY); 34 | 35 | if (day == 1) { 36 | c.add(Calendar.DAY_OF_WEEK, -7); 37 | } 38 | if (day == 2) { 39 | if (hour < 8 && hour >=0) { 40 | c.add(Calendar.DAY_OF_WEEK, -7); 41 | } 42 | } 43 | return formator.format(c.getTime()); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/anthonyeef/fanfoudaily/volley/Requestor.java: -------------------------------------------------------------------------------- 1 | package io.github.anthonyeef.fanfoudaily.volley; 2 | 3 | import com.android.volley.Request; 4 | import com.android.volley.RequestQueue; 5 | import com.android.volley.toolbox.JsonObjectRequest; 6 | import com.android.volley.toolbox.RequestFuture; 7 | 8 | import org.json.JSONObject; 9 | 10 | import java.util.concurrent.ExecutionException; 11 | import java.util.concurrent.TimeUnit; 12 | import java.util.concurrent.TimeoutException; 13 | 14 | import io.github.anthonyeef.fanfoudaily.Utils.LogUtils; 15 | 16 | /** 17 | * Created by anthonyeef on 10/16/15. 18 | */ 19 | 20 | public class Requestor { 21 | public static JSONObject requestJSON(RequestQueue requestQueue, String url) { 22 | JSONObject response = null; 23 | RequestFuture requestFuture = RequestFuture.newFuture(); 24 | 25 | JsonObjectRequest request = new JsonObjectRequest(Request.Method.GET, 26 | url, 27 | (String)null, 28 | requestFuture, requestFuture); 29 | 30 | requestQueue.add(request); 31 | try { 32 | response = requestFuture.get(30000, TimeUnit.MILLISECONDS); 33 | } catch (InterruptedException e) { 34 | LogUtils.m(e + ""); 35 | } catch (ExecutionException e) { 36 | LogUtils.m(e + ""); 37 | } catch (TimeoutException e) { 38 | LogUtils.m(e + ""); 39 | } 40 | return response; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/anthonyeef/fanfoudaily/callbacks/RecyclerItemClickListener.java: -------------------------------------------------------------------------------- 1 | package io.github.anthonyeef.fanfoudaily.callbacks; 2 | 3 | import android.content.Context; 4 | import android.support.v7.widget.RecyclerView; 5 | import android.view.GestureDetector; 6 | import android.view.MotionEvent; 7 | import android.view.View; 8 | 9 | /** 10 | * Created by anthonyeef on 11/1/15. 11 | */ 12 | public class RecyclerItemClickListener implements RecyclerView.OnItemTouchListener{ 13 | GestureDetector mGestureDetector; 14 | private OnItemClickListener mListener; 15 | 16 | public interface OnItemClickListener { 17 | public void onItemClick(View view, int position); 18 | } 19 | 20 | 21 | public RecyclerItemClickListener(Context context, OnItemClickListener listener) { 22 | mListener = listener; 23 | mGestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() { 24 | @Override public boolean onSingleTapUp(MotionEvent e) { 25 | return true; 26 | } 27 | }); 28 | } 29 | 30 | @Override 31 | public boolean onInterceptTouchEvent(RecyclerView view, MotionEvent e) { 32 | View childView = view.findChildViewUnder(e.getX(), e.getY()); 33 | if (childView != null && mListener != null && mGestureDetector.onTouchEvent(e)) { 34 | mListener.onItemClick(childView, view.getChildPosition(childView)); 35 | return true; 36 | } 37 | return false; 38 | } 39 | 40 | @Override 41 | public void onTouchEvent(RecyclerView view, MotionEvent motionEvent) { } 42 | 43 | 44 | 45 | @Override 46 | public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) { 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/anthonyeef/fanfoudaily/fragment/FragmentSettings.java: -------------------------------------------------------------------------------- 1 | package io.github.anthonyeef.fanfoudaily.fragment; 2 | 3 | import android.content.Intent; 4 | import android.net.Uri; 5 | import android.os.Bundle; 6 | import android.preference.Preference; 7 | import android.preference.PreferenceFragment; 8 | 9 | import io.github.anthonyeef.fanfoudaily.R; 10 | 11 | /** 12 | * Created by anthonyeef on 11/11/15. 13 | */ 14 | public class FragmentSettings extends PreferenceFragment implements Preference.OnPreferenceClickListener { 15 | 16 | private Preference pref_homepage; 17 | 18 | public FragmentSettings() { 19 | 20 | } 21 | 22 | @Override 23 | public void onCreate(Bundle savedInstanceState) { 24 | super.onCreate(savedInstanceState); 25 | addPreferencesFromResource(R.xml.main_prefs); 26 | 27 | pref_homepage = findPreference("fanfoudaily"); 28 | pref_homepage.setOnPreferenceClickListener(this); 29 | 30 | getPreferenceScreen().setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { 31 | @Override 32 | public boolean onPreferenceClick(Preference preference) { 33 | 34 | return false; 35 | } 36 | }); 37 | } 38 | 39 | 40 | 41 | @Override 42 | public boolean onPreferenceClick(Preference preference) { 43 | String key = preference.getKey(); 44 | if (key == "fanfoudaily"){ 45 | openWebsite(getString(R.string.project_address)); 46 | return true; 47 | } 48 | return false; 49 | } 50 | 51 | private void openWebsite(String url) { 52 | Uri uri = Uri.parse(url); 53 | Intent i = new Intent(Intent.ACTION_VIEW); 54 | i.setData(uri); 55 | startActivity(i); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/anthonyeef/fanfoudaily/animation/ScrollAwareFABBehavior.java: -------------------------------------------------------------------------------- 1 | package io.github.anthonyeef.fanfoudaily.animation; 2 | 3 | import android.content.Context; 4 | import android.support.design.widget.CoordinatorLayout; 5 | import android.support.design.widget.FloatingActionButton; 6 | import android.support.v4.view.ViewCompat; 7 | import android.util.AttributeSet; 8 | import android.view.View; 9 | 10 | import io.github.anthonyeef.fanfoudaily.ui.UIHome; 11 | 12 | /** 13 | * Created by anthonyeef on 11/4/15. 14 | */ 15 | public class ScrollAwareFABBehavior extends FloatingActionButton.Behavior{ 16 | 17 | public ScrollAwareFABBehavior(Context context, AttributeSet attrs) { 18 | super(); 19 | } 20 | @Override 21 | public boolean onStartNestedScroll(CoordinatorLayout coordinatorLayout, 22 | FloatingActionButton child, View directTargetChild, 23 | View target, int nestedScrollAxes) { 24 | return nestedScrollAxes == ViewCompat.SCROLL_AXIS_VERTICAL || 25 | super.onStartNestedScroll(coordinatorLayout, child, directTargetChild, target, 26 | nestedScrollAxes); 27 | } 28 | 29 | @Override 30 | public void onNestedScroll(CoordinatorLayout coordinatorLayout, FloatingActionButton child, 31 | View target, int dxConsumed, int dyConsunmed, int dxUnconsumed, 32 | int dyUnconsumed) { 33 | if (UIHome.viewPager.getCurrentItem() == 0) { 34 | if (dyConsunmed > 0 && child.getVisibility() == View.VISIBLE ) { 35 | child.hide(); 36 | } else if (dyConsunmed < 0 && child.getVisibility() != View.VISIBLE) { 37 | child.show(); 38 | } 39 | 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 19 | 22 | 23 | 26 | 27 | 28 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 42 | 45 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/anthonyeef/fanfoudaily/MyApplication.java: -------------------------------------------------------------------------------- 1 | package io.github.anthonyeef.fanfoudaily; 2 | 3 | import android.app.Application; 4 | import android.content.Context; 5 | 6 | import com.umeng.analytics.MobclickAgent; 7 | 8 | import im.fir.sdk.FIR; 9 | import io.github.anthonyeef.fanfoudaily.model.Date; 10 | 11 | /** 12 | * Created by anthonyeef on 10/13/15. 13 | */ 14 | public class MyApplication extends Application { 15 | 16 | public static final String TAG = Application.class.getSimpleName(); 17 | 18 | private static MyApplication mInstance; 19 | /* private RequestQueue mRequestQueue;*/ 20 | private static Date mDate; 21 | 22 | @Override 23 | public void onCreate() { 24 | MobclickAgent.setCatchUncaughtExceptions(false); 25 | FIR.init(this); 26 | super.onCreate(); 27 | mInstance = this; 28 | } 29 | 30 | public static synchronized MyApplication getInstance() { 31 | return mInstance; 32 | } 33 | 34 | public static Context getAppContext() { 35 | return mInstance.getApplicationContext(); 36 | } 37 | /* 38 | public RequestQueue getRequestQueue() { 39 | if (mRequestQueue == null) { 40 | mRequestQueue = Volley.newRequestQueue(getApplicationContext()); 41 | } 42 | return mRequestQueue; 43 | }*/ 44 | 45 | /* public void addToRequestQueue(Request request, String tag) { 46 | request.setTag(TextUtils.isEmpty(tag) ? TAG : tag); 47 | getRequestQueue().add(request); 48 | } 49 | 50 | public void addToRequestQueue(Request request) { 51 | request.setTag(TAG); 52 | getRequestQueue().add(request); 53 | } 54 | 55 | public void cancelPendingRequests(Object tag) { 56 | if (mRequestQueue != null) { 57 | mRequestQueue.cancelAll(tag); 58 | } 59 | }*/ 60 | 61 | public static void setDate(Date date) { 62 | mDate = date; 63 | } 64 | 65 | public static Date getDate() { 66 | return mDate; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_home.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 16 | 17 | 23 | 24 | 28 | 29 | 30 | 31 | 36 | 37 | 38 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 19 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 46 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | 4 | android { 5 | compileSdkVersion 23 6 | buildToolsVersion "23.0.1" 7 | 8 | defaultConfig { 9 | applicationId "io.github.anthonyeef.fanfoudaily" 10 | minSdkVersion 14 11 | targetSdkVersion 23 12 | versionCode 1 13 | versionName "0.9.2" 14 | 15 | manifestPlaceholders = [UMENG_CHANNEL_VALUE: "GitHub"] 16 | multiDexEnabled true 17 | } 18 | buildTypes { 19 | release { 20 | minifyEnabled false 21 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 22 | 23 | } 24 | 25 | } 26 | 27 | signingConfigs { 28 | debug { 29 | 30 | } 31 | /* release { 32 | storeFile file(System.console().readLine("\n\$ Enter keystore path: ")) 33 | storePassword new String(System.console().readPassword("\n\$ Enter keystore password: ")) 34 | keyAlias System.console().readLine("\n\$ Enter key alias: ") 35 | keyPassword new String(System.console().readPassword("\n\$ Enter key password: ")) 36 | }*/ 37 | } 38 | 39 | productFlavors { 40 | github { 41 | manifestPlaceholders = [UMENG_CHANNEL_VALUE: "GitHub"] 42 | } 43 | 44 | fir { 45 | manifestPlaceholders = [UMENG_CHANNEL_VALUE: "FIR"] 46 | } 47 | 48 | google { 49 | manifestPlaceholders = [UMENG_CHANNEL_VALUE: "Google"] 50 | } 51 | 52 | wandoujia { 53 | manifestPlaceholders = [UMENG_CHANNEL_VALUE: "Wandoujia"] 54 | } 55 | } 56 | } 57 | 58 | dependencies { 59 | compile fileTree(dir: 'libs', include: ['*.jar']) 60 | testCompile 'junit:junit:4.12' 61 | compile 'com.android.support:appcompat-v7:23.0.1' 62 | compile 'com.android.support:design:23.0.1' 63 | compile 'com.android.support:recyclerview-v7:23.0.1' 64 | compile 'com.android.support:cardview-v7:23.0.+' 65 | 66 | compile 'com.squareup.picasso:picasso:2.4.0' 67 | compile 'de.hdodenhof:circleimageview:2.0.0' 68 | compile 'com.jakewharton:butterknife:7.0.1' 69 | compile 'com.mcxiaoke.volley:library:1.0.18' 70 | compile 'de.greenrobot:eventbus:2.4.0' 71 | 72 | compile 'com.umeng.analytics:analytics:latest.integration' 73 | compile 'im.fir:sdk:latest.integration' 74 | } 75 | 76 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/anthonyeef/fanfoudaily/ui/UIPreference.java: -------------------------------------------------------------------------------- 1 | package io.github.anthonyeef.fanfoudaily.ui; 2 | 3 | import android.os.Build; 4 | import android.os.Bundle; 5 | import android.support.v7.widget.Toolbar; 6 | import android.util.TypedValue; 7 | import android.view.LayoutInflater; 8 | import android.view.View; 9 | import android.view.ViewGroup; 10 | import android.widget.ListView; 11 | 12 | import io.github.anthonyeef.fanfoudaily.R; 13 | 14 | /** 15 | * Created by anthonyeef on 11/10/15. 16 | */ 17 | public class UIPreference extends AppCompatPreferenceActivity{ 18 | 19 | 20 | @Override 21 | protected void onCreate(Bundle savedInstanceState) { 22 | super.onCreate(savedInstanceState); 23 | addPreferencesFromResource(R.xml.main_prefs); 24 | 25 | // setContentView(R.xml.main_prefs); 26 | setupActionBar(); 27 | // getFragmentManager().beginTransaction().replace(R.id.pref_container, new FragmentPreference()).commit(); 28 | 29 | } 30 | 31 | private void setupActionBar() { 32 | Toolbar toolbar; 33 | 34 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { 35 | ViewGroup root = (ViewGroup) findViewById(android.R.id.list).getParent().getParent().getParent(); 36 | toolbar = (Toolbar) LayoutInflater.from(this).inflate(R.layout.toolbar_pref, root, false); 37 | root.addView(toolbar, 0); 38 | } else { 39 | ViewGroup root = (ViewGroup) findViewById(android.R.id.content); 40 | ListView content = (ListView) root.getChildAt(0); 41 | root.removeAllViews(); 42 | toolbar = (Toolbar) LayoutInflater.from(this).inflate(R.layout.toolbar_pref, root, false); 43 | int height; 44 | TypedValue tv = new TypedValue(); 45 | if (getTheme().resolveAttribute(R.attr.actionBarSize, tv, true)) { 46 | height = TypedValue.complexToDimensionPixelSize(tv.data, getResources().getDisplayMetrics()); 47 | } else { 48 | height = toolbar.getHeight(); 49 | } 50 | content.setPadding(0, height, 0, 0); 51 | root.addView(content); 52 | root.addView(toolbar); 53 | } 54 | setSupportActionBar(toolbar); 55 | getSupportActionBar().setDisplayHomeAsUpEnabled(true); 56 | toolbar.setNavigationOnClickListener(new View.OnClickListener() { 57 | @Override 58 | public void onClick(View v) { 59 | finish(); 60 | } 61 | }); 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## 饭否精选 第三方客户端 for Android —— 饭否 Daily 2 | 3 | 4 | 5 | 6 | 「饭否精选」是我的一个小练习。RecyclerView + Volley. 另外使用的一些第三方库有 `Butterknife` , `EventBus`, `CircleView` 等。 7 | 8 | 9 | 10 | 11 | Still under building. 12 | 13 | Almost there ;) 14 | 15 | ### Screenshot 16 | 17 | 18 | 19 | 20 | 21 | 22 | ### 已完成: 23 | - 可以从 Api 接口中解析数据并完整呈现 24 | - 可以在「每日精选」和「每周精选」间切换 25 | - 可以查看 `2015-10-05` 开始的任意时间的 `每日精选`,以及最新一期的`每周精选` 26 | 27 | ### TO DO 28 | - 增加卡片的点击事件 29 | - 实现饭否帐号登录,实现「收藏」「转发」等功能 30 | - 实现转发到其他平台 31 | - 夜间模式 32 | - 「每周精选」的 `Fragment` 底部增加 footer,浏览到最底部后可以自动加载上一期「每周精选」 33 | - 考虑增加这个[工具](https://github.com/mcxiaoke/gradle-packer-plugin),用以管理多渠道打包和版本号 34 | - 多语言支持 35 | 36 | ### Installation 37 | Still trying to figure out the publishing method. 38 | 39 | And currently only support 40 | 41 | - Build from source code(using Android Studio). 42 | - [GitHub release](https://github.com/Anthonyeef/FanfouDaily/releases/download/v0.9.2/app-github-release.apk) 43 | - [Fir](http://fir.im/zhj3) 44 | - Scan QR code: 45 | 46 | 47 | 48 | ## Some thing I would like to write it here: 49 | - 很感谢 [rex](https://github.com/zhasm) 提供的 Api,才使得这个小项目成为可能。 50 | 51 | ## Q&A 52 | - 为什么 icon 中的 Daily 少了一个 y? 53 | 54 | 因为这是用 Android Asset Studio 在线生成的 icon。本来想是「饭否精选」的,但发现文字部分过长会被截掉。换成英文,于是 y 就被截掉了……但看着也蛮舒服的。等有时间会尝试画一个 icon 出来 :) 55 | 56 | - 为什么右上角的菜单只有一个设置,而且点击后没有反应? 57 | 58 | 抱歉……因为临近考试,所以右上角的 popup menu 部分还没有写。后面的版本会加上内容,以及夜间模式 :) 59 | 60 | - 为什么只有每日精选可以选择日期,每周精选不可以? 61 | 62 | 因为每日精选是从 `2015-10-05` 后每天都有的,故很方便可以在 `DatePickerDialog` 里通过选择日期来选择期数。但每周精选是每周的周一上午 8 点才会有一期,如果也用一个 `DatePickerDialog` 来挑选,大大的日历只有星期一可以选,感觉不是很好 :( 后面会通过「下拉到底部自动加载上一期每周精选」的方式来呈现内容;或者是其他更优雅的解决方法。 63 | 64 | - 你是谁? 65 | - 我的 [blog](https://anthonyeef.github.io) 66 | - 我的 [diary](https://anthonyeef.github.io/diary) 67 | - 我的[饭否](http://fanfou.com/anthonyeef) 68 | 69 | ## License 70 | 71 | ``` 72 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 73 | Version 2, December 2004 74 | 75 | Copyright (C) 2019 Yifen Wu 76 | 77 | Everyone is permitted to copy and distribute verbatim or modified 78 | copies of this license document, and changing it is allowed as long 79 | as the name is changed. 80 | 81 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 82 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 83 | 84 | 0. You just DO WHAT THE FUCK YOU WANT TO. 85 | ``` 86 | 87 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/anthonyeef/fanfoudaily/volley/Parser.java: -------------------------------------------------------------------------------- 1 | package io.github.anthonyeef.fanfoudaily.volley; 2 | 3 | import android.text.Html; 4 | 5 | import org.json.JSONArray; 6 | import org.json.JSONException; 7 | import org.json.JSONObject; 8 | 9 | import java.text.DateFormat; 10 | import java.text.SimpleDateFormat; 11 | import java.util.ArrayList; 12 | 13 | import io.github.anthonyeef.fanfoudaily.model.Fanfou; 14 | 15 | import static io.github.anthonyeef.fanfoudaily.extras.Keys.ComeoutSomeKeys.KEY_AVATAR; 16 | import static io.github.anthonyeef.fanfoudaily.extras.Keys.ComeoutSomeKeys.KEY_IMG; 17 | import static io.github.anthonyeef.fanfoudaily.extras.Keys.ComeoutSomeKeys.KEY_MESSAGE; 18 | import static io.github.anthonyeef.fanfoudaily.extras.Keys.ComeoutSomeKeys.KEY_PREVIEW; 19 | import static io.github.anthonyeef.fanfoudaily.extras.Keys.ComeoutSomeKeys.KEY_REALNAME; 20 | import static io.github.anthonyeef.fanfoudaily.extras.Keys.ComeoutSomeKeys.KEY_TIME; 21 | /** 22 | * Created by anthonyeef on 10/16/15. 23 | */ 24 | public class Parser { 25 | public static ArrayList parseFanfouJSON(JSONObject response) { 26 | DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); 27 | ArrayList fanfous = new ArrayList<>(); 28 | if (response != null && response.length() > 0) { 29 | try { 30 | JSONArray message = response.getJSONArray("msgs"); 31 | for (int i = 0; i < message.length(); i++) { 32 | String name; 33 | String avatar; 34 | String msg; 35 | String img; 36 | String time; 37 | 38 | JSONObject fanfou = message.getJSONObject(i); 39 | name = fanfou.getString(KEY_REALNAME); 40 | avatar = fanfou.getString(KEY_AVATAR); 41 | avatar = avatar.replace("s0", "l0"); 42 | time = fanfou.getString(KEY_TIME); 43 | msg = fanfou.getString(KEY_MESSAGE); 44 | 45 | img = fanfou.getJSONObject(KEY_IMG).getString(KEY_PREVIEW); 46 | if (!img.equals("")) { 47 | img = img.replaceFirst("m0", "n0"); 48 | } 49 | 50 | Fanfou fan = new Fanfou(); 51 | 52 | fan.setScreenName(name); 53 | fan.setAvatarUrl(avatar); 54 | fan.setStatus(Html.fromHtml(msg).toString()); 55 | fan.setImageUrl(img); 56 | fan.setTimeStamp(time); 57 | 58 | if (!name.equals(null)) { 59 | fanfous.add(fan); 60 | } 61 | } 62 | } catch (JSONException e) { 63 | 64 | } 65 | } 66 | return fanfous; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/anthonyeef/fanfoudaily/model/Fanfou.java: -------------------------------------------------------------------------------- 1 | package io.github.anthonyeef.fanfoudaily.model; 2 | 3 | import android.os.Parcel; 4 | import android.os.Parcelable; 5 | 6 | /** 7 | * Created by anthonyeef on 10/13/15. 8 | */ 9 | public class Fanfou implements Parcelable{ 10 | 11 | public static final Parcelable.Creator CREATOR 12 | = new Parcelable.Creator() { 13 | public Fanfou createFromParcel(Parcel in) { 14 | return new Fanfou(in); 15 | } 16 | 17 | public Fanfou[] newArray(int size) { 18 | return new Fanfou[size]; 19 | } 20 | }; 21 | 22 | public Fanfou(Parcel in) { 23 | readFromParcel(in); 24 | } 25 | 26 | public Fanfou(String screenName, String status, String avatarUrl, String imageUrl, String timeStamp) { 27 | super(); 28 | this.screenName = screenName; 29 | this.status = status; 30 | this.avatarUrl = avatarUrl; 31 | this.imageUrl = imageUrl; 32 | this.timeStamp = timeStamp; 33 | } 34 | 35 | public String getScreenName() { 36 | return screenName; 37 | } 38 | 39 | public void setScreenName(String screenName) { 40 | this.screenName = screenName; 41 | } 42 | 43 | public String getStatus() { 44 | return status; 45 | } 46 | 47 | public void setStatus(String status) { 48 | this.status = status; 49 | } 50 | 51 | public String getAvatarUrl() { 52 | return avatarUrl; 53 | } 54 | 55 | private String screenName; 56 | private String status; 57 | private String avatarUrl; 58 | private String imageUrl; 59 | private String timeStamp; 60 | 61 | public Fanfou() { 62 | 63 | } 64 | 65 | public void setAvatarUrl(String avatarUrl) { 66 | this.avatarUrl = avatarUrl; 67 | } 68 | 69 | public String getImageUrl() { 70 | return imageUrl; 71 | } 72 | 73 | public void setImageUrl(String imageUrl) { 74 | this.imageUrl = imageUrl; 75 | } 76 | 77 | public String getTimeStamp() { 78 | return timeStamp; 79 | } 80 | 81 | public void setTimeStamp(String timeStamp) { 82 | this.timeStamp = timeStamp; 83 | } 84 | 85 | @Override 86 | public int describeContents() { 87 | 88 | return 0; 89 | } 90 | @Override 91 | public void writeToParcel(Parcel dest, int flags) { 92 | dest.writeString(screenName); 93 | dest.writeString(status); 94 | dest.writeString(avatarUrl); 95 | dest.writeString(imageUrl); 96 | dest.writeString(timeStamp); 97 | } 98 | private void readFromParcel(Parcel in) { 99 | screenName = in.readString(); 100 | status = in.readString(); 101 | avatarUrl = in.readString(); 102 | imageUrl = in.readString(); 103 | timeStamp = in.readString(); 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /app/src/main/res/layout/card_list_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 15 | 19 | 25 | 26 | 29 | 33 | 40 | 41 | 47 | 48 | 55 | 56 | 57 | 58 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/anthonyeef/fanfoudaily/ui/AppCompatPreferenceActivity.java: -------------------------------------------------------------------------------- 1 | package io.github.anthonyeef.fanfoudaily.ui; 2 | 3 | import android.content.res.Configuration; 4 | import android.os.Bundle; 5 | import android.preference.PreferenceActivity; 6 | import android.support.annotation.LayoutRes; 7 | import android.support.annotation.Nullable; 8 | import android.support.v7.app.ActionBar; 9 | import android.support.v7.app.AppCompatDelegate; 10 | import android.support.v7.widget.Toolbar; 11 | import android.view.MenuInflater; 12 | import android.view.View; 13 | import android.view.ViewGroup; 14 | 15 | /** 16 | * Created by anthonyeef on 11/11/15. 17 | */ 18 | public abstract class AppCompatPreferenceActivity extends PreferenceActivity{ 19 | private AppCompatDelegate mDelegate; 20 | 21 | @Override 22 | protected void onCreate(Bundle savedInstanceState) { 23 | getDelegate().installViewFactory(); 24 | getDelegate().onCreate(savedInstanceState); 25 | super.onCreate(savedInstanceState); 26 | } 27 | 28 | @Override 29 | protected void onPostCreate(Bundle savedInstanceState) { 30 | super.onPostCreate(savedInstanceState); 31 | getDelegate().onPostCreate(savedInstanceState); 32 | } 33 | public ActionBar getSupportActionBar() { 34 | return getDelegate().getSupportActionBar(); 35 | } 36 | public void setSupportActionBar(@Nullable Toolbar toolbar) { 37 | getDelegate().setSupportActionBar(toolbar); 38 | } 39 | @Override 40 | public MenuInflater getMenuInflater() { 41 | return getDelegate().getMenuInflater(); 42 | } 43 | @Override 44 | public void setContentView(@LayoutRes int layoutResID) { 45 | getDelegate().setContentView(layoutResID); 46 | } 47 | @Override 48 | public void setContentView(View view) { 49 | getDelegate().setContentView(view); 50 | } 51 | @Override 52 | public void setContentView(View view, ViewGroup.LayoutParams params) { 53 | getDelegate().setContentView(view, params); 54 | } 55 | @Override 56 | public void addContentView(View view, ViewGroup.LayoutParams params) { 57 | getDelegate().addContentView(view, params); 58 | } 59 | @Override 60 | protected void onPostResume() { 61 | super.onPostResume(); 62 | getDelegate().onPostResume(); 63 | } 64 | @Override 65 | protected void onTitleChanged(CharSequence title, int color) { 66 | super.onTitleChanged(title, color); 67 | getDelegate().setTitle(title); 68 | } 69 | @Override 70 | public void onConfigurationChanged(Configuration newConfig) { 71 | super.onConfigurationChanged(newConfig); 72 | getDelegate().onConfigurationChanged(newConfig); 73 | } 74 | @Override 75 | protected void onStop() { 76 | super.onStop(); 77 | getDelegate().onStop(); 78 | } 79 | @Override 80 | protected void onDestroy() { 81 | super.onDestroy(); 82 | getDelegate().onDestroy(); 83 | } 84 | public void invalidateOptionsMenu() { 85 | getDelegate().invalidateOptionsMenu(); 86 | } 87 | 88 | 89 | private AppCompatDelegate getDelegate() { 90 | if (mDelegate == null) { 91 | mDelegate = AppCompatDelegate.create(this, null); 92 | } 93 | return mDelegate; 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/anthonyeef/fanfoudaily/adapter/FanfouAdapter.java: -------------------------------------------------------------------------------- 1 | package io.github.anthonyeef.fanfoudaily.adapter; 2 | 3 | import android.content.Context; 4 | import android.net.Uri; 5 | import android.support.v7.widget.RecyclerView; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | import android.widget.ImageView; 10 | import android.widget.TextView; 11 | 12 | import com.squareup.picasso.Picasso; 13 | 14 | import java.util.ArrayList; 15 | 16 | import butterknife.Bind; 17 | import butterknife.ButterKnife; 18 | import de.hdodenhof.circleimageview.CircleImageView; 19 | import io.github.anthonyeef.fanfoudaily.R; 20 | import io.github.anthonyeef.fanfoudaily.model.Fanfou; 21 | import io.github.anthonyeef.fanfoudaily.volley.VolleySingleton; 22 | 23 | /** 24 | * Created by anthonyeef on 10/13/15. 25 | */ 26 | public class FanfouAdapter extends RecyclerView.Adapter{ 27 | 28 | private ArrayList mFanfouList = new ArrayList<>(); 29 | private VolleySingleton mVolleySingleton; 30 | private LayoutInflater mInflater; 31 | private Context mContext; 32 | 33 | public FanfouAdapter(Context context) { 34 | mInflater = LayoutInflater.from(context); 35 | mVolleySingleton = VolleySingleton.getInstance(); 36 | mContext = context; 37 | } 38 | 39 | public void setFanfous(ArrayList listFanfous) { 40 | this.mFanfouList = listFanfous; 41 | notifyDataSetChanged(); 42 | } 43 | 44 | @Override 45 | public int getItemCount() { 46 | return mFanfouList.size(); 47 | } 48 | 49 | 50 | class FanfouViewHolder extends RecyclerView.ViewHolder { 51 | 52 | @Bind(R.id.avatar) CircleImageView vAvatar; 53 | @Bind(R.id.name) TextView vScreenName; 54 | @Bind(R.id.timestamp) TextView vTimeStamp; 55 | @Bind(R.id.status) TextView vStatus; 56 | @Bind(R.id.imageflag) ImageView vImageflag; 57 | 58 | Fanfou mFanfou; 59 | View feed; 60 | 61 | public FanfouViewHolder(View itemView) { 62 | super(itemView); 63 | feed = itemView; 64 | ButterKnife.bind(this, itemView); 65 | } 66 | 67 | } 68 | @Override 69 | public void onBindViewHolder(final FanfouViewHolder fanfouViewHolder, int location){ 70 | Fanfou current = mFanfouList.get(location); 71 | 72 | Uri avatar_uri = Uri.parse(current.getAvatarUrl()); 73 | Context context = fanfouViewHolder.vAvatar.getContext(); 74 | Picasso.with(context).load(avatar_uri) 75 | .into(fanfouViewHolder.vAvatar); 76 | 77 | fanfouViewHolder.vScreenName.setText(current.getScreenName()); 78 | fanfouViewHolder.vTimeStamp.setText(current.getTimeStamp()); 79 | fanfouViewHolder.vStatus.setText(current.getStatus()); 80 | fanfouViewHolder.mFanfou = current; 81 | fanfouViewHolder.vImageflag.setImageResource(R.drawable.ic_photo_24dp); 82 | 83 | if (current.getImageUrl().equals("")) { 84 | fanfouViewHolder.vImageflag.setImageDrawable(null); 85 | } 86 | } 87 | 88 | @Override 89 | public FanfouViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) { 90 | View itemView = mInflater.inflate(R.layout.card_list_item, viewGroup, false); 91 | final FanfouViewHolder holder = new FanfouViewHolder(itemView); 92 | return holder; 93 | } 94 | 95 | 96 | } 97 | -------------------------------------------------------------------------------- /app/src/main/res/layout/card_status.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 11 | 12 | 17 | 18 | 23 | 28 | 32 | 38 | 43 | 44 | 45 | 46 | 52 | 56 | 66 | 75 | 76 | 77 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/anthonyeef/fanfoudaily/ui/UIStatus.java: -------------------------------------------------------------------------------- 1 | package io.github.anthonyeef.fanfoudaily.ui; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.support.v7.widget.Toolbar; 7 | import android.view.Menu; 8 | import android.view.MenuItem; 9 | import android.view.View; 10 | import android.widget.ImageView; 11 | import android.widget.ProgressBar; 12 | import android.widget.TextView; 13 | 14 | import com.squareup.picasso.Callback; 15 | import com.squareup.picasso.Picasso; 16 | import com.umeng.analytics.MobclickAgent; 17 | 18 | import butterknife.Bind; 19 | import butterknife.ButterKnife; 20 | import de.hdodenhof.circleimageview.CircleImageView; 21 | import io.github.anthonyeef.fanfoudaily.R; 22 | import io.github.anthonyeef.fanfoudaily.model.Fanfou; 23 | 24 | /** 25 | * Created by anthonyeef on 10/31/15. 26 | */ 27 | public class UIStatus extends AppCompatActivity{ 28 | 29 | @Bind(R.id.statustoolbar) Toolbar mToolbar; 30 | @Bind(R.id.avatar1) CircleImageView avatar1; 31 | @Bind(R.id.name1) TextView name1; 32 | @Bind(R.id.timestamp1) TextView timestamp1; 33 | @Bind(R.id.status1) TextView status1; 34 | @Bind(R.id.image1) ImageView image1; 35 | @Bind(R.id.imageprogress) ProgressBar mProgressBar; 36 | 37 | @Override 38 | public void onCreate(Bundle savedInstanceState) { 39 | super.onCreate(savedInstanceState); 40 | MobclickAgent.setCatchUncaughtExceptions(false); 41 | Intent intent = getIntent(); 42 | 43 | 44 | setContentView(R.layout.activity_status); 45 | ButterKnife.bind(this); 46 | setSupportActionBar(mToolbar); 47 | // mProgressBar.setVisibility(View.VISIBLE); 48 | 49 | Fanfou feed = (Fanfou) intent.getParcelableExtra("feed"); 50 | 51 | name1.setText(feed.getScreenName()); 52 | timestamp1.setText(feed.getTimeStamp()); 53 | status1.setText(feed.getStatus()); 54 | 55 | Picasso.with(this).load(feed.getAvatarUrl()) 56 | .into(avatar1); 57 | if (!feed.getImageUrl().equals("")) { 58 | Picasso.with(this).load(feed.getImageUrl()) 59 | // .fit().centerInside() 60 | .into(image1, new ImageLoadedCallback(mProgressBar) { 61 | @Override 62 | public void onSuccess() { 63 | if (this.mProgressBar != null) { 64 | mProgressBar.setVisibility(View.GONE); 65 | } 66 | } 67 | }); 68 | } else { 69 | mProgressBar.setVisibility(View.GONE); 70 | } 71 | } 72 | 73 | @Override 74 | public boolean onCreateOptionsMenu(Menu menu) { 75 | getMenuInflater().inflate(R.menu.menu_home, menu); 76 | return true; 77 | } 78 | 79 | @Override 80 | public boolean onOptionsItemSelected(MenuItem item) { 81 | int id = item.getItemId(); 82 | if (id == R.id.action_settings) { 83 | return true; 84 | } 85 | 86 | return super.onOptionsItemSelected(item); 87 | } 88 | 89 | @Override 90 | public void onResume() { 91 | super.onResume(); 92 | MobclickAgent.onResume(this); 93 | } 94 | 95 | @Override 96 | public void onPause() { 97 | super.onPause(); 98 | MobclickAgent.onPause(this); 99 | } 100 | 101 | private class ImageLoadedCallback implements Callback { 102 | ProgressBar mProgressBar; 103 | 104 | public ImageLoadedCallback(ProgressBar progressBar) { 105 | mProgressBar = progressBar; 106 | } 107 | 108 | @Override 109 | public void onSuccess() { 110 | 111 | } 112 | 113 | @Override 114 | public void onError() { 115 | 116 | } 117 | } 118 | 119 | } 120 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/anthonyeef/fanfoudaily/fragment/FragmentWeekly.java: -------------------------------------------------------------------------------- 1 | package io.github.anthonyeef.fanfoudaily.fragment; 2 | 3 | /** 4 | * Created by anthonyeef on 10/28/15. 5 | */ 6 | 7 | import android.content.Intent; 8 | import android.os.AsyncTask; 9 | import android.os.Bundle; 10 | import android.os.Handler; 11 | import android.support.annotation.Nullable; 12 | import android.support.v4.app.Fragment; 13 | import android.support.v4.widget.SwipeRefreshLayout; 14 | import android.support.v7.widget.LinearLayoutManager; 15 | import android.support.v7.widget.RecyclerView; 16 | import android.view.LayoutInflater; 17 | import android.view.View; 18 | import android.view.ViewGroup; 19 | 20 | import com.android.volley.RequestQueue; 21 | 22 | import java.util.ArrayList; 23 | 24 | import butterknife.Bind; 25 | import butterknife.ButterKnife; 26 | import io.github.anthonyeef.fanfoudaily.R; 27 | import io.github.anthonyeef.fanfoudaily.Utils.DateUtils; 28 | import io.github.anthonyeef.fanfoudaily.adapter.FanfouAdapter; 29 | import io.github.anthonyeef.fanfoudaily.callbacks.RecyclerItemClickListener; 30 | import io.github.anthonyeef.fanfoudaily.extras.FanfouUtils; 31 | import io.github.anthonyeef.fanfoudaily.model.Fanfou; 32 | import io.github.anthonyeef.fanfoudaily.volley.VolleySingleton; 33 | import io.github.anthonyeef.fanfoudaily.ui.UIStatus; 34 | 35 | public class FragmentWeekly extends Fragment { 36 | private static final String WEEKLY_FANFOU = "weekly_fanfou"; 37 | 38 | private ArrayList listFanfous = new ArrayList<>(); 39 | private FanfouAdapter mFanfouAdapter; 40 | 41 | private String temp = DateUtils.getCurrentMonday(); 42 | 43 | @Bind(R.id.swipeFanfous) SwipeRefreshLayout mSwipeRefreshLayout; 44 | @Bind(R.id.recyclerview) RecyclerView mRecyclerView; 45 | 46 | public FragmentWeekly() { 47 | 48 | } 49 | 50 | @Nullable 51 | @Override 52 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 53 | Bundle savedInstanceState) { 54 | View view = inflater.inflate( 55 | R.layout.fragment_item_list, container, false); 56 | ButterKnife.bind(this, view); 57 | 58 | mSwipeRefreshLayout.setColorSchemeResources(R.color.orange, R.color.red, R.color.green); 59 | mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { 60 | @Override 61 | public void onRefresh() { 62 | new Handler().postDelayed(new Runnable() { 63 | @Override 64 | public void run() { 65 | new TaskLoadFanfouWeekly().execute(); 66 | mFanfouAdapter.setFanfous(listFanfous); 67 | mSwipeRefreshLayout.setRefreshing(false); 68 | } 69 | }, 2500); 70 | } 71 | }); 72 | 73 | mRecyclerView.addOnItemTouchListener(new RecyclerItemClickListener(getContext(), 74 | new RecyclerItemClickListener.OnItemClickListener() { 75 | @Override 76 | public void onItemClick(View view, int position) { 77 | Intent intent = new Intent(getActivity(), UIStatus.class); 78 | Fanfou feed = listFanfous.get(position); 79 | intent.putExtra("feed", feed); 80 | startActivity(intent); 81 | } 82 | })); 83 | 84 | mRecyclerView.setLayoutManager(new LinearLayoutManager(mRecyclerView.getContext())); 85 | mFanfouAdapter = new FanfouAdapter(getContext()); 86 | 87 | mRecyclerView.setAdapter(mFanfouAdapter); 88 | if (savedInstanceState != null) { 89 | listFanfous = savedInstanceState.getParcelableArrayList(WEEKLY_FANFOU); 90 | } else { 91 | if (listFanfous.isEmpty()) { 92 | mSwipeRefreshLayout.post(new Runnable() { 93 | @Override 94 | public void run() { 95 | mSwipeRefreshLayout.setRefreshing(true); 96 | new TaskLoadFanfouWeekly().execute(); 97 | } 98 | }); 99 | mFanfouAdapter.setFanfous(listFanfous); 100 | } 101 | } 102 | return view; 103 | } 104 | 105 | @Override 106 | public void onResume() { 107 | super.onResume(); 108 | if (listFanfous.isEmpty()){ 109 | new TaskLoadFanfouWeekly().execute(); 110 | } 111 | } 112 | 113 | @Override 114 | public void onSaveInstanceState(Bundle outState) { 115 | super.onSaveInstanceState(outState); 116 | outState.putParcelableArrayList(WEEKLY_FANFOU, listFanfous); 117 | } 118 | 119 | 120 | 121 | public class TaskLoadFanfouWeekly extends AsyncTask { 122 | private VolleySingleton mVolleySingleton; 123 | private RequestQueue mRequestQueue; 124 | 125 | public TaskLoadFanfouWeekly() { 126 | mVolleySingleton = VolleySingleton.getInstance(); 127 | mRequestQueue = mVolleySingleton.getRequestQueue(); 128 | } 129 | 130 | @Override 131 | protected void onPreExecute() { 132 | mSwipeRefreshLayout.setRefreshing(true); 133 | listFanfous.clear(); 134 | } 135 | 136 | @Override 137 | protected Integer doInBackground(Void... params) { 138 | Integer result = 0; 139 | temp = DateUtils.getCurrentMonday(); 140 | listFanfous = FanfouUtils.loadFanfouWeeklyFeeds(mRequestQueue, temp); 141 | result = 1; 142 | return result; 143 | } 144 | @Override 145 | protected void onPostExecute(Integer result) { 146 | if (result == 1) { 147 | mFanfouAdapter.setFanfous(listFanfous); 148 | if (mSwipeRefreshLayout.isRefreshing()) { 149 | mSwipeRefreshLayout.setRefreshing(false); 150 | } 151 | } 152 | } 153 | } 154 | 155 | } 156 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/anthonyeef/fanfoudaily/ui/UIHome.java: -------------------------------------------------------------------------------- 1 | package io.github.anthonyeef.fanfoudaily.ui; 2 | 3 | import android.app.DatePickerDialog; 4 | import android.app.Dialog; 5 | import android.content.Intent; 6 | import android.os.Bundle; 7 | import android.support.design.widget.FloatingActionButton; 8 | import android.support.design.widget.TabLayout; 9 | import android.support.v4.app.DialogFragment; 10 | import android.support.v4.view.ViewPager; 11 | import android.support.v7.app.AppCompatActivity; 12 | import android.support.v7.widget.Toolbar; 13 | import android.view.Menu; 14 | import android.view.MenuItem; 15 | import android.view.View; 16 | import android.widget.DatePicker; 17 | 18 | import com.umeng.analytics.MobclickAgent; 19 | 20 | import java.text.SimpleDateFormat; 21 | import java.util.Calendar; 22 | 23 | import butterknife.Bind; 24 | import butterknife.ButterKnife; 25 | import de.greenrobot.event.EventBus; 26 | import io.github.anthonyeef.fanfoudaily.R; 27 | import io.github.anthonyeef.fanfoudaily.adapter.PagerAdapter; 28 | import io.github.anthonyeef.fanfoudaily.fragment.FragmentDaily; 29 | import io.github.anthonyeef.fanfoudaily.fragment.FragmentWeekly; 30 | import io.github.anthonyeef.fanfoudaily.model.Date; 31 | 32 | public class UIHome extends AppCompatActivity { 33 | 34 | // @Bind(R.id.viewPager) ViewPager viewPager; 35 | public static ViewPager viewPager; 36 | @Bind(R.id.tabs) TabLayout tabLayout; 37 | @Bind(R.id.toolbar) Toolbar toolbar; 38 | @Bind(R.id.fab) FloatingActionButton mFloatingActionButton; 39 | 40 | // public static boolean isFABinCurrentTabVisible = true; 41 | FragmentDaily fragmentDaily = new FragmentDaily(); 42 | FragmentWeekly fragmentWeekly = new FragmentWeekly(); 43 | 44 | @Override 45 | protected void onCreate(Bundle savedInstanceState) { 46 | super.onCreate(savedInstanceState); 47 | 48 | MobclickAgent.updateOnlineConfig(this); 49 | MobclickAgent.setCatchUncaughtExceptions(false); 50 | 51 | setContentView(R.layout.activity_home); 52 | 53 | viewPager = (ViewPager) findViewById(R.id.viewPager); 54 | 55 | ButterKnife.bind(this); 56 | setSupportActionBar(toolbar); 57 | 58 | if (viewPager != null) { 59 | setupViewPager(viewPager); 60 | } 61 | 62 | tabLayout.setupWithViewPager(viewPager); 63 | mFloatingActionButton.setOnClickListener(new View.OnClickListener() { 64 | @Override 65 | public void onClick(View v) { 66 | showDatePickerDialog(v); 67 | } 68 | }); 69 | 70 | 71 | } 72 | 73 | @Override 74 | public boolean onCreateOptionsMenu(Menu menu) { 75 | getMenuInflater().inflate(R.menu.menu_home, menu); 76 | return true; 77 | } 78 | 79 | @Override 80 | public boolean onOptionsItemSelected(MenuItem item) { 81 | int id = item.getItemId(); 82 | if (id == R.id.action_settings) { 83 | Intent i = new Intent(this, UIPreference.class); 84 | startActivity(i); 85 | } 86 | 87 | return super.onOptionsItemSelected(item); 88 | } 89 | 90 | 91 | @Override 92 | public void onResume() { 93 | super.onResume(); 94 | MobclickAgent.onResume(this); 95 | } 96 | 97 | @Override 98 | public void onPause() { 99 | super.onPause(); 100 | MobclickAgent.onPause(this); 101 | } 102 | public void showDatePickerDialog(View view) { 103 | DialogFragment newFragment = new FragmentDatePicker(); 104 | newFragment.show(getSupportFragmentManager(), "datePicker"); 105 | } 106 | public void setupViewPager(final ViewPager viewPager) { 107 | PagerAdapter adapter = new PagerAdapter(getSupportFragmentManager()); 108 | adapter.addFragment(fragmentDaily, getString(R.string.daily)); 109 | adapter.addFragment(fragmentWeekly, getString(R.string.weekly)); 110 | viewPager.setAdapter(adapter); 111 | viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { 112 | @Override 113 | public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { 114 | 115 | } 116 | 117 | @Override 118 | public void onPageSelected(int position) { 119 | switch (position) { 120 | case 0: 121 | // isFABinCurrentTabVisible = true; 122 | mFloatingActionButton.show(); 123 | break; 124 | default: 125 | // isFABinCurrentTabVisible = false; 126 | mFloatingActionButton.hide(); 127 | break; 128 | } 129 | } 130 | 131 | @Override 132 | public void onPageScrollStateChanged(int state) { 133 | 134 | } 135 | }); 136 | } 137 | 138 | public static class FragmentDatePicker extends DialogFragment implements DatePickerDialog.OnDateSetListener { 139 | 140 | @Override 141 | public Dialog onCreateDialog(Bundle savedInstanceState) { 142 | 143 | final Calendar cal = Calendar.getInstance(); 144 | int year = cal.get(Calendar.YEAR); 145 | int month = cal.get(Calendar.MONTH); 146 | int day = cal.get(Calendar.DAY_OF_MONTH); 147 | 148 | return new DatePickerDialog(getActivity(), this, year, month, day); 149 | } 150 | 151 | public void onDateSet(DatePicker view, int year, int month, int day) { 152 | // Toast.makeText(getContext(), "You just select" + year + month + day, Toast.LENGTH_SHORT).show(); 153 | Calendar pickDate = Calendar.getInstance(); 154 | pickDate.set(year, month, day); 155 | 156 | SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd"); 157 | String fdate = format1.format(pickDate.getTime()); 158 | 159 | Date date = new Date(fdate); 160 | EventBus.getDefault().post(date); 161 | } 162 | 163 | 164 | } 165 | } 166 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/anthonyeef/fanfoudaily/fragment/FragmentDaily.java: -------------------------------------------------------------------------------- 1 | package io.github.anthonyeef.fanfoudaily.fragment; 2 | 3 | import android.content.Intent; 4 | import android.os.AsyncTask; 5 | import android.os.Bundle; 6 | import android.os.Handler; 7 | import android.support.annotation.Nullable; 8 | import android.support.design.widget.Snackbar; 9 | import android.support.v4.app.Fragment; 10 | import android.support.v4.widget.SwipeRefreshLayout; 11 | import android.support.v7.widget.LinearLayoutManager; 12 | import android.support.v7.widget.RecyclerView; 13 | import android.view.LayoutInflater; 14 | import android.view.View; 15 | import android.view.ViewGroup; 16 | 17 | import com.android.volley.RequestQueue; 18 | import com.android.volley.VolleyError; 19 | 20 | import java.util.ArrayList; 21 | 22 | import butterknife.Bind; 23 | import butterknife.ButterKnife; 24 | import de.greenrobot.event.EventBus; 25 | import io.github.anthonyeef.fanfoudaily.MyApplication; 26 | import io.github.anthonyeef.fanfoudaily.R; 27 | import io.github.anthonyeef.fanfoudaily.Utils.DateUtils; 28 | import io.github.anthonyeef.fanfoudaily.Utils.HttpUtils; 29 | import io.github.anthonyeef.fanfoudaily.Utils.LogUtils; 30 | import io.github.anthonyeef.fanfoudaily.adapter.FanfouAdapter; 31 | import io.github.anthonyeef.fanfoudaily.callbacks.RecyclerItemClickListener; 32 | import io.github.anthonyeef.fanfoudaily.extras.FanfouUtils; 33 | import io.github.anthonyeef.fanfoudaily.model.Date; 34 | import io.github.anthonyeef.fanfoudaily.model.Fanfou; 35 | import io.github.anthonyeef.fanfoudaily.ui.UIStatus; 36 | import io.github.anthonyeef.fanfoudaily.volley.VolleySingleton; 37 | 38 | /** 39 | * Created by anthonyeef on 10/14/15. 40 | */ 41 | public class FragmentDaily extends Fragment { 42 | private static final String DAILY_FANFOU = "daily_fanfou"; 43 | 44 | private ArrayList listFanfous = new ArrayList<>(); 45 | private FanfouAdapter mFanfouAdapter; 46 | 47 | private String temp = DateUtils.getCurrentDate(); 48 | 49 | @Bind(R.id.swipeFanfous) SwipeRefreshLayout mSwipeRefreshLayout; 50 | @Bind(R.id.recyclerview) RecyclerView mRecyclerView; 51 | 52 | public FragmentDaily() { 53 | 54 | } 55 | 56 | @Nullable 57 | @Override 58 | public View onCreateView(final LayoutInflater inflater, ViewGroup container, 59 | Bundle savedInstanceState) { 60 | 61 | final View view = inflater.inflate( 62 | R.layout.fragment_item_list, container, false); 63 | ButterKnife.bind(this, view); 64 | 65 | setupSwipeRefreshLayout(); 66 | setupRecyclerView(); 67 | 68 | EventBus.getDefault().register(this); 69 | 70 | if (savedInstanceState != null) { 71 | listFanfous = savedInstanceState.getParcelableArrayList(DAILY_FANFOU); 72 | } else { 73 | if (listFanfous.isEmpty()) { 74 | mSwipeRefreshLayout.post(new Runnable() { 75 | @Override 76 | public void run() { 77 | if (HttpUtils.isNetworkConnected(getContext())) { 78 | mSwipeRefreshLayout.setRefreshing(true); 79 | Snackbar.make(mRecyclerView, getString(R.string.action_loading) + temp, Snackbar.LENGTH_SHORT).show(); 80 | fetchData(temp); 81 | } else { 82 | Snackbar.make(view, getString(R.string.network_notworking), Snackbar.LENGTH_LONG).show(); 83 | if (mSwipeRefreshLayout.isRefreshing()) { 84 | mSwipeRefreshLayout.setRefreshing(false); 85 | } 86 | } 87 | } 88 | }); 89 | mFanfouAdapter.setFanfous(listFanfous); 90 | } 91 | } 92 | return view; 93 | } 94 | 95 | @Override 96 | public void onResume() { 97 | super.onResume(); 98 | if (listFanfous.isEmpty()){ 99 | fetchData(temp); 100 | } 101 | } 102 | @Override 103 | public void onDestroy() { 104 | super.onDestroy(); 105 | EventBus.getDefault().unregister(this); 106 | } 107 | 108 | public void onEvent(Date date) { 109 | MyApplication.setDate(date); 110 | Snackbar.make(mRecyclerView, getString(R.string.action_loading) + MyApplication.getDate().getDate(), Snackbar.LENGTH_SHORT).show(); 111 | fetchData(MyApplication.getDate().getDate()); 112 | } 113 | @Override 114 | public void onSaveInstanceState(Bundle outState) { 115 | super.onSaveInstanceState(outState); 116 | outState.putParcelableArrayList(DAILY_FANFOU, listFanfous); 117 | } 118 | 119 | private void setupSwipeRefreshLayout() { 120 | mSwipeRefreshLayout.setColorSchemeResources(R.color.orange, 121 | R.color.green, R.color.red, R.color.blue); 122 | mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { 123 | @Override 124 | public void onRefresh() { 125 | new Handler().postDelayed(new Runnable() { 126 | @Override 127 | public void run() { 128 | if(HttpUtils.isNetworkConnected(getContext())) { 129 | Snackbar.make(mRecyclerView, getString(R.string.action_loading) + temp, Snackbar.LENGTH_SHORT).show(); 130 | fetchData(temp); 131 | } else { 132 | Snackbar.make(getView(), getString(R.string.network_notworking), Snackbar.LENGTH_LONG).show(); 133 | if (mSwipeRefreshLayout.isRefreshing()) { 134 | mSwipeRefreshLayout.setRefreshing(false); 135 | } 136 | } 137 | } 138 | }, 2500); 139 | } 140 | }); 141 | } 142 | 143 | private void setupRecyclerView() { 144 | 145 | mRecyclerView.addOnItemTouchListener( 146 | new RecyclerItemClickListener(getContext(), 147 | new RecyclerItemClickListener.OnItemClickListener() { 148 | @Override 149 | public void onItemClick(View view, int position) { 150 | startActivity(position); 151 | } 152 | }) 153 | ); 154 | mRecyclerView.setLayoutManager( 155 | new LinearLayoutManager(mRecyclerView.getContext())); 156 | mFanfouAdapter = new FanfouAdapter(getContext()); 157 | mRecyclerView.setAdapter(mFanfouAdapter); 158 | } 159 | 160 | public class TaskLoadFanfouDaily extends AsyncTask { 161 | 162 | private VolleySingleton mVolleySingleton; 163 | private RequestQueue mRequestQueue; 164 | String date; 165 | 166 | public TaskLoadFanfouDaily(String date) { 167 | this.date = date; 168 | mVolleySingleton = VolleySingleton.getInstance(); 169 | mRequestQueue = mVolleySingleton.getRequestQueue(); 170 | } 171 | 172 | @Override 173 | protected void onPreExecute() { 174 | mSwipeRefreshLayout.setRefreshing(true); 175 | listFanfous.clear(); 176 | } 177 | 178 | @Override 179 | protected Integer doInBackground(Void... params) { 180 | Integer result = 0; 181 | try { 182 | listFanfous = FanfouUtils.loadFanfouDailyFeeds(mRequestQueue, date); 183 | throw new VolleyError("Ya Volley not working"); 184 | } catch (VolleyError e) { 185 | LogUtils.m("Something happend:"+ e ); 186 | } 187 | result = 1; 188 | return result; 189 | } 190 | 191 | @Override 192 | protected void onPostExecute(Integer result) { 193 | if (result == 1) { 194 | mFanfouAdapter.setFanfous(listFanfous); 195 | if (mSwipeRefreshLayout.isRefreshing()) { 196 | mSwipeRefreshLayout.setRefreshing(false); 197 | } 198 | } 199 | } 200 | } 201 | 202 | private void startActivity(int position) { 203 | Intent intent = new Intent(getActivity(), UIStatus.class); 204 | Fanfou feed = listFanfous.get(position); 205 | intent.putExtra("feed", feed); 206 | startActivity(intent); 207 | } 208 | 209 | public void fetchData(String date) { 210 | mSwipeRefreshLayout.setRefreshing(true); 211 | new TaskLoadFanfouDaily(date).execute(); 212 | mFanfouAdapter.setFanfous(listFanfous); 213 | } 214 | } 215 | -------------------------------------------------------------------------------- /app/app.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | --------------------------------------------------------------------------------