|
|
|
@ -22,6 +22,7 @@ import android.content.Context;
|
|
|
|
|
import android.content.Intent;
|
|
|
|
|
import android.graphics.Typeface;
|
|
|
|
|
import android.os.Bundle;
|
|
|
|
|
import android.support.annotation.NonNull;
|
|
|
|
|
import android.support.design.widget.FloatingActionButton;
|
|
|
|
|
import android.support.v7.app.AppCompatActivity;
|
|
|
|
|
import android.support.v7.widget.Toolbar;
|
|
|
|
@ -50,7 +51,7 @@ import fr.mobdev.goblim.R;
|
|
|
|
|
*/
|
|
|
|
|
public class HistoryActivity extends AppCompatActivity {
|
|
|
|
|
|
|
|
|
|
private List<Img> images;
|
|
|
|
|
private List<Long> imagesIdx;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
@ -78,9 +79,9 @@ public class HistoryActivity extends AppCompatActivity {
|
|
|
|
|
@Override
|
|
|
|
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
|
|
|
Intent linkIntent = new Intent(HistoryActivity.this,LinkActivity.class);
|
|
|
|
|
if(position < images.size()) {
|
|
|
|
|
Img image = images.get(position);
|
|
|
|
|
linkIntent.putExtra("imageId", image.getId());
|
|
|
|
|
if(position < imagesIdx.size()) {
|
|
|
|
|
Long img = imagesIdx.get(position);
|
|
|
|
|
linkIntent.putExtra("imageId", img);
|
|
|
|
|
startActivity(linkIntent);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -99,7 +100,12 @@ public class HistoryActivity extends AppCompatActivity {
|
|
|
|
|
{
|
|
|
|
|
ListView historyList = (ListView) findViewById(R.id.history_list);
|
|
|
|
|
|
|
|
|
|
images = Database.getInstance(getApplicationContext()).getHistory();
|
|
|
|
|
List<Img> images = Database.getInstance(getApplicationContext()).getHistory();
|
|
|
|
|
if(imagesIdx == null)
|
|
|
|
|
imagesIdx = new ArrayList<>();
|
|
|
|
|
imagesIdx.clear();
|
|
|
|
|
for(Img img : images)
|
|
|
|
|
imagesIdx.add(img.getId());
|
|
|
|
|
HistoryAdapter adapter = new HistoryAdapter(this,R.layout.history_item,R.id.url_history_item,images);
|
|
|
|
|
historyList.setAdapter(adapter);
|
|
|
|
|
}
|
|
|
|
@ -112,15 +118,16 @@ public class HistoryActivity extends AppCompatActivity {
|
|
|
|
|
private LayoutInflater mInflater;
|
|
|
|
|
int resource;
|
|
|
|
|
|
|
|
|
|
public HistoryAdapter(Context context, int resource, int textViewResourceId, List<Img> objects) {
|
|
|
|
|
HistoryAdapter(Context context, int resource, int textViewResourceId, List<Img> objects) {
|
|
|
|
|
super(context, resource, textViewResourceId, objects);
|
|
|
|
|
images = new ArrayList<>(objects);
|
|
|
|
|
this.resource = resource;
|
|
|
|
|
mInflater = LayoutInflater.from(context);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@NonNull
|
|
|
|
|
@Override
|
|
|
|
|
public View getView(int position, View convertView, ViewGroup parent)
|
|
|
|
|
public View getView(int position, View convertView, @NonNull ViewGroup parent)
|
|
|
|
|
{
|
|
|
|
|
Img image = images.get(position);
|
|
|
|
|
//reuse view or create a new one?
|
|
|
|
|