Skip to content

Instantly share code, notes, and snippets.

View janishar's full-sized avatar
🚀
I help developers become better coders

Janishar Ali janishar

🚀
I help developers become better coders
View GitHub Profile
public class Utils {
private static final String TAG = "Utils";
public static List<InfiniteFeedInfo> loadInfiniteFeeds(Context context){
try{
GsonBuilder builder = new GsonBuilder();
Gson gson = builder.create();
JSONArray array = new JSONArray(loadJSONFromAsset(context, "infinite_news.json"));
List<InfiniteFeedInfo> feedList = new ArrayList<>();
@Layout(R.layout.load_more_view)
public class LoadMoreView {
public static final int LOAD_VIEW_SET_COUNT = 6;
private InfinitePlaceHolderView mLoadMoreView;
private List<InfiniteFeedInfo> mFeedList;
public LoadMoreView(InfinitePlaceHolderView loadMoreView, List<InfiniteFeedInfo> feedList) {
this.mLoadMoreView = loadMoreView;
@Layout(R.layout.load_more_item_view)
public class ItemView {
@View(R.id.titleTxt)
private TextView titleTxt;
@View(R.id.captionTxt)
private TextView captionTxt;
@View(R.id.timeTxt)
public class InfiniteFeedInfo {
@SerializedName("title")
@Expose
private String title;
@SerializedName("image_url")
@Expose
private String imageUrl;
[
{
"title" : "Nashville Season 5 Premiere Set at CMT",
"image_url" : "http://ia.media-imdb.com/images/M/MV5BMjA2NTE0NzkyMF5BMl5BanBnXkFtZTgwMjAwMzg5NjE@._V1._SY140_.jpg",
"caption" : "The cancelled ABC country-music drama will make its CMT debut with a two-hour premiere on Thursday, January 5, at 9/8c, the cable network announced Wednesday",
"time" : "1 hours ago"
},
{
"title" : "Sarah Paulson Joins Ryan Murphy's FX Drama Feud as Geraldine Page",
"image_url" : "http://ia.media-imdb.com/images/M/MV5BMTUzMTA3NjM4MV5BMl5BanBnXkFtZTcwNjk1NTAyMg@@._V1._SY140_.jpg",
<?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:layout_height="wrap_content"
android:gravity="center"
android:padding="5dp">
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="4dp"
app:cardElevation="1dp"
android:layout_margin="5dp"
app:cardBackgroundColor="@android:color/holo_blue_dark">
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.mindorks.placeholderview.InfinitePlaceHolderView
android:id="@+id/loadMoreView"
android:layout_width="match_parent"
public class MainActivity extends AppCompatActivity {
private ListView repoListView;
private RepoListAdapter repoListAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
repoListView = (ListView) findViewById(R.id.repoListView);
public class ApiHandler{
public static String GIT_REPO_URL = "https://api.github.com/users/mralexgray/repos";
private static final int API_CHANNEL_ID = 1000;
private static ApiHandler apiHandler;
public static void init(){
apiHandler = new ApiHandler();
}