Skip to content

Commit

Permalink
Merge pull request #35 from ShivamTaneja/master
Browse files Browse the repository at this point in the history
Added onClickListener to cards
  • Loading branch information
ShivamTaneja authored Apr 30, 2018
2 parents 0b02d77 + 5bec616 commit 9d5c828
Show file tree
Hide file tree
Showing 16 changed files with 291 additions and 20 deletions.
Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
2 changes: 1 addition & 1 deletion .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

apply plugin: 'com.android.application'

android {
Expand Down
27 changes: 18 additions & 9 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.dhananjay.dailygoals">

<uses-permission android:name="com.android.alarm.permission.SET_ALARM" />

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
Expand All @@ -16,13 +18,20 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".WelcomeScreenActivity"
android:theme="@style/WelcomeScreenTheme"
android:screenOrientation="portrait"/>
<activity android:name=".TodayActivity"></activity>
<activity android:name=".PopupActivity"
android:theme="@style/AppTheme.CustomTheme"></activity>
<receiver android:name=".NotificationActivity"></receiver>
<activity
android:name=".WelcomeScreenActivity"
android:screenOrientation="portrait"
android:theme="@style/WelcomeScreenTheme" />
<activity android:name=".TodayActivity" />
<activity
android:name=".PopupActivity"
android:theme="@style/AppTheme.CustomTheme" />

<receiver android:name=".NotificationActivity" />

<activity android:name=".Goals_Completed" />
<activity android:name=".Goals_Missed" />
<activity android:name=".Achievements"></activity>
</application>
<uses-permission android:name="com.android.alarm.permission.SET_ALARM"></uses-permission>
</manifest>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.example.dhananjay.dailygoals;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class Achievements extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_achievements);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.example.dhananjay.dailygoals;


import android.view.View;

public interface ClickListener{
public void onClick(View view, int position);
public void onLongClick(View view,int position);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.example.dhananjay.dailygoals;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class Goals_Completed extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_goals__completed);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.example.dhananjay.dailygoals;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class Goals_Missed extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_goals__missed);
}
}
115 changes: 115 additions & 0 deletions app/src/main/java/com/example/dhananjay/dailygoals/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package com.example.dhananjay.dailygoals;

import android.content.Context;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.content.Intent;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Toast;

import com.stephentuso.welcome.WelcomeHelper;

Expand Down Expand Up @@ -50,21 +54,25 @@ protected void onCreate(Bundle savedInstanceState) {
item2List.add(new Items2(R.drawable.tick));
item2List.add(new Items2(R.drawable.wrong));
item3List.add(new Items3(R.drawable.achievements));

LinearLayoutManager layoutmanager=new LinearLayoutManager(this,LinearLayoutManager.HORIZONTAL,false);
RecyclerView.LayoutManager rvlayoutmanager=layoutmanager;
recyclerView.setLayoutManager(rvlayoutmanager);
TextAdapter adapter=new TextAdapter(this,itemList);
recyclerView.setAdapter(adapter);

LinearLayoutManager layoutmanager1=new LinearLayoutManager(this,LinearLayoutManager.HORIZONTAL,false);
RecyclerView.LayoutManager rvlayoutmanager1=layoutmanager1;
recyclerView1.setLayoutManager(rvlayoutmanager1);
TextAdapter1 adapter1=new TextAdapter1(this,item1List);
recyclerView1.setAdapter(adapter1);

LinearLayoutManager layoutmanager2=new LinearLayoutManager(this,LinearLayoutManager.HORIZONTAL,false);
RecyclerView.LayoutManager rvlayoutmanager2=layoutmanager2;
recyclerView2.setLayoutManager(rvlayoutmanager2);
TextAdapter2 adapter2=new TextAdapter2(this,item2List);
recyclerView2.setAdapter(adapter2);

LinearLayoutManager layoutmanager3=new LinearLayoutManager(this,LinearLayoutManager.HORIZONTAL,false);
RecyclerView.LayoutManager rvlayoutmanager3=layoutmanager3;
recyclerView3.setLayoutManager(rvlayoutmanager3);
Expand All @@ -78,11 +86,118 @@ public void onItemClicked(RecyclerView recyclerView, int position, View v) {
}
} );





recyclerView2.addOnItemTouchListener(new RecyclerTouchListener(this,
recyclerView2, new ClickListener() {
@Override
public void onClick(View view, final int position) {
//Values are passing to activity & to fragment as well


if(position == 0)
{
Intent intent = new Intent(getApplicationContext(), Goals_Completed.class);
startActivity(intent);
}
if(position == 1)
{
Intent intent = new Intent(getApplicationContext(), Goals_Missed.class);
startActivity(intent);
}

}
@Override
public void onLongClick(View view, int position) {

if(position == 0)
{
Toast.makeText(getApplicationContext(), "Daily Goals Completed by You",
Toast.LENGTH_SHORT).show();
}
if(position == 1)
{
Toast.makeText(getApplicationContext(), "Daily Goals Missed by You",
Toast.LENGTH_SHORT).show();
}
}
}));
recyclerView3.addOnItemTouchListener(new RecyclerTouchListener(this,
recyclerView3, new ClickListener() {
@Override
public void onClick(View view, final int position) {
//Values are passing to activity & to fragment as well



Intent intent = new Intent(getApplicationContext(), Achievements.class);
startActivity(intent);


}
@Override
public void onLongClick(View view, int position) {


Toast.makeText(getApplicationContext(), "Your Achievements",
Toast.LENGTH_SHORT).show();

}
}));

// Show the welcome screen
welcomeScreen = new WelcomeHelper(this, WelcomeScreenActivity.class);
welcomeScreen.show(savedInstanceState);
}


class RecyclerTouchListener implements RecyclerView.OnItemTouchListener{

private ClickListener clicklistener;
private GestureDetector gestureDetector;

public RecyclerTouchListener(Context context, final RecyclerView recycleView, final ClickListener clicklistener){

this.clicklistener=clicklistener;
gestureDetector=new GestureDetector(context,new GestureDetector.SimpleOnGestureListener(){
@Override
public boolean onSingleTapUp(MotionEvent e) {
return true;
}

@Override
public void onLongPress(MotionEvent e) {
View child=recycleView.findChildViewUnder(e.getX(),e.getY());
if(child!=null && clicklistener!=null){
clicklistener.onLongClick(child,recycleView.getChildAdapterPosition(child));
}
}
});
}

@Override
public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {
View child=rv.findChildViewUnder(e.getX(),e.getY());
if(child!=null && clicklistener!=null && gestureDetector.onTouchEvent(e)){
clicklistener.onClick(child,rv.getChildAdapterPosition(child));
}

return false;
}

@Override
public void onTouchEvent(RecyclerView rv, MotionEvent e) {

}

@Override
public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {

}
}

@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
Expand Down
35 changes: 35 additions & 0 deletions app/src/main/res/layout/activity_achievements.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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"
tools:context=".Achievements"
android:orientation="vertical"
android:background="#E0F2F1"
>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/your_achievements"
android:textSize="30sp"
android:layout_gravity="center"
android:textStyle="bold"
/>

<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/linearlayout_achievements"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#80CBC4"
>

</LinearLayout>
</ScrollView>
</LinearLayout>
33 changes: 33 additions & 0 deletions app/src/main/res/layout/activity_goals__completed.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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"
tools:context=".Goals_Completed"
android:orientation="vertical"
android:background="#E1F5FE"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/goals_completed"
android:textSize="30sp"
android:layout_gravity="center"
android:textStyle="bold"
/>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/linearlayout_goals_completed"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#81D4FA"
>

</LinearLayout>
</ScrollView>
</LinearLayout>
33 changes: 33 additions & 0 deletions app/src/main/res/layout/activity_goals__missed.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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"
tools:context=".Goals_Missed"
android:orientation="vertical"
android:background="#E0F7FA">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/goals_missed"
android:textSize="30sp"
android:layout_gravity="center"
android:textStyle="bold"
/>

<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/linearlayout_goals_missed"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#80DEEA" >

</LinearLayout>
</ScrollView>
</LinearLayout>
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,7 @@
<string name="description_performance">
View your performance in terms of stunning Pie charts!
</string>
<string name="goals_missed">GOALS MISSED</string>
<string name="goals_completed">GOALS COMPLETED</string>
<string name="your_achievements">YOUR ACHIEVEMENTS</string>
</resources>
Loading

0 comments on commit 9d5c828

Please sign in to comment.