diff --git a/app/src/main/java/com/aditya/hopon/patternsActivity.java b/app/src/main/java/com/aditya/hopon/patternsActivity.java index 5a27373..152468f 100644 --- a/app/src/main/java/com/aditya/hopon/patternsActivity.java +++ b/app/src/main/java/com/aditya/hopon/patternsActivity.java @@ -2,17 +2,32 @@ import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; +import androidx.cardview.widget.CardView; +import androidx.core.content.ContextCompat; +import androidx.core.content.res.ResourcesCompat; import androidx.cursoradapter.widget.SimpleCursorAdapter; +import androidx.transition.AutoTransition; +import androidx.transition.TransitionManager; import android.content.ContentValues; import android.content.SharedPreferences; +import android.content.res.ColorStateList; import android.database.Cursor; +import android.graphics.drawable.Drawable; import android.os.Bundle; +import android.transition.Transition; +import android.util.Log; import android.view.MenuItem; +import android.view.View; import android.widget.AdapterView; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.ListAdapter; import android.widget.ListView; import android.widget.TextView; +import org.w3c.dom.Text; + public class patternsActivity extends AppCompatActivity { private TextView toolbartitle; private DBManager dbManager; @@ -37,19 +52,126 @@ protected void onCreate(Bundle savedInstanceState) { dbManager.open(); if(firstStart){ dbManager.insert("Regular","122426182A2C",1); + dbManager.insert("Single Jumps","1214181C",2); + dbManager.insert("Multiplex","212315172A2C",1); SharedPreferences.Editor editor=sharedPreferences.edit(); editor.putBoolean("firstStart",false); editor.apply(); } Cursor cursor = dbManager.fetch(); - listView = (ListView) findViewById(R.id.patterns_list); listView.setEmptyView(findViewById(R.id.emptytextpattern)); - adapter = new SimpleCursorAdapter(this, R.layout.pattern_view_layout, cursor, from, to, 0); adapter.notifyDataSetChanged(); listView.setAdapter(adapter); + //OnCLickListener for List Items + listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView parent, View view, int position, long viewId) { + TextView idTextView = (TextView) view.findViewById(R.id.patternid); + TextView nameTextView = (TextView) view.findViewById(R.id.patternname); + TextView sequenceTextView = (TextView) view.findViewById(R.id.patternsequence); + TextView patternmode = (TextView) view.findViewById(R.id.patternmode); + ImageView patternmodeic=(ImageView)view.findViewById(R.id.patternmodeic); + String id = idTextView.getText().toString(); + String name = nameTextView.getText().toString(); + String sequence = sequenceTextView.getText().toString(); + //game mode handling + if(patternmode.getVisibility()== View.INVISIBLE){ + int mode=Integer.parseInt(patternmode.getText().toString()); + if(mode==1)patternmode.setText("Normal Mode"); + else if(mode==2){ + patternmodeic.setImageResource(R.drawable.ic_baseline_timer_24); + patternmode.setText("Timed Mode"); + } + patternmode.setVisibility(View.VISIBLE); + } + else{ + if(patternmode.getText().toString().equals("Normal Mode")){patternmode.setText("1");} + else{patternmode.setText("2");} + patternmode.setVisibility(View.INVISIBLE); + } + //game mode handling ends here + //pattern display + ImageView img1=(ImageView)view.findViewById(R.id.pattgrid1); + ImageView img2=(ImageView)view.findViewById(R.id.pattgrid2); + ImageView img3=(ImageView)view.findViewById(R.id.pattgrid3); + ImageView img4=(ImageView)view.findViewById(R.id.pattgrid4); + ImageView img5=(ImageView)view.findViewById(R.id.pattgrid5); + ImageView img6=(ImageView)view.findViewById(R.id.pattgrid6); + ImageView img7=(ImageView)view.findViewById(R.id.pattgrid7); + ImageView img8=(ImageView)view.findViewById(R.id.pattgrid8); + ImageView img9=(ImageView)view.findViewById(R.id.pattgrid9); + ImageView imgA=(ImageView)view.findViewById(R.id.pattgridA); + ImageView imgB=(ImageView)view.findViewById(R.id.pattgridB); + ImageView imgC=(ImageView)view.findViewById(R.id.pattgridC); + for(int i=0;i