Changed Position of Search to Filter BottomSheet

Also fixed the FC on orientation change
This commit is contained in:
Aditya Aggarwal 2017-10-21 20:12:41 +05:30
parent b246982300
commit dfdb377dee
9 changed files with 74 additions and 36 deletions

View File

@ -168,7 +168,6 @@ dependencies {
implementation 'net.yslibrary.keyboardvisibilityevent:keyboardvisibilityevent:2.1.0'
implementation 'com.airbnb.android:lottie:2.2.5'
implementation 'com.firebase:firebase-jobdispatcher:0.8.2'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
compileOnly "org.projectlombok:lombok:${lombokVersion}"
kapt "org.projectlombok:lombok:${lombokVersion}"
kapt "com.evernote:android-state-processor:${state_version}"
@ -189,5 +188,4 @@ dependencies {
}
apply plugin: 'ManifestClasspath'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.google.gms.google-services'

View File

@ -316,7 +316,7 @@
android:name="io.fabric.ApiKey"
android:value="6ed82b6e0756853d7d782a3f547f84f9ecba217e" />
<activity android:name=".ui.modules.search.SearchUserActivity"></activity>
<activity android:name=".ui.modules.search.SearchUserActivity" />
</application>
</manifest>

View File

@ -36,6 +36,7 @@ public class OrgReposFragment extends BaseFragment<OrgReposMvp.View, OrgReposPre
@BindView(R.id.fastScroller) RecyclerViewFastScroller fastScroller;
private OnLoadMore<String> onLoadMore;
private ReposAdapter adapter;
private String username;
public static OrgReposFragment newInstance(@NonNull String username) {
OrgReposFragment view = new OrgReposFragment();
@ -64,6 +65,7 @@ public class OrgReposFragment extends BaseFragment<OrgReposMvp.View, OrgReposPre
if (getArguments() == null) {
throw new NullPointerException("Bundle is null, username is required");
}
username = getArguments().getString(BundleConstant.EXTRA);
stateLayout.setEmptyText(R.string.no_repos);
stateLayout.setOnReloadListener(this);
refresh.setOnRefreshListener(this);
@ -148,6 +150,11 @@ public class OrgReposFragment extends BaseFragment<OrgReposMvp.View, OrgReposPre
//Not supported for org profile
}
@Override
public String getLogin() {
return username;
}
private void showReload() {
hideProgress();
stateLayout.showReload(adapter.getItemCount());

View File

@ -1,6 +1,7 @@
package com.fastaccess.ui.modules.profile.repos;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
@ -16,6 +17,7 @@ import com.fastaccess.helper.Bundler;
import com.fastaccess.ui.base.BaseBottomSheetDialog;
import com.fastaccess.ui.modules.profile.org.repos.OrgReposFragment;
import com.fastaccess.ui.modules.profile.org.repos.OrgReposMvp;
import com.fastaccess.ui.modules.search.SearchUserActivity;
import butterknife.BindView;
import butterknife.OnClick;
@ -94,6 +96,13 @@ public class ProfileReposFilterBottomSheetDialog extends BaseBottomSheetDialog {
sortSelectionSpinner.setSelection(0);
}
@OnClick(R.id.filter_sheet_search_btn) public void startSearch() {
if (listener != null) {
Intent intent = SearchUserActivity.getIntent(getContext(), listener.getLogin(), "");
startActivity(intent);
}
}
public interface ProfileReposFilterChangeListener {
void onFilterApply();
@ -102,5 +111,7 @@ public class ProfileReposFilterBottomSheetDialog extends BaseBottomSheetDialog {
void onSortOptionSelected(String selectedSortOption);
void onSortDirectionSelected(String selectedSortDirection);
String getLogin();
}
}

View File

@ -35,6 +35,7 @@ public class ProfileReposFragment extends BaseFragment<ProfileReposMvp.View, Pro
@BindView(R.id.fastScroller) RecyclerViewFastScroller fastScroller;
private OnLoadMore<String> onLoadMore;
private ReposAdapter adapter;
private String username;
public static ProfileReposFragment newInstance(@NonNull String username) {
ProfileReposFragment view = new ProfileReposFragment();
@ -63,6 +64,7 @@ public class ProfileReposFragment extends BaseFragment<ProfileReposMvp.View, Pro
if (getArguments() == null) {
throw new NullPointerException("Bundle is null, username is required");
}
this.username = getArguments().getString(BundleConstant.EXTRA);
stateLayout.setEmptyText(R.string.no_repos);
stateLayout.setOnReloadListener(this);
refresh.setOnRefreshListener(this);
@ -154,4 +156,9 @@ public class ProfileReposFragment extends BaseFragment<ProfileReposMvp.View, Pro
public void onSortDirectionSelected(String selectedSortDirection) {
getPresenter().onSortDirectionSelected(selectedSortDirection);
}
@Override
public String getLogin() {
return username;
}
}

View File

@ -3,20 +3,22 @@ package com.fastaccess.ui.modules.search
import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.text.Editable
import butterknife.ButterKnife
import butterknife.OnClick
import butterknife.OnEditorAction
import butterknife.OnTextChanged
import android.util.Log
import android.view.View
import android.widget.CheckBox
import butterknife.*
import com.fastaccess.R
import com.fastaccess.helper.AnimHelper
import com.fastaccess.helper.InputHelper
import com.fastaccess.helper.Logger
import com.fastaccess.ui.base.BaseActivity
import com.fastaccess.ui.base.mvp.BaseMvp
import com.fastaccess.ui.base.mvp.presenter.BasePresenter
import com.fastaccess.ui.modules.search.repos.SearchReposFragment
import kotlinx.android.synthetic.main.activity_search_user.*
import com.fastaccess.ui.widgets.FontAutoCompleteEditText
class SearchUserActivity : AppCompatActivity() {
class SearchUserActivity : BaseActivity<BaseMvp.FAView, BasePresenter<BaseMvp.FAView>>() {
companion object {
@ -34,6 +36,10 @@ class SearchUserActivity : AppCompatActivity() {
}
}
@BindView(R.id.forkCheckBox) lateinit var forkCheckBox: CheckBox
@BindView(R.id.clear) lateinit var clear: View
@BindView(R.id.searchEditText) lateinit var searchEditText: FontAutoCompleteEditText
private var username = ""
private var searchTerm = ""
private var isFork = true
@ -41,7 +47,6 @@ class SearchUserActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_search_user)
ButterKnife.bind(this)
searchReposFragment = SearchReposFragment.newInstance()
@ -50,14 +55,15 @@ class SearchUserActivity : AppCompatActivity() {
.commit()
val args = intent.extras
username = args.getString(USERNAME)
if (InputHelper.isEmpty(username))
throw UninitializedPropertyAccessException("Username cannot be empty")
searchTerm = args.getString(SEARCH_TERM)
if (InputHelper.isEmpty(searchTerm))
searchTerm = ""
Logger.d(username + " " + searchTerm)
makeSearch()
Logger.d("savedS $args")
if (args != null) {
username = args.getString(USERNAME)
if (InputHelper.isEmpty(username))
throw UninitializedPropertyAccessException("Username cannot be empty")
searchTerm = args.getString(SEARCH_TERM)
searchEditText.setText(searchTerm)
onSearchClicked()
}
forkCheckBox.setOnClickListener {
isFork = forkCheckBox.isChecked
@ -65,6 +71,11 @@ class SearchUserActivity : AppCompatActivity() {
}
}
override fun onSaveInstanceState(outState: Bundle?) {
super.onSaveInstanceState(outState)
intent.putExtra(SEARCH_TERM, searchTerm)
}
@OnTextChanged(value = R.id.searchEditText, callback = OnTextChanged.Callback.AFTER_TEXT_CHANGED)
fun onTextChange(str: Editable) {
searchTerm = str.toString()
@ -78,6 +89,7 @@ class SearchUserActivity : AppCompatActivity() {
@OnClick(R.id.search)
fun onSearchClicked() {
searchTerm = searchEditText.text.toString()
Logger.d("savedS $searchTerm")
makeSearch()
}
@ -92,4 +104,15 @@ class SearchUserActivity : AppCompatActivity() {
Logger.d(query)
searchReposFragment.onQueueSearch(query)
}
override fun layout(): Int = R.layout.activity_search_user
override fun isTransparent(): Boolean = false
override fun canBack(): Boolean = true
override fun providePresenter(): BasePresenter<BaseMvp.FAView> = BasePresenter()
override fun isSecured(): Boolean = false
}

View File

@ -244,7 +244,6 @@ public class UserPagerActivity extends BaseActivity<UserPagerMvp.View, UserPager
@Override public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.share_menu, menu);
getMenuInflater().inflate(R.menu.search_menu_solo, menu);
return super.onCreateOptionsMenu(menu);
}
@ -256,10 +255,6 @@ public class UserPagerActivity extends BaseActivity<UserPagerMvp.View, UserPager
.toString());
return true;
}
if (item.getItemId() == R.id.search && !InputHelper.isEmpty(login)) {
Intent intent = SearchUserActivity.getIntent(this, login, "");
startActivity(intent);
}
return super.onOptionsItemSelected(item);
}

View File

@ -42,6 +42,14 @@
android:text="@string/reset"
android:textColor="?android:textColorPrimary"/>
<com.fastaccess.ui.widgets.FontButton
android:id="@+id/filter_sheet_search_btn"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="end|center"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:background="@drawable/ic_search" />
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>

View File

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/search"
android:icon="@drawable/ic_search"
android:title="@string/search"
app:showAsAction="always" />
</menu>