forked from YoKeyword/Fragmentation
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from YoKeyword/master
Master
- Loading branch information
Showing
29 changed files
with
334 additions
and
115 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
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
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 |
---|---|---|
|
@@ -13,8 +13,8 @@ buildscript { | |
|
||
allprojects { | ||
repositories { | ||
jcenter() | ||
google() | ||
jcenter() | ||
} | ||
} | ||
|
||
|
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
73 changes: 73 additions & 0 deletions
73
.../src/main/java/me/yokeyword/sample/demo_wechat/ui/fragment/second/DemoDialogFragment.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,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; | ||
} | ||
} |
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
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,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
139
demo/src/main/res/layout/wechat_fragment_new_feature.xml
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 |
---|---|---|
@@ -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> |
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
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
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
Oops, something went wrong.