Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.content.Context;
import android.content.SharedPreferences;
import android.util.Log;

import com.google.gson.Gson;
import com.hapramp.main.HapRampMain;
Expand Down Expand Up @@ -182,7 +183,8 @@ public void saveCurrentUserFollowings(ArrayList<String> followings) {
Set<String> set = new HashSet<String>();
set.addAll(followings);
editor.putStringSet("followings", set);
editor.apply();
editor.commit();
Log.d("UserInfo","saving followings "+set.toString());
}

public Set<String> getFollowingsSet() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import android.text.style.ForegroundColorSpan;
import android.text.style.StyleSpan;
import android.view.View;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.RelativeLayout;
Expand Down Expand Up @@ -103,6 +104,9 @@ public class ParticipateEditorActivity extends AppCompatActivity implements Edit
TextView submissionInfo;
@BindView(R.id.auto_hashtags_text)
TextView autoHashtagsText;
@BindView(R.id.attach_link_check)
CheckBox attachLinkCheckBox;

private ProgressDialog progressDialog;
private String title;
private String generated_permalink;
Expand Down Expand Up @@ -307,6 +311,11 @@ private void sendPostToSteemBlockChain() {
showPublishingProgressDialog(true, "Publishing...");
SteemPostCreator steemPostCreator = new SteemPostCreator();
steemPostCreator.setSteemPostCreatorCallback(this);
if(attachLinkCheckBox.isChecked()) {
//add competition link
String url = String.format(getString(R.string.contest_structure), mCompetitionTitle, mCompetitionId);
body = body + url;
}
//add footer
body = body + Constants.COMPETITION_FOOTER;
steemPostCreator.createPost(body, title, imageLinks, tags, generated_permalink);
Expand Down
106 changes: 37 additions & 69 deletions app/src/main/java/com/hapramp/ui/fragments/UserInfoFragment.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package com.hapramp.ui.fragments;

import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.app.AlertDialog;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand All @@ -30,7 +30,6 @@
import com.hapramp.datastore.callbacks.UserProfileCallback;
import com.hapramp.models.AppServerUserModel;
import com.hapramp.models.CommunityModel;
import com.hapramp.models.MicroCommunity;
import com.hapramp.preferences.HaprampPreferenceManager;
import com.hapramp.steem.CommunityListWrapper;
import com.hapramp.steem.models.User;
Expand Down Expand Up @@ -66,7 +65,8 @@
import static com.hapramp.ui.activity.FollowListActivity.EXTRA_KEY_TAB_INDEX;
import static com.hapramp.ui.activity.FollowListActivity.EXTRA_KEY_USERNAME;

public class UserInfoFragment extends Fragment implements FollowInfoCallback, UserProfileCallback, CompleteFollowingHelper.FollowingsSyncCompleteListener {
public class UserInfoFragment extends Fragment implements FollowInfoCallback, UserProfileCallback,
CompleteFollowingHelper.FollowingsSyncCompleteListener {
Unbinder unbinder;
@BindView(R.id.profile_wall_pic)
ImageView profileWallPic;
Expand Down Expand Up @@ -147,7 +147,8 @@ public void onCreate(@Nullable Bundle savedInstanceState) {

@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.user_info_fragment, null);
unbinder = ButterKnife.bind(this, view);
init(mContext);
Expand All @@ -172,32 +173,18 @@ private void init(Context context) {
}
}


private void attachListeners() {
followBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (isFollowed) {
confirmUnfollowAction();
} else {
requestFollowOnSteem();
}
followBtn.setOnClickListener(v -> {
if (isFollowed) {
confirmUnfollowAction();
} else {
requestFollowOnSteem();
}
});

followersCountTv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
navigateToFollowersListPage();
}
});
followersCountTv.setOnClickListener(view -> navigateToFollowersListPage());

followingsCountTv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
navigateToFollowingListPage();
}
});
followingsCountTv.setOnClickListener(view -> navigateToFollowingListPage());
}

private void fetchUserInfo() {
Expand All @@ -209,12 +196,7 @@ private void confirmUnfollowAction() {
AlertDialog.Builder builder = new AlertDialog.Builder(mContext)
.setTitle("Unfollow")
.setMessage("Do you want to Unfollow " + mUsername + " ?")
.setPositiveButton("UnFollow", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
requestUnFollowOnSteem();
}
})
.setPositiveButton("UnFollow", (dialog, which) -> requestUnFollowOnSteem())
.setNegativeButton("No", null);
builder.show();
}
Expand All @@ -230,23 +212,17 @@ public void run() {
new SteemConnectCallback() {
@Override
public void onResponse(String s) {
mHandler.post(new Runnable() {
@Override
public void run() {
showFollowProgress(false);
userFollowedOnSteem();
}
mHandler.post(() -> {
showFollowProgress(false);
userFollowedOnSteem();
});
}

@Override
public void onError(SteemConnectException e) {
mHandler.post(new Runnable() {
@Override
public void run() {
showFollowProgress(false);
userFollowFailed();
}
mHandler.post(() -> {
showFollowProgress(false);
userFollowFailed();
});
}
}
Expand Down Expand Up @@ -292,23 +268,17 @@ public void run() {
new SteemConnectCallback() {
@Override
public void onResponse(String s) {
mHandler.post(new Runnable() {
@Override
public void run() {
showFollowProgress(false);
userUnFollowedOnSteem();
}
mHandler.post(() -> {
showFollowProgress(false);
userUnFollowedOnSteem();
});
}

@Override
public void onError(SteemConnectException e) {
mHandler.post(new Runnable() {
@Override
public void run() {
showFollowProgress(false);
userUnfollowFailed();
}
mHandler.post(() -> {
showFollowProgress(false);
userUnfollowFailed();
});
}
}
Expand Down Expand Up @@ -371,6 +341,7 @@ private void userUnfollowFailed() {
}

private void setFollowState(boolean state) {
Log.d("UserInfo", "setting follow " + state);
try { // to avoid dead view access
if (state) {
followBtn.setText(TICK_TEXT + " Following");
Expand All @@ -386,7 +357,10 @@ private void setFollowState(boolean state) {
}

private void syncFollowings() {
FollowingsSyncUtils.syncFollowings(mContext, this);
new Handler().postDelayed(() -> {
Log.d("UserInfo","firing fetch...");
FollowingsSyncUtils.syncFollowings(mContext, this);
}, 10000);
}

private void t(String s) {
Expand Down Expand Up @@ -438,12 +412,7 @@ private void bind(User data) {
followBtn.setVisibility(GONE);
editBtn.setVisibility(VISIBLE);
editBtn.setEnabled(true);
editBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
navigateToProfileEditActivity();
}
});
editBtn.setOnClickListener(view -> navigateToProfileEditActivity());
CommunityListWrapper listWrapper = new Gson().fromJson(HaprampPreferenceManager
.getInstance().getUserSelectedCommunityAsJson(), CommunityListWrapper.class);
if (interestsView != null) {
Expand Down Expand Up @@ -495,6 +464,8 @@ private void invalidateFollowButton() {
if (followBtn != null) {
followBtn.setVisibility(VISIBLE);
}
Log.d("UserInfo", "New Following set " + followings.toString());
Log.d("UserInfo", "invalidating follow=" + followings.contains(mUsername));
setFollowState(followings.contains(mUsername));
} else {
if (followBtn != null) {
Expand Down Expand Up @@ -554,7 +525,7 @@ private void setMCData(AppServerUserModel userModel) {
if (userModel != null) {
mcView.setMicroCommunityList(userModel.getMicroCommunities());
} else {
mcView.setMicroCommunityList(new ArrayList<MicroCommunity>());
mcView.setMicroCommunityList(new ArrayList<>());
}
}
}
Expand All @@ -578,12 +549,9 @@ public void onFollowInfoAvailable(final int followers, final int followings) {
this.followersCount = followers;
this.followingCount = followings;
followInfoAvailable = true;
mHandler.post(new Runnable() {
@Override
public void run() {
setFollowerCount(followers);
setFollowingCount(followings);
}
mHandler.post(() -> {
setFollowerCount(followers);
setFollowingCount(followings);
});
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.hapramp.utils;

import android.content.Context;
import android.util.Log;

import com.hapramp.datastore.DataStore;
import com.hapramp.datastore.callbacks.FollowingsCallback;
Expand Down Expand Up @@ -51,6 +52,7 @@ public void onFollowingsAvailable(ArrayList<String> followings) {
if (followings.size() >= 19) {
fetchFollowingsFrom(lastUserInResult);
} else {
Log.d("UserInfo","fetched followings "+followings.toString());
HaprampPreferenceManager.getInstance().saveCurrentUserFollowings(followingList);
if (followingsSyncCompleteListener != null) {
followingsSyncCompleteListener.onSyncCompleted();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@

<include
android:id="@+id/metaView"
layout="@layout/article_meta_view"
layout="@layout/contest_participate_meta_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />

Expand Down
Loading