123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- package com.example.meinwald.ui.area;
-
- import android.app.AlertDialog;
- import android.content.Context;
- import android.content.DialogInterface;
- import android.graphics.Rect;
- import android.util.Log;
- import android.view.LayoutInflater;
- import android.view.View;
- import android.view.ViewGroup;
- import android.widget.BaseAdapter;
- import android.widget.ImageView;
- import android.widget.TextView;
-
- import com.example.meinwald.BuildConfig;
- import com.example.meinwald.R;
- import com.example.meinwald.ui.task.OwnTask;
- import com.google.android.material.floatingactionbutton.FloatingActionButton;
-
- import java.util.ArrayList;
- import java.util.List;
-
- import androidx.appcompat.widget.AlertDialogLayout;
- import androidx.appcompat.widget.LinearLayoutCompat;
- import androidx.constraintlayout.widget.ConstraintLayout;
-
- import static java.security.AccessController.getContext;
-
- public class AreaAdapter extends BaseAdapter
- {
- List<OwnArea> areaList;
- LayoutInflater inflater;
- Context context;
-
- public AreaAdapter(Context applicationContext, List<OwnArea> areaList)
- {
- this.areaList = new ArrayList<>();
- this.areaList = areaList;
- this.context = applicationContext;
-
- inflater = LayoutInflater.from(applicationContext);
-
- if (BuildConfig.DEBUG)
- {
- Log.d("AreaAdapter","size: " + areaList.size());
- }
- }
-
- @Override
- public View getView(final int i, View view, final ViewGroup viewGroup) {
-
- view = inflater.inflate(R.layout.area_element, null);
- final ConstraintLayout elementView = view.findViewById(R.id.areaInfoView);
- final ConstraintLayout infovView = view.findViewById(R.id.areaInfoView);
- final TextView title = (TextView) view.findViewById(R.id.areaInfoTitle);
- final TextView notice = (TextView) view.findViewById(R.id.areaInfoNotice);
- final ImageView icon = (ImageView) view.findViewById(R.id.areaIcon);
- context = view.getContext();
-
-
-
- if (BuildConfig.DEBUG)
- {
- Log.d("AreaAdapter",areaList.get(i).toString());
- Log.d("AreaAdapter",areaList.get(i).getTitle());
- Log.d("AreaAdapter",areaList.get(i).getNotice());
- }
-
- title.setText(areaList.get(i).getTitle());
- notice.setText(areaList.get(i).getNotice());
- icon.setImageBitmap(areaList.get(i).getImage());
-
- title.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v)
- {
-
-
- }
- });
-
- notice.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v)
- {
-
-
- }
- });
-
- icon.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v)
- {
-
- final AlertDialog.Builder builder = new AlertDialog.Builder(v.getRootView().getContext());
- final View viewInflated = LayoutInflater.from(v.getRootView().getContext()).inflate(R.layout.image_large, viewGroup, false);
-
- builder.setView(viewInflated);
-
- final ConstraintLayout imageViewLayout = viewInflated.findViewById(R.id.taskLargeImageLayout);
- final ImageView imageView = viewInflated.findViewById(R.id.taskLargeImage);
-
- imageView.setImageBitmap(areaList.get(i).getImage());
-
- builder.setNegativeButton("Zurück", new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- dialog.cancel();
- }
- });
-
- builder.show();
- }
- });
-
- view.setOnLongClickListener(new View.OnLongClickListener() {
- @Override
- public boolean onLongClick(View v) {
- // TODO Auto-generated method stub
- return true;
- }
- });
-
- return view;
- }
-
- @Override
- public int getCount() {
- return areaList.size();
- }
-
- @Override
- public Object getItem(int i) {
- return areaList.get(i);
- }
-
- @Override
- public long getItemId(int i) {
- return i;
- }
- }
|