Skip to content

Commit

Permalink
Merge pull request #3 from IEEEDTU/bugfixes
Browse files Browse the repository at this point in the history
Bugfixes
  • Loading branch information
samarthgupta1011 authored Aug 11, 2017
2 parents 156d2e2 + 80c4ef0 commit 6ff7bb6
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 39 deletions.
61 changes: 35 additions & 26 deletions app/src/main/java/app/com/ieeedtu/EventFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import android.os.Bundle;
import android.provider.CalendarContract;
import android.support.v4.app.Fragment;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
Expand Down Expand Up @@ -33,6 +34,7 @@ public class EventFragment extends Fragment {
RecyclerView rvEvents;
ProgressBar pbEvents;
String date, month, year;
TextView tvNo;

public EventFragment() {
// Required empty public constructor
Expand All @@ -45,18 +47,27 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
View v = inflater.inflate(R.layout.fragment_event, container, false);
rvEvents = (RecyclerView) v.findViewById(R.id.rv_events);
pbEvents = (ProgressBar) v.findViewById(R.id.pb_events);
tvNo = (TextView) v.findViewById(R.id.tv_no_event);

Call<List<EventInfo>> callEve = RetroClass.client.getEvents();
callEve.enqueue(new Callback<List<EventInfo>>() {
@Override
public void onResponse(Call<List<EventInfo>> call, Response<List<EventInfo>> response) {

pbEvents.setVisibility(View.GONE);
Log.i("Info",response.body().get(0).getDescription());
EventAdapter adapter = new EventAdapter(response.body());
rvEvents.setAdapter(adapter);
rvEvents.setLayoutManager(new LinearLayoutManager(getActivity()));
rvEvents.setHasFixedSize(true);
if (response.body() != null && !response.body().isEmpty()) {
Log.i("Info", response.body().get(0).getDescription());
EventAdapter adapter = new EventAdapter(response.body());
rvEvents.setAdapter(adapter);
rvEvents.setLayoutManager(new LinearLayoutManager(getActivity()));
rvEvents.setHasFixedSize(true);
}

else {

tvNo.setVisibility(View.VISIBLE);

}
}

@Override
Expand All @@ -69,7 +80,7 @@ public void onFailure(Call<List<EventInfo>> call, Throwable t) {
return v;
}

class EventAdapter extends RecyclerView.Adapter<EventFragment.EventAdapter.EventHolder>{
class EventAdapter extends RecyclerView.Adapter<EventFragment.EventAdapter.EventHolder> {

List<EventInfo> list = new ArrayList<>();

Expand All @@ -79,19 +90,19 @@ public EventAdapter(List<EventInfo> list) {

@Override
public EventFragment.EventAdapter.EventHolder onCreateViewHolder(ViewGroup parent, int viewType) {
return new EventFragment.EventAdapter.EventHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.layout_event_recycler,parent,false));
return new EventFragment.EventAdapter.EventHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.layout_event_recycler, parent, false));
}

@Override
public void onBindViewHolder(EventFragment.EventAdapter.EventHolder holder, int position) {

String completeDate = list.get(position).getFromDateTime();
date = completeDate.substring(8,10);
month = completeDate.substring(5,7);
year = completeDate.substring(0,4);
date = completeDate.substring(8, 10);
month = completeDate.substring(5, 7);
year = completeDate.substring(0, 4);


switch (month){
switch (month) {
case "01":
holder.tvMonth.setText("Jan");
break;
Expand Down Expand Up @@ -162,29 +173,27 @@ public EventHolder(View itemView) {

@Override
public void onClick(View view) {
if(view==tvRemind){
if (view == tvRemind) {
int pos = getAdapterPosition();
String completeDate = list.get(pos).getFromDateTime();
date = completeDate.substring(8,10);
month = completeDate.substring(5,7);
year = completeDate.substring(0,4);
date = completeDate.substring(8, 10);
month = completeDate.substring(5, 7);
year = completeDate.substring(0, 4);
Calendar begin = Calendar.getInstance();
begin.set(Integer.parseInt(year),Integer.parseInt(month),Integer.parseInt(date));
begin.set(Integer.parseInt(year), Integer.parseInt(month), Integer.parseInt(date));
Intent intent = new Intent(Intent.ACTION_INSERT)
.setData(CalendarContract.Events.CONTENT_URI)
.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, begin.getTimeInMillis()).putExtra(CalendarContract.Events.TITLE,list.get(pos).getName())
.putExtra(CalendarContract.Events.DESCRIPTION,list.get(pos).getDescription()).putExtra(CalendarContract.Events.EVENT_LOCATION, list.get(pos).getLocation());
.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, begin.getTimeInMillis()).putExtra(CalendarContract.Events.TITLE, list.get(pos).getName())
.putExtra(CalendarContract.Events.DESCRIPTION, list.get(pos).getDescription()).putExtra(CalendarContract.Events.EVENT_LOCATION, list.get(pos).getLocation());
getActivity().startActivity(intent);

}

else if(view==tvTopic||view==tvDate||view==tvMonth){
} else if (view == tvTopic || view == tvDate || view == tvMonth) {
int pos = getAdapterPosition();
Intent intent = new Intent(getActivity(),DetailsActivity.class);
intent.putExtra("Date",date).putExtra("Month",month).putExtra("Topic",list.get(pos).getName())
.putExtra("Loc",list.get(pos).getLocation()).putExtra("Desc",list.get(pos).getDescription())
.putExtra("CoordiName",list.get(pos).getCoordinators().get(0).getUser().getFirstName()+" "+list.get(pos).getCoordinators().get(0).getUser().getLastName())
.putExtra("CoordiCon",Long.toString(list.get(pos).getCoordinators().get(0).getMobile()));
Intent intent = new Intent(getActivity(), DetailsActivity.class);
intent.putExtra("Date", date).putExtra("Month", month).putExtra("Topic", list.get(pos).getName())
.putExtra("Loc", list.get(pos).getLocation()).putExtra("Desc", list.get(pos).getDescription())
.putExtra("CoordiName", list.get(pos).getCoordinators().get(0).getUser().getFirstName() + " " + list.get(pos).getCoordinators().get(0).getUser().getLastName())
.putExtra("CoordiCon", Long.toString(list.get(pos).getCoordinators().get(0).getMobile()));
getActivity().startActivity(intent);

}
Expand Down
29 changes: 18 additions & 11 deletions app/src/main/java/app/com/ieeedtu/NewsFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
Expand All @@ -15,7 +16,6 @@
import android.widget.Toast;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

import app.com.ieeedtu.POJO.NewsInfo;
Expand All @@ -32,6 +32,7 @@ public class NewsFragment extends Fragment {
RecyclerView rvNews;
ProgressBar pbNews;

TextView tvNo;
public NewsFragment() {
// Required empty public constructor
}
Expand All @@ -44,32 +45,38 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
View v = inflater.inflate(R.layout.fragment_news, container, false);
pbNews = (ProgressBar) v.findViewById(R.id.pb_news);
rvNews = (RecyclerView) v.findViewById(R.id.rv_news);
tvNo = (TextView) v.findViewById(R.id.tv_no_news);
pbNews.setVisibility(View.VISIBLE);

Call<List<NewsInfo>> newsCall = RetroClass.client.getNews();
newsCall.enqueue(new Callback<List<NewsInfo>>() {
@Override
public void onResponse(Call<List<NewsInfo>> call, Response<List<NewsInfo>> response) {
NewsAdapter adapter = new NewsAdapter(response.body());
Log.i("Resp","True");

pbNews.setVisibility(View.GONE);
rvNews.setAdapter(adapter);
RecyclerView.LayoutManager manager = new LinearLayoutManager(getActivity());
rvNews.setLayoutManager(manager);
rvNews.setHasFixedSize(true);
if (response.body() != null && !response.body().isEmpty()) {
NewsAdapter adapter = new NewsAdapter(response.body());
Log.i("Resp", "True");
rvNews.setAdapter(adapter);
RecyclerView.LayoutManager manager = new LinearLayoutManager(getActivity());
rvNews.setLayoutManager(manager);
rvNews.setHasFixedSize(true);
}

else {
tvNo.setVisibility(View.VISIBLE);
}
}

@Override
public void onFailure(Call<List<NewsInfo>> call, Throwable t) {
Log.i("Resp","False"+t.toString());
Log.i("Resp", "False" + t.toString());
pbNews.setVisibility(View.GONE);
Toast.makeText(getActivity(), "Network error", Toast.LENGTH_SHORT).show();
}
});




return v;
}

Expand All @@ -90,7 +97,7 @@ public NewsHolder onCreateViewHolder(ViewGroup parent, int viewType) {
public void onBindViewHolder(NewsHolder holder, int position) {
holder.tvHeading.setText(list.get(position).getHeading());

String date = list.get(position).getPublishedOn().substring(0,10);
String date = list.get(position).getPublishedOn().substring(0, 10);
holder.tvDate.setText(date);
holder.tvBody.setText(list.get(position).getBody());

Expand Down
13 changes: 11 additions & 2 deletions app/src/main/java/app/com/ieeedtu/SIGFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import android.os.Bundle;
import android.provider.CalendarContract;
import android.support.v4.app.Fragment;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
Expand Down Expand Up @@ -34,6 +35,7 @@ public class SIGFragment extends Fragment {
ProgressBar pbSig;
String year, month, date;

TextView tvNo;
public SIGFragment() {
// Required empty public constructor
}
Expand All @@ -46,17 +48,24 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
View v = inflater.inflate(R.layout.fragment_sig, container, false);
rvSigs = (RecyclerView) v.findViewById(R.id.rv_sig);
pbSig = (ProgressBar) v.findViewById(R.id.pb_sig);
tvNo = (TextView) v.findViewById(R.id.tv_no_sig);
pbSig.setVisibility(View.VISIBLE);
Call<List<SigInfo>> sigCall = RetroClass.client.getSigs();
sigCall.enqueue(new Callback<List<SigInfo>>() {
@Override
public void onResponse(Call<List<SigInfo>> call, Response<List<SigInfo>> response) {

pbSig.setVisibility(View.GONE);
if(response.body()!=null&&!response.body().isEmpty()){
SigsAdapter adapter = new SigsAdapter(response.body());
rvSigs.setAdapter(adapter);
pbSig.setVisibility(View.GONE);
RecyclerView.LayoutManager man = new LinearLayoutManager(getActivity());
rvSigs.setLayoutManager(man);
rvSigs.setHasFixedSize(true);
rvSigs.setHasFixedSize(true);}

else {
tvNo.setVisibility(View.VISIBLE);
}
}

@Override
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/app/com/ieeedtu/SectionPagerAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import android.support.v4.app.FragmentPagerAdapter;

public class SectionPagerAdapter extends FragmentPagerAdapter {
public static int frag = 0;

public SectionPagerAdapter(FragmentManager fm) {
super(fm);
}
Expand Down
12 changes: 12 additions & 0 deletions app/src/main/res/layout/fragment_event.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,17 @@
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"/>

<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="20dp"
android:layout_margin="20dp"
android:id="@+id/tv_no_event"
android:visibility="gone"
android:text="No Recent Events Found"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Large"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:gravity="center"/>

</RelativeLayout>
13 changes: 13 additions & 0 deletions app/src/main/res/layout/fragment_news.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,17 @@
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"/>

<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="20dp"
android:id="@+id/tv_no_news"
android:layout_margin="20dp"
android:visibility="gone"
android:text="No Recent News Found"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Large"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:gravity="center"/>

</RelativeLayout>
13 changes: 13 additions & 0 deletions app/src/main/res/layout/fragment_sig.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,17 @@
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"/>

<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/tv_no_sig"
android:padding="20dp"
android:layout_margin="20dp"
android:visibility="gone"
android:text="No Recent SIG Scheduled"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Large"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:gravity="center"/>

</RelativeLayout>

0 comments on commit 6ff7bb6

Please sign in to comment.