This commit is contained in:
wangcongtao
2020-01-07 17:56:33 +08:00
parent dca01fe24b
commit c69a959b6a
177 changed files with 1457 additions and 650 deletions

View File

@@ -0,0 +1,65 @@
package com.mogo.module.apps;
import android.view.View;
import androidx.annotation.NonNull;
import com.alibaba.android.arouter.launcher.ARouter;
import com.mogo.commons.mvp.IView;
import com.mogo.commons.mvp.MvpFragment;
import com.mogo.commons.mvp.Presenter;
import com.mogo.service.MogoServicePaths;
import com.mogo.service.cardmanager.IMogoCardManager;
/**
* @author congtaowang
* @since 2020-01-06
* <p>
* 描述
*/
public class AppNavigatorFragment extends MvpFragment< IView, Presenter< IView > > implements IView {
private View mNavigation;
private View mMusic;
private View mChat;
private View mApps;
private IMogoCardManager mCardManager;
private AppsFragment mAppsFragment;
@Override
protected int getLayoutId() {
return R.layout.module_apps_fragment_apps_navigator;
}
@Override
protected void initViews() {
mCardManager = ( IMogoCardManager ) ARouter.getInstance().build( MogoServicePaths.PATH_CARD_MANAGER ).navigation( getContext() );
mNavigation = findViewById( R.id.module_apps_id_navigation );
mMusic = findViewById( R.id.module_apps_id_music );
mChat = findViewById( R.id.module_apps_id_chat );
mApps = findViewById( R.id.module_apps_id_apps );
mNavigation.setOnClickListener( view -> {
mCardManager.switch2( "CARD_TYPE_NAVIGATION" );
} );
mMusic.setOnClickListener( view -> {
mCardManager.switch2( "CARD_TYPE_SHARE_MUSIC" );
} );
mChat.setOnClickListener( view -> {
mCardManager.switch2( "CARD_TYPE_CARS_CHATTING" );
} );
mApps.setOnClickListener( view -> {
new AppsFragment().show( getChildFragmentManager(), AppsFragment.TAG );
} );
}
@NonNull
@Override
protected Presenter< IView > createPresenter() {
return new Presenter< IView >( this ) {
};
}
}

View File

@@ -1,7 +1,9 @@
package com.mogo.module.apps;
import android.app.Dialog;
import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -10,8 +12,11 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.bottomsheet.BottomSheetBehavior;
import com.mogo.commons.mvp.MvpDialogFragment;
import com.mogo.commons.mvp.MvpFragment;
import com.mogo.module.apps.model.AppInfo;
import com.mogo.utils.BitmapHelper;
import com.mogo.utils.WindowUtils;
import java.util.List;
@@ -21,9 +26,11 @@ import java.util.List;
* <p>
* 描述
*/
public class AppsFragment extends MvpFragment< AppsView, AppsPresenter > implements AppsView {
public class AppsFragment extends MvpDialogFragment< AppsView, AppsPresenter > implements AppsView {
private BottomSheetBehavior mBottomSheetBehavior;
public static final String TAG = "AppsFragment";
// private BottomSheetBehavior mBottomSheetBehavior;
private RecyclerView mAppsList;
private AppsAdapter mAppsAdapter;
@@ -35,22 +42,36 @@ public class AppsFragment extends MvpFragment< AppsView, AppsPresenter > impleme
@Override
protected void initViews() {
mAppsList = findViewById( R.id.module_apps_id_apps );
mAppsList.setLayoutManager( new GridLayoutManager( getContext(), 3 ) );
mBottomSheetBehavior = BottomSheetBehavior.from( mAppsList );
mBottomSheetBehavior.setSkipCollapsed( true );
mBottomSheetBehavior.setBottomSheetCallback( new BottomSheetBehavior.BottomSheetCallback() {
@Override
public void onStateChanged( @NonNull View bottomSheet, int newState ) {
mAppsList.setLayoutManager( new GridLayoutManager( getContext(), 8 ) );
// mBottomSheetBehavior = BottomSheetBehavior.from( mAppsList );
// mBottomSheetBehavior.setSkipCollapsed( true );
// mBottomSheetBehavior.setBottomSheetCallback( new BottomSheetBehavior.BottomSheetCallback() {
// @Override
// public void onStateChanged( @NonNull View bottomSheet, int newState ) {
//
// }
//
// @Override
// public void onSlide( @NonNull View bottomSheet, float slideOffset ) {
//
// }
// } );
// mBottomSheetBehavior.setState( BottomSheetBehavior.STATE_COLLAPSED );
}
@Override
public void onStart() {
super.onStart();
super.onStart();
final Dialog dialog = getDialog();
if ( dialog != null ) {
if ( dialog.getWindow() != null ) {
final WindowManager.LayoutParams params = dialog.getWindow().getAttributes();
params.width = WindowUtils.getScreenWidth( getContext() );
params.height = WindowUtils.getScreenHeight( getContext() );
dialog.getWindow().setAttributes( params );
}
@Override
public void onSlide( @NonNull View bottomSheet, float slideOffset ) {
}
} );
mBottomSheetBehavior.setState( BottomSheetBehavior.STATE_COLLAPSED );
}
}
@NonNull
@@ -76,11 +97,9 @@ public class AppsFragment extends MvpFragment< AppsView, AppsPresenter > impleme
}
private void bindListener() {
mAppsAdapter.setOnClickListener(new View.OnClickListener() {
@Override public void onClick(View v) {
AppInfo tag = (AppInfo) v.getTag();
}
});
mAppsAdapter.setOnClickListener( view -> {
AppInfo app = ( AppInfo ) view.getTag();
mPresenter.launch( app );
} );
}
}

View File

@@ -26,11 +26,11 @@ import com.mogo.service.module.ModuleType;
@Route( path = MogoModulePaths.PATH_MODULE_APPS )
public class AppsFragmentProvider implements IMogoModuleProvider {
private AppsFragment mAppsFragment;
private AppNavigatorFragment mAppsFragment;
@Override
public Fragment createFragment( Context context, Bundle data ) {
mAppsFragment = new AppsFragment();
mAppsFragment = new AppNavigatorFragment();
mAppsFragment.setArguments( data );
return mAppsFragment;
}

View File

@@ -1,5 +1,6 @@
package com.mogo.module.apps;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
@@ -83,4 +84,17 @@ public class AppsPresenter extends Presenter< AppsView > {
return appInfos;
}
public void launch( AppInfo appInfo ) {
if ( appInfo == null ) {
return;
}
Intent intent = getContext().getPackageManager().getLaunchIntentForPackage( appInfo.getPackageName() );
if ( intent == null ) {
Logger.e( TAG, "can't launch app: %s", appInfo.toString() );
return;
}
intent.addFlags( Intent.FLAG_ACTIVITY_NEW_TASK );
getContext().startActivity( intent );
}
}

View File

@@ -43,4 +43,14 @@ public class AppInfo {
public Drawable getIcon() {
return mIcon;
}
@Override
public String toString() {
return "AppInfo{" +
"mName='" + mName + '\'' +
", mPackageName='" + mPackageName + '\'' +
", mVersionName='" + mVersionName + '\'' +
", mVersionCode=" + mVersionCode +
'}';
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View File

@@ -1,5 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
<?xml version="1.0" encoding="utf-8"?><!--<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"-->
<!-- xmlns:app="http://schemas.android.com/apk/res-auto"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="match_parent">-->
<!-- <androidx.recyclerview.widget.RecyclerView-->
<!-- android:id="@+id/module_apps_id_apps"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="match_parent"-->
<!-- app:behavior_hideable="false"-->
<!-- app:behavior_peekHeight="76dp"-->
<!-- app:layout_behavior="@string/bottom_sheet_behavior" />-->
<!--</androidx.coordinatorlayout.widget.CoordinatorLayout>-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
@@ -9,6 +22,5 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
app:behavior_hideable="false"
app:behavior_peekHeight="76dp"
app:layout_behavior="@string/bottom_sheet_behavior" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
app:behavior_peekHeight="76dp" />
</LinearLayout>

View File

@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
android:paddingBottom="@dimen/dp_33">
<ImageView
android:id="@+id/module_apps_id_navigation"
android:layout_width="@dimen/dp_119"
android:layout_height="@dimen/dp_119"
android:src="@drawable/module_apps_ic_navigation" />
<ImageView
android:id="@+id/module_apps_id_music"
android:layout_width="@dimen/dp_119"
android:layout_height="@dimen/dp_119"
android:layout_marginLeft="@dimen/dp_61"
android:src="@drawable/module_apps_ic_music" />
<ImageView
android:id="@+id/module_apps_id_chat"
android:layout_width="@dimen/dp_119"
android:layout_height="@dimen/dp_119"
android:layout_marginLeft="@dimen/dp_61"
android:src="@drawable/module_apps_ic_chat" />
<ImageView
android:id="@+id/module_apps_id_apps"
android:layout_width="@dimen/dp_119"
android:layout_height="@dimen/dp_119"
android:layout_marginLeft="@dimen/dp_61"
android:src="@drawable/module_apps_ic_apps" />
</LinearLayout>

View File

@@ -3,6 +3,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical">
<ImageView
@@ -13,5 +14,7 @@
<TextView
android:id="@+id/module_apps_id_app_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"
android:gravity="center"
android:maxLines="2" />
</LinearLayout>