Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
luzhensheng
committed
Feb 20, 2017
0 parents
commit c70d702
Showing
74 changed files
with
1,713 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/workspace.xml | ||
/.idea/libraries | ||
.DS_Store | ||
/build | ||
/captures |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
android { | ||
compileSdkVersion 24 | ||
buildToolsVersion "25.0.0" | ||
|
||
defaultConfig { | ||
applicationId "com.jomeslu.toprouter" | ||
minSdkVersion 15 | ||
targetSdkVersion 24 | ||
versionCode 1 | ||
versionName "1.0" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
compile fileTree(dir: 'libs', include: ['*.jar']) | ||
compile project(':router') | ||
|
||
compile 'com.android.support:appcompat-v7:24.2.1' | ||
compile 'com.android.support:design:24.2.1' | ||
testCompile 'junit:junit:4.12' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Add project specific ProGuard rules here. | ||
# By default, the flags in this file are appended to flags specified | ||
# in /home/jomeslu/Tinybuild/sdk/android/tools/proguard/proguard-android.txt | ||
# You can edit the include path and order by changing the proguardFiles | ||
# directive in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# Add any project specific keep options here: | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} |
13 changes: 13 additions & 0 deletions
13
app/src/androidTest/java/com/jomeslu/toprouter/ApplicationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.jomeslu.toprouter; | ||
|
||
import android.app.Application; | ||
import android.test.ApplicationTestCase; | ||
|
||
/** | ||
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a> | ||
*/ | ||
public class ApplicationTest extends ApplicationTestCase<Application> { | ||
public ApplicationTest() { | ||
super(Application.class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.jomeslu.toprouter"> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:launchMode="singleTask" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme"> | ||
<activity android:name=".MainActivity"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
<intent-filter> | ||
<data | ||
android:host="main" | ||
android:scheme="jomeslu" /> | ||
|
||
<action android:name="android.intent.action.VIEW" /> | ||
|
||
<category android:name="android.intent.category.BROWSABLE" /> | ||
<category android:name="android.intent.category.DEFAULT" /> | ||
</intent-filter> | ||
</activity> | ||
<activity android:name=".OneActivity" /> | ||
<activity | ||
android:name=".LoginActivity" | ||
android:label="@string/title_activity_login" | ||
android:theme="@style/AppTheme.NoActionBar"></activity> | ||
</application> | ||
|
||
</manifest> |
29 changes: 29 additions & 0 deletions
29
app/src/main/java/com/jomeslu/toprouter/LoginActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.jomeslu.toprouter; | ||
|
||
import android.os.Bundle; | ||
import android.support.design.widget.FloatingActionButton; | ||
import android.support.design.widget.Snackbar; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.support.v7.widget.Toolbar; | ||
import android.view.View; | ||
|
||
public class LoginActivity extends AppCompatActivity { | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_login); | ||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); | ||
setSupportActionBar(toolbar); | ||
|
||
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); | ||
fab.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) | ||
.setAction("Action", null).show(); | ||
} | ||
}); | ||
} | ||
|
||
} |
138 changes: 138 additions & 0 deletions
138
app/src/main/java/com/jomeslu/toprouter/MainActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
package com.jomeslu.toprouter; | ||
|
||
import android.app.Activity; | ||
import android.content.Intent; | ||
import android.net.Uri; | ||
import android.os.Bundle; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.text.TextUtils; | ||
import android.view.View; | ||
import android.widget.EditText; | ||
import android.widget.TextView; | ||
import android.widget.Toast; | ||
|
||
|
||
import java.util.Map; | ||
|
||
import jomeslu.com.router.IRouteInterceptor; | ||
import jomeslu.com.router.IRouteTableMapping; | ||
import jomeslu.com.router.IRouterResultCallback; | ||
import jomeslu.com.router.LogUtils; | ||
import jomeslu.com.router.Router; | ||
|
||
public class MainActivity extends AppCompatActivity { | ||
|
||
|
||
private TextView tips; | ||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_main); | ||
Router.initRouteTable(new IRouteTableMapping() { | ||
@Override | ||
public void operaRouterTable(Map<String, Class<? extends Activity>> map) { | ||
map.put("jomeslu://www", OneActivity.class); | ||
map.put("jomeslu://loginactivity", LoginActivity.class); | ||
} | ||
}); | ||
|
||
getIntentParam("url"); | ||
|
||
tips = (TextView) findViewById(R.id.tips); | ||
final EditText edit = (EditText) findViewById(R.id.edit); | ||
|
||
|
||
setTips(tips); | ||
|
||
findViewById(R.id.go).setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
String url = TextUtils.isEmpty(edit.getText().toString())?"test":edit.getText().toString(); | ||
Router.build(url).setRouterResultCallback(new IRouterResultCallback() { | ||
@Override | ||
public void succeed(Uri uri) { | ||
Toast.makeText(MainActivity.this, "success uri:" + uri.toString(), Toast.LENGTH_LONG).show(); | ||
} | ||
|
||
@Override | ||
public void failure(Uri uri, String message) { | ||
Toast.makeText(MainActivity.this, message, Toast.LENGTH_LONG).show(); | ||
} | ||
}).start(MainActivity.this); | ||
} | ||
}); | ||
|
||
findViewById(R.id.btn).setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
|
||
Router.build("jomeslu://www?{i:id}=168&{s:jomeslu}=jomeslu").setRouterResultCallback(new IRouterResultCallback() { | ||
@Override | ||
public void succeed(Uri uri) { | ||
Toast.makeText(MainActivity.this, "success uri:" + uri.toString(), Toast.LENGTH_LONG).show(); | ||
} | ||
@Override | ||
public void failure(Uri uri, String message) { | ||
Toast.makeText(MainActivity.this, message, Toast.LENGTH_LONG).show(); | ||
|
||
} | ||
}).start(MainActivity.this); | ||
|
||
} | ||
}); | ||
|
||
findViewById(R.id.browser).setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
Router.build("http://androidblog.cn/index.php/Source").start(MainActivity.this); | ||
} | ||
}); | ||
|
||
findViewById(R.id.inter).setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
Router.build("jomeslu://www?{i:id}=168&{s:jomeslu}=jomeslu").setIRouteInterceptor(new IRouteInterceptor() { | ||
@Override | ||
public boolean interceptor() { | ||
Router.build("jomeslu://loginactivity?{i:id}=168&{s:jomeslu}=jomeslu").start(MainActivity.this); | ||
Toast.makeText(MainActivity.this, "login...", Toast.LENGTH_LONG).show(); | ||
|
||
return true; | ||
} | ||
}).start(MainActivity.this);; | ||
|
||
} | ||
}); | ||
|
||
} | ||
|
||
protected void setTips(TextView tips){ | ||
String jomeslu = getIntent().getStringExtra("jomeslu"); | ||
jomeslu = TextUtils.isEmpty(jomeslu) ?"网页参数":jomeslu; | ||
int id = getIntent().getIntExtra("id", -1); | ||
String message = new StringBuffer("来自网页启动! \n 接收到网页参数 String jomeslu=").append(jomeslu).append(" \n 接收到网页参数 int id = ").append(id).toString(); | ||
tips.setText(message); | ||
} | ||
|
||
@Override | ||
protected void onNewIntent(Intent intent) { | ||
super.onNewIntent(intent); | ||
getIntentParam("url"); | ||
setTips(tips); | ||
} | ||
|
||
|
||
private void getIntentParam(String param) { | ||
Intent intent = getIntent(); | ||
if (intent != null && intent.getDataString() != null) { | ||
String spitParam=new StringBuffer(param).append("=").toString(); | ||
if(intent.getDataString().contains(spitParam)) { | ||
String url = intent.getDataString().split(spitParam)[1]; | ||
Router.build(url).start(this); | ||
} | ||
|
||
|
||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.jomeslu.toprouter; | ||
|
||
import android.support.v7.app.AppCompatActivity; | ||
import android.os.Bundle; | ||
import android.text.TextUtils; | ||
import android.widget.TextView; | ||
import android.widget.Toast; | ||
|
||
public class OneActivity extends AppCompatActivity { | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_one); | ||
|
||
TextView textView = (TextView) findViewById(R.id.infos); | ||
String jomeslu = getIntent().getStringExtra("jomeslu"); | ||
jomeslu = TextUtils.isEmpty(jomeslu) ?"":jomeslu; | ||
int id = getIntent().getIntExtra("id", -1); | ||
String message = new StringBuffer("Success! get \n jomeslu:").append(jomeslu).append(" id : ").append(id).toString(); | ||
textView.setText(message); | ||
Toast.makeText(this, message, Toast.LENGTH_LONG).show(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<set xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<translate android:fromXDelta="100%p" android:toXDelta="0" | ||
android:duration="2000" /> | ||
</set> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<set xmlns:android="http://schemas.android.com/apk/res/android" > | ||
|
||
<translate | ||
android:duration="2000" | ||
android:fromXDelta="0" | ||
android:toXDelta="-100%p" /> | ||
|
||
</set> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<set xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<translate xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:interpolator="@android:anim/accelerate_interpolator" | ||
android:fromXDelta="-100%p" | ||
android:toXDelta="0%p" | ||
android:duration="500"> | ||
</translate> | ||
</set> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<set xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:interpolator="@android:anim/accelerate_interpolator"> | ||
<translate | ||
android:duration="500" | ||
android:fromXDelta="0%p" | ||
android:toXDelta="-100%p"> | ||
|
||
</translate> | ||
</set> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:fitsSystemWindows="true" | ||
tools:context="com.jomeslu.toprouter.LoginActivity"> | ||
|
||
<android.support.design.widget.AppBarLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:theme="@style/AppTheme.AppBarOverlay"> | ||
|
||
<android.support.v7.widget.Toolbar | ||
android:id="@+id/toolbar" | ||
android:layout_width="match_parent" | ||
android:layout_height="?attr/actionBarSize" | ||
android:background="?attr/colorPrimary" | ||
app:popupTheme="@style/AppTheme.PopupOverlay" /> | ||
|
||
</android.support.design.widget.AppBarLayout> | ||
|
||
<include layout="@layout/content_login" /> | ||
|
||
<android.support.design.widget.FloatingActionButton | ||
android:id="@+id/fab" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="bottom|end" | ||
android:layout_margin="@dimen/fab_margin" | ||
app:srcCompat="@android:drawable/ic_dialog_email" /> | ||
|
||
</android.support.design.widget.CoordinatorLayout> |
Oops, something went wrong.