-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/banditAmit/BugBazaar into…
… vedant
- Loading branch information
Showing
12 changed files
with
358 additions
and
33 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.BugBazaar.ui.cart; | ||
|
||
import android.content.Context; | ||
import android.content.SharedPreferences; | ||
import android.view.View; | ||
|
||
|
||
public class addtimestamp { | ||
|
||
private static Context context; | ||
public static void saveCartStartTime(View.OnClickListener onClickListener, String productName) { | ||
// Save the timestamp in SharedPreferences when an item is added to the cart | ||
SharedPreferences sharedPreferences = context.getSharedPreferences("CartPrefs", Context.MODE_PRIVATE); | ||
SharedPreferences.Editor editor = sharedPreferences.edit(); | ||
long currentTimeMillis = System.currentTimeMillis(); | ||
editor.putString("productname", String.valueOf((productName))); | ||
// editor.putLong("cartStartTime", 232323); | ||
editor.apply(); | ||
} | ||
|
||
|
||
} |
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
53 changes: 53 additions & 0 deletions
53
app/src/main/java/com/BugBazaar/utils/FileDownloadWorker.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,53 @@ | ||
package com.BugBazaar.utils; | ||
|
||
import android.content.Context; | ||
import android.util.Log; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.work.Worker; | ||
import androidx.work.WorkerParameters; | ||
import androidx.work.Data; | ||
|
||
import java.io.File; | ||
import java.io.FileOutputStream; | ||
import java.io.InputStream; | ||
import java.net.HttpURLConnection; | ||
import java.net.URL; | ||
|
||
public class FileDownloadWorker extends Worker { | ||
public FileDownloadWorker(@NonNull Context context, @NonNull WorkerParameters params) { | ||
super(context, params); | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public Result doWork() { | ||
String fileUrl = getInputData().getString("FILE_URL"); | ||
try { | ||
URL url = new URL(fileUrl); | ||
HttpURLConnection connection = (HttpURLConnection) url.openConnection(); | ||
connection.connect(); | ||
|
||
File outputFile = new File(getApplicationContext().getFilesDir(), "abcd.apk"); // Modify the file name and extension as needed | ||
FileOutputStream outputStream = new FileOutputStream(outputFile); | ||
InputStream inputStream = connection.getInputStream(); | ||
|
||
byte[] data = new byte[1024]; | ||
int count; | ||
while ((count = inputStream.read(data)) != -1) { | ||
outputStream.write(data, 0, count); | ||
} | ||
|
||
outputStream.flush(); | ||
outputStream.close(); | ||
inputStream.close(); | ||
|
||
return Result.success(); | ||
} catch (Exception e) { | ||
Log.d("hello", String.valueOf(e)); | ||
|
||
e.printStackTrace(); | ||
return Result.failure(); | ||
} | ||
} | ||
} |
Oops, something went wrong.