mirror of
https://github.com/viq/NewsBlur.git
synced 2025-09-18 21:43:31 +00:00
Added Add Follow flow.
This commit is contained in:
parent
9591dc55ab
commit
81a2de2347
2 changed files with 74 additions and 5 deletions
|
@ -84,6 +84,7 @@
|
|||
android:id="@+id/addsocial_autofollow_checkbox"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:checked="true"
|
||||
android:layout_below="@id/addsocial_facebook"
|
||||
android:layout_alignBaseline="@id/addsocial_autofollow_text"
|
||||
android:layout_toRightOf="@id/addsocial_autofollow_text" />
|
||||
|
|
|
@ -1,41 +1,109 @@
|
|||
package com.newsblur.fragment;
|
||||
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.newsblur.R;
|
||||
import com.newsblur.network.APIManager;
|
||||
|
||||
public class AddFollowFragment extends Fragment {
|
||||
|
||||
boolean followingNewsblur, followingPopular;
|
||||
private View parentView;
|
||||
private LinearLayout followingNewsblurButton, followingPopularButton;
|
||||
private LinearLayout followingNewsblurLayout, followingPopularLayout;
|
||||
private APIManager apiManager;
|
||||
private TextView followingNewsblurText;
|
||||
private CheckBox followingNewsblurCheckbox;
|
||||
private TextView followingPopularText;
|
||||
private CheckBox followingPopularCheckbox;
|
||||
private String TAG = "addFollowFragment";
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
apiManager = new APIManager(getActivity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
parentView = inflater.inflate(R.layout.fragment_addfollow, null);
|
||||
followingNewsblurButton = (LinearLayout) parentView.findViewById(R.id.addfollow_newsblur);
|
||||
followingPopularButton = (LinearLayout) parentView.findViewById(R.id.addfollow_popular);
|
||||
followingNewsblurLayout = (LinearLayout) parentView.findViewById(R.id.addfollow_newsblur);
|
||||
followingNewsblurText = (TextView) parentView.findViewById(R.id.addfollow_newsblur_text);
|
||||
followingNewsblurCheckbox = (CheckBox) parentView.findViewById(R.id.addfollow_newsblur_checkbox);
|
||||
|
||||
followingPopularLayout = (LinearLayout) parentView.findViewById(R.id.addfollow_popular);
|
||||
followingPopularText = (TextView) parentView.findViewById(R.id.addfollow_popular_text);
|
||||
followingPopularCheckbox = (CheckBox) parentView.findViewById(R.id.addfollow_popular_checkbox);
|
||||
|
||||
setupUI();
|
||||
|
||||
followingNewsblurCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
followingNewsblurCheckbox.setEnabled(false);
|
||||
|
||||
new AsyncTask<Void, Void, Void>() {
|
||||
@Override
|
||||
protected Void doInBackground(Void... arg0) {
|
||||
boolean addedOkay = apiManager.addFeed("http://blog.newsblur.com", null);
|
||||
Log.d(TAG, "Added okay: " + addedOkay);
|
||||
followingNewsblur = true;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Void result) {
|
||||
setupUI();
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
});
|
||||
|
||||
followingPopularCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
followingPopularCheckbox.setEnabled(false);
|
||||
|
||||
new AsyncTask<Void, Void, Void>() {
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... arg0) {
|
||||
|
||||
boolean addedOkay = apiManager.addFeed("http://popular.newsblur.com/", null);
|
||||
followingPopular = true;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Void result) {
|
||||
setupUI();
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
});
|
||||
|
||||
return parentView;
|
||||
}
|
||||
|
||||
private void setupUI() {
|
||||
if (followingNewsblur) {
|
||||
|
||||
followingNewsblurText.setText("Following Newsblur");
|
||||
followingNewsblurCheckbox.setEnabled(false);
|
||||
}
|
||||
|
||||
if (followingPopular) {
|
||||
|
||||
followingPopularText.setText("Following Popular");
|
||||
followingPopularCheckbox.setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue