Skip to content

Commit

Permalink
V0.3.0 released: Support starting multiple activities.
Browse files Browse the repository at this point in the history
  • Loading branch information
belinwu committed Dec 19, 2015
1 parent d195d5a commit 92ce4b4
Show file tree
Hide file tree
Showing 29 changed files with 617 additions and 333 deletions.
7 changes: 7 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# V0.3.0 (2015-12-19): Support Starting Multiple Activities

- Support starting multiple activities.
- Remove `Transition` interface.
- New `Starter` creating methods with transition animation resource id.
- New abstract `Starter` implementation added.
- Support setting default transition animation.

# V0.2.0 (2015-11-21): Internal Logic Change Release

Expand Down
39 changes: 26 additions & 13 deletions DOC.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ mehtods listed below in a chain.

```java
.start(Activity.class) // or
.start(Intent)
.start(Intent) // or
.start(Activity1.class, Activity2.class, ...) // or
.start(Intent, Intent, ...)
```

### Sets the request code
Expand Down Expand Up @@ -96,6 +98,8 @@ ignored.
.extras(Bundle)
```

**Notice: If you start multiple activties and these methods chained, then all intents affected.**

### Sets additional options

This feature rquires Android SDK API >= 16.
Expand All @@ -109,8 +113,7 @@ This feature rquires Android SDK API >= 16.
```java
.enter(int) // or
.exit(int) // or
.transition(int, int) // or
.transition(Transition) // Ignore if transition is null
.transition(int, int)
```

### Define your Starter
Expand All @@ -120,30 +123,40 @@ your Presenter class implement the `Starter` interface.

```java
public class Presenter implements Starter {
/**
* The real starter
*/
private Fragment fragment;
private Starter starter = Starters.newStarter(fragment);

@Override
public void startActivity(Intent intent, Bundle options) {
// Take care of your NPE
Starter starter = Starters.newFragmentStarter(fragment);
// Take care of NPE
starter.startActivity(intent, options);
}

@Override
public void startActivityForResult(Intent intent, int requestCode, Bundle options) {
// Take care of your NPE
Starter starter = Starters.newFragmentStarter(fragment);
// Take care of NPE
starter.startActivityForResult(intent, requestCode, options);
}

@Override
public void startActivities(Intent[] intents, Bundle options) {
starter.startActivities(intents, options);
}

@Nullable
@Override
public Activity getActivity() {
// Take care of your NPE
return fragment.getActivity();
// Take care of NPE
return starter.getActivity();
}

@Override
public int getEnter() {
return starter.getEnter();
}

@Override
public int getExit() {
return starter.getEnter();
}
}
```
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Doorbell is available on jCenter.
Gradle:

```
compile 'com.wujilin.doorbell:doorbell:0.2.0'
compile 'com.wujilin.doorbell:doorbell:0.3.0'
```

# How do I use Doorbell?
Expand Down
3 changes: 1 addition & 2 deletions app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/23.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.wujilin.doorbell/doorbell/0.2.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
Expand All @@ -85,9 +84,9 @@
<orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="support-annotations-23.1.0" level="project" />
<orderEntry type="library" exported="" name="doorbell-0.2.0" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-23.1.0" level="project" />
<orderEntry type="library" exported="" name="glide-3.6.1" level="project" />
<orderEntry type="library" exported="" name="support-v4-23.1.0" level="project" />
<orderEntry type="module" module-name="doorbell" exported="" />
</component>
</module>
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ dependencies {
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.github.bumptech.glide:glide:3.6.1'

// compile project(':doorbell')
compile 'com.wujilin.doorbell:doorbell:0.2.0'
compile project(':doorbell')
// compile 'com.wujilin.doorbell:doorbell:0.2.0'
}
3 changes: 2 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
</intent-filter>
</activity>
<activity android:name=".SendActivity">

</activity>
<activity android:name=".ThirdActivity">
</activity>
</application>

Expand Down
10 changes: 10 additions & 0 deletions app/src/main/java/com/wujilin/sample/doorbell/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public class MainActivity extends Activity implements View.OnClickListener {
private Button activity7;
private Button activity8;
private Button activity9;
private Button activity10;
private boolean logined;

private LoginDoor loginDoor = new LoginDoor();
Expand Down Expand Up @@ -85,6 +86,7 @@ public void onFindView() {
activity7 = (Button) findViewById(R.id.activity7);
activity8 = (Button) findViewById(R.id.activity8);
activity9 = (Button) findViewById(R.id.activity9);
activity10 = (Button) findViewById(R.id.activity10);
login = (Button) findViewById(R.id.login);
logout = (Button) findViewById(R.id.logout);
status = (TextView) findViewById(R.id.status);
Expand All @@ -106,6 +108,7 @@ public void onInitView() {
activity7.setOnClickListener(this);
activity8.setOnClickListener(this);
activity9.setOnClickListener(this);
activity10.setOnClickListener(this);
login.setOnClickListener(this);
logout.setOnClickListener(this);
}
Expand Down Expand Up @@ -330,6 +333,13 @@ public void onBlock() {
}
});
break;
case R.id.activity10:
Doorbell.defaultTransition(R.anim.app_push_left_in, R.anim.app_navigtor_pop_right_out);
Doorbell.with(this)
.start(SendActivity.class, ThirdActivity.class)
.extra("name", "Doorbell")
.ring();
break;
}
}

Expand Down
22 changes: 17 additions & 5 deletions app/src/main/java/com/wujilin/sample/doorbell/Presenter.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,27 +33,39 @@ of this software and associated documentation files (the "Software"), to deal
import com.wujilin.doorbell.starter.Starters;

public class Presenter implements Starter {

private Fragment fragment;
Starter starter = Starters.newStarter(new Fragment());

@Override
public void startActivity(Intent intent, Bundle options) {
// Take care of NPE
Starter starter = Starters.newFragmentStarter(fragment);
starter.startActivity(intent, options);
}

@Override
public void startActivityForResult(Intent intent, int requestCode, Bundle options) {
// Take care of NPE
Starter starter = Starters.newFragmentStarter(fragment);
starter.startActivityForResult(intent, requestCode, options);
}

@Override
public void startActivities(Intent[] intents, Bundle options) {
starter.startActivities(intents, options);
}

@Nullable
@Override
public Activity getActivity() {
// Take care of NPE
return fragment.getActivity();
return starter.getActivity();
}

@Override
public int getEnter() {
return starter.getEnter();
}

@Override
public int getExit() {
return starter.getEnter();
}
}
22 changes: 21 additions & 1 deletion app/src/main/java/com/wujilin/sample/doorbell/SendActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,13 @@ of this software and associated documentation files (the "Software"), to deal
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.widget.TextView;

public class SendActivity extends Activity {
import com.wujilin.doorbell.Doorbell;
import com.wujilin.doorbell.Starter;

public class SendActivity extends Activity implements Starter {

private TextView extras;

Expand All @@ -41,4 +45,20 @@ protected void onCreate(Bundle savedInstanceState) {
Intent intent = getIntent();
extras.setText(intent.getExtras().getString("name"));
}

@Override
public int getEnter() {
return 0;
}

@Override
public int getExit() {
return 0;
}

@Nullable
@Override
public Activity getActivity() {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,43 @@ of this software and associated documentation files (the "Software"), to deal
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
package com.wujilin.doorbell;

import android.support.annotation.AnimRes;

/**
* The interface represents transition animation to perform next.
*/
public interface Transition {

/**
* Returns a resource ID of the animation resource to use for the incoming activity.
*
* @return A resource ID of the animation resource to use for the incoming activity
*/
@AnimRes
int getEnter();

/**
* Returns a resource ID of the animation resource to use for the outgoing activity.
*
* @return A resource ID of the animation resource to use for the outgoing activity
*/
@AnimRes
int getExit();
package com.wujilin.sample.doorbell;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.widget.TextView;

import com.wujilin.doorbell.Starter;

public class ThirdActivity extends Activity implements Starter {

private TextView extras;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.app_activity_third);

extras = (TextView) findViewById(R.id.extras);
Intent intent = getIntent();
extras.setText(intent.getExtras().getString("name"));
}

@Override
public int getEnter() {
return 0;
}

@Override
public int getExit() {
return 0;
}

@Nullable
@Override
public Activity getActivity() {
return null;
}
}
6 changes: 6 additions & 0 deletions app/src/main/res/layout/app_activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,11 @@
android:layout_height="wrap_content"
android:text="Start SecondActivity door() ring(OnBlockListenr)"
/>
<Button
android:id="@+id/activity10"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Start SecondActivity and ThirdActivity"
/>
</LinearLayout>
</ScrollView>
5 changes: 5 additions & 0 deletions app/src/main/res/layout/app_activity_second.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
android:layout_height="match_parent"
android:orientation="vertical"
>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Second"
/>
<TextView
android:id="@+id/extras"
android:layout_width="match_parent"
Expand Down
18 changes: 18 additions & 0 deletions app/src/main/res/layout/app_activity_third.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Third"
/>
<TextView
android:id="@+id/extras"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
4 changes: 2 additions & 2 deletions doorbell/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ ext {
gitUrl = 'https://github.com/belinwu/doorbell.git'
issueUrl = 'https://github.com/belinwu/doorbell/issues'

libraryVersionCode = 2
libraryVersion = '0.2.0'
libraryVersionCode = 3
libraryVersion = '0.3.0'

developerId = 'belinwu'
developerName = 'Belin Wu'
Expand Down
Loading

0 comments on commit 92ce4b4

Please sign in to comment.