Skip to content

Commit

Permalink
Sigs, news, council members done.
Browse files Browse the repository at this point in the history
  • Loading branch information
samarthgupta1011 committed Aug 7, 2017
1 parent 23a2406 commit 719229f
Show file tree
Hide file tree
Showing 24 changed files with 997 additions and 69 deletions.
2 changes: 2 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ dependencies {
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:cardview-v7:25.1.1'
compile 'com.android.support:recyclerview-v7:25.1.1'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.0.2'
compile 'it.sephiroth.android.library.picasso:picasso:2.5.2.4b'
testCompile 'junit:junit:4.12'
}
10 changes: 9 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="app.com.ieeedtu">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_CALENDAR" />
<uses-permission android:name="android.permission.WRITE_CALENDAR" />

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
Expand All @@ -25,7 +29,11 @@
android:name=".SIGDetailActivity"
android:label="@string/title_activity_sigdetail"
android:theme="@style/AppTheme.NoActionBar" />
<activity android:name=".EventDetailActivity"></activity>
<activity android:name=".EventDetailActivity" />

<activity android:name=".CouncilMemberActivity"
android:label="Council"
android:parentActivityName=".MainActivity"></activity>
</application>

</manifest>
91 changes: 91 additions & 0 deletions app/src/main/java/app/com/ieeedtu/CouncilMemberActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
package app.com.ieeedtu;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

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

import app.com.ieeedtu.POJO.CouncilMember;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class CouncilMemberActivity extends AppCompatActivity {

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

rvCouncil = (RecyclerView) findViewById(R.id.rv_council);

Call<List<CouncilMember>> callCouncil = RetroClass.client.getCouncil();
callCouncil.enqueue(new Callback<List<CouncilMember>>() {
@Override
public void onResponse(Call<List<CouncilMember>> call, Response<List<CouncilMember>> response) {
CouncilAdapter adapter = new CouncilAdapter(response.body());
rvCouncil.setAdapter(adapter);
rvCouncil.setLayoutManager(new LinearLayoutManager(CouncilMemberActivity.this));
rvCouncil.setHasFixedSize(true);
}

@Override
public void onFailure(Call<List<CouncilMember>> call, Throwable t) {

}
});

}

class CouncilAdapter extends RecyclerView.Adapter<CouncilAdapter.CouncilHolder>{

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

public CouncilAdapter(List<CouncilMember> list) {
this.list = list;
}

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

@Override
public void onBindViewHolder(CouncilHolder holder, int position) {

String name = list.get(position).getMember().getUser().getFirstName()+" "+list.get(position).getMember().getUser().getLastName();
holder.tvName.setText(name);
holder.tvDes.setText(list.get(position).getDesignation());


}

@Override
public int getItemCount() {
return list.size();
}

public class CouncilHolder extends RecyclerView.ViewHolder {

TextView tvName, tvDes;
ImageView ivImage;

public CouncilHolder(View itemView) {
super(itemView);
tvName = (TextView) itemView.findViewById(R.id.tv_council_member_name);
tvDes = (TextView) itemView.findViewById(R.id.tv_council_member_designation);
ivImage = (ImageView) itemView.findViewById(R.id.iv_council_image);

}
}
}
}
25 changes: 25 additions & 0 deletions app/src/main/java/app/com/ieeedtu/DataInterface.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package app.com.ieeedtu;

import java.util.List;

import app.com.ieeedtu.POJO.CouncilMember;
import app.com.ieeedtu.POJO.NewsInfo;
import app.com.ieeedtu.POJO.SigInfo;
import retrofit2.Call;
import retrofit2.http.GET;

/**
* Created by samarthgupta on 08/08/17.
*/

public interface DataInterface {

@GET("/news/")
Call<List<NewsInfo>> getNews();

@GET("/sigs/")
Call<List<SigInfo>> getSigs();

@GET("/council/")
Call<List<CouncilMember>> getCouncil();
}
3 changes: 2 additions & 1 deletion app/src/main/java/app/com/ieeedtu/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package app.com.ieeedtu;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.NavigationView;
Expand Down Expand Up @@ -36,7 +37,7 @@ public boolean onNavigationItemSelected(@NonNull MenuItem item) {
int id = item.getItemId();

if (id == R.id.nav_council) {
// Handle the camera action
startActivity(new Intent(MainActivity.this,CouncilMemberActivity.class));
} else if (id == R.id.nav_volunteer) {

} else if (id == R.id.nav_organizer) {
Expand Down
102 changes: 99 additions & 3 deletions app/src/main/java/app/com/ieeedtu/NewsFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,34 @@

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;

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

import app.com.ieeedtu.POJO.NewsInfo;
import it.sephiroth.android.library.picasso.Picasso;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;


/**
* A simple {@link Fragment} subclass.
*/
public class NewsFragment extends Fragment {

RecyclerView rvNews;
ProgressBar pbNews;

public NewsFragment() {
// Required empty public constructor
Expand All @@ -22,8 +40,86 @@ public NewsFragment() {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_news, container, false);

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);
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);
}

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




return v;
}

private class NewsAdapter extends RecyclerView.Adapter<NewsAdapter.NewsHolder> {

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

public NewsAdapter(List<NewsInfo> list) {
this.list = list;
}

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

@Override
public void onBindViewHolder(NewsHolder holder, int position) {
holder.tvHeading.setText(list.get(position).getHeading());

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

String im = list.get(position).getImage();
if (im != null && !im.isEmpty()) {
Picasso.with(getActivity()).load(im).into(holder.ivImage);
// Picasso.with(getActivity()).load(R.drawable.eg).into(holder.ivImage);
} else {
holder.ivImage.setVisibility(View.GONE);
}
}

@Override
public int getItemCount() {
return list.size();
}

public class NewsHolder extends RecyclerView.ViewHolder {

TextView tvHeading, tvDate, tvBody;
ImageView ivImage;

public NewsHolder(View itemView) {
super(itemView);
tvHeading = (TextView) itemView.findViewById(R.id.tv_news_heading);
tvDate = (TextView) itemView.findViewById(R.id.tv_news_date);
tvBody = (TextView) itemView.findViewById(R.id.tv_news_body);
ivImage = (ImageView) itemView.findViewById(R.id.iv_news_im);
}
}
}
}
56 changes: 56 additions & 0 deletions app/src/main/java/app/com/ieeedtu/POJO/CouncilMember.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package app.com.ieeedtu.POJO;

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;

/**
* Created by samarthgupta on 08/08/17.
*/

public class CouncilMember {

@SerializedName("id")
@Expose
private Integer id;
@SerializedName("member")
@Expose
private Person member;
@SerializedName("designation")
@Expose
private String designation;
@SerializedName("fbProfileLink")
@Expose
private String fbProfileLink;

public Integer getId() {
return id;
}

public void setId(Integer id) {
this.id = id;
}

public Person getMember() {
return member;
}

public void setMember(Person member) {
this.member = member;
}

public String getDesignation() {
return designation;
}

public void setDesignation(String designation) {
this.designation = designation;
}

public String getFbProfileLink() {
return fbProfileLink;
}

public void setFbProfileLink(String fbProfileLink) {
this.fbProfileLink = fbProfileLink;
}
}
Loading

0 comments on commit 719229f

Please sign in to comment.