diff --git a/README.md b/README.md index 92a7969..64ee4bd 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Beam 是一套基于MVP模式的快速开发框架。定义了一套开发规范。并提供了基于这套规范的Activity,Fragment,Presenter,Model等父类及控件和API等,完成APP开发过程中大量繁琐工作。 ##依赖 -`compile 'com.jude:beam:2.7.3'` +`compile 'com.jude:beam:2.7.5'` ##MVP概念 MVP模式在Android开发中的使用越来越流行,它十分适合Android。最好先看看[本框架对MVP的理解](http://www.jianshu.com/p/ed2aa9546c2c)。 diff --git a/beam/build.gradle b/beam/build.gradle index 8bb4c98..17338ee 100644 --- a/beam/build.gradle +++ b/beam/build.gradle @@ -31,7 +31,7 @@ ext { gitUrl = 'https://github.com/Jude95/RequestVolley' - libraryVersion = '2.7.3'//版本号 + libraryVersion = '2.7.5'//版本号 libraryName = 'beam'//项目名字,没什么用 libraryDescription = 'A framwork for Android'//项目描述,没什么用 diff --git a/beam/src/main/java/com/jude/beam/bijection/BeamFragment.java b/beam/src/main/java/com/jude/beam/bijection/BeamFragment.java index e9fd042..1f971f0 100644 --- a/beam/src/main/java/com/jude/beam/bijection/BeamFragment.java +++ b/beam/src/main/java/com/jude/beam/bijection/BeamFragment.java @@ -2,9 +2,11 @@ import android.content.Intent; import android.os.Bundle; +import android.support.annotation.IdRes; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; +import android.view.View; /** * This view is an example of how a view should control it's presenter. @@ -55,9 +57,16 @@ public void onPause() { @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); - helper.onResult(requestCode, resultCode,data); + helper.onResult(requestCode, resultCode, data); } + protected final E $(@NonNull View view,@IdRes int id){ + return (E)view.findViewById(id); + } + + protected final E viewId(@NonNull View view,@IdRes int id){ + return (E)view.findViewById(id); + } public PresenterType getPresenter() { return helper.getPresenter(); diff --git a/beam/src/main/java/com/jude/beam/expansion/BeamBaseActivity.java b/beam/src/main/java/com/jude/beam/expansion/BeamBaseActivity.java index a1ef5a7..7b04da8 100644 --- a/beam/src/main/java/com/jude/beam/expansion/BeamBaseActivity.java +++ b/beam/src/main/java/com/jude/beam/expansion/BeamBaseActivity.java @@ -1,6 +1,7 @@ package com.jude.beam.expansion; import android.support.annotation.IdRes; +import android.support.annotation.NonNull; import android.support.v7.widget.Toolbar; import android.view.MenuItem; import android.view.View; @@ -104,12 +105,17 @@ public final ViewExpansionDelegate getExpansion() { return mDelegate; } - protected final E $(View view,@IdRes int id){ + protected final E $(@NonNull View view,@IdRes int id){ + return (E)view.findViewById(id); + } + protected final E viewId(@NonNull View view,@IdRes int id){ return (E)view.findViewById(id); } protected final E $(@IdRes int id){ return (E)findViewById(id); } - + protected final E viewId(@IdRes int id){ + return (E)findViewById(id); + } } diff --git a/beam/src/main/java/com/jude/beam/expansion/list/BeamListActivity.java b/beam/src/main/java/com/jude/beam/expansion/list/BeamListActivity.java index 2ed02b7..77a03e5 100644 --- a/beam/src/main/java/com/jude/beam/expansion/list/BeamListActivity.java +++ b/beam/src/main/java/com/jude/beam/expansion/list/BeamListActivity.java @@ -39,10 +39,12 @@ protected void onCreate(Bundle savedInstanceState) { } public void stopRefresh(){ - mListView.getSwipeToRefresh().setRefreshing(false); + if(mListView!=null) + mListView.getSwipeToRefresh().setRefreshing(false); } public void showError(Throwable e){ - mListView.showError(); + if (mListView!=null) + mListView.showError(); } public int getLayout(){ diff --git a/beam/src/main/java/com/jude/beam/expansion/list/BeamListFragment.java b/beam/src/main/java/com/jude/beam/expansion/list/BeamListFragment.java index aa8e67a..885d414 100644 --- a/beam/src/main/java/com/jude/beam/expansion/list/BeamListFragment.java +++ b/beam/src/main/java/com/jude/beam/expansion/list/BeamListFragment.java @@ -47,10 +47,12 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa } public void stopRefresh(){ - mListView.getSwipeToRefresh().setRefreshing(false); + if(mListView!=null) + mListView.getSwipeToRefresh().setRefreshing(false); } public void showError(Throwable e){ - mListView.showError(); + if (mListView!=null) + mListView.showError(); } public int getLayout(){ diff --git a/beam/src/main/java/com/jude/beam/expansion/overlay/ViewExpansionDelegateProvider.java b/beam/src/main/java/com/jude/beam/expansion/overlay/ViewExpansionDelegateProvider.java index 6745101..457b6ca 100644 --- a/beam/src/main/java/com/jude/beam/expansion/overlay/ViewExpansionDelegateProvider.java +++ b/beam/src/main/java/com/jude/beam/expansion/overlay/ViewExpansionDelegateProvider.java @@ -5,10 +5,10 @@ /** * Created by Mr.Jude on 2015/8/17. */ -public abstract class ViewExpansionDelegateProvider { - public abstract ViewExpansionDelegate createViewExpansionDelegate(BeamBaseActivity activity); +public interface ViewExpansionDelegateProvider { + ViewExpansionDelegate createViewExpansionDelegate(BeamBaseActivity activity); - public static ViewExpansionDelegateProvider DEFAULT = new ViewExpansionDelegateProvider() { + ViewExpansionDelegateProvider DEFAULT = new ViewExpansionDelegateProvider() { @Override public ViewExpansionDelegate createViewExpansionDelegate(BeamBaseActivity activity) { return new DefaultViewExpansionDelegate(activity); diff --git a/demo/src/main/java/com/jude/beamdemo/app/APP.java b/demo/src/main/java/com/jude/beamdemo/app/APP.java index 8884602..23e79c0 100644 --- a/demo/src/main/java/com/jude/beamdemo/app/APP.java +++ b/demo/src/main/java/com/jude/beamdemo/app/APP.java @@ -3,7 +3,10 @@ import android.app.Application; import com.jude.beam.Beam; +import com.jude.beam.expansion.BeamBaseActivity; import com.jude.beam.expansion.list.ListConfig; +import com.jude.beam.expansion.overlay.ViewExpansionDelegate; +import com.jude.beam.expansion.overlay.ViewExpansionDelegateProvider; import com.jude.beamdome.R; import com.jude.utils.JUtils; @@ -17,6 +20,12 @@ public void onCreate() { JUtils.initialize(this); JUtils.setDebug(true, "BeamTest"); Beam.init(this); + Beam.setViewExpansionDelegateProvider(new ViewExpansionDelegateProvider() { + @Override + public ViewExpansionDelegate createViewExpansionDelegate(BeamBaseActivity activity) { + return null; + } + }); ListConfig.setDefaultListConfig( new ListConfig(). setRefreshAble(true). diff --git a/demo/src/main/java/com/jude/beamdemo/ui/MainActivity.java b/demo/src/main/java/com/jude/beamdemo/ui/MainActivity.java index 013af99..97ca50b 100644 --- a/demo/src/main/java/com/jude/beamdemo/ui/MainActivity.java +++ b/demo/src/main/java/com/jude/beamdemo/ui/MainActivity.java @@ -17,5 +17,6 @@ public class MainActivity extends BeamBaseActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); + data(5,5); } }