Update UI list view
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Umberto Furno 2020-01-02 20:03:26 +01:00
parent 45fe2381ad
commit 844a3710b4
7 changed files with 104 additions and 59 deletions

View File

@ -55,6 +55,8 @@ dependencies {
// UI
implementation "com.google.android.material:material:$rootProject.materialVersion"
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
//Card view
implementation 'androidx.cardview:cardview:1.0.0'
// TESTING

View File

@ -11,4 +11,5 @@ class MainActivity : AppCompatActivity() {
setContentView(R.layout.activity_main)
val service : BoardService? = null
}
}

View File

@ -30,7 +30,8 @@ import retrofit2.Response;
public class BoardViewActivity extends AppCompatActivity {
String idBoard, username;
String idBoard, username, boardTitle;
int boardColor;
TextView description, members, permission, creationDate, lastModificationDate;
View divider1, divider2, divider3;
ListView listView;
@ -65,11 +66,14 @@ public class BoardViewActivity extends AppCompatActivity {
initializeUI(idBoard);
getListsButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent i = new Intent(getApplicationContext(), WListsListActivity.class);
i.putExtra("idBoard", idBoard);
i.putExtra("barTitle", boardTitle);
i.putExtra("barColor", boardColor);
startActivity(i);
}
});
@ -86,9 +90,13 @@ public class BoardViewActivity extends AppCompatActivity {
myToolbar.setBackgroundColor(Color.parseColor(encodeColor(
board.getBackgroundColor().toString())));
boardTitle = board.getTitle();
boardColor= Color.parseColor(encodeColor(
board.getBackgroundColor().toString()));
Drawable background = getListsButton.getBackground();
background.setTint(Color.parseColor(encodeColor(
board.getBackgroundColor().toString())));
background.setTint(boardColor);
getListsButton.setBackgroundDrawable(background);
description.setText(board.getDescription());
@ -100,12 +108,10 @@ public class BoardViewActivity extends AppCompatActivity {
creationDate.append("\n" + board.getCreatedAt());
lastModificationDate.append("\n" + board.getModifiedAt());
divider1.setBackgroundColor(Color.parseColor(encodeColor(
board.getBackgroundColor().toString())));
divider2.setBackgroundColor(Color.parseColor(encodeColor(
board.getBackgroundColor().toString())));
divider3.setBackgroundColor(Color.parseColor(encodeColor(
board.getBackgroundColor().toString())));
divider1.setBackgroundColor(boardColor);
divider2.setBackgroundColor(boardColor);
divider3.setBackgroundColor(boardColor);
ArrayList<String> labelsTitle = new ArrayList<>();
for (int i=0; i<board.getLabels().size(); i++){

View File

@ -1,15 +1,18 @@
package it.unisannio.ding.ids.wedroid.app.view;
import android.content.Intent;
import android.os.Bundle;
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.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import java.util.List;
import java.util.Objects;
import it.unisannio.ding.ids.wedroid.app.R;
import it.unisannio.ding.ids.wedroid.app.data.entity.WList;
@ -20,23 +23,32 @@ import it.unisannio.ding.ids.wedroid.app.viewModel.WListsListViewModel;
public class WListsListActivity extends AppCompatActivity {
private WListsListViewModel viewModel;
Toolbar myToolbar;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_wlists_view);
myToolbar = findViewById(R.id.my_toolbar);
setSupportActionBar(myToolbar);
Intent i = getIntent();
String boardTitle = i.getStringExtra("barTitle");
Objects.requireNonNull(getSupportActionBar()).setTitle(boardTitle);
int barColor = i.getIntExtra("barColor", 0);
myToolbar.setBackgroundColor(barColor);
PreferenceReader reader =new SharedPreferenceHelper(this);
RecyclerView recyclerView = findViewById(R.id.recyclerviewWList);
final WListsAdapter adapter = new WListsAdapter(this);
recyclerView.setAdapter(adapter);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.setLayoutManager(new LinearLayoutManager(this,
LinearLayoutManager.HORIZONTAL, false));
//linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
//recyclerView.setHasFixedSize(true);
viewModel = new ViewModelProvider(this).get(WListsListViewModel.class);
WListsListViewModel viewModel = new ViewModelProvider(this).get(WListsListViewModel.class);
viewModel.getAllWLists().observe(this, new Observer<List<WList>>() {
@Override

View File

@ -1,30 +1,47 @@
package it.unisannio.ding.ids.wedroid.app.view.adapter;
import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
import java.util.List;
import it.unisannio.ding.ids.wedroid.app.R;
import it.unisannio.ding.ids.wedroid.app.data.entity.WList;
import it.unisannio.ding.ids.wedroid.app.util.ServicesFactory;
import it.unisannio.ding.ids.wedroid.app.util.SharedPreferenceHelper;
import it.unisannio.ding.ids.wedroid.wrapper.entity.Card;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class WListsAdapter extends RecyclerView.Adapter<WListsAdapter.WListViewHolder> {
private final LayoutInflater mInflater;
private List<WList> mWLists; // Cached copy of words
public WListsAdapter(Context context) { mInflater = LayoutInflater.from(context); }
private Context mContext;
public WListsAdapter(Context context){
mInflater = LayoutInflater.from(context);
mContext=context;
}
class WListViewHolder extends RecyclerView.ViewHolder{
private final TextView wListItemView;
ListView listView;
private WListViewHolder(View itemView){
super(itemView);
wListItemView= itemView.findViewById(R.id.wListTitle);
listView = itemView.findViewById(R.id.listViewCard);
}
}
@ -35,11 +52,33 @@ public class WListsAdapter extends RecyclerView.Adapter<WListsAdapter.WListViewH
return new WListViewHolder(itemView);
}
@SuppressLint("SetTextI18n")
@Override
public void onBindViewHolder(@NonNull WListViewHolder holder, int position) {
public void onBindViewHolder(@NonNull final WListViewHolder holder, int position) {
if (mWLists != null) {
WList current = mWLists.get(position);
final WList current = mWLists.get(position);
final List<String> cardTitle = new ArrayList<>();
SharedPreferenceHelper sp = new SharedPreferenceHelper(mContext);
ServicesFactory service = new ServicesFactory(sp);
service.getCardService().getAllCards(sp.getBoardId(), current.getId()).enqueue(
new Callback<List<Card>>() {
@Override
public void onResponse(Call<List<Card>> call, Response<List<Card>> response) {
for(int i=0; i<response.body().size(); i++){
cardTitle.add(response.body().get(i).getTitle());
}
ArrayAdapter<String> adapter = new ArrayAdapter<>(mContext,
android.R.layout.simple_list_item_1, cardTitle);
holder.listView.setAdapter(adapter);
holder.wListItemView.setText(current.getTitle());
}
@Override
public void onFailure(Call<List<Card>> call, Throwable t) {
}
});
/*position of the old content holder**/
} else {
// Covers the case of data not being ready yet.
holder.wListItemView.setText("No wList");
@ -57,43 +96,4 @@ public class WListsAdapter extends RecyclerView.Adapter<WListsAdapter.WListViewH
mWLists = wList;
notifyDataSetChanged();
}
}
/** Vecchia versione
private List<WList> wLists;
private Context context;
public WListsAdapter(Context context, List<WList> wLists){
this.wLists = wLists;
this.context = context;
}
public class WListViewHolder extends RecyclerView.ViewHolder {
private TextView title;
public WListViewHolder(View itemView) {
super(itemView);
title = (TextView) itemView.findViewById(R.id.zWListTitle);
}
}
@NonNull
@Override
public WListViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.z_wlist_recycle_item, parent, false);
return new WListViewHolder(itemView);
}
@Override
public void onBindViewHolder(@NonNull WListViewHolder holder, int position) {
WList wList = wLists.get(position);
holder.title.setText(wList.getTitle());
}
@Override
public int getItemCount() {
return 0;
}
**/

View File

@ -6,15 +6,28 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.appcompat.widget.Toolbar
android:id="@id/my_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
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"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintTop_toBottomOf="@+id/my_toolbar"
tools:listitem="@layout/wlist_recyclerview_item" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -1,12 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/wListTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/holo_blue_bright" />
android:layout_height="match_parent"
android:background="#BBDEFB"
android:orientation="horizontal"
android:textAlignment="center"
android:textSize="24sp"
android:textStyle="bold" />
<ListView
android:id="@+id/listViewCard"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>