Skip to content

Commit

Permalink
#262 - Changes in preview screen (#274)
Browse files Browse the repository at this point in the history
  • Loading branch information
eddygta17 authored and Swati4star committed Jul 25, 2018
1 parent c93bd1d commit 295a6a4
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;

import com.eftimoff.viewpagertransformers.DepthPageTransformer;

Expand All @@ -27,7 +28,7 @@ protected void onCreate(Bundle savedInstanceState) {
ArrayList<String> images = intent.getStringArrayListExtra(PREVIEW_IMAGES);

ViewPager viewPager = findViewById(R.id.viewpager);
viewPager.setAdapter(new PreviewAdapter(this, images));
viewPager.setAdapter(new PreviewAdapter(this, images ));
viewPager.setPageTransformer(true, new DepthPageTransformer());

Objects.requireNonNull(getSupportActionBar()).hide();
Expand Down
17 changes: 13 additions & 4 deletions app/src/main/java/swati4star/createpdf/adapter/PreviewAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,23 @@ public class PreviewAdapter extends PagerAdapter {
private final ArrayList<String> mPreviewItems;
private final LayoutInflater mInflater;


public PreviewAdapter(Context context, ArrayList<String> previewItems) {
mContext = context;
mPreviewItems = previewItems;
mInflater = LayoutInflater.from(context);

}

@NonNull
@Override
public Object instantiateItem(@NonNull ViewGroup view, int position) {
View layout = mInflater.inflate(R.layout.pdf_preview_item, view, false);
final TextView textView = layout.findViewById(R.id.textView);

final ImageView imageView = layout.findViewById(R.id.image);

File fileLocation = new File(mPreviewItems.get(position));
textView.setText(
String.format(mContext.getResources().getString(R.string.showing_image),
position + 1, mPreviewItems.size()));

Picasso.with(mContext).load(fileLocation).into(imageView);
view.addView(layout, 0);
return layout;
Expand All @@ -59,4 +59,13 @@ public boolean isViewFromObject(@NonNull View view, @NonNull Object object) {
return view == object;
}

@Override
public CharSequence getPageTitle(int position) {
String pageTitle = String.format(mContext.getResources().getString(R.string.showing_image),
position + 1, mPreviewItems.size());

return pageTitle;
}


}
26 changes: 25 additions & 1 deletion app/src/main/res/layout/activity_preview.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,30 @@
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
android:layout_height="match_parent">

<android.support.v4.view.PagerTabStrip
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:background="@color/colorPrimary"
android:textColor="@color/mb_white"
android:paddingTop="5dp"
android:paddingBottom="5dp"/>

</android.support.v4.view.ViewPager>



<TextView
android:id="@+id/info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="21dp"
android:textColor="@color/black"
android:text="@string/swipe_to_view_next" />

</RelativeLayout>
23 changes: 1 addition & 22 deletions app/src/main/res/layout/pdf_preview_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,12 @@
<ImageView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="400dp"
android:layout_height="500dp"
android:layout_marginTop="20dp"
android:contentDescription="@string/preview_image_to_pdf"
android:background="@color/light_gray"
android:padding="1dp" />

<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="55dp"
android:text="@string/showing_image"
android:textColor="@color/black"
android:textSize="14sp" />

<TextView
android:id="@+id/info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="21dp"
android:textColor="@color/black"
android:text="@string/swipe_to_view_next" />

</RelativeLayout>

0 comments on commit 295a6a4

Please sign in to comment.