Commit 94562cb5 authored by topjohnwu's avatar topjohnwu

Fix UI bugs

parent b064c124
...@@ -60,6 +60,18 @@ public class ModulesFragment extends Fragment implements CallbackHandler.EventLi ...@@ -60,6 +60,18 @@ public class ModulesFragment extends Fragment implements CallbackHandler.EventLi
new Async.LoadModules().exec(); new Async.LoadModules().exec();
}); });
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
mSwipeRefreshLayout.setEnabled(recyclerView.getChildAt(0).getTop() >= 0);
}
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
}
});
if (moduleLoadDone.isTriggered) { if (moduleLoadDone.isTriggered) {
updateUI(); updateUI();
} }
......
...@@ -25,7 +25,6 @@ import butterknife.ButterKnife; ...@@ -25,7 +25,6 @@ import butterknife.ButterKnife;
public class ModulesAdapter extends RecyclerView.Adapter<ModulesAdapter.ViewHolder> { public class ModulesAdapter extends RecyclerView.Adapter<ModulesAdapter.ViewHolder> {
private final List<Module> mList; private final List<Module> mList;
private View mView;
private Context context; private Context context;
public ModulesAdapter(List<Module> list) { public ModulesAdapter(List<Module> list) {
...@@ -34,10 +33,10 @@ public class ModulesAdapter extends RecyclerView.Adapter<ModulesAdapter.ViewHold ...@@ -34,10 +33,10 @@ public class ModulesAdapter extends RecyclerView.Adapter<ModulesAdapter.ViewHold
@Override @Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
mView = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item_module, parent, false); View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item_module, parent, false);
context = parent.getContext(); context = parent.getContext();
ButterKnife.bind(this, mView); ButterKnife.bind(this, view);
return new ViewHolder(mView); return new ViewHolder(view);
} }
@Override @Override
...@@ -70,7 +69,7 @@ public class ModulesAdapter extends RecyclerView.Adapter<ModulesAdapter.ViewHold ...@@ -70,7 +69,7 @@ public class ModulesAdapter extends RecyclerView.Adapter<ModulesAdapter.ViewHold
@Override @Override
protected void onPostExecute(Void v) { protected void onPostExecute(Void v) {
Snackbar.make(mView, R.string.disable_file_removed, Snackbar.LENGTH_SHORT).show(); Snackbar.make(holder.title, R.string.disable_file_removed, Snackbar.LENGTH_SHORT).show();
} }
}.exec(); }.exec();
} else { } else {
...@@ -83,7 +82,7 @@ public class ModulesAdapter extends RecyclerView.Adapter<ModulesAdapter.ViewHold ...@@ -83,7 +82,7 @@ public class ModulesAdapter extends RecyclerView.Adapter<ModulesAdapter.ViewHold
@Override @Override
protected void onPostExecute(Void v) { protected void onPostExecute(Void v) {
Snackbar.make(mView, R.string.disable_file_created, Snackbar.LENGTH_SHORT).show(); Snackbar.make(holder.title, R.string.disable_file_created, Snackbar.LENGTH_SHORT).show();
} }
}.exec(); }.exec();
} }
...@@ -100,7 +99,7 @@ public class ModulesAdapter extends RecyclerView.Adapter<ModulesAdapter.ViewHold ...@@ -100,7 +99,7 @@ public class ModulesAdapter extends RecyclerView.Adapter<ModulesAdapter.ViewHold
@Override @Override
protected void onPostExecute(Void v) { protected void onPostExecute(Void v) {
Snackbar.make(mView, R.string.remove_file_deleted, Snackbar.LENGTH_SHORT).show(); Snackbar.make(holder.title, R.string.remove_file_deleted, Snackbar.LENGTH_SHORT).show();
updateDeleteButton(holder, module); updateDeleteButton(holder, module);
} }
}.exec(); }.exec();
...@@ -114,7 +113,7 @@ public class ModulesAdapter extends RecyclerView.Adapter<ModulesAdapter.ViewHold ...@@ -114,7 +113,7 @@ public class ModulesAdapter extends RecyclerView.Adapter<ModulesAdapter.ViewHold
@Override @Override
protected void onPostExecute(Void v) { protected void onPostExecute(Void v) {
Snackbar.make(mView, R.string.remove_file_created, Snackbar.LENGTH_SHORT).show(); Snackbar.make(holder.title, R.string.remove_file_created, Snackbar.LENGTH_SHORT).show();
updateDeleteButton(holder, module); updateDeleteButton(holder, module);
} }
}.exec(); }.exec();
......
...@@ -42,10 +42,10 @@ ...@@ -42,10 +42,10 @@
<com.github.clans.fab.FloatingActionMenu <com.github.clans.fab.FloatingActionMenu
android:id="@+id/fabmenu" android:id="@+id/fabmenu"
android:layout_width="wrap_content" android:layout_width="500dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="bottom|center_horizontal" android:layout_gravity="bottom|center_horizontal"
android:layout_marginRight="120dp" android:layout_marginEnd="115dp"
android:layout_marginBottom="10dp" android:layout_marginBottom="10dp"
app:layout_behavior=".FABBehavior" app:layout_behavior=".FABBehavior"
fab:menu_fab_size="normal" fab:menu_fab_size="normal"
...@@ -74,5 +74,4 @@ ...@@ -74,5 +74,4 @@
</android.support.design.widget.CoordinatorLayout> </android.support.design.widget.CoordinatorLayout>
</android.support.v4.widget.SwipeRefreshLayout> </android.support.v4.widget.SwipeRefreshLayout>
\ No newline at end of file
...@@ -85,7 +85,7 @@ ...@@ -85,7 +85,7 @@
<string name="no_thanks">No thanks</string> <string name="no_thanks">No thanks</string>
<string name="repo_install_title">Install %1$s</string> <string name="repo_install_title">Install %1$s</string>
<string name="repo_install_msg">Do you want to install %1$s ?</string> <string name="repo_install_msg">Do you want to install %1$s ?</string>
<string name="download_install">Download and install</string> <string name="download_install">Download &amp; install</string>
<string name="goto_install">Go to \"Install\" section</string> <string name="goto_install">Go to \"Install\" section</string>
<string name="download_file_error">Error downloading file</string> <string name="download_file_error">Error downloading file</string>
<string name="install_error">Installation error!</string> <string name="install_error">Installation error!</string>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment