Skip to content

Commit

Permalink
more animations
Browse files Browse the repository at this point in the history
  • Loading branch information
Tharyck Gusmao committed Jul 24, 2022
1 parent d5c7ee1 commit fcaa170
Show file tree
Hide file tree
Showing 36,452 changed files with 6,750,053 additions and 75 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
3 changes: 3 additions & 0 deletions android/fitnesstracker/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Fitnesstracker">
<activity
android:name=".ListCalcActivity"
android:exported="false" />
<activity
android:name=".TmbActivity"
android:exported="false" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ package com.fitnesstracker

import android.content.Context
import android.content.DialogInterface
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import android.view.Menu
import android.view.MenuItem
import android.view.inputmethod.InputMethodManager
import android.widget.Button
import android.widget.EditText
Expand Down Expand Up @@ -57,12 +60,16 @@ class ImcActivity : AppCompatActivity() {


Thread {
val databaseHandler: SqlHelper = SqlHelper(this)
val databaseHandler = SqlHelper(this)
val calcId = databaseHandler.addItem("imc", resultImc)

runOnUiThread {

if (calcId > 0) {
Toast.makeText(this, R.string.saved, Toast.LENGTH_SHORT)
Toast.makeText(this, R.string.saved, Toast.LENGTH_SHORT);
openListCalcActivity()


}

}
Expand All @@ -84,6 +91,24 @@ class ImcActivity : AppCompatActivity() {

}

override fun onCreateOptionsMenu(menu: Menu?): Boolean {
menuInflater.inflate(R.menu.menu,menu)
return super.onCreateOptionsMenu(menu)
}

override fun onOptionsItemSelected(item: MenuItem): Boolean {
if(item.itemId == R.id.nmenu_list){
openListCalcActivity();
return true
}
return super.onOptionsItemSelected(item)
}

private fun openListCalcActivity(){
val intent = Intent(this@ImcActivity,ListCalcActivity::class.java);
intent.putExtra("type","imc");
startActivity(intent)
}
@StringRes
private fun imcResponse(imc: Double): Int {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package com.fitnesstracker

import android.content.Context
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView

class ListCalcActivity : AppCompatActivity() {
lateinit var rvMain: RecyclerView;

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_list_calc_acitivy)

val extras: Bundle? = intent.extras;

if(extras != null){
val type = extras.getString("type");

val registers: List<Register> = SqlHelper(this).getRegisterBy(type);

rvMain = findViewById(R.id.recycler_view_list);
rvMain.layoutManager = LinearLayoutManager(this)
rvMain.adapter = MainAdapter(registers, this);
}
}
private class MainAdapter(
private val mainItems: List<Register>,
private val context: Context
): RecyclerView.Adapter<MainAdapter.MainViewHolder>(){
inner class MainViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {

fun bind(item: Register) {

val textView = itemView.findViewById<TextView>(R.id.title_item);
val responseView = itemView.findViewById<TextView>(R.id.title_response);
val dateView = itemView.findViewById<TextView>(R.id.title_date);
textView.text = item.type;
responseView.text = item.response.toString();
dateView.text = item.createdDate;

}

}

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MainViewHolder {
return MainViewHolder(LayoutInflater.from(context).inflate(R.layout.main_register,parent,false))
}

override fun onBindViewHolder(holder: MainViewHolder, position: Int) {
var mainItemCurrent = mainItems.get(position)
holder.bind(mainItemCurrent)
}

override fun getItemCount(): Int {
return mainItems.size
}




}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.fitnesstracker

class Register {
lateinit var type:String;
var response:Double = 0.0;
lateinit var createdDate:String;
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.fitnesstracker

import android.annotation.SuppressLint
import android.content.ContentValues
import android.content.Context
import android.database.Cursor
import android.database.sqlite.SQLiteDatabase
import android.database.sqlite.SQLiteOpenHelper
import android.util.Log
Expand Down Expand Up @@ -34,11 +36,42 @@ class SqlHelper(private val context: Context):
override fun onUpgrade(p0: SQLiteDatabase?, p1: Int, p2: Int) {
Log.d("Teste","Upgrade disparado")
}
@SuppressLint("Range")
fun getRegisterBy(type: String?):List<Register>{
val registers = arrayListOf<Register>()
val db:SQLiteDatabase = readableDatabase;

val cursor: Cursor = db.rawQuery("SELECT * FROM calc WHERE type_calc = ?", arrayOf(type))
try {

if(cursor.moveToFirst()){
do {
val register = Register();
register.type = cursor.getString(cursor.getColumnIndex("type_calc"));
register.response = cursor.getDouble(cursor.getColumnIndex("res"));
register.createdDate = cursor.getString(cursor.getColumnIndex("created_date"));

registers.add(register)

}while(cursor.moveToNext())
}

}catch(e:Exception ){
Log.e("SQLite",e.message,e)

}finally {
if(cursor != null && !cursor.isClosed){
cursor.close()
}

}
return registers
}

fun addItem(type:String,response:Double):Long{
val db:SQLiteDatabase = writableDatabase

val calcId:Long = 0;
var calcId:Long = 0;
try {
db.beginTransaction()
val values = ContentValues();
Expand All @@ -48,9 +81,8 @@ class SqlHelper(private val context: Context):
val formatDate = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale("pt","BR"))
val now = formatDate.format(Date())
values.put("created_date",now);
db.insertOrThrow("calc",null,values)
calcId = db.insertOrThrow("calc",null,values)
db.setTransactionSuccessful()

}catch (e:Exception ){
Log.e("SQLite",e.message,e)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?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=".ListCalcActivity">

<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/recycler_view_list"
tools:listitem="@layout/main_register"
tools:itemCount="5"

/>

</LinearLayout>
42 changes: 42 additions & 0 deletions android/fitnesstracker/app/src/main/res/layout/main_register.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
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="wrap_content"
android:layout_marginBottom="10dp"
>

<LinearLayout
android:id="@+id/btn_imc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:padding="10dp"
app:layout_constraintDimensionRatio="1:1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">


<TextView
android:id="@+id/title_item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/label_imc" />

<TextView
android:id="@+id/title_response"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/label_imc" />

<TextView
android:id="@+id/title_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/label_imc" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
6 changes: 6 additions & 0 deletions android/fitnesstracker/app/src/main/res/menu/menu.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/nmenu_list"
android:title="@string/buscar"
></item>
</menu>
1 change: 1 addition & 0 deletions android/fitnesstracker/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@
<string name="imc_response">Imc: %1$.2f</string>
<string name="save">Salvar</string>
<string name="saved">Salvo</string>
<string name="buscar">Buscar</string>

</resources>
1 change: 1 addition & 0 deletions react-native/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
2 changes: 1 addition & 1 deletion react-native/.prettierrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ module.exports = {
bracketSpacing: false,
jsxBracketSameLine: true,
singleQuote: true,
trailingComma: 'all',
trailingComma: 'none',
arrowParens: 'avoid',
};
Loading

0 comments on commit fcaa170

Please sign in to comment.