Skip to content

Commit

Permalink
[feat-reader] 完成主页面的搭架
Browse files Browse the repository at this point in the history
  • Loading branch information
Gracefulwind committed Feb 22, 2022
1 parent cad3756 commit 306dc45
Show file tree
Hide file tree
Showing 42 changed files with 1,630 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package com.gracefulwind.learnarms.commonres.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.viewpager.widget.ViewPager;

import org.jetbrains.annotations.NotNull;

/**
* @ClassName: NoScrollViewPager
* @Author: Gracefulwind
* @CreateDate: 2022/2/22
* @Description: ---------------------------
* 禁止滑动的viewPager
* @UpdateUser:
* @UpdateDate: 2022/2/22
* @UpdateRemark:
* @Version: 1.0
* @Email: [email protected]
*/
public class NoScrollViewPager extends ViewPager {

private boolean noScroll = true;

public NoScrollViewPager(@NonNull @NotNull Context context) {
super(context);
}

public NoScrollViewPager(@NonNull @NotNull Context context, @Nullable @org.jetbrains.annotations.Nullable AttributeSet attrs) {
super(context, attrs);
}

//调用此方法 参数为true 即可禁止滑动
public void setNoScroll(boolean noScroll) {
this.noScroll = noScroll;
}

@Override
public boolean onTouchEvent(MotionEvent arg0) {
if (noScroll){
return false;
}else {
return super.onTouchEvent(arg0);
}
}

@Override
public boolean onInterceptTouchEvent(MotionEvent arg0) {
if (noScroll){
return false;
}else {
return super.onInterceptTouchEvent(arg0);
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.gracefulwind.learnarms.commonsdk.base;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.gracefulwind.learnarms.commonsdk.R;
import com.gracefulwind.learnarms.commonsdk.core.RouterHub;

/**
* @ClassName: DefaultFragment
* @Author: Gracefulwind
* @CreateDate: 2022/2/22
* @Description: ---------------------------
* defaultFragment 默认空白页面
* @UpdateUser:
* @UpdateDate: 2022/2/22
* @UpdateRemark:
* @Version: 1.0
* @Email: [email protected]
*/
@Route(path = RouterHub.Default.DEFAULT_FRAGMENT)
//@Route(path = "/degrade/fragment")
public class DefaultFragment extends Fragment {
View mRootView;

@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
mRootView = inflater.inflate(R.layout.fragment_default, container, false);
return mRootView;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public interface RouterHub {
* 组名
*/
String APP_HOME = "/app";//宿主 App 组件
String DEFAULT = "/default";//default组件

String COPY = "/copy";//copy组件
String ZHIHU_HOME = "/zhihu";//知乎组件
String GANK_HOME = "/gank";//干货集中营组件
Expand All @@ -65,6 +67,18 @@ public interface RouterHub {
String APP_SPLASHACTIVITY = APP_HOME + "/SplashActivity";
String APP_MAINACTIVITY = APP_HOME + "/MainActivity";

//====================================================================
/**
* 通用基础组件组件
* */
interface Default{
String BASE = DEFAULT;
String DEFAULT_ACTIVITY = BASE + "/DefaultActivity";
String DEFAULT_FRAGMENT = BASE + "/DefaultFragment";
}

//====================================================================================================

//====================================================================
/**
* copy组件
Expand Down Expand Up @@ -158,6 +172,14 @@ interface Reader {
String TEST_TEXT_ACTIVITY = BASE + "/TestTextActivity";
String READER_MAIN_ACTIVITY = BASE + "/ReaderMainActivity";

//=======================
String BOOK_SHELF_FRAGMENT = BASE + "/BookShelfFragment";
String BOOK_MALL_FRAGMENT = BASE + "/BookMallFragment";
String BOOK_SEARCH_FRAGMENT = BASE + "/BookSearchFragment";
String BOOK_ACTIVITY_FRAGMENT = BASE + "/BookActivityFragment";
String BOOK_MINE_FRAGMENT = BASE + "/BookMineFragment";


interface Server{
String COMMON_SERVER = BASE + SERVICE + "/CommonService";
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.gracefulwind.learnarms.commonsdk.utils;

import androidx.fragment.app.Fragment;

import com.alibaba.android.arouter.launcher.ARouter;
import com.gracefulwind.learnarms.commonsdk.base.DefaultFragment;
import com.gracefulwind.learnarms.commonsdk.core.RouterHub;

/**
* @ClassName: ArouterUtil
* @Author: Gracefulwind
* @CreateDate: 2022/2/22
* @Description: ---------------------------
* @UpdateUser:
* @UpdateDate: 2022/2/22
* @UpdateRemark:
* @Version: 1.0
* @Email: [email protected]
*/
public class ARouterUtil {

/**
* 通过路由地址生成相应fragment,如果地址有误则生成default页面
*
* */
public static Fragment getFragment(String path){
Object targetFragment = ARouter.getInstance().build(path).navigation();
if(null != targetFragment && targetFragment instanceof Fragment){
return (Fragment) targetFragment;
}
// return (Fragment) ARouter.getInstance().build(RouterHub.Default.DEFAULT_FRAGMENT).navigation();
//一直为null...为什么
// return (Fragment) ARouter.getInstance().build("/degrade/fragment").navigation();
return new DefaultFragment();
}

}
16 changes: 16 additions & 0 deletions CommonSDK/src/main/res/layout/fragment_default.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:text="默认页面"/>

</androidx.constraintlayout.widget.ConstraintLayout>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.gracefulwind.learnarms.reader.mvp.contract;


import com.jess.arms.mvp.IModel;
import com.jess.arms.mvp.IView;

/**
* ================================================
* Description:
* <p>
* Created by MVPArmsTemplate on 2021/08/20 10:54
* <a href="mailto:[email protected]">Contact me</a>
* <a href="https://github.com/JessYanCoding">Follow me</a>
* <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
* <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
* <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
* ================================================
*/
public interface BookActivityContract {
//对于经常使用的关于UI的方法可以定义到IView中,如显示隐藏进度条,和显示文字消息
interface View extends IView {

}

//Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
interface Model extends IModel {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.gracefulwind.learnarms.reader.mvp.contract;


import com.jess.arms.mvp.IModel;
import com.jess.arms.mvp.IView;

/**
* ================================================
* Description:
* <p>
* Created by MVPArmsTemplate on 2021/08/20 10:54
* <a href="mailto:[email protected]">Contact me</a>
* <a href="https://github.com/JessYanCoding">Follow me</a>
* <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
* <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
* <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
* ================================================
*/
public interface BookMallContract {
//对于经常使用的关于UI的方法可以定义到IView中,如显示隐藏进度条,和显示文字消息
interface View extends IView {

}

//Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
interface Model extends IModel {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.gracefulwind.learnarms.reader.mvp.contract;


import com.jess.arms.mvp.IModel;
import com.jess.arms.mvp.IView;

/**
* ================================================
* Description:
* <p>
* Created by MVPArmsTemplate on 2021/08/20 10:54
* <a href="mailto:[email protected]">Contact me</a>
* <a href="https://github.com/JessYanCoding">Follow me</a>
* <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
* <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
* <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
* ================================================
*/
public interface BookMineContract {
//对于经常使用的关于UI的方法可以定义到IView中,如显示隐藏进度条,和显示文字消息
interface View extends IView {

}

//Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
interface Model extends IModel {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.gracefulwind.learnarms.reader.mvp.contract;


import com.jess.arms.mvp.IModel;
import com.jess.arms.mvp.IView;

/**
* ================================================
* Description:
* <p>
* Created by MVPArmsTemplate on 2021/08/20 10:54
* <a href="mailto:[email protected]">Contact me</a>
* <a href="https://github.com/JessYanCoding">Follow me</a>
* <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
* <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
* <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
* ================================================
*/
public interface BookSearchContract {
//对于经常使用的关于UI的方法可以定义到IView中,如显示隐藏进度条,和显示文字消息
interface View extends IView {

}

//Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
interface Model extends IModel {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.gracefulwind.learnarms.reader.mvp.contract;


import com.jess.arms.mvp.IModel;
import com.jess.arms.mvp.IView;

/**
* ================================================
* Description:
* <p>
* Created by MVPArmsTemplate on 2021/08/20 10:54
* <a href="mailto:[email protected]">Contact me</a>
* <a href="https://github.com/JessYanCoding">Follow me</a>
* <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
* <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
* <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
* ================================================
*/
public interface BookShelfContract {
//对于经常使用的关于UI的方法可以定义到IView中,如显示隐藏进度条,和显示文字消息
interface View extends IView {

}

//Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
interface Model extends IModel {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.gracefulwind.learnarms.reader.mvp.di.component;

import com.gracefulwind.learnarms.reader.mvp.contract.BookActivityContract;
import com.gracefulwind.learnarms.reader.mvp.contract.BookMallContract;
import com.gracefulwind.learnarms.reader.mvp.di.module.BookActivityModule;
import com.gracefulwind.learnarms.reader.mvp.di.module.BookMallModule;
import com.gracefulwind.learnarms.reader.mvp.ui.fragment.BookActivityFragment;
import com.gracefulwind.learnarms.reader.mvp.ui.fragment.BookMallFragment;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.di.scope.ActivityScope;

import dagger.BindsInstance;
import dagger.Component;

/**
* ================================================
* Description:
* <p>
* Created by MVPArmsTemplate on 2021/08/20 10:54
* <a href="mailto:[email protected]">Contact me</a>
* <a href="https://github.com/JessYanCoding">Follow me</a>
* <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
* <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
* <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
* ================================================
*/
@ActivityScope
@Component(modules = BookActivityModule.class, dependencies = AppComponent.class)
public interface BookActivityComponent {

void inject(BookActivityFragment fragment);
@Component.Builder
interface Builder {
@BindsInstance
BookActivityComponent.Builder view(BookActivityContract.View view);
BookActivityComponent.Builder appComponent(AppComponent appComponent);
BookActivityComponent build();
}
}
Loading

0 comments on commit 306dc45

Please sign in to comment.