-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
725eef0
commit 3247a5e
Showing
58 changed files
with
648 additions
and
133 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
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
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
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
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
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
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
34 changes: 34 additions & 0 deletions
34
app/src/main/java/com/prince/assetManagement/DeleteAssetInfo.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,34 @@ | ||
package com.prince.assetManagement; | ||
|
||
import android.os.Bundle; | ||
import android.widget.Toast; | ||
|
||
import androidx.fragment.app.Fragment; | ||
import androidx.fragment.app.FragmentActivity; | ||
import androidx.fragment.app.FragmentManager; | ||
import androidx.fragment.app.FragmentTransaction; | ||
|
||
public class DeleteAssetInfo extends FragmentActivity { | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_delete_asset_info); | ||
String selected_item = getIntent().getStringExtra("Selected Item"); | ||
Toast.makeText(this, "Selected Item is: " + selected_item, Toast.LENGTH_SHORT).show(); | ||
|
||
if (selected_item.equals("By Year")) { | ||
FragmentManager fragmentManager = getSupportFragmentManager(); | ||
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); | ||
Fragment fragment = new DeleteFragmentDepartment(); | ||
fragmentTransaction.replace(R.id.fragment_area, fragment); | ||
fragmentTransaction.commit(); | ||
} else if (selected_item.equals("By Asset Type")) { | ||
FragmentManager fragmentManager = getSupportFragmentManager(); | ||
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); | ||
Fragment fragment = new DeleteFragmentAssetType(); | ||
fragmentTransaction.replace(R.id.fragment_area, fragment); | ||
fragmentTransaction.commit(); | ||
} | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
app/src/main/java/com/prince/assetManagement/DeleteAssets.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,41 @@ | ||
package com.prince.assetManagement; | ||
|
||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.util.Log; | ||
import android.view.View; | ||
import android.widget.AdapterView; | ||
import android.widget.ArrayAdapter; | ||
import android.widget.ListView; | ||
import android.widget.Toast; | ||
|
||
import androidx.appcompat.app.AppCompatActivity; | ||
|
||
public class DeleteAssets extends AppCompatActivity { | ||
private static final String TAG = "DeleteAssets"; | ||
String items[] = {"By Asset Type", "By Year"}; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_delete_assets); | ||
|
||
ArrayAdapter<String> itemsAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, items); | ||
ListView listView = findViewById(R.id.list_item); | ||
|
||
listView.setAdapter(itemsAdapter); | ||
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { | ||
@Override | ||
public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) { | ||
String selectedItem = (String) adapterView.getItemAtPosition(position); | ||
Intent intent = new Intent(DeleteAssets.this, DeleteAssetInfo.class); | ||
intent.putExtra("Selected Item", selectedItem); | ||
startActivity(intent); | ||
|
||
Toast.makeText(DeleteAssets.this, "Selected Item is: " + selectedItem, Toast.LENGTH_SHORT).show(); | ||
Log.e(TAG, "Selected Item is: " + selectedItem); | ||
// Toast.makeText(GetAssetInfo.this, "Selected Item position is: " + position, Toast.LENGTH_SHORT).show(); | ||
} | ||
}); | ||
} | ||
} |
101 changes: 101 additions & 0 deletions
101
app/src/main/java/com/prince/assetManagement/DeleteFragmentAssetType.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,101 @@ | ||
package com.prince.assetManagement; | ||
|
||
import android.os.Bundle; | ||
import android.util.Log; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.Button; | ||
import android.widget.EditText; | ||
import android.widget.TextView; | ||
|
||
import com.google.android.gms.tasks.OnCompleteListener; | ||
import com.google.android.gms.tasks.Task; | ||
import com.google.firebase.auth.FirebaseAuth; | ||
import com.google.firebase.firestore.DocumentSnapshot; | ||
import com.google.firebase.firestore.FirebaseFirestore; | ||
import com.google.firebase.firestore.QuerySnapshot; | ||
|
||
import java.util.ArrayList; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.fragment.app.Fragment; | ||
|
||
|
||
public class DeleteFragmentAssetType extends Fragment { | ||
private static final String TAG = "DeleteFragmentAssetType"; | ||
Button get_info; | ||
EditText editText; | ||
TextView textView; | ||
FirebaseFirestore db = FirebaseFirestore.getInstance(); | ||
String user_id = FirebaseAuth.getInstance().getCurrentUser().getUid(); | ||
|
||
@Override | ||
public View onCreateView(LayoutInflater inflater, ViewGroup container, | ||
Bundle savedInstanceState) { | ||
// Inflate the layout for this fragment | ||
View view = inflater.inflate(R.layout.fragment_delete_fragment_asset_type, container, false); | ||
get_info = view.findViewById(R.id.get_info); | ||
editText = view.findViewById(R.id.asset_type); | ||
textView = view.findViewById(R.id.result); | ||
|
||
get_info.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
final String asset_type = editText.getText().toString(); | ||
final ArrayList<String> list = new ArrayList<>(); | ||
final ArrayList<String> new_list = new ArrayList<>(); | ||
db.collection("users") | ||
.document(user_id) | ||
.collection(asset_type) | ||
.get() | ||
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() { | ||
@Override | ||
public void onComplete(@NonNull Task<QuerySnapshot> task) { | ||
if (task.isSuccessful()) { | ||
int number_assets = task.getResult().size(); | ||
String str_assets = String.valueOf(number_assets); | ||
String result = "Number of such assets: " + str_assets; | ||
// textView.setText(result); | ||
Log.e(TAG, "onComplete: total assets is " + result); | ||
for (DocumentSnapshot documentSnapshot : task.getResult()) { | ||
documentSnapshot.getReference().delete(); | ||
// Log.e(TAG, "onComplete: querysnapshot is " + task.getResult().size() ); | ||
// Log.e(TAG, "onComplete: querysnapshot is " + task.getResult().getDocuments().toString() ); | ||
// Log.e(TAG, "onComplete: querysnapshot is " + task.getResult().getMetadata() ); | ||
// Log.e(TAG, "onComplete: Query snapshot " + querySnapshot.getData().toString() ); | ||
// Log.e(TAG, "onComplete: Query snapshot " + querySnapshot.getData().get("department") ); | ||
// list.add(querySnapshot.getData().get("department").toString()); | ||
} | ||
// Set<String> unique = new HashSet<>(list); | ||
// for (String key : unique) { | ||
//// String unique_result = (key + ": " + Collections.frequency(list, key)); | ||
// String unique_result = (key + ": " + Collections.frequency(list, key)); | ||
// new_list.add(unique_result); | ||
// } | ||
// for (final String dep : unique) { | ||
// Log.e(TAG, "onComplete: dep is" + dep); | ||
// Log.e(TAG, "onComplete: Inner loop is getting executed"); | ||
// db.collection("users").document(user_id) | ||
// .collection(asset_type) | ||
// .whereEqualTo("department", dep).get() | ||
// .addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() { | ||
// @Override | ||
// public void onComplete(@NonNull Task<QuerySnapshot> task) { | ||
// if (task.isSuccessful()){ | ||
// QuerySnapshot querySnapshot = task.getResult(); | ||
// } | ||
// } | ||
// }); | ||
// } | ||
} else { | ||
Log.e(TAG, "onComplete: Task is unsuccessful " + task.getException().toString()); | ||
} | ||
} | ||
}); | ||
} | ||
}); | ||
|
||
return view; | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
app/src/main/java/com/prince/assetManagement/DeleteFragmentDate.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,20 @@ | ||
package com.prince.assetManagement; | ||
|
||
import android.os.Bundle; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
|
||
import androidx.fragment.app.Fragment; | ||
|
||
|
||
public class DeleteFragmentDate extends Fragment { | ||
|
||
@Override | ||
public View onCreateView(LayoutInflater inflater, ViewGroup container, | ||
Bundle savedInstanceState) { | ||
// Inflate the layout for this fragment | ||
View view = inflater.inflate(R.layout.fragment_delete_fragment_date, container, false); | ||
return view; | ||
} | ||
} |
Oops, something went wrong.