This repository has been archived by the owner on Feb 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #108 from spacecowboy/fix-fastscroll
Fix some of the samples
- Loading branch information
Showing
8 changed files
with
661 additions
and
150 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
425 changes: 425 additions & 0 deletions
425
sample/src/androidTest/java/com/nononsenseapps/filepicker/sample/FastScrollerNewFile.java
Large diffs are not rendered by default.
Oops, something went wrong.
73 changes: 73 additions & 0 deletions
73
sample/src/androidTest/java/com/nononsenseapps/filepicker/sample/FtpPicker.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,73 @@ | ||
package com.nononsenseapps.filepicker.sample; | ||
|
||
|
||
import android.support.test.espresso.ViewInteraction; | ||
import android.support.test.espresso.action.ViewActions; | ||
import android.support.test.rule.ActivityTestRule; | ||
import android.support.test.runner.AndroidJUnit4; | ||
import android.test.suitebuilder.annotation.LargeTest; | ||
|
||
import org.junit.Before; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import java.io.IOException; | ||
|
||
import static android.support.test.espresso.Espresso.onView; | ||
import static android.support.test.espresso.action.ViewActions.click; | ||
import static android.support.test.espresso.action.ViewActions.replaceText; | ||
import static android.support.test.espresso.assertion.ViewAssertions.matches; | ||
import static android.support.test.espresso.contrib.RecyclerViewActions.actionOnItemAtPosition; | ||
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; | ||
import static android.support.test.espresso.matcher.ViewMatchers.withId; | ||
import static android.support.test.espresso.matcher.ViewMatchers.withParent; | ||
import static android.support.test.espresso.matcher.ViewMatchers.withText; | ||
import static com.nononsenseapps.filepicker.sample.PermissionGranter.allowPermissionsIfNeeded; | ||
import static org.hamcrest.Matchers.allOf; | ||
|
||
@LargeTest | ||
@RunWith(AndroidJUnit4.class) | ||
public class FtpPicker { | ||
|
||
@Rule | ||
public ActivityTestRule<NoNonsenseFilePickerTest> mActivityTestRule = | ||
new ActivityTestRule<>(NoNonsenseFilePickerTest.class); | ||
|
||
@Before | ||
public void allowPermissions() { | ||
allowPermissionsIfNeeded(mActivityTestRule.getActivity()); | ||
} | ||
|
||
@Test | ||
public void selectDir() throws IOException { | ||
ViewInteraction radioButton = onView( | ||
allOf(withId(R.id.radioDir), withText("Select directory"), | ||
withParent(withId(R.id.radioGroup)), | ||
isDisplayed())); | ||
radioButton.perform(click()); | ||
|
||
onView(withId(R.id.button_ftp)).perform(ViewActions.scrollTo()); | ||
|
||
ViewInteraction button = onView( | ||
allOf(withId(R.id.button_ftp), isDisplayed())); | ||
button.perform(click()); | ||
|
||
ViewInteraction recyclerView = onView( | ||
allOf(withId(android.R.id.list), isDisplayed())); | ||
|
||
// press pub | ||
recyclerView.perform(actionOnItemAtPosition(1, click())); | ||
|
||
ViewInteraction okButton = onView( | ||
allOf(withId(R.id.nnf_button_ok), | ||
withParent(allOf(withId(R.id.nnf_button_container), | ||
withParent(withId(R.id.nnf_buttons_container)))), | ||
isDisplayed())); | ||
// Click ok | ||
okButton.perform(click()); | ||
|
||
ViewInteraction textView = onView(withId(R.id.text)); | ||
textView.check(matches(withText("ftp://anonymous:anonymous@debian.simnet.is:21/pub"))); | ||
} | ||
} |
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
59 changes: 2 additions & 57 deletions
59
...ava/com/nononsenseapps/filepicker/sample/fastscroller/FastScrollerFilePickerFragment.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 |
---|---|---|
@@ -1,70 +1,15 @@ | ||
package com.nononsenseapps.filepicker.sample.fastscroller; | ||
|
||
import android.os.Bundle; | ||
import android.support.v4.content.Loader; | ||
import android.support.v7.util.SortedList; | ||
import android.support.v7.widget.LinearLayoutManager; | ||
import android.support.v7.widget.RecyclerView; | ||
import android.support.v7.widget.Toolbar; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.TextView; | ||
|
||
import com.nononsenseapps.filepicker.FilePickerFragment; | ||
import com.nononsenseapps.filepicker.sample.R; | ||
import com.nononsenseapps.filepicker.sample.fastscroller.FastScrollerFileItemAdapter; | ||
import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView; | ||
|
||
import java.io.File; | ||
|
||
public class FastScrollerFilePickerFragment extends FilePickerFragment { | ||
|
||
private FastScrollRecyclerView recyclerView; | ||
|
||
@Override | ||
public View onCreateView(LayoutInflater inflater, ViewGroup container, | ||
Bundle savedInstanceState) { | ||
View view = inflater.inflate(R.layout.fragment_fastscrollerfilepicker, container, false); | ||
|
||
Toolbar toolbar = (Toolbar) view.findViewById(com.nononsenseapps.filepicker.R.id.nnf_picker_toolbar); | ||
if (toolbar != null) { | ||
setupToolbar(toolbar); | ||
} | ||
|
||
recyclerView = (FastScrollRecyclerView) view.findViewById(android.R.id.list); | ||
// improve performance if you know that changes in content | ||
// do not change the size of the RecyclerView | ||
recyclerView.setHasFixedSize(true); | ||
// use a linear layout manager | ||
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity()); | ||
recyclerView.setLayoutManager(layoutManager); | ||
// Set adapter | ||
mAdapter = new FastScrollerFileItemAdapter(this); | ||
recyclerView.setAdapter(mAdapter); | ||
|
||
view.findViewById(com.nononsenseapps.filepicker.R.id.nnf_button_cancel) | ||
.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(final View v) { | ||
onClickCancel(v); | ||
} | ||
}); | ||
|
||
view.findViewById(com.nononsenseapps.filepicker.R.id.nnf_button_ok) | ||
.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(final View v) { | ||
onClickOk(v); | ||
} | ||
}); | ||
|
||
mCurrentDirView = (TextView) view.findViewById(com.nononsenseapps.filepicker.R.id.nnf_current_dir); | ||
// Restore state | ||
if (mCurrentPath != null && mCurrentDirView != null) { | ||
mCurrentDirView.setText(getFullPath(mCurrentPath)); | ||
} | ||
|
||
return view; | ||
protected View inflateRootView(LayoutInflater inflater, ViewGroup container) { | ||
return inflater.inflate(R.layout.fragment_fastscrollerfilepicker, container, false); | ||
} | ||
} |
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
Oops, something went wrong.