forked from WebJournal/journaldev
-
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' of https://github.com/journaldev/journaldev
- Loading branch information
Showing
31 changed files
with
725 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,8 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/workspace.xml | ||
/.idea/libraries | ||
.DS_Store | ||
/build | ||
/captures |
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,27 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
android { | ||
compileSdkVersion 24 | ||
buildToolsVersion "24.0.1" | ||
|
||
defaultConfig { | ||
applicationId "com.journaldev.bottomsheet" | ||
minSdkVersion 15 | ||
targetSdkVersion 24 | ||
versionCode 1 | ||
versionName "1.0" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
compile fileTree(dir: 'libs', include: ['*.jar']) | ||
testCompile 'junit:junit:4.12' | ||
compile 'com.android.support:appcompat-v7:24.2.1' | ||
compile 'com.android.support:design:24.2.1' | ||
} |
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/anupamchugh/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 *; | ||
#} |
13 changes: 13 additions & 0 deletions
13
Android/BottomSheet/app/src/androidTest/java/com/journaldev/bottomsheet/ApplicationTest.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,13 @@ | ||
package com.journaldev.bottomsheet; | ||
|
||
import android.app.Application; | ||
import android.test.ApplicationTestCase; | ||
|
||
/** | ||
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a> | ||
*/ | ||
public class ApplicationTest extends ApplicationTestCase<Application> { | ||
public ApplicationTest() { | ||
super(Application.class); | ||
} | ||
} |
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="com.journaldev.bottomsheet"> | ||
|
||
<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/app_name" | ||
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> |
67 changes: 67 additions & 0 deletions
67
Android/BottomSheet/app/src/main/java/com/journaldev/bottomsheet/ItemAdapter.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,67 @@ | ||
package com.journaldev.bottomsheet; | ||
|
||
import android.support.v7.widget.RecyclerView; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.TextView; | ||
|
||
|
||
import java.util.List; | ||
|
||
|
||
class ItemAdapter extends RecyclerView.Adapter<ItemAdapter.ViewHolder> { | ||
|
||
private List<String> mItems; | ||
private ItemListener mListener; | ||
|
||
ItemAdapter(List<String> items, ItemListener listener) { | ||
mItems = items; | ||
mListener = listener; | ||
} | ||
|
||
|
||
@Override | ||
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { | ||
return new ViewHolder(LayoutInflater.from(parent.getContext()) | ||
.inflate(R.layout.bottom_sheet_item, parent, false)); | ||
} | ||
|
||
@Override | ||
public void onBindViewHolder(ViewHolder holder, int position) { | ||
holder.setData(mItems.get(position)); | ||
} | ||
|
||
@Override | ||
public int getItemCount() { | ||
return mItems.size(); | ||
} | ||
|
||
class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { | ||
|
||
TextView textView; | ||
String item; | ||
|
||
ViewHolder(View itemView) { | ||
super(itemView); | ||
itemView.setOnClickListener(this); | ||
textView = (TextView) itemView.findViewById(R.id.textView); | ||
} | ||
|
||
void setData(String item) { | ||
this.item = item; | ||
textView.setText(item); | ||
} | ||
|
||
@Override | ||
public void onClick(View v) { | ||
if (mListener != null) { | ||
mListener.onItemClick(item); | ||
} | ||
} | ||
} | ||
|
||
interface ItemListener { | ||
void onItemClick(String item); | ||
} | ||
} |
88 changes: 88 additions & 0 deletions
88
Android/BottomSheet/app/src/main/java/com/journaldev/bottomsheet/MainActivity.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,88 @@ | ||
package com.journaldev.bottomsheet; | ||
|
||
import android.os.Bundle; | ||
import android.support.annotation.NonNull; | ||
import android.support.design.widget.BottomSheetBehavior; | ||
import android.support.design.widget.CoordinatorLayout; | ||
import android.support.design.widget.Snackbar; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.support.v7.widget.LinearLayoutManager; | ||
import android.support.v7.widget.RecyclerView; | ||
import android.support.v7.widget.Toolbar; | ||
import android.view.View; | ||
import android.widget.Button; | ||
|
||
import java.util.ArrayList; | ||
|
||
public class MainActivity extends AppCompatActivity implements ItemAdapter.ItemListener { | ||
|
||
|
||
BottomSheetBehavior behavior; | ||
RecyclerView recyclerView; | ||
private ItemAdapter mAdapter; | ||
CoordinatorLayout coordinatorLayout; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_main); | ||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); | ||
setSupportActionBar(toolbar); | ||
|
||
coordinatorLayout = (CoordinatorLayout) findViewById(R.id.coordinatorLayout); | ||
|
||
|
||
View bottomSheet = findViewById(R.id.bottom_sheet); | ||
behavior = BottomSheetBehavior.from(bottomSheet); | ||
behavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() { | ||
@Override | ||
public void onStateChanged(@NonNull View bottomSheet, int newState) { | ||
// React to state change | ||
} | ||
|
||
@Override | ||
public void onSlide(@NonNull View bottomSheet, float slideOffset) { | ||
// React to dragging events | ||
} | ||
}); | ||
|
||
|
||
|
||
recyclerView = (RecyclerView) findViewById(R.id.recyclerView); | ||
recyclerView.setHasFixedSize(true); | ||
recyclerView.setLayoutManager(new LinearLayoutManager(this)); | ||
|
||
|
||
ArrayList<String> items = new ArrayList<>(); | ||
items.add("Item 1"); | ||
items.add("Item 2"); | ||
items.add("Item 3"); | ||
items.add("Item 4"); | ||
items.add("Item 5"); | ||
items.add("Item 6"); | ||
|
||
mAdapter = new ItemAdapter(items, this); | ||
recyclerView.setAdapter(mAdapter); | ||
|
||
Button button = (Button) findViewById(R.id.button); | ||
|
||
button.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
behavior.setState(BottomSheetBehavior.STATE_EXPANDED); | ||
} | ||
}); | ||
|
||
} | ||
|
||
@Override | ||
public void onItemClick(String item) { | ||
|
||
Snackbar.make(coordinatorLayout,item + " is selected", Snackbar.LENGTH_LONG) | ||
.setAction("Action", null).show(); | ||
|
||
|
||
behavior.setState(BottomSheetBehavior.STATE_COLLAPSED); | ||
|
||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
Android/BottomSheet/app/src/main/res/layout/activity_main.xml
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,58 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:fitsSystemWindows="true" | ||
android:id="@+id/coordinatorLayout" | ||
tools:context="com.journaldev.bottomsheet.MainActivity"> | ||
|
||
<android.support.design.widget.AppBarLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:theme="@style/AppTheme.AppBarOverlay"> | ||
|
||
<android.support.v7.widget.Toolbar | ||
android:id="@+id/toolbar" | ||
android:layout_width="match_parent" | ||
android:layout_height="?attr/actionBarSize" | ||
android:background="?attr/colorPrimary" | ||
app:popupTheme="@style/AppTheme.PopupOverlay" /> | ||
|
||
</android.support.design.widget.AppBarLayout> | ||
|
||
<include layout="@layout/content_main" /> | ||
|
||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:fitsSystemWindows="true" | ||
android:orientation="vertical" | ||
app:behavior_hideable="true" | ||
app:behavior_peekHeight="0dp" | ||
android:id="@+id/bottom_sheet" | ||
android:background="@android:color/white" | ||
app:layout_behavior="@string/bottom_sheet_behavior"> | ||
|
||
|
||
<TextView | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="center" | ||
android:gravity="center" | ||
android:textStyle="bold" | ||
android:text="SELECT AN ITEM"/> | ||
|
||
<android.support.v7.widget.RecyclerView | ||
android:id="@+id/recyclerView" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginBottom="16dp" | ||
android:layout_marginTop="16dp" /> | ||
|
||
</LinearLayout> | ||
|
||
|
||
</android.support.design.widget.CoordinatorLayout> |
23 changes: 23 additions & 0 deletions
23
Android/BottomSheet/app/src/main/res/layout/bottom_sheet_item.xml
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 @@ | ||
<RelativeLayout android:layout_height="wrap_content" | ||
android:layout_width="match_parent" | ||
android:id="@+id/rl_car" | ||
android:padding="10dp" | ||
xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
<TextView | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:id="@+id/textView" | ||
android:textSize="16sp" | ||
android:layout_centerInParent="true"/> | ||
|
||
|
||
|
||
|
||
|
||
</RelativeLayout> | ||
|
||
|
||
|
||
|
||
|
21 changes: 21 additions & 0 deletions
21
Android/BottomSheet/app/src/main/res/layout/content_main.xml
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,21 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:paddingBottom="@dimen/activity_vertical_margin" | ||
android:paddingLeft="@dimen/activity_horizontal_margin" | ||
android:paddingRight="@dimen/activity_horizontal_margin" | ||
android:paddingTop="@dimen/activity_vertical_margin" | ||
app:layout_behavior="@string/appbar_scrolling_view_behavior" | ||
tools:context="com.journaldev.bottomsheet.MainActivity" | ||
android:background="@android:color/darker_gray" | ||
tools:showIn="@layout/activity_main"> | ||
|
||
<Button | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:id="@+id/button" | ||
android:text="Bottom sheet" /> | ||
</RelativeLayout> |
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,10 @@ | ||
<menu xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
tools:context="com.journaldev.bottomsheet.MainActivity"> | ||
<item | ||
android:id="@+id/action_settings" | ||
android:orderInCategory="100" | ||
android:title="@string/action_settings" | ||
app:showAsAction="never" /> | ||
</menu> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,9 @@ | ||
<resources> | ||
|
||
<style name="AppTheme.NoActionBar"> | ||
<item name="windowActionBar">false</item> | ||
<item name="windowNoTitle">true</item> | ||
<item name="android:windowDrawsSystemBarBackgrounds">true</item> | ||
<item name="android:statusBarColor">@android:color/transparent</item> | ||
</style> | ||
</resources> |
6 changes: 6 additions & 0 deletions
6
Android/BottomSheet/app/src/main/res/values-w820dp/dimens.xml
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,6 @@ | ||
<resources> | ||
<!-- Example customization of dimensions originally defined in res/values/dimens.xml | ||
(such as screen margins) for screens with more than 820dp of available width. This | ||
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). --> | ||
<dimen name="activity_horizontal_margin">64dp</dimen> | ||
</resources> |
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,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<color name="colorPrimary">#3F51B5</color> | ||
<color name="colorPrimaryDark">#303F9F</color> | ||
<color name="colorAccent">#FF4081</color> | ||
</resources> |
Oops, something went wrong.