-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into masterGit
Conflicts: .gitignore
- Loading branch information
Showing
64 changed files
with
4,277 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
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,34 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
android { | ||
compileSdkVersion 24 | ||
buildToolsVersion '25.0.0' | ||
defaultConfig { | ||
applicationId "kaufland.com.demo" | ||
minSdkVersion 17 | ||
targetSdkVersion 24 | ||
versionCode 1 | ||
versionName "1.0" | ||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
compile fileTree(dir: 'libs', include: ['*.jar']) | ||
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { | ||
exclude group: 'com.android.support', module: 'support-annotations' | ||
}) | ||
compile project(path: ':swipelibrary') | ||
compile 'com.android.support:appcompat-v7:25.0.1' | ||
compile 'com.android.support:design:24.2.1' | ||
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha9' | ||
compile 'com.android.support:support-v4:24.2.1' | ||
compile 'com.android.support:recyclerview-v7:24.2.1' | ||
testCompile 'junit:junit:4.12' | ||
} |
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,17 @@ | ||
# Add project specific ProGuard rules here. | ||
# By default, the flags in this file are appended to flags specified | ||
# in /Users/sbra0902/Library/Android/sdk/tools/proguard/proguard-android.txt | ||
# You can edit the include path and order by changing the proguardFiles | ||
# directive in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# Add any project specific keep options here: | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} |
26 changes: 26 additions & 0 deletions
26
app/src/androidTest/java/kaufland/com/demo/ExampleInstrumentedTest.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,26 @@ | ||
package kaufland.com.demo; | ||
|
||
import android.content.Context; | ||
import android.support.test.InstrumentationRegistry; | ||
import android.support.test.runner.AndroidJUnit4; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* Instrumentation test, which will execute on an Android device. | ||
* | ||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a> | ||
*/ | ||
@RunWith(AndroidJUnit4.class) | ||
public class ExampleInstrumentedTest { | ||
@Test | ||
public void useAppContext() throws Exception { | ||
// Context of the app under test. | ||
Context appContext = InstrumentationRegistry.getTargetContext(); | ||
|
||
assertEquals("kaufland.com.demo", appContext.getPackageName()); | ||
} | ||
} |
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,23 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="kaufland.com.demo"> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme"> | ||
<activity | ||
android:name=".MainActivity" | ||
android:label="@string/title_activity_main" | ||
android:theme="@style/AppTheme.NoActionBar"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN"/> | ||
|
||
<category android:name="android.intent.category.LAUNCHER"/> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
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,86 @@ | ||
package kaufland.com.demo; | ||
|
||
import android.os.Bundle; | ||
import android.support.design.widget.NavigationView; | ||
import android.support.v4.view.GravityCompat; | ||
import android.support.v4.widget.DrawerLayout; | ||
import android.support.v7.app.ActionBarDrawerToggle; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.support.v7.widget.Toolbar; | ||
import android.view.Menu; | ||
import android.view.MenuItem; | ||
|
||
import kaufland.com.demo.example.EasyExample; | ||
import kaufland.com.demo.example.RecylerViewWithRestoreFragment; | ||
|
||
public class MainActivity extends AppCompatActivity | ||
implements NavigationView.OnNavigationItemSelectedListener { | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_main); | ||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); | ||
setSupportActionBar(toolbar); | ||
|
||
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); | ||
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( | ||
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); | ||
drawer.setDrawerListener(toggle); | ||
toggle.syncState(); | ||
|
||
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); | ||
navigationView.setNavigationItemSelectedListener(this); | ||
} | ||
|
||
@Override | ||
public void onBackPressed() { | ||
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); | ||
if (drawer.isDrawerOpen(GravityCompat.START)) { | ||
drawer.closeDrawer(GravityCompat.START); | ||
} else { | ||
super.onBackPressed(); | ||
} | ||
} | ||
|
||
@Override | ||
public boolean onCreateOptionsMenu(Menu menu) { | ||
// Inflate the menu; this adds items to the action bar if it is present. | ||
getMenuInflater().inflate(R.menu.main, menu); | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean onOptionsItemSelected(MenuItem item) { | ||
// Handle action bar item clicks here. The action bar will | ||
// automatically handle clicks on the Home/Up button, so long | ||
// as you specify a parent activity in AndroidManifest.xml. | ||
int id = item.getItemId(); | ||
|
||
//noinspection SimplifiableIfStatement | ||
if (id == R.id.action_settings) { | ||
return true; | ||
} | ||
|
||
return super.onOptionsItemSelected(item); | ||
} | ||
|
||
@SuppressWarnings("StatementWithEmptyBody") | ||
@Override | ||
public boolean onNavigationItemSelected(MenuItem item) { | ||
// Handle navigation view item clicks here. | ||
int id = item.getItemId(); | ||
|
||
if (id == R.id.nav_easy_example) { | ||
getFragmentManager().beginTransaction().replace(R.id.content_main, new EasyExample()).commit(); | ||
} else if (id == R.id.nav_recycler_with_restore) { | ||
getFragmentManager().beginTransaction().replace(R.id.content_main, new RecylerViewWithRestoreFragment()).commit(); | ||
} else if (id == R.id.nav_share) { | ||
|
||
} | ||
|
||
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); | ||
drawer.closeDrawer(GravityCompat.START); | ||
return true; | ||
} | ||
} |
99 changes: 99 additions & 0 deletions
99
app/src/main/java/kaufland/com/demo/example/EasyExample.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,99 @@ | ||
package kaufland.com.demo.example; | ||
|
||
import android.app.Fragment; | ||
import android.os.Bundle; | ||
import android.support.annotation.Nullable; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.Button; | ||
import android.widget.Toast; | ||
|
||
import kaufland.com.demo.R; | ||
import kaufland.com.swipelibrary.DragView; | ||
import kaufland.com.swipelibrary.SwipeLayout; | ||
import kaufland.com.swipelibrary.SwipeState; | ||
|
||
/** | ||
* Created by sbra0902 on 30.03.17. | ||
*/ | ||
|
||
public class EasyExample extends Fragment { | ||
|
||
|
||
@Nullable | ||
@Override | ||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) { | ||
return inflater.inflate(R.layout.easy_example_fragment, container, false); | ||
} | ||
|
||
@Override | ||
public void onViewCreated(final View view, @Nullable Bundle savedInstanceState) { | ||
super.onViewCreated(view, savedInstanceState); | ||
final SwipeLayout mViewById = (SwipeLayout) view.findViewById(R.id.swipe_example_2); | ||
mViewById.setSwipeListener(new SwipeLayout.SwipeListener() { | ||
@Override | ||
public void onSwipeOpened(SwipeState.DragViewState openedDragView, boolean isFullSwipe) { | ||
Toast.makeText(getActivity(), "onSwipeOpened " + openedDragView.name() + String.valueOf(isFullSwipe), Toast.LENGTH_SHORT).show(); | ||
} | ||
|
||
@Override | ||
public void onSwipeClosed(SwipeState.DragViewState dragViewState) { | ||
Toast.makeText(getActivity(), "onSwipeOpened " + dragViewState.name(), Toast.LENGTH_SHORT).show(); | ||
} | ||
|
||
@Override | ||
public void onBounce(SwipeState.DragViewState dragViewState) { | ||
Toast.makeText(getActivity(), "onBounce " + dragViewState.name(), Toast.LENGTH_SHORT).show(); | ||
} | ||
}); | ||
view.findViewById(R.id.btn_close).setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
mViewById.closeSwipe(); | ||
} | ||
}); | ||
view.findViewById(R.id.btn_open_left).setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
mViewById.openSwipe(SwipeLayout.LEFT_DRAG_VIEW); | ||
} | ||
}); | ||
view.findViewById(R.id.btn_open_right).setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
mViewById.openSwipe(SwipeLayout.RIGHT_DRAG_VIEW); | ||
} | ||
}); | ||
view.findViewById(R.id.btn_disable_left_drag).setOnClickListener(new View.OnClickListener() { | ||
private boolean state = true; | ||
public void onClick(View v) { | ||
if ( state ) { | ||
state = false; | ||
((Button)v).setText("enable left drag"); | ||
|
||
} else { | ||
state = true; | ||
((Button)v).setText("disable left drag"); | ||
} | ||
((DragView)view.findViewById(R.id.swipe_example_2_left_drag)).setDraggable(state); | ||
|
||
} | ||
}); | ||
view.findViewById(R.id.btn_disable_right_drag).setOnClickListener(new View.OnClickListener() { | ||
private boolean state = true; | ||
public void onClick(View v) { | ||
if ( state ) { | ||
state = false; | ||
((Button)v).setText("enable right drag"); | ||
|
||
} else { | ||
state = true; | ||
((Button)v).setText("disable right drag"); | ||
} | ||
((DragView)view.findViewById(R.id.swipe_example_2_right_drag)).setDraggable(state); | ||
|
||
} | ||
}); | ||
} | ||
} |
82 changes: 82 additions & 0 deletions
82
app/src/main/java/kaufland/com/demo/example/MyItemRecyclerViewAdapter.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,82 @@ | ||
package kaufland.com.demo.example; | ||
|
||
import android.os.Looper; | ||
import android.support.v7.widget.RecyclerView; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.TextView; | ||
|
||
import kaufland.com.demo.R; | ||
import kaufland.com.demo.example.RecylerViewWithRestoreFragment.OnListFragmentInteractionListener; | ||
import kaufland.com.demo.example.dummy.DummyContent.DummyItem; | ||
import kaufland.com.swipelibrary.SwipeLayout; | ||
import kaufland.com.swipelibrary.SwipeState; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.logging.Handler; | ||
|
||
/** | ||
* {@link RecyclerView.Adapter} that can display a {@link DummyItem} and makes a call to the | ||
* specified {@link OnListFragmentInteractionListener}. | ||
* TODO: Replace the implementation with code for your data type. | ||
*/ | ||
public class MyItemRecyclerViewAdapter extends RecyclerView.Adapter<MyItemRecyclerViewAdapter.ViewHolder> { | ||
|
||
private final List<DummyItem> mValues; | ||
private final OnListFragmentInteractionListener mListener; | ||
|
||
private Map<Integer, SwipeState.DragViewState> mStateReminder = new HashMap<>(); | ||
|
||
public MyItemRecyclerViewAdapter(List<DummyItem> items, OnListFragmentInteractionListener listener) { | ||
mValues = items; | ||
mListener = listener; | ||
} | ||
|
||
@Override | ||
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { | ||
View view = LayoutInflater.from(parent.getContext()) | ||
.inflate(R.layout.fragment_item_restore, parent, false); | ||
return new ViewHolder(view); | ||
} | ||
|
||
@Override | ||
public void onBindViewHolder(final ViewHolder holder, final int position) { | ||
|
||
holder.mSwipeLayout.markForRestoreOnDraw(mStateReminder.containsKey(position) ? mStateReminder.get(position) : SwipeState.DragViewState.CLOSED); | ||
holder.mSwipeLayout.setSwipeListener(new SwipeLayout.SwipeListener() { | ||
@Override | ||
public void onSwipeOpened(SwipeState.DragViewState openedDragView, boolean isFullSwipe) { | ||
mStateReminder.put(position, openedDragView); | ||
} | ||
|
||
@Override | ||
public void onSwipeClosed(SwipeState.DragViewState dragViewState) { | ||
mStateReminder.put(position, dragViewState); | ||
} | ||
|
||
@Override | ||
public void onBounce(SwipeState.DragViewState dragViewState) { | ||
|
||
} | ||
}); | ||
} | ||
|
||
@Override | ||
public int getItemCount() { | ||
return mValues.size(); | ||
} | ||
|
||
public class ViewHolder extends RecyclerView.ViewHolder { | ||
|
||
SwipeLayout mSwipeLayout; | ||
|
||
public ViewHolder(View view) { | ||
super(view); | ||
mSwipeLayout = (SwipeLayout) view.findViewById(R.id.swipe_example_2); | ||
} | ||
|
||
} | ||
} |
Oops, something went wrong.