Skip to content

Commit

Permalink
done
Browse files Browse the repository at this point in the history
  • Loading branch information
Asilbek199816 committed Jul 3, 2019
1 parent 6a333f2 commit 2239a2a
Show file tree
Hide file tree
Showing 16 changed files with 65 additions and 195 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,6 @@ public class SwipeBackSampleFragment extends SwipeBackFragment {
# 致谢
[ikew0ng/SwipeBackLayout](https://github.com/ikew0ng/SwipeBackLayout)

# BackFragment
# BackFragment
# BackFragment
13 changes: 6 additions & 7 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
compileSdkVersion 28
buildToolsVersion "28.0.3"

defaultConfig {
applicationId "me.yokeyword.swipebackfragment.sample"
minSdkVersion 14
targetSdkVersion 23
minSdkVersion 21
targetSdkVersion 27
versionCode 1
versionName "1.0"
}
Expand All @@ -21,7 +21,6 @@ android {

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.android.support:recyclerview-v7:25.2.0'
compile project(':swipeback')
api 'com.android.support:appcompat-v7:28.0.0'
api project(':swipeback')
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.Toolbar;
import android.widget.Toast;

import me.yokeyword.swipebackfragment.SwipeBackActivity;
Expand All @@ -13,7 +14,8 @@ public class MainActivity extends SwipeBackActivity implements BaseSwipeBackFrag
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
setTitle("activity-");
// 给其下Fragment的默认背景 (默认使用Fragment根布局的background属性,如若没有则使用Theme的windowBackground属性)
setDefaultFragmentBackground(android.R.color.white);

Expand Down Expand Up @@ -47,15 +49,15 @@ public void onBackPressed() {
private void addFragment(Fragment fromFragment, Fragment toFragment) {
getSupportFragmentManager().beginTransaction()
.setCustomAnimations(R.anim.h_fragment_enter, R.anim.h_fragment_exit, R.anim.h_fragment_pop_enter, R.anim.h_fragment_pop_exit)
.add(R.id.fl_container, toFragment, toFragment.getClass().getSimpleName())
.replace(R.id.fl_container, toFragment, toFragment.getClass().getSimpleName())
.hide(fromFragment)
.addToBackStack(toFragment.getClass().getSimpleName())
.commit();
}

private void loadFragment(Fragment toFragment) {
getSupportFragmentManager().beginTransaction()
.add(R.id.fl_container, toFragment, toFragment.getClass().getSimpleName())
.replace(R.id.fl_container, toFragment, toFragment.getClass().getSimpleName())
.addToBackStack(toFragment.getClass().getSimpleName())
.commit();
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ public static FirstSwipeBackFragment newInstance() {
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_swipe_back_first, container, false);

mToolbar = (Toolbar) view.findViewById(R.id.toolbar);
mToolbar.setTitle("SwipeBackActivity的Fragment");
_initToolbar(mToolbar);

view.findViewById(R.id.tv_btn).setOnClickListener(new View.OnClickListener() {
@Override
Expand All @@ -48,5 +45,9 @@ public void onClick(View v) {
return attachToSwipeBack(view);
}


@Override
public void onResume() {
getActivity().setTitle("1-");
super.onResume();
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import android.support.v4.view.GravityCompat;
import android.support.v7.widget.PopupMenu;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
Expand Down Expand Up @@ -36,7 +37,6 @@ public static SecondSwipeBackFragment newInstance() {
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_swipe_back_second, container, false);

initToolbar(view);

view.findViewById(R.id.tv_btn).setOnClickListener(new View.OnClickListener() {
Expand All @@ -51,22 +51,30 @@ public void onClick(View v) {
getSwipeBackLayout().addSwipeListener(new SwipeBackLayout.OnSwipeListener() {
@Override
public void onDragStateChange(int state) {
Log.d("MRX", "s=" + state);
}

@Override
public void onEdgeTouch(int edgeFlag) {
Log.d("MRX", "sf=" + edgeFlag);
}

@Override
public void onDragScrolled(float scrollPercent) {
Log.d("MRX", "sp=" + scrollPercent);
}
});
return attachToSwipeBack(view);
}

@Override
public void onResume() {
getActivity().setTitle("2-");
super.onResume();
}

private void initToolbar(View view) {
mToolbar = (Toolbar) view.findViewById(R.id.toolbar);
_initToolbar(mToolbar);


Button btnSet = (Button) view.findViewById(R.id.btn_set);
btnSet.setOnClickListener(new View.OnClickListener() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,17 @@ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
View view = inflater.inflate(R.layout.fragment_swipe_back_third, container, false);

initToolbar(view);
view.findViewById(R.id.tv_btn).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mAddFragmentListener != null) {
mAddFragmentListener.onAddFragment(ThirdSwipeBackFragment.this, RecyclerSwipeBackFragment.newInstance());
}
}
});

return attachToSwipeBack(view);
}

@Override
public void onResume() {
super.onResume();
getActivity().setTitle("3-");
}

private void initToolbar(View view) {
mToolbar = (Toolbar) view.findViewById(R.id.toolbar);
_initToolbar(mToolbar);

Button btnSet = (Button) view.findViewById(R.id.btn_set);
btnSet.setOnClickListener(new View.OnClickListener() {
Expand Down
10 changes: 8 additions & 2 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:background="@color/colorPrimary"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"/>

<FrameLayout
android:id="@+id/fl_container"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
</LinearLayout>
6 changes: 3 additions & 3 deletions app/src/main/res/layout/fragment_swipe_back_first.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@
android:layout_height="match_parent"
android:orientation="vertical">

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


<TextView
android:id="@+id/tv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="100dp"
android:gravity="center"
android:text="我是SwipeBackActivity\n里的Fragment\n\n"
android:text="Activity"
android:textSize="28sp"/>

<TextView
android:id="@+id/tv_btn"
android:layout_width="wrap_content"
android:text="点击我跳转\n边缘右滑退出"
android:text="aaaasasfasfdasdfa"
android:textSize="28sp"
android:layout_gravity="center_horizontal"
android:gravity="center"
Expand Down
7 changes: 2 additions & 5 deletions app/src/main/res/layout/fragment_swipe_back_recy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@
android:layout_height="match_parent"
android:orientation="vertical">

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

<android.support.v7.widget.RecyclerView
android:id="@+id/recy"
android:layout_width="match_parent"
android:layout_height="match_parent"/>



</LinearLayout>
Loading

0 comments on commit 2239a2a

Please sign in to comment.