Commit 7b22d50a authored by 9731301's avatar 9731301

change recycler manger to staggered

parent 4738181f
...@@ -32,12 +32,11 @@ dependencies { ...@@ -32,12 +32,11 @@ dependencies {
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'androidx.navigation:navigation-fragment:2.3.1' implementation 'androidx.navigation:navigation-fragment:2.3.1'
implementation 'androidx.navigation:navigation-ui:2.3.1' implementation 'androidx.navigation:navigation-ui:2.3.1'
compile 'com.alirezaafkar:sundatepicker:2.0.4' implementation 'com.alirezaafkar:sundatepicker:2.0.4'
def room_version = "2.2.5"
implementation "androidx.room:room-runtime:$room_version" implementation "androidx.room:room-runtime:2.2.5"
annotationProcessor "androidx.room:room-compiler:$room_version" annotationProcessor "androidx.room:room-compiler:2.2.5"
//i added these parts just for voice recorder //i added these parts just for voice recorder
def nav_version = "2.3.1" def nav_version = "2.3.1"
......
...@@ -113,10 +113,6 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -113,10 +113,6 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
startActivity(new Intent(getApplicationContext(), PicsActivity.class)); startActivity(new Intent(getApplicationContext(), PicsActivity.class));
} }
public void onProgramsClicked(View view) {
}
@SuppressLint("NonConstantResourceId") @SuppressLint("NonConstantResourceId")
@Override @Override
public boolean onNavigationItemSelected(MenuItem item) { public boolean onNavigationItemSelected(MenuItem item) {
......
...@@ -9,6 +9,7 @@ import androidx.navigation.NavController; ...@@ -9,6 +9,7 @@ import androidx.navigation.NavController;
import androidx.navigation.Navigation; import androidx.navigation.Navigation;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
...@@ -92,10 +93,10 @@ public class ArchivedNoesListFragment extends Fragment { ...@@ -92,10 +93,10 @@ public class ArchivedNoesListFragment extends Fragment {
// show list with recycler view // show list with recycler view
recyclerView = view.findViewById(R.id.recyclerView); recyclerView = view.findViewById(R.id.recyclerView);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false); StaggeredGridLayoutManager staggeredGridLayoutManager = new StaggeredGridLayoutManager(2, LinearLayoutManager.VERTICAL);
myarchivedAdaptor = new MyArchivedAdaptor(myNotes, myDates); myarchivedAdaptor = new MyArchivedAdaptor(myNotes, myDates);
recyclerView.setAdapter(myarchivedAdaptor); recyclerView.setAdapter(myarchivedAdaptor);
recyclerView.setLayoutManager(linearLayoutManager); recyclerView.setLayoutManager(staggeredGridLayoutManager);
addListeners(); addListeners();
} }
......
...@@ -9,6 +9,8 @@ import androidx.navigation.NavController; ...@@ -9,6 +9,8 @@ import androidx.navigation.NavController;
import androidx.navigation.Navigation; import androidx.navigation.Navigation;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
...@@ -90,12 +92,11 @@ public class AllNotesListFragment extends Fragment { ...@@ -90,12 +92,11 @@ public class AllNotesListFragment extends Fragment {
// show list with recycler view // show list with recycler view
recyclerView = view.findViewById(R.id.recyclerView); recyclerView = view.findViewById(R.id.recyclerView);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false); StaggeredGridLayoutManager staggeredGridLayoutManager = new StaggeredGridLayoutManager(2, LinearLayoutManager.VERTICAL);
myAdaptor = new MyAllNotesAdaptor(myNotes); myAdaptor = new MyAllNotesAdaptor(myNotes);
recyclerView.setLayoutManager(linearLayoutManager); recyclerView.setLayoutManager(staggeredGridLayoutManager);
recyclerView.setAdapter(myAdaptor); recyclerView.setAdapter(myAdaptor);
} }
private void addListeners() { private void addListeners() {
......
...@@ -150,36 +150,6 @@ ...@@ -150,36 +150,6 @@
app:tint="?android:textColor" app:tint="?android:textColor"
android:src="@drawable/ic_noted_pictures" /> android:src="@drawable/ic_noted_pictures" />
</LinearLayout> </LinearLayout>
<LinearLayout
android:id="@+id/programBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:background="@drawable/bg_button"
android:orientation="horizontal">
<TextView
android:id="@+id/program"
android:layout_width="120dp"
android:layout_height="54dp"
android:gravity="center"
android:onClick="onProgramsClicked"
android:text="@string/programs"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.502"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/button6" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/bg_icon"
android:onClick="onProgramsClicked"
android:padding="10dp"
app:tint="?android:textColor"
android:src="@drawable/ic_program" />
</LinearLayout>
</LinearLayout> </LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout <RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="160dp" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
android:background="@drawable/bg_row"> android:background="@drawable/bg_row">
<TextView <TextView
android:id="@+id/titleTv" android:id="@+id/titleTv"
android:layout_width="match_parent" android:layout_width="wrap_content"
android:layout_height="0dp" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_alignParentStart="true"
android:layout_marginLeft="15dp" android:layout_alignParentLeft="true"
android:layout_marginRight="15dp" android:layout_alignParentTop="true"
android:layout_marginTop="12dp" android:layout_alignParentEnd="true"
android:text="title" android:layout_alignParentRight="true"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:padding="5dp" android:padding="5dp"
android:text="title"
android:textColor="?android:textColor" android:textColor="?android:textColor"
android:textSize="20dp" /> android:textSize="20dp" />
<TextView <TextView
android:id="@+id/descriptionTv" android:id="@+id/descriptionTv"
android:layout_marginTop="2dp" android:layout_width="wrap_content"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:layout_height="0dp" android:layout_below="@+id/titleTv"
android:layout_weight="3" android:layout_alignParentStart="true"
android:layout_marginLeft="15dp" android:layout_alignParentLeft="true"
android:layout_marginRight="15dp" android:layout_alignParentEnd="true"
android:lines="3" android:layout_alignParentRight="true"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:layout_marginBottom="16dp"
android:padding="5dp" android:padding="5dp"
android:textColor="?android:textColor"
android:text="body text" android:text="body text"
android:textSize="12dp" /> android:textColor="?android:textColor"
android:textSize="12dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/titleTv" />
</LinearLayout> </RelativeLayout>
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical" android:orientation="vertical"
android:background="?colorButtonNormal" android:background="@drawable/bg_border"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="200dp">
<ImageView <ImageView
android:id="@+id/img_gallery" android:id="@+id/img_gallery"
android:adjustViewBounds="true"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" /> android:layout_height="match_parent"
android:layout_marginStart="10dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="8dp"
android:adjustViewBounds="true"
app:layout_constraintBottom_toTopOf="@+id/tv_gallery"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView <TextView
android:id="@+id/tv_gallery" android:id="@+id/tv_gallery"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:layout_marginStart="10dp"
android:layout_marginLeft="10dp"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="10dp"
android:textColor="?android:textColorPrimary" android:textColor="?android:textColorPrimary"
android:textStyle="bold" android:textStyle="bold"
android:layout_width="wrap_content" app:layout_constraintBottom_toBottomOf="parent"
android:layout_height="wrap_content" /> app:layout_constraintEnd_toEndOf="parent"
</LinearLayout> app:layout_constraintStart_toStartOf="parent" />
\ No newline at end of file </androidx.constraintlayout.widget.ConstraintLayout>
\ 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