From 3e41aa442c0039dda10316b066c4f6e4b5fc0388 Mon Sep 17 00:00:00 2001 From: vivek1826 <vivek_96@rocketmail.com> Date: Sun, 23 Apr 2017 22:42:24 +0530 Subject: [PATCH] updates --- .../example/srinivasan/database2/Float.java | 2 +- .../srinivasan/database2/RecyclerAdapter.java | 2 +- .../srinivasan/database2/SingleView.java | 47 ++++++++++++++++--- app/src/main/res/layout/activity_float.xml | 2 +- .../main/res/layout/content_single_view.xml | 37 +++++++++++++++ 5 files changed, 81 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/com/example/srinivasan/database2/Float.java b/app/src/main/java/com/example/srinivasan/database2/Float.java index 0ac48b6..91abf7c 100644 --- a/app/src/main/java/com/example/srinivasan/database2/Float.java +++ b/app/src/main/java/com/example/srinivasan/database2/Float.java @@ -51,7 +51,7 @@ public class Float extends AppCompatActivity { button=(Button)findViewById(R.id.button); databaseHelperTwo=new DatabaseHelperTwo(getApplicationContext()); - databaseHelperTwo.searchpass(); + //databaseHelperTwo.searchpass(); s=new Session(this); if (!s.loggedIn()){ diff --git a/app/src/main/java/com/example/srinivasan/database2/RecyclerAdapter.java b/app/src/main/java/com/example/srinivasan/database2/RecyclerAdapter.java index 771dab8..d44e9ee 100644 --- a/app/src/main/java/com/example/srinivasan/database2/RecyclerAdapter.java +++ b/app/src/main/java/com/example/srinivasan/database2/RecyclerAdapter.java @@ -104,7 +104,7 @@ String[] a,b,c; try { viewHolder.itemImage.setImageBitmap(bitmapArray.get(i)); }catch (IndexOutOfBoundsException e){ - + viewHolder.itemImage.setImageBitmap(null); } } diff --git a/app/src/main/java/com/example/srinivasan/database2/SingleView.java b/app/src/main/java/com/example/srinivasan/database2/SingleView.java index 7768050..0d7fa30 100644 --- a/app/src/main/java/com/example/srinivasan/database2/SingleView.java +++ b/app/src/main/java/com/example/srinivasan/database2/SingleView.java @@ -1,7 +1,9 @@ package com.example.srinivasan.database2; import android.app.ProgressDialog; +import android.content.Context; import android.content.Intent; +import android.content.SharedPreferences; import android.graphics.Bitmap; import android.os.Bundle; import android.os.Handler; @@ -11,6 +13,7 @@ import android.support.design.widget.Snackbar; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.view.View; +import android.widget.Button; import android.widget.EditText; import android.widget.ImageView; import android.widget.PopupWindow; @@ -19,12 +22,13 @@ import android.widget.TextView; import java.util.ArrayList; +import static android.R.attr.editTextStyle; import static android.R.attr.handle; -public class SingleView extends AppCompatActivity { +public class SingleView extends AppCompatActivity implements View.OnClickListener{ DatabaseHelperTwo db2; String[] date, time, query , locat; - TextView date1, time1, com1 ,location ; + TextView date1, time1, com1 ,location ,comments,typecom,butcom; ProgressBar progressBar; FloatingActionButton fab; ProgressDialog progress; @@ -32,7 +36,10 @@ public class SingleView extends AppCompatActivity { private TextView textView; PopupWindow popupWindow; private Handler handler = new Handler(); - + SharedPreferences sharedpreferences; + public static final String MyPREFERENCES = "MyPrefs" ; + public static final String textsave = null; + int position; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -42,11 +49,15 @@ public class SingleView extends AppCompatActivity { time1 = (TextView) findViewById(R.id.texttime); com1 = (TextView) findViewById(R.id.comm); location = (TextView)findViewById(R.id.location); + comments = (TextView)findViewById(R.id.comments); + typecom = (EditText)findViewById(R.id.typecom); + butcom = (Button)findViewById(R.id.butcom); + butcom.setOnClickListener(this); // Get intent data popupWindow = new PopupWindow(this); Intent i = getIntent(); // Selected image id - int position = i.getExtras().getInt("i"); + position = i.getExtras().getInt("i"); //ImageAdapter imageAdapter = new ImageAdapter(this); ArrayList<Bitmap> bitmapArray = new ArrayList<Bitmap>(); bitmapArray = db2.searchpass(); @@ -62,6 +73,12 @@ public class SingleView extends AppCompatActivity { } }); */ + sharedpreferences = getSharedPreferences("text",0); + //SharedPreferences.Editor sedt = sharedpreferences.edit(); + String newtw = sharedpreferences.getString("text",""); + + comments.setText(newtw); + ImageView imageView = (ImageView) findViewById(R.id.SingleView); //imageView.setImageResource(imageAdapter.mThumbIds[position]); imageView.setImageBitmap(bitmapArray.get(position)); @@ -71,9 +88,17 @@ public class SingleView extends AppCompatActivity { location.setText(locat[position]); } + /*public void Comment(View v){ + String a; + a = typecom.getText().toString(); + SharedPreferences.Editor editor = sharedpreferences.edit(); + editor.putString(textsave, a); + editor.commit(); + comments.append(++i + " . "+ a + "\n\n"); + } public void pro(View v) { - /* + progress = new ProgressDialog(SingleView.this); progress.setMax(100); progress.setMessage("Work on Progress"); @@ -104,7 +129,17 @@ public class SingleView extends AppCompatActivity { public void handleMessage(Message msg) { super.handleMessage(msg); progress.incrementProgressBy(1); - }*/ + } + }*/ + + @Override + public void onClick(View v) { + String a; + a = typecom.getText().toString(); + comments.append("->"+ a + "\n\n"); + SharedPreferences.Editor editor = sharedpreferences.edit(); + editor.putString("text",comments.getText().toString()); + editor.commit(); } } diff --git a/app/src/main/res/layout/activity_float.xml b/app/src/main/res/layout/activity_float.xml index 35ff7bb..6ffeb0c 100644 --- a/app/src/main/res/layout/activity_float.xml +++ b/app/src/main/res/layout/activity_float.xml @@ -14,7 +14,7 @@ <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" - android:layout_height="?attr/actionBarSize" + android:layout_height="wrap_content" android:background="?attr/colorPrimary" app:popupTheme="@style/AppTheme.PopupOverlay" /> diff --git a/app/src/main/res/layout/content_single_view.xml b/app/src/main/res/layout/content_single_view.xml index 47b2b48..4e3c952 100644 --- a/app/src/main/res/layout/content_single_view.xml +++ b/app/src/main/res/layout/content_single_view.xml @@ -141,6 +141,43 @@ android:text="Loc" android:textColor="@android:color/holo_blue_bright" android:textSize="24sp" /> + </LinearLayout> + + <LinearLayout + android:id="@+id/LinearLayout06" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_below="@+id/LinearLayout05" + android:orientation="vertical" + android:paddingTop="30dp"> + + + <TextView + android:id="@+id/textView10" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="Comments :" + android:textSize="30sp" /> + + <TextView + android:id="@+id/comments" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="20dp" + android:textSize="30sp" /> + + <EditText + android:id="@+id/typecom" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:ems="10" + android:inputType="textPersonName" /> + + <Button + android:id="@+id/butcom" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="Submit Comment" /> </LinearLayout> </RelativeLayout> </android.support.v4.widget.NestedScrollView> -- GitLab