diff --git a/app/src/main/java/io/github/wulkanowy/activity/dashboard/DashboardActivity.java b/app/src/main/java/io/github/wulkanowy/activity/dashboard/DashboardActivity.java index a53dcf69..4498f819 100644 --- a/app/src/main/java/io/github/wulkanowy/activity/dashboard/DashboardActivity.java +++ b/app/src/main/java/io/github/wulkanowy/activity/dashboard/DashboardActivity.java @@ -18,7 +18,7 @@ import io.github.wulkanowy.activity.dashboard.marks.MarksFragment; public class DashboardActivity extends AppCompatActivity { - MarksFragment marksFragment = new MarksFragment(); + MarksFragment marksFragment; AttendanceFragment attendanceFragment = new AttendanceFragment(); BoardFragment boardFragment = new BoardFragment(); LessonplanFragment lessonplanFragment = new LessonplanFragment(); @@ -68,6 +68,8 @@ public class DashboardActivity extends AppCompatActivity { super.onCreate(savedInstanceState); setContentView(R.layout.activity_dashboard); + marksFragment = new MarksFragment(); + setTitle(R.string.title_dashboard); BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation); diff --git a/app/src/main/java/io/github/wulkanowy/activity/dashboard/marks/ImageAdapter.java b/app/src/main/java/io/github/wulkanowy/activity/dashboard/marks/ImageAdapter.java new file mode 100644 index 00000000..4319ce15 --- /dev/null +++ b/app/src/main/java/io/github/wulkanowy/activity/dashboard/marks/ImageAdapter.java @@ -0,0 +1,62 @@ +package io.github.wulkanowy.activity.dashboard.marks; + +import android.content.Context; +import android.view.View; +import android.view.ViewGroup; +import android.widget.BaseAdapter; +import android.widget.GridView; +import android.widget.ImageView; + +import io.github.wulkanowy.R; + +public class ImageAdapter extends BaseAdapter { + private Context mContext; + + public ImageAdapter(Context c) { + this.mContext = c; + } + + public int getCount() { + return mThumbIds.length; + } + + public Object getItem(int position) { + return null; + } + + public long getItemId(int position) { + return 0; + } + + // create a new ImageView for each item referenced by the Adapter + public View getView(int position, View convertView, ViewGroup parent) { + ImageView imageView; + if (convertView == null) { + // if it's not recycled, initialize some attributes + imageView = new ImageView(mContext); + imageView.setLayoutParams(new GridView.LayoutParams(85, 85)); + imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); + imageView.setPadding(8, 8, 8, 8); + } else { + imageView = (ImageView) convertView; + } + + imageView.setImageResource(mThumbIds[position]); + return imageView; + } + + // references to our images + private Integer[] mThumbIds = { + R.drawable.sample_2, R.drawable.sample_3, + R.drawable.sample_4, R.drawable.sample_5, + R.drawable.sample_6, R.drawable.sample_7, + R.drawable.sample_0, R.drawable.sample_1, + R.drawable.sample_2, R.drawable.sample_3, + R.drawable.sample_4, R.drawable.sample_5, + R.drawable.sample_6, R.drawable.sample_7, + R.drawable.sample_0, R.drawable.sample_1, + R.drawable.sample_2, R.drawable.sample_3, + R.drawable.sample_4, R.drawable.sample_5, + R.drawable.sample_6, R.drawable.sample_7 + }; +} diff --git a/app/src/main/java/io/github/wulkanowy/activity/dashboard/marks/MarksFragment.java b/app/src/main/java/io/github/wulkanowy/activity/dashboard/marks/MarksFragment.java index 3af34af1..ea2e0926 100644 --- a/app/src/main/java/io/github/wulkanowy/activity/dashboard/marks/MarksFragment.java +++ b/app/src/main/java/io/github/wulkanowy/activity/dashboard/marks/MarksFragment.java @@ -1,16 +1,30 @@ package io.github.wulkanowy.activity.dashboard.marks; +import android.app.Activity; +import android.content.Context; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.AdapterView; +import android.widget.GridView; +import android.widget.Toast; +import android.widget.AdapterView.OnItemClickListener; + import io.github.wulkanowy.R; public class MarksFragment extends Fragment { + Activity mActivity; + @Override + public void onAttach(Context context) { + super.onAttach(context); + mActivity = (Activity) context; + } + public MarksFragment() { } @@ -19,6 +33,18 @@ public class MarksFragment extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + + View view = inflater.inflate(R.layout.fragment_marks, container, false); + + GridView gridview = (GridView) view.findViewById(R.id.gridview); + gridview.setAdapter(new ImageAdapter(mActivity)); + + gridview.setOnItemClickListener(new OnItemClickListener() { + public void onItemClick(AdapterView parent, View v, + int position, long id) { + Toast.makeText(mActivity,"HALLO", Toast.LENGTH_SHORT).show(); + } + }); return inflater.inflate(R.layout.fragment_marks, container, false); } diff --git a/app/src/main/java/io/github/wulkanowy/activity/started/LoadingTask.java b/app/src/main/java/io/github/wulkanowy/activity/started/LoadingTask.java index e6eb602b..bc57ffc0 100644 --- a/app/src/main/java/io/github/wulkanowy/activity/started/LoadingTask.java +++ b/app/src/main/java/io/github/wulkanowy/activity/started/LoadingTask.java @@ -31,7 +31,7 @@ public class LoadingTask extends AsyncTask { /* Intent intent = new Intent(activity,MainActivity.class); activity.startActivity(intent); */ - Intent intent = new Intent(activity,MainActivity.class); + Intent intent = new Intent(activity,DashboardActivity.class); activity.startActivity(intent); } } diff --git a/app/src/main/res/drawable/sample_0.jpg b/app/src/main/res/drawable/sample_0.jpg new file mode 100644 index 00000000..9dd3bce8 Binary files /dev/null and b/app/src/main/res/drawable/sample_0.jpg differ diff --git a/app/src/main/res/drawable/sample_1.jpg b/app/src/main/res/drawable/sample_1.jpg new file mode 100644 index 00000000..46d06e02 Binary files /dev/null and b/app/src/main/res/drawable/sample_1.jpg differ diff --git a/app/src/main/res/drawable/sample_2.jpg b/app/src/main/res/drawable/sample_2.jpg new file mode 100644 index 00000000..c23dd637 Binary files /dev/null and b/app/src/main/res/drawable/sample_2.jpg differ diff --git a/app/src/main/res/drawable/sample_3.jpg b/app/src/main/res/drawable/sample_3.jpg new file mode 100644 index 00000000..0f0d5b53 Binary files /dev/null and b/app/src/main/res/drawable/sample_3.jpg differ diff --git a/app/src/main/res/drawable/sample_4.jpg b/app/src/main/res/drawable/sample_4.jpg new file mode 100644 index 00000000..d28ce6f3 Binary files /dev/null and b/app/src/main/res/drawable/sample_4.jpg differ diff --git a/app/src/main/res/drawable/sample_5.jpg b/app/src/main/res/drawable/sample_5.jpg new file mode 100644 index 00000000..2348c7d3 Binary files /dev/null and b/app/src/main/res/drawable/sample_5.jpg differ diff --git a/app/src/main/res/drawable/sample_6.jpg b/app/src/main/res/drawable/sample_6.jpg new file mode 100644 index 00000000..a35fc0ce Binary files /dev/null and b/app/src/main/res/drawable/sample_6.jpg differ diff --git a/app/src/main/res/drawable/sample_7.jpg b/app/src/main/res/drawable/sample_7.jpg new file mode 100644 index 00000000..96a4879e Binary files /dev/null and b/app/src/main/res/drawable/sample_7.jpg differ diff --git a/app/src/main/res/layout/fragment_marks.xml b/app/src/main/res/layout/fragment_marks.xml index bc582405..3db405dc 100644 --- a/app/src/main/res/layout/fragment_marks.xml +++ b/app/src/main/res/layout/fragment_marks.xml @@ -1,17 +1,18 @@ +xmlns:tools="http://schemas.android.com/tools" +android:layout_width="match_parent" +android:layout_height="match_parent" +tools:context="io.github.wulkanowy.activity.dashboard.marks.MarksFragment"> - - - - + android:columnWidth="90dp" + android:numColumns="auto_fit" + android:verticalSpacing="10dp" + android:horizontalSpacing="10dp" + android:gravity="center" + />