mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-10-30 22:07:57 +01:00 
			
		
		
		
	Display dummy data
This commit is contained in:
		| @@ -0,0 +1,81 @@ | ||||
| package eu.kanade.mangafeed.ui.adapter; | ||||
|  | ||||
| import android.app.Activity; | ||||
| import android.content.Context; | ||||
| import android.view.LayoutInflater; | ||||
| import android.view.View; | ||||
| import android.view.ViewGroup; | ||||
| import android.widget.ArrayAdapter; | ||||
| import android.widget.ImageView; | ||||
| import android.widget.TextView; | ||||
|  | ||||
| import com.bumptech.glide.Glide; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
|  | ||||
| import butterknife.Bind; | ||||
| import butterknife.ButterKnife; | ||||
| import eu.kanade.mangafeed.R; | ||||
| import eu.kanade.mangafeed.data.entities.Manga; | ||||
| import uk.co.ribot.easyadapter.annotations.LayoutId; | ||||
|  | ||||
| /** | ||||
|  * Created by len on 25/09/2015. | ||||
|  */ | ||||
|  | ||||
| @LayoutId(R.layout.item_library) | ||||
| public class LibraryAdapter extends ArrayAdapter<Manga> { | ||||
|  | ||||
|     Context context; | ||||
|     int layoutResourceId; | ||||
|     ArrayList<Manga> data; | ||||
|  | ||||
|     public LibraryAdapter(Context context, int layoutResourceId, ArrayList<Manga> data) { | ||||
|         super(context, layoutResourceId, data); | ||||
|         this.context = context; | ||||
|         this.layoutResourceId = layoutResourceId; | ||||
|         this.data = data; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public View getView(int position, View convertView, ViewGroup parent) { | ||||
|         View row = convertView; | ||||
|         MangoHolder holder = null; | ||||
|  | ||||
|         if(row == null) { | ||||
|             LayoutInflater inflater = ((Activity)context).getLayoutInflater(); | ||||
|             row = inflater.inflate(layoutResourceId, parent, false); | ||||
|  | ||||
|             holder = new MangoHolder(row); | ||||
|             row.setTag(holder); | ||||
|         } | ||||
|         else { | ||||
|             holder = (MangoHolder)row.getTag(); | ||||
|         } | ||||
|  | ||||
|         Manga m = data.get(position); | ||||
|         holder.nameText.setText(m.title); | ||||
|         Glide.with(getContext()) | ||||
|                 .load(getImageUrl()) | ||||
|                 .centerCrop() | ||||
|                 .into(holder.thumbnail); | ||||
|  | ||||
|         return row; | ||||
|     } | ||||
|  | ||||
|     private String getImageUrl() { | ||||
|         return "http://img1.wikia.nocookie.net/__cb20090524204255/starwars/images/thumb/1/1a/R2d2.jpg/400px-R2d2.jpg"; | ||||
|     } | ||||
|  | ||||
|     static class MangoHolder { | ||||
|         @Bind(R.id.thumbnailImageView) | ||||
|         ImageView thumbnail; | ||||
|  | ||||
|         @Bind(R.id.nameTextView) | ||||
|         TextView nameText; | ||||
|  | ||||
|         public MangoHolder(View view) { | ||||
|             ButterKnife.bind(this, view); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -5,15 +5,22 @@ import android.app.Fragment; | ||||
| import android.view.LayoutInflater; | ||||
| import android.view.View; | ||||
| import android.view.ViewGroup; | ||||
| import android.widget.ArrayAdapter; | ||||
| import android.widget.GridView; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
|  | ||||
| import butterknife.Bind; | ||||
| import butterknife.ButterKnife; | ||||
| import eu.kanade.mangafeed.R; | ||||
| import eu.kanade.mangafeed.data.entities.Manga; | ||||
| import eu.kanade.mangafeed.ui.activity.BaseActivity; | ||||
| import eu.kanade.mangafeed.ui.adapter.LibraryAdapter; | ||||
|  | ||||
| public class LibraryFragment extends Fragment { | ||||
|  | ||||
|     @Bind(R.id.gridView) | ||||
|     GridView grid; | ||||
|  | ||||
|     public static LibraryFragment newInstance() { | ||||
|         LibraryFragment fragment = new LibraryFragment(); | ||||
|         Bundle args = new Bundle(); | ||||
| @@ -21,35 +28,26 @@ public class LibraryFragment extends Fragment { | ||||
|         return fragment; | ||||
|     } | ||||
|  | ||||
|     public LibraryFragment() { | ||||
|         // Required empty public constructor | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void onCreate(Bundle savedInstanceState) { | ||||
|         super.onCreate(savedInstanceState); | ||||
|         ((BaseActivity) getActivity()).getSupportActionBar().setTitle(R.string.library_title); | ||||
|  | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public View onCreateView(LayoutInflater inflater, ViewGroup container, | ||||
|                              Bundle savedInstanceState) { | ||||
|         // Inflate the layout for this fragment | ||||
|  | ||||
|         View view = inflater.inflate(R.layout.fragment_library, container, false); | ||||
|         ((BaseActivity) getActivity()).getSupportActionBar().setTitle(R.string.library_title); | ||||
|  | ||||
|         ButterKnife.bind(this, view); | ||||
|  | ||||
|         ArrayList<Manga> mangas = new ArrayList<>(); | ||||
|         mangas.add(new Manga("One Piece")); | ||||
|         mangas.add(new Manga("Berserk")); | ||||
|         mangas.add(new Manga("Fate/stay night: Unlimited Blade Works")); | ||||
|  | ||||
|         LibraryAdapter adapter = new LibraryAdapter(getActivity(), | ||||
|                 R.layout.item_library, mangas); | ||||
|  | ||||
|         grid.setAdapter(adapter); | ||||
|  | ||||
|         return view; | ||||
|     } | ||||
|  | ||||
|  | ||||
|     public class LocalManga { | ||||
|         public String name; | ||||
|         public String url; | ||||
|  | ||||
|         public LocalManga(String name, String url) { | ||||
|             this.name = name; | ||||
|             this.url = url; | ||||
|         } | ||||
|     } | ||||
|  | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user