Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,48 +1,78 @@
package com.triard.asus.openproject2019.activities;

import android.content.SharedPreferences;
import android.provider.CalendarContract;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.widget.TextView;
import android.widget.Toast;

import com.triard.asus.openproject2019.R;

import com.triard.asus.openproject2019.adapter.ClubScheduleAdapter;
import com.triard.asus.openproject2019.model.Schedule;
import com.triard.asus.openproject2019.interfaces.EventService;

import com.triard.asus.openproject2019.model.Event;
import com.triard.asus.openproject2019.network.ApiClient;


import java.util.ArrayList;
import java.util.Collections;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class ClubsFavoriteSchedule extends AppCompatActivity {
RecyclerView recyclerView;
ClubScheduleAdapter clubScheduleAdapter;
SharedPreferences preference;

private EventService eventService;
private ArrayList<Event> events = new ArrayList<> ( ) ;
private static final String tag = ClubsFavoriteSchedule.class.getName();

private RecyclerView recyclerView;
private ClubScheduleAdapter adapter;
private ArrayList<Schedule> schedulesArrayList;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_club_favorite_schedule);

addData();
recyclerView = findViewById( R.id.recylerview_detail_schedule);
recyclerView.setLayoutManager ( new LinearLayoutManager ( this ) );
preference = this.getSharedPreferences ( "MY_DATA", MODE_PRIVATE );

recyclerView = (RecyclerView) findViewById(R.id.recylerview_detail_schedule);
eventService = ApiClient.getClient ().create(EventService.class);
getEventsByClub();

adapter = new ClubScheduleAdapter(schedulesArrayList);

RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(ClubsFavoriteSchedule.this);
}
// tampil semua jadwal

recyclerView.setLayoutManager(layoutManager);
public void getEventsByClub(){
Call<ArrayList<Event>> clubResponse = eventService.getEventsByClub ();
clubResponse.enqueue( new Callback<ArrayList<Event>>( ) {
@Override
public void onResponse(Call<ArrayList<Event>> call, Response<ArrayList<Event>> response) {
events = response.body ();
Data();
}

recyclerView.setAdapter(adapter);
@Override
public void onFailure(Call<ArrayList<Event>> call, Throwable t) {
Log.e ( tag, t.toString () );
String message = "Failed to get more events club, please check your connection.";
Toast.makeText(ClubsFavoriteSchedule.this, message, Toast.LENGTH_SHORT).show();
}
});
}

void addData(){
schedulesArrayList = new ArrayList<>();
schedulesArrayList.add(new Schedule("2001","friendly","ind vs jpn","12/04/2019","18.59"));
schedulesArrayList.add(new Schedule("2002","friendly","ind vs jpn","12/04/2019","18.59"));
schedulesArrayList.add(new Schedule("2003","friendly","ind vs jpn","12/04/2019","18.59"));
schedulesArrayList.add(new Schedule("2004","friendly","ind vs jpn","12/04/2019","18.59"));
schedulesArrayList.add(new Schedule("2005","friendly","ind vs jpn","12/04/2019","18.59"));
schedulesArrayList.add(new Schedule("2006","friendly","ind vs jpn","12/04/2019","18.59"));
schedulesArrayList.add(new Schedule("2007","friendly","ind vs jpn","12/04/2019","18.59"));
private void Data() {

clubScheduleAdapter = new ClubScheduleAdapter(this,events, this);
recyclerView.setAdapter( clubScheduleAdapter );

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ public class ViewHolder extends RecyclerView.ViewHolder {
public ViewHolder(View itemview) {
super(itemview);

this.mStrIdTeam = itemview.findViewById(R.id.TextViewIdTeam);this.mStrTeam = itemview.findViewById(R.id.TextViewNama);
this.mStrIdTeam = itemview.findViewById(R.id.TextViewIdTeam);
this.mStrTeam = itemview.findViewById(R.id.TextViewNama);
this.mStrIdLiga = itemview.findViewById(R.id.TextViewIdLiga);
this.mStrLeague = itemview.findViewById(R.id.TextViewLegaue);
this.mStrStadium = itemview.findViewById(R.id.TextViewStadium);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,39 +1,47 @@
package com.triard.asus.openproject2019.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.google.gson.internal.bind.DateTypeAdapter;
import com.triard.asus.openproject2019.R;
import com.triard.asus.openproject2019.model.Event;
import com.triard.asus.openproject2019.model.Schedule;

import java.util.ArrayList;
import java.util.Date;

public class ClubScheduleAdapter extends RecyclerView.Adapter<ClubScheduleAdapter.ViewHolder> {

private ArrayList<Schedule> schedules;
Context context;
public ArrayList<Event> schedules;

public ClubScheduleAdapter(ArrayList<Schedule> schedules) {
public ClubScheduleAdapter(Context context, ArrayList<Event> schedules) {
this.schedules = schedules;
this.context = context;
}

@Override
public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int position) {
LayoutInflater layoutInflater = LayoutInflater.from(viewGroup.getContext());
View view = layoutInflater.inflate(R.layout.activity_club_favorite_schedule_list_item, viewGroup, false);
View view = layoutInflater.from(context).inflate(R.layout.activity_club_favorite_schedule_list_item, viewGroup, false);
return new ViewHolder(view);
}

@Override
public void onBindViewHolder(ViewHolder holder, int position) {
holder.txtIdEvent.setText(schedules.get(position).getIdEvent());
holder.txtLeague.setText(schedules.get(position).getLeague());
holder.txtEvent.setText(schedules.get(position).getEvent());
holder.txtDate.setText(schedules.get(position).getDate());
holder.txtTime.setText(schedules.get(position).getTime());
final Event event= schedules.get(position);
holder.txtIdEvent.setText( event.getIdEvent());
holder.txtLeague.setText( event.getStrLeague());
holder.txtEvent.setText( event.getStrEvent());
holder.txtDate.setText ( event.getDateEvent());
holder.txtTime.setText( event.getStrTime());
holder.txtHome.setText( event.getStrHomeTeam());
}

@Override
Expand All @@ -42,15 +50,17 @@ public int getItemCount() {
}

public class ViewHolder extends RecyclerView.ViewHolder {
private TextView txtIdEvent, txtLeague, txtEvent, txtDate, txtTime;
private TextView txtIdEvent, txtLeague, txtEvent, txtTime,txtHome,txtDate;


public ViewHolder(View itemView) {
super(itemView);
txtIdEvent = (TextView) itemView.findViewById(R.id.TextViewIdEvent);

txtLeague = (TextView) itemView.findViewById(R.id.TextViewLeague);
txtEvent = (TextView) itemView.findViewById(R.id.TextViewEvent);
txtDate = (TextView) itemView.findViewById(R.id.TextViewDate);
txtTime = (TextView) itemView.findViewById(R.id.TextViewTime);
txtHome = (TextView) itemView.findViewById(R.id.TextViewHome);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ public class Event {
@SerializedName("strAwayTeam")
private String strAwayTeam;
@SerializedName("dateEvent")
private Date dateEvent;
private String dateEvent;
@SerializedName("strTime")
private String strTime;


public Event(int idEvent, String strEvent, String strLeague, int idHomeTeam, String strHomeTeam, int idAwayTeam, String strAwayTeam, Date dateEvent, String strTime){
this.idEvent = idEvent;
this.strEvent = strEvent;
Expand Down Expand Up @@ -88,14 +89,15 @@ public void setStrAwayTeam(String strAwayTeam) {
this.strAwayTeam = strAwayTeam;
}

public Date getDateEvent() {
public String getDateEvent() {
return dateEvent;
}

public void setDateEvent(Date dateEvent) {
public void setDateEvent(String dateEvent) {
this.dateEvent = dateEvent;
}


public String getStrTime() {
return strTime;
}
Expand Down
107 changes: 90 additions & 17 deletions app/src/main/res/layout/activity_club_favorite_schedule_list_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,40 +13,113 @@
android:layout_margin="5dp"
android:orientation="vertical"
android:padding="5dp">

<TextView
android:id="@+id/TextViewIdEvent"
android:layout_width="match_parent"
android:layout_height="5dp"
android:text="id event"
android:textColor="#0000"
android:textSize="18sp" />
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="2dp"
android:layout_marginLeft="10dp"
android:text="League : "
android:textStyle="bold"
android:textSize="15dp"/>

<TextView
android:id="@+id/TextViewLeague"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:layout_marginBottom="1dp"
android:layout_marginLeft="10dp"
android:text="@string/app_name"
android:textAlignment="center"
android:textSize="15dp"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="league"
android:textSize="18sp" />
android:layout_marginTop="5dp"
android:layout_marginBottom="2dp"
android:layout_marginLeft="10dp"
android:text="Event : "
android:textStyle="bold"
android:textSize="15dp"/>

<TextView
android:id="@+id/TextViewEvent"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="event"
android:textSize="24sp" />
android:layout_marginTop="3dp"
android:layout_marginBottom="1dp"
android:layout_marginLeft="10dp"
android:text="@string/app_name"
android:textAlignment="center"
android:textSize="15dp"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginBottom="2dp"
android:layout_marginLeft="10dp"
android:text="Date : "
android:textStyle="bold"
android:textSize="15dp"/>

<TextView
android:id="@+id/TextViewDate"
android:layout_width="163dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="date"
android:textSize="18sp" />
android:layout_marginTop="3dp"
android:layout_marginBottom="1dp"
android:layout_marginLeft="10dp"
android:text="@string/app_name"
android:textAlignment="center"
android:textSize="15dp"/>



<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginBottom="2dp"
android:layout_marginLeft="10dp"
android:text="Time : "
android:textStyle="bold"
android:textSize="15dp"/>

<TextView
android:id="@+id/TextViewTime"
android:layout_width="163dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:layout_marginBottom="1dp"
android:layout_marginLeft="10dp"
android:text="@string/app_name"
android:textAlignment="center"
android:textSize="15dp"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginBottom="2dp"
android:layout_marginLeft="10dp"
android:text="Home Team : "
android:textStyle="bold"
android:textSize="15dp"/>

<TextView
android:id="@+id/TextViewHome"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="time" />
android:layout_marginTop="3dp"
android:layout_marginBottom="1dp"
android:layout_marginLeft="10dp"
android:text="@string/app_name"
android:textAlignment="center"
android:textSize="15dp"/>

</LinearLayout>

Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values/ids.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item name="recylerview_event_item" type="id" />
</resources>