Skip to content

Commit

Permalink
修改viewexpansion的类型
Browse files Browse the repository at this point in the history
开始进行对kotlin的支持
  • Loading branch information
Jude95 committed Mar 13, 2016
1 parent ac47849 commit 39cc9e1
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion beam/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'//项目描述,没什么用

Expand Down
11 changes: 10 additions & 1 deletion beam/src/main/java/com/jude/beam/bijection/BeamFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 extends View> E $(@NonNull View view,@IdRes int id){
return (E)view.findViewById(id);
}

protected final <E extends View> E viewId(@NonNull View view,@IdRes int id){
return (E)view.findViewById(id);
}

public PresenterType getPresenter() {
return helper.getPresenter();
Expand Down
10 changes: 8 additions & 2 deletions beam/src/main/java/com/jude/beam/expansion/BeamBaseActivity.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -104,12 +105,17 @@ public final ViewExpansionDelegate getExpansion() {
return mDelegate;
}

protected final <E extends View> E $(View view,@IdRes int id){
protected final <E extends View> E $(@NonNull View view,@IdRes int id){
return (E)view.findViewById(id);
}
protected final <E extends View> E viewId(@NonNull View view,@IdRes int id){
return (E)view.findViewById(id);
}
protected final <E extends View> E $(@IdRes int id){
return (E)findViewById(id);
}

protected final <E extends View> E viewId(@IdRes int id){
return (E)findViewById(id);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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(){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 9 additions & 0 deletions demo/src/main/java/com/jude/beamdemo/app/APP.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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).
Expand Down
1 change: 1 addition & 0 deletions demo/src/main/java/com/jude/beamdemo/ui/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ public class MainActivity extends BeamBaseActivity<MainPresenter> {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
data(5,5);
}
}

0 comments on commit 39cc9e1

Please sign in to comment.