Skip to content

Commit

Permalink
Merge pull request #2 from YoKeyword/master
Browse files Browse the repository at this point in the history
Master
  • Loading branch information
Klong0709 authored Dec 21, 2020
2 parents 1f001e2 + 76e2823 commit 91bdeb1
Show file tree
Hide file tree
Showing 29 changed files with 334 additions and 115 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
[![Download](https://api.bintray.com/packages/yokeyword/maven/Fragmentation/images/download.svg) ](https://bintray.com/yokeyword/maven/Fragmentation/_latestVersion)
[![Hex.pm](https://img.shields.io/hexpm/l/plug.svg)](https://www.apache.org/licenses/LICENSE-2.0)

# PLEASE NOTE, THIS PROJECT IS NO LONGER BEING MAINTAINED

### [中文版 README.md](https://github.com/YoKeyword/Fragmentation/blob/master/README_CN.md)

# Fragmentation
Expand Down Expand Up @@ -46,15 +48,15 @@ The first demo shows the basic usage of the library. The second one shows the wa
**1、build.gradle**
````gradle
// appcompat-v7 is required
compile 'me.yokeyword:fragmentation:1.3.6'
compile 'me.yokeyword:fragmentation:1.3.8'
// If you don't want to extends SupportActivity/Fragment and would like to customize your own support, just rely on fragmentation-core
// compile 'me.yokeyword:fragmentation-core:1.3.6'
// compile 'me.yokeyword:fragmentation-core:1.3.8'
// To get SwipeBack feature, rely on both fragmentation & fragmentation-swipeback
compile 'me.yokeyword:fragmentation:1.3.6'
compile 'me.yokeyword:fragmentation:1.3.8'
// Swipeback is based on fragmentation. Refer to SwipeBackActivity/Fragment for your Customized SupportActivity/Fragment
compile 'me.yokeyword:fragmentation-swipeback:1.3.6'
compile 'me.yokeyword:fragmentation-swipeback:1.3.8'
// To simplify the communication between Fragments.
compile 'me.yokeyword:eventbus-activity-scope:1.1.0'
Expand Down
10 changes: 6 additions & 4 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
[![Download](https://api.bintray.com/packages/yokeyword/maven/Fragmentation/images/download.svg) ](https://bintray.com/yokeyword/maven/Fragmentation/_latestVersion)
[![Hex.pm](https://img.shields.io/hexpm/l/plug.svg)](https://www.apache.org/licenses/LICENSE-2.0)

# 注意:该项目不再维护

# Fragmentation
A powerful library that manage Fragment for Android!

Expand Down Expand Up @@ -52,15 +54,15 @@ A powerful library that manage Fragment for Android!
**1. 项目下app的build.gradle中依赖:**
````gradle
// appcompat-v7包是必须的
compile 'me.yokeyword:fragmentation:1.3.6'
compile 'me.yokeyword:fragmentation:1.3.8'
// 如果不想继承SupportActivity/Fragment,自己定制Support,可仅依赖:
// compile 'me.yokeyword:fragmentation-core:1.3.6'
// compile 'me.yokeyword:fragmentation-core:1.3.8'
// 如果想使用SwipeBack 滑动边缘退出Fragment/Activity功能,完整的添加规则如下:
compile 'me.yokeyword:fragmentation:1.3.6'
compile 'me.yokeyword:fragmentation:1.3.8'
// swipeback基于fragmentation, 如果是自定制SupportActivity/Fragment,则参照SwipeBackActivity/Fragment实现即可
compile 'me.yokeyword:fragmentation-swipeback:1.3.6'
compile 'me.yokeyword:fragmentation-swipeback:1.3.8'
// Activity作用域的EventBus,更安全,可有效避免after onSavenInstanceState()异常
compile 'me.yokeyword:eventbus-activity-scope:1.1.0'
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ buildscript {

allprojects {
repositories {
jcenter()
google()
jcenter()
}
}

Expand Down
20 changes: 10 additions & 10 deletions demo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,17 @@ android {
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile "com.android.support:appcompat-v7:$rootProject.v4Version"
compile "com.android.support:design:$rootProject.v4Version"
compile "com.android.support:cardview-v7:$rootProject.v4Version"
compile "com.android.support:recyclerview-v7:$rootProject.v4Version"
compile project(':fragmentation')
compile project(':fragmentation_swipeback')
api fileTree(include: ['*.jar'], dir: 'libs')
testApi 'junit:junit:4.12'
api "com.android.support:appcompat-v7:$rootProject.v4Version"
api "com.android.support:design:$rootProject.v4Version"
api "com.android.support:cardview-v7:$rootProject.v4Version"
api "com.android.support:recyclerview-v7:$rootProject.v4Version"
api project(':fragmentation')
api project(':fragmentation_swipeback')
// EventBus
compile project(':eventbus_activity_scope')
compile 'org.greenrobot:eventbus:3.0.0'
api project(':eventbus_activity_scope')
api 'org.greenrobot:eventbus:3.0.0'
// apt 'org.greenrobot:eventbus-annotation-processor:3.0.1'
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package me.yokeyword.sample.demo_wechat.ui.fragment.second;

import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import me.yokeyword.fragmentation.ISupportActivity;
import me.yokeyword.sample.R;

/**
* 使用DialogFragment时,需要重写show(),入Fragmentation的事务队列
*
* Dialog是基于Window (Activity也是Window),普通Fragment的视图一般基于View,这样会导致Dialog永远会浮在最顶层
*
* 可以考虑自定义半透明View的Fragment,从视觉上模拟Dialog
*
* Created by YoKey on 19/6/7.
*/

public class DemoDialogFragment extends DialogFragment {

public static DemoDialogFragment newInstance() {
return new DemoDialogFragment();
}

protected FragmentActivity _mActivity;

@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
_mActivity = (FragmentActivity) activity;
}

/**
* Enqueue the Fragmentation Queue.
*
* 如果是SupportFragment打开,可以不用复写该方法, 放到post()中show亦可
*/
@Override
public void show(final FragmentManager manager, final String tag) {
if (_mActivity instanceof ISupportActivity) {
((ISupportActivity) _mActivity).getSupportDelegate().post(new Runnable() {
@Override
public void run() {
DemoDialogFragment.super.show(manager, tag);
}
});
return;
}

super.show(manager, tag);
}

@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.wechat_fragment_dialog, container, false);
view.findViewById(R.id.btn).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dismiss();
}
});
return view;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ public void onClick(View v) {
}
});

// 启动一个DialogFragment
view.findViewById(R.id.btn_dialog).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
DemoDialogFragment dialogFragment = DemoDialogFragment.newInstance();
dialogFragment.show(getFragmentManager(), getClass().getSimpleName());
}
});

return attachToSwipeBack(view);
}

Expand Down
20 changes: 20 additions & 0 deletions demo/src/main/res/layout/wechat_fragment_dialog.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="16dp">

<EditText
android:layout_width="300dp"
android:layout_height="wrap_content"/>

<Button
android:id="@+id/btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:text="Dismiss"/>

</LinearLayout>
139 changes: 85 additions & 54 deletions demo/src/main/res/layout/wechat_fragment_new_feature.xml
Original file line number Diff line number Diff line change
@@ -1,61 +1,92 @@
<?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">
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<include layout="@layout/toolbar"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="48dp"
android:text="@string/new_tip_start"
android:textColor="@android:color/black"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:layout_marginLeft="16dp"
android:text="extraTransaction()\n.setCustomAnimations(enter,exit...)\n.start()"/>

<Button
android:id="@+id/btn_start"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:text="start()"
android:textAllCaps="false"/>
android:orientation="vertical">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="32dp"
android:text="@string/new_tip_start_dont_hide"
android:textColor="@android:color/black"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:layout_marginLeft="16dp"
android:text="extraTransaction()\n.setCustomAnimations(enter,exit...)\n.startDontHideSelf()"/>
<include layout="@layout/toolbar"/>

<Button
android:id="@+id/btn_start_dont_hide"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:text="startDontHideSelf()"
android:textAllCaps="false"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="48dp"
android:text="@string/new_tip_start"
android:textColor="@android:color/black"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:layout_marginLeft="16dp"
android:text="extraTransaction()\n.setCustomAnimations(enter,exit...)\n.start()"/>

<Button
android:id="@+id/btn_start"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:text="start()"
android:textAllCaps="false"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="32dp"
android:text="@string/new_tip_start_dont_hide"
android:textColor="@android:color/black"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:layout_marginLeft="16dp"
android:text="extraTransaction()\n.setCustomAnimations(enter,exit...)\n.startDontHideSelf()"/>

<Button
android:id="@+id/btn_start_dont_hide"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:text="startDontHideSelf()"
android:textAllCaps="false"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="32dp"
android:text="Show a DialogFragment"
android:textColor="@android:color/black"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:layout_marginLeft="16dp"
android:text="dialogFragment.show(fragmentManager, tag)"/>

<Button
android:id="@+id/btn_dialog"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:text="dialogFragment.show(..)"
android:textAllCaps="false"/>

</LinearLayout>
</LinearLayout>
</ScrollView>
2 changes: 1 addition & 1 deletion eventbus_activity_scope/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ android {
}

dependencies {
provided 'org.greenrobot:eventbus:3.0.0'
compileOnly 'org.greenrobot:eventbus:3.0.0'
}
4 changes: 2 additions & 2 deletions fragmentation/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ android {
}

dependencies {
provided "com.android.support:appcompat-v7:$rootProject.v4Version"
compile project(':fragmentation_core')
compileOnly "com.android.support:appcompat-v7:$rootProject.v4Version"
api project(':fragmentation_core')
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.view.animation.Animation;

Expand All @@ -19,7 +18,7 @@
*/
public class SupportFragment extends Fragment implements ISupportFragment {
final SupportFragmentDelegate mDelegate = new SupportFragmentDelegate(this);
protected FragmentActivity _mActivity;
protected SupportActivity _mActivity;

@Override
public SupportFragmentDelegate getSupportDelegate() {
Expand All @@ -39,7 +38,7 @@ public ExtraTransaction extraTransaction() {
public void onAttach(Activity activity) {
super.onAttach(activity);
mDelegate.onAttach(activity);
_mActivity = mDelegate.getActivity();
_mActivity = (SupportActivity) mDelegate.getActivity();
}

@Override
Expand Down
Loading

0 comments on commit 91bdeb1

Please sign in to comment.