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
Showing
5 changed files
with
126 additions
and
41 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<menu xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<item android:title="Add Sticky view" | ||
android:id="@+id/action_add_view" /> | ||
<item android:title="Add Sticky view" android:id="@+id/action_add_view" /> | ||
<item android:title="Clear All" android:id="@+id/action_clear_all" /> | ||
</menu> |
42 changes: 42 additions & 0 deletions
42
stickyheaderview-rv/src/main/java/tellh/com/stickyheaderview_rv/LinkListStack.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,42 @@ | ||
package tellh.com.stickyheaderview_rv; | ||
|
||
import java.util.EmptyStackException; | ||
import java.util.LinkedList; | ||
|
||
/** | ||
* Created by tlh on 2017/5/11 :) | ||
*/ | ||
|
||
public class LinkListStack<E> { | ||
private LinkedList<E> list = new LinkedList<>(); | ||
|
||
public E push(E item) { | ||
list.addLast(item); | ||
return item; | ||
} | ||
|
||
public E pop() { | ||
if (list.isEmpty()) | ||
return null; | ||
return list.removeLast(); | ||
} | ||
|
||
public synchronized E peek() { | ||
if (list.size() == 0) | ||
throw new EmptyStackException(); | ||
return list.peekLast(); | ||
} | ||
|
||
public boolean isEmpty() { | ||
return list.size() == 0; | ||
} | ||
|
||
public void clear() { | ||
list.clear(); | ||
} | ||
|
||
public boolean remove(E item) { | ||
return list.remove(item); | ||
} | ||
|
||
} |
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