Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ dependencies {
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'org.androidannotations:androidannotations-api:4.4.0'
annotationProcessor "org.androidannotations:androidannotations:4.4.0"
implementation 'com.tom_roush:pdfbox-android:1.8.10.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.github.barteksc.pdfviewer.PDFView;
Expand All @@ -45,6 +49,7 @@
import org.androidannotations.annotations.OptionsMenu;
import org.androidannotations.annotations.ViewById;

import java.util.ArrayList;
import java.util.List;

@EActivity(R.layout.activity_main)
Expand All @@ -63,6 +68,25 @@ public class PDFViewActivity extends AppCompatActivity implements OnPageChangeLi
@ViewById
PDFView pdfView;

@ViewById
EditText searchET;
@ViewById
Button searchBtn;
@ViewById
Button exitSearchBtn;
@ViewById
Button searchResultBeforeBtn;
@ViewById
Button searchResultAfterBtn;
@ViewById
TextView searchIndexTV;
@ViewById
RelativeLayout searchResultRelativeLayout;

int pageCount = 0;
int currentSearchResultIndex = -1;
ArrayList<Integer> searchIndeces;

@NonConfigurationInstance
Uri uri;

Expand Down
82 changes: 78 additions & 4 deletions sample/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,83 @@
android:layout_width="match_parent"
android:layout_height="match_parent">

<com.github.barteksc.pdfviewer.PDFView
android:id="@+id/pdfView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:id="@+id/searchLayout"
android:weightSum="5">

<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/searchET"
android:layout_weight="4"
android:hint="search here" />

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/searchBtn"
android:layout_weight="1"
android:visibility="visible"
android:text="Search"
android:onClick="search"/>


</LinearLayout>


<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/searchResultRelativeLayout"
android:layout_alignParentRight="true"
android:visibility="invisible">

<Button
android:layout_width="25dp"
android:layout_height="25dp"
android:id="@+id/exitSearchBtn"
android:background="@android:drawable/ic_menu_close_clear_cancel"
android:onClick="exitSearch"
android:layout_centerVertical="true"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1/8"
android:id="@+id/searchIndexTV"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/exitSearchBtn"
android:layout_alignBaseline="@+id/exitSearchBtn" />

<Button
android:layout_width="35dp"
android:layout_height="35dp"
android:id="@+id/searchResultBeforeBtn"
android:onClick="goToBeforeSearchResult"
android:background="@android:drawable/arrow_up_float"
android:layout_toRightOf="@+id/searchIndexTV"
android:layout_marginLeft="5dp"
android:layout_centerVertical="true"/>

<Button
android:layout_width="35dp"
android:layout_height="35dp"
android:id="@+id/searchResultAfterBtn"
android:onClick="goToAfterSearchResult"
android:layout_toRightOf="@+id/searchResultBeforeBtn"
android:background="@android:drawable/arrow_down_float"
android:layout_centerVertical="true"/>

</RelativeLayout>


<com.github.barteksc.pdfviewer.PDFView
android:layout_below="@+id/searchLayout"
android:id="@+id/pdfView"
android:layout_width="match_parent"
android:layout_height="match_parent" />

</RelativeLayout>