Commit 1e1d10e3 authored by 9731301's avatar 9731301

add GalleryAdaptor

parent c8a3009f
......@@ -46,5 +46,4 @@ dependencies {
implementation 'com.google.android.material:material:1.3.0-alpha03'
}
\ No newline at end of file
......@@ -6,6 +6,7 @@ import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.fragment.app.Fragment;
import android.view.LayoutInflater;
......@@ -21,6 +22,7 @@ import com.example.mynotepad.MenuFeatures.AllNotes.AllNotesListFragment;
import com.example.mynotepad.MenuFeatures.AllNotes.DataBase.DateEntity;
import com.example.mynotepad.MenuFeatures.AllNotes.DataBase.Note;
import com.example.mynotepad.MenuFeatures.Calender.CalenderNotesListFragment;
import com.example.mynotepad.MenuFeatures.Utils;
import com.example.mynotepad.R;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
......@@ -37,6 +39,7 @@ public class NoteFragment extends Fragment {
private FloatingActionButton back;
private boolean isAnewNote;
private String type, noteDateType;
private ConstraintLayout noteLayout ;
public NoteFragment() {
}
......@@ -47,6 +50,7 @@ public class NoteFragment extends Fragment {
// Inflate the layout for this fragment
final View v = inflater.inflate(R.layout.fragment_note, container, false);
init(v);
setBg(Utils.sTheme);
isAnewNote = true;
return v;
}
......@@ -57,15 +61,28 @@ public class NoteFragment extends Fragment {
setTitleAndBodyTxt();
}
private void setBg(String sTheme) {
switch (sTheme) {
case "dark":
noteLayout.setBackgroundResource(R.drawable.main_bg_dark);
break;
case "bright":
noteLayout.setBackgroundResource(R.drawable.main_bg_bright);
break;
}
}
private void init(View view) {
back = view.findViewById(R.id.backBtn);
titleTxt = view.findViewById(R.id.myTitle);
bodyTxt = view.findViewById(R.id.textBody);
noteLayout = view.findViewById(R.id.noteLayout);
back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (titleTxt.getText().length() != 0 && bodyTxt.getText().length() != 0)
showAlert();
else getActivity().onBackPressed();
}
});
}
......
package com.example.mynotepad.MenuFeatures.Pics.Gallery;
import android.content.Context;
import android.graphics.BitmapFactory;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.example.mynotepad.R;
import java.util.ArrayList;
public class GalleryAdaptor extends RecyclerView.Adapter<GalleryAdaptor.GalleryViewHolder> {
private ArrayList<MyGalleryPic> picsUrlAndTxt;
private Context context;
public GalleryAdaptor(ArrayList<MyGalleryPic> picsUrlAndTxt, Context context) {
this.picsUrlAndTxt = picsUrlAndTxt;
this.context = context;
}
@NonNull
@Override
public GalleryViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.custom_gallery_item, parent, false);
return new GalleryViewHolder(view);
}
@Override
public void onBindViewHolder(@NonNull GalleryViewHolder holder, int position) {
holder.textView.setText(picsUrlAndTxt.get(position).getText());
System.out.println(picsUrlAndTxt.get(position).getUrl() + " !!!!!");
holder.imageView.setImageBitmap(BitmapFactory.decodeFile(picsUrlAndTxt.get(position).getUrl()));
}
@Override
public int getItemCount() {
return picsUrlAndTxt.size();
}
public class GalleryViewHolder extends RecyclerView.ViewHolder {
TextView textView;
ImageView imageView;
public GalleryViewHolder(@NonNull View itemView) {
super(itemView);
textView = itemView.findViewById(R.id.tv_gallery);
imageView = itemView.findViewById(R.id.img_gallery);
}
}
}
package com.example.mynotepad.MenuFeatures.Pics.Gallery;
public class MyGalleryPic {
private String url;
private String text;
public MyGalleryPic(String url, String text) {
this.url = url;
this.text = text;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
}
package com.example.mynotepad.MenuFeatures.Pics;
package com.example.mynotepad.MenuFeatures.Pics.Gallery;
import android.os.Bundle;
......@@ -10,6 +10,7 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.example.mynotepad.MenuFeatures.Pics.PicsActivity;
import com.example.mynotepad.R;
public class NotedPicsListFragment extends Fragment {
......
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="?colorButtonNormal"/>
<stroke android:color="?colorPrimary"
android:width="10dp"/>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:background="@color/colorPrimaryDark"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/img_gallery"
android:adjustViewBounds="true"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/tv_gallery"
android:layout_gravity="center"
android:textColor="#FFFFFF"
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
\ No newline at end of file
......@@ -3,20 +3,35 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/noteLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/notes_bg"
android:background="@drawable/main_bg_bright"
android:orientation="vertical"
android:visibility="visible">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="32dp"
android:layout_marginLeft="32dp"
android:layout_marginTop="32dp"
android:layout_marginEnd="32dp"
android:layout_marginRight="32dp"
android:layout_marginBottom="32dp"
android:background="@drawable/bg_border"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<EditText
android:id="@+id/myTitle"
android:layout_width="311dp"
android:layout_height="48dp"
android:layout_marginTop="52dp"
android:layout_marginTop="12dp"
android:hint=" title"
android:textColor="@color/black"
android:textColor="?android:textColorPrimary"
android:textSize="24dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
......@@ -24,21 +39,26 @@
<EditText
android:id="@+id/textBody"
android:layout_width="341dp"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_alignParentBottom="true"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:layout_marginBottom="20dp"
android:gravity="top"
android:hint="@string/dots"
android:selectAllOnFocus="false"
android:textColor="#000000"
android:textColor="?android:textColorPrimary"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.492"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/myTitle"
app:layout_constraintVertical_bias="0.353" />
</androidx.constraintlayout.widget.ConstraintLayout>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/backBtn"
......
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MenuFeatures.Pics.NotedPicsListFragment">
tools:context=".MenuFeatures.Pics.Gallery.NotedPicsListFragment">
</FrameLayout>
\ No newline at end of file
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"/>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
......@@ -12,7 +12,7 @@
tools:layout="@layout/fragment_choosing_pics" />
<fragment
android:id="@+id/navigation_picturedNoteList"
android:name="com.example.mynotepad.MenuFeatures.Pics.NotedPicsListFragment"
android:name="com.example.mynotepad.MenuFeatures.Pics.Gallery.NotedPicsListFragment"
android:label="fragment_noted_pics"
tools:layout="@layout/fragment_noted_pics" />
</navigation>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment