-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPostUtils.java
More file actions
64 lines (50 loc) · 2.25 KB
/
PostUtils.java
File metadata and controls
64 lines (50 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package com.example.jeffreynyauke.myapplication.utils;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.ActivityOptionsCompat;
import android.util.Log;
import android.view.View;
import com.example.jeffreynyauke.myapplication.MainActivity;
import com.example.jeffreynyauke.myapplication.R;
import com.example.jeffreynyauke.myapplication.models.Post;
import com.example.jeffreynyauke.myapplication.services.MyDownloadService;
/**
* Created by Jeffrey Nyauke on 2/2/2017.
*/
public class PostUtils {
private static ProgressDialog mProgressDialog;
public void navigateToGameDetails(Post post, View viewToshare) {
/* Intent detailsActivityIntent = new Intent(activityContext, DetailsActivity.class);
detailsActivityIntent.putExtra(DetailsActivity.GAME_EXTRA, Parcels.wrap(game));
ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(
(Activity) activityContext, viewToshare, "sharedImage");
ActivityCompat.startActivity((Activity) activityContext, detailsActivityIntent, options.toBundle());*/
}
public static void beginDownload(String folder, String name, Context context) {
// Get path
String path = folder + name;
// Kick off MyDownloadService to download the file
Intent intent = new Intent(context, MyDownloadService.class)
.putExtra(MyDownloadService.EXTRA_DOWNLOAD_PATH, path)
.setAction(MyDownloadService.ACTION_DOWNLOAD);
context.startService(intent);
// Show loading spinner
showProgressDialog(context.getString(R.string.progress_downloading), context);
}
private static void showProgressDialog(String caption, Context context) {
if (mProgressDialog == null) {
mProgressDialog = new ProgressDialog(context);
mProgressDialog.setIndeterminate(true);
}
mProgressDialog.setMessage(caption);
mProgressDialog.show();
}
private void hideProgressDialog() {
if (mProgressDialog != null && mProgressDialog.isShowing()) {
mProgressDialog.dismiss();
}
}
}