Skip to content
This repository has been archived by the owner on Dec 1, 2019. It is now read-only.

Commit

Permalink
add magnetic
Browse files Browse the repository at this point in the history
  • Loading branch information
7449 committed Jun 6, 2017
1 parent d505d2e commit 0a81d23
Show file tree
Hide file tree
Showing 87 changed files with 1,598 additions and 648 deletions.
31 changes: 29 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,21 @@ jsoupSample

使用`Jsoup`抓取一些网站的数据,抓取数据的网站已经列在下面,如果有侵权嫌疑,请及时联系我删除相关数据



# android SDK 内存泄露

如图所示,这个Bug是Android输入法的Bug,输入法内存泄漏了.....

![](https://github.com/7449/JsoupSample/blob/master/screenshot/androidBug.png)


详情见:

[InputMethodManager内存泄露现象及解决](http://blog.csdn.net/sodino/article/details/32188809)<br>
[Android InputMethodManager 导致的内存泄露及解决方案](https://zhuanlan.zhihu.com/p/20828861?refer=zmywly8866)


* fiction

>浏览小说
Expand Down Expand Up @@ -31,12 +46,24 @@ jsoupSample

[豆瓣美女](http://www.dbmeinv.com/)<br>
[妹子图](http://www.mzitu.com/)<br>
[MM](http://www.mmjpg.com/)</br>
[MEIZITU](http://www.meizitu.com/)</br>
[MM](http://www.mmjpg.com/)<br>
[MEIZITU](http://www.meizitu.com/)<br>
[7kk](http://m.7kk.com/)<br>

![](https://github.com/7449/JsoupSample/blob/master/screenshot/image.gif)
![](https://github.com/7449/JsoupSample/blob/master/screenshot/image_search.gif)

* magnetic (暂开发...)

>磁力链接抓取
[BT蚂蚁](http://www.btans.com)<br>
[BT樱桃](http://www.btcherry.info)<br>
[尼玛搜](https://www.nimasou.info)<br>
[BT蜘蛛](http://www.zhizhucili.cc)<br>




整个框架围绕着`framework`这个`modules`展开。

Expand Down
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,8 @@ ext {
movieStorePath = 'movie.jks'
moviePassword = '123456'
movieKeyAlias = 'movie'

magneticStorePath = 'magnetic.jks'
magneticPassword = '123456'
magneticKeyAlias = 'magnetic'
}
1 change: 1 addition & 0 deletions commonLibrary/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

package="com.framework">

<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:label="@string/app_name"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.framework.R;
import com.framework.base.mvp.BasePresenterImpl;
import com.framework.widget.StatusLayout;
import com.socks.library.KLog;

/**
* by y on 2016/7/26.
Expand All @@ -24,6 +25,7 @@ public abstract class BaseActivity<P extends BasePresenterImpl> extends AppCompa
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
KLog.i(getClass().getSimpleName());
mStatusView = new StatusLayout(this);
mStatusView.setSuccessView(getLayoutId(), new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
mStatusView.setEmptyView(R.layout.layout_empty_view);
Expand Down Expand Up @@ -70,6 +72,9 @@ public boolean onOptionsItemSelected(MenuItem item) {
@Override
protected void onDestroy() {
super.onDestroy();
if (mStatusView != null) {
mStatusView.onDestroyView();
}
if (mPresenter != null) {
mPresenter.onDestroy();
mPresenter = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,15 @@ protected void setLoad() {
@Override
public void onDestroyView() {
super.onDestroyView();
if (mStatusView != null) {
mStatusView.onDestroyView();
}
if (mPresenter != null) {
mPresenter.onDestroy();
mPresenter = null;
}
}


}

Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public void onNetWorkSuccess(M data) {
}

protected void netWork(String url) {
KLog.i(url);
RxJsoupNetWork.getInstance().cancel(tag);
RxJsoupNetWork
.getInstance()
Expand Down
4 changes: 4 additions & 0 deletions commonLibrary/src/main/java/com/framework/utils/UIUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,8 @@ public static void toast(Object o) {
public static void snackBar(View view, Object object) {
Snackbar.make(view, object + "", Snackbar.LENGTH_SHORT).show();
}

public static void snackBar(View view, int object) {
Snackbar.make(view, object, Snackbar.LENGTH_SHORT).show();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ private int findMax(int[] lastPositions) {
return max;
}

public enum LAYOUT_MANAGER_TYPE {
private enum LAYOUT_MANAGER_TYPE {
LINEAR,
GRID,
STAGGERED_GRID
Expand Down
32 changes: 32 additions & 0 deletions commonLibrary/src/main/java/com/framework/widget/StatusLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;

import com.framework.R;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.List;

/**
* by y on 2017/5/19
Expand Down Expand Up @@ -82,6 +85,35 @@ public StatusLayout(Context context, AttributeSet attrs, int defStyleAttr) {
}


public void onDestroyView() {
// for (int i = 0; i < getChildCount(); i++) {
// View view = getChildAt(i);
// KLog.i(view.getClass().getSimpleName());
// }
List<View> allChildViews = getAllChildViews(this);
int size = allChildViews.size();
for (int i = 0; i < size; i++) {
View view = allChildViews.get(i);
if (view != null) {
view = null;
}
}
}


private List<View> getAllChildViews(View view) {
List<View> listView = new ArrayList<>();
if (view instanceof ViewGroup) {
ViewGroup vp = (ViewGroup) view;
for (int i = 0; i < vp.getChildCount(); i++) {
View viewchild = vp.getChildAt(i);
listView.add(viewchild);
listView.addAll(getAllChildViews(viewchild));
}
}
return listView;
}

public int getStatus() {
return mStatus;
}
Expand Down
1 change: 0 additions & 1 deletion fiction/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
xmlns:tools="http://schemas.android.com/tools"
package="com.fiction">

<uses-permission android:name="android.permission.INTERNET" />
<application
android:name="com.framework.App"
android:allowBackup="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.fiction.mvp.view.ViewManager;
import com.framework.base.BaseActivity;
import com.framework.utils.UIUtils;
import com.framework.widget.StatusLayout;
import com.xadapter.OnXBindListener;
import com.xadapter.adapter.XRecyclerViewAdapter;
import com.xadapter.holder.XViewHolder;
Expand All @@ -40,6 +41,7 @@ public class FictionContentsActivity extends BaseActivity<FictionContentsPresent
private SwipeRefreshLayout swipeRefreshLayout;
private XRecyclerViewAdapter<FictionModel> mAdapter;
private Toolbar toolbar;
private Bundle extras;

public static void getInstance(String type, String url, String title) {
Bundle bundle = new Bundle();
Expand All @@ -53,7 +55,7 @@ public static void getInstance(String type, String url, String title) {
@Override
protected void initCreate(Bundle savedInstanceState) {
swipeRefreshLayout.setEnabled(false);
Bundle extras = getIntent().getExtras();
extras = getIntent().getExtras();
type = extras.getString(TYPE);
toolbar.setTitle(extras.getString(TITLE));
setSupportActionBar(toolbar);
Expand All @@ -68,6 +70,14 @@ protected void initCreate(Bundle savedInstanceState) {
mPresenter.startContents(extras.getString(URL), type);
}

@Override
protected void clickNetWork() {
super.clickNetWork();
if (!swipeRefreshLayout.isRefreshing()) {
mPresenter.startContents(extras.getString(URL), type);
}
}

@Override
protected void initById() {
toolbar = getView(R.id.toolbar);
Expand All @@ -89,15 +99,19 @@ protected int getLayoutId() {
@Override
public void netWorkSuccess(List<FictionModel> data) {
if (mStatusView != null) {
mStatusView.setStatus(StatusLayout.SUCCESS);
Collections.reverse(data);
mAdapter.addAllData(data);
}
}

@Override
public void netWorkError() {
if (mStatusView != null)
if (mStatusView != null) {
mAdapter.removeAll();
mStatusView.setStatus(StatusLayout.ERROR);
UIUtils.snackBar(mStatusView, getString(R.string.network_error));
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class MainActivity extends BaseActivity<MainPresenterImpl>
@Override
protected void initCreate(Bundle savedInstanceState) {
navigationView.setNavigationItemSelectedListener(this);
toolbar.setTitle(getString(R.string.title_81));
toolbar.setTitle(R.string.title_81);
setSupportActionBar(toolbar);
mPresenter.switchId(MainPresenterImpl.FIRST_FRAGMENT);
}
Expand Down
29 changes: 25 additions & 4 deletions fiction/src/main/java/com/fiction/ui/activity/SearchActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.framework.utils.ImageLoaderUtils;
import com.framework.utils.UIUtils;
import com.framework.widget.LoadMoreRecyclerView;
import com.framework.widget.StatusLayout;
import com.xadapter.adapter.XRecyclerViewAdapter;

import java.util.List;
Expand Down Expand Up @@ -61,6 +62,15 @@ protected void initCreate(Bundle savedInstanceState) {
mPresenter.startSearch(fictionName, page = 0);
}

@Override
protected void clickNetWork() {
super.clickNetWork();
if (!swipeRefreshLayout.isRefreshing()) {
mStatusView.setStatus(StatusLayout.SUCCESS);
mPresenter.startSearch(fictionName, page = 0);
}
}

@Override
public void onLoadMore() {
if (swipeRefreshLayout.isRefreshing()) {
Expand All @@ -82,8 +92,14 @@ public void netWorkSuccess(List<FictionModel> data) {

@Override
public void netWorkError() {
if (mStatusView != null)
UIUtils.snackBar(mStatusView, getString(R.string.network_error));
if (mStatusView != null) {
if (page == 0) {
mAdapter.removeAll();
mStatusView.setStatus(StatusLayout.ERROR);
} else {
UIUtils.snackBar(mStatusView, R.string.net_error);
}
}
}

@Override
Expand All @@ -101,8 +117,13 @@ public void hideProgress() {

@Override
public void noMore() {
if (mStatusView != null)
UIUtils.snackBar(mStatusView, getString(R.string.data_empty));
if (mStatusView != null) {
if (page == 0) {
mStatusView.setStatus(StatusLayout.EMPTY);
} else {
UIUtils.snackBar(mStatusView, R.string.data_empty);
}
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.framework.utils.ImageLoaderUtils;
import com.framework.utils.UIUtils;
import com.framework.widget.LoadMoreRecyclerView;
import com.framework.widget.StatusLayout;
import com.xadapter.adapter.multi.MultiAdapter;
import com.xadapter.adapter.multi.XMultiAdapterListener;
import com.xadapter.holder.XViewHolder;
Expand Down Expand Up @@ -70,7 +71,7 @@ protected void initActivityCreated() {
}
swipeRefreshLayout.setOnRefreshListener(this);
swipeRefreshLayout.post(this::onRefresh);

swipeRefreshLayout.setEnabled(false);
mAdapter = new MultiAdapter<>(new ArrayList<>());
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
Expand All @@ -86,8 +87,17 @@ protected int getLayoutId() {
return R.layout.fragment_fiction_home;
}

@Override
protected void clickNetWork() {
super.clickNetWork();
if (!swipeRefreshLayout.isRefreshing()) {
onRefresh();
}
}

@Override
public void onRefresh() {
mStatusView.setStatus(StatusLayout.SUCCESS);
mPresenter.netWorkRequest(type);
}

Expand All @@ -98,12 +108,15 @@ public void netWorkSuccess(List<FictionModel> data) {
mAdapter.getData().clear();
}
mAdapter.addAll(data);
mStatusView.setStatus(StatusLayout.SUCCESS);
}
}

@Override
public void netWorkError() {
if (mStatusView != null) {
mAdapter.clearAll();
mStatusView.setStatus(StatusLayout.ERROR);
UIUtils.snackBar(mStatusView, getString(R.string.network_error));
}
}
Expand Down
Loading

0 comments on commit 0a81d23

Please sign in to comment.