Added refesh to module overview
This commit is contained in:
BIN
.idea/caches/build_file_checksums.ser
generated
BIN
.idea/caches/build_file_checksums.ser
generated
Binary file not shown.
1
.idea/vcs.xml
generated
1
.idea/vcs.xml
generated
@@ -2,6 +2,5 @@
|
|||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="VcsDirectoryMappings">
|
<component name="VcsDirectoryMappings">
|
||||||
<mapping directory="" vcs="Git" />
|
<mapping directory="" vcs="Git" />
|
||||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
@@ -72,7 +72,6 @@ public class MainActivity extends AppCompatActivity
|
|||||||
|
|
||||||
|
|
||||||
this.getGoogleAuth().connect(() -> {
|
this.getGoogleAuth().connect(() -> {
|
||||||
// getGoogleAuth().setLoginState("seedorf96", "m&gcwBaT@");
|
|
||||||
getGoogleAuth().getLoginState(credentials -> {
|
getGoogleAuth().getLoginState(credentials -> {
|
||||||
if (credentials == null || credentials.getUsername() == null || credentials.getPassword() == null) {
|
if (credentials == null || credentials.getUsername() == null || credentials.getPassword() == null) {
|
||||||
MainActivity.this.getKVV().endUpdate();
|
MainActivity.this.getKVV().endUpdate();
|
||||||
@@ -257,9 +256,7 @@ public class MainActivity extends AppCompatActivity
|
|||||||
@Override
|
@Override
|
||||||
public void onModulesFragmentInteraction(final int itemPosition) {
|
public void onModulesFragmentInteraction(final int itemPosition) {
|
||||||
log.d("Item clicked", itemPosition);
|
log.d("Item clicked", itemPosition);
|
||||||
getKVV().getModuleList(success -> log.d(success.get(itemPosition).title), error -> {
|
getKVV().getModuleList(success -> log.d(success.get(itemPosition).title), error -> log.e(error));
|
||||||
// TODO
|
|
||||||
});
|
|
||||||
|
|
||||||
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
|
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
|
||||||
fragmentTransaction.replace(R.id.fragcontainer, ModDetailFragment.newInstance(itemPosition));
|
fragmentTransaction.replace(R.id.fragcontainer, ModDetailFragment.newInstance(itemPosition));
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import android.content.Context;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.support.v4.widget.SwipeRefreshLayout;
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
@@ -31,6 +32,8 @@ public class ModDetailOverviewFragment extends Fragment {
|
|||||||
// TODO: Rename and change types of parameters
|
// TODO: Rename and change types of parameters
|
||||||
private int mItemPos;
|
private int mItemPos;
|
||||||
private Logger log = new Logger(this);
|
private Logger log = new Logger(this);
|
||||||
|
private ModDetailOverviewAdapter adapter;
|
||||||
|
private SwipeRefreshLayout swipeLayout;
|
||||||
|
|
||||||
|
|
||||||
public ModDetailOverviewFragment() {
|
public ModDetailOverviewFragment() {
|
||||||
@@ -70,40 +73,48 @@ public class ModDetailOverviewFragment extends Fragment {
|
|||||||
log.d("on create");
|
log.d("on create");
|
||||||
View view = inflater.inflate(R.layout.fragment_mod_detail_overview, container, false);
|
View view = inflater.inflate(R.layout.fragment_mod_detail_overview, container, false);
|
||||||
// Set the adapter
|
// Set the adapter
|
||||||
if (view instanceof RecyclerView) {
|
Context context = view.getContext();
|
||||||
Context context = view.getContext();
|
RecyclerView recyclerView = view.findViewById(R.id.list);
|
||||||
RecyclerView recyclerView = (RecyclerView) view;
|
recyclerView.setLayoutManager(new LinearLayoutManager(context));
|
||||||
recyclerView.setLayoutManager(new LinearLayoutManager(context));
|
adapter = new ModDetailOverviewAdapter();
|
||||||
final ModDetailOverviewAdapter adapter = new ModDetailOverviewAdapter();
|
recyclerView.setAdapter(adapter);
|
||||||
recyclerView.setAdapter(adapter);
|
|
||||||
|
|
||||||
|
|
||||||
if (getActivity() != null) {
|
|
||||||
KVV kvv = ((MainActivity) getActivity()).getKVV();
|
|
||||||
kvv.getModuleList((Modules success) -> {
|
|
||||||
log.d(success);
|
|
||||||
Modules.Module module = success.get(mItemPos);
|
|
||||||
adapter.setModule(module);
|
|
||||||
kvv.getModuleAnnouncements(module, module1 -> {
|
|
||||||
log.d("announcements", module.announcements);
|
|
||||||
adapter.setModule();
|
|
||||||
}, error -> log.e(error));
|
|
||||||
kvv.getModuleAssignments(module, module1 -> {
|
|
||||||
log.d("assignments", module.assignments);
|
|
||||||
adapter.setModule();
|
|
||||||
}, error -> log.e(error));
|
|
||||||
kvv.getModuleEvents(module, module1 -> {
|
|
||||||
log.d("events", module.events);
|
|
||||||
adapter.setModule();
|
|
||||||
}, error -> log.e(error));
|
|
||||||
}, error -> log.e(error));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Getting SwipeContainerLayout
|
||||||
|
swipeLayout = view.findViewById(R.id.swipe_container);
|
||||||
|
// Adding Listener
|
||||||
|
swipeLayout.setOnRefreshListener(this::refresh);
|
||||||
|
refresh();
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void refresh() {
|
||||||
|
if (getActivity() != null) {
|
||||||
|
KVV kvv = ((MainActivity) getActivity()).getKVV();
|
||||||
|
kvv.getModuleList((Modules success) -> {
|
||||||
|
log.d(success);
|
||||||
|
Modules.Module module = success.get(mItemPos);
|
||||||
|
log.d("Print c");
|
||||||
|
adapter.setModule(module);
|
||||||
|
kvv.getModuleAnnouncements(module, module1 -> {
|
||||||
|
//log.d("announcements", module.announcements);
|
||||||
|
adapter.setModule();
|
||||||
|
}, error -> log.e(error));
|
||||||
|
kvv.getModuleAssignments(module, module1 -> {
|
||||||
|
//log.d("assignments", module.assignments);
|
||||||
|
adapter.setModule();
|
||||||
|
}, error -> log.e(error));
|
||||||
|
kvv.getModuleEvents(module, module1 -> {
|
||||||
|
//log.d("events", module.events);
|
||||||
|
adapter.setModule();
|
||||||
|
}, error -> log.e(error));
|
||||||
|
kvv.getModuleGradebook(module, module1 -> {
|
||||||
|
log.d("gradebook", module.gradebook);
|
||||||
|
adapter.setModule();
|
||||||
|
}, error -> log.e(error));
|
||||||
|
}, error -> log.e(error));
|
||||||
|
}
|
||||||
|
swipeLayout.setRefreshing(false);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,4 +22,10 @@ public class Gradebook {
|
|||||||
public String getItemName() {
|
public String getItemName() {
|
||||||
return itemName;
|
return itemName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
// TODO
|
||||||
|
return super.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,19 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
|
<android.support.v4.widget.SwipeRefreshLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:id="@+id/list"
|
android:id="@+id/swipe_container"
|
||||||
android:name=".fragments.moddetails.ModDetailOverviewFragment"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent">
|
||||||
android:layout_marginLeft="16dp"
|
<android.support.v7.widget.RecyclerView
|
||||||
android:layout_marginRight="16dp"
|
android:id="@+id/list"
|
||||||
app:layoutManager="android.support.v7.widget.LinearLayoutManager"
|
android:name=".fragments.moddetails.ModDetailOverviewFragment"
|
||||||
tools:context=".fragments.moddetails.ModDetailOverviewFragment"
|
android:layout_width="match_parent"
|
||||||
tools:listitem="@layout/list_all_caption" />
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginLeft="16dp"
|
||||||
|
android:layout_marginRight="16dp"
|
||||||
|
app:layoutManager="android.support.v7.widget.LinearLayoutManager"
|
||||||
|
tools:context=".fragments.moddetails.ModDetailOverviewFragment"
|
||||||
|
tools:listitem="@layout/list_all_caption" />
|
||||||
|
</android.support.v4.widget.SwipeRefreshLayout>
|
||||||
Reference in New Issue
Block a user