mirror of
https://github.com/k0shk0sh/FastHub.git
synced 2026-01-25 14:47:05 +00:00
Removed banners.
This commit is contained in:
parent
eb32becc6e
commit
cf2efcd8ed
@ -1,100 +0,0 @@
|
||||
package com.fastaccess.ui.modules.profile.banner;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.widget.Button;
|
||||
|
||||
import com.fastaccess.App;
|
||||
import com.fastaccess.R;
|
||||
import com.fastaccess.helper.ActivityHelper;
|
||||
import com.fastaccess.helper.BundleConstant;
|
||||
import com.fastaccess.helper.FileHelper;
|
||||
import com.fastaccess.ui.base.BaseActivity;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.OnClick;
|
||||
import es.dmoral.toasty.Toasty;
|
||||
|
||||
/**
|
||||
* Created by JediB on 5/25/2017.
|
||||
*/
|
||||
|
||||
public class BannerInfoActivity extends BaseActivity<BannerInfoMvp.View, BannerInfoPresenter> implements BannerInfoMvp.View {
|
||||
|
||||
@BindView(R.id.imageChooser) Button imageChooser;
|
||||
|
||||
@Override protected int layout() {
|
||||
return R.layout.activity_banner_info;
|
||||
}
|
||||
|
||||
@Override protected boolean isTransparent() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override protected boolean canBack() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override protected boolean isSecured() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
@OnClick(R.id.imageChooser) void onChooseImage() {
|
||||
if (ActivityHelper.checkAndRequestReadWritePermission(this)) {
|
||||
showFileChooser();
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if (requestCode == BundleConstant.REQUEST_CODE) {
|
||||
if (resultCode == RESULT_OK) {
|
||||
String path = FileHelper.getPath(this, data.getData());
|
||||
if (path == null) {
|
||||
showMessage(R.string.error, R.string.image_error);
|
||||
return;
|
||||
}
|
||||
getPresenter().onPostImage(path);
|
||||
}
|
||||
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
if (requestCode == 1) {
|
||||
if (permissions[0].equals(Manifest.permission.READ_EXTERNAL_STORAGE)) {
|
||||
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
showFileChooser();
|
||||
} else {
|
||||
Toasty.error(App.getInstance(), getString(R.string.permission_failed)).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull @Override public BannerInfoPresenter providePresenter() {
|
||||
return new BannerInfoPresenter();
|
||||
}
|
||||
|
||||
@Override public void onFinishedUploading() {
|
||||
showMessage(R.string.success, R.string.successfully_submitted);
|
||||
setResult(RESULT_OK);
|
||||
finish();
|
||||
}
|
||||
|
||||
private void showFileChooser() {
|
||||
Intent intent = new Intent();
|
||||
intent.setType("image/*");
|
||||
intent.setAction(Intent.ACTION_GET_CONTENT);
|
||||
startActivityForResult(Intent.createChooser(intent, getString(R.string.select_picture)), BundleConstant.REQUEST_CODE);
|
||||
}
|
||||
}
|
||||
@ -1,21 +0,0 @@
|
||||
package com.fastaccess.ui.modules.profile.banner;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import com.fastaccess.ui.base.mvp.BaseMvp;
|
||||
|
||||
/**
|
||||
* Created by JediB on 5/25/2017.
|
||||
*/
|
||||
|
||||
public interface BannerInfoMvp {
|
||||
|
||||
interface View extends BaseMvp.FAView {
|
||||
void onFinishedUploading();
|
||||
}
|
||||
|
||||
interface Presenter {
|
||||
void onPostImage(@NonNull String path);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,57 +0,0 @@
|
||||
package com.fastaccess.ui.modules.profile.banner;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import com.fastaccess.ui.base.mvp.presenter.BasePresenter;
|
||||
|
||||
/**
|
||||
* Created by JediB on 5/25/2017.
|
||||
*/
|
||||
|
||||
public class BannerInfoPresenter extends BasePresenter<BannerInfoMvp.View> implements BannerInfoMvp.Presenter {
|
||||
// @NonNull private Observable<String> getHeaderGist() {
|
||||
// return RxHelper.getObserver(RestProvider.getGistService(true).getGistFile(ProfileOverviewMvp.HEADER_FST_URL));
|
||||
// }
|
||||
|
||||
@Override public void onPostImage(@NonNull String path) {
|
||||
// Login login = Login.getUser();
|
||||
// RequestBody image = RequestBody.create(MediaType.parse("image/*"), new File(path));
|
||||
// ImgurProvider.getImgurService().postImage("", image);
|
||||
// makeRestCall(RxHelper.getObserver(ImgurProvider.getImgurService().postImage("", image))
|
||||
// .filter(imgurReponseModel -> imgurReponseModel != null && imgurReponseModel.getData() != null)
|
||||
// .map(imgurReponseModel -> imgurReponseModel.getData().getLink())
|
||||
// .flatMap(link -> getHeaderGist(), (imageLink, gistContent) -> {
|
||||
// boolean isReplace = false;
|
||||
// if (gistContent.contains(login.getLogin() + "->")) {
|
||||
// String[] splitByNewLine = gistContent.split("\n");
|
||||
// for (String s : splitByNewLine) {
|
||||
// String[] splitByUser = s.split("->");
|
||||
// if (login.getLogin().equalsIgnoreCase(splitByUser[0])) {
|
||||
// gistContent = gistContent.replaceFirst(splitByUser[0] + "->" +
|
||||
// splitByUser[1], login.getLogin() + "->" + imageLink);
|
||||
// isReplace = true;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// PrefGetter.setProfileBackgroundUrl(imageLink);
|
||||
// if (!isReplace) {
|
||||
// gistContent += "\n" + login.getLogin() + "->" + imageLink;
|
||||
// }
|
||||
// return gistContent;
|
||||
// })
|
||||
// .map(s -> {
|
||||
// CreateGistModel createGistModel = new CreateGistModel();
|
||||
// createGistModel.setPublicGist(true);
|
||||
// HashMap<String, FilesListModel> modelHashMap = new HashMap<>();
|
||||
// FilesListModel file = new FilesListModel();
|
||||
// file.setFilename("header.fst");
|
||||
// file.setContent(s);
|
||||
// modelHashMap.put("header.fst", file);
|
||||
// createGistModel.setFiles(modelHashMap);
|
||||
// return createGistModel;
|
||||
// })
|
||||
// .flatMap(body -> RxHelper.getObserver(RestProvider.getGistService().editGist(body, ProfileOverviewMvp.HEADER_GIST_ID))),
|
||||
// gist -> sendToView(BannerInfoMvp.View::onFinishedUploading));
|
||||
}
|
||||
}
|
||||
@ -1,66 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout
|
||||
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"
|
||||
android:background="@color/material_light_white"
|
||||
android:orientation="vertical"
|
||||
android:theme="@style/InfoTheme"
|
||||
tools:context="com.fastaccess.ui.modules.profile.banner.BannerInfoActivity">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<android.support.design.widget.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="192dp"
|
||||
android:layout_marginBottom="@dimen/spacing_xs_large">
|
||||
|
||||
<android.support.design.widget.CollapsingToolbarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/material_blue_accent_700"
|
||||
app:expandedTitleTextAppearance="@style/TextAppearance.Design.CollapsingToolbar.Expanded.LightText"
|
||||
app:layout_scrollFlags="scroll|exitUntilCollapsed"
|
||||
app:title="@string/banners">
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
app:layout_collapseMode="pin"/>
|
||||
</android.support.design.widget.CollapsingToolbarLayout>
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingEnd="@dimen/spacing_large"
|
||||
android:paddingStart="@dimen/spacing_large">
|
||||
|
||||
<com.fastaccess.ui.widgets.FontTextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/banners_info"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<Button
|
||||
android:id="@+id/imageChooser"
|
||||
style="@style/Base.Widget.AppCompat.ButtonBar"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:padding="@dimen/spacing_xs_large"
|
||||
android:text="@string/edit_banner"/>
|
||||
|
||||
</RelativeLayout>
|
||||
Loading…
x
Reference in New Issue
Block a user