-
Notifications
You must be signed in to change notification settings - Fork 816
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
78c5954
commit d55314c
Showing
15 changed files
with
218 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
app/src/main/java/swati4star/createpdf/activity/PreviewActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package swati4star.createpdf.activity; | ||
|
||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.support.v4.view.ViewPager; | ||
import android.support.v7.app.AppCompatActivity; | ||
|
||
import java.util.ArrayList; | ||
|
||
import swati4star.createpdf.R; | ||
import swati4star.createpdf.adapter.PreviewAdapter; | ||
|
||
import static swati4star.createpdf.util.Constants.PREVIEW_IMAGES; | ||
|
||
public class PreviewActivity extends AppCompatActivity { | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_preview); | ||
|
||
Intent intent = getIntent(); | ||
ArrayList<String> images = intent.getStringArrayListExtra(PREVIEW_IMAGES); | ||
|
||
ViewPager viewPager = findViewById(R.id.viewpager); | ||
viewPager.setAdapter(new PreviewAdapter(this, images)); | ||
|
||
getSupportActionBar().hide(); | ||
} | ||
|
||
} |
62 changes: 62 additions & 0 deletions
62
app/src/main/java/swati4star/createpdf/adapter/PreviewAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package swati4star.createpdf.adapter; | ||
|
||
import android.content.Context; | ||
import android.support.annotation.NonNull; | ||
import android.support.v4.view.PagerAdapter; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.ImageView; | ||
import android.widget.TextView; | ||
|
||
import com.squareup.picasso.Picasso; | ||
|
||
import java.io.File; | ||
import java.util.ArrayList; | ||
|
||
import swati4star.createpdf.R; | ||
|
||
public class PreviewAdapter extends PagerAdapter { | ||
|
||
private Context mContext; | ||
private ArrayList<String> mPreviewItems; | ||
private 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; | ||
} | ||
|
||
@Override | ||
public void destroyItem(@NonNull ViewGroup collection, int position, @NonNull Object view) { | ||
collection.removeView((View) view); | ||
} | ||
|
||
@Override | ||
public int getCount() { | ||
return mPreviewItems.size(); | ||
} | ||
|
||
@Override | ||
public boolean isViewFromObject(@NonNull View view, @NonNull Object object) { | ||
return view == object; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
app/src/main/res/drawable/ic_play_circle_outline_black_24dp.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:viewportWidth="24.0" | ||
android:viewportHeight="24.0"> | ||
<path | ||
android:fillColor="#FF000000" | ||
android:pathData="M10,16.5l6,-4.5 -6,-4.5v9zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8z"/> | ||
</vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<RelativeLayout 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" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
tools:context=".activity.PreviewActivity"> | ||
|
||
<android.support.v4.view.ViewPager | ||
app:layout_behavior="@string/appbar_scrolling_view_behavior" | ||
android:id="@+id/viewpager" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"/> | ||
|
||
</RelativeLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:orientation="vertical"> | ||
|
||
<ImageView | ||
android:id="@+id/image" | ||
android:layout_width="match_parent" | ||
android:layout_height="400dp" | ||
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters