Skip to content

Commit

Permalink
Merge remote-tracking branch 'davideas/dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Rafael Dominiquini committed Jun 30, 2016
2 parents 5cc6281 + 5c30974 commit 427d9fd
Show file tree
Hide file tree
Showing 25 changed files with 261 additions and 183 deletions.
185 changes: 69 additions & 116 deletions README.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ ext {

//Support and Build tools version
minSdk = 14
targetSdk = 23
targetSdk = 24
buildTools = "23.0.3"
supportLib = "23.4.0"
supportLib = "24.0.0"

//Support Libraries dependencies
supportDependencies = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@
import android.support.v7.widget.Toolbar;
import android.support.v7.widget.helper.ItemTouchHelper;
import android.text.InputType;
import android.transition.Fade;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.view.inputmethod.EditorInfo;
import android.widget.TextView;
import android.widget.Toast;
Expand Down Expand Up @@ -120,7 +122,13 @@ public boolean handleMessage(Message message) {

@Override
protected void onCreate(Bundle savedInstanceState) {
if (Utils.hasLollipop()) requestWindowFeature(Window.FEATURE_CONTENT_TRANSITIONS);
super.onCreate(savedInstanceState);

if (Utils.hasLollipop()) {
getWindow().setEnterTransition(new Fade());
}

setContentView(R.layout.activity_main);
Log.d(TAG, "onCreate");
FlexibleAdapter.enableLogs(true);
Expand Down Expand Up @@ -853,6 +861,12 @@ public void onBackPressed() {
mSearchView.setIconified(true);
return;
}
//Return to Overall View
if (DatabaseService.getInstance().getDatabaseType() != 0) {
MenuItem menuItem = mNavigationView.getMenu().findItem(R.id.nav_overall);
onNavigationItemSelected(menuItem);
return;
}
//Close the App
DatabaseService.onDestroy();
super.onBackPressed();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,13 @@ public void onPrepareOptionsMenu(Menu menu) {
}
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.action_list_type)
mAdapter.setAnimationOnScrolling(true);
return super.onOptionsItemSelected(item);
}

@Override
protected GridLayoutManager createNewGridLayoutManager() {
GridLayoutManager gridLayoutManager = new SmoothScrollGridLayoutManager(getActivity(), mColumnCount);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,11 @@ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
//TODO: Implement Filterable in the item interfaces
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.action_list_type)
mAdapter.setAnimationOnScrolling(true);
return super.onOptionsItemSelected(item);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,11 @@ public void onPrepareOptionsMenu(Menu menu) {
}
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.action_list_type)
mAdapter.setAnimationOnScrolling(true);
return super.onOptionsItemSelected(item);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -231,4 +231,11 @@ public void onPrepareOptionsMenu(Menu menu) {
}
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.action_list_type)
mAdapter.setAnimationOnScrolling(true);
return super.onOptionsItemSelected(item);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.MenuItem;
import android.widget.Toast;

import java.util.ArrayList;
Expand Down Expand Up @@ -34,7 +35,7 @@ public class FragmentInstagramHeaders extends AbstractFragment
/**
* Custom implementation of FlexibleAdapter
*/
private FlexibleAdapter mAdapter;
private FlexibleAdapter<AbstractFlexibleItem> mAdapter;


public static FragmentInstagramHeaders newInstance() {
Expand Down Expand Up @@ -62,12 +63,14 @@ public void onActivityCreated(Bundle savedInstanceState) {
FlipView.stopLayoutAnimation();
}

@SuppressWarnings({"ConstantConditions", "unchecked"})
@SuppressWarnings({"unchecked", "ConstantConditions"})
private void initializeRecyclerView(Bundle savedInstanceState) {
mAdapter = new FlexibleAdapter<>(DatabaseService.getInstance().getDatabaseList(), getActivity());
//Experimenting NEW features (v5.0.0)
mAdapter.setAnimationOnScrolling(true);
mAdapter.setAnimationOnReverseScrolling(true);
mAdapter.initializeListeners(getActivity())
.setDisplayHeadersAtStartUp(true)//Show Headers at startUp!
//Experimenting NEW features (v5.0.0)
.setAnimationOnScrolling(true)
.setAnimationOnReverseScrolling(true);
mRecyclerView = (RecyclerView) getView().findViewById(R.id.recycler_view);
mRecyclerView.setLayoutManager(createNewLinearLayoutManager());
mRecyclerView.setAdapter(mAdapter);
Expand All @@ -80,8 +83,7 @@ public boolean canReuseUpdatedViewHolder(RecyclerView.ViewHolder viewHolder) {
}
});
mRecyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), 0, 24));
mAdapter.setDisplayHeadersAtStartUp(true)//Show Headers at startUp!
.enableStickyHeaders()//Make headers sticky
mAdapter.enableStickyHeaders()//Make headers sticky
//Endless scroll with 1 item threshold
.setEndlessScrollListener(this, new ProgressItem())
.setEndlessScrollThreshold(1);//Default=1
Expand Down Expand Up @@ -120,6 +122,13 @@ public void run() {
}, 2000);
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.action_list_type)
mAdapter.setAnimationOnScrolling(true);
return super.onOptionsItemSelected(item);
}

@Override
protected GridLayoutManager createNewGridLayoutManager() {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private void initializeRecyclerView(Bundle savedInstanceState) {
mAdapter.setAnimationDelay(150L);
mRecyclerView = (RecyclerView) getView().findViewById(R.id.recycler_view);
mRecyclerView.setItemViewCacheSize(0);//Setting ViewCache to 0 (default=2) will animate items better while scrolling down+up with LinearLayout
mRecyclerView.setLayoutManager(createNewGridLayoutManager());
mRecyclerView.setLayoutManager(createNewStaggeredGridLayoutManager());
mRecyclerView.setAdapter(mAdapter);
mRecyclerView.setHasFixedSize(true);//Size of RV will not change
//mRecyclerView.setItemAnimator(new SlideInRightAnimator());
Expand Down Expand Up @@ -133,4 +133,11 @@ public void onPrepareOptionsMenu(Menu menu) {
}
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.action_list_type)
mAdapter.setAnimationOnScrolling(true);
return super.onOptionsItemSelected(item);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -222,4 +222,11 @@ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.action_list_type)
mAdapter.setAnimationOnScrolling(true);
return super.onOptionsItemSelected(item);
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package eu.davidea.samples.flexibleadapter.models;

import android.content.Context;
import android.support.annotation.NonNull;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
Expand Down Expand Up @@ -68,7 +69,7 @@ public ParentViewHolder createViewHolder(FlexibleAdapter adapter, LayoutInflater
}

@Override
@SuppressWarnings("unchecked")
@SuppressWarnings({"unchecked", "deprecation"})
public void bindViewHolder(final FlexibleAdapter adapter, ParentViewHolder holder, int position, List payloads) {
//Subtitle
if (adapter.isExpandable(this)) {
Expand All @@ -78,11 +79,14 @@ public void bindViewHolder(final FlexibleAdapter adapter, ParentViewHolder holde
}
setSubtitle(getSubtitle() + (getHeader() != null ? " - Header: " + getHeader().getId() : ""));

Context context = holder.itemView.getContext();
int defColorAccent = context.getResources().getColor(R.color.colorAccent_light);

if (adapter.isExpandable(this) && payloads.size() > 0){
Log.i(this.getClass().getSimpleName(), "ExpandableItem Payload " + payloads);
if (adapter.hasSearchText()) {
Utils.highlightText(holder.itemView.getContext(), holder.mSubtitle,
getSubtitle(), adapter.getSearchText(), R.color.colorAccent_light);
getSubtitle(), adapter.getSearchText(), defColorAccent);
} else {
holder.mSubtitle.setText(getSubtitle());
}
Expand All @@ -108,10 +112,10 @@ public void run() {
//In case of searchText matches with Title or with an SimpleItem's field
// this will be highlighted
if (adapter.hasSearchText()) {
Utils.highlightText(holder.itemView.getContext(), holder.mTitle,
getTitle(), adapter.getSearchText(), R.color.colorAccent_light);
Utils.highlightText(holder.itemView.getContext(), holder.mSubtitle,
getSubtitle(), adapter.getSearchText(), R.color.colorAccent_light);
Utils.highlightText(context, holder.mTitle,
getTitle(), adapter.getSearchText(), defColorAccent);
Utils.highlightText(context, holder.mSubtitle,
getSubtitle(), adapter.getSearchText(), defColorAccent);
} else {
holder.mTitle.setText(getTitle());
holder.mSubtitle.setText(getSubtitle());
Expand Down Expand Up @@ -161,18 +165,23 @@ public void onClick(View v) {
}
});
this.mHandleView = (ImageView) view.findViewById(R.id.row_handle);
if (adapter.isHandleDragEnabled()) {
this.mHandleView.setVisibility(View.VISIBLE);
setDragHandleView(mHandleView);
} else {
this.mHandleView.setVisibility(View.GONE);
}
setDragHandleView(mHandleView);

this.frontView = view.findViewById(R.id.front_view);
this.rearLeftView = view.findViewById(R.id.rear_left_view);
this.rearRightView = view.findViewById(R.id.rear_right_view);
}

@Override
protected void setDragHandleView(@NonNull View view) {
if (mAdapter.isHandleDragEnabled()) {
view.setVisibility(View.VISIBLE);
super.setDragHandleView(view);
} else {
view.setVisibility(View.GONE);
}
}

@Override
public void onClick(View view) {
Toast.makeText(mContext, "Click on " + mTitle.getText() + " position " + getAdapterPosition(), Toast.LENGTH_SHORT).show();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ public ViewHolder createViewHolder(FlexibleAdapter adapter, LayoutInflater infla
public void bindViewHolder(final FlexibleAdapter adapter, final ViewHolder holder, int position, List payloads) {
Context context = holder.itemTextView.getContext();

//Table Id
//Item Id
holder.itemTextView.setText(toString());

//Table Status
//Item Status
holder.statusTextView.setText(status.getResId());
DrawableUtils.setBackground(holder.itemView,
DrawableUtils.getSelectableBackgroundCompat(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
android:layout_height="wrap_content"
android:gravity="center"
android:ellipsize="end"
android:maxLines="4"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
tools:text="@string/endless_scrolling_description"/>

Expand Down
5 changes: 5 additions & 0 deletions flexible-adapter-app/src/main/res/values-v21/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>

<!-- Transitions settings -->
<item name="android:windowContentTransitions">true</item>
<item name="android:windowAllowEnterTransitionOverlap">true</item>
<item name="android:windowAllowReturnTransitionOverlap">true</item>
</style>

<style name="AppTheme.AlertDialog" parent="Theme.AppCompat.Light.Dialog.Alert">
Expand Down
12 changes: 6 additions & 6 deletions flexible-adapter-app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,22 @@
<!--<string name="overall_description">Examples may have options where available to enable/disable: (1) Filter (2) FastScroller (3) Grid Layout (4) Sticky Headers</string>-->

<string name="selection_modes">Selection modes</string>
<string name="selection_modes_description">IDLE, SINGLE, MULTI + ActionModeHelper (AH) + UndoHelper (UH)</string>
<string name="selection_modes_description">IDLE, SINGLE, MULTI + ActionModeHelper + UndoHelper</string>

<string name="endless_scrolling">EndlessScrolling</string>
<string name="endless_scrolling_description">EndlessScrolling + Adapter Animation + Swipe-To-Delete w/rear-views + (AH) + (UH)</string><!-- TODO: in combination with Item Animation -->
<string name="endless_scrolling_description">EndlessScrolling + Adapter Animation + Swipe-To-Delete w/rear-views + ActionModeHelper + UndoHelper</string><!-- TODO: in combination with Item Animation -->

<string name="expandable">Expandable</string>
<string name="expandable_description">List with expandable items + Selection Coherence (SC) + Filter (F) + (AH) + (UH)</string>
<string name="expandable_description">List with expandable items + Selection Coherence + Filter + ActionModeHelper + UndoHelper</string>

<string name="multi_level_expandable">Expandable Multi-Level</string>
<string name="multi_level_expandable_description">2 levels of expandable + (SC) + Swipeable &amp; Draggable items + (AH) + (UH)</string>
<string name="multi_level_expandable_description">2 levels of expandable + Selection Coherence + Swipeable &amp; Draggable items + ActionModeHelper + UndoHelper</string>

<string name="expandable_sections">Expandable Sections</string>
<string name="expandable_sections_description">Sections with (sticky) headers that can expand/collapse + Drag items + (F)</string>
<string name="expandable_sections_description">Sections with (sticky) headers that can expand/collapse + Drag items + Filter</string>

<string name="headers_sections">Headers and Sections</string>
<string name="headers_sections_description">Clickable sticky headers for sections + Drag items with Auto-Linkage + (F)</string>
<string name="headers_sections_description">Clickable sticky headers for sections + Drag items with Auto-Linkage + Filter</string>

<string name="instagram_headers">Instagram headers</string>
<string name="instagram_headers_description"><![CDATA[1 sticky header for each item + EndlessScrolling.<br/><font color="#ff4081"><b>Internet is required.</b></font>]]></string>
Expand Down
Loading

0 comments on commit 427d9fd

Please sign in to comment.