Skip to content

Commit

Permalink
Test Router used Interface
Browse files Browse the repository at this point in the history
  • Loading branch information
designDo committed Feb 27, 2019
1 parent 73d223a commit 7971fbd
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 7 deletions.
10 changes: 6 additions & 4 deletions app/src/main/java/com/example/componentdemo/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.alibaba.android.arouter.facade.callback.NavCallback;
import com.alibaba.android.arouter.launcher.ARouter;
import com.example.componentlib.ServiceFactory;
import com.example.logincomponent.ALoginService;
import com.example.logincomponent.UserInfo;

public class MainActivity extends AppCompatActivity {
Expand Down Expand Up @@ -81,11 +82,12 @@ public static MainActivity getThis() {
}
});

findViewById(R.id.show_ui).setOnClickListener(new View.OnClickListener() {
findViewById(R.id.test_interface).setOnClickListener(new View.OnClickListener() {
@Override public void onClick(View v) {
ServiceFactory.getInstance()
.getmLoginService()
.getUserInfoFragment(getSupportFragmentManager(), R.id.container, new Bundle());
ARouter.getInstance().navigation(ALoginService.class).isLogin("TangSan");
/*((ALoginService) ARouter.getInstance()
.build("/loginComponent/isLogin")
.navigation()).isLogin("TangSan");*/
}
});
}
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@
android:text="跳转到-搜索-组件(测试result)"
android:textStyle="bold"
/>
<TextView
android:id="@+id/show_ui"
<Button
android:id="@+id/test_interface"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:text="显示登录组件的UserFragment"
android:text="测试组件内的接口"
android:textStyle="bold"
/>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.example.logincomponent;

import com.alibaba.android.arouter.facade.template.IProvider;

/**
* Created by apple on 2019/2/27.
*/
public interface ALoginService extends IProvider {

void isLogin(String name);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.example.logincomponent;

import android.content.Context;
import android.widget.Toast;
import com.alibaba.android.arouter.facade.annotation.Route;

/**
* Created by apple on 2019/2/27.
*/
@Route(path = "/loginComponent/isLogin") public class ALoginServiceImpl implements ALoginService {

private Context mContext;

@Override public void init(Context context) {
mContext = context;
}

@Override public void isLogin(String name) {
Toast.makeText(mContext, "Hello" + name, Toast.LENGTH_LONG).show();
}
}

0 comments on commit 7971fbd

Please sign in to comment.