release 0.1 #30

Manually merged
noemi3 merged 150 commits from release/0.1 into master 2020-01-18 14:59:02 +00:00
3 changed files with 85 additions and 17 deletions
Showing only changes of commit 9f9675f091 - Show all commits

View File

@ -1,16 +1,23 @@
package it.unisannio.ding.ids.wedroid.app.view;
import android.content.Intent;
import android.content.res.ColorStateList;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.ItemTouchHelper;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import java.util.List;
import java.util.Objects;
@ -26,7 +33,8 @@ public class WListsListActivity extends AppCompatActivity {
int barColor;
WListsListViewModel viewModel;
RecyclerView recyclerView;
//SwipeRefreshLayout swipeRefreshLayout;
SharedPreferenceHelper sp;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
@ -34,6 +42,8 @@ public class WListsListActivity extends AppCompatActivity {
setContentView(R.layout.activity_wlists_view);
myToolbar = findViewById(R.id.my_toolbar);
setSupportActionBar(myToolbar);
//swipeRefreshLayout = findViewById(R.id.pullToRefresh);
sp = new SharedPreferenceHelper(this);
Intent i = getIntent();
String boardTitle = i.getStringExtra("barTitle");
@ -44,10 +54,19 @@ public class WListsListActivity extends AppCompatActivity {
myToolbar.setBackgroundColor(barColor);
recyclerView = findViewById(R.id.recyclerviewWList);
initializeUi();
initializeUi(sp.getBoardId());
FloatingActionButton fab = findViewById(R.id.synchronize);
fab.setBackgroundTintList(ColorStateList.valueOf(barColor));
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
viewModel.refresh();
}
});
}
private void initializeUi() {
private void initializeUi(final String idBoard) {
final WListsAdapter adapter = new WListsAdapter(this);
recyclerView.setAdapter(adapter);
recyclerView.setLayoutManager(new LinearLayoutManager(this,
@ -62,5 +81,37 @@ public class WListsListActivity extends AppCompatActivity {
adapter.setWLists(wLists);
}
});
swipeBottomToDelete(idBoard);
/* BUG REPORT: Refresh of page enter in conflict with swipe down for delete list
* swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
viewModel.refresh();
}
});*/
}
private void swipeBottomToDelete(final String idBoard) {
ItemTouchHelper.SimpleCallback simpleCallback = new ItemTouchHelper.SimpleCallback(0,
ItemTouchHelper.DOWN) {
@Override
public boolean onMove(@NonNull RecyclerView recyclerView,
@NonNull RecyclerView.ViewHolder viewHolder,
@NonNull RecyclerView.ViewHolder target) {
return true;
}
@Override
public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) {
int pos = viewHolder.getAdapterPosition();
viewModel.deleteWList(pos, idBoard);
Toast.makeText(getApplicationContext(), "List deleted", Toast.LENGTH_LONG).show();
}
};
new ItemTouchHelper(simpleCallback).attachToRecyclerView(recyclerView);
}
}

View File

@ -35,7 +35,7 @@ import retrofit2.Response;
public class WListsAdapter extends RecyclerView.Adapter<WListsAdapter.WListViewHolder> {
private final LayoutInflater mInflater;
private List<WList> mWLists; // Cached copy of words
private List<WList> mWLists; // Cached copy of lists
private Context mContext;
private ServicesFactory service;
private SharedPreferenceHelper sp;
@ -119,7 +119,8 @@ public class WListsAdapter extends RecyclerView.Adapter<WListsAdapter.WListViewH
private void showInputDialog(final String current) {
LayoutInflater layoutInflater = LayoutInflater.from(mContext);
@SuppressLint("InflateParams") View promptView = layoutInflater.inflate(R.layout.alert_new_card, null);
@SuppressLint("InflateParams") View promptView = layoutInflater.inflate(
R.layout.alert_new_card, null);
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(mContext);
alertDialogBuilder.setView(promptView);
@ -130,9 +131,11 @@ public class WListsAdapter extends RecyclerView.Adapter<WListsAdapter.WListViewH
public void onClick(DialogInterface dialog, int id) {
if(!editText.getText().toString().matches("")) {
service.getSwimlanesService().getAllSwimlanes(sp.getBoardId()).enqueue(new Callback<List<Swimlane>>() {
service.getSwimlanesService().getAllSwimlanes(sp.getBoardId())
.enqueue(new Callback<List<Swimlane>>() {
@Override
public void onResponse(@NotNull Call<List<Swimlane>> call, @NotNull Response<List<Swimlane>> response) {
public void onResponse(@NotNull Call<List<Swimlane>> call,
@NotNull Response<List<Swimlane>> response) {
String idDefaultSwimlane = null;
assert response.body() != null;
for(Swimlane swim: response.body()){
@ -155,7 +158,7 @@ public class WListsAdapter extends RecyclerView.Adapter<WListsAdapter.WListViewH
Toast.makeText(mContext, "card posted" ,
Toast.LENGTH_LONG).show();
else
Toast.makeText(mContext, "card unposted" ,
Toast.makeText(mContext, "card doesn't posted" ,
Toast.LENGTH_LONG).show();
}
@Override

View File

@ -13,21 +13,35 @@
android:background="?attr/colorPrimary"
android:elevation="4dp"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerviewWList"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@android:color/white"
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerviewWList"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@android:color/white"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/my_toolbar"
tools:listitem="@layout/wlist_recyclerview_item" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/synchronize"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/fab_margin"
android:clickable="true"
android:focusable="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/my_toolbar"
tools:listitem="@layout/wlist_recyclerview_item" />
app:srcCompat="@android:drawable/ic_popup_sync" />
</androidx.constraintlayout.widget.ConstraintLayout>