Skip to content
This repository has been archived by the owner on Aug 13, 2021. It is now read-only.

Commit

Permalink
Merge pull request #47 from schul-cloud/95-swipe-refresh-for-every-ne…
Browse files Browse the repository at this point in the history
…cessary-activity

add swipe to refresh to every necessary activity
  • Loading branch information
Niklas Kiefer authored Jun 30, 2017
2 parents c7dbee3 + 7d76d26 commit 42a65d3
Show file tree
Hide file tree
Showing 8 changed files with 182 additions and 87 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
Expand Down Expand Up @@ -38,6 +40,9 @@ public class CourseActivity extends BaseActivity implements CourseMvpView {
@BindView(R.id.recycler_view)
RecyclerView mRecyclerView;

@BindView(R.id.swiperefresh)
SwipeRefreshLayout swipeRefresh;

/**
* Return an Intent to start this Activity.
* triggerDataSyncOnCreate allows disabling the background sync service onCreate. Should
Expand Down Expand Up @@ -75,6 +80,21 @@ protected void onCreate(Bundle savedInstanceState) {
if (getIntent().getBooleanExtra(EXTRA_TRIGGER_SYNC_FLAG, true)) {
startService(CourseSyncService.getStartIntent(this));
}

swipeRefresh.setColorSchemeColors(getResources().getColor(R.color.hpiRed), getResources().getColor(R.color.hpiOrange), getResources().getColor(R.color.hpiYellow));

swipeRefresh.setOnRefreshListener(
() -> {
startService(CourseSyncService.getStartIntent(this));

Handler handler = new Handler();
handler.postDelayed(() -> {
mCoursePresenter.loadCourses();

swipeRefresh.setRefreshing(false);
}, 3000);
}
);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.CardView;
import android.support.v7.widget.LinearLayoutManager;
Expand Down Expand Up @@ -85,12 +86,21 @@ protected void onCreate(Bundle savedInstanceState) {
startService(EventSyncService.getStartIntent(this));
}

swipeRefresh.setColorSchemeColors(getResources().getColor(R.color.hpiRed), getResources().getColor(R.color.hpiOrange), getResources().getColor(R.color.hpiYellow));

swipeRefresh.setOnRefreshListener(
() -> {
mDashboardPresenter.showHomeworks();
mDashboardPresenter.showEvents();
startService(CourseSyncService.getStartIntent(this));
startService(HomeworkSyncService.getStartIntent(this));
startService(EventSyncService.getStartIntent(this));

Handler handler = new Handler();
handler.postDelayed(() -> {
mDashboardPresenter.showHomeworks();
mDashboardPresenter.showEvents();

swipeRefresh.setRefreshing(false);
swipeRefresh.setRefreshing(false);
}, 3000);
}
);

Expand Down
25 changes: 22 additions & 3 deletions app/src/main/java/org/schulcloud/mobile/ui/files/FileActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@
import android.content.res.ColorStateList;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.AlertDialog;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import com.github.johnpersano.supertoasts.library.utils.PaletteUtils;

Expand Down Expand Up @@ -67,6 +66,9 @@ public class FileActivity extends BaseActivity implements FileMvpView {
@BindView(R.id.files_upload)
FloatingActionButton fileUploadButton;

@BindView(R.id.swiperefresh)
SwipeRefreshLayout swipeRefresh;

private InternalFilesUtil filesUtil;
private ProgressDialog uploadProgressDialog;
private ProgressDialog downloadProgressDialog;
Expand Down Expand Up @@ -119,6 +121,23 @@ protected void onCreate(Bundle savedInstanceState) {
}

filesUtil = new InternalFilesUtil(this);

swipeRefresh.setColorSchemeColors(getResources().getColor(R.color.hpiRed), getResources().getColor(R.color.hpiOrange), getResources().getColor(R.color.hpiYellow));

swipeRefresh.setOnRefreshListener(
() -> {
startService(FileSyncService.getStartIntent(this));
startService(DirectorySyncService.getStartIntent(this));

Handler handler = new Handler();
handler.postDelayed(() -> {
mFilePresenter.loadFiles();
mFilePresenter.loadDirectories();

swipeRefresh.setRefreshing(false);
}, 3000);
}
);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
Expand Down Expand Up @@ -38,6 +40,8 @@ public class HomeworkActivity extends BaseActivity implements HomeworkMvpView {

@BindView(R.id.recycler_view)
RecyclerView mRecyclerView;
@BindView(R.id.swiperefresh)
SwipeRefreshLayout swipeRefresh;

/**
* Return an Intent to start this Activity.
Expand Down Expand Up @@ -77,6 +81,22 @@ protected void onCreate(Bundle savedInstanceState) {
startService(HomeworkSyncService.getStartIntent(this));
startService(SubmissionSyncService.getStartIntent(this));
}

swipeRefresh.setColorSchemeColors(getResources().getColor(R.color.hpiRed), getResources().getColor(R.color.hpiOrange), getResources().getColor(R.color.hpiYellow));

swipeRefresh.setOnRefreshListener(
() -> {
startService(HomeworkSyncService.getStartIntent(this));
startService(SubmissionSyncService.getStartIntent(this));

Handler handler = new Handler();
handler.postDelayed(() -> {
mHomeworkPresenter.loadHomework();

swipeRefresh.setRefreshing(false);
}, 3000);
}
);
}

@Override
Expand Down
45 changes: 27 additions & 18 deletions app/src/main/res/layouts/courses/layout/activity_course.xml
Original file line number Diff line number Diff line change
@@ -1,26 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/gray"
android:paddingTop="?attr/actionBarSize"
tools:context="org.schulcloud.mobile.ui.main.MainActivity">
android:layout_height="wrap_content"
android:background="@color/gray">

<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/swiperefresh"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:paddingBottom="6dp"
android:paddingTop="6dp"
android:scrollbars="vertical"/>
android:layout_marginTop="70dp">

</RelativeLayout>
<FrameLayout android:id="@+id/overlay_fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:context="org.schulcloud.mobile.ui.main.MainActivity">

<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:paddingBottom="6dp"
android:paddingTop="6dp"
android:scrollbars="vertical" />

</RelativeLayout>

<FrameLayout
android:id="@+id/overlay_fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.v4.widget.SwipeRefreshLayout>
</RelativeLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/swiperefresh"
android:layout_marginTop="70dp"
android:layout_width="match_parent"
android:layout_height="match_parent">

Expand All @@ -25,7 +26,6 @@
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginTop="70dp"
android:paddingBottom="@dimen/bootstrap_alert_paddings"
android:text="Heutige Stunden"
android:textColor="@color/hpiRed"
Expand Down
96 changes: 52 additions & 44 deletions app/src/main/res/layouts/files/layout/activity_files.xml
Original file line number Diff line number Diff line change
@@ -1,55 +1,63 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/gray"
android:paddingTop="?attr/actionBarSize">

<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/swiperefresh"
android:layout_width="match_parent"
android:layout_height="match_parent">

<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@color/gray"
android:paddingTop="?attr/actionBarSize">
<ScrollView
android:layout_width="fill_parent"
android:fillViewport="true"
android:layout_height="fill_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="25dp"
android:orientation="vertical">
android:fillViewport="true">

<android.support.v7.widget.RecyclerView
android:id="@+id/directories_recycler_view"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:nestedScrollingEnabled="false"
android:paddingBottom="6dp"
android:paddingTop="6dp"
android:scrollbars="vertical"/>
android:orientation="vertical"
android:paddingBottom="25dp">

<android.support.v7.widget.RecyclerView
android:id="@+id/directories_recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:nestedScrollingEnabled="false"
android:paddingBottom="6dp"
android:paddingTop="6dp"
android:scrollbars="vertical" />

<android.support.v7.widget.RecyclerView
android:id="@+id/files_recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="6dp"
android:paddingTop="6dp"
android:clipToPadding="false"
android:nestedScrollingEnabled="false"
android:scrollbars="vertical"/>
</LinearLayout>
</ScrollView>

<android.support.design.widget.FloatingActionButton
android:id="@+id/files_upload"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="21dp"
android:layout_marginEnd="15dp"
android:layout_marginRight="15dp"
android:foregroundTint="@android:color/white"
android:src="@android:drawable/ic_menu_upload"
android:tint="@android:color/white"
app:rippleColor="@android:color/white"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/files_recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:nestedScrollingEnabled="false"
android:paddingBottom="6dp"
android:paddingTop="6dp"
android:scrollbars="vertical" />
</LinearLayout>
</ScrollView>

<android.support.design.widget.FloatingActionButton
android:id="@+id/files_upload"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="21dp"
android:layout_marginEnd="15dp"
android:layout_marginRight="15dp"
android:foregroundTint="@android:color/white"
android:src="@android:drawable/ic_menu_upload"
android:tint="@android:color/white"
app:rippleColor="@android:color/white" />
</android.support.v4.widget.SwipeRefreshLayout>
</RelativeLayout>
45 changes: 27 additions & 18 deletions app/src/main/res/layouts/homework/layout/activity_homework.xml
Original file line number Diff line number Diff line change
@@ -1,26 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:background="@color/gray"
android:layout_height="wrap_content">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/gray"
android:paddingTop="?attr/actionBarSize"
tools:context="org.schulcloud.mobile.ui.main.MainActivity">

<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/swiperefresh"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:paddingBottom="6dp"
android:paddingTop="6dp"
android:scrollbars="vertical"/>
android:layout_marginTop="70dp"
android:layout_height="match_parent">

</RelativeLayout>
<FrameLayout android:id="@+id/overlay_fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:context="org.schulcloud.mobile.ui.main.MainActivity">

<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:paddingBottom="6dp"
android:paddingTop="6dp"
android:scrollbars="vertical" />

</RelativeLayout>
</android.support.v4.widget.SwipeRefreshLayout>

<FrameLayout
android:id="@+id/overlay_fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>

0 comments on commit 42a65d3

Please sign in to comment.