├── .gitignore ├── .idea ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── gradle.xml ├── modules.xml └── vcs.xml ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── looklook │ │ └── xinghongfei │ │ └── looklook │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── assets │ │ └── fonts │ │ │ └── roboto-mono-regular.ttf │ ├── java │ │ └── com │ │ │ └── looklook │ │ │ └── xinghongfei │ │ │ └── looklook │ │ │ ├── MainActivity.java │ │ │ ├── MyApplication.java │ │ │ ├── activity │ │ │ ├── AboutActivity.java │ │ │ ├── BaseActivity.java │ │ │ ├── MeiziPhotoDescribeActivity.java │ │ │ ├── TopNewsDescribeActivity.java │ │ │ └── ZhihuDescribeActivity.java │ │ │ ├── adapter │ │ │ ├── MeiziAdapter.java │ │ │ ├── TopNewsAdapter.java │ │ │ └── ZhihuAdapter.java │ │ │ ├── api │ │ │ ├── ApiManager.java │ │ │ ├── GankApi.java │ │ │ ├── TopNews.java │ │ │ └── ZhihuApi.java │ │ │ ├── bean │ │ │ ├── image │ │ │ │ ├── ImageData.java │ │ │ │ ├── ImageItem.java │ │ │ │ └── ImageResponse.java │ │ │ ├── meizi │ │ │ │ ├── BaseData.java │ │ │ │ ├── DGank.java │ │ │ │ ├── DGankData.java │ │ │ │ ├── Gank.java │ │ │ │ ├── GankData.java │ │ │ │ ├── Meizi.java │ │ │ │ ├── MeiziData.java │ │ │ │ └── VedioData.java │ │ │ ├── news │ │ │ │ ├── NewsBean.java │ │ │ │ ├── NewsDetailBean.java │ │ │ │ └── NewsList.java │ │ │ └── zhihu │ │ │ │ ├── ZhihuDaily.java │ │ │ │ ├── ZhihuDailyItem.java │ │ │ │ └── ZhihuStory.java │ │ │ ├── config │ │ │ └── Config.java │ │ │ ├── fragment │ │ │ ├── BaseFragment.java │ │ │ ├── MeiziFragment.java │ │ │ ├── TopNewsFragment.java │ │ │ └── ZhihuFragment.java │ │ │ ├── presenter │ │ │ ├── BasePresenter.java │ │ │ ├── IMainPresenter.java │ │ │ ├── IMeiziPresenter.java │ │ │ ├── INewTopDescriblePresenter.java │ │ │ ├── INewTopPresenter.java │ │ │ ├── IZhihuPresenter.java │ │ │ ├── IZhihuStoryPresenter.java │ │ │ ├── implPresenter │ │ │ │ ├── BasePresenterImpl.java │ │ │ │ ├── MainPresenterImpl.java │ │ │ │ ├── MeiziPresenterImpl.java │ │ │ │ ├── TopNewsDesPresenterImpl.java │ │ │ │ ├── TopNewsPrensenterImpl.java │ │ │ │ ├── ZhihuPresenterImpl.java │ │ │ │ └── ZhihuStoryPresenterImpl.java │ │ │ └── implView │ │ │ │ ├── IBaseFragment.java │ │ │ │ ├── IMain.java │ │ │ │ ├── IMeiziFragment.java │ │ │ │ ├── ITopNewsDesFragment.java │ │ │ │ ├── ITopNewsFragment.java │ │ │ │ ├── IZhihuFragment.java │ │ │ │ └── IZhihuStory.java │ │ │ ├── util │ │ │ ├── AnimUtils.java │ │ │ ├── CacheUtil.java │ │ │ ├── ColorUtils.java │ │ │ ├── DBUtils.java │ │ │ ├── DensityUtil.java │ │ │ ├── DribbbleTarget.java │ │ │ ├── GlideUtils.java │ │ │ ├── Help.java │ │ │ ├── ImageLoader.java │ │ │ ├── ImageTarget.java │ │ │ ├── JsonUtils.java │ │ │ ├── MathUtils.java │ │ │ ├── NetWorkUtil.java │ │ │ ├── NewsJsonUtils.java │ │ │ ├── ObservableColorMatrix.java │ │ │ ├── OkHttpUtils.java │ │ │ ├── Once.java │ │ │ ├── SharePreferenceUtil.java │ │ │ ├── Urls.java │ │ │ ├── ViewUtils.java │ │ │ ├── WebUtil.java │ │ │ └── common │ │ │ │ └── UIUtils.java │ │ │ ├── view │ │ │ ├── GridItemDividerDecoration.java │ │ │ ├── Pop.java │ │ │ └── SlideInItemAnimator.java │ │ │ └── widget │ │ │ ├── BadgedFourThreeImageView.java │ │ │ ├── ElasticDragDismissFrameLayout.java │ │ │ ├── ForegroundImageView.java │ │ │ ├── FourThreeImageView.java │ │ │ ├── LiftOff.java │ │ │ ├── MyParallaxScrimageView.java │ │ │ ├── ParallaxScrimageView.java │ │ │ ├── ShotSharedEnter.java │ │ │ ├── TranslateYTextView.java │ │ │ └── WrapContentLinearLayoutManager.java │ └── res │ │ ├── anim │ │ └── trim_start_interpolator.xml │ │ ├── animator │ │ ├── app_bar_pin.xml │ │ ├── button_frown.xml │ │ ├── raise.xml │ │ ├── show_connection_cross.xml │ │ ├── show_connection_line.xml │ │ ├── upload_arrow_fill.xml │ │ ├── upload_progress.xml │ │ └── upload_progress_rotation.xml │ │ ├── drawable-hdpi │ │ ├── bg.png │ │ └── ic_color_lens_white_24dp.png │ │ ├── drawable │ │ ├── avd_uploading.xml │ │ ├── fab.xml │ │ ├── ic_arrow_back.xml │ │ ├── ic_launcher.png │ │ ├── ic_uploading.xml │ │ ├── look.png │ │ ├── look2.png │ │ ├── look3.png │ │ ├── looklookbg.png │ │ ├── mid_grey_ripple.xml │ │ ├── nav_icon.png │ │ ├── open.png │ │ ├── settin.png │ │ ├── wangyi.png │ │ └── zhihu.png │ │ ├── interpolator │ │ └── trim_end_interpolator.xml │ │ ├── layout │ │ ├── action_view_switch.xml │ │ ├── activity_about.xml │ │ ├── activity_picture.xml │ │ ├── infinite_loading.xml │ │ ├── main_layout.xml │ │ ├── meizi_fragment_layout.xml │ │ ├── meizi_layout_item.xml │ │ ├── nav_header_main.xml │ │ ├── no_connection.xml │ │ ├── no_connection_text.xml │ │ ├── posting_progress.xml │ │ ├── topnews_describe.xml │ │ ├── topnews_fragment_layout.xml │ │ ├── topnews_layout_item.xml │ │ ├── view_toolbar.xml │ │ ├── zhihu_fragment_layout.xml │ │ ├── zhihu_layout.xml │ │ ├── zhihu_layout_item.xml │ │ └── zhihudescribe.xml │ │ ├── menu │ │ ├── main.xml │ │ ├── menu_empty.xml │ │ └── nevmenu.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── mylook.png │ │ ├── mipmap-xxhdpi │ │ ├── downlosd.png │ │ ├── ic_launcher.png │ │ └── look.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── look.png │ │ ├── transition │ │ ├── dribbble_shot_enter.xml │ │ ├── dribbble_shot_return.xml │ │ ├── dribbble_shot_shared_enter.xml │ │ ├── dribbble_shot_shared_return.xml │ │ └── home_enter.xml │ │ ├── values-w820dp │ │ ├── dimens.xml │ │ ├── no_connection.xml │ │ └── paths.xml │ │ └── values │ │ ├── attrs_badged_image_view.xml │ │ ├── attrs_elastic_drag_dismiss_frame_layout.xml │ │ ├── attrs_foreground_view.xml │ │ ├── attrs_lift_off.xml │ │ ├── attrs_parallax_scrimage_view.xml │ │ ├── attrs_pinnable.xml │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── drawables.xml │ │ ├── integers.xml │ │ ├── strings.xml │ │ ├── styles.xml │ │ └── values.xml │ └── test │ └── java │ └── com │ └── looklook │ └── xinghongfei │ └── looklook │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── screenshots ├── LookLook.gif ├── about.png ├── meizi.png ├── navigation.png ├── pay.png ├── pay1.png └── zhihu.png └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .idea/tasks.xml 10 | /.idea/ 11 | .idea 12 | /.idea/misc.xml 13 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LookLook 2 | 3 | This is a news reading app. You can use it to read Zhihu Daily, News and view some pictures. I hope the user experience is amazing to you. The project will be updating, you are welcome to **Star** or **Fork**. 4 | 5 | 6 | 7 | 8 | ## Screenshots 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | ## About me 25 | 26 | An Android developer in Beijing. Please feel free to offer me an [Interview Invitation](mailto:maat.xing@gmail.com). If you have any new idea about this project, feel free to [contact me](mailto:maat.xing@gmail.com). :smiley: 27 | 28 | 29 | 30 | 31 | 32 | 33 | License 34 | ======= 35 | 36 | Copyright 2016 Maat 37 | 38 | 39 | Licensed under the Apache License, Version 2.0 (the "License"); 40 | you may not use this file except in compliance with the License. 41 | You may obtain a copy of the License at 42 | 43 | http://www.apache.org/licenses/LICENSE-2.0 44 | 45 | Unless required by applicable law or agreed to in writing, software 46 | distributed under the License is distributed on an "AS IS" BASIS, 47 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 48 | See the License for the specific language governing permissions and 49 | limitations under the License. 50 | 51 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'android-apt' 3 | 4 | android { 5 | compileSdkVersion 24 6 | buildToolsVersion '25.0.0' 7 | defaultConfig { 8 | applicationId "com.looklook.xinghongfei.looklook" 9 | minSdkVersion 21 10 | targetSdkVersion 24 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 | productFlavors { 21 | } 22 | } 23 | 24 | dependencies { 25 | compile fileTree(dir: 'libs', include: ['*.jar']) 26 | testCompile 'junit:junit:4.12' 27 | //support lib 28 | compile 'com.android.support:design:24.1.1' 29 | compile 'com.android.support:support-v4:24.1.1' 30 | compile 'com.android.support:recyclerview-v7:24.1.1' 31 | compile 'com.android.support:appcompat-v7:24.1.1' 32 | compile 'com.android.support:palette-v7:24.1.1' 33 | compile 'com.android.support:cardview-v7:24.1.1' 34 | /*rotrofit*/ 35 | compile 'com.squareup.retrofit2:retrofit:+' 36 | compile 'com.squareup.retrofit2:converter-gson:+' 37 | compile 'com.squareup.retrofit2:adapter-rxjava:+' 38 | compile 'com.google.code.gson:gson:+' 39 | /*rx-android-java*/ 40 | compile 'io.reactivex:rxjava:+' 41 | compile 'com.squareup.retrofit:adapter-rxjava:+' 42 | compile 'com.trello:rxlifecycle:+' 43 | compile 'com.trello:rxlifecycle-components:+' 44 | 45 | compile 'com.google.code.gson:gson:2.2.4' 46 | //butterknife 47 | compile 'com.jakewharton:butterknife:8.0.1' 48 | apt 'com.jakewharton:butterknife-compiler:8.0.1' 49 | 50 | compile 'com.jakewharton:butterknife:5.1.1' 51 | 52 | compile 'com.github.bumptech.glide:glide:3.7.0' 53 | compile 'org.sufficientlysecure:html-textview:1.3' 54 | 55 | // 富文本 56 | compile 'com.github.iwgang:simplifyspan:1.1' 57 | // compile 'com.github.chrisbanes:PhotoView:1.3.0' 58 | compile 'com.github.githubwing:DragPhotoView:1.0.1' 59 | 60 | // swipeback activity 61 | compile 'com.github.liuguangqiang.swipeback:library:1.0.2@aar' 62 | } 63 | -------------------------------------------------------------------------------- /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/xinghongfei/Downloads/android-sdk--mac-r24-updated/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 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/looklook/xinghongfei/looklook/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.looklook.xinghongfei.looklook; 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/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 14 | 22 | 23 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 40 | 41 | 44 | 45 | 46 | 52 | 53 | 56 | 57 | 58 | 63 | 64 | 68 | 71 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /app/src/main/assets/fonts/roboto-mono-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xinghongfei/LookLook/c436ef9949aa80ee085408900c54e800c839ce77/app/src/main/assets/fonts/roboto-mono-regular.ttf -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/MyApplication.java: -------------------------------------------------------------------------------- 1 | package com.looklook.xinghongfei.looklook; 2 | 3 | import android.app.Application; 4 | import android.content.Context; 5 | import android.support.v7.app.AppCompatDelegate; 6 | 7 | import com.looklook.xinghongfei.looklook.activity.BaseActivity; 8 | 9 | import java.util.LinkedList; 10 | import java.util.List; 11 | import java.util.ListIterator; 12 | 13 | /** 14 | * Created by xinghongfei on 16/8/12. 15 | */ 16 | public class MyApplication extends Application { 17 | 18 | public final static String TAG = "BaseApplication"; 19 | public final static boolean DEBUG = true; 20 | private static MyApplication myApplication; 21 | private static int mainTid; 22 | 23 | /** 24 | * Activity集合,来管理所有的Activity 25 | */ 26 | private static List activities; 27 | 28 | static { 29 | AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM); 30 | } 31 | 32 | public static Application getContext() { 33 | return myApplication; 34 | } 35 | 36 | @Override 37 | public void onCreate() { 38 | super.onCreate(); 39 | myApplication = this; 40 | activities = new LinkedList<>(); 41 | mainTid = android.os.Process.myTid(); 42 | } 43 | 44 | /** 45 | * 获取application 46 | * 47 | * @return 48 | */ 49 | public static Context getApplication() { 50 | return myApplication; 51 | } 52 | 53 | /** 54 | * 获取主线程ID 55 | * 56 | * @return 57 | */ 58 | public static int getMainTid() { 59 | return mainTid; 60 | } 61 | 62 | /** 63 | * 添加一个Activity 64 | * 65 | * @param activity 66 | */ 67 | public void addActivity(BaseActivity activity) { 68 | activities.add(activity); 69 | } 70 | 71 | /** 72 | * 结束一个Activity 73 | * 74 | * @param activity 75 | */ 76 | public void removeActivity(BaseActivity activity) { 77 | activities.remove(activity); 78 | } 79 | 80 | /** 81 | * 结束当前所有Activity 82 | */ 83 | public static void clearActivities() { 84 | ListIterator iterator = activities.listIterator(); 85 | BaseActivity activity; 86 | while (iterator.hasNext()) { 87 | activity = iterator.next(); 88 | if (activity != null) { 89 | activity.finish(); 90 | } 91 | } 92 | } 93 | 94 | /** 95 | * 退出应运程序 96 | */ 97 | public static void quiteApplication() { 98 | clearActivities(); 99 | System.exit(0); 100 | } 101 | 102 | } 103 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/activity/AboutActivity.java: -------------------------------------------------------------------------------- 1 | package com.looklook.xinghongfei.looklook.activity; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.Nullable; 5 | import android.view.View; 6 | import android.widget.LinearLayout; 7 | 8 | import com.looklook.xinghongfei.looklook.R; 9 | 10 | /** 11 | * Created by top2015 on 17/6/3. 12 | */ 13 | 14 | 15 | public class AboutActivity extends BaseActivity implements View.OnClickListener{ 16 | @Override 17 | protected void onCreate(@Nullable Bundle savedInstanceState) { 18 | super.onCreate(savedInstanceState); 19 | setContentView(R.layout.activity_about); 20 | LinearLayout draggable_frame = (LinearLayout) findViewById(R.id.draggable_frame); 21 | draggable_frame.setOnClickListener(this); 22 | } 23 | 24 | @Override 25 | public void onClick(View v) { 26 | finish(); 27 | 28 | } 29 | 30 | 31 | } 32 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/activity/BaseActivity.java: -------------------------------------------------------------------------------- 1 | package com.looklook.xinghongfei.looklook.activity; 2 | 3 | import android.os.Bundle; 4 | import android.os.PersistableBundle; 5 | import android.support.v7.app.AppCompatActivity; 6 | import com.looklook.xinghongfei.looklook.MyApplication; 7 | import com.looklook.xinghongfei.looklook.util.common.UIUtils; 8 | 9 | /** 10 | * Created by xinghongfei on 16/8/12. 11 | */ 12 | public class BaseActivity extends AppCompatActivity { 13 | 14 | protected final String TAG = getClass().getSimpleName(); 15 | public static BaseActivity activity; 16 | 17 | @Override 18 | public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) { 19 | super.onCreate(savedInstanceState, persistentState); 20 | // TODO: 16/9/1 add the third service. eg.umeng ... 21 | activity = this; 22 | ((MyApplication) UIUtils.getContext()).addActivity(this); 23 | init(); 24 | } 25 | 26 | @Override 27 | protected void onResume() { 28 | super.onResume(); 29 | activity = this; 30 | } 31 | 32 | @Override 33 | protected void onPause() { 34 | super.onPause(); 35 | activity = null; 36 | } 37 | 38 | private void init() { 39 | initData(); 40 | initEvents(); 41 | } 42 | 43 | /*** 44 | * 初始化事件(监听事件等事件绑定) 45 | */ 46 | protected void initEvents() { 47 | } 48 | 49 | /** 50 | * 绑定数据 51 | */ 52 | protected void initData() { 53 | } 54 | 55 | /** 56 | * activity退出时将activity移出栈 57 | */ 58 | @Override 59 | protected void onDestroy() { 60 | super.onDestroy(); 61 | ((MyApplication) UIUtils.getContext()).removeActivity(this); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/api/ApiManager.java: -------------------------------------------------------------------------------- 1 | package com.looklook.xinghongfei.looklook.api; 2 | 3 | import com.looklook.xinghongfei.looklook.MyApplication; 4 | import com.looklook.xinghongfei.looklook.util.NetWorkUtil; 5 | 6 | import java.io.File; 7 | import java.io.IOException; 8 | 9 | import okhttp3.Cache; 10 | import okhttp3.Interceptor; 11 | import okhttp3.OkHttpClient; 12 | import okhttp3.Response; 13 | import retrofit2.Retrofit; 14 | import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory; 15 | import retrofit2.converter.gson.GsonConverterFactory; 16 | 17 | /** 18 | * Created by xinghongfei on 16/8/12. 19 | */ 20 | public class ApiManager { 21 | 22 | private static final Interceptor REWRITE_CACHE_CONTROL_INTERCEPTOR = new Interceptor() { 23 | @Override 24 | public Response intercept(Chain chain) throws IOException { 25 | Response originalResponse = chain.proceed(chain.request()); 26 | if (NetWorkUtil.isNetWorkAvailable(MyApplication.getContext())) { 27 | int maxAge = 60; // 在线缓存在1分钟内可读取 28 | return originalResponse.newBuilder() 29 | .removeHeader("Pragma") 30 | .removeHeader("Cache-Control") 31 | .header("Cache-Control", "public, max-age=" + maxAge) 32 | .build(); 33 | } else { 34 | int maxStale = 60 * 60 * 24 * 28; // 离线时缓存保存4周 35 | return originalResponse.newBuilder() 36 | .removeHeader("Pragma") 37 | .removeHeader("Cache-Control") 38 | .header("Cache-Control", "public, only-if-cached, max-stale=" + maxStale) 39 | .build(); 40 | } 41 | } 42 | }; 43 | private static ApiManager apiManager; 44 | private static File httpCacheDirectory = new File(MyApplication.getContext().getCacheDir(), "zhihuCache"); 45 | private static int cacheSize = 10 * 1024 * 1024; // 10 MiB 46 | private static Cache cache = new Cache(httpCacheDirectory, cacheSize); 47 | private static OkHttpClient client = new OkHttpClient.Builder() 48 | .addNetworkInterceptor(REWRITE_CACHE_CONTROL_INTERCEPTOR) 49 | .addInterceptor(REWRITE_CACHE_CONTROL_INTERCEPTOR) 50 | .cache(cache) 51 | .build(); 52 | private ZhihuApi zhihuApi; 53 | private TopNews topNews; 54 | private Object zhihuMonitor = new Object(); 55 | 56 | public static ApiManager getInstence() { 57 | if (apiManager == null) { 58 | synchronized (ApiManager.class) { 59 | if (apiManager == null) { 60 | apiManager = new ApiManager(); 61 | } 62 | } 63 | } 64 | return apiManager; 65 | } 66 | 67 | public ZhihuApi getZhihuApiService() { 68 | if (zhihuApi == null) { 69 | synchronized (zhihuMonitor) { 70 | if (zhihuApi == null) { 71 | zhihuApi = new Retrofit.Builder() 72 | .baseUrl("http://news-at.zhihu.com") 73 | .addCallAdapterFactory(RxJavaCallAdapterFactory.create()) 74 | .client(client) 75 | .addConverterFactory(GsonConverterFactory.create()) 76 | .build().create(ZhihuApi.class); 77 | } 78 | } 79 | } 80 | 81 | return zhihuApi; 82 | } 83 | 84 | public TopNews getTopNewsService() { 85 | if (topNews == null) { 86 | synchronized (zhihuMonitor) { 87 | if (topNews == null) { 88 | topNews = new Retrofit.Builder() 89 | .baseUrl("http://c.m.163.com") 90 | .addCallAdapterFactory(RxJavaCallAdapterFactory.create()) 91 | .client(client) 92 | .addConverterFactory(GsonConverterFactory.create()) 93 | .build().create(TopNews.class); 94 | 95 | } 96 | } 97 | } 98 | 99 | return topNews; 100 | } 101 | 102 | private GankApi ganK; 103 | public GankApi getGankService(){ 104 | if (ganK==null){ 105 | synchronized (zhihuMonitor){ 106 | if (ganK==null){ 107 | ganK=new Retrofit.Builder() 108 | .baseUrl("http://gank.io") 109 | .addCallAdapterFactory(RxJavaCallAdapterFactory.create()) 110 | .client(client) 111 | .addConverterFactory(GsonConverterFactory.create()) 112 | .build().create(GankApi.class); 113 | 114 | } 115 | } 116 | } 117 | return ganK; 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/api/GankApi.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Drakeet 3 | * 4 | * This file is part of Meizhi 5 | * 6 | * Meizhi is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Meizhi is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Meizhi. If not, see . 18 | */ 19 | 20 | package com.looklook.xinghongfei.looklook.api; 21 | 22 | 23 | import com.looklook.xinghongfei.looklook.bean.meizi.GankData; 24 | import com.looklook.xinghongfei.looklook.bean.meizi.MeiziData; 25 | import com.looklook.xinghongfei.looklook.bean.meizi.VedioData; 26 | 27 | import retrofit2.http.GET; 28 | import retrofit2.http.Path; 29 | import rx.Observable; 30 | 31 | // @formatter:off 32 | 33 | /** 34 | * Created by drakeet on 8/9/15. 35 | */ 36 | public interface GankApi { 37 | 38 | @GET("/api/data/福利/10/{page}") 39 | Observable getMeizhiData(@Path("page") int page); 40 | 41 | @GET("/day/{year}/{month}/{day}") 42 | Observable getGankData(@Path("year") int year, @Path("month") int month, 43 | @Path("day") int day); 44 | 45 | @GET("/api/data/休息视频/10/{page}") 46 | Observable getVedioData(@Path("page") int page); 47 | 48 | } 49 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/api/TopNews.java: -------------------------------------------------------------------------------- 1 | package com.looklook.xinghongfei.looklook.api; 2 | 3 | import com.looklook.xinghongfei.looklook.bean.news.NewsList; 4 | 5 | import retrofit2.http.GET; 6 | import retrofit2.http.Path; 7 | import rx.Observable; 8 | 9 | /** 10 | * Created by xinghongfei on 16/8/17. 11 | */ 12 | public interface TopNews { 13 | 14 | // TODO: 16/8/17 string or int 15 | @GET("http://c.m.163.com/nc/article/headline/T1348647909107/{id}-20.html") 16 | Observable getNews(@Path("id") int id ); 17 | 18 | @GET("http://c.m.163.com/nc/article/{id}/full.html") 19 | Observable getNewsDetail(@Path("id") String id); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/api/ZhihuApi.java: -------------------------------------------------------------------------------- 1 | package com.looklook.xinghongfei.looklook.api; 2 | 3 | 4 | import com.looklook.xinghongfei.looklook.bean.image.ImageResponse; 5 | import com.looklook.xinghongfei.looklook.bean.zhihu.ZhihuDaily; 6 | import com.looklook.xinghongfei.looklook.bean.zhihu.ZhihuStory; 7 | 8 | import retrofit2.http.GET; 9 | import retrofit2.http.Path; 10 | import rx.Observable; 11 | 12 | 13 | public interface ZhihuApi { 14 | 15 | @GET("/api/4/news/latest") 16 | Observable getLastDaily(); 17 | 18 | @GET("/api/4/news/before/{date}") 19 | Observable getTheDaily(@Path("date") String date); 20 | 21 | @GET("/api/4/news/{id}") 22 | Observable getZhihuStory(@Path("id") String id); 23 | 24 | @GET("http://lab.zuimeia.com/wallpaper/category/1/?page_size=1") 25 | Observable getImage(); 26 | 27 | } 28 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/bean/image/ImageData.java: -------------------------------------------------------------------------------- 1 | package com.looklook.xinghongfei.looklook.bean.image; 2 | 3 | import com.google.gson.annotations.SerializedName; 4 | 5 | import java.util.ArrayList; 6 | 7 | /** 8 | * Created by 蔡小木 on 2016/3/21 0021. 9 | */ 10 | public class ImageData { 11 | @SerializedName("images") 12 | private ArrayList images; 13 | 14 | public ArrayList getImages() { 15 | return images; 16 | } 17 | 18 | public void setImages(ArrayList images) { 19 | this.images = images; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/bean/image/ImageItem.java: -------------------------------------------------------------------------------- 1 | package com.looklook.xinghongfei.looklook.bean.image; 2 | 3 | import com.google.gson.annotations.SerializedName; 4 | 5 | /** 6 | * Created by 蔡小木 on 2016/3/21 0021. 7 | */ 8 | public class ImageItem { 9 | @SerializedName("description") 10 | private String description; 11 | @SerializedName("image_url") 12 | private String mImageUrl; 13 | 14 | public String getDescription() { 15 | return description; 16 | } 17 | 18 | public void setDescription(String description) { 19 | this.description = description; 20 | } 21 | 22 | public String getImageUrl() { 23 | return mImageUrl; 24 | } 25 | 26 | public void setImageUrl(String imageUrl) { 27 | this.mImageUrl = imageUrl; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/bean/image/ImageResponse.java: -------------------------------------------------------------------------------- 1 | package com.looklook.xinghongfei.looklook.bean.image; 2 | 3 | import com.google.gson.annotations.SerializedName; 4 | 5 | /** 6 | * Created by 蔡小木 on 2016/3/21 0021. 7 | */ 8 | public class ImageResponse { 9 | @SerializedName("data") 10 | private ImageData data; 11 | 12 | public ImageData getData() { 13 | return data; 14 | } 15 | 16 | public void setData(ImageData data) { 17 | this.data = data; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/bean/meizi/BaseData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Drakeet 3 | * 4 | * This file is part of Meizhi 5 | * 6 | * Meizhi is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Meizhi is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Meizhi. If not, see . 18 | */ 19 | 20 | package com.looklook.xinghongfei.looklook.bean.meizi; 21 | 22 | /** 23 | * Created by drakeet on 8/9/15. 24 | */ 25 | public class BaseData { 26 | 27 | public boolean error; 28 | } 29 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/bean/meizi/DGank.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Drakeet 3 | * 4 | * This file is part of Meizhi 5 | * 6 | * Meizhi is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Meizhi is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Meizhi. If not, see . 18 | */ 19 | 20 | package com.looklook.xinghongfei.looklook.bean.meizi; 21 | 22 | import com.google.gson.annotations.Expose; 23 | 24 | /** 25 | * Created by drakeet(http://drakeet.me) 26 | * Date: 9/9/15 11:00 27 | */ 28 | public class DGank { 29 | 30 | @Expose 31 | public String preview; 32 | @Expose 33 | public String tag; 34 | @Expose 35 | public String createdAt; 36 | @Expose 37 | public String updatedAt; 38 | @Expose 39 | public String objectId; 40 | } 41 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/bean/meizi/DGankData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Drakeet 3 | * 4 | * This file is part of Meizhi 5 | * 6 | * Meizhi is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Meizhi is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Meizhi. If not, see . 18 | */ 19 | 20 | package com.looklook.xinghongfei.looklook.bean.meizi; 21 | 22 | import com.google.gson.annotations.Expose; 23 | 24 | import java.util.ArrayList; 25 | 26 | 27 | /** 28 | * Created by drakeet(http://drakeet.me) 29 | * Date: 9/9/15 10:51 30 | */ 31 | public class DGankData { 32 | 33 | @Expose 34 | public ArrayList results = new ArrayList(); 35 | } 36 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/bean/meizi/Gank.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Drakeet 3 | * 4 | * This file is part of Meizhi 5 | * 6 | * Meizhi is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Meizhi is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Meizhi. If not, see . 18 | */ 19 | 20 | package com.looklook.xinghongfei.looklook.bean.meizi; 21 | 22 | import java.util.Date; 23 | 24 | /** 25 | * Created by drakeet on 8/11/15. 26 | */ 27 | public class Gank { 28 | public String objectId; 29 | public String url; 30 | public String type; 31 | public String desc; 32 | public String who; 33 | public boolean used; 34 | public Date createdAt; 35 | public Date updatedAt; 36 | public Date publishedAt; 37 | 38 | public String getObjectId() { 39 | return objectId; 40 | } 41 | 42 | public void setObjectId(String objectId) { 43 | this.objectId = objectId; 44 | } 45 | 46 | public String getUrl() { 47 | return url; 48 | } 49 | 50 | public void setUrl(String url) { 51 | this.url = url; 52 | } 53 | 54 | public String getType() { 55 | return type; 56 | } 57 | 58 | public void setType(String type) { 59 | this.type = type; 60 | } 61 | 62 | public String getDesc() { 63 | return desc; 64 | } 65 | 66 | public void setDesc(String desc) { 67 | this.desc = desc; 68 | } 69 | 70 | public String getWho() { 71 | return who; 72 | } 73 | 74 | public void setWho(String who) { 75 | this.who = who; 76 | } 77 | 78 | public boolean isUsed() { 79 | return used; 80 | } 81 | 82 | public void setUsed(boolean used) { 83 | this.used = used; 84 | } 85 | 86 | public Date getCreatedAt() { 87 | return createdAt; 88 | } 89 | 90 | public void setCreatedAt(Date createdAt) { 91 | this.createdAt = createdAt; 92 | } 93 | 94 | public Date getUpdatedAt() { 95 | return updatedAt; 96 | } 97 | 98 | public void setUpdatedAt(Date updatedAt) { 99 | this.updatedAt = updatedAt; 100 | } 101 | 102 | public Date getPublishedAt() { 103 | return publishedAt; 104 | } 105 | 106 | public void setPublishedAt(Date publishedAt) { 107 | this.publishedAt = publishedAt; 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/bean/meizi/GankData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Drakeet 3 | * 4 | * This file is part of Meizhi 5 | * 6 | * Meizhi is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Meizhi is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Meizhi. If not, see . 18 | */ 19 | 20 | package com.looklook.xinghongfei.looklook.bean.meizi; 21 | 22 | import com.google.gson.annotations.SerializedName; 23 | 24 | import java.util.List; 25 | 26 | /** 27 | * Created by drakeet on 8/11/15. 28 | */ 29 | public class GankData extends BaseData { 30 | 31 | public Result results; 32 | public List category; 33 | 34 | public class Result { 35 | @SerializedName("Android") public List androidList; 36 | @SerializedName("休息视频") public List 休息视频List; 37 | @SerializedName("iOS") public List iOSList; 38 | @SerializedName("福利") public List 妹纸List; 39 | @SerializedName("拓展资源") public List 拓展资源List; 40 | @SerializedName("瞎推荐") public List 瞎推荐List; 41 | @SerializedName("App") public List appList; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/bean/meizi/Meizi.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Drakeet 3 | * 4 | * This file is part of Meizhi 5 | * 6 | * Meizhi is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Meizhi is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Meizhi. If not, see . 18 | */ 19 | 20 | package com.looklook.xinghongfei.looklook.bean.meizi; 21 | 22 | import java.util.Date; 23 | 24 | /** 25 | * Created by drakeet on 6/20/15. 26 | */ 27 | public class Meizi { 28 | public String objectId; 29 | public String url; 30 | public String type; 31 | public String desc; 32 | public String who; 33 | public boolean used; 34 | public Date createdAt; 35 | public Date updatedAt; 36 | public boolean hasFadedIn=false; 37 | 38 | public int getImageHeight() { 39 | return imageHeight; 40 | } 41 | 42 | public void setImageHeight(int imageHeight) { 43 | this.imageHeight = imageHeight; 44 | } 45 | 46 | public int getImageWidth() { 47 | return imageWidth; 48 | } 49 | 50 | public void setImageWidth(int imageWidth) { 51 | this.imageWidth = imageWidth; 52 | } 53 | 54 | public String getObjectId() { 55 | return objectId; 56 | } 57 | 58 | public void setObjectId(String objectId) { 59 | this.objectId = objectId; 60 | } 61 | 62 | public String getUrl() { 63 | return url; 64 | } 65 | 66 | public void setUrl(String url) { 67 | this.url = url; 68 | } 69 | 70 | public String getType() { 71 | return type; 72 | } 73 | 74 | public void setType(String type) { 75 | this.type = type; 76 | } 77 | 78 | public String getDesc() { 79 | return desc; 80 | } 81 | 82 | public void setDesc(String desc) { 83 | this.desc = desc; 84 | } 85 | 86 | public String getWho() { 87 | return who; 88 | } 89 | 90 | public void setWho(String who) { 91 | this.who = who; 92 | } 93 | 94 | public boolean isUsed() { 95 | return used; 96 | } 97 | 98 | public void setUsed(boolean used) { 99 | this.used = used; 100 | } 101 | 102 | public Date getCreatedAt() { 103 | return createdAt; 104 | } 105 | 106 | public void setCreatedAt(Date createdAt) { 107 | this.createdAt = createdAt; 108 | } 109 | 110 | public Date getUpdatedAt() { 111 | return updatedAt; 112 | } 113 | 114 | public void setUpdatedAt(Date updatedAt) { 115 | this.updatedAt = updatedAt; 116 | } 117 | 118 | public Date getPublishedAt() { 119 | return publishedAt; 120 | } 121 | 122 | public void setPublishedAt(Date publishedAt) { 123 | this.publishedAt = publishedAt; 124 | } 125 | 126 | public Date publishedAt; 127 | public int imageWidth; 128 | public int imageHeight; 129 | } 130 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/bean/meizi/MeiziData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Drakeet 3 | * 4 | * This file is part of Meizhi 5 | * 6 | * Meizhi is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Meizhi is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Meizhi. If not, see . 18 | */ 19 | 20 | package com.looklook.xinghongfei.looklook.bean.meizi; 21 | 22 | import java.util.ArrayList; 23 | 24 | 25 | /** 26 | * Created by drakeet on 8/9/15. 27 | */ 28 | public class MeiziData extends BaseData { 29 | 30 | public ArrayList results; 31 | 32 | public ArrayList getResults() { 33 | return results; 34 | } 35 | 36 | public void setResults(ArrayList results) { 37 | this.results = results; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/bean/meizi/VedioData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Drakeet 3 | * 4 | * This file is part of Meizhi 5 | * 6 | * Meizhi is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Meizhi is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Meizhi. If not, see . 18 | */ 19 | 20 | package com.looklook.xinghongfei.looklook.bean.meizi; 21 | 22 | import java.util.ArrayList; 23 | 24 | /** 25 | * 中文名是故意的,请勿吐槽[笑哭] 26 | * Created by drakeet on 8/15/15. 27 | */ 28 | public class VedioData extends BaseData { 29 | 30 | public ArrayList results; 31 | 32 | public ArrayList getResults() { 33 | return results; 34 | } 35 | 36 | public void setResults(ArrayList results) { 37 | this.results = results; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/bean/news/NewsBean.java: -------------------------------------------------------------------------------- 1 | package com.looklook.xinghongfei.looklook.bean.news; 2 | 3 | import com.google.gson.annotations.SerializedName; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * Description : 新闻实体类 9 | * Author : lauren 10 | * Email : lauren.liuling@gmail.com 11 | * Blog : http://www.liuling123.com 12 | * Date : 15/12/19 13 | */ 14 | public class NewsBean implements Serializable { 15 | 16 | /** 17 | * docid 18 | */ 19 | @SerializedName("docid") 20 | private String docid; 21 | /** 22 | * 标题 23 | */ 24 | @SerializedName("title") 25 | private String title; 26 | /** 27 | * 小内容 28 | */ 29 | @SerializedName("digest") 30 | private String digest; 31 | /** 32 | * 图片地址 33 | */ 34 | @SerializedName("imgsrc") 35 | private String imgsrc; 36 | /** 37 | * 来源 38 | */ 39 | @SerializedName("source") 40 | private String source; 41 | /** 42 | * 时间 43 | */ 44 | @SerializedName("ptime") 45 | private String ptime; 46 | /** 47 | * TAG 48 | */ 49 | @SerializedName("tag") 50 | private String tag; 51 | 52 | public boolean hasFadedIn=false; 53 | 54 | public String getDocid() { 55 | return docid; 56 | } 57 | 58 | public void setDocid(String docid) { 59 | this.docid = docid; 60 | } 61 | 62 | public String getTitle() { 63 | return title; 64 | } 65 | 66 | public void setTitle(String title) { 67 | this.title = title; 68 | } 69 | 70 | public String getDigest() { 71 | return digest; 72 | } 73 | 74 | public void setDigest(String digest) { 75 | this.digest = digest; 76 | } 77 | 78 | public String getImgsrc() { 79 | return imgsrc; 80 | } 81 | 82 | public void setImgsrc(String imgsrc) { 83 | this.imgsrc = imgsrc; 84 | } 85 | 86 | public String getSource() { 87 | return source; 88 | } 89 | 90 | public void setSource(String source) { 91 | this.source = source; 92 | } 93 | 94 | public String getPtime() { 95 | return ptime; 96 | } 97 | 98 | public void setPtime(String ptime) { 99 | this.ptime = ptime; 100 | } 101 | 102 | public String getTag() { 103 | return tag; 104 | } 105 | 106 | public void setTag(String tag) { 107 | this.tag = tag; 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/bean/news/NewsDetailBean.java: -------------------------------------------------------------------------------- 1 | package com.looklook.xinghongfei.looklook.bean.news; 2 | 3 | import com.google.gson.annotations.SerializedName; 4 | 5 | import java.io.Serializable; 6 | import java.util.List; 7 | 8 | /** 9 | * Description : 新闻详情实体类 10 | * Author : lauren 11 | * Email : lauren.liuling@gmail.com 12 | * Blog : http://www.liuling123.com 13 | * Date : 15/12/19 14 | */ 15 | public class NewsDetailBean implements Serializable { 16 | /** 17 | * docid 18 | */ 19 | @SerializedName("docid") 20 | private String docid; 21 | /** 22 | * title 23 | */ 24 | @SerializedName("title") 25 | private String title; 26 | /** 27 | * source 28 | */ 29 | @SerializedName("source") 30 | private String source; 31 | /** 32 | * body 33 | */ 34 | @SerializedName("body") 35 | private String body; 36 | /** 37 | * ptime 38 | */ 39 | @SerializedName("ptime") 40 | private String ptime; 41 | /** 42 | * cover 43 | */ 44 | @SerializedName("cover") 45 | private String cover; 46 | /** 47 | * 图片列表 48 | */ 49 | @SerializedName("imgList") 50 | private List imgList; 51 | 52 | 53 | public String getDocid() { 54 | return docid; 55 | } 56 | 57 | public void setDocid(String docid) { 58 | this.docid = docid; 59 | } 60 | 61 | public String getTitle() { 62 | return title; 63 | } 64 | 65 | public void setTitle(String title) { 66 | this.title = title; 67 | } 68 | 69 | public String getSource() { 70 | return source; 71 | } 72 | 73 | public void setSource(String source) { 74 | this.source = source; 75 | } 76 | 77 | public String getBody() { 78 | return body; 79 | } 80 | 81 | public void setBody(String body) { 82 | this.body = body; 83 | } 84 | 85 | public String getPtime() { 86 | return ptime; 87 | } 88 | 89 | public void setPtime(String ptime) { 90 | this.ptime = ptime; 91 | } 92 | 93 | public String getCover() { 94 | return cover; 95 | } 96 | 97 | public void setCover(String cover) { 98 | this.cover = cover; 99 | } 100 | 101 | public List getImgList() { 102 | return imgList; 103 | } 104 | 105 | public void setImgList(List imgList) { 106 | this.imgList = imgList; 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/bean/news/NewsList.java: -------------------------------------------------------------------------------- 1 | package com.looklook.xinghongfei.looklook.bean.news; 2 | 3 | import com.google.gson.annotations.SerializedName; 4 | 5 | import java.util.ArrayList; 6 | 7 | /** 8 | * Created by xinghongfei on 16/8/17. 9 | */ 10 | public class NewsList { 11 | 12 | // TODO: 16/8/17 donot forget remove first 13 | @SerializedName("T1348647909107") 14 | ArrayList newsList; 15 | public ArrayList getNewsList() { 16 | return newsList; 17 | } 18 | public void setNewsList(ArrayList newsList) { 19 | this.newsList = newsList; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/bean/zhihu/ZhihuDaily.java: -------------------------------------------------------------------------------- 1 | package com.looklook.xinghongfei.looklook.bean.zhihu; 2 | 3 | import com.google.gson.annotations.SerializedName; 4 | 5 | import java.util.ArrayList; 6 | 7 | /** 8 | * Created by 蔡小木 on 2016/3/6 0006. 9 | */ 10 | public class ZhihuDaily{ 11 | @SerializedName("date") 12 | private String date; 13 | @SerializedName("top_stories") 14 | private ArrayList mZhihuDailyItems; 15 | @SerializedName("stories") 16 | private ArrayList stories; 17 | 18 | public String getDate() { 19 | return date; 20 | } 21 | 22 | public void setDate(String date) { 23 | this.date = date; 24 | } 25 | 26 | public ArrayList getZhihuDailyItems() { 27 | return mZhihuDailyItems; 28 | } 29 | 30 | public void setZhihuDailyItems(ArrayList zhihuDailyItems) { 31 | this.mZhihuDailyItems = zhihuDailyItems; 32 | } 33 | 34 | public ArrayList getStories() { 35 | return stories; 36 | } 37 | 38 | public void setStories(ArrayList stories) { 39 | this.stories = stories; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/bean/zhihu/ZhihuDailyItem.java: -------------------------------------------------------------------------------- 1 | package com.looklook.xinghongfei.looklook.bean.zhihu; 2 | 3 | import com.google.gson.annotations.SerializedName; 4 | 5 | /** 6 | * Created by 蔡小木 on 2016/3/6 0006. 7 | */ 8 | public class ZhihuDailyItem{ 9 | @SerializedName("images") 10 | private String[] images; 11 | @SerializedName("type") 12 | private int type; 13 | @SerializedName("id") 14 | private String id; 15 | @SerializedName("title") 16 | private String title; 17 | private String date; 18 | public boolean hasFadedIn = false; 19 | 20 | public String[] getImages() { 21 | return images; 22 | } 23 | 24 | public void setImages(String[] images) { 25 | this.images = images; 26 | } 27 | 28 | public int getType() { 29 | return type; 30 | } 31 | 32 | public void setType(int type) { 33 | this.type = type; 34 | } 35 | 36 | public String getId() { 37 | return id; 38 | } 39 | 40 | public void setId(String id) { 41 | this.id = id; 42 | } 43 | 44 | public String getTitle() { 45 | return title; 46 | } 47 | 48 | public void setTitle(String title) { 49 | this.title = title; 50 | } 51 | 52 | public String getDate() { 53 | return date; 54 | } 55 | 56 | public void setDate(String date) { 57 | this.date = date; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/bean/zhihu/ZhihuStory.java: -------------------------------------------------------------------------------- 1 | package com.looklook.xinghongfei.looklook.bean.zhihu; 2 | 3 | import com.google.gson.annotations.SerializedName; 4 | 5 | /** 6 | * Created by 蔡小木 on 2016/3/7 0007. 7 | */ 8 | public class ZhihuStory { 9 | @SerializedName("body") 10 | private String body; 11 | @SerializedName("title") 12 | private String title; 13 | @SerializedName("image") 14 | private String image; 15 | @SerializedName("share_url") 16 | private String mShareUrl; 17 | @SerializedName("css") 18 | private String[] css; 19 | 20 | public String getBody() { 21 | return body; 22 | } 23 | 24 | public void setBody(String body) { 25 | this.body = body; 26 | } 27 | 28 | public String getTitle() { 29 | return title; 30 | } 31 | 32 | public void setTitle(String title) { 33 | this.title = title; 34 | } 35 | 36 | public String getImage() { 37 | return image; 38 | } 39 | 40 | public void setImage(String image) { 41 | this.image = image; 42 | } 43 | 44 | public String getShareUrl() { 45 | return mShareUrl; 46 | } 47 | 48 | public void setShareUrl(String shareUrl) { 49 | this.mShareUrl = shareUrl; 50 | } 51 | 52 | public String[] getCss() { 53 | return css; 54 | } 55 | 56 | public void setCss(String[] css) { 57 | this.css = css; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/config/Config.java: -------------------------------------------------------------------------------- 1 | package com.looklook.xinghongfei.looklook.config; 2 | 3 | 4 | 5 | 6 | public class Config { 7 | 8 | public static final String DB__IS_READ_NAME = "IsRead"; 9 | public static final String ZHIHU = "zhihu"; 10 | public static final String TOPNEWS= "topnews"; 11 | public static final String MEIZI="meizi"; 12 | public static final int meiziSize=10; 13 | 14 | public static boolean isNight = false; 15 | public static boolean isDebug=true; 16 | 17 | public static final String THEME_MODEL = "theme_model"; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/fragment/BaseFragment.java: -------------------------------------------------------------------------------- 1 | package com.looklook.xinghongfei.looklook.fragment; 2 | 3 | import android.support.v4.app.Fragment; 4 | 5 | /** 6 | * Created by xinghongfei on 16/8/17. 7 | */ 8 | public class BaseFragment extends Fragment { 9 | // TODO: 16/9/1 10 | } 11 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/presenter/BasePresenter.java: -------------------------------------------------------------------------------- 1 | package com.looklook.xinghongfei.looklook.presenter; 2 | 3 | 4 | public interface BasePresenter { 5 | void unsubscrible(); 6 | } 7 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/presenter/IMainPresenter.java: -------------------------------------------------------------------------------- 1 | package com.looklook.xinghongfei.looklook.presenter; 2 | 3 | /** 4 | * Created by xumaodun on 2016/12/1. 5 | */ 6 | public interface IMainPresenter extends BasePresenter{ 7 | void getBackground(); 8 | } 9 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/presenter/IMeiziPresenter.java: -------------------------------------------------------------------------------- 1 | package com.looklook.xinghongfei.looklook.presenter; 2 | 3 | /** 4 | * Created by xinghongfei on 16/8/20. 5 | */ 6 | public interface IMeiziPresenter extends BasePresenter { 7 | void getVedioData(int t); 8 | void getMeiziData(int t); 9 | } 10 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/presenter/INewTopDescriblePresenter.java: -------------------------------------------------------------------------------- 1 | package com.looklook.xinghongfei.looklook.presenter; 2 | 3 | /** 4 | * Created by xinghongfei on 16/8/17. 5 | */ 6 | public interface INewTopDescriblePresenter extends BasePresenter { 7 | void getDescribleMessage(String id); 8 | } 9 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/presenter/INewTopPresenter.java: -------------------------------------------------------------------------------- 1 | package com.looklook.xinghongfei.looklook.presenter; 2 | 3 | /** 4 | * Created by xinghongfei on 16/8/17. 5 | */ 6 | public interface INewTopPresenter extends BasePresenter { 7 | void getNewsList(int t); 8 | } 9 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/presenter/IZhihuPresenter.java: -------------------------------------------------------------------------------- 1 | package com.looklook.xinghongfei.looklook.presenter; 2 | 3 | 4 | 5 | public interface IZhihuPresenter extends BasePresenter{ 6 | void getLastZhihuNews(); 7 | 8 | void getTheDaily(String date); 9 | 10 | void getLastFromCache(); 11 | } 12 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/presenter/IZhihuStoryPresenter.java: -------------------------------------------------------------------------------- 1 | package com.looklook.xinghongfei.looklook.presenter; 2 | 3 | 4 | public interface IZhihuStoryPresenter extends BasePresenter{ 5 | void getZhihuStory(String id); 6 | 7 | void getGuokrArticle(String id); 8 | } 9 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/presenter/implPresenter/BasePresenterImpl.java: -------------------------------------------------------------------------------- 1 | package com.looklook.xinghongfei.looklook.presenter.implPresenter; 2 | 3 | 4 | import com.looklook.xinghongfei.looklook.presenter.BasePresenter; 5 | 6 | import rx.Subscription; 7 | import rx.subscriptions.CompositeSubscription; 8 | 9 | /** 10 | * Created by 蔡小木 on 2016/4/29 0029. 11 | */ 12 | public class BasePresenterImpl implements BasePresenter { 13 | 14 | private CompositeSubscription mCompositeSubscription; 15 | 16 | protected void addSubscription(Subscription s) { 17 | if (this.mCompositeSubscription == null) { 18 | this.mCompositeSubscription = new CompositeSubscription(); 19 | } 20 | this.mCompositeSubscription.add(s); 21 | } 22 | 23 | @Override 24 | public void unsubscrible() { 25 | 26 | // TODO: 16/8/17 find when unsubscrible 27 | if (this.mCompositeSubscription != null) { 28 | this.mCompositeSubscription.unsubscribe(); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/presenter/implPresenter/MainPresenterImpl.java: -------------------------------------------------------------------------------- 1 | package com.looklook.xinghongfei.looklook.presenter.implPresenter; 2 | 3 | import android.content.Context; 4 | import android.graphics.Bitmap; 5 | import android.graphics.BitmapFactory; 6 | 7 | import com.looklook.xinghongfei.looklook.api.ApiManager; 8 | import com.looklook.xinghongfei.looklook.bean.image.ImageResponse; 9 | import com.looklook.xinghongfei.looklook.presenter.IMainPresenter; 10 | import com.looklook.xinghongfei.looklook.presenter.implView.IMain; 11 | 12 | import java.io.File; 13 | import java.io.FileOutputStream; 14 | import java.io.IOException; 15 | import java.net.URL; 16 | 17 | import rx.Observer; 18 | import rx.android.schedulers.AndroidSchedulers; 19 | import rx.functions.Func1; 20 | import rx.schedulers.Schedulers; 21 | 22 | /** 23 | * Created by xumaodun on 2016/12/1. 24 | */ 25 | public class MainPresenterImpl extends BasePresenterImpl implements IMainPresenter { 26 | 27 | private IMain mIMain; 28 | private Context mContext; 29 | 30 | public MainPresenterImpl(IMain main, Context context) { 31 | if (main == null) 32 | throw new IllegalArgumentException("main must not be null"); 33 | mIMain = main; 34 | mContext = context; 35 | } 36 | 37 | @Override 38 | public void getBackground() { 39 | ApiManager.getInstence().getZhihuApiService().getImage().subscribeOn(Schedulers.io()) 40 | .map(new Func1() { 41 | @Override 42 | public Boolean call(ImageResponse imageResponse) { 43 | if (imageResponse.getData() != null && imageResponse.getData().getImages() != null) { 44 | try { 45 | Bitmap bitmap = BitmapFactory.decodeStream(new URL("http://wpstatic.zuimeia.com/" + imageResponse.getData().getImages().get(0).getImageUrl() + "?imageMogr/v2/auto-orient/thumbnail/480x320/quality/100").openConnection().getInputStream()); 46 | bitmap.compress(Bitmap.CompressFormat.JPEG, 100, new FileOutputStream(new File(mContext.getFilesDir().getPath() + "/bg.jpg"))); 47 | } catch (IOException e) { 48 | e.printStackTrace(); 49 | } 50 | } 51 | return true; 52 | } 53 | }) 54 | .observeOn(AndroidSchedulers.mainThread()) 55 | .subscribe(new Observer() { 56 | @Override 57 | public void onCompleted() { 58 | } 59 | 60 | @Override 61 | public void onError(Throwable e) { 62 | mIMain.getPic(); 63 | } 64 | 65 | @Override 66 | public void onNext(Boolean imageReponse) { 67 | mIMain.getPic(); 68 | } 69 | }); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/presenter/implPresenter/MeiziPresenterImpl.java: -------------------------------------------------------------------------------- 1 | package com.looklook.xinghongfei.looklook.presenter.implPresenter; 2 | 3 | import android.content.Context; 4 | 5 | import com.google.gson.Gson; 6 | import com.looklook.xinghongfei.looklook.api.ApiManager; 7 | import com.looklook.xinghongfei.looklook.bean.meizi.MeiziData; 8 | import com.looklook.xinghongfei.looklook.bean.meizi.VedioData; 9 | import com.looklook.xinghongfei.looklook.config.Config; 10 | import com.looklook.xinghongfei.looklook.presenter.IMeiziPresenter; 11 | import com.looklook.xinghongfei.looklook.presenter.implView.IMeiziFragment; 12 | import com.looklook.xinghongfei.looklook.util.CacheUtil; 13 | 14 | import rx.Observer; 15 | import rx.Subscription; 16 | import rx.android.schedulers.AndroidSchedulers; 17 | import rx.schedulers.Schedulers; 18 | 19 | /** 20 | * Created by 蔡小木 on 2016/4/23 0023. 21 | */ 22 | public class MeiziPresenterImpl extends BasePresenterImpl implements IMeiziPresenter { 23 | 24 | private IMeiziFragment mMeiziFragment; 25 | private CacheUtil mCacheUtil; 26 | private Gson gson = new Gson(); 27 | 28 | public MeiziPresenterImpl(Context context, IMeiziFragment mMeiziFragment) { 29 | 30 | this.mMeiziFragment = mMeiziFragment; 31 | mCacheUtil = CacheUtil.get(context); 32 | } 33 | 34 | @Override 35 | public void getMeiziData(int t) { 36 | mMeiziFragment.showProgressDialog(); 37 | Subscription subscription = ApiManager.getInstence().getGankService().getMeizhiData(t) 38 | .subscribeOn(Schedulers.io()) 39 | .observeOn(AndroidSchedulers.mainThread()) 40 | .subscribe(new Observer() { 41 | @Override 42 | public void onCompleted() { 43 | 44 | } 45 | 46 | @Override 47 | public void onError(Throwable e) { 48 | mMeiziFragment.hidProgressDialog(); 49 | mMeiziFragment.showError(e.getMessage()); 50 | } 51 | 52 | @Override 53 | public void onNext(MeiziData meiziData) { 54 | mMeiziFragment.hidProgressDialog(); 55 | mCacheUtil.put(Config.ZHIHU, gson.toJson(meiziData)); 56 | mMeiziFragment.updateMeiziData(meiziData.getResults()); 57 | } 58 | }); 59 | addSubscription(subscription); 60 | } 61 | 62 | 63 | 64 | @Override 65 | public void getVedioData(int t) { 66 | Subscription subscription = com.looklook.xinghongfei.looklook.api.ApiManager.getInstence().getGankService().getVedioData(t) 67 | .subscribeOn(Schedulers.io()) 68 | .observeOn(AndroidSchedulers.mainThread()) 69 | .subscribe(new Observer() { 70 | @Override 71 | public void onCompleted() { 72 | 73 | } 74 | 75 | @Override 76 | public void onError(Throwable e) { 77 | e.printStackTrace(); 78 | mMeiziFragment.hidProgressDialog(); 79 | mMeiziFragment.showError(e.getMessage()); 80 | } 81 | 82 | @Override 83 | public void onNext(VedioData vedioData) { 84 | mMeiziFragment.hidProgressDialog(); 85 | mMeiziFragment.updateVedioData(vedioData.getResults()); 86 | } 87 | }); 88 | addSubscription(subscription); 89 | } 90 | 91 | 92 | 93 | 94 | } 95 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/presenter/implPresenter/TopNewsDesPresenterImpl.java: -------------------------------------------------------------------------------- 1 | package com.looklook.xinghongfei.looklook.presenter.implPresenter; 2 | 3 | 4 | import com.looklook.xinghongfei.looklook.bean.news.NewsDetailBean; 5 | import com.looklook.xinghongfei.looklook.presenter.INewTopDescriblePresenter; 6 | import com.looklook.xinghongfei.looklook.presenter.implView.ITopNewsDesFragment; 7 | import com.looklook.xinghongfei.looklook.util.NewsJsonUtils; 8 | import com.looklook.xinghongfei.looklook.util.OkHttpUtils; 9 | import com.looklook.xinghongfei.looklook.util.Urls; 10 | 11 | /** 12 | * Created by 蔡小木 on 2016/4/26 0026. 13 | */ 14 | public class TopNewsDesPresenterImpl extends BasePresenterImpl implements INewTopDescriblePresenter { 15 | 16 | private ITopNewsDesFragment mITopNewsFragment; 17 | 18 | public TopNewsDesPresenterImpl(ITopNewsDesFragment topNewsFragment) { 19 | if (topNewsFragment == null) 20 | throw new IllegalArgumentException(" must not be null"); 21 | mITopNewsFragment = topNewsFragment; 22 | } 23 | private String getDetailUrl(String docId) { 24 | StringBuffer sb = new StringBuffer(Urls.NEW_DETAIL); 25 | sb.append(docId).append(Urls.END_DETAIL_URL); 26 | return sb.toString(); 27 | } 28 | 29 | @Override 30 | public void getDescribleMessage(final String docid) { 31 | mITopNewsFragment.showProgressDialog(); 32 | String url = getDetailUrl(docid); 33 | OkHttpUtils.ResultCallback loadNewsCallback = new OkHttpUtils.ResultCallback() { 34 | @Override 35 | public void onSuccess(String response) { 36 | NewsDetailBean newsDetailBean = NewsJsonUtils.readJsonNewsDetailBeans(response, docid); 37 | mITopNewsFragment.updateListItem(newsDetailBean); 38 | } 39 | 40 | @Override 41 | public void onFailure(Exception e) { 42 | mITopNewsFragment.showError(e.toString()); 43 | } 44 | }; 45 | OkHttpUtils.get(url, loadNewsCallback); 46 | 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/presenter/implPresenter/TopNewsPrensenterImpl.java: -------------------------------------------------------------------------------- 1 | package com.looklook.xinghongfei.looklook.presenter.implPresenter; 2 | 3 | import com.looklook.xinghongfei.looklook.api.ApiManager; 4 | import com.looklook.xinghongfei.looklook.bean.news.NewsList; 5 | import com.looklook.xinghongfei.looklook.presenter.INewTopPresenter; 6 | import com.looklook.xinghongfei.looklook.presenter.implView.ITopNewsFragment; 7 | 8 | import rx.Observer; 9 | import rx.Subscription; 10 | import rx.android.schedulers.AndroidSchedulers; 11 | import rx.schedulers.Schedulers; 12 | 13 | /** 14 | * Created by xinghongfei on 16/8/17. 15 | */ 16 | public class TopNewsPrensenterImpl extends BasePresenterImpl implements INewTopPresenter { 17 | 18 | ITopNewsFragment mITopNewsFragment; 19 | public TopNewsPrensenterImpl(ITopNewsFragment iTopNewsFragment){ 20 | mITopNewsFragment=iTopNewsFragment; 21 | } 22 | @Override 23 | public void getNewsList(int t) { 24 | mITopNewsFragment.showProgressDialog(); 25 | Subscription subscription= ApiManager.getInstence().getTopNewsService().getNews(t) 26 | .subscribeOn(Schedulers.io()) 27 | .observeOn(AndroidSchedulers.mainThread()) 28 | .subscribe(new Observer() { 29 | @Override 30 | public void onCompleted() { 31 | 32 | } 33 | 34 | @Override 35 | public void onError(Throwable e) { 36 | 37 | mITopNewsFragment.hidProgressDialog(); 38 | mITopNewsFragment.showError(e.toString()); 39 | } 40 | 41 | @Override 42 | public void onNext(NewsList newsList) { 43 | mITopNewsFragment.hidProgressDialog(); 44 | mITopNewsFragment.updateListItem(newsList); 45 | 46 | } 47 | }); 48 | addSubscription(subscription); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/presenter/implPresenter/ZhihuStoryPresenterImpl.java: -------------------------------------------------------------------------------- 1 | package com.looklook.xinghongfei.looklook.presenter.implPresenter; 2 | 3 | 4 | import com.looklook.xinghongfei.looklook.api.ApiManager; 5 | import com.looklook.xinghongfei.looklook.bean.zhihu.ZhihuStory; 6 | import com.looklook.xinghongfei.looklook.presenter.IZhihuStoryPresenter; 7 | import com.looklook.xinghongfei.looklook.presenter.implView.IZhihuStory; 8 | 9 | import rx.Observer; 10 | import rx.Subscription; 11 | import rx.android.schedulers.AndroidSchedulers; 12 | import rx.schedulers.Schedulers; 13 | 14 | /** 15 | * Created by 蔡小木 on 2016/4/26 0026. 16 | */ 17 | public class ZhihuStoryPresenterImpl extends BasePresenterImpl implements IZhihuStoryPresenter { 18 | 19 | private IZhihuStory mIZhihuStory; 20 | 21 | public ZhihuStoryPresenterImpl(IZhihuStory zhihuStory) { 22 | if (zhihuStory == null) 23 | throw new IllegalArgumentException("zhihuStory must not be null"); 24 | mIZhihuStory = zhihuStory; 25 | } 26 | 27 | @Override 28 | public void getZhihuStory(String id) { 29 | Subscription s = ApiManager.getInstence().getZhihuApiService().getZhihuStory(id) 30 | .subscribeOn(Schedulers.io()) 31 | .observeOn(AndroidSchedulers.mainThread()) 32 | .subscribe(new Observer() { 33 | @Override 34 | public void onCompleted() { 35 | 36 | } 37 | 38 | @Override 39 | public void onError(Throwable e) { 40 | mIZhihuStory.showError(e.getMessage()); 41 | } 42 | 43 | @Override 44 | public void onNext(ZhihuStory zhihuStory) { 45 | mIZhihuStory.showZhihuStory(zhihuStory); 46 | } 47 | }); 48 | addSubscription(s); 49 | } 50 | 51 | @Override 52 | public void getGuokrArticle(String id) { 53 | 54 | } 55 | 56 | // @Override 57 | // public void getGuokrArticle(String id) { 58 | // Subscription s = ApiManager.getInstence().getZhihuApiService().getGuokrArticle(id) 59 | // .subscribeOn(Schedulers.io()) 60 | // .observeOn(AndroidSchedulers.mainThread()) 61 | // .subscribe(new Observer() { 62 | // @Override 63 | // public void onCompleted() { 64 | // 65 | // } 66 | // 67 | // @Override 68 | // public void onError(Throwable e) { 69 | // mIZhihuStory.showError(e.getMessage()); 70 | // } 71 | // 72 | // @Override 73 | // public void onNext(GuokrArticle guokrArticle) { 74 | // mIZhihuStory.showGuokrArticle(guokrArticle); 75 | // } 76 | // }); 77 | // addSubscription(s); 78 | // } 79 | } 80 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/presenter/implView/IBaseFragment.java: -------------------------------------------------------------------------------- 1 | package com.looklook.xinghongfei.looklook.presenter.implView; 2 | 3 | /** 4 | * Created by 蔡小木 on 2016/4/26 0026. 5 | */ 6 | public interface IBaseFragment { 7 | void showProgressDialog(); 8 | 9 | void hidProgressDialog(); 10 | 11 | void showError(String error); 12 | } 13 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/presenter/implView/IMain.java: -------------------------------------------------------------------------------- 1 | package com.looklook.xinghongfei.looklook.presenter.implView; 2 | 3 | /** 4 | * Created by xumaodun on 2016/12/1. 5 | */ 6 | public interface IMain { 7 | void getPic(); 8 | } 9 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/presenter/implView/IMeiziFragment.java: -------------------------------------------------------------------------------- 1 | package com.looklook.xinghongfei.looklook.presenter.implView; 2 | 3 | import com.looklook.xinghongfei.looklook.bean.meizi.Gank; 4 | import com.looklook.xinghongfei.looklook.bean.meizi.Meizi; 5 | 6 | import java.util.ArrayList; 7 | 8 | /** 9 | * Created by xinghongfei on 16/8/20. 10 | */ 11 | public interface IMeiziFragment extends IBaseFragment { 12 | void updateMeiziData(ArrayList list); 13 | void updateVedioData(ArrayList list); 14 | } 15 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/presenter/implView/ITopNewsDesFragment.java: -------------------------------------------------------------------------------- 1 | package com.looklook.xinghongfei.looklook.presenter.implView; 2 | 3 | import com.looklook.xinghongfei.looklook.bean.news.NewsDetailBean; 4 | 5 | /** 6 | * Created by xinghongfei on 16/8/17. 7 | */ 8 | public interface ITopNewsDesFragment extends IBaseFragment { 9 | void updateListItem(NewsDetailBean newsList); 10 | } 11 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/presenter/implView/ITopNewsFragment.java: -------------------------------------------------------------------------------- 1 | package com.looklook.xinghongfei.looklook.presenter.implView; 2 | 3 | import com.looklook.xinghongfei.looklook.bean.news.NewsList; 4 | 5 | /** 6 | * Created by xinghongfei on 16/8/17. 7 | */ 8 | public interface ITopNewsFragment extends IBaseFragment { 9 | void updateListItem(NewsList newsList); 10 | } 11 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/presenter/implView/IZhihuFragment.java: -------------------------------------------------------------------------------- 1 | package com.looklook.xinghongfei.looklook.presenter.implView; 2 | 3 | 4 | import com.looklook.xinghongfei.looklook.bean.zhihu.ZhihuDaily; 5 | 6 | /** 7 | * Created by 蔡小木 on 2016/4/23 0023. 8 | */ 9 | public interface IZhihuFragment extends IBaseFragment { 10 | void updateList(ZhihuDaily zhihuDaily); 11 | } 12 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/presenter/implView/IZhihuStory.java: -------------------------------------------------------------------------------- 1 | package com.looklook.xinghongfei.looklook.presenter.implView; 2 | 3 | 4 | import com.looklook.xinghongfei.looklook.bean.zhihu.ZhihuStory; 5 | 6 | 7 | public interface IZhihuStory { 8 | 9 | void showError(String error); 10 | 11 | void showZhihuStory(ZhihuStory zhihuStory); 12 | } 13 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/util/DBUtils.java: -------------------------------------------------------------------------------- 1 | package com.looklook.xinghongfei.looklook.util; 2 | 3 | import android.content.ContentValues; 4 | import android.content.Context; 5 | import android.database.Cursor; 6 | import android.database.sqlite.SQLiteDatabase; 7 | import android.database.sqlite.SQLiteOpenHelper; 8 | 9 | import com.looklook.xinghongfei.looklook.config.Config; 10 | 11 | 12 | /** 13 | * Created by 蔡小木 on 2016/4/14 0014. 14 | */ 15 | public class DBUtils { 16 | public static final String CREATE_TABLE_IF_NOT_EXISTS = "create table if not exists %s " + 17 | "(id integer primary key autoincrement,key text unique,is_read integer)"; 18 | 19 | private static DBUtils sDBUtis; 20 | private SQLiteDatabase mSQLiteDatabase; 21 | 22 | private DBUtils(Context context) { 23 | mSQLiteDatabase = new DBHelper(context, Config.DB__IS_READ_NAME + ".db").getWritableDatabase(); 24 | } 25 | 26 | public static synchronized DBUtils getDB(Context context) { 27 | if (sDBUtis == null) 28 | sDBUtis = new DBUtils(context); 29 | return sDBUtis; 30 | } 31 | 32 | 33 | public void insertHasRead(String table, String key, int value) { 34 | Cursor cursor = mSQLiteDatabase.query(table, null, null, null, null, null, "id asc"); 35 | if (cursor.getCount() > 200 && cursor.moveToNext()) { 36 | mSQLiteDatabase.delete(table, "id=?", new String[]{String.valueOf(cursor.getInt(cursor.getColumnIndex("id")))}); 37 | } 38 | cursor.close(); 39 | ContentValues contentValues = new ContentValues(); 40 | contentValues.put("key", key); 41 | contentValues.put("is_read", value); 42 | mSQLiteDatabase.insertWithOnConflict(table, null, contentValues, SQLiteDatabase.CONFLICT_REPLACE); 43 | } 44 | 45 | public boolean isRead(String table, String key, int value) { 46 | boolean isRead = false; 47 | Cursor cursor = mSQLiteDatabase.query(table, null, "key=?", new String[]{key}, null, null, null); 48 | if (cursor.moveToNext() && (cursor.getInt(cursor.getColumnIndex("is_read")) == value)) { 49 | isRead = true; 50 | } 51 | cursor.close(); 52 | return isRead; 53 | } 54 | 55 | public class DBHelper extends SQLiteOpenHelper { 56 | 57 | public DBHelper(Context context, String name) { 58 | super(context, name, null, 1); 59 | } 60 | 61 | @Override 62 | public void onCreate(SQLiteDatabase db) { 63 | 64 | db.execSQL(String.format(CREATE_TABLE_IF_NOT_EXISTS, Config.ZHIHU)); 65 | db.execSQL(String.format(CREATE_TABLE_IF_NOT_EXISTS, Config.TOPNEWS)); 66 | } 67 | 68 | @Override 69 | public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { 70 | 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/util/DensityUtil.java: -------------------------------------------------------------------------------- 1 | package com.looklook.xinghongfei.looklook.util; 2 | 3 | import android.annotation.TargetApi; 4 | import android.app.Activity; 5 | import android.content.Context; 6 | import android.graphics.Point; 7 | import android.os.Build; 8 | import android.util.DisplayMetrics; 9 | import android.view.Display; 10 | import android.view.WindowManager; 11 | 12 | /** 13 | * liujingyuan 14 | */ 15 | public class DensityUtil { 16 | 17 | private static int[] deviceWidthHeight = new int[2]; 18 | public static int[] getDeviceInfo(Context context) { 19 | if ((deviceWidthHeight[0] == 0) && (deviceWidthHeight[1] == 0)) { 20 | DisplayMetrics metrics = new DisplayMetrics(); 21 | ((Activity) context).getWindowManager().getDefaultDisplay() 22 | .getMetrics(metrics); 23 | 24 | deviceWidthHeight[0] = metrics.widthPixels; 25 | deviceWidthHeight[1] = metrics.heightPixels; 26 | } 27 | return deviceWidthHeight; 28 | } 29 | /** 30 | * 31 | * @param context 上下文 32 | * @param dpValue dp数值 33 | * @return dp to px 34 | */ 35 | public static int dip2px(Context context, float dpValue) { 36 | final float scale = context.getResources().getDisplayMetrics().density; 37 | return (int) (dpValue * scale + 0.5f); 38 | 39 | } 40 | /** 41 | * 获取屏幕尺寸 42 | */ 43 | @SuppressWarnings("deprecation") 44 | @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2) 45 | public static Point getScreenSize(Context context){ 46 | WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); 47 | Display display = windowManager.getDefaultDisplay(); 48 | if(Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB_MR2){ 49 | return new Point(display.getWidth(), display.getHeight()); 50 | }else{ 51 | Point point = new Point(); 52 | display.getSize(point); 53 | return point; 54 | } 55 | } 56 | /** 57 | * 58 | * @param context 上下文 59 | * @param pxValue px的数值 60 | * @return px to dp 61 | */ 62 | public static int px2dip(Context context, float pxValue) { 63 | final float scale = context.getResources().getDisplayMetrics().density; 64 | return (int) (pxValue / scale + 0.5f); 65 | 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/util/DribbbleTarget.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 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 | 17 | package com.looklook.xinghongfei.looklook.util; 18 | 19 | import android.graphics.Bitmap; 20 | import android.support.v4.content.ContextCompat; 21 | import android.support.v7.graphics.Palette; 22 | 23 | import com.bumptech.glide.load.resource.bitmap.GlideBitmapDrawable; 24 | import com.bumptech.glide.load.resource.drawable.GlideDrawable; 25 | import com.bumptech.glide.load.resource.gif.GifDrawable; 26 | import com.bumptech.glide.request.animation.GlideAnimation; 27 | import com.bumptech.glide.request.target.GlideDrawableImageViewTarget; 28 | import com.looklook.xinghongfei.looklook.R; 29 | import com.looklook.xinghongfei.looklook.widget.BadgedFourThreeImageView; 30 | 31 | /** 32 | * A Glide {@see ViewTarget} for {@link BadgedFourThreeImageView}s. It applies a badge for animated 33 | * images, can prevent GIFs from auto-playing & applies a palette generated ripple. 34 | */ 35 | public class DribbbleTarget extends GlideDrawableImageViewTarget implements 36 | Palette.PaletteAsyncListener { 37 | 38 | private final boolean autoplayGifs; 39 | 40 | public DribbbleTarget(BadgedFourThreeImageView view, boolean autoplayGifs) { 41 | super(view); 42 | this.autoplayGifs = autoplayGifs; 43 | } 44 | 45 | @Override 46 | public void onResourceReady(GlideDrawable resource, GlideAnimation 47 | animation) { 48 | super.onResourceReady(resource, animation); 49 | if (!autoplayGifs) { 50 | resource.stop(); 51 | } 52 | 53 | BadgedFourThreeImageView badgedImageView = (BadgedFourThreeImageView) getView(); 54 | if (resource instanceof GlideBitmapDrawable) { 55 | Palette.from(((GlideBitmapDrawable) resource).getBitmap()) 56 | .clearFilters() 57 | .generate(this); 58 | } else if (resource instanceof GifDrawable) { 59 | Bitmap image = ((GifDrawable) resource).getFirstFrame(); 60 | Palette.from(image).clearFilters().generate(this); 61 | 62 | // look at the corner to determine the gif badge color 63 | int cornerSize = (int) (56 * getView().getContext().getResources().getDisplayMetrics 64 | ().scaledDensity); 65 | Bitmap corner = Bitmap.createBitmap(image, 66 | image.getWidth() - cornerSize, 67 | image.getHeight() - cornerSize, 68 | cornerSize, cornerSize); 69 | boolean isDark = ColorUtils.isDark(corner); 70 | corner.recycle(); 71 | badgedImageView.setBadgeColor(ContextCompat.getColor(getView().getContext(), 72 | isDark ? R.color.gif_badge_dark_image : R.color.gif_badge_light_image)); 73 | } 74 | } 75 | 76 | @Override 77 | public void onStart() { 78 | if (autoplayGifs) { 79 | super.onStart(); 80 | } 81 | } 82 | 83 | @Override 84 | public void onStop() { 85 | if (autoplayGifs) { 86 | super.onStop(); 87 | } 88 | } 89 | 90 | @Override 91 | public void onGenerated(Palette palette) { 92 | ((BadgedFourThreeImageView) getView()).setForeground( 93 | ViewUtils.createRipple(palette, 0.25f, 0.5f, 94 | ContextCompat.getColor(getView().getContext(), R.color.mid_grey), true)); 95 | } 96 | 97 | } 98 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/util/GlideUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 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 | 17 | package com.looklook.xinghongfei.looklook.util; 18 | 19 | import android.graphics.Bitmap; 20 | 21 | import com.bumptech.glide.load.resource.bitmap.GlideBitmapDrawable; 22 | import com.bumptech.glide.load.resource.drawable.GlideDrawable; 23 | import com.bumptech.glide.load.resource.gif.GifDrawable; 24 | 25 | /** 26 | * Utility methods for working with Glide. 27 | */ 28 | public class GlideUtils { 29 | 30 | private GlideUtils() { 31 | } 32 | 33 | public static Bitmap getBitmap(GlideDrawable glideDrawable) { 34 | if (glideDrawable instanceof GlideBitmapDrawable) { 35 | return ((GlideBitmapDrawable) glideDrawable).getBitmap(); 36 | } else if (glideDrawable instanceof GifDrawable) { 37 | return ((GifDrawable) glideDrawable).getFirstFrame(); 38 | } 39 | return null; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/util/Help.java: -------------------------------------------------------------------------------- 1 | package com.looklook.xinghongfei.looklook.util; 2 | 3 | import android.app.Activity; 4 | import android.support.annotation.NonNull; 5 | import android.support.annotation.Nullable; 6 | import android.support.v4.util.Pair; 7 | import android.view.View; 8 | 9 | import java.util.ArrayList; 10 | import java.util.Arrays; 11 | import java.util.List; 12 | 13 | /** 14 | * Created by xinghongfei on 16/8/16. 15 | */ 16 | public class Help { 17 | public static Pair[] createSafeTransitionParticipants(@NonNull Activity activity, 18 | boolean includeStatusBar, @Nullable Pair... otherParticipants) { 19 | // Avoid system UI glitches as described here: 20 | // https://plus.google.com/+AlexLockwood/posts/RPtwZ5nNebb 21 | View decor = activity.getWindow().getDecorView(); 22 | View statusBar = null; 23 | if (includeStatusBar) { 24 | statusBar = decor.findViewById(android.R.id.statusBarBackground); 25 | } 26 | View navBar = decor.findViewById(android.R.id.navigationBarBackground); 27 | 28 | // Create pair of transition participants. 29 | List participants = new ArrayList<>(3); 30 | addNonNullViewToTransitionParticipants(statusBar, participants); 31 | addNonNullViewToTransitionParticipants(navBar, participants); 32 | // only add transition participants if there's at least one none-null element 33 | if (otherParticipants != null && !(otherParticipants.length == 1 34 | && otherParticipants[0] == null)) { 35 | participants.addAll(Arrays.asList(otherParticipants)); 36 | } 37 | return participants.toArray(new Pair[participants.size()]); 38 | } 39 | 40 | private static void addNonNullViewToTransitionParticipants(View view, List participants) { 41 | if (view == null) { 42 | return; 43 | } 44 | participants.add(new Pair<>(view, view.getTransitionName())); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/util/ImageLoader.java: -------------------------------------------------------------------------------- 1 | package com.looklook.xinghongfei.looklook.util; 2 | 3 | import android.content.Context; 4 | import android.graphics.Color; 5 | import android.widget.ImageView; 6 | 7 | import com.bumptech.glide.Glide; 8 | import com.looklook.xinghongfei.looklook.config.Config; 9 | 10 | 11 | /** 12 | * Created by 蔡小木 on 2016/5/23 0023. 13 | */ 14 | 15 | public class ImageLoader { 16 | private ImageLoader() { 17 | } 18 | 19 | public static void loadImage(Context context, String url, ImageView imageView) { 20 | if (Config.isNight) { 21 | imageView.setAlpha(0.2f); 22 | imageView.setBackgroundColor(Color.BLACK); 23 | } 24 | Glide.with(context).load(url).centerCrop().into(imageView); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/util/ImageTarget.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 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 | 17 | package com.looklook.xinghongfei.looklook.util; 18 | 19 | import android.graphics.Bitmap; 20 | import android.support.v4.content.ContextCompat; 21 | import android.support.v7.graphics.Palette; 22 | 23 | import com.bumptech.glide.load.resource.bitmap.GlideBitmapDrawable; 24 | import com.bumptech.glide.load.resource.drawable.GlideDrawable; 25 | import com.bumptech.glide.load.resource.gif.GifDrawable; 26 | import com.bumptech.glide.request.animation.GlideAnimation; 27 | import com.bumptech.glide.request.target.GlideDrawableImageViewTarget; 28 | import com.looklook.xinghongfei.looklook.R; 29 | import com.looklook.xinghongfei.looklook.widget.BadgedFourThreeImageView; 30 | 31 | 32 | /** 33 | * A Glide {@see ViewTarget} for {@link BadgedFourThreeImageView}s. It applies a badge for animated 34 | * images, can prevent GIFs from auto-playing & applies a palette generated ripple. 35 | */ 36 | public class ImageTarget extends GlideDrawableImageViewTarget implements 37 | Palette.PaletteAsyncListener { 38 | 39 | private final boolean autoplayGifs; 40 | 41 | public ImageTarget(BadgedFourThreeImageView view, boolean autoplayGifs) { 42 | super(view); 43 | this.autoplayGifs = autoplayGifs; 44 | } 45 | 46 | @Override 47 | public void onResourceReady(GlideDrawable resource, GlideAnimation 48 | animation) { 49 | super.onResourceReady(resource, animation); 50 | if (!autoplayGifs) { 51 | resource.stop(); 52 | } 53 | 54 | BadgedFourThreeImageView badgedImageView = (BadgedFourThreeImageView) getView(); 55 | if (resource instanceof GlideBitmapDrawable) { 56 | Palette.from(((GlideBitmapDrawable) resource).getBitmap()) 57 | .clearFilters() 58 | .generate(this); 59 | } else if (resource instanceof GifDrawable) { 60 | Bitmap image = ((GifDrawable) resource).getFirstFrame(); 61 | Palette.from(image).clearFilters().generate(this); 62 | 63 | // look at the corner to determine the gif badge color 64 | int cornerSize = (int) (56 * getView().getContext().getResources().getDisplayMetrics 65 | ().scaledDensity); 66 | Bitmap corner = Bitmap.createBitmap(image, 67 | image.getWidth() - cornerSize, 68 | image.getHeight() - cornerSize, 69 | cornerSize, cornerSize); 70 | boolean isDark = ColorUtils.isDark(corner); 71 | corner.recycle(); 72 | badgedImageView.setBadgeColor(ContextCompat.getColor(getView().getContext(), 73 | isDark ? R.color.gif_badge_dark_image : R.color.gif_badge_light_image)); 74 | } 75 | } 76 | 77 | @Override 78 | public void onStart() { 79 | if (autoplayGifs) { 80 | super.onStart(); 81 | } 82 | } 83 | 84 | @Override 85 | public void onStop() { 86 | if (autoplayGifs) { 87 | super.onStop(); 88 | } 89 | } 90 | 91 | @Override 92 | public void onGenerated(Palette palette) { 93 | ((BadgedFourThreeImageView) getView()).setForeground( 94 | ViewUtils.createRipple(palette, 0.25f, 0.5f, 95 | ContextCompat.getColor(getView().getContext(), R.color.mid_grey), true)); 96 | } 97 | 98 | } 99 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/util/JsonUtils.java: -------------------------------------------------------------------------------- 1 | package com.looklook.xinghongfei.looklook.util; 2 | 3 | import com.google.gson.Gson; 4 | import com.google.gson.JsonObject; 5 | import com.google.gson.JsonSyntaxException; 6 | 7 | import java.lang.reflect.Type; 8 | 9 | /** 10 | * Description : Json转换工具类 11 | * Author : lauren 12 | * Email : lauren.liuling@gmail.com 13 | * Blog : http://www.liuling123.com 14 | * Date : 15/12/17 15 | */ 16 | public class JsonUtils { 17 | 18 | private static Gson mGson = new Gson(); 19 | 20 | /** 21 | * 将对象准换为json字符串 22 | * @param object 23 | * @param 24 | * @return 25 | */ 26 | public static String serialize(T object) { 27 | return mGson.toJson(object); 28 | } 29 | 30 | /** 31 | * 将json字符串转换为对象 32 | * @param json 33 | * @param clz 34 | * @param 35 | * @return 36 | */ 37 | public static T deserialize(String json, Class clz) throws JsonSyntaxException { 38 | return mGson.fromJson(json, clz); 39 | } 40 | 41 | /** 42 | * 将json对象转换为实体对象 43 | * @param json 44 | * @param clz 45 | * @param 46 | * @return 47 | * @throws JsonSyntaxException 48 | */ 49 | public static T deserialize(JsonObject json, Class clz) throws JsonSyntaxException { 50 | return mGson.fromJson(json, clz); 51 | } 52 | 53 | /** 54 | * 将json字符串转换为对象 55 | * @param json 56 | * @param type 57 | * @param 58 | * @return 59 | */ 60 | public static T deserialize(String json, Type type) throws JsonSyntaxException { 61 | return mGson.fromJson(json, type); 62 | } 63 | 64 | 65 | 66 | 67 | 68 | 69 | } 70 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/util/MathUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 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 | 17 | package com.looklook.xinghongfei.looklook.util; 18 | 19 | /** 20 | * Borrowed from github.com/romannurik/muzei 21 | */ 22 | public class MathUtils { 23 | 24 | private MathUtils() { } 25 | 26 | public static float constrain(float min, float max, float v) { 27 | return Math.max(min, Math.min(max, v)); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/util/NetWorkUtil.java: -------------------------------------------------------------------------------- 1 | package com.looklook.xinghongfei.looklook.util; 2 | 3 | import android.content.Context; 4 | import android.net.ConnectivityManager; 5 | import android.net.NetworkInfo; 6 | 7 | /** 8 | * Created by 蔡小木 on 2016/3/16 0016. 9 | */ 10 | public class NetWorkUtil { 11 | 12 | private NetWorkUtil() {} 13 | 14 | /** 15 | * 判断网络是否可用 16 | * 17 | * @param context 18 | * @return 19 | */ 20 | public static boolean isNetWorkAvailable(Context context) { 21 | ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); 22 | NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo(); 23 | return networkInfo != null && networkInfo.isConnected(); 24 | } 25 | 26 | /** 27 | * 检测wifi是否连接 28 | * 29 | * @return 30 | */ 31 | public static boolean isWifiConnected(Context context) { 32 | ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); 33 | NetworkInfo networkInfo = cm.getActiveNetworkInfo(); 34 | return networkInfo != null && networkInfo.getType() == ConnectivityManager.TYPE_WIFI; 35 | } 36 | 37 | /** 38 | * 检测3G是否连接 39 | * 40 | * @return 41 | */ 42 | public static boolean is3gConnected(Context context) { 43 | ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); 44 | NetworkInfo networkInfo = cm.getActiveNetworkInfo(); 45 | return networkInfo != null && networkInfo.getType() == ConnectivityManager.TYPE_MOBILE; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/util/NewsJsonUtils.java: -------------------------------------------------------------------------------- 1 | package com.looklook.xinghongfei.looklook.util; 2 | 3 | import com.google.gson.JsonArray; 4 | import com.google.gson.JsonElement; 5 | import com.google.gson.JsonObject; 6 | import com.google.gson.JsonParser; 7 | import com.looklook.xinghongfei.looklook.bean.news.NewsBean; 8 | import com.looklook.xinghongfei.looklook.bean.news.NewsDetailBean; 9 | 10 | import java.util.ArrayList; 11 | import java.util.List; 12 | 13 | /** 14 | * Description : 15 | * Author : lauren 16 | * Email : lauren.liuling@gmail.com 17 | * Blog : http://www.liuling123.com 18 | * Date : 15/12/19 19 | */ 20 | public class NewsJsonUtils { 21 | 22 | private final static String TAG = "NewsJsonUtils"; 23 | 24 | /** 25 | * 将获取到的json转换为新闻列表对象 26 | * @param res 27 | * @param value 28 | * @return 29 | */ 30 | public static List readJsonNewsBeans(String res, String value) { 31 | List beans = new ArrayList(); 32 | try { 33 | JsonParser parser = new JsonParser(); 34 | JsonObject jsonObj = parser.parse(res).getAsJsonObject(); 35 | JsonElement jsonElement = jsonObj.get(value); 36 | if(jsonElement == null) { 37 | return null; 38 | } 39 | JsonArray jsonArray = jsonElement.getAsJsonArray(); 40 | for (int i = 1; i < jsonArray.size(); i++) { 41 | JsonObject jo = jsonArray.get(i).getAsJsonObject(); 42 | if (jo.has("skipType") && "special".equals(jo.get("skipType").getAsString())) { 43 | continue; 44 | } 45 | if (jo.has("TAGS") && !jo.has("TAG")) { 46 | continue; 47 | } 48 | 49 | if (!jo.has("imgextra")) { 50 | NewsBean news = JsonUtils.deserialize(jo, NewsBean.class); 51 | beans.add(news); 52 | } 53 | } 54 | } catch (Exception e) { 55 | } 56 | return beans; 57 | } 58 | 59 | public static NewsDetailBean readJsonNewsDetailBeans(String res, String docId) { 60 | NewsDetailBean newsDetailBean = null; 61 | try { 62 | JsonParser parser = new JsonParser(); 63 | JsonObject jsonObj = parser.parse(res).getAsJsonObject(); 64 | JsonElement jsonElement = jsonObj.get(docId); 65 | if(jsonElement == null) { 66 | return null; 67 | } 68 | newsDetailBean = JsonUtils.deserialize(jsonElement.getAsJsonObject(), NewsDetailBean.class); 69 | } catch (Exception e) { 70 | } 71 | return newsDetailBean; 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/util/ObservableColorMatrix.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 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 | 17 | package com.looklook.xinghongfei.looklook.util; 18 | 19 | import android.graphics.ColorMatrix; 20 | import android.util.Property; 21 | 22 | /** 23 | * An extension to {@link ColorMatrix} which caches the saturation value for animation purposes. 24 | */ 25 | public class ObservableColorMatrix extends ColorMatrix { 26 | 27 | private float saturation = 1f; 28 | 29 | public ObservableColorMatrix() { 30 | super(); 31 | } 32 | 33 | public float getSaturation() { 34 | return saturation; 35 | } 36 | 37 | @Override 38 | public void setSaturation(float saturation) { 39 | this.saturation = saturation; 40 | super.setSaturation(saturation); 41 | } 42 | 43 | public static final Property SATURATION 44 | = new AnimUtils.FloatProperty("saturation") { 45 | 46 | @Override 47 | public void setValue(ObservableColorMatrix cm, float value) { 48 | cm.setSaturation(value); 49 | } 50 | 51 | @Override 52 | public Float get(ObservableColorMatrix cm) { 53 | return cm.getSaturation(); 54 | } 55 | }; 56 | 57 | } 58 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/util/Once.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Drakeet 3 | * 4 | * This file is part of Meizhi 5 | * 6 | * Meizhi is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Meizhi is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Meizhi. If not, see . 18 | */ 19 | 20 | package com.looklook.xinghongfei.looklook.util; 21 | 22 | import android.content.Context; 23 | import android.content.SharedPreferences; 24 | 25 | /** 26 | * Created by drakeet on 8/16/15. 27 | */ 28 | public class Once { 29 | 30 | SharedPreferences mSharedPreferences; 31 | Context mContext; 32 | 33 | 34 | public Once(Context context) { 35 | mSharedPreferences = context.getSharedPreferences("once", Context.MODE_PRIVATE); 36 | mContext = context; 37 | } 38 | 39 | 40 | public void show(String tagKey, OnceCallback callback) { 41 | boolean isSecondTime = mSharedPreferences.getBoolean(tagKey, false); 42 | if (!isSecondTime) { 43 | callback.onOnce(); 44 | SharedPreferences.Editor editor = mSharedPreferences.edit(); 45 | editor.putBoolean(tagKey, true); 46 | editor.apply(); 47 | } 48 | } 49 | 50 | 51 | public void show(int tagKeyResId, OnceCallback callback) { 52 | show(mContext.getString(tagKeyResId), callback); 53 | } 54 | 55 | 56 | public interface OnceCallback { 57 | void onOnce(); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/util/SharePreferenceUtil.java: -------------------------------------------------------------------------------- 1 | package com.looklook.xinghongfei.looklook.util; 2 | 3 | import android.content.Context; 4 | import android.content.SharedPreferences; 5 | import android.preference.PreferenceManager; 6 | 7 | import com.looklook.xinghongfei.looklook.R; 8 | 9 | /** 10 | * Created by 蔡小木 on 2016/3/13 0013. 11 | */ 12 | public class SharePreferenceUtil { 13 | 14 | private SharePreferenceUtil() {} 15 | 16 | public static final String SHARED_PREFERENCE_NAME = "micro_reader"; 17 | public static final String IMAGE_DESCRIPTION = "image_description"; 18 | public static final String VIBRANT = "vibrant"; 19 | public static final String MUTED = "muted"; 20 | public static final String IMAGE_GET_TIME = "image_get_time"; 21 | public static final String SAVED_CHANNEL = "saved_channel"; 22 | 23 | public static boolean isRefreshOnlyWifi(Context context) { 24 | SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); 25 | return sharedPreferences.getBoolean(context.getResources().getString(R.string.pre_refresh_data), false); 26 | } 27 | 28 | public static boolean isChangeThemeAuto(Context context) { 29 | SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); 30 | return sharedPreferences.getBoolean(context.getResources().getString(R.string.pre_get_image), true); 31 | } 32 | 33 | public static boolean isImmersiveMode(Context context) { 34 | SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); 35 | return sharedPreferences.getBoolean(context.getString(R.string.pre_status_bar), true); 36 | } 37 | 38 | public static boolean isChangeNavColor(Context context) { 39 | SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); 40 | return sharedPreferences.getBoolean(context.getString(R.string.pre_nav_color), true); 41 | } 42 | 43 | public static boolean isUseLocalBrowser(Context context) { 44 | SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); 45 | return sharedPreferences.getBoolean(context.getString(R.string.pre_use_local), false); 46 | } 47 | 48 | public static int getNevigationItem(Context context){ 49 | SharedPreferences sharedPreferences=PreferenceManager.getDefaultSharedPreferences(context); 50 | return sharedPreferences.getInt(context.getString(R.string.nevigation_item),-1); 51 | } 52 | public static void putNevigationItem(Context context,int t){ 53 | SharedPreferences sharedPreferences=PreferenceManager.getDefaultSharedPreferences(context); 54 | SharedPreferences.Editor editor=sharedPreferences.edit(); 55 | editor.putInt(context.getString(R.string.nevigation_item),t); 56 | editor.commit(); 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/util/Urls.java: -------------------------------------------------------------------------------- 1 | package com.looklook.xinghongfei.looklook.util; 2 | 3 | /** 4 | * Description : 接口API的URL 5 | * Author : lauren 6 | * Email : lauren.liuling@gmail.com 7 | * Blog : http://www.liuling123.com 8 | * Date : 15/12/13 9 | */ 10 | public class Urls { 11 | 12 | //http://c.m.163.com/nc/article/headline/T1348647909107/0-5.html 头条 13 | 14 | public static final int PAZE_SIZE = 20; 15 | 16 | public static final String HOST = "http://c.m.163.com/"; 17 | public static final String END_URL = "-" + PAZE_SIZE + ".html"; 18 | public static final String END_DETAIL_URL = "/full.html"; 19 | // 头条 20 | public static final String TOP_URL = HOST + "nc/article/headline/"; 21 | public static final String TOP_ID = "T1348647909107"; 22 | // 新闻详情 23 | public static final String NEW_DETAIL = HOST + "nc/article/"; 24 | 25 | public static final String COMMON_URL = HOST + "nc/article/list/"; 26 | 27 | 28 | // 图片 29 | public static final String IMAGES_URL = "http://api.laifudao.com/open/tupian.json"; 30 | 31 | // 天气预报url 32 | public static final String WEATHER = "http://wthrcdn.etouch.cn/weather_mini?city="; 33 | 34 | //百度定位 35 | public static final String INTERFACE_LOCATION = "http://api.map.baidu.com/geocoder"; 36 | 37 | } 38 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/util/WebUtil.java: -------------------------------------------------------------------------------- 1 | package com.looklook.xinghongfei.looklook.util; 2 | 3 | /** 4 | * Created by 蔡小木 on 2016/3/7 0007. 5 | */ 6 | public class WebUtil { 7 | 8 | private WebUtil() { 9 | } 10 | 11 | public static final String BASE_URL = "file:///android_asset/"; 12 | public static final String MIME_TYPE = "text/html"; 13 | public static final String ENCODING = "utf-8"; 14 | public static final String FAIL_URL = "http//:daily.zhihu.com/"; 15 | 16 | private static final String CSS_LINK_PATTERN = " "; 17 | private static final String NIGHT_DIV_TAG_START = "
"; 18 | private static final String NIGHT_DIV_TAG_END = "
"; 19 | 20 | private static final String DIV_IMAGE_PLACE_HOLDER = "class=\"img-place-holder\""; 21 | private static final String DIV_IMAGE_PLACE_HOLDER_IGNORED = "class=\"img-place-holder-ignored\""; 22 | 23 | public static String buildHtmlWithCss(String html, String[] cssUrls, boolean isNightMode) { 24 | StringBuilder result = new StringBuilder(); 25 | for (String cssUrl : cssUrls) { 26 | result.append(String.format(CSS_LINK_PATTERN, cssUrl)); 27 | } 28 | 29 | if (isNightMode) { 30 | result.append(NIGHT_DIV_TAG_START); 31 | } 32 | result.append(html.replace(DIV_IMAGE_PLACE_HOLDER, DIV_IMAGE_PLACE_HOLDER_IGNORED)); 33 | if (isNightMode) { 34 | result.append(NIGHT_DIV_TAG_END); 35 | } 36 | return result.toString(); 37 | } 38 | 39 | public static String buildHtmlForIt(String content, boolean isNightMode) { 40 | StringBuilder modifiedHtml = new StringBuilder(); 41 | modifiedHtml.append("" + "" 42 | + "" + "" + "" 43 | + "" + "" 44 | + "" 45 | + "" + ""); 46 | modifiedHtml.append(""); 51 | modifiedHtml.append(content); 52 | modifiedHtml.append(""); 53 | return modifiedHtml.toString(); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/util/common/UIUtils.java: -------------------------------------------------------------------------------- 1 | package com.looklook.xinghongfei.looklook.util.common; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | import android.net.Uri; 6 | 7 | import com.looklook.xinghongfei.looklook.MyApplication; 8 | import com.looklook.xinghongfei.looklook.R; 9 | 10 | /** 11 | * Author :hymanme 12 | * Email :hymanme@163.com 13 | * Created at 2015/7/27 14 | */ 15 | public class UIUtils { 16 | 17 | public static Context getContext() { 18 | return MyApplication.getApplication(); 19 | } 20 | 21 | /** 22 | * 页面跳转 23 | * 24 | * @param intent 25 | */ 26 | public static void startActivity(Intent intent) { 27 | // 如果不在activity里去打开activity 需要指定任务栈 需要设置标签 28 | if (com.looklook.xinghongfei.looklook.activity.BaseActivity.activity == null) { 29 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 30 | getContext().startActivity(intent); 31 | } else { 32 | com.looklook.xinghongfei.looklook.activity.BaseActivity.activity.startActivity(intent); 33 | } 34 | } 35 | 36 | /** 37 | * 分享 38 | * 39 | * @param context 40 | * @param content 分享内容 41 | * @param uri 分享图片uri 42 | */ 43 | public static void share(Context context, String content, Uri uri) { 44 | Intent shareIntent = new Intent(); 45 | shareIntent.setAction(Intent.ACTION_SEND); 46 | if (uri != null) { 47 | shareIntent.putExtra(Intent.EXTRA_STREAM, uri); 48 | shareIntent.setType("image/*"); 49 | //当用户选择短信时使用sms_body取得文字 50 | shareIntent.putExtra("sms_body", content); 51 | } else { 52 | shareIntent.setType("text/plain"); 53 | } 54 | shareIntent.putExtra(Intent.EXTRA_TEXT, content); 55 | context.startActivity(Intent.createChooser(shareIntent, context.getString(R.string.share_dialog_title))); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/view/GridItemDividerDecoration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 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 | 17 | package com.looklook.xinghongfei.looklook.view; 18 | 19 | import android.content.Context; 20 | import android.graphics.Canvas; 21 | import android.graphics.Paint; 22 | import android.support.annotation.ColorInt; 23 | import android.support.annotation.ColorRes; 24 | import android.support.annotation.DimenRes; 25 | import android.support.annotation.NonNull; 26 | import android.support.v4.content.ContextCompat; 27 | import android.support.v7.widget.RecyclerView; 28 | import android.view.View; 29 | 30 | /** 31 | * A {@link RecyclerView.ItemDecoration} which draws dividers (along the right & bottom) 32 | * for certain {@link RecyclerView.ViewHolder} types. 33 | */ 34 | public class GridItemDividerDecoration extends RecyclerView.ItemDecoration { 35 | 36 | 37 | private final float dividerSize; 38 | private final Paint paint; 39 | 40 | public GridItemDividerDecoration(float dividerSize, 41 | @ColorInt int dividerColor) { 42 | 43 | this.dividerSize = dividerSize; 44 | paint = new Paint(); 45 | paint.setColor(dividerColor); 46 | paint.setStyle(Paint.Style.FILL); 47 | } 48 | 49 | public GridItemDividerDecoration(@NonNull Context context, 50 | @DimenRes int dividerSizeResId, 51 | @ColorRes int dividerColorResId) { 52 | this( 53 | context.getResources().getDimensionPixelSize(dividerSizeResId), 54 | ContextCompat.getColor(context, dividerColorResId)); 55 | } 56 | 57 | @Override 58 | public void onDrawOver(Canvas canvas, RecyclerView parent, RecyclerView.State state) { 59 | if (parent.isAnimating()) return; 60 | 61 | final int childCount = parent.getChildCount(); 62 | final RecyclerView.LayoutManager lm = parent.getLayoutManager(); 63 | for (int i = 0; i < childCount; i++) { 64 | final View child = parent.getChildAt(i); 65 | RecyclerView.ViewHolder viewHolder = parent.getChildViewHolder(child); 66 | 67 | if (requiresDivider(viewHolder)) { 68 | final int right = lm.getDecoratedRight(child); 69 | final int bottom = lm.getDecoratedBottom(child); 70 | // draw the bottom divider 71 | canvas.drawRect(lm.getDecoratedLeft(child), 72 | bottom - dividerSize, 73 | right, 74 | bottom, 75 | paint); 76 | // draw the right edge divider 77 | canvas.drawRect(right - dividerSize, 78 | lm.getDecoratedTop(child), 79 | right, 80 | bottom - dividerSize, 81 | paint); 82 | } 83 | 84 | } 85 | } 86 | 87 | private boolean requiresDivider(RecyclerView.ViewHolder viewHolder) { 88 | 89 | return true; 90 | } 91 | 92 | } 93 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/view/Pop.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 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 | 17 | package com.looklook.xinghongfei.looklook.view; 18 | 19 | import android.animation.Animator; 20 | import android.animation.ObjectAnimator; 21 | import android.animation.PropertyValuesHolder; 22 | import android.content.Context; 23 | import android.transition.TransitionValues; 24 | import android.transition.Visibility; 25 | import android.util.AttributeSet; 26 | import android.view.View; 27 | import android.view.ViewGroup; 28 | 29 | /** 30 | * A transition that animates the alpha, scale X & Y of a view simultaneously. 31 | */ 32 | public class Pop extends Visibility { 33 | 34 | public Pop(Context context, AttributeSet attrs) { 35 | super(context, attrs); 36 | } 37 | 38 | @Override 39 | public Animator onAppear(ViewGroup sceneRoot, View view, TransitionValues startValues, 40 | TransitionValues endValues) { 41 | return ObjectAnimator.ofPropertyValuesHolder( 42 | endValues.view, 43 | PropertyValuesHolder.ofFloat(View.ALPHA, 0f, 1f), 44 | PropertyValuesHolder.ofFloat(View.SCALE_X, 0f, 1f), 45 | PropertyValuesHolder.ofFloat(View.SCALE_Y, 0f, 1f)); 46 | } 47 | 48 | @Override 49 | public Animator onDisappear(ViewGroup sceneRoot, View view, TransitionValues startValues, 50 | TransitionValues endValues) { 51 | return ObjectAnimator.ofPropertyValuesHolder( 52 | endValues.view, 53 | PropertyValuesHolder.ofFloat(View.ALPHA, 1f, 0f), 54 | PropertyValuesHolder.ofFloat(View.SCALE_X, 1f, 0f), 55 | PropertyValuesHolder.ofFloat(View.SCALE_Y, 1f, 0f)); 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/widget/FourThreeImageView.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 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 | 17 | package com.looklook.xinghongfei.looklook.widget; 18 | 19 | import android.content.Context; 20 | import android.util.AttributeSet; 21 | 22 | /** 23 | * A extension of ForegroundImageView that is always 4:3 aspect ratio. 24 | */ 25 | public class FourThreeImageView extends ForegroundImageView { 26 | 27 | public FourThreeImageView(Context context, AttributeSet attrs) { 28 | super(context, attrs); 29 | } 30 | 31 | public FourThreeImageView(Context context,AttributeSet attrs,int defStyle){ 32 | super(context, attrs,defStyle); 33 | 34 | } 35 | 36 | @Override 37 | protected void onMeasure(int widthSpec, int heightSpec) { 38 | int fourThreeHeight = MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthSpec) * 3 / 4, 39 | MeasureSpec.EXACTLY); 40 | super.onMeasure(widthSpec, fourThreeHeight); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/widget/LiftOff.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 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 | 17 | package com.looklook.xinghongfei.looklook.widget; 18 | 19 | import android.animation.Animator; 20 | import android.animation.ObjectAnimator; 21 | import android.content.Context; 22 | import android.content.res.TypedArray; 23 | import android.transition.Transition; 24 | import android.transition.TransitionValues; 25 | import android.util.AttributeSet; 26 | import android.view.View; 27 | import android.view.ViewGroup; 28 | 29 | import com.looklook.xinghongfei.looklook.R; 30 | 31 | 32 | /** 33 | * A transition that animates the elevation of a View from a given value down to zero. 34 | *

35 | * Useful for creating parent↔child navigation transitions (https://www.google.com/design/spec/patterns/navigational-transitions.html#navigational-transitions-parent-to-child) 36 | * when combined with a {@link android.transition.ChangeBounds} on a shared element. 37 | */ 38 | public class LiftOff extends Transition { 39 | 40 | private static final String PROPNAME_ELEVATION = "plaid:liftoff:elevation"; 41 | 42 | private static final String[] transitionProperties = { 43 | PROPNAME_ELEVATION 44 | }; 45 | 46 | private final float lift; 47 | 48 | public LiftOff(float lift) { 49 | this.lift = lift; 50 | } 51 | 52 | public LiftOff(Context context, AttributeSet attrs) { 53 | super(context, attrs); 54 | final TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.LiftOff); 55 | lift = ta.getDimensionPixelSize(R.styleable.LiftOff_android_elevation, 0); 56 | ta.recycle(); 57 | } 58 | 59 | @Override 60 | public String[] getTransitionProperties() { 61 | return transitionProperties; 62 | } 63 | 64 | @Override 65 | public void captureStartValues(TransitionValues transitionValues) { 66 | transitionValues.values.put(PROPNAME_ELEVATION, 0f); 67 | } 68 | 69 | @Override 70 | public void captureEndValues(TransitionValues transitionValues) { 71 | transitionValues.values.put(PROPNAME_ELEVATION, lift); 72 | } 73 | 74 | @Override 75 | public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues, 76 | TransitionValues endValues) { 77 | return ObjectAnimator.ofFloat(endValues.view, View.TRANSLATION_Z, lift, 0f); 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/widget/ShotSharedEnter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 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 | 17 | package com.looklook.xinghongfei.looklook.widget; 18 | 19 | import android.content.Context; 20 | import android.graphics.Rect; 21 | import android.transition.ChangeBounds; 22 | import android.transition.TransitionValues; 23 | import android.util.AttributeSet; 24 | import android.view.View; 25 | 26 | /** 27 | * Shared element transitions do not seem to like transitioning from a single view to two separate 28 | * views so we need to alter the ChangeBounds transition to compensate 29 | */ 30 | public class ShotSharedEnter extends ChangeBounds { 31 | 32 | private static final String PROPNAME_BOUNDS = "android:changeBounds:bounds"; 33 | private static final String PROPNAME_PARENT = "android:changeBounds:parent"; 34 | 35 | public ShotSharedEnter(Context context, AttributeSet attrs) { 36 | super(context, attrs); 37 | } 38 | 39 | @Override 40 | public void captureEndValues(TransitionValues transitionValues) { 41 | super.captureEndValues(transitionValues); 42 | int width = ((View) transitionValues.values.get(PROPNAME_PARENT)).getWidth(); 43 | Rect bounds = (Rect) transitionValues.values.get(PROPNAME_BOUNDS); 44 | bounds.right = width; 45 | bounds.bottom = width * 3 / 4; 46 | transitionValues.values.put(PROPNAME_BOUNDS, bounds); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /app/src/main/java/com/looklook/xinghongfei/looklook/widget/WrapContentLinearLayoutManager.java: -------------------------------------------------------------------------------- 1 | package com.looklook.xinghongfei.looklook.widget; 2 | 3 | import android.content.Context; 4 | import android.support.v7.widget.LinearLayoutManager; 5 | import android.support.v7.widget.RecyclerView; 6 | import android.util.AttributeSet; 7 | 8 | /** 9 | * Created by xinghongfei on 16/8/16. 10 | */ 11 | public class WrapContentLinearLayoutManager extends LinearLayoutManager { 12 | public WrapContentLinearLayoutManager(Context context) { 13 | super(context); 14 | } 15 | public WrapContentLinearLayoutManager(Context context, int orientation, boolean reverseLayout) { 16 | super(context, orientation, reverseLayout); 17 | } 18 | 19 | public WrapContentLinearLayoutManager(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { 20 | super(context, attrs, defStyleAttr, defStyleRes); 21 | } 22 | 23 | @Override 24 | public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state) { 25 | try { 26 | super.onLayoutChildren(recycler, state); 27 | } catch (IndexOutOfBoundsException e) { 28 | e.printStackTrace(); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /app/src/main/res/anim/trim_start_interpolator.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 21 | -------------------------------------------------------------------------------- /app/src/main/res/animator/app_bar_pin.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 21 | 22 | 24 | 25 | 26 | 31 | 32 | 33 | 34 | 39 | 40 | 41 | 42 | 47 | 48 | 49 | 50 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /app/src/main/res/animator/button_frown.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 27 | -------------------------------------------------------------------------------- /app/src/main/res/animator/raise.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 22 | 26 | 27 | 28 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /app/src/main/res/animator/show_connection_cross.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 20 | 21 | 28 | 29 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /app/src/main/res/animator/show_connection_line.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 27 | -------------------------------------------------------------------------------- /app/src/main/res/animator/upload_arrow_fill.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 29 | -------------------------------------------------------------------------------- /app/src/main/res/animator/upload_progress.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 21 | 22 | 29 | 30 | 37 | 38 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /app/src/main/res/animator/upload_progress_rotation.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 26 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xinghongfei/LookLook/c436ef9949aa80ee085408900c54e800c839ce77/app/src/main/res/drawable-hdpi/bg.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_color_lens_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xinghongfei/LookLook/c436ef9949aa80ee085408900c54e800c839ce77/app/src/main/res/drawable-hdpi/ic_color_lens_white_24dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/avd_uploading.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 21 | 22 | 25 | 26 | 29 | 30 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/fab.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 18 | 19 | 22 | 23 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_arrow_back.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 23 | 24 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xinghongfei/LookLook/c436ef9949aa80ee085408900c54e800c839ce77/app/src/main/res/drawable/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_uploading.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 24 | 25 | 30 | 31 | 32 | 33 | 36 | 37 | 41 | 42 | 43 | 44 | 48 | 49 | 53 | 54 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/look.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xinghongfei/LookLook/c436ef9949aa80ee085408900c54e800c839ce77/app/src/main/res/drawable/look.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/look2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xinghongfei/LookLook/c436ef9949aa80ee085408900c54e800c839ce77/app/src/main/res/drawable/look2.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/look3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xinghongfei/LookLook/c436ef9949aa80ee085408900c54e800c839ce77/app/src/main/res/drawable/look3.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/looklookbg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xinghongfei/LookLook/c436ef9949aa80ee085408900c54e800c839ce77/app/src/main/res/drawable/looklookbg.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/mid_grey_ripple.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 21 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/nav_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xinghongfei/LookLook/c436ef9949aa80ee085408900c54e800c839ce77/app/src/main/res/drawable/nav_icon.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xinghongfei/LookLook/c436ef9949aa80ee085408900c54e800c839ce77/app/src/main/res/drawable/open.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/settin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xinghongfei/LookLook/c436ef9949aa80ee085408900c54e800c839ce77/app/src/main/res/drawable/settin.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/wangyi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xinghongfei/LookLook/c436ef9949aa80ee085408900c54e800c839ce77/app/src/main/res/drawable/wangyi.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/zhihu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xinghongfei/LookLook/c436ef9949aa80ee085408900c54e800c839ce77/app/src/main/res/drawable/zhihu.png -------------------------------------------------------------------------------- /app/src/main/res/interpolator/trim_end_interpolator.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 21 | -------------------------------------------------------------------------------- /app/src/main/res/layout/action_view_switch.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_about.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 26 | 27 | 28 | 39 | 40 | 49 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_picture.xml: -------------------------------------------------------------------------------- 1 | 19 | 20 | 25 | 31 | 32 | 33 | 34 | 35 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /app/src/main/res/layout/infinite_loading.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 29 | -------------------------------------------------------------------------------- /app/src/main/res/layout/main_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 14 | 15 | 20 | 21 | 25 | 26 | 27 | 36 | 37 | 38 | 45 | 46 | -------------------------------------------------------------------------------- /app/src/main/res/layout/meizi_fragment_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 16 | 17 | 18 | 19 | 27 | 28 | 29 | 35 | 36 | 37 | 45 | 46 | -------------------------------------------------------------------------------- /app/src/main/res/layout/meizi_layout_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 22 | 23 | 27 | 28 | 29 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /app/src/main/res/layout/nav_header_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 15 | 16 | 17 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/res/layout/no_connection.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 25 | -------------------------------------------------------------------------------- /app/src/main/res/layout/no_connection_text.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 26 | -------------------------------------------------------------------------------- /app/src/main/res/layout/posting_progress.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 30 | -------------------------------------------------------------------------------- /app/src/main/res/layout/topnews_fragment_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 14 | 15 | 23 | 24 | 25 | 26 | 32 | 33 | 34 | 35 | 43 | 44 | -------------------------------------------------------------------------------- /app/src/main/res/layout/topnews_layout_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 27 | 28 | 32 | 33 | 44 | 45 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /app/src/main/res/layout/view_toolbar.xml: -------------------------------------------------------------------------------- 1 | 19 | 20 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /app/src/main/res/layout/zhihu_fragment_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 14 | 15 | 23 | 24 | 25 | 26 | 27 | 28 | 34 | 35 | 36 | 37 | 45 | 46 | -------------------------------------------------------------------------------- /app/src/main/res/layout/zhihu_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 14 | 15 | 20 | 21 | 22 | 31 | 32 | 33 | 34 | 35 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /app/src/main/res/layout/zhihu_layout_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 26 | 27 | 28 | 39 | -------------------------------------------------------------------------------- /app/src/main/res/menu/main.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 18 | 19 |

23 | 28 | 29 | -------------------------------------------------------------------------------- /app/src/main/res/menu/menu_empty.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/menu/nevmenu.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 14 | 21 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 43 | 47 | 48 | 49 | 54 | 55 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xinghongfei/LookLook/c436ef9949aa80ee085408900c54e800c839ce77/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xinghongfei/LookLook/c436ef9949aa80ee085408900c54e800c839ce77/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xinghongfei/LookLook/c436ef9949aa80ee085408900c54e800c839ce77/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/mylook.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xinghongfei/LookLook/c436ef9949aa80ee085408900c54e800c839ce77/app/src/main/res/mipmap-xhdpi/mylook.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/downlosd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xinghongfei/LookLook/c436ef9949aa80ee085408900c54e800c839ce77/app/src/main/res/mipmap-xxhdpi/downlosd.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xinghongfei/LookLook/c436ef9949aa80ee085408900c54e800c839ce77/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/look.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xinghongfei/LookLook/c436ef9949aa80ee085408900c54e800c839ce77/app/src/main/res/mipmap-xxhdpi/look.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xinghongfei/LookLook/c436ef9949aa80ee085408900c54e800c839ce77/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/look.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xinghongfei/LookLook/c436ef9949aa80ee085408900c54e800c839ce77/app/src/main/res/mipmap-xxxhdpi/look.png -------------------------------------------------------------------------------- /app/src/main/res/transition/dribbble_shot_enter.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /app/src/main/res/transition/dribbble_shot_return.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /app/src/main/res/transition/dribbble_shot_shared_enter.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 22 | 23 | 24 | 25 | 29 | 30 | 31 | 32 | 33 | 34 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /app/src/main/res/transition/dribbble_shot_shared_return.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 18 | 19 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /app/src/main/res/transition/home_enter.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 20 | 21 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/no_connection.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | M26,159 L26,159 L32,159 L32,159 Z 20 | M26,67 L26,159 L32,159 L32,67 Z 21 | M24,206.5 C24,206.5 27.6392462,206.449997 28,206.449997 C28.3607538,206.449997 32,206.5 32,206.5 22 | M23.6061137,207.020699 C23.6061137,207.020699 26.2397148,206 28.494994,206 C30.7502732,206 32.753258,207.020699 32.753258,207.020699 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/paths.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | M44,8c0-2.2-1.8-4-4-4H8C5.8,4,4,5.8,4,8v24c0,2.2,1.8,4,4,4h28l8,8L44,8z M36,28H12v-4h24V28z M36,22H12v-4h24V22z M36,16H12v-4h24V16z 20 | M38,26H26v12h-4V26H10v-4h12V10h4v12h12V26z 21 | M20,36h8v-4h-8V36z M6,12v4h36v-4H6z M12,26h24v-4H12V26z 22 | M13.3843083,13.3956843 C11.233862,15.5399983 7.7581039,15.5381046 5.61000013,13.3900003 C3.46000004,11.2399998 3.46000004,7.76000023 5.61000013,5.61000013 C7.76000023,3.46000004 11.2400007,3.46000004 13.3900003,5.61000013 C15.54,7.76000023 15.5400009,11.2400007 13.3900003,13.3900003 C13.388104,13.3918967 13.3862067,13.3937913 13.3843083,13.3956843 C15.1427975,15.1834093 19.6826174,19.798706 19.6826172,19.7987061 L13.3843085,13.3956846 L13.3843083,13.3956843 Z 23 | M12 7l-8 9h16l-8-9z 24 | M3 6h18v11H3z 25 | -------------------------------------------------------------------------------- /app/src/main/res/values/attrs_badged_image_view.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /app/src/main/res/values/attrs_elastic_drag_dismiss_frame_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /app/src/main/res/values/attrs_foreground_view.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/res/values/attrs_lift_off.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /app/src/main/res/values/attrs_parallax_scrimage_view.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /app/src/main/res/values/attrs_pinnable.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #ff676767 5 | #FF4081 6 | #5acc95 7 | 8 | 9 | #69F0AE 10 | @color/primary 11 | #5acc95 12 | #11261c 13 | 14 | #ffffffff 15 | 16 | 17 | #de000000 18 | #8a000000 19 | #61000000 20 | #ffffffff 21 | #b3ffffff 22 | #4dffffff 23 | #99ffffffprimary 24 | @color/mid_grey 25 | #fafafa 26 | #e0e0e0 27 | #ff333333 28 | #99000000 29 | @color/immersive_bars 30 | #ff676767 31 | #ff292929 32 | #99323232 33 | #40808080 34 | #fff5f5f5 35 | #ffeeeeee 36 | #ffe0e0e0 37 | 38 | #ffe0e0e0 39 | #99000000 40 | #4d000000 41 | #ff2a6046 42 | #ff757575 43 | #ffffffff 44 | #1f000000 45 | #80333333 46 | #ff333333 47 | #ffffffff 48 | #ffdd2c00 49 | 50 | 51 | #43000000 52 | #8f000000 53 | 54 | 55 | #03a9f4 --> 56 | #039be5 57 | #b303a9f4 58 | @android:color/transparent 59 | 60 | 61 | #000133 62 | #ffeceef1 63 | #73000000 64 | 65 | 66 | #fff06292 67 | #ec407a 68 | #ff33292d 69 | #b3f06292 70 | @color/text_primary_light 71 | #deffffff 72 | #ffffffff 73 | #40000000 74 | #b3ffffff 75 | 76 | #f6000000 77 | #732b2828 78 | 79 | #faf1f1f1 80 | #ef6269 81 | 82 | 83 | -------------------------------------------------------------------------------- /app/src/main/res/values/drawables.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | @drawable/ic_color_lens_white_24dp 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/integers.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 120 20 | 368 21 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | LookLook 3 | 4 | 5 | Be kind one another 6 | 7 | 8 | refresh_data 9 | get_image 10 | cache_size 11 | feedback 12 | author 13 | version 14 | pre_nav_color 15 | pre_use_local 16 | pre_status_bar 17 | 18 | 19 | 请检查网络 20 | 21 | shot_background 22 | shot 23 | 24 | nevigation_item 25 | 26 | 知乎日报 27 | 网易头条 28 | 每日看看 29 | 30 | 打开 31 | 关于 32 | 33 | 34 | topnewsimage 35 | topnewlinear 36 | 37 | 每日推送一个漂亮妹子和经典视频,看不看随小主!(长按保存图片) 38 | 我懂 39 | 40 | 小主好眼力,快收了她 41 | 42 | 感谢对项目的支持和关注,项目会不断的升级更新,如果小主感兴趣欢迎一起来贡献,有好的想法也可以随时发email给我. 43 | maat.xing@gmail.com 44 | 45 | 46 | 分享 47 | 48 | 49 | -------------------------------------------------------------------------------- /app/src/main/res/values/values.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/test/java/com/looklook/xinghongfei/looklook/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.looklook.xinghongfei.looklook; 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 | } -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:2.3.2' 9 | classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | jcenter() 18 | maven { url "https://jitpack.io" } 19 | maven { url 'https://jitpack.io' } 20 | } 21 | } 22 | 23 | task clean(type: Delete) { 24 | delete rootProject.buildDir 25 | } 26 | -------------------------------------------------------------------------------- /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 -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xinghongfei/LookLook/c436ef9949aa80ee085408900c54e800c839ce77/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon May 29 20:47:30 CST 2017 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-3.3-all.zip 7 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /screenshots/LookLook.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xinghongfei/LookLook/c436ef9949aa80ee085408900c54e800c839ce77/screenshots/LookLook.gif -------------------------------------------------------------------------------- /screenshots/about.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xinghongfei/LookLook/c436ef9949aa80ee085408900c54e800c839ce77/screenshots/about.png -------------------------------------------------------------------------------- /screenshots/meizi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xinghongfei/LookLook/c436ef9949aa80ee085408900c54e800c839ce77/screenshots/meizi.png -------------------------------------------------------------------------------- /screenshots/navigation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xinghongfei/LookLook/c436ef9949aa80ee085408900c54e800c839ce77/screenshots/navigation.png -------------------------------------------------------------------------------- /screenshots/pay.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xinghongfei/LookLook/c436ef9949aa80ee085408900c54e800c839ce77/screenshots/pay.png -------------------------------------------------------------------------------- /screenshots/pay1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xinghongfei/LookLook/c436ef9949aa80ee085408900c54e800c839ce77/screenshots/pay1.png -------------------------------------------------------------------------------- /screenshots/zhihu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xinghongfei/LookLook/c436ef9949aa80ee085408900c54e800c839ce77/screenshots/zhihu.png -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | --------------------------------------------------------------------------------