Removes ButterKnife annotations.

main
Vavassor 8 years ago
parent dacfbb3455
commit adfb96483a
  1. 2
      app/build.gradle
  2. 23
      app/src/main/java/com/keylesspalace/tusky/AccountActivity.java
  3. 53
      app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java
  4. 33
      app/src/main/java/com/keylesspalace/tusky/EditProfileActivity.java
  5. 20
      app/src/main/java/com/keylesspalace/tusky/LoginActivity.java
  6. 13
      app/src/main/java/com/keylesspalace/tusky/MainActivity.java
  7. 17
      app/src/main/java/com/keylesspalace/tusky/ReportActivity.java
  8. 8
      app/src/main/java/com/keylesspalace/tusky/ViewTagActivity.java
  9. 14
      app/src/main/java/com/keylesspalace/tusky/ViewVideoActivity.java
  10. 17
      app/src/main/java/com/keylesspalace/tusky/adapter/BlocksAdapter.java
  11. 20
      app/src/main/java/com/keylesspalace/tusky/adapter/FollowRequestsAdapter.java
  12. 17
      app/src/main/java/com/keylesspalace/tusky/adapter/MutesAdapter.java
  13. 13
      app/src/main/java/com/keylesspalace/tusky/fragment/ComposeOptionsFragment.java
  14. 43
      app/src/main/java/com/keylesspalace/tusky/fragment/ViewMediaFragment.java

@ -48,12 +48,10 @@ dependencies {
compile 'com.github.chrisbanes:PhotoView:2.0.0'
compile 'com.mikepenz:google-material-typeface:3.0.1.0.original@aar'
compile 'com.theartofdev.edmodo:android-image-cropper:2.4.3'
compile 'com.jakewharton:butterknife:8.5.1'
compile 'org.jsoup:jsoup:1.10.2'
compile 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.1.0'
compile('org.eclipse.paho:org.eclipse.paho.android.service:1.1.1') {
exclude module: 'support-v4'
}
testCompile 'junit:junit:4.12'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
}

@ -59,8 +59,6 @@ import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
@ -80,19 +78,24 @@ public class AccountActivity extends BaseActivity {
private boolean muting;
private boolean isSelf;
private Account loadedAccount;
@BindView(R.id.account_avatar) CircularImageView avatar;
@BindView(R.id.account_header) ImageView header;
@BindView(R.id.floating_btn) FloatingActionButton floatingBtn;
@BindView(R.id.tab_layout) TabLayout tabLayout;
@BindView(R.id.account_locked) ImageView accountLockedView;
@BindView(R.id.activity_account) View container;
private CircularImageView avatar;
private ImageView header;
private FloatingActionButton floatingBtn;
private TabLayout tabLayout;
private ImageView accountLockedView;
private View container;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_account);
ButterKnife.bind(this);
avatar = (CircularImageView) findViewById(R.id.account_avatar);
header = (ImageView) findViewById(R.id.account_header);
floatingBtn = (FloatingActionButton) findViewById(R.id.floating_btn);
tabLayout = (TabLayout) findViewById(R.id.tab_layout);
accountLockedView = (ImageView) findViewById(R.id.account_locked);
container = findViewById(R.id.activity_account);
if (savedInstanceState != null) {
accountId = savedInstanceState.getString("accountId");

@ -105,8 +105,6 @@ import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import butterknife.BindView;
import butterknife.ButterKnife;
import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
@ -129,28 +127,20 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFragm
private static final int PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE = 1;
private static final int COMPOSE_SUCCESS = -1;
private static final int THUMBNAIL_SIZE = 128; // pixels
@BindView(R.id.compose_edit_field)
EditTextTyped textEditor;
@BindView(R.id.compose_media_preview_bar)
LinearLayout mediaPreviewBar;
@BindView(R.id.compose_content_warning_bar)
View contentWarningBar;
@BindView(R.id.field_content_warning)
EditText contentWarningEditor;
@BindView(R.id.characters_left)
TextView charactersLeft;
@BindView(R.id.floating_btn)
Button floatingBtn;
@BindView(R.id.compose_photo_pick)
ImageButton pickBtn;
@BindView(R.id.compose_photo_take)
ImageButton takeBtn;
@BindView(R.id.action_hide_media)
ImageButton hideMediaToggle;
@BindView(R.id.postProgress)
ProgressBar postProgress;
@BindView(R.id.action_toggle_visibility)
ImageButton visibilityBtn;
private EditTextTyped textEditor;
private LinearLayout mediaPreviewBar;
private View contentWarningBar;
private EditText contentWarningEditor;
private TextView charactersLeft;
private Button floatingBtn;
private ImageButton pickBtn;
private ImageButton takeBtn;
private ImageButton hideMediaToggle;
private ImageButton visibilityBtn;
private ProgressBar postProgress;
// this only exists when a status is trying to be sent, but uploads are still occurring
private ProgressDialog finishingUploadDialog;
private String inReplyToId;
private ArrayList<QueuedMedia> mediaQueued;
private CountUpDownLatch waitForMediaLatch;
@ -162,8 +152,6 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFragm
private InputContentInfoCompat currentInputContentInfo;
private int currentFlags;
private Uri photoUploadUri;
// this only exists when a status is trying to be sent, but uploads are still occurring
private ProgressDialog finishingUploadDialog;
/**
* The Target object must be stored as a member field or method and cannot be an anonymous class otherwise this won't work as expected. The reason is that Picasso accepts this parameter as a weak memory reference. Because anonymous classes are eligible for garbage collection when there are no more references, the network request to fetch the image may finish after this anonymous class has already been reclaimed. See this Stack Overflow discussion for more details.
@ -175,7 +163,18 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFragm
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_compose);
ButterKnife.bind(this);
textEditor = (EditTextTyped) findViewById(R.id.compose_edit_field);
mediaPreviewBar = (LinearLayout) findViewById(R.id.compose_media_preview_bar);
contentWarningBar = findViewById(R.id.compose_content_warning_bar);
contentWarningEditor = (EditText) findViewById(R.id.field_content_warning);
charactersLeft = (TextView) findViewById(R.id.characters_left);
floatingBtn = (Button) findViewById(R.id.floating_btn);
pickBtn = (ImageButton) findViewById(R.id.compose_photo_pick);
takeBtn = (ImageButton) findViewById(R.id.compose_photo_take);
hideMediaToggle = (ImageButton) findViewById(R.id.action_hide_media);
visibilityBtn = (ImageButton) findViewById(R.id.action_toggle_visibility);
postProgress = (ProgressBar) findViewById(R.id.postProgress);
// Setup the toolbar.
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);

@ -55,8 +55,6 @@ import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
@ -77,16 +75,14 @@ public class EditProfileActivity extends BaseActivity {
HEADER
}
@BindView(R.id.edit_profile_header) ImageButton headerButton;
@BindView(R.id.edit_profile_header_preview) ImageView headerPreview;
@BindView(R.id.edit_profile_header_progress) ProgressBar headerProgress;
@BindView(R.id.edit_profile_avatar) ImageButton avatarButton;
@BindView(R.id.edit_profile_avatar_preview) ImageView avatarPreview;
@BindView(R.id.edit_profile_avatar_progress) ProgressBar avatarProgress;
@BindView(R.id.edit_profile_display_name) EditText displayNameEditText;
@BindView(R.id.edit_profile_note) EditText noteEditText;
@BindView(R.id.edit_profile_save_progress) ProgressBar saveProgress;
private ImageView headerPreview;
private ProgressBar headerProgress;
private ImageButton avatarButton;
private ImageView avatarPreview;
private ProgressBar avatarProgress;
private EditText displayNameEditText;
private EditText noteEditText;
private ProgressBar saveProgress;
private String priorDisplayName;
private String priorNote;
private boolean isAlreadySaving;
@ -98,7 +94,16 @@ public class EditProfileActivity extends BaseActivity {
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_edit_profile);
ButterKnife.bind(this);
ImageButton headerButton = (ImageButton) findViewById(R.id.edit_profile_header);
headerPreview = (ImageView) findViewById(R.id.edit_profile_header_preview);
headerProgress = (ProgressBar) findViewById(R.id.edit_profile_header_progress);
avatarButton = (ImageButton) findViewById(R.id.edit_profile_avatar);
avatarPreview = (ImageView) findViewById(R.id.edit_profile_avatar_preview);
avatarProgress = (ProgressBar) findViewById(R.id.edit_profile_avatar_progress);
displayNameEditText = (EditText) findViewById(R.id.edit_profile_display_name);
noteEditText = (EditText) findViewById(R.id.edit_profile_note);
saveProgress = (ProgressBar) findViewById(R.id.edit_profile_save_progress);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
@ -125,8 +130,6 @@ public class EditProfileActivity extends BaseActivity {
headerBase64 = null;
}
avatarButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

@ -45,8 +45,6 @@ import com.keylesspalace.tusky.util.OkHttpUtils;
import java.util.HashMap;
import java.util.Map;
import butterknife.BindView;
import butterknife.ButterKnife;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
@ -57,19 +55,14 @@ public class LoginActivity extends AppCompatActivity {
private static final String TAG = "LoginActivity"; // logging tag
private static String OAUTH_SCOPES = "read write follow";
private LinearLayout input;
private LinearLayout loading;
private EditText editText;
private SharedPreferences preferences;
private String domain;
private String clientId;
private String clientSecret;
@BindView(R.id.login_input) LinearLayout input;
@BindView(R.id.login_loading) LinearLayout loading;
@BindView(R.id.edit_text_domain) EditText editText;
@BindView(R.id.button_login) Button button;
@BindView(R.id.whats_an_instance) TextView whatsAnInstance;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ -79,7 +72,12 @@ public class LoginActivity extends AppCompatActivity {
}
setContentView(R.layout.activity_login);
ButterKnife.bind(this);
input = (LinearLayout) findViewById(R.id.login_input);
loading = (LinearLayout) findViewById(R.id.login_loading);
editText = (EditText) findViewById(R.id.edit_text_domain);
Button button = (Button) findViewById(R.id.button_login);
TextView whatsAnInstance = (TextView) findViewById(R.id.whats_an_instance);
if (savedInstanceState != null) {
domain = savedInstanceState.getString("domain");

@ -58,8 +58,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Stack;
import butterknife.BindView;
import butterknife.ButterKnife;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
@ -82,11 +80,7 @@ public class MainActivity extends BaseActivity {
private Stack<Integer> pageHistory;
private AccountHeader headerResult;
private Drawer drawer;
@BindView(R.id.floating_btn) FloatingActionButton floatingBtn;
@BindView(R.id.drawer_toggle) ImageButton drawerToggle;
@BindView(R.id.tab_layout) TabLayout tabLayout;
@BindView(R.id.pager) ViewPager viewPager;
private ViewPager viewPager;
public FloatingActionButton composeButton;
@ -103,7 +97,10 @@ public class MainActivity extends BaseActivity {
}
}
ButterKnife.bind(this);
FloatingActionButton floatingBtn = (FloatingActionButton) findViewById(R.id.floating_btn);
ImageButton drawerToggle = (ImageButton) findViewById(R.id.drawer_toggle);
TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
viewPager = (ViewPager) findViewById(R.id.pager);
floatingBtn.setOnClickListener(new View.OnClickListener() {
@Override

@ -43,6 +43,7 @@ import java.util.List;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class ReportActivity extends BaseActivity {
private static final String TAG = "ReportActivity"; // logging tag
@ -118,9 +119,9 @@ public class ReportActivity extends BaseActivity {
private void sendReport(final String accountId, final String[] statusIds,
final String comment) {
mastodonApi.report(accountId, Arrays.asList(statusIds), comment).enqueue(new Callback<ResponseBody>() {
Callback<ResponseBody> callback = new Callback<ResponseBody>() {
@Override
public void onResponse(Call<ResponseBody> call, retrofit2.Response<ResponseBody> response) {
public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
if (response.isSuccessful()) {
onSendSuccess();
} else {
@ -132,7 +133,9 @@ public class ReportActivity extends BaseActivity {
public void onFailure(Call<ResponseBody> call, Throwable t) {
onSendFailure(accountId, statusIds, comment);
}
});
};
mastodonApi.report(accountId, Arrays.asList(statusIds), comment)
.enqueue(callback);
}
private void onSendSuccess() {
@ -155,9 +158,9 @@ public class ReportActivity extends BaseActivity {
}
private void fetchRecentStatuses(String accountId) {
mastodonApi.accountStatuses(accountId, null, null, null).enqueue(new Callback<List<Status>>() {
Callback<List<Status>> callback = new Callback<List<Status>>() {
@Override
public void onResponse(Call<List<Status>> call, retrofit2.Response<List<Status>> response) {
public void onResponse(Call<List<Status>> call, Response<List<Status>> response) {
if (!response.isSuccessful()) {
onFetchStatusesFailure(new Exception(response.message()));
return;
@ -178,7 +181,9 @@ public class ReportActivity extends BaseActivity {
public void onFailure(Call<List<Status>> call, Throwable t) {
onFetchStatusesFailure((Exception) t);
}
});
};
mastodonApi.accountStatuses(accountId, null, null, null)
.enqueue(callback);
}
private void onFetchStatusesFailure(Exception exception) {

@ -25,21 +25,15 @@ import android.view.MenuItem;
import com.keylesspalace.tusky.fragment.TimelineFragment;
import butterknife.BindView;
import butterknife.ButterKnife;
public class ViewTagActivity extends BaseActivity {
@BindView(R.id.toolbar) Toolbar toolbar;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_view_tag);
ButterKnife.bind(this);
String hashtag = getIntent().getStringExtra("hashtag");
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ActionBar bar = getSupportActionBar();

@ -25,24 +25,18 @@ import android.widget.MediaController;
import android.widget.ProgressBar;
import android.widget.VideoView;
import butterknife.BindView;
import butterknife.ButterKnife;
public class ViewVideoActivity extends BaseActivity {
@BindView(R.id.video_progress) ProgressBar progressBar;
@BindView(R.id.video_player) VideoView videoView;
@BindView(R.id.toolbar) Toolbar toolbar;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_view_video);
ButterKnife.bind(this);
setSupportActionBar(toolbar);
final ProgressBar progressBar = (ProgressBar) findViewById(R.id.video_progress);
VideoView videoView = (VideoView) findViewById(R.id.video_player);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ActionBar bar = getSupportActionBar();
if (bar != null) {
bar.setTitle(null);
bar.setDisplayHomeAsUpEnabled(true);

@ -28,9 +28,6 @@ import com.keylesspalace.tusky.interfaces.AccountActionListener;
import com.pkmmte.view.CircularImageView;
import com.squareup.picasso.Picasso;
import butterknife.BindView;
import butterknife.ButterKnife;
public class BlocksAdapter extends AccountAdapter {
private static final int VIEW_TYPE_BLOCKED_USER = 0;
private static final int VIEW_TYPE_FOOTER = 1;
@ -75,16 +72,18 @@ public class BlocksAdapter extends AccountAdapter {
}
static class BlockedUserViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.blocked_user_avatar) CircularImageView avatar;
@BindView(R.id.blocked_user_username) TextView username;
@BindView(R.id.blocked_user_display_name) TextView displayName;
@BindView(R.id.blocked_user_unblock) ImageButton unblock;
private CircularImageView avatar;
private TextView username;
private TextView displayName;
private ImageButton unblock;
private String id;
BlockedUserViewHolder(View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
avatar = (CircularImageView) itemView.findViewById(R.id.blocked_user_avatar);
username = (TextView) itemView.findViewById(R.id.blocked_user_username);
displayName = (TextView) itemView.findViewById(R.id.blocked_user_display_name);
unblock = (ImageButton) itemView.findViewById(R.id.blocked_user_unblock);
}
void setupWithAccount(Account account) {

@ -28,9 +28,6 @@ import com.keylesspalace.tusky.entity.Account;
import com.pkmmte.view.CircularImageView;
import com.squareup.picasso.Picasso;
import butterknife.BindView;
import butterknife.ButterKnife;
public class FollowRequestsAdapter extends AccountAdapter {
private static final int VIEW_TYPE_FOLLOW_REQUEST = 0;
private static final int VIEW_TYPE_FOOTER = 1;
@ -75,17 +72,20 @@ public class FollowRequestsAdapter extends AccountAdapter {
}
static class FollowRequestViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.follow_request_avatar) CircularImageView avatar;
@BindView(R.id.follow_request_username) TextView username;
@BindView(R.id.follow_request_display_name) TextView displayName;
@BindView(R.id.follow_request_accept) ImageButton accept;
@BindView(R.id.follow_request_reject) ImageButton reject;
private CircularImageView avatar;
private TextView username;
private TextView displayName;
private ImageButton accept;
private ImageButton reject;
private String id;
FollowRequestViewHolder(View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
avatar = (CircularImageView) itemView.findViewById(R.id.follow_request_avatar);
username = (TextView) itemView.findViewById(R.id.follow_request_username);
displayName = (TextView) itemView.findViewById(R.id.follow_request_display_name);
accept = (ImageButton) itemView.findViewById(R.id.follow_request_accept);
reject = (ImageButton) itemView.findViewById(R.id.follow_request_reject);
}
void setupWithAccount(Account account) {

@ -13,9 +13,6 @@ import com.keylesspalace.tusky.interfaces.AccountActionListener;
import com.pkmmte.view.CircularImageView;
import com.squareup.picasso.Picasso;
import butterknife.BindView;
import butterknife.ButterKnife;
public class MutesAdapter extends AccountAdapter {
private static final int VIEW_TYPE_MUTED_USER = 0;
private static final int VIEW_TYPE_FOOTER = 1;
@ -60,16 +57,18 @@ public class MutesAdapter extends AccountAdapter {
}
static class MutedUserViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.muted_user_avatar) CircularImageView avatar;
@BindView(R.id.muted_user_username) TextView username;
@BindView(R.id.muted_user_display_name) TextView displayName;
@BindView(R.id.muted_user_unmute) ImageButton unmute;
private CircularImageView avatar;
private TextView username;
private TextView displayName;
private ImageButton unmute;
private String id;
MutedUserViewHolder(View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
avatar = (CircularImageView) itemView.findViewById(R.id.muted_user_avatar);
username = (TextView) itemView.findViewById(R.id.muted_user_username);
displayName = (TextView) itemView.findViewById(R.id.muted_user_display_name);
unmute = (ImageButton) itemView.findViewById(R.id.muted_user_unmute);
}
void setupWithAccount(Account account) {

@ -82,14 +82,11 @@ public class ComposeOptionsFragment extends BottomSheetDialogFragment {
radioCheckedId = R.id.radio_unlisted;
}
if (statusVisibility != null) {
if (statusVisibility.equals("public")) {
radioCheckedId = R.id.radio_public;
} else if (statusVisibility.equals("private")) {
radioCheckedId = R.id.radio_private;
} else if (statusVisibility.equals("unlisted")) {
radioCheckedId = R.id.radio_unlisted;
} else if (statusVisibility.equals("direct")) {
radioCheckedId = R.id.radio_direct;
switch (statusVisibility) {
case "public": radioCheckedId = R.id.radio_public; break;
case "private": radioCheckedId = R.id.radio_private; break;
case "unlisted": radioCheckedId = R.id.radio_unlisted; break;
case "direct": radioCheckedId = R.id.radio_direct; break;
}
}
radio.check(radioCheckedId);

@ -15,6 +15,7 @@
package com.keylesspalace.tusky.fragment;
import android.Manifest;
import android.app.DownloadManager;
import android.content.Context;
import android.content.pm.PackageManager;
@ -26,6 +27,7 @@ import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.StringRes;
import android.support.design.widget.Snackbar;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.DialogFragment;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.Toolbar;
@ -47,21 +49,11 @@ import com.squareup.picasso.Picasso;
import java.io.File;
import butterknife.BindView;
import butterknife.ButterKnife;
public class ViewMediaFragment extends DialogFragment implements Toolbar.OnMenuItemClickListener {
private PhotoViewAttacher attacher;
private static final int PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE = 1;
@BindView(R.id.view_media_image)
PhotoView photoView;
@BindView(R.id.toolbar)
Toolbar toolbar;
public static ViewMediaFragment newInstance(String url) {
Bundle arguments = new Bundle();
ViewMediaFragment fragment = new ViewMediaFragment();
@ -89,7 +81,9 @@ public class ViewMediaFragment extends DialogFragment implements Toolbar.OnMenuI
public View onCreateView(LayoutInflater inflater, final ViewGroup container,
Bundle savedInstanceState) {
final View rootView = inflater.inflate(R.layout.fragment_view_media, container, false);
ButterKnife.bind(this, rootView);
final Toolbar toolbar = (Toolbar) rootView.findViewById(R.id.toolbar);
PhotoView photoView = (PhotoView) rootView.findViewById(R.id.view_media_image);
Bundle arguments = getArguments();
String url = arguments.getString("url");
@ -138,37 +132,34 @@ public class ViewMediaFragment extends DialogFragment implements Toolbar.OnMenuI
}
@Override
public void onError() {
}
public void onError() {}
});
return rootView;
}
private void downloadImage(){
private void downloadImage() {
//Permission stuff
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN &&
ContextCompat.checkSelfPermission(this.getContext(), android.Manifest.permission.WRITE_EXTERNAL_STORAGE)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN
&& ContextCompat.checkSelfPermission(getContext(), Manifest.permission.WRITE_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED) {
android.support.v4.app.ActivityCompat.requestPermissions(getActivity(),
new String[] { android.Manifest.permission.WRITE_EXTERNAL_STORAGE },
ActivityCompat.requestPermissions(getActivity(),
new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE },
PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE);
} else {
//download stuff
String url = getArguments().getString("url");
Uri uri = Uri.parse(url);
String filename = new File(url).getName();
DownloadManager downloadManager = (DownloadManager) getContext().getSystemService(Context.DOWNLOAD_SERVICE);
DownloadManager downloadManager = (DownloadManager) getContext()
.getSystemService(Context.DOWNLOAD_SERVICE);
DownloadManager.Request request = new DownloadManager.Request(uri);
request.allowScanningByMediaScanner();
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_PICTURES, getString(R.string.app_name) + "/" + filename);
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_PICTURES,
getString(R.string.app_name) + "/" + filename);
downloadManager.enqueue(request);
}
@ -197,8 +188,8 @@ public class ViewMediaFragment extends DialogFragment implements Toolbar.OnMenuI
}
private void doErrorDialog(@StringRes int descriptionId, @StringRes int actionId,
View.OnClickListener listener) {
if(getView() != null) {
View.OnClickListener listener) {
if (getView() != null) {
Snackbar bar = Snackbar.make(getView(), getString(descriptionId),
Snackbar.LENGTH_SHORT);
bar.setAction(actionId, listener);

Loading…
Cancel
Save