{
14 | /**
15 | * 构造方法
16 | *
17 | * @param context context
18 | */
19 | public PullToRefreshWebView(Context context) {
20 | this(context, null);
21 | }
22 |
23 | /**
24 | * 构造方法
25 | *
26 | * @param context context
27 | * @param attrs attrs
28 | */
29 | public PullToRefreshWebView(Context context, AttributeSet attrs) {
30 | this(context, attrs, 0);
31 | }
32 |
33 | /**
34 | * 构造方法
35 | *
36 | * @param context context
37 | * @param attrs attrs
38 | * @param defStyle defStyle
39 | */
40 | public PullToRefreshWebView(Context context, AttributeSet attrs, int defStyle) {
41 | super(context, attrs, defStyle);
42 | }
43 |
44 |
45 | @Override
46 | protected WebView createRefreshableView(Context context, AttributeSet attrs) {
47 | WebView webView = new WebView(context);
48 | return webView;
49 | }
50 |
51 |
52 | @Override
53 | protected boolean isReadyForPullDown() {
54 | return mRefreshableView.getScrollY() == 0;
55 | }
56 |
57 |
58 | @Override
59 | protected boolean isReadyForPullUp() {
60 | double exactContentHeight = Math.floor((double)(mRefreshableView.getContentHeight() * mRefreshableView.getScale()));
61 | return mRefreshableView.getScrollY() >= (exactContentHeight - mRefreshableView.getHeight());
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/widget_empty_feed.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
15 |
16 |
23 |
24 |
34 |
35 |
45 |
46 |
--------------------------------------------------------------------------------
/app/src/main/java/com/moon/myreadapp/common/components/scroll/ObservableScrollViewCallbacks.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 Soichiro Kashima
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.moon.myreadapp.common.components.scroll;
18 |
19 | /**
20 | * Callbacks for Scrollable widgets.
21 | */
22 | public interface ObservableScrollViewCallbacks {
23 | /**
24 | * Called when the scroll change events occurred.
25 | * This won't be called just after the view is laid out, so if you'd like to
26 | * initialize the position of your views with this method, you should call this manually
27 | * or invoke scroll as appropriate.
28 | *
29 | * @param scrollY Scroll position in Y axis.
30 | * @param firstScroll True when this is called for the first time in the consecutive motion events.
31 | * @param dragging True when the view is dragged and false when the view is scrolled in the inertia.
32 | */
33 | void onScrollChanged(int scrollY, boolean firstScroll, boolean dragging);
34 |
35 | /**
36 | * Called when the down motion event occurred.
37 | */
38 | void onDownMotionEvent();
39 |
40 | /**
41 | * Called when the dragging ended or canceled.
42 | *
43 | * @param scrollState State to indicate the scroll direction.
44 | */
45 | void onUpOrCancelMotionEvent(ScrollState scrollState);
46 | }
47 |
--------------------------------------------------------------------------------
/app/src/main/java/com/moon/myreadapp/common/components/scrollview/ObservableScrollViewCallbacks.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 Soichiro Kashima
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.moon.myreadapp.common.components.scrollview;
18 |
19 | /**
20 | * Callbacks for Scrollable widgets.
21 | */
22 | public interface ObservableScrollViewCallbacks {
23 | /**
24 | * Called when the scroll change events occurred.
25 | * This won't be called just after the view is laid out, so if you'd like to
26 | * initialize the position of your views with this method, you should call this manually
27 | * or invoke scroll as appropriate.
28 | *
29 | * @param scrollY scroll position in Y axis
30 | * @param firstScroll true when this is called for the first time in the consecutive motion events
31 | * @param dragging true when the view is dragged and false when the view is scrolled in the inertia
32 | */
33 | void onScrollChanged(int scrollY, boolean firstScroll, boolean dragging);
34 |
35 | /**
36 | * Called when the down motion event occurred.
37 | */
38 | void onDownMotionEvent();
39 |
40 | /**
41 | * Called when the dragging ended or canceled.
42 | *
43 | * @param scrollState state to indicate the scroll direction
44 | */
45 | void onUpOrCancelMotionEvent(ScrollState scrollState);
46 | }
47 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_share.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
17 |
25 |
26 |
34 |
35 |
44 |
45 |
--------------------------------------------------------------------------------
/app/src/main/java/com/moon/myreadapp/util/HtmlHelper.java:
--------------------------------------------------------------------------------
1 | package com.moon.myreadapp.util;
2 |
3 | import android.graphics.drawable.Drawable;
4 | import android.text.Html;
5 | import android.text.Spanned;
6 |
7 | import com.moon.myreadapp.R;
8 |
9 | import java.net.HttpURLConnection;
10 | import java.net.MalformedURLException;
11 | import java.net.URL;
12 | import java.util.ArrayList;
13 | import java.util.List;
14 | import java.util.regex.Matcher;
15 | import java.util.regex.Pattern;
16 |
17 | /**
18 | * Created by moon on 15/11/29.
19 | */
20 | public class HtmlHelper {
21 |
22 |
23 | /**
24 | * 得到网页中图片的地址
25 | */
26 | public static ArrayList getImgStr(String htmlStr,final int maxSize) {
27 | ArrayList result = new ArrayList<>();
28 | String imgRegex = "
]+src\\s*=\\s*['\"]([^'\"]+)['\"][^>]*>";
29 | Pattern pImage = Pattern.compile(imgRegex);
30 | Matcher mImage = pImage.matcher(htmlStr);
31 | try{
32 | while (mImage.find()) {
33 | String imagePath = mImage.group(1);
34 | if (result.size() >= maxSize){
35 | return result;
36 | }
37 | result.add(imagePath);
38 | }
39 | }catch (Exception e){
40 | return result;
41 | }
42 | return result;
43 | }
44 |
45 |
46 | /**
47 | * 拿到网站icon
48 | * @param urlString
49 | * @return
50 | */
51 | public static String getIconUrlString( String urlString ) {
52 | if (urlString == null || urlString.isEmpty()){
53 | return null;
54 | }
55 | try{
56 | URL url = new URL( urlString );
57 | String iconUrl = "http://statics.dnspod.cn/proxy_favicon/_/favicon?domain=" + url.getHost();// 使用dnspod进行favicon的获取
58 | return iconUrl;
59 | }catch (MalformedURLException e){
60 | return null;
61 | }
62 | }
63 |
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/app/src/main/java/com/moon/myreadapp/common/components/photoview/scrollerproxy/ScrollerProxy.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright 2011, 2012 Chris Banes.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *******************************************************************************/
16 | package com.moon.myreadapp.common.components.photoview.scrollerproxy;
17 |
18 | import android.content.Context;
19 | import android.os.Build.VERSION;
20 | import android.os.Build.VERSION_CODES;
21 |
22 | public abstract class ScrollerProxy {
23 |
24 | public static ScrollerProxy getScroller(Context context) {
25 | if (VERSION.SDK_INT < VERSION_CODES.GINGERBREAD) {
26 | return new PreGingerScroller(context);
27 | } else if (VERSION.SDK_INT < VERSION_CODES.ICE_CREAM_SANDWICH) {
28 | return new GingerScroller(context);
29 | } else {
30 | return new IcsScroller(context);
31 | }
32 | }
33 |
34 | public abstract boolean computeScrollOffset();
35 |
36 | public abstract void fling(int startX, int startY, int velocityX, int velocityY, int minX, int maxX, int minY,
37 | int maxY, int overX, int overY);
38 |
39 | public abstract void forceFinished(boolean finished);
40 |
41 | public abstract boolean isFinished();
42 |
43 | public abstract int getCurrX();
44 |
45 | public abstract int getCurrY();
46 |
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/app/src/main/java/com/moon/myreadapp/common/components/scrollview/Scrollable.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 Soichiro Kashima
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.moon.myreadapp.common.components.scrollview;
18 |
19 | import android.view.ViewGroup;
20 |
21 | /**
22 | * Provides common API for observable and scrollable widgets.
23 | */
24 | public interface Scrollable {
25 | /**
26 | * Sets a callback listener.
27 | *
28 | * @param listener listener to set
29 | */
30 | void setScrollViewCallbacks(ObservableScrollViewCallbacks listener);
31 |
32 | /**
33 | * Scrolls vertically to the absolute Y.
34 | * Implemented classes are expected to scroll to the exact Y pixels from the top,
35 | * but it depends on the type of the widget_empty_home.
36 | *
37 | * @param y vertical position to scroll to
38 | */
39 | void scrollVerticallyTo(int y);
40 |
41 | /**
42 | * Returns the current Y of the scrollable view.
43 | *
44 | * @return current Y pixel
45 | */
46 | int getCurrentScrollY();
47 |
48 | /**
49 | * Sets a touch motion event delegation ViewGroup.
50 | * This is used to pass motion events back to parent view.
51 | * It's up to the implementation classes whether or not it works.
52 | *
53 | * @param viewGroup ViewGroup object to dispatch motion events
54 | */
55 | void setTouchInterceptionViewGroup(ViewGroup viewGroup);
56 | }
57 |
--------------------------------------------------------------------------------
/app/src/main/java/com/moon/myreadapp/common/components/dialog/BaseButtomDialog.java:
--------------------------------------------------------------------------------
1 | package com.moon.myreadapp.common.components.dialog;
2 |
3 | import android.app.Activity;
4 | import android.view.Gravity;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.view.Window;
8 | import android.view.WindowManager;
9 | import android.widget.PopupWindow;
10 |
11 | import com.moon.myreadapp.R;
12 |
13 | /**
14 | * Created by moon on 15/12/24.
15 | */
16 | public abstract class BaseButtomDialog extends PopupWindow{
17 |
18 | protected Activity context;
19 | protected Window mWindow;
20 |
21 |
22 | public BaseButtomDialog(Activity context) {
23 | this.context = context;
24 | this.mWindow = context.getWindow();
25 |
26 |
27 | //设置SelectPicPopupWindow弹出窗体的宽
28 | this.setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
29 | //设置SelectPicPopupWindow弹出窗体的高
30 | this.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
31 | //设置SelectPicPopupWindow弹出窗体可点击
32 | this.setFocusable(true);
33 | //设置SelectPicPopupWindow弹出窗体动画效果
34 | this.setAnimationStyle(R.style.ButtomPopupAnimStyle);
35 |
36 | setContentView();
37 | init();
38 | setOnDismissListener(new OnDismissListener() {
39 | @Override
40 | public void onDismiss() {
41 | onDimiss();
42 | WindowManager.LayoutParams lp = mWindow.getAttributes();
43 | lp.alpha = 1f;
44 | mWindow.setAttributes(lp);
45 | }
46 | });
47 |
48 | }
49 |
50 | public BaseButtomDialog() {
51 | }
52 |
53 | public void showWithView(View v) {
54 | WindowManager.LayoutParams lp = mWindow.getAttributes();
55 | lp.alpha = 0.4f;
56 | mWindow.setAttributes(lp);
57 | showAtLocation(v, Gravity.BOTTOM, 0, 0);
58 | }
59 |
60 |
61 |
62 | abstract void setContentView();
63 | abstract void init();
64 | abstract void onDimiss();
65 |
66 | }
67 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dialog_sub.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
13 |
14 |
17 |
18 |
30 |
31 |
41 |
42 |
43 |
50 |
51 |
--------------------------------------------------------------------------------
/app/src/main/res/values/color-theme.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FF5722
4 | #F4511E
5 | #FF6347
6 |
7 | #795548
8 | #5D4037
9 | #795548
10 |
11 |
12 | #2196F3
13 | #1976D2
14 | #448AFF
15 |
16 | #607D8B
17 | #455A64
18 | #607D8B
19 |
20 | #FF9800
21 | #F57C00
22 | #FF9800
23 |
24 | #673AB7
25 | #512DA8
26 | #7C4DFF
27 |
28 | #E91E63
29 | #C2185B
30 | #FF4081
31 |
32 | #4CAF50
33 | #388E3C
34 | #4CAF50
35 |
36 | #212121
37 | #727272
38 |
39 | #ffbebebe
40 | #9E9E9E
41 | #FF080808
42 | #ffbebebe
43 | #FFEEEEEE
44 |
45 | #88EEEEEE
46 | @android:color/white
47 | @android:color/white
48 |
49 |
50 |
51 |
52 |
53 |
54 | #E91E63
55 | #E91E63
56 | #ffbebebe
57 |
--------------------------------------------------------------------------------
/app/src/main/java/com/moon/myreadapp/common/components/photoview/scrollerproxy/PreGingerScroller.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright 2011, 2012 Chris Banes.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *******************************************************************************/
16 | package com.moon.myreadapp.common.components.photoview.scrollerproxy;
17 |
18 | import android.content.Context;
19 | import android.widget.Scroller;
20 |
21 | public class PreGingerScroller extends ScrollerProxy {
22 |
23 | private final Scroller mScroller;
24 |
25 | public PreGingerScroller(Context context) {
26 | mScroller = new Scroller(context);
27 | }
28 |
29 | @Override
30 | public boolean computeScrollOffset() {
31 | return mScroller.computeScrollOffset();
32 | }
33 |
34 | @Override
35 | public void fling(int startX, int startY, int velocityX, int velocityY, int minX, int maxX, int minY, int maxY,
36 | int overX, int overY) {
37 | mScroller.fling(startX, startY, velocityX, velocityY, minX, maxX, minY, maxY);
38 | }
39 |
40 | @Override
41 | public void forceFinished(boolean finished) {
42 | mScroller.forceFinished(finished);
43 | }
44 |
45 | public boolean isFinished() {
46 | return mScroller.isFinished();
47 | }
48 |
49 | @Override
50 | public int getCurrX() {
51 | return mScroller.getCurrX();
52 | }
53 |
54 | @Override
55 | public int getCurrY() {
56 | return mScroller.getCurrY();
57 | }
58 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/moon/myreadapp/common/components/rss/FeedParser.java:
--------------------------------------------------------------------------------
1 | package com.moon.myreadapp.common.components.rss;
2 |
3 | import com.moon.myreadapp.mvvm.models.dao.Feed;
4 |
5 | import org.xml.sax.InputSource;
6 | import org.xml.sax.SAXException;
7 | import org.xml.sax.XMLReader;
8 |
9 | import java.io.IOException;
10 | import java.io.InputStream;
11 |
12 | import javax.xml.parsers.ParserConfigurationException;
13 | import javax.xml.parsers.SAXParser;
14 | import javax.xml.parsers.SAXParserFactory;
15 |
16 |
17 | /**
18 | * @description:
19 | * @author: Match
20 | * @date: 8/29/15
21 | */
22 | public class FeedParser {
23 |
24 | public Feed parse(InputStream is) throws FeedReadException, SAXException,
25 | ParserConfigurationException, IOException {
26 | // Since SAXParserFactory implementations are not guaranteed to be
27 | // thread-safe, a new local object is instantiated.
28 | SAXParserFactory factory = SAXParserFactory.newInstance();
29 |
30 | // Support Android 1.6 (see Issue 1)
31 | factory.setFeature("http://xml.org/sax/features/namespaces", false);
32 | factory.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
33 | SAXParser parser = factory.newSAXParser();
34 |
35 | return parse(parser, is);
36 | }
37 |
38 | private Feed parse(SAXParser parser, InputStream is) throws FeedReadException, SAXException, IOException {
39 | if (parser == null) {
40 | throw new FeedReadException(0, "RSS parser must not be null.");
41 | } else if (is == null) {
42 | throw new FeedReadException(0, "RSS feed must not be null.");
43 | }
44 |
45 | // SAX automatically detects the correct character encoding from the stream
46 | // See also http://www.w3.org/TR/REC-xml/#sec-guessing
47 | InputSource source = new InputSource(is);
48 | XMLReader xmlreader = parser.getXMLReader();
49 | FeedHandler handler = new FeedHandler();
50 |
51 | xmlreader.setContentHandler(handler);
52 | xmlreader.parse(source);
53 |
54 | return handler.getFeedSource();
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/app/src/main/java/com/moon/myreadapp/common/components/pulltorefresh/ILoadingLayout.java:
--------------------------------------------------------------------------------
1 | package com.moon.myreadapp.common.components.pulltorefresh;
2 |
3 | /**
4 | * 下拉刷新和上拉加载更多的界面接口
5 | *
6 | * @author Li Hong
7 | * @since 2013-7-29
8 | */
9 | public interface ILoadingLayout {
10 | /**
11 | * 当前的状态
12 | */
13 | enum State {
14 |
15 | /**
16 | * Initial state
17 | */
18 | NONE,
19 |
20 | /**
21 | * When the UI is in base_slide_remain state which means that user is not interacting
22 | * with the Pull-to-Refresh function.
23 | */
24 | RESET,
25 |
26 | /**
27 | * When the UI is being pulled by the user, but has not been pulled far
28 | * enough so that it refreshes when released.
29 | */
30 | PULL_TO_REFRESH,
31 |
32 | /**
33 | * When the UI is being pulled by the user, and has
34 | * been pulled far enough so that it will refresh when released.
35 | */
36 | RELEASE_TO_REFRESH,
37 |
38 | /**
39 | * When the UI is currently refreshing, caused by base_slide_remain pull gesture.
40 | */
41 | REFRESHING,
42 |
43 | /**
44 | * When the UI is currently refreshing, caused by base_slide_remain pull gesture.
45 | */
46 | @Deprecated
47 | LOADING,
48 |
49 | /**
50 | * No more data
51 | */
52 | NO_MORE_DATA,
53 | }
54 |
55 | /**
56 | * 设置当前状态,派生类应该根据这个状态的变化来改变View的变化
57 | *
58 | * @param state 状态
59 | */
60 | void setState(State state);
61 |
62 | /**
63 | * 得到当前的状态
64 | *
65 | * @return 状态
66 | */
67 | State getState();
68 |
69 | /**
70 | * 得到当前Layout的内容大小,它将作为一个刷新的临界点
71 | *
72 | * @return 高度
73 | */
74 | int getContentSize();
75 |
76 | /**
77 | * 在拉动时调用
78 | *
79 | * @param scale 拉动的比例
80 | */
81 | void onPull(float scale);
82 | }
83 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 | 46dp
7 | 12dp
8 |
9 | 18dp
10 | 16dp
11 | 14dp
12 | 12dp
13 | 10dp
14 |
15 | 18sp
16 | 16sp
17 | 14sp
18 | 13sp
19 | 12sp
20 | 11sp
21 | 10sp
22 |
23 | 16dp
24 |
25 | 16dp
26 | 32dp
27 | 8dp
28 |
29 | 48dp
30 | 72dp
31 | 96dp
32 |
33 | 16dp
34 | 48dp
35 | 32dp
36 | 64dp
37 | 96dp
38 | 128dp
39 |
40 |
41 | 300dp
42 | 60dp
43 | 56dp
44 | 100dp
45 | 48dp
46 |
47 | @dimen/normal_list_item_regular
48 | 80dp
49 | 180dp
50 | 16dp
51 |
52 |
53 | 32dp
54 |
55 |
56 |
--------------------------------------------------------------------------------
/app/src/main/java/com/moon/myreadapp/common/event/UpdateFeedEvent.java:
--------------------------------------------------------------------------------
1 | package com.moon.myreadapp.common.event;
2 |
3 | import com.moon.appframework.event.XEvent;
4 | import com.moon.myreadapp.mvvm.models.dao.Article;
5 | import com.moon.myreadapp.mvvm.models.dao.Feed;
6 |
7 | /**
8 | * Created by moon on 15/11/13.
9 | */
10 | public class UpdateFeedEvent implements XEvent {
11 |
12 | public enum TYPE {
13 | STATUS,
14 | SET
15 | }
16 |
17 | private Feed feed;
18 | private int status = NORMAL;
19 | private boolean showAllArticles;
20 | private String notice;
21 | private int updatePosition = -1;
22 | private Article article;
23 |
24 | /** 更新状态*/
25 | public static int ON_UPDATE = 1<<10;
26 | /** 正常状态*/
27 | public static int NORMAL = 1<<11;
28 | /** 失败状态*/
29 | public static int FAIL = 1<<12;
30 |
31 | private TYPE type;
32 |
33 | public UpdateFeedEvent(Feed feed,TYPE type) {
34 | this.feed = feed;
35 | this.type = type;
36 | }
37 |
38 | public void setStatus(int status) {
39 | this.status = status;
40 | }
41 |
42 | public boolean isShowAllArticles() {
43 | return showAllArticles;
44 | }
45 |
46 | public void setShowAllArticles(boolean showAllArticles) {
47 | this.showAllArticles = showAllArticles;
48 | }
49 |
50 | public TYPE getType() {
51 | return type;
52 | }
53 |
54 | public void setType(TYPE type) {
55 | this.type = type;
56 | }
57 |
58 | public Feed getFeed() {
59 | return feed;
60 | }
61 |
62 | public int getStatus() {
63 | return status;
64 | }
65 |
66 | public String getNotice() {
67 | return notice;
68 | }
69 |
70 | public void setNotice(String notice) {
71 | this.notice = notice;
72 | }
73 |
74 | public int getUpdatePosition() {
75 | return updatePosition;
76 | }
77 |
78 | public void setUpdatePosition(int updatePosition) {
79 | this.updatePosition = updatePosition;
80 | }
81 |
82 | public Article getArticle() {
83 | return article;
84 | }
85 |
86 | public void setArticle(Article article) {
87 | this.article = article;
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/app/src/main/java/com/moon/myreadapp/mvvm/models/dao/DaoSession.java:
--------------------------------------------------------------------------------
1 | package com.moon.myreadapp.mvvm.models.dao;
2 |
3 | import android.database.sqlite.SQLiteDatabase;
4 |
5 | import java.util.Map;
6 |
7 | import de.greenrobot.dao.AbstractDao;
8 | import de.greenrobot.dao.AbstractDaoSession;
9 | import de.greenrobot.dao.identityscope.IdentityScopeType;
10 | import de.greenrobot.dao.internal.DaoConfig;
11 |
12 |
13 |
14 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
15 |
16 | /**
17 | * {@inheritDoc}
18 | *
19 | * @see AbstractDaoSession
20 | */
21 | public class DaoSession extends AbstractDaoSession {
22 |
23 | private final DaoConfig userDaoConfig;
24 | private final DaoConfig feedDaoConfig;
25 | private final DaoConfig articleDaoConfig;
26 |
27 | private final UserDao userDao;
28 | private final FeedDao feedDao;
29 | private final ArticleDao articleDao;
30 |
31 | public DaoSession(SQLiteDatabase db, IdentityScopeType type, Map>, DaoConfig>
32 | daoConfigMap) {
33 | super(db);
34 |
35 | userDaoConfig = daoConfigMap.get(UserDao.class).clone();
36 | userDaoConfig.initIdentityScope(type);
37 |
38 | feedDaoConfig = daoConfigMap.get(FeedDao.class).clone();
39 | feedDaoConfig.initIdentityScope(type);
40 |
41 | articleDaoConfig = daoConfigMap.get(ArticleDao.class).clone();
42 | articleDaoConfig.initIdentityScope(type);
43 |
44 | userDao = new UserDao(userDaoConfig, this);
45 | feedDao = new FeedDao(feedDaoConfig, this);
46 | articleDao = new ArticleDao(articleDaoConfig, this);
47 |
48 | registerDao(User.class, userDao);
49 | registerDao(Feed.class, feedDao);
50 | registerDao(Article.class, articleDao);
51 | }
52 |
53 | public void clear() {
54 | userDaoConfig.getIdentityScope().clear();
55 | feedDaoConfig.getIdentityScope().clear();
56 | articleDaoConfig.getIdentityScope().clear();
57 | }
58 |
59 | public UserDao getUserDao() {
60 | return userDao;
61 | }
62 |
63 | public FeedDao getFeedDao() {
64 | return feedDao;
65 | }
66 |
67 | public ArticleDao getArticleDao() {
68 | return articleDao;
69 | }
70 |
71 | }
72 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_add_sub_sec.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
10 |
11 |
12 |
20 |
21 |
25 |
26 |
38 |
39 |
40 |
51 |
52 |
--------------------------------------------------------------------------------
/app/src/main/java/com/moon/myreadapp/util/ViewUtils.java:
--------------------------------------------------------------------------------
1 | package com.moon.myreadapp.util;
2 |
3 | import android.content.Context;
4 | import android.view.Menu;
5 | import android.view.View;
6 | import android.view.inputmethod.InputMethodManager;
7 | import android.widget.EditText;
8 | import android.widget.PopupMenu;
9 |
10 | import java.lang.reflect.Method;
11 |
12 | /**
13 | * Created by moon on 15/10/22.
14 | */
15 | public class ViewUtils {
16 |
17 |
18 | /**
19 | * 获取焦点并弹出软键盘
20 | *
21 | * @param view
22 | */
23 | public static void editViewFocus(EditText view, boolean openKeyBord) {
24 | view.requestFocus();
25 | if (openKeyBord) {
26 | InputMethodManager imm = (InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
27 | imm.toggleSoftInput(0, InputMethodManager.SHOW_FORCED);
28 | }
29 | }
30 |
31 |
32 | public static Menu showPopupMenu(final Context context, View view, int layout, PopupMenu.OnMenuItemClickListener listener) {
33 | // View当前PopupMenu显示的相对View的位置
34 | PopupMenu popupMenu = new PopupMenu(context, view);
35 |
36 | // menu布局
37 |
38 | //4.0以上icon无法显示,需要反射调用该方法
39 | setIconEnable(popupMenu.getMenu(), true);
40 | popupMenu.getMenuInflater().inflate(layout, popupMenu.getMenu());
41 | // menu的item点击事件
42 | popupMenu.setOnMenuItemClickListener(listener);
43 | // PopupMenu关闭事件
44 | popupMenu.setOnDismissListener(new PopupMenu.OnDismissListener() {
45 | @Override
46 | public void onDismiss(PopupMenu menu) {
47 | //Toast.makeText(context, "关闭PopupMenu", Toast.LENGTH_SHORT).show();
48 | }
49 | });
50 |
51 | popupMenu.show();
52 | return popupMenu.getMenu();
53 | }
54 |
55 |
56 | private static void setIconEnable(Menu menu, boolean enable) {
57 |
58 | try {
59 | //未知的类
60 | Class> clazz = Class.forName("com.android.internal.view.menu.MenuBuilder");
61 | Method m = clazz.getDeclaredMethod("setOptionalIconsVisible", boolean.class);
62 | m.setAccessible(true);
63 | m.invoke(menu, enable);
64 | } catch (Exception e) {
65 | e.printStackTrace();
66 | }
67 |
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/app/src/main/java/com/moon/myreadapp/common/components/cutebuttombar/AutoButtomBar.java:
--------------------------------------------------------------------------------
1 | package com.moon.myreadapp.common.components.cutebuttombar;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.widget.LinearLayout;
8 |
9 | import com.joanzapata.iconify.widget.IconTextView;
10 | import com.moon.appframework.common.log.XLog;
11 | import com.moon.myreadapp.R;
12 | import com.nineoldandroids.animation.ObjectAnimator;
13 |
14 | /**
15 | * Created by moon on 15/12/8.
16 | */
17 | public class AutoButtomBar extends LinearLayout {
18 |
19 | private static String TAG = AutoButtomBar.class.getSimpleName();
20 |
21 | public AutoButtomBar(Context context) {
22 | super(context);
23 | init(context);
24 | }
25 |
26 | public AutoButtomBar(Context context, AttributeSet attrs) {
27 | super(context, attrs);
28 | init(context);
29 | }
30 |
31 | public AutoButtomBar(Context context, AttributeSet attrs, int defStyleAttr) {
32 | super(context, attrs, defStyleAttr);
33 | init(context);
34 | }
35 |
36 | LayoutInflater mInflater;
37 |
38 | private void init(Context context){
39 | mInflater = LayoutInflater.from(context);
40 | addView(createButton("返回", new OnClickListener() {
41 | @Override
42 | public void onClick(View v) {
43 | XLog.d(TAG + "click execute!");
44 | ObjectAnimator.ofFloat(AutoButtomBar.this, "translationX", 300).setDuration(1000).start();
45 | }
46 | }));
47 | addView(createButton("返回", new OnClickListener() {
48 | @Override
49 | public void onClick(View v) {
50 | XLog.d(TAG + "click execute!");
51 | ObjectAnimator.ofFloat(AutoButtomBar.this, "translationX", 300).setDuration(1000).start();
52 | }
53 | }));
54 | }
55 |
56 | private IconTextView createButton(String text,OnClickListener listener){
57 | IconTextView iconTextView = (IconTextView)mInflater.inflate(R.layout.article_bottom_bar,this);
58 | iconTextView.setText(text);
59 | iconTextView.setOnClickListener(listener);
60 | return (IconTextView)mInflater.inflate(R.layout.article_bottom_bar,null);
61 | }
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/app/src/main/java/com/moon/myreadapp/constants/Constants.java:
--------------------------------------------------------------------------------
1 | package com.moon.myreadapp.constants;
2 |
3 | import com.moon.myreadapp.R;
4 | import com.moon.myreadapp.util.Globals;
5 |
6 | /**
7 | * Created by moon on 15/10/22.
8 | */
9 | public class Constants {
10 |
11 |
12 | public static boolean DEBUG = true;
13 |
14 | public static String APP_URL = "http://rssread.bmob.cn";
15 |
16 | /**
17 | * Bmob APP id
18 | */
19 | public static final String APP_ID = "1c56866927e32c7063d2179cc121a741";
20 |
21 | /**
22 | * 微信开发者id
23 | */
24 | public static String APP_WX_ID = "wxf756a2b5b525d281";
25 |
26 | public static final String DB_NAME = "eaasy-rss-db";
27 |
28 | public static final String FEED = "feed_object";
29 |
30 | public static final String FEED_ID = "feed_object_id";
31 |
32 | public static final String ARTICLE = "article_object";
33 |
34 | public static final String ARTICLE_ID = "article_object_id";
35 |
36 | public static final String ARTICLE_POS = "article_object_pos";
37 |
38 | public static final String ARTICLE_TITLE = "article_object_title";
39 |
40 | public static final String ARTICLE_URL = "article_object_url";
41 |
42 | public static final String IMAGES_LIST = "images_list";
43 |
44 | public static final String IMAGES_NOW_POSITION = "images_now_position";
45 |
46 | public static final String VIEW_ARTICLE_TYPE = "view_article_type";
47 |
48 |
49 | /**
50 | * 配置类
51 | */
52 |
53 | /**
54 | * app是否第一次进入
55 | */
56 | public static final String APP_IS_FIRST_USE = "app_is_first_use";
57 |
58 | /**
59 | * 文章字体大小
60 | */
61 | public static final String ARTICLE_FONT_SIZE = "article_font_size";
62 |
63 | /**
64 | * 频道内文章显示
65 | */
66 | public static final String FEED_SHOW_ALL = Globals.getApplication().getString(R.string.set_auto_show_unread_key);
67 | public static boolean showUnReadArticles = false;
68 |
69 | /**
70 | * 最小的文章内容大小,当开启智能打开原文时,小于这个值会直接打开原文链接
71 | */
72 | public static int MIN_CONTAINER_SIZE = 100;
73 |
74 |
75 | /**
76 | * 单次加载文章的数量
77 | */
78 | public static int SINGLE_LOAD_SIZE = 10;
79 |
80 |
81 |
82 | public static String RSS_REQUEST_URL = "http://cloud.feedly.com//v3/search/feeds?query=";
83 |
84 |
85 | }
86 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_about_me.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
14 |
22 |
26 |
34 |
38 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/app/src/main/java/com/moon/myreadapp/common/adapter/DrawerAdapter.java:
--------------------------------------------------------------------------------
1 | package com.moon.myreadapp.common.adapter;
2 |
3 | import android.databinding.DataBindingUtil;
4 | import android.text.Html;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 |
8 | import com.moon.myreadapp.R;
9 | import com.moon.myreadapp.common.adapter.base.BaseListAdapter;
10 | import com.moon.myreadapp.databinding.LeftDrawerListItemBinding;
11 | import com.moon.myreadapp.mvvm.models.MenuItem;
12 | import com.moon.myreadapp.mvvm.viewmodels.ViewArticleViewModel;
13 | import com.moon.myreadapp.util.BuiltConfig;
14 | import com.moon.myreadapp.util.DBHelper;
15 |
16 | import java.util.List;
17 |
18 | /**
19 | * Created by moon on 15/10/19.
20 | */
21 | public class DrawerAdapter extends BaseListAdapter