Skip to content
Permalink
Browse files

Henna adding fragment

  • Loading branch information...
Roman Tronenko
Roman Tronenko committed Feb 27, 2017
1 parent 12f218d commit 0d7dcc0fb5297627682d4c5951ca09177b983e70
@@ -82,6 +82,18 @@ public void onClick(View v) {
}
});

newHenna.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
animateFAB();
getSupportFragmentManager().beginTransaction()
.addToBackStack("xyz")
.hide(getSupportFragmentManager().findFragmentByTag("welcome"))
.add(R.id.fragment_container, new NewHennaFragment(), "new henna")
.commit();
}
});

}

public void animateFAB() {
@@ -143,4 +155,21 @@ public boolean onOptionsItemSelected(MenuItem item) {

return super.onOptionsItemSelected(item);
}

@Override
public void onBackPressed() {

if (isFabOpen) {
animateFAB();
} else {
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
animateFAB();
}
});

super.onBackPressed();
}
}
}
@@ -15,6 +15,7 @@
import java.util.Date;

import okhttp3.OkHttpClient;
import tattoo.gogo.app.gogo_android.model.Design;

import static android.view.View.GONE;

@@ -0,0 +1,167 @@
package tattoo.gogo.app.gogo_android;

import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;

import com.moandjiezana.toml.TomlWriter;

import java.util.Calendar;
import java.util.Date;

import okhttp3.OkHttpClient;
import tattoo.gogo.app.gogo_android.model.Henna;

import static android.view.View.GONE;

/**
* Created by delirium on 2/22/17.
*/
public class NewHennaFragment extends NewWorkFragment {

private Henna mHenna;


@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mHenna = new Henna();
populateWithDelay(etAuthor, mTattooArtist, 600);
populateWithDelay(etMadeAt, mHenna.getMade_at_shop(), 1000);
String dateToday = watermarkDateFormat.format(new Date());
populateWithDelay(etMadeDate, dateToday, 1400);
populateWithDelay(etTimeDuration, String.valueOf(mHenna.getDuration_min()), 400);
populateWithDelay(etMadeCity, String.valueOf(mHenna.getLocation_city()), 200);
populateWithDelay(etMadeCountry, String.valueOf(mHenna.getLocation_country()), 700);

tetTags.setTags(mHenna.getTags());
tetBodyParts.setTags(mHenna.getBodypart());

setListeners();

btnFemale.performClick();
etTitle.requestFocus();

client = new OkHttpClient();
}

private void setListeners() {

btnFemale.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
btnFemale.setTextColor(ContextCompat.getColor(getContext(), R.color.colorPrimaryDark));
btnMale.setTextColor(Color.GRAY);
mHenna.setGender("female");
}
});

btnMale.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
btnMale.setTextColor(ContextCompat.getColor(getContext(), R.color.colorPrimaryDark));
btnFemale.setTextColor(Color.GRAY);
mHenna.setGender("male");
}
});

etAuthor.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {

}

@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {

}

@Override
public void afterTextChanged(Editable authorName) {
mTattooArtist = authorName.toString().trim();
updateLink();
}
});
etTitle.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {

}

@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {

}

@Override
public void afterTextChanged(Editable tattooTitle) {
mHenna.setTitle(tattooTitle.toString().trim());
updateLink();


handler.removeCallbacks(workRunnable);
workRunnable = new Runnable() {
@Override
public void run() {
if (mHenna.getTitle().length() < 4 || mTattooArtist.isEmpty()) {
ivQRgogo.setVisibility(GONE);
ivQRgithub.setVisibility(GONE);
tvGogoLink.setVisibility(GONE);
tvGithubLink.setVisibility(GONE);
return;
}
updateQRcodes();
testLink();
}
};
handler.postDelayed(workRunnable, 1500 /*delay*/);

}
});

((MainActivity) getActivity()).getFloatingActionButton().setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mHenna.setTattoodate(sdf.format(new Date()));
long t = Calendar.getInstance().getTimeInMillis();
mHenna.setDate(sdf.format(new Date(t + (mHenna.getDuration_min() * ONE_MINUTE_IN_MILLIS))));
mHenna.setBodypart(tetBodyParts.getTags().toArray(new String[0]));
mHenna.setTags(tetTags.getTags().toArray(new String[0]));
mHenna.setLink(makeLink(MAIN_URL));
sendForApprovalToPublish();
}
});
}


private void sendForApprovalToPublish() {
if (!isAdded()) {
return;
}
TomlWriter tomlWriter = new TomlWriter();
String tomlString = tomlWriter.write(mHenna);

Intent sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
sharingIntent.putExtra(Intent.EXTRA_SUBJECT, mHenna.getTitle());
sharingIntent.putExtra(Intent.EXTRA_TEXT, tomlString);
startActivity(Intent.createChooser(sharingIntent, getResources().getString(R.string.share_to)));

}



protected String makeLink(String mainUrl) {
String tattooTitleLinkified = mHenna.getTitle().toLowerCase().replace(" ", "_");
return mainUrl + mTattooArtist.toLowerCase() + "/henna/" + tattooTitleLinkified;
}
@Override
protected int getLayout() {
return R.layout.fragment_new_henna;
}
}
@@ -1,44 +1,22 @@
package tattoo.gogo.app.gogo_android;

import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.support.v4.content.FileProvider;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.moandjiezana.toml.TomlWriter;

import net.glxn.qrgen.android.QRCode;
import net.glxn.qrgen.core.image.ImageType;

import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

import butterknife.BindView;
import butterknife.ButterKnife;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import tattoo.gogo.app.gogo_android.model.Henna;
import tattoo.gogo.app.gogo_android.model.Piercing;

import static android.view.View.GONE;

@@ -40,6 +40,7 @@
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import tattoo.gogo.app.gogo_android.model.Tattoo;

import static android.view.View.GONE;

@@ -1,4 +1,4 @@
package tattoo.gogo.app.gogo_android;
package tattoo.gogo.app.gogo_android.model;

import java.util.ArrayList;

@@ -0,0 +1,15 @@
package tattoo.gogo.app.gogo_android.model;

import java.util.ArrayList;

/**
* Created by delirium on 2/24/17.
*/

public class Henna extends Project {

public void Henna() {
link = "gogo/henna";
}

}
@@ -0,0 +1,15 @@
package tattoo.gogo.app.gogo_android.model;

import java.util.ArrayList;

/**
* Created by delirium on 2/24/17.
*/

public class Piercing extends Project {

public void Piercing() {
link = "gogo/piercing/";
}

}
@@ -1,24 +1,24 @@
package tattoo.gogo.app.gogo_android;
package tattoo.gogo.app.gogo_android.model;

import java.util.ArrayList;

/**
* Created by delirium on 2/24/17.
* Created by delirium on 2/26/17.
*/

public class Piercing {
public class Project {

String link = "gogo/piercing/";
String link = "gogo/";
String title = "";
String tattoodate = "2017-02-25T20:01:06+03:00";
String made_date = "2017-02-25T20:01:06+03:00";
String date = "2017-02-25T20:01:06+03:00";
String []tags = {"sharp"};
String [] tags = {"sharp"};
String [] bodypart = {"nose", "lip", "ear"};
String image_ipfs = "";
ArrayList<String> images_ipfs = new ArrayList<>();
String location_country = "China";
String location_city = "Shanghai";
String made_at_shop = "chushangfeng";
String made_at = "chushangfeng";
int duration_min = 30;
String gender = "female";
String extra = "";
@@ -40,11 +40,11 @@ public void setLink(String link) {
}

public String getTattoodate() {
return tattoodate;
return made_date;
}

public void setTattoodate(String tattoodate) {
this.tattoodate = tattoodate;
this.made_date = tattoodate;
}

public String getDate() {
@@ -104,11 +104,11 @@ public void setLocation_city(String location_city) {
}

public String getMade_at_shop() {
return made_at_shop;
return made_at;
}

public void setMade_at_shop(String made_at_shop) {
this.made_at_shop = made_at_shop;
this.made_at = made_at_shop;
}

public int getDuration_min() {
@@ -134,5 +134,4 @@ public String getExtra() {
public void setExtra(String extra) {
this.extra = extra;
}

}
@@ -1,4 +1,4 @@
package tattoo.gogo.app.gogo_android;
package tattoo.gogo.app.gogo_android.model;

import java.util.ArrayList;

0 comments on commit 0d7dcc0

Please sign in to comment.
You can’t perform that action at this time.